diff --git a/.vs/VisionEdit/v14/.suo b/.vs/VisionEdit/v14/.suo index 33a5d43..d98717b 100644 Binary files a/.vs/VisionEdit/v14/.suo and b/.vs/VisionEdit/v14/.suo differ diff --git a/CaliperTool/Caliper.cs b/CaliperTool/Caliper.cs index 0f1c3ac..0e5634c 100644 --- a/CaliperTool/Caliper.cs +++ b/CaliperTool/Caliper.cs @@ -4,7 +4,7 @@ using HalconDotNet; using ToolBase; using static DataStruct.DataStruct; using ChoiceTech.Halcon.Control; - +using ViewROI; namespace CaliperTool { @@ -114,7 +114,7 @@ namespace CaliperTool { if (inputImage != null) { - FormCaliper.Instance.myHwindow.HalconWindow.DispObj(inputImage); + FormCaliper.Instance.myHwindow.DispHWindow.DispObj(inputImage); } } @@ -158,7 +158,7 @@ namespace CaliperTool public void UpdateImage() { - FormCaliper.Instance.myHwindow.HalconWindow.ClearWindow(); + FormCaliper.Instance.myHwindow.DispHWindow.ClearWindow(); DispImage(); } @@ -211,7 +211,7 @@ namespace CaliperTool HOperatorSet.GenCrossContourXld(out crossDisp, ResulttRow, ResultCol, new HTuple(80), new HTuple(0)); if(softwareRunState == SoftwareRunState.Debug) { - DispMainWindow(FormCaliper.Instance.myHwindow.HalconWindow); + DispMainWindow(FormCaliper.Instance.myHwindow); FormCaliper.Instance.tbx_resultStartRow.Text = ResulttRow.ToString(); FormCaliper.Instance.tbx_resultStartCol.Text = ResultCol.ToString(); FormCaliper.Instance.SetToolStatus("运行成功", ToolRunStatu.Succeed); @@ -250,19 +250,19 @@ namespace CaliperTool } - public override void DispMainWindow(HWindow window) + public override void DispMainWindow(HWindowTool_Smart window) { // 显示矩形 if (dispRec && contoursDisp != null) { - window.SetColor("blue"); - window.DispObj(contoursDisp); + window.DispHWindow.SetColor("blue"); + window.DispHWindow.DispObj(contoursDisp); } // 显示交点 if (dispCross && crossDisp != null) { - window.SetColor("green"); - window.DispObj(crossDisp); + window.DispHWindow.SetColor("green"); + window.DispHWindow.DispObj(crossDisp); } //显示找到的线 // window.DispObj(LineDisp, "green"); diff --git a/CaliperTool/CaliperToolRun.cs b/CaliperTool/CaliperToolRun.cs index 0b53175..58d8fc7 100644 --- a/CaliperTool/CaliperToolRun.cs +++ b/CaliperTool/CaliperToolRun.cs @@ -73,7 +73,7 @@ namespace CaliperTool myCaliper.Run(SoftwareRunState.Release); if (myCaliper.toolRunStatu == ToolRunStatu.Succeed) { - myCaliper.DispMainWindow(FormImageWindow.Instance.myHWindow.DispHWindow); + myCaliper.DispMainWindow(FormImageWindow.Instance.myHWindow); myJob.FormLogDisp(L_toolList[toolIndex].toolName + " 运行成功", Color.Green, selectNode); } else diff --git a/CaliperTool/FormCaliper.cs b/CaliperTool/FormCaliper.cs index b059a39..7919623 100644 --- a/CaliperTool/FormCaliper.cs +++ b/CaliperTool/FormCaliper.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using CommonMethods; using ChoiceTech.Halcon.Control; using HalconDotNet; +using ViewROI; namespace CaliperTool { @@ -18,7 +19,7 @@ namespace CaliperTool public Caliper myCaliper = null; public IToolInfo myToolInfo = null; - public HSmartWindowControl myHwindow = new HSmartWindowControl(); + public HWindowTool_Smart myHwindow = new HWindowTool_Smart(); private static FormCaliper _instance; public FormCaliper(ref object caliper) @@ -90,7 +91,7 @@ namespace CaliperTool private void btn_moveCliperRegion_Click(object sender, EventArgs e) { myCaliper.UpdateImage(); - myCaliper.DrawExpectLine(myHwindow.HalconWindow); + myCaliper.DrawExpectLine(myHwindow.DispHWindow); } private void btn_runCaliperool_Click(object sender, EventArgs e) diff --git a/FindCircle/FindCircle.cs b/FindCircle/FindCircle.cs index b28977a..0fe8c0b 100644 --- a/FindCircle/FindCircle.cs +++ b/FindCircle/FindCircle.cs @@ -3,6 +3,7 @@ using HalconDotNet; using static DataStruct.DataStruct; using ToolBase; using CommonMethods; +using ViewROI; namespace FindCircle { @@ -112,7 +113,7 @@ namespace FindCircle } - public override void DispMainWindow(HWindow window) + public override void DispMainWindow(HWindowTool_Smart window) { throw new NotImplementedException(); } diff --git a/FindLine/FindLine.cs b/FindLine/FindLine.cs index f3ae92f..2ca7fba 100644 --- a/FindLine/FindLine.cs +++ b/FindLine/FindLine.cs @@ -4,6 +4,7 @@ using static DataStruct.DataStruct; using ToolBase; using CommonMethods; using System.Diagnostics; +using ViewROI; namespace FindLineTool { @@ -334,22 +335,30 @@ namespace FindLineTool Point start = new Point() { Row = ResultLineStartRow, Col = ResultLineStartCol }; Point end = new Point() { Row = ResultLineEndRow, Col = ResultLineEndCol }; resultLine = new Line() { StartPoint = start, EndPoint = end }; + HOperatorSet.AngleLx(ResultLineStartRow, ResultLineStartCol, ResultLineEndRow, ResultLineEndCol, out _angle); + if (softwareRunState == SoftwareRunState.Debug) + { + DispMainWindow(FormFindLine.Instance.myHwindow); + FormFindLine.Instance.tbx_resultStartRow.Text = ResultLineStartRow.ToString(); + FormFindLine.Instance.tbx_resultStartCol.Text = ResultLineEndCol.ToString(); + FormFindLine.Instance.tbx_resultEndRow.Text = ResultLineEndRow.ToString(); + FormFindLine.Instance.tbx_resultEndCol.Text = ResultLineEndCol.ToString(); + } + runMessage = "工具运行成功,已找到线!"; + toolRunStatu = ToolRunStatu.Succeed; } - HOperatorSet.AngleLx(ResultLineStartRow, ResultLineStartCol, ResultLineEndRow, ResultLineEndCol, out _angle); - if (softwareRunState == SoftwareRunState.Debug) + else { - DispMainWindow(FormFindLine.Instance.myHwindow.DispHWindow); - FormFindLine.Instance.tbx_resultStartRow.Text = ResultLineStartRow.ToString(); - FormFindLine.Instance.tbx_resultStartCol.Text = ResultLineEndCol.ToString(); - FormFindLine.Instance.tbx_resultEndRow.Text = ResultLineEndRow.ToString(); - FormFindLine.Instance.tbx_resultEndCol.Text = ResultLineEndCol.ToString(); + runMessage = "工具运行失败,未找到线"; + toolRunStatu = ToolRunStatu.Tool_Run_Error; } - HOperatorSet.ClearMetrologyModel(handleID); + // 参数传递 ParamsTrans(); sw.Stop(); runTime = $"运行时间: {sw.ElapsedMilliseconds} ms"; - FormFindLine.Instance.SetToolStatus("工具运行成功!", ToolRunStatu.Succeed); + FormFindLine.Instance.SetToolStatus(runMessage, toolRunStatu); + HOperatorSet.ClearMetrologyModel(handleID); } catch (Exception ex) { @@ -357,6 +366,7 @@ namespace FindLineTool } finally { + //homMat2DArrow.Dispose(); //arrow.Dispose(); //arrowTrans.Dispose(); @@ -375,23 +385,23 @@ namespace FindLineTool FormFindLine.Instance.myToolInfo.toolOutput.Add(new ToolIO("EndPoint.Column", ResultLineEndCol, DataType.IntValue)); } - public override void DispMainWindow(HWindow window) + public override void DispMainWindow(HWindowTool_Smart window) { // 显示矩形 if (dispRec) { - window.SetColor("blue"); - window.DispObj(contoursDisp); + window.DispHWindow.SetColor("blue"); + window.DispHWindow.DispObj(contoursDisp); } // 显示交点 if (dispCross) { - window.SetColor("orange"); - window.DispObj(crossDisp); + window.DispHWindow.SetColor("orange"); + window.DispHWindow.DispObj(crossDisp); } //显示找到的线 - window.SetColor("green"); - window.DispObj(LineDisp); + window.DispHWindow.SetColor("green"); + window.DispHWindow.DispObj(LineDisp); } } diff --git a/FindLine/FindLineToolRun.cs b/FindLine/FindLineToolRun.cs index e3b32f7..4fa0c56 100644 --- a/FindLine/FindLineToolRun.cs +++ b/FindLine/FindLineToolRun.cs @@ -74,7 +74,7 @@ namespace FindLineTool else { myJob.FormLogDisp($"{L_toolList[toolIndex].toolName} 运行成功,{myFindLine.runTime}", Color.Green, selectNode); - myFindLine.DispMainWindow(FormImageWindow.Instance.myHWindow.DispHWindow); + myFindLine.DispMainWindow(FormImageWindow.Instance.myHWindow); } } } diff --git a/FindLine/FormFindLine.cs b/FindLine/FormFindLine.cs index d363b8a..65befc5 100644 --- a/FindLine/FormFindLine.cs +++ b/FindLine/FormFindLine.cs @@ -95,6 +95,8 @@ namespace FindLineTool selected_drawing_object.OnResize(OnSelectDrawingObject); selected_drawing_object.OnDrag(OnSelectDrawingObject); myHwindow.DispHWindow.AttachDrawingObjectToWindow(selected_drawing_object); + + tsbtRunTool_Click(null, null); isInit = false; } /// diff --git a/HalconTool/HalconTool.cs b/HalconTool/HalconTool.cs index ae0d42e..9c9aa27 100644 --- a/HalconTool/HalconTool.cs +++ b/HalconTool/HalconTool.cs @@ -9,6 +9,7 @@ using CommonMethods; using HalconDotNet; using ToolBase; using System.Diagnostics; +using ViewROI; namespace HalconTool { @@ -159,7 +160,7 @@ namespace HalconTool } } - public override void DispMainWindow(HWindow window) + public override void DispMainWindow(HWindowTool_Smart window) { throw new NotImplementedException(); } diff --git a/HalconTool/HalconToolRun.cs b/HalconTool/HalconToolRun.cs index 68d12dc..cd3dc4a 100644 --- a/HalconTool/HalconToolRun.cs +++ b/HalconTool/HalconToolRun.cs @@ -40,7 +40,7 @@ namespace HalconTool else { myJob.FormLogDisp($"{L_toolList[toolIndex].toolName} 运行成功,{myHalconTool.runTime}", Color.Green, selectNode); - FormImageWindow.Instance.myHWindow.DispHWindow.DispObj(myHalconTool.outputImage); + FormImageWindow.Instance.myHWindow.DispImage(myHalconTool.outputImage); L_toolList[toolIndex].toolOutput[0] = new ToolIO("OutputImage", myHalconTool.outputImage, DataType.Image); } } diff --git a/ImageWindow/HWindowTool_Smart.Designer.cs b/ImageWindow/HWindowTool_Smart.Designer.cs index e191e0f..0275386 100644 --- a/ImageWindow/HWindowTool_Smart.Designer.cs +++ b/ImageWindow/HWindowTool_Smart.Designer.cs @@ -29,15 +29,17 @@ namespace ViewROI private void InitializeComponent() { this.SmartWindow = new HalconDotNet.HSmartWindowControl(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.lb_Status = new System.Windows.Forms.ToolStripStatusLabel(); - this.statusStrip.SuspendLayout(); + this.uiContextMenuStrip1 = new Sunny.UI.UIContextMenuStrip(); + this.tsmiDispCorr = new System.Windows.Forms.ToolStripMenuItem(); + this.grayValueLable = new Sunny.UI.UISymbolLabel(); + this.uiContextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // SmartWindow // this.SmartWindow.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.SmartWindow.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange; + this.SmartWindow.ContextMenuStrip = this.uiContextMenuStrip1; this.SmartWindow.Dock = System.Windows.Forms.DockStyle.Fill; this.SmartWindow.HDoubleClickToFitContent = true; this.SmartWindow.HDrawingObjectsModifier = HalconDotNet.HSmartWindowControl.DrawingObjectsModifier.None; @@ -53,45 +55,57 @@ namespace ViewROI this.SmartWindow.WindowSize = new System.Drawing.Size(576, 457); this.SmartWindow.HMouseMove += new HalconDotNet.HMouseEventHandler(this.SmartWindow_HMouseMove); // - // statusStrip + // uiContextMenuStrip1 // - this.statusStrip.BackColor = System.Drawing.Color.White; - this.statusStrip.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.lb_Status}); - this.statusStrip.Location = new System.Drawing.Point(0, 435); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(576, 22); - this.statusStrip.TabIndex = 1; - this.statusStrip.Text = "statusStrip1"; - this.statusStrip.Visible = false; + this.uiContextMenuStrip1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiContextMenuStrip1.IsScaled = false; + this.uiContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsmiDispCorr}); + this.uiContextMenuStrip1.Name = "uiContextMenuStrip1"; + this.uiContextMenuStrip1.Size = new System.Drawing.Size(145, 30); // - // lb_Status + // tsmiDispCorr // - this.lb_Status.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lb_Status.Name = "lb_Status"; - this.lb_Status.Size = new System.Drawing.Size(0, 17); + this.tsmiDispCorr.Name = "tsmiDispCorr"; + this.tsmiDispCorr.Size = new System.Drawing.Size(144, 26); + this.tsmiDispCorr.Text = "显示坐标"; + this.tsmiDispCorr.Click += new System.EventHandler(this.tsmiDispCorr_Click); + // + // grayValueLable + // + this.grayValueLable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.grayValueLable.BackColor = System.Drawing.Color.Transparent; + this.grayValueLable.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.grayValueLable.IsScaled = false; + this.grayValueLable.Location = new System.Drawing.Point(3, 430); + this.grayValueLable.MinimumSize = new System.Drawing.Size(1, 1); + this.grayValueLable.Name = "grayValueLable"; + this.grayValueLable.Padding = new System.Windows.Forms.Padding(28, 0, 0, 0); + this.grayValueLable.Size = new System.Drawing.Size(260, 26); + this.grayValueLable.Symbol = 61483; + this.grayValueLable.TabIndex = 4; + this.grayValueLable.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.grayValueLable.Visible = false; // // HWindowTool_Smart // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.statusStrip); + this.Controls.Add(this.grayValueLable); this.Controls.Add(this.SmartWindow); this.Name = "HWindowTool_Smart"; this.Size = new System.Drawing.Size(576, 457); this.Load += new System.EventHandler(this.HWindowTool_Smart_Load); this.SizeChanged += new System.EventHandler(this.HWindowTool_Smart_SizeChanged); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); + this.uiContextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.ToolStripStatusLabel lb_Status; public HalconDotNet.HSmartWindowControl SmartWindow; + private Sunny.UI.UIContextMenuStrip uiContextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem tsmiDispCorr; + private Sunny.UI.UISymbolLabel grayValueLable; } } diff --git a/ImageWindow/HWindowTool_Smart.cs b/ImageWindow/HWindowTool_Smart.cs index 74aa01a..8392466 100644 --- a/ImageWindow/HWindowTool_Smart.cs +++ b/ImageWindow/HWindowTool_Smart.cs @@ -14,6 +14,8 @@ namespace ViewROI { public bool DispStatus { get; set; } public HImage hv_Image { get; set; } + HTuple hv_Width = new HTuple(); + HTuple hv_Height = new HTuple(); public HWindow DispHWindow { get @@ -27,22 +29,112 @@ namespace ViewROI } public void DispImage(HObject inputImage) { - statusStrip.BackColor = Color.White; if (inputImage == null || !inputImage.IsInitialized()) { - this.lb_Status.Text = "输入图像为空,请检查!"; - statusStrip.BackColor = Color.Red; return; } - this.SmartWindow.HalconWindow.DispImage(new HImage(inputImage)); + + + #region 缩放图像,适应窗口 + //获取图像大小及纵横比 + HOperatorSet.GetImageSize(inputImage, out hv_Width, out hv_Height); + int im_width = int.Parse(hv_Width.ToString()); + int im_height = int.Parse(hv_Height.ToString()); + double im_AspectRatio = (double)(im_width) / (double)(im_height); + //获取窗口大小及纵横比 + int w_width = SmartWindow.Size.Width; + int w_height = SmartWindow.Size.Height; + double w_AspectRatio = (double)(w_width) / (double)(w_height); + + HOperatorSet.SetSystem("int_zooming", "false");//图像缩放之前最好将此参数设置为false. + HTuple para = new HTuple("constant"); + HObject ho_zoomImage; + HOperatorSet.GenEmptyObj(out ho_zoomImage); + + ho_zoomImage.Dispose(); + if (w_width < im_width && im_AspectRatio > w_AspectRatio) + { + //超宽图像 + HOperatorSet.ZoomImageSize(inputImage, out ho_zoomImage, w_width, w_width / im_AspectRatio, para); + } + else if (w_height < im_height && im_AspectRatio < w_AspectRatio) + { + //超高图像 + HOperatorSet.ZoomImageSize(inputImage, out ho_zoomImage, w_height * im_AspectRatio, w_height, para); + } + #endregion + SmartWindow.HalconWindow.SetPart(0, 0,-2, -2); + hv_Image = new HImage(inputImage); + SmartWindow.HalconWindow.DispImage(hv_Image); + ho_zoomImage.Dispose(); + hv_Width.Dispose(); + hv_Height.Dispose(); } private void SmartWindow_HMouseMove(object sender, HalconDotNet.HMouseEventArgs e) { - this.Cursor = e.Button == MouseButtons.Left ? Cursors.Hand : Cursors.Default; + // this.Cursor = e.Button == MouseButtons.Left ? Cursors.Hand : Cursors.Default; if(DispStatus) { + if (hv_Image != null && hv_Image.IsInitialized()) + { + try + { + int button_state; + double positionX, positionY; + string str_value; + string str_position; + bool _isXOut = true, _isYOut = true; + HTuple channel_count; + HOperatorSet.CountChannels(hv_Image, out channel_count); + + SmartWindow.HalconWindow.GetMpositionSubPix(out positionY, out positionX, out button_state); + str_position = String.Format("RC: {0:0},{1:0}", positionY, positionX); + + _isXOut = (positionX < 0 || positionX >= hv_Width); + _isYOut = (positionY < 0 || positionY >= hv_Height); + + if (!_isXOut && !_isYOut) + { + if ((int)channel_count == 1) + { + double grayVal; + grayVal = hv_Image.GetGrayval((int)positionY, (int)positionX); + str_value = String.Format("Val: {0:000}", grayVal); + } + else if ((int)channel_count == 3) + { + double grayValRed, grayValGreen, grayValBlue; + + HImage _RedChannel, _GreenChannel, _BlueChannel; + + _RedChannel = hv_Image.AccessChannel(1); + _GreenChannel = hv_Image.AccessChannel(2); + _BlueChannel = hv_Image.AccessChannel(3); + + grayValRed = _RedChannel.GetGrayval((int)positionY, (int)positionX); + grayValGreen = _GreenChannel.GetGrayval((int)positionY, (int)positionX); + grayValBlue = _BlueChannel.GetGrayval((int)positionY, (int)positionX); + + _RedChannel.Dispose(); + _GreenChannel.Dispose(); + _BlueChannel.Dispose(); + + str_value = String.Format("Gray: ({0:000}, {1:000}, {2:000})", grayValRed, grayValGreen, grayValBlue); + } + else + { + str_value = ""; + } + grayValueLable.Text = $"Ch{channel_count.D }, {str_position}: {str_value}"; + } + } + catch (Exception ex) + { + //不处理 + } + } } } @@ -64,5 +156,21 @@ namespace ViewROI //Point pt2 = SmartWindow.PointToScreen(pt); //this.SmartWindow.HalconWindow.SendMouseDoubleClickEvent(pt2.X+20, pt2.Y+30,(int)MouseButtons.Left); } + + private void tsmiDispCorr_Click(object sender, EventArgs e) + { + if(tsmiDispCorr.Checked) + { + tsmiDispCorr.Checked = false; + DispStatus = false; + grayValueLable.Visible = false; + } + else + { + tsmiDispCorr.Checked = true; + DispStatus = true; + grayValueLable.Visible = true; + } + } } } diff --git a/ImageWindow/HWindowTool_Smart.resx b/ImageWindow/HWindowTool_Smart.resx index 648e4b5..a0f97ba 100644 --- a/ImageWindow/HWindowTool_Smart.resx +++ b/ImageWindow/HWindowTool_Smart.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 + + 16, 14 \ No newline at end of file diff --git a/ImageWindow/HWindow_Final.resx b/ImageWindow/HWindow_Final.resx index adf7c83..589e3e9 100644 --- a/ImageWindow/HWindow_Final.resx +++ b/ImageWindow/HWindow_Final.resx @@ -112,20 +112,20 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADk - CAAAAk1TRnQBSQFMAgEBAgEAARABAQEQAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAASABAQEgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -166,7 +166,7 @@ Cw== - + \ No newline at end of file diff --git a/ImageWindow/HWindow_Tool.csproj b/ImageWindow/HWindow_Tool.csproj index 60ad7a2..b5caeb7 100644 --- a/ImageWindow/HWindow_Tool.csproj +++ b/ImageWindow/HWindow_Tool.csproj @@ -84,6 +84,9 @@ False C:\Program Files\MVTec\HALCON-19.05-Progress\bin\dotnet20\halcondotnet.dll + + ..\VisionEdit\bin\Debug\ThirdLib\SunnyUI.dll + diff --git a/PMAlignTool/FormPMAlignTool.Designer.cs b/PMAlignTool/FormPMAlignTool.Designer.cs index 47a065f..87ecad1 100644 --- a/PMAlignTool/FormPMAlignTool.Designer.cs +++ b/PMAlignTool/FormPMAlignTool.Designer.cs @@ -29,6 +29,10 @@ namespace PMAlignTool private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormPMAlignTool)); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.statusStrip = new System.Windows.Forms.StatusStrip(); this.lb_RunStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); @@ -77,7 +81,7 @@ namespace PMAlignTool this.cbCErosion1 = new System.Windows.Forms.CheckBox(); this.cbCErosion2 = new System.Windows.Forms.CheckBox(); this.btnCreateModel = new System.Windows.Forms.Button(); - this.btnAcqNewModelImage = new System.Windows.Forms.Button(); + this.btnChangeModel = new System.Windows.Forms.Button(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.panel4 = new System.Windows.Forms.Panel(); @@ -118,14 +122,13 @@ namespace PMAlignTool this.cbx_showTemplate = new System.Windows.Forms.CheckBox(); this.ckb_showFeature = new System.Windows.Forms.CheckBox(); this.ckb_showCross = new System.Windows.Forms.CheckBox(); - this.tabPage5 = new System.Windows.Forms.TabPage(); - this.panel7 = new System.Windows.Forms.Panel(); - this.dgv_matchResult = new System.Windows.Forms.DataGridView(); - this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.dgv_matchResult = new Sunny.UI.UIDataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.statusStrip.SuspendLayout(); this.toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -152,8 +155,7 @@ namespace PMAlignTool this.panel5.SuspendLayout(); this.tabPage4.SuspendLayout(); this.panel6.SuspendLayout(); - this.tabPage5.SuspendLayout(); - this.panel7.SuspendLayout(); + this.tabPage3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgv_matchResult)).BeginInit(); this.SuspendLayout(); // @@ -166,7 +168,7 @@ namespace PMAlignTool this.lb_RunTime}); this.statusStrip.Location = new System.Drawing.Point(0, 633); this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(999, 22); + this.statusStrip.Size = new System.Drawing.Size(1007, 22); this.statusStrip.TabIndex = 0; // // lb_RunStatus @@ -192,7 +194,7 @@ namespace PMAlignTool this.tsbtRunTool}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(999, 32); + this.toolStrip1.Size = new System.Drawing.Size(1007, 32); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; // @@ -218,8 +220,8 @@ namespace PMAlignTool // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.tabControl1); - this.splitContainer1.Size = new System.Drawing.Size(999, 601); - this.splitContainer1.SplitterDistance = 599; + this.splitContainer1.Size = new System.Drawing.Size(1007, 601); + this.splitContainer1.SplitterDistance = 603; this.splitContainer1.TabIndex = 2; // // panel1 @@ -228,7 +230,7 @@ namespace PMAlignTool this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(599, 601); + this.panel1.Size = new System.Drawing.Size(603, 601); this.panel1.TabIndex = 0; // // tabControl1 @@ -236,13 +238,13 @@ namespace PMAlignTool this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage4); - this.tabControl1.Controls.Add(this.tabPage5); + this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(396, 601); + this.tabControl1.Size = new System.Drawing.Size(400, 601); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -251,7 +253,7 @@ namespace PMAlignTool this.tabPage1.Location = new System.Drawing.Point(4, 29); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(388, 568); + this.tabPage1.Size = new System.Drawing.Size(392, 568); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "模板"; this.tabPage1.UseVisualStyleBackColor = true; @@ -278,7 +280,7 @@ namespace PMAlignTool this.tableLayoutPanel1.Controls.Add(this.panel10, 0, 6); this.tableLayoutPanel1.Controls.Add(this.panel14, 0, 8); this.tableLayoutPanel1.Controls.Add(this.btnCreateModel, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.btnAcqNewModelImage, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.btnChangeModel, 1, 1); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -293,7 +295,7 @@ namespace PMAlignTool this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.405694F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.20996F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15.12456F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(382, 562); + this.tableLayoutPanel1.Size = new System.Drawing.Size(386, 562); this.tableLayoutPanel1.TabIndex = 0; // // panel13 @@ -304,7 +306,7 @@ namespace PMAlignTool this.panel13.Dock = System.Windows.Forms.DockStyle.Fill; this.panel13.Location = new System.Drawing.Point(3, 382); this.panel13.Name = "panel13"; - this.panel13.Size = new System.Drawing.Size(376, 29); + this.panel13.Size = new System.Drawing.Size(380, 29); this.panel13.TabIndex = 126; // // label4 @@ -326,7 +328,7 @@ namespace PMAlignTool this.panel9.Dock = System.Windows.Forms.DockStyle.Fill; this.panel9.Location = new System.Drawing.Point(3, 254); this.panel9.Name = "panel9"; - this.panel9.Size = new System.Drawing.Size(376, 23); + this.panel9.Size = new System.Drawing.Size(380, 23); this.panel9.TabIndex = 124; // // label3 @@ -349,7 +351,7 @@ namespace PMAlignTool this.hWindowTool_Smart1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.hWindowTool_Smart1.Name = "hWindowTool_Smart1"; this.tableLayoutPanel1.SetRowSpan(this.hWindowTool_Smart1, 3); - this.hWindowTool_Smart1.Size = new System.Drawing.Size(226, 169); + this.hWindowTool_Smart1.Size = new System.Drawing.Size(228, 169); this.hWindowTool_Smart1.TabIndex = 0; // // panel3 @@ -360,7 +362,7 @@ namespace PMAlignTool this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; this.panel3.Location = new System.Drawing.Point(3, 182); this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(376, 22); + this.panel3.Size = new System.Drawing.Size(380, 22); this.panel3.TabIndex = 121; // // label1 @@ -382,7 +384,7 @@ namespace PMAlignTool this.panel8.Dock = System.Windows.Forms.DockStyle.Fill; this.panel8.Location = new System.Drawing.Point(3, 210); this.panel8.Name = "panel8"; - this.panel8.Size = new System.Drawing.Size(376, 38); + this.panel8.Size = new System.Drawing.Size(380, 38); this.panel8.TabIndex = 122; // // panel18 @@ -392,7 +394,7 @@ namespace PMAlignTool this.panel18.Dock = System.Windows.Forms.DockStyle.Fill; this.panel18.Location = new System.Drawing.Point(0, 0); this.panel18.Name = "panel18"; - this.panel18.Size = new System.Drawing.Size(376, 38); + this.panel18.Size = new System.Drawing.Size(380, 38); this.panel18.TabIndex = 147; // // rabGray @@ -430,9 +432,9 @@ namespace PMAlignTool this.groupBox1.Controls.Add(this.rabFormLocal); this.groupBox1.Controls.Add(this.rabFormFlow); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(237, 3); + this.groupBox1.Location = new System.Drawing.Point(239, 3); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(142, 79); + this.groupBox1.Size = new System.Drawing.Size(144, 79); this.groupBox1.TabIndex = 123; this.groupBox1.TabStop = false; this.groupBox1.Text = "模板图像来源"; @@ -478,7 +480,7 @@ namespace PMAlignTool this.panel10.Dock = System.Windows.Forms.DockStyle.Fill; this.panel10.Location = new System.Drawing.Point(3, 283); this.panel10.Name = "panel10"; - this.panel10.Size = new System.Drawing.Size(376, 93); + this.panel10.Size = new System.Drawing.Size(380, 93); this.panel10.TabIndex = 125; // // panel12 @@ -633,7 +635,7 @@ namespace PMAlignTool this.panel14.Location = new System.Drawing.Point(3, 417); this.panel14.Name = "panel14"; this.tableLayoutPanel1.SetRowSpan(this.panel14, 2); - this.panel14.Size = new System.Drawing.Size(376, 142); + this.panel14.Size = new System.Drawing.Size(380, 142); this.panel14.TabIndex = 127; // // label8 @@ -854,34 +856,34 @@ namespace PMAlignTool this.btnCreateModel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; this.btnCreateModel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnCreateModel.ForeColor = System.Drawing.Color.White; - this.btnCreateModel.Location = new System.Drawing.Point(237, 134); + this.btnCreateModel.Location = new System.Drawing.Point(239, 134); this.btnCreateModel.Name = "btnCreateModel"; - this.btnCreateModel.Size = new System.Drawing.Size(142, 42); + this.btnCreateModel.Size = new System.Drawing.Size(144, 42); this.btnCreateModel.TabIndex = 129; this.btnCreateModel.TabStop = false; this.btnCreateModel.Text = "创建模板"; this.btnCreateModel.UseVisualStyleBackColor = false; this.btnCreateModel.Click += new System.EventHandler(this.btnCreateModel_Click); // - // btnAcqNewModelImage + // btnChangeModel // - this.btnAcqNewModelImage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(150)))), ((int)(((byte)(219))))); - this.btnAcqNewModelImage.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.btnAcqNewModelImage.Cursor = System.Windows.Forms.Cursors.Hand; - this.btnAcqNewModelImage.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnAcqNewModelImage.FlatAppearance.BorderSize = 0; - this.btnAcqNewModelImage.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkGray; - this.btnAcqNewModelImage.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; - this.btnAcqNewModelImage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnAcqNewModelImage.ForeColor = System.Drawing.Color.White; - this.btnAcqNewModelImage.Location = new System.Drawing.Point(237, 88); - this.btnAcqNewModelImage.Name = "btnAcqNewModelImage"; - this.btnAcqNewModelImage.Size = new System.Drawing.Size(142, 40); - this.btnAcqNewModelImage.TabIndex = 129; - this.btnAcqNewModelImage.TabStop = false; - this.btnAcqNewModelImage.Text = "获取图像"; - this.btnAcqNewModelImage.UseVisualStyleBackColor = false; - this.btnAcqNewModelImage.Click += new System.EventHandler(this.btnAcqNewModelImage_Click); + this.btnChangeModel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(150)))), ((int)(((byte)(219))))); + this.btnChangeModel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.btnChangeModel.Cursor = System.Windows.Forms.Cursors.Hand; + this.btnChangeModel.Dock = System.Windows.Forms.DockStyle.Fill; + this.btnChangeModel.FlatAppearance.BorderSize = 0; + this.btnChangeModel.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkGray; + this.btnChangeModel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; + this.btnChangeModel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnChangeModel.ForeColor = System.Drawing.Color.White; + this.btnChangeModel.Location = new System.Drawing.Point(239, 88); + this.btnChangeModel.Name = "btnChangeModel"; + this.btnChangeModel.Size = new System.Drawing.Size(144, 40); + this.btnChangeModel.TabIndex = 129; + this.btnChangeModel.TabStop = false; + this.btnChangeModel.Text = "修改模板"; + this.btnChangeModel.UseVisualStyleBackColor = false; + this.btnChangeModel.Click += new System.EventHandler(this.btnChangeModel_Click); // // tabPage2 // @@ -889,7 +891,7 @@ namespace PMAlignTool this.tabPage2.Location = new System.Drawing.Point(4, 29); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(388, 568); + this.tabPage2.Size = new System.Drawing.Size(392, 568); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "参数"; this.tabPage2.UseVisualStyleBackColor = true; @@ -919,7 +921,7 @@ namespace PMAlignTool this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(382, 562); + this.tableLayoutPanel2.Size = new System.Drawing.Size(386, 562); this.tableLayoutPanel2.TabIndex = 0; // // panel4 @@ -929,7 +931,7 @@ namespace PMAlignTool this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; this.panel4.Location = new System.Drawing.Point(3, 344); this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(376, 28); + this.panel4.Size = new System.Drawing.Size(380, 28); this.panel4.TabIndex = 150; // // label2 @@ -953,7 +955,7 @@ namespace PMAlignTool this.panel11.Dock = System.Windows.Forms.DockStyle.Fill; this.panel11.Location = new System.Drawing.Point(3, 3); this.panel11.Name = "panel11"; - this.panel11.Size = new System.Drawing.Size(376, 28); + this.panel11.Size = new System.Drawing.Size(380, 28); this.panel11.TabIndex = 148; // // label11 @@ -999,7 +1001,7 @@ namespace PMAlignTool this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Location = new System.Drawing.Point(3, 37); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(376, 301); + this.panel2.Size = new System.Drawing.Size(380, 301); this.panel2.TabIndex = 149; // // nud_angleRange @@ -1419,7 +1421,7 @@ namespace PMAlignTool this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; this.panel5.Location = new System.Drawing.Point(3, 378); this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(376, 181); + this.panel5.Size = new System.Drawing.Size(380, 181); this.panel5.TabIndex = 151; // // cbx_searchRegionType @@ -1440,6 +1442,7 @@ namespace PMAlignTool this.cbx_searchRegionType.Size = new System.Drawing.Size(172, 26); this.cbx_searchRegionType.TabIndex = 122; this.cbx_searchRegionType.TextStr = "整幅图像"; + this.cbx_searchRegionType.SelectedIndexChanged += new Controls.DSelectedIndexChanged(this.cbx_searchRegionType_SelectedIndexChanged); // // label5 // @@ -1456,7 +1459,7 @@ namespace PMAlignTool this.tabPage4.Controls.Add(this.panel6); this.tabPage4.Location = new System.Drawing.Point(4, 29); this.tabPage4.Name = "tabPage4"; - this.tabPage4.Size = new System.Drawing.Size(388, 568); + this.tabPage4.Size = new System.Drawing.Size(392, 568); this.tabPage4.TabIndex = 3; this.tabPage4.Text = "图形"; this.tabPage4.UseVisualStyleBackColor = true; @@ -1471,7 +1474,7 @@ namespace PMAlignTool this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; this.panel6.Location = new System.Drawing.Point(0, 0); this.panel6.Name = "panel6"; - this.panel6.Size = new System.Drawing.Size(388, 568); + this.panel6.Size = new System.Drawing.Size(392, 568); this.panel6.TabIndex = 0; // // checkBox2 @@ -1535,89 +1538,102 @@ namespace PMAlignTool this.ckb_showCross.Text = "显示参考点"; this.ckb_showCross.UseVisualStyleBackColor = true; // - // tabPage5 + // tabPage3 // - this.tabPage5.Controls.Add(this.panel7); - this.tabPage5.Location = new System.Drawing.Point(4, 29); - this.tabPage5.Name = "tabPage5"; - this.tabPage5.Size = new System.Drawing.Size(388, 568); - this.tabPage5.TabIndex = 4; - this.tabPage5.Text = "结果"; - this.tabPage5.UseVisualStyleBackColor = true; - // - // panel7 - // - this.panel7.Controls.Add(this.dgv_matchResult); - this.panel7.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel7.Location = new System.Drawing.Point(0, 0); - this.panel7.Name = "panel7"; - this.panel7.Size = new System.Drawing.Size(388, 568); - this.panel7.TabIndex = 0; + this.tabPage3.Controls.Add(this.dgv_matchResult); + this.tabPage3.Location = new System.Drawing.Point(4, 29); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Size = new System.Drawing.Size(392, 568); + this.tabPage3.TabIndex = 5; + this.tabPage3.Text = "结果"; + this.tabPage3.UseVisualStyleBackColor = true; // // dgv_matchResult // - this.dgv_matchResult.AllowDrop = true; - this.dgv_matchResult.AllowUserToAddRows = false; - this.dgv_matchResult.AllowUserToDeleteRows = false; - this.dgv_matchResult.AllowUserToResizeRows = false; - this.dgv_matchResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); + this.dgv_matchResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.dgv_matchResult.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; + this.dgv_matchResult.BackgroundColor = System.Drawing.Color.White; + this.dgv_matchResult.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_matchResult.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dgv_matchResult.ColumnHeadersHeight = 32; + this.dgv_matchResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dgv_matchResult.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.Column7, - this.Column8, - this.Column9, - this.Column10, - this.Column12}); + this.Column1, + this.Column2, + this.Column3, + this.Column4, + this.Column5}); this.dgv_matchResult.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv_matchResult.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; + this.dgv_matchResult.EnableHeadersVisualStyles = false; + this.dgv_matchResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dgv_matchResult.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); this.dgv_matchResult.Location = new System.Drawing.Point(0, 0); - this.dgv_matchResult.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.dgv_matchResult.Name = "dgv_matchResult"; - this.dgv_matchResult.ReadOnly = true; - this.dgv_matchResult.RowHeadersVisible = false; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_matchResult.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.dgv_matchResult.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToFirstHeader; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; + this.dgv_matchResult.RowsDefaultCellStyle = dataGridViewCellStyle4; this.dgv_matchResult.RowTemplate.Height = 23; - this.dgv_matchResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dgv_matchResult.Size = new System.Drawing.Size(388, 568); - this.dgv_matchResult.TabIndex = 13; + this.dgv_matchResult.SelectedIndex = -1; + this.dgv_matchResult.ShowGridLine = true; + this.dgv_matchResult.Size = new System.Drawing.Size(392, 568); + this.dgv_matchResult.TabIndex = 0; // - // Column7 + // Column1 // - this.Column7.HeaderText = "编号"; - this.Column7.Name = "Column7"; - this.Column7.ReadOnly = true; - this.Column7.Width = 70; + this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Column1.HeaderText = "编号"; + this.Column1.Name = "Column1"; + this.Column1.Width = 66; // - // Column8 + // Column2 // - this.Column8.HeaderText = "分数"; - this.Column8.Name = "Column8"; - this.Column8.ReadOnly = true; - this.Column8.Width = 75; + this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Column2.HeaderText = "分值"; + this.Column2.Name = "Column2"; // - // Column9 + // Column3 // - this.Column9.HeaderText = "行"; - this.Column9.Name = "Column9"; - this.Column9.ReadOnly = true; - this.Column9.Width = 70; + this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Column3.HeaderText = "行"; + this.Column3.Name = "Column3"; + this.Column3.Width = 50; // - // Column10 + // Column4 // - this.Column10.HeaderText = "列"; - this.Column10.Name = "Column10"; - this.Column10.ReadOnly = true; - this.Column10.Width = 70; + this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Column4.HeaderText = "列"; + this.Column4.Name = "Column4"; + this.Column4.Width = 50; // - // Column12 + // Column5 // - this.Column12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Column12.HeaderText = "角度(°)"; - this.Column12.Name = "Column12"; - this.Column12.ReadOnly = true; + this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Column5.HeaderText = "角度"; + this.Column5.Name = "Column5"; + this.Column5.Width = 66; // // FormPMAlignTool // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(999, 655); + this.ClientSize = new System.Drawing.Size(1007, 655); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.statusStrip); @@ -1668,8 +1684,7 @@ namespace PMAlignTool this.tabPage4.ResumeLayout(false); this.panel6.ResumeLayout(false); this.panel6.PerformLayout(); - this.tabPage5.ResumeLayout(false); - this.panel7.ResumeLayout(false); + this.tabPage3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgv_matchResult)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1687,7 +1702,6 @@ namespace PMAlignTool private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage4; - private System.Windows.Forms.TabPage tabPage5; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private ViewROI.HWindowTool_Smart hWindowTool_Smart1; private System.Windows.Forms.Panel panel3; @@ -1728,13 +1742,6 @@ namespace PMAlignTool public System.Windows.Forms.CheckBox cbx_showTemplate; public System.Windows.Forms.CheckBox ckb_showFeature; public System.Windows.Forms.CheckBox ckb_showCross; - private System.Windows.Forms.Panel panel7; - internal System.Windows.Forms.DataGridView dgv_matchResult; - private System.Windows.Forms.DataGridViewTextBoxColumn Column7; - private System.Windows.Forms.DataGridViewTextBoxColumn Column8; - private System.Windows.Forms.DataGridViewTextBoxColumn Column9; - private System.Windows.Forms.DataGridViewTextBoxColumn Column10; - private System.Windows.Forms.DataGridViewTextBoxColumn Column12; private System.Windows.Forms.Panel panel8; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.RadioButton rabFormLocal; @@ -1763,7 +1770,7 @@ namespace PMAlignTool private System.Windows.Forms.CheckBox cbCErosion1; private System.Windows.Forms.CheckBox cbCErosion2; internal System.Windows.Forms.Button btnCreateModel; - internal System.Windows.Forms.Button btnAcqNewModelImage; + internal System.Windows.Forms.Button btnChangeModel; public Controls.CNumericUpDown nud_angleRange; public Controls.CNumericUpDown nud_angleStart; public Controls.CComboBox cmbErsion1; @@ -1775,5 +1782,12 @@ namespace PMAlignTool private System.Windows.Forms.ToolStripStatusLabel lb_RunStatus; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripStatusLabel lb_RunTime; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column2; + private System.Windows.Forms.DataGridViewTextBoxColumn Column3; + private System.Windows.Forms.DataGridViewTextBoxColumn Column4; + private System.Windows.Forms.DataGridViewTextBoxColumn Column5; + public Sunny.UI.UIDataGridView dgv_matchResult; } } \ No newline at end of file diff --git a/PMAlignTool/FormPMAlignTool.cs b/PMAlignTool/FormPMAlignTool.cs index a032cba..27e3768 100644 --- a/PMAlignTool/FormPMAlignTool.cs +++ b/PMAlignTool/FormPMAlignTool.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -20,10 +21,10 @@ namespace PMAlignTool private PMAlign myPMAlign = new PMAlign(); public IToolInfo myToolInfo = new IToolInfo(); public HWindowTool_Smart myHwindow = new HWindowTool_Smart(); - private HDrawingObject selected_drawing_object = new HDrawingObject(); + private HDrawingObject serachRegion_drawing_object = new HDrawingObject(); public List templateModelListAdd = new List() { }; public List templateModelListSub = new List() { }; - + public List templateModelList = new List() { }; public FormPMAlignTool(ref object pmalign) { InitializeComponent(); @@ -100,17 +101,14 @@ namespace PMAlignTool nud_ScaleStart.Value = myPMAlign.minScale; nud_ScaleRange.Value = myPMAlign.maxScale; tkb_contrast.Value = myPMAlign.contrast; - #endregion - isInitTool = false; - } - - private void btnAcqNewModelImage_Click(object sender, EventArgs e) - { - if (myPMAlign.inputImage != null) + if(myPMAlign.modelPartImage != null) { - myPMAlign.oldTrainImage = myPMAlign.inputImage; + hWindowTool_Smart1.DispImage(myPMAlign.modelPartImage); } + // myHwindow.DispHWindow.AttachDrawingObjectToWindow(serachRegion_drawing_object); + tsbtRunTool_Click(null, null); + isInitTool = false; } private ShapeMode selectType; private void btnOperateROI_Click(object sender, EventArgs e) @@ -182,6 +180,12 @@ namespace PMAlignTool selectObj.Dispose(); } + private void OnSerchRegionDrawingObject(HDrawingObject dobj, HWindow hwin, string type) + { + HObject selectObj = dobj.GetDrawingObjectIconic(); + myPMAlign.SearchRegion = selectObj.Clone(); + } + public HObject contour; private void btnCreateModel_Click(object sender, EventArgs e) { @@ -206,19 +210,11 @@ namespace PMAlignTool HTuple row1, col1, row2, col2; HOperatorSet.SmallestRectangle1(myPMAlign.templateRegion, out row1, out col1, out row2, out col2); HObject outRectangle1; - HOperatorSet.GenRectangle1(out outRectangle1, row1 - 20, col1 - 20, row2 + 20, col2 + 20); - HObject imageReduced, imagePart; + HOperatorSet.GenRectangle1(out outRectangle1, row1, col1, row2, col2); + HObject imageReduced; HOperatorSet.ReduceDomain(myPMAlign.inputImage, outRectangle1, out imageReduced); - HObject outBoundary, inBoundary; - HOperatorSet.Boundary(myPMAlign.templateRegion, out outBoundary, "inner_filled"); - HOperatorSet.Boundary(myPMAlign.templateRegion, out inBoundary, "outer"); - HOperatorSet.CropDomain(imageReduced, out imagePart); HOperatorSet.SetSystem("flush_graphic", "true"); - hWindowTool_Smart1.DispImage(imagePart); - hWindowTool_Smart1.DispHWindow.SetColor("green"); - hWindowTool_Smart1.DispHWindow.SetDraw("margin"); - hWindowTool_Smart1.DispHWindow.DispObj(outBoundary); - hWindowTool_Smart1.DispHWindow.DispObj(inBoundary); + hWindowTool_Smart1.DispImage(myPMAlign.modelPartImage); if (myPMAlign.matchMode == MatchMode.BasedShape) { HOperatorSet.SetLineStyle(myHwindow.DispHWindow, new HTuple()); @@ -322,5 +318,50 @@ namespace PMAlignTool } } + private void btnChangeModel_Click(object sender, EventArgs e) + { + if(!File.Exists(myPMAlign.pmaModelName + ".ShapeModel")) + { + MessageBox.Show("还未创建过模板,请先进行创建!"); + return; + } + myPMAlign.inputImage = myPMAlign.oldTrainImage; + myPMAlign.Run(SoftwareRunState.Debug); + + } + + private void cbx_searchRegionType_SelectedIndexChanged() + { + serachRegion_drawing_object.ClearDrawingObject(); + string selectRegion = cbx_searchRegionType.TextStr; + switch (selectRegion) + { + case "整幅图像": + myPMAlign.searchRegionType = RegionType.AllImage; + return; + case "矩形": + myPMAlign.searchRegionType = RegionType.Rectangle1; + serachRegion_drawing_object = HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.RECTANGLE1, new HTuple[] { 100, 100, 300, 400 }); + break; + case "圆": + myPMAlign.searchRegionType = RegionType.Circle; + serachRegion_drawing_object = HDrawingObject.CreateDrawingObject(HDrawingObject.HDrawingObjectType.CIRCLE, new HTuple[] { 200, 200, 100 }); + break; + case "多点": + myPMAlign.searchRegionType = RegionType.MultPoint; + break; + default: + break; + } + GC.KeepAlive(serachRegion_drawing_object); + serachRegion_drawing_object.OnSelect(OnSerchRegionDrawingObject); + serachRegion_drawing_object.OnAttach(OnSerchRegionDrawingObject); + serachRegion_drawing_object.OnResize(OnSerchRegionDrawingObject); + serachRegion_drawing_object.OnDrag(OnSerchRegionDrawingObject); + serachRegion_drawing_object.SetDrawingObjectParams("color", "yellow"); + myHwindow.DispHWindow.AttachDrawingObjectToWindow(serachRegion_drawing_object); + + } + } } diff --git a/PMAlignTool/FormPMAlignTool.resx b/PMAlignTool/FormPMAlignTool.resx index 836d7e6..ae9539c 100644 --- a/PMAlignTool/FormPMAlignTool.resx +++ b/PMAlignTool/FormPMAlignTool.resx @@ -196,19 +196,19 @@ n4H40MZzWKY2esaEIAiCIAiCIKrhy5f/A2/46JDXUARZAAAAAElFTkSuQmCC - + True - + True - + True - + True - + True diff --git a/PMAlignTool/PMAlign.cs b/PMAlignTool/PMAlign.cs index 2e15b7a..ff05c4e 100644 --- a/PMAlignTool/PMAlign.cs +++ b/PMAlignTool/PMAlign.cs @@ -24,6 +24,7 @@ using System.Windows.Forms; using Logger; using System.Diagnostics; using System.IO; +using ViewROI; namespace PMAlignTool { @@ -118,11 +119,15 @@ namespace PMAlignTool public bool isCreateModel { get; set; } internal string pmaModelName { get; set; } = Guid.NewGuid().ToString(); /// + /// 剪出的模板图像 + /// + public HObject modelPartImage = new HObject(); + /// /// 模板位置和实际位置的姿态差异 /// internal HTuple posHomMat2D = new HTuple(); - public override void DispMainWindow(HWindow dispHWindow) + public override void DispMainWindow(HWindowTool_Smart dispHWindow) { if (showFeature) { @@ -158,8 +163,7 @@ namespace PMAlignTool public bool isAutoConstants { get; set; } public string modelFilePath { get; set; } public RegionType searchRegionType { get; set; } - public HObject SearchRegion { get; private set; } - + public HObject SearchRegion { get; set; } public override void Run(SoftwareRunState softwareState) { Stopwatch sw = new Stopwatch(); @@ -167,7 +171,9 @@ namespace PMAlignTool softwareRunState = softwareState; if (inputImage == null) { - FormPMAlignTool.Instance.SetToolStatus("工具输入图像为空", ToolRunStatu.Not_Input_Image); + toolRunStatu = ToolRunStatu.Lack_Of_Input_Image; + runMessage = "工具输入图像为空"; + FormPMAlignTool.Instance.SetToolStatus(runMessage, toolRunStatu); return; } try @@ -192,21 +198,36 @@ namespace PMAlignTool // UpdateParamsFromUI(); // 操作前先将UI中参数写入类 HObject findModelImg = ProcessImage(inputImage); int ret = FindModelTemplate(findModelImg); + UpdateResultDataGridview(); ToolRunStatu myState = ret == 0 ? ToolRunStatu.Succeed : ToolRunStatu.Model_UnFound; - string retMsg = ret == 0 ? "工具运行成功,已找到匹配项!" : "未找到匹配项"; + toolRunStatu = myState; + string retMsg = ret == 0 ? $"{toolName}工具运行成功,已找到匹配项!" : $"{toolName}未找到匹配项"; + runMessage = retMsg; sw.Stop(); runTime = $"运行时间: {sw.ElapsedMilliseconds} ms"; FormPMAlignTool.Instance.SetToolStatus(retMsg, myState); } catch (Exception ex) { - FormPMAlignTool.Instance.SetToolStatus($"工具运行异常,异常原因: {ex}", ToolRunStatu.Tool_Run_Error); + FormPMAlignTool.Instance.SetToolStatus($"{toolName}工具运行异常,异常原因: {ex}", ToolRunStatu.Tool_Run_Error); } finally { } } + + public void UpdateResultDataGridview() + { + FormPMAlignTool.Instance.dgv_matchResult.Rows.Clear(); + int count = 0; + foreach (var item in L_resultList) + { + FormPMAlignTool.Instance.dgv_matchResult.AddRow(++count, item.Socre, item.Row, item.Col, item.Angle); + } + + } + public void UpdateParamsFromUI() { minScore = FormPMAlignTool.Instance.nud_minScore.Value; @@ -261,7 +282,7 @@ namespace PMAlignTool oldTrainImage = inputImage; if (FormPMAlignTool.Instance.templateModelListAdd.Count == 0) { - LoggerClass.WriteLog("未划定模板建立区域", MsgLevel.Exception); + LoggerClass.WriteLog($"{toolName}未划定模板建立区域", MsgLevel.Exception); isCreateModel = false; return -1; } @@ -270,6 +291,7 @@ namespace PMAlignTool HOperatorSet.GenEmptyObj(out createModelImg); createModelImg = ProcessImage(inputImage); HOperatorSet.ReduceDomain(createModelImg, templateRegion, out template); + HOperatorSet.CropDomain(template, out modelPartImage); //SetParamsFromUI(); try { @@ -327,6 +349,7 @@ namespace PMAlignTool isCreateModel = true; HOperatorSet.WriteRegion(templateRegion, FormPMAlignTool.Instance.myToolInfo.FormToolName + ".hobj"); HOperatorSet.WriteShapeModel(modelID, pmaModelName + ".ShapeModel"); + if (scores != null && scores.Type != HTupleType.EMPTY) { templatePose = new PosXYU { X = rows[0].D, Y = cols[0].D , U = angles[0].D }; @@ -335,28 +358,23 @@ namespace PMAlignTool } catch (Exception ex) { - Logger.LoggerClass.WriteLog("创建模板时出现异常", ex); + Logger.LoggerClass.WriteLog($"{toolName}创建模板时出现异常", ex); isCreateModel = false; return -1; } finally { - FormPMAlignTool.Instance.templateModelListAdd.Clear(); - FormPMAlignTool.Instance.templateModelListSub.Clear(); + // FormPMAlignTool.Instance.templateModelListAdd.Clear(); + // FormPMAlignTool.Instance.templateModelListSub.Clear(); } return 0; } public int FindModelTemplate(HObject findModelImage) { - if (!isCreateModel) - { - LoggerClass.WriteLog("未创建或加载模板", MsgLevel.Exception); - return -1; - } if (!File.Exists(pmaModelName + ".ShapeModel")) { - LoggerClass.WriteLog("未创建或加载模板", MsgLevel.Exception); + LoggerClass.WriteLog($"{toolName}未创建或加载模板", MsgLevel.Exception); return -1; } HOperatorSet.ReadShapeModel(pmaModelName + ".ShapeModel", out modelID); @@ -466,14 +484,14 @@ namespace PMAlignTool toolRunStatu = ToolRunStatu.Succeed; if (softwareRunState == SoftwareRunState.Debug) { - ShowTemplate(FormPMAlignTool.Instance.myHwindow.DispHWindow); + ShowTemplate(FormPMAlignTool.Instance.myHwindow); } return 0; } } catch (Exception ex) { - LoggerClass.WriteLog("寻找模板时出现异常!", ex); + LoggerClass.WriteLog($"{toolName}寻找模板时出现异常!", ex); toolRunStatu = ToolRunStatu.Not_Succeed; } return -1; @@ -483,7 +501,7 @@ namespace PMAlignTool /// /// 显示模板 /// - internal void ShowTemplate(HWindow dispHWindow, bool clearImg = false) + internal void ShowTemplate(HWindowTool_Smart dispHWindow, bool clearImg = false) { try { @@ -493,8 +511,8 @@ namespace PMAlignTool } if(clearImg) { - dispHWindow.ClearWindow(); - dispHWindow.DispObj(inputImage); + dispHWindow.DispHWindow.ClearWindow(); + dispHWindow.DispImage(inputImage); } if(L_resultList.Count > 0) { @@ -504,15 +522,15 @@ namespace PMAlignTool HOperatorSet.GetShapeModelContours(out contour, modelID, new HTuple(1)); HOperatorSet.VectorAngleToRigid(0, 0, 0, item.Row, item.Col, item.Angle,out homMat2D); HOperatorSet.AffineTransContourXld(contour, out contour, homMat2D); - dispHWindow.SetColor("green"); - dispHWindow.DispObj(contour); + dispHWindow.DispHWindow.SetColor("green"); + dispHWindow.DispHWindow.DispObj(contour); } } } catch (Exception ex) { - Logger.LoggerClass.WriteLog("显示模板时出现错误", ex); + Logger.LoggerClass.WriteLog($"{toolName}显示模板时出现错误", ex); } } diff --git a/PMAlignTool/PMAlignTool.csproj b/PMAlignTool/PMAlignTool.csproj index c1227f8..f76ce52 100644 --- a/PMAlignTool/PMAlignTool.csproj +++ b/PMAlignTool/PMAlignTool.csproj @@ -37,11 +37,17 @@ C:\Program Files\MVTec\HALCON-19.05-Progress\bin\dotnet20\halcondotnet.dll + + False + ..\VisionEdit\bin\Debug\ThirdLib\SunnyUI.dll + + + @@ -97,7 +103,7 @@ ToolBase - {D4E052B9-E541-4B67-A1F9-273073EF1D4B} + {d4e052b9-e541-4b67-a1f9-273073ef1d4b} Logger diff --git a/PMAlignTool/PMAlignToolRun.cs b/PMAlignTool/PMAlignToolRun.cs index 08a072e..fa0f4cb 100644 --- a/PMAlignTool/PMAlignToolRun.cs +++ b/PMAlignTool/PMAlignToolRun.cs @@ -41,6 +41,7 @@ namespace PMAlignTool if (L_toolList[toolIndex].GetInput(L_toolList[toolIndex].toolInput[j].IOName).value == null) { selectNode.ForeColor = Color.Red; + myPMAlign.inputImage = null; LoggerClass.WriteLog(L_toolList[toolIndex].toolName + " 无输入图像", MsgLevel.Exception); } else @@ -63,7 +64,7 @@ namespace PMAlignTool else { myJob.FormLogDisp($"{L_toolList[toolIndex].toolName} 运行成功,{myPMAlign.runTime}", Color.Green, selectNode); - myPMAlign.DispMainWindow(FormImageWindow.Instance.myHWindow.DispHWindow); + myPMAlign.DispMainWindow(FormImageWindow.Instance.myHWindow); // 将输出值赋值到界面输出中 if (myPMAlign.L_resultList.Count > 0) { diff --git a/ToolBase/IToolBase.cs b/ToolBase/IToolBase.cs index d1a425f..c028604 100644 --- a/ToolBase/IToolBase.cs +++ b/ToolBase/IToolBase.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using CommonMethods; using HalconDotNet; +using ViewROI; namespace ToolBase { @@ -18,6 +19,6 @@ namespace ToolBase public abstract void Run(SoftwareRunState softwareRunState); public HObject inputImage { get; set; } public abstract void DispImage(); - public abstract void DispMainWindow(HWindow window); + public abstract void DispMainWindow(HWindowTool_Smart window); } } diff --git a/ToolBase/ToolBase.csproj b/ToolBase/ToolBase.csproj index 5e60034..46e5731 100644 --- a/ToolBase/ToolBase.csproj +++ b/ToolBase/ToolBase.csproj @@ -52,6 +52,10 @@ {1C8D0DDC-2086-48A9-9586-F2B643E2FC54} CommonHelper + + {9baa53fd-89b5-43e2-ac59-a27b006debb6} + HWindow_Tool +