From db8c3ee65f7d04cee9251a61c99de64943b13b49 Mon Sep 17 00:00:00 2001 From: moco Date: Thu, 5 Dec 2024 21:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B5=8B=E5=80=BC=E7=B2=98?= =?UTF-8?q?=E8=B4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PBAnaly/Module/BioanalysisMannage.cs | 136 +++++++++++++++--- src/PBAnaly/UI/BioanalyImagePanel.Designer.cs | 47 ++++++ src/PBAnaly/UI/BioanalyImagePanel.resx | 3 + 3 files changed, 168 insertions(+), 18 deletions(-) diff --git a/src/PBAnaly/Module/BioanalysisMannage.cs b/src/PBAnaly/Module/BioanalysisMannage.cs index 7ec99be..7468664 100644 --- a/src/PBAnaly/Module/BioanalysisMannage.cs +++ b/src/PBAnaly/Module/BioanalysisMannage.cs @@ -1,5 +1,6 @@ using AntdUI; using MiniExcelLibs; +using OpenCvSharp.Flann; using PBAnaly.UI; using PBBiologyVC; using ReaLTaiizor.Extension; @@ -58,8 +59,20 @@ namespace PBAnaly.Module public List points; public Pseudo_infoVC pdinfovc; } + + private enum ShapeForm + { + None, + Line, + Polygon, + Rect, + Circle + } #endregion #region 变量 + private ShapeForm curShape = ShapeForm.None; + private int curShapeIndex; + public int ImageIndex { get; set; }// 图片加载进来的序号 public bool Arrangement { get; set; } private Dictionary bioanalysisMannages; @@ -105,7 +118,9 @@ namespace PBAnaly.Module private bool rectOn = false; private bool linepolygonON = false; private bool isRecDragging = false; + private bool curIsCopy = false; // 是否需要拷贝 private List rectangles = new List(); // 存储所有绘制完成的矩形 + private RectAttribute oldCopyRect; //当前需要赋值的矩形 private System.Drawing.Rectangle? currentRectangle = null; // 当前正在绘制的矩形 private System.Drawing.Point leftTopPoint; // 矩形左上角的起始点 private bool drawRect = false; // 是否正在绘制 @@ -117,6 +132,7 @@ namespace PBAnaly.Module private bool drawCircle = false;//是否绘制圆 private bool isCirDragging = false; private List CircleAndInfoList = new List(); + private CirceAndInfo oldCopyCircle; private System.Drawing.Point cirDragStart; private System.Drawing.Point circleCenter; private System.Drawing.Point circleRadio; @@ -438,7 +454,9 @@ namespace PBAnaly.Module imagePanel.image_pl.MouseMove += Image_pl_MouseMove; imagePanel.image_pl.MouseUp += Image_pl_MouseUp; imagePanel.image_pl.Paint += Image_pl_Paint; - + imagePanel.ctms_strop_delete.Click += Ctms_strop_delete_Click; + imagePanel.ctms_strop_copy.Click += Ctms_strop_copy_Click; + imagePanel.ctms_strop_stickup.Click += Ctms_strop_stickup_Click; imagePaletteForm.hpb_line.Click += Hpb_line_Click; @@ -1598,35 +1616,117 @@ namespace PBAnaly.Module } - else if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { + imagePanel.ctms_strop.Enabled = true; + imagePanel.ctms_strop_copy.Enabled = false; + imagePanel.ctms_strop_stickup.Enabled = curIsCopy; if (ImageProcess.IsPointOnLine(readLoction,startPoint,endPoint,CircleRadius)) { + curShape = ShapeForm.Line; + + } + else if (IsPointInCircle(readLoction, CircleAndInfoList, out var cner1, out var curRect, out var index1)) + { + curShape = ShapeForm.Circle; + curShapeIndex = index1; + imagePanel.ctms_strop_copy.Enabled = true; + } + else if (IsPointInRectangles(readLoction, rectangles, out var cner, out var cr, out var index)) + { + curShape = ShapeForm.Rect; + curShapeIndex = index; + imagePanel.ctms_strop_copy.Enabled = true; + } + else if (drawpolygon==false && IsPointInPolygon(readLoction, curPolygonAndInfoList)) + { + curShape = ShapeForm.Polygon; + + } + + } + + } + private void Ctms_strop_copy_Click(object sender, EventArgs e) + { + // 复制矩形 目前只允许复制矩形和圆形 + switch (curShape) + { + case ShapeForm.None: + break; + case ShapeForm.Line: + break; + case ShapeForm.Polygon: + break; + case ShapeForm.Rect: + oldCopyRect = rectangles[curShapeIndex]; + curIsCopy = true; + break; + case ShapeForm.Circle: + oldCopyCircle = CircleAndInfoList[curShapeIndex]; + curIsCopy = true; + break; + default: + break; + } + } + private void Ctms_strop_stickup_Click(object sender, EventArgs e) + { + switch (curShape) + { + case ShapeForm.None: + break; + case ShapeForm.Line: + break; + case ShapeForm.Polygon: + break; + case ShapeForm.Rect: + + rectangles.Add(oldCopyRect); + + break; + case ShapeForm.Circle: + CircleAndInfoList.Add(oldCopyCircle); + break; + default: + break; + } + curIsCopy = false; + imagePanel.image_pl.Invalidate(); + } + private void Ctms_strop_delete_Click(object sender, EventArgs e) + { + switch (curShape) + { + case ShapeForm.None: + break; + case ShapeForm.Line: startPoint = new System.Drawing.Point(-10, 0); endPoint = new System.Drawing.Point(-10, 0); imagePanel.image_pl.Invalidate(); imagePaletteForm.flb_act_mm.Text = ("0"); imagePaletteForm.flb_act_mm.Refresh(); - } - else if (IsPointInCircle(readLoction, CircleAndInfoList, out var cner1, out var curRect, out var index1)) - { - CircleAndInfoList.RemoveAt(index1); - imagePanel.image_pl.Invalidate(); - } - else if (IsPointInRectangles(readLoction, rectangles, out var cner, out var cr, out var index)) - { - rectangles.RemoveAt(index); - imagePanel.image_pl.Invalidate(); - } - else if (drawpolygon==false && IsPointInPolygon(readLoction, curPolygonAndInfoList)) - { + break; + case ShapeForm.Polygon: PolygonAndInfoList.Clear(); curPolygonAndInfoList.points.Clear(); curPolygonAndInfoList.pdinfovc = null; - imagePanel.image_pl.Invalidate(); - } + + break; + case ShapeForm.Rect: + rectangles.RemoveAt(curShapeIndex); + + break; + case ShapeForm.Circle: + CircleAndInfoList.RemoveAt(curShapeIndex); + + + break; + default: + break; } - + curShape = ShapeForm.None; + imagePanel.image_pl.Invalidate(); } diff --git a/src/PBAnaly/UI/BioanalyImagePanel.Designer.cs b/src/PBAnaly/UI/BioanalyImagePanel.Designer.cs index 0baa80d..616f377 100644 --- a/src/PBAnaly/UI/BioanalyImagePanel.Designer.cs +++ b/src/PBAnaly/UI/BioanalyImagePanel.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.wdb_title = new AntdUI.WindowBar(); this.panel1 = new AntdUI.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); @@ -51,6 +52,11 @@ this.tlp_right_panel = new System.Windows.Forms.TableLayoutPanel(); this.lb_wh = new AntdUI.Label(); this.image_pr = new AntdUI.Image3D(); + this.ctms_strop = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.ctms_strop_copy = new System.Windows.Forms.ToolStripMenuItem(); + this.ctms_strop_stickup = new System.Windows.Forms.ToolStripMenuItem(); + this.ctms_strop_delete = new System.Windows.Forms.ToolStripMenuItem(); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.panel2.SuspendLayout(); @@ -61,6 +67,7 @@ this.pl_bg_panel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.image_pl)).BeginInit(); this.tlp_right_panel.SuspendLayout(); + this.ctms_strop.SuspendLayout(); this.SuspendLayout(); // // wdb_title @@ -299,6 +306,7 @@ // // image_pl // + this.image_pl.ContextMenuStrip = this.ctms_strop; this.image_pl.Dock = System.Windows.Forms.DockStyle.Fill; this.image_pl.Location = new System.Drawing.Point(0, 0); this.image_pl.Name = "image_pl"; @@ -348,6 +356,39 @@ this.image_pr.TabIndex = 1; this.image_pr.Text = "image3D1"; // + // ctms_strop + // + this.ctms_strop.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripSeparator1, + this.ctms_strop_copy, + this.ctms_strop_stickup, + this.ctms_strop_delete}); + this.ctms_strop.Name = "ctms_strop"; + this.ctms_strop.Size = new System.Drawing.Size(181, 98); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); + // + // ctms_strop_copy + // + this.ctms_strop_copy.Name = "ctms_strop_copy"; + this.ctms_strop_copy.Size = new System.Drawing.Size(180, 22); + this.ctms_strop_copy.Text = "复制"; + // + // ctms_strop_stickup + // + this.ctms_strop_stickup.Name = "ctms_strop_stickup"; + this.ctms_strop_stickup.Size = new System.Drawing.Size(180, 22); + this.ctms_strop_stickup.Text = "粘贴"; + // + // ctms_strop_delete + // + this.ctms_strop_delete.Name = "ctms_strop_delete"; + this.ctms_strop_delete.Size = new System.Drawing.Size(180, 22); + this.ctms_strop_delete.Text = "删除"; + // // BioanalyImagePanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -373,6 +414,7 @@ this.pl_bg_panel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.image_pl)).EndInit(); this.tlp_right_panel.ResumeLayout(false); + this.ctms_strop.ResumeLayout(false); this.ResumeLayout(false); } @@ -401,5 +443,10 @@ public AntdUI.Checkbox cb_scientific; private AntdUI.Label label2; public AntdUI.Label lb_imageIndex; + public System.Windows.Forms.ContextMenuStrip ctms_strop; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + public System.Windows.Forms.ToolStripMenuItem ctms_strop_copy; + public System.Windows.Forms.ToolStripMenuItem ctms_strop_stickup; + public System.Windows.Forms.ToolStripMenuItem ctms_strop_delete; } } \ No newline at end of file diff --git a/src/PBAnaly/UI/BioanalyImagePanel.resx b/src/PBAnaly/UI/BioanalyImagePanel.resx index 1af7de1..719a85a 100644 --- a/src/PBAnaly/UI/BioanalyImagePanel.resx +++ b/src/PBAnaly/UI/BioanalyImagePanel.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file