新增画矩形ROI #1
@ -81,6 +81,13 @@ namespace PBAnaly.Module
|
|||||||
private const int CircleRadius = 5;
|
private const int CircleRadius = 5;
|
||||||
private bool lineOn =false;
|
private bool lineOn =false;
|
||||||
private bool drawLine = false;
|
private bool drawLine = false;
|
||||||
|
|
||||||
|
private bool CircleOn = false;
|
||||||
|
private bool rectOn = false;
|
||||||
|
private List<System.Drawing.Rectangle> rectangles = new List<System.Drawing.Rectangle>(); // 存储所有绘制完成的矩形
|
||||||
|
private System.Drawing.Rectangle? currentRectangle = null; // 当前正在绘制的矩形
|
||||||
|
private System.Drawing.Point leftTopPoint; // 矩形左上角的起始点
|
||||||
|
private bool drawRect = false; // 是否正在绘制
|
||||||
private System.Drawing.Point startPoint = new System.Drawing.Point(-10, 0);
|
private System.Drawing.Point startPoint = new System.Drawing.Point(-10, 0);
|
||||||
private System.Drawing.Point endPoint = new System.Drawing.Point(-10, 0);
|
private System.Drawing.Point endPoint = new System.Drawing.Point(-10, 0);
|
||||||
|
|
||||||
@ -356,6 +363,7 @@ namespace PBAnaly.Module
|
|||||||
imagePaletteForm.cb_colortable.SelectedIndexChanged += Cb_colortable_SelectedIndexChanged;
|
imagePaletteForm.cb_colortable.SelectedIndexChanged += Cb_colortable_SelectedIndexChanged;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
imagePanel.cb_scientific.CheckedChanged += Cb_scientific_CheckedChanged;
|
imagePanel.cb_scientific.CheckedChanged += Cb_scientific_CheckedChanged;
|
||||||
|
|
||||||
imagePanel.image_pl.MouseDown += Image_pl_MouseDown;
|
imagePanel.image_pl.MouseDown += Image_pl_MouseDown;
|
||||||
@ -369,6 +377,7 @@ namespace PBAnaly.Module
|
|||||||
|
|
||||||
imagePanel.wdb_title.MouseDown += Wdb_title_Click;
|
imagePanel.wdb_title.MouseDown += Wdb_title_Click;
|
||||||
|
|
||||||
|
imagePaletteForm.hpb_rect.Click += hpb_rect_Click;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -618,6 +627,7 @@ namespace PBAnaly.Module
|
|||||||
{
|
{
|
||||||
Graphics g = e.Graphics;
|
Graphics g = e.Graphics;
|
||||||
|
|
||||||
|
|
||||||
// 绘制直线
|
// 绘制直线
|
||||||
if ((startPoint != System.Drawing.Point.Empty && endPoint != System.Drawing.Point.Empty))
|
if ((startPoint != System.Drawing.Point.Empty && endPoint != System.Drawing.Point.Empty))
|
||||||
{
|
{
|
||||||
@ -629,6 +639,21 @@ namespace PBAnaly.Module
|
|||||||
ImageProcess.DrawCircle(g, srart, CircleRadius, Pens.Blue, Brushes.LightBlue);
|
ImageProcess.DrawCircle(g, srart, CircleRadius, Pens.Blue, Brushes.LightBlue);
|
||||||
ImageProcess.DrawCircle(g, end, CircleRadius, Pens.Blue, Brushes.LightBlue);
|
ImageProcess.DrawCircle(g, end, CircleRadius, Pens.Blue, Brushes.LightBlue);
|
||||||
}
|
}
|
||||||
|
if(leftTopPoint != System.Drawing.Point.Empty)
|
||||||
|
{
|
||||||
|
// 绘制所有已绘制的矩形
|
||||||
|
foreach (var rect in rectangles)
|
||||||
|
{
|
||||||
|
e.Graphics.DrawRectangle(Pens.Blue, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绘制当前正在绘制的矩形
|
||||||
|
if (currentRectangle.HasValue)
|
||||||
|
{
|
||||||
|
e.Graphics.DrawRectangle(Pens.Red, currentRectangle.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Image_pl_MouseUp(object sender, MouseEventArgs e)
|
private void Image_pl_MouseUp(object sender, MouseEventArgs e)
|
||||||
@ -654,7 +679,21 @@ namespace PBAnaly.Module
|
|||||||
imagePaletteForm.flb_act_mm.Text = value.ToString() + " mm";
|
imagePaletteForm.flb_act_mm.Text = value.ToString() + " mm";
|
||||||
imagePaletteForm.flb_act_mm.Refresh();
|
imagePaletteForm.flb_act_mm.Refresh();
|
||||||
}
|
}
|
||||||
|
else if(drawRect && e.Button == MouseButtons.Left)
|
||||||
|
{
|
||||||
|
if (drawRect && currentRectangle.HasValue)
|
||||||
|
{
|
||||||
|
// 完成绘制并保存矩形
|
||||||
|
rectangles.Add(currentRectangle.Value);
|
||||||
|
currentRectangle = null;
|
||||||
|
drawRect = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawRect = false;
|
||||||
|
rectOn = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,6 +740,17 @@ namespace PBAnaly.Module
|
|||||||
{
|
{
|
||||||
imagePanel.image_pl.Cursor = Cursors.Hand;
|
imagePanel.image_pl.Cursor = Cursors.Hand;
|
||||||
}
|
}
|
||||||
|
else if(drawRect && e.Button == MouseButtons.Left)
|
||||||
|
{
|
||||||
|
// 动态调整矩形大小
|
||||||
|
int x = Math.Min(leftTopPoint.X, e.X);
|
||||||
|
int y = Math.Min(leftTopPoint.Y, e.Y);
|
||||||
|
int width = Math.Abs(e.X - leftTopPoint.X);
|
||||||
|
int height = Math.Abs(e.Y - leftTopPoint.Y);
|
||||||
|
|
||||||
|
currentRectangle = new System.Drawing.Rectangle(x, y, width, height);
|
||||||
|
imagePanel.image_pl.Invalidate(); // 触发重绘
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -742,6 +792,13 @@ namespace PBAnaly.Module
|
|||||||
isEndCircleDragged = true;
|
isEndCircleDragged = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (rectOn)
|
||||||
|
{
|
||||||
|
// 开始绘制新矩形
|
||||||
|
drawRect = true;
|
||||||
|
leftTopPoint = e.Location;
|
||||||
|
currentRectangle = new System.Drawing.Rectangle(e.X, e.Y, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (e.Button == MouseButtons.Right)
|
else if (e.Button == MouseButtons.Right)
|
||||||
{
|
{
|
||||||
@ -763,6 +820,11 @@ namespace PBAnaly.Module
|
|||||||
{
|
{
|
||||||
lineOn = true;
|
lineOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hpb_rect_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
rectOn = true;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
#region 对外接口
|
#region 对外接口
|
||||||
|
13
src/PBAnaly/UI/BioanayImagePaletteForm.Designer.cs
generated
13
src/PBAnaly/UI/BioanayImagePaletteForm.Designer.cs
generated
@ -358,7 +358,7 @@
|
|||||||
this.tableLayoutPanel3.RowCount = 2;
|
this.tableLayoutPanel3.RowCount = 2;
|
||||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F));
|
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 34F));
|
||||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(268, 113);
|
this.tableLayoutPanel3.Size = new System.Drawing.Size(266, 113);
|
||||||
this.tableLayoutPanel3.TabIndex = 0;
|
this.tableLayoutPanel3.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// hpb_circe
|
// hpb_circe
|
||||||
@ -388,16 +388,17 @@
|
|||||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.panel2.Location = new System.Drawing.Point(3, 37);
|
this.panel2.Location = new System.Drawing.Point(3, 37);
|
||||||
this.panel2.Name = "panel2";
|
this.panel2.Name = "panel2";
|
||||||
this.panel2.Size = new System.Drawing.Size(262, 73);
|
this.panel2.Size = new System.Drawing.Size(260, 73);
|
||||||
this.panel2.TabIndex = 14;
|
this.panel2.TabIndex = 14;
|
||||||
this.panel2.Text = "panel2";
|
this.panel2.Text = "panel2";
|
||||||
//
|
//
|
||||||
// collapseItem2
|
// collapseItem2
|
||||||
//
|
//
|
||||||
this.collapseItem2.Controls.Add(this.tableLayoutPanel3);
|
this.collapseItem2.Controls.Add(this.tableLayoutPanel3);
|
||||||
this.collapseItem2.Location = new System.Drawing.Point(-268, -113);
|
this.collapseItem2.Expand = true;
|
||||||
|
this.collapseItem2.Location = new System.Drawing.Point(19, 433);
|
||||||
this.collapseItem2.Name = "collapseItem2";
|
this.collapseItem2.Name = "collapseItem2";
|
||||||
this.collapseItem2.Size = new System.Drawing.Size(268, 113);
|
this.collapseItem2.Size = new System.Drawing.Size(266, 113);
|
||||||
this.collapseItem2.TabIndex = 1;
|
this.collapseItem2.TabIndex = 1;
|
||||||
this.collapseItem2.Text = "ROI工具";
|
this.collapseItem2.Text = "ROI工具";
|
||||||
//
|
//
|
||||||
@ -660,7 +661,7 @@
|
|||||||
// collapseItem3
|
// collapseItem3
|
||||||
//
|
//
|
||||||
this.collapseItem3.Expand = true;
|
this.collapseItem3.Expand = true;
|
||||||
this.collapseItem3.Location = new System.Drawing.Point(19, 473);
|
this.collapseItem3.Location = new System.Drawing.Point(19, 618);
|
||||||
this.collapseItem3.Margin = new System.Windows.Forms.Padding(2);
|
this.collapseItem3.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.collapseItem3.Name = "collapseItem3";
|
this.collapseItem3.Name = "collapseItem3";
|
||||||
this.collapseItem3.Size = new System.Drawing.Size(266, 154);
|
this.collapseItem3.Size = new System.Drawing.Size(266, 154);
|
||||||
@ -718,7 +719,6 @@
|
|||||||
private ReaLTaiizor.Controls.HopePictureBox hpb_wand;
|
private ReaLTaiizor.Controls.HopePictureBox hpb_wand;
|
||||||
private ReaLTaiizor.Controls.HopePictureBox hpb_xianduan;
|
private ReaLTaiizor.Controls.HopePictureBox hpb_xianduan;
|
||||||
private ReaLTaiizor.Controls.FoxTextBox ftb_r;
|
private ReaLTaiizor.Controls.FoxTextBox ftb_r;
|
||||||
private ReaLTaiizor.Controls.HopePictureBox hpb_rect;
|
|
||||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
||||||
private ReaLTaiizor.Controls.HopePictureBox hpb_circe;
|
private ReaLTaiizor.Controls.HopePictureBox hpb_circe;
|
||||||
private AntdUI.Panel panel2;
|
private AntdUI.Panel panel2;
|
||||||
@ -739,5 +739,6 @@
|
|||||||
public System.Windows.Forms.ComboBox cb_colortable;
|
public System.Windows.Forms.ComboBox cb_colortable;
|
||||||
public ReaLTaiizor.Controls.HopePictureBox hpb_line;
|
public ReaLTaiizor.Controls.HopePictureBox hpb_line;
|
||||||
public ReaLTaiizor.Controls.FoxLabel flb_act_mm;
|
public ReaLTaiizor.Controls.FoxLabel flb_act_mm;
|
||||||
|
public ReaLTaiizor.Controls.HopePictureBox hpb_rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user