private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (locationShapes != null) { int index = comboBox1.SelectedIndex; if (index >= 0) { crossCollection = locationShapes[index].locationCross; if (locationShapes[index].Shape.ModelImg != null && locationShapes[index].Shape.ModelImg.IsInitialized()) { hImage = locationShapes[index].Shape.ModelImg.Clone(); hWndCtrller.AddIconicVar(hImage); } else { hWndCtrller.ClearEntries(); } propertyGridShow(index); if (this.treeView1.Nodes.Count > 0) { int i = this.treeView1.Nodes.Count; this.treeView1.SelectedNode = treeView1.Nodes[0]; } button5.Enabled = button9.Enabled = button8.Enabled = false; } Repaint(); } }
private void DisplayMaskRegion() { if (hImage.IsInitialized()) { hWndCtrller.AddIconicVar(hImage); } hWndCtrller.ChangeGraphicSettings(GraphicContext.GC_COLOR, "blue"); hWndCtrller.AddIconicVar(maskEdit.GetMaskHRegion()); hWndCtrller.AddIconicVar(maskEdit.DisplayMaksHRegion()); hWndCtrller.Repaint(); GC_Collect(); }
private void Frm_MaskEditor_Load(object sender, EventArgs e) { hWindowControl1.HMouseDown += HWindowControl1_HMouseDown; hWindowControl1.HMouseMove += HWindowControl1_HMouseMove; hWindowControl1.HMouseUp += HWindowControl1_HMouseUp; hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel; hWndCtrller = new HWndCtrller(hWindowControl1); hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); }; hWndCtrller.RegisterROICtroller(ctrller); if (hImage.IsInitialized()) { hImage.GetImageSize(out imageWidth, out imageHeigh); hWndCtrller.AddIconicVar(hImage); hWndCtrller.Repaint(); } AdjHalconWindow(panel2, hWindowControl1); toolStripMenuItem1.PerformClick(); SetFromDisplay(); hWndCtrller.SetGUICompRangeX(new int[] { XTrackBar.Minimum, XTrackBar.Maximum }, XTrackBar.Value); hWndCtrller.SetGUICompRangeY(new int[] { YTrackBar.Minimum, YTrackBar.Maximum }, YTrackBar.Maximum - YTrackBar.Value); }
private void button7_Click(object sender, EventArgs e) { HImage hImage = VisionProject.Instance.Camera[0].GetCurrentImage(); ctrller.Reset(); hWndCtrller.AddIconicVar(hImage.Clone()); DrawRegionCtrlFlag = 0; hWndCtrller.Repaint(); ShapeModel model = VisionProject.Instance.visionTool.checkStick.Location; if (model.InputImg != null) { model.InputImg.Dispose(); } model.InputImg = hImage; }
private void button1_Click(object sender, EventArgs e) { hWndCtrller.AddIconicVar(nCCModel.InputImg); rOI = new ROIRectangle1(); ctrller.Reset(); ctrller.SetROISign(ROICtrller.SIGN_ROI_POS); hWndCtrller.Repaint(); ctrller.SetROIShape(rOI); SearchRegionCtrlFlag = true; }
private void Frm_CheckStick_Load(object sender, EventArgs e) { hWndCtrller = new HWndCtrllerEx(hWindowControl1); hWndCtrller.ChangeGraphicSettings("DrawMode", "margin"); hWndCtrller.ChangeGraphicSettings("Color", "green"); ((HWndCtrllerEx)hWndCtrller).Paint += Frm_CheckStick_Paint; hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); }; hWindowControl1.HMouseMove += HWindowControl1_HMouseMove; hWindowControl1.HMouseUp += HWindowControl1_HMouseUp; hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel; hWndCtrller.RegisterROICtroller(ctrller); ShapeModel model = VisionProject.Instance.visionTool.checkStick.Location; if (model.ModelImg != null && model.ModelImg.IsInitialized()) { hWndCtrller.AddIconicVar(model.ModelImg.Clone()); hWndCtrller.Repaint(); } hWindowControl1.HalconWindow.SetColor("blue"); foreach (var item in VisionProject.Instance.visionTool.checkStick.CheckRegion) { if (item != null && item.IsInitialized()) { this.hWindowControl1.HalconWindow.DispObj(item); } } trackBar1.Value = (int)VisionProject.Instance.visionTool.checkStick.Threshold; DrawRegionCtrlFlag = 0; if (VisionProject.Instance.visionApi.CheckStick.Count == 4) { label3.Text = string.Format("上:X={0:0.00},Y={1:0.00},R={2:0.00}", VisionProject.Instance.visionApi.CheckStick[0].X, VisionProject.Instance.visionApi.CheckStick[0].Y, VisionProject.Instance.visionApi.CheckStick[0].R); label5.Text = string.Format("下:X={0:0.00},Y={1:0.00},R={2:0.00}", VisionProject.Instance.visionApi.CheckStick[1].X, VisionProject.Instance.visionApi.CheckStick[1].Y, VisionProject.Instance.visionApi.CheckStick[1].R); label4.Text = string.Format("左:X={0:0.00},Y={1:0.00},R={2:0.00}", VisionProject.Instance.visionApi.CheckStick[2].X, VisionProject.Instance.visionApi.CheckStick[2].Y, VisionProject.Instance.visionApi.CheckStick[2].R); label6.Text = string.Format("右:X={0:0.00},Y={1:0.00},R={2:0.00}", VisionProject.Instance.visionApi.CheckStick[3].X, VisionProject.Instance.visionApi.CheckStick[3].Y, VisionProject.Instance.visionApi.CheckStick[3].R); } }
protected override void Render() { lock (this.Locker) { if (hWndCtrller != null) { if (himage.IsInitialized()) { hWndCtrller.AddIconicVar(new HImage(this.himage)); hWndCtrller.Repaint(); } else { hWndCtrller.ClearEntries(); base.HalconWindow.ClearWindow(); } } } }
private void Frm_NccModelControl_Load(object sender, EventArgs e) { hWndCtrller = new HWndCtrller(hWindowControl1); hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); }; hWindowControl1.HMouseMove += HWindowControl1_HMouseMove; hWindowControl1.HMouseUp += HWindowControl1_HMouseUp; hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel; hWndCtrller.RegisterROICtroller(ctrller); AdjHalconWindow(panel2, hWindowControl1); comboBox2.Items.Clear(); comboBox2.Items.Add("矩形"); comboBox2.Items.Add("圆"); comboBox2.Items.Add("矩形2"); comboBox2.SelectedIndex = 0; if (nCCModel == null) { nCCModel = new NCCModel(); } if (nCCModel.InputImg != null && nCCModel.InputImg.IsInitialized()) { nCCModel.InputImg.GetImageSize(out imageHeigh, out imageWidth); hWndCtrller.AddIconicVar(nCCModel.InputImg); hWndCtrller.Repaint(); } SafeSetUpDownRange(StartingAngleUpDown, DegFromRad(nCCModel.nCCParam.AngleStart)); SafeSetUpDownRange(AngleExtentUpDown, DegFromRad(nCCModel.nCCParam.AngleExtent)); SafeSetUpDownRange(AngleStepUpDown, DegFromRad(nCCModel.nCCParam.AngleStep) * 10); SafeSetUpDownRange(numUpDwnNumLevels, (nCCModel.nCCParam.NumLevels)); if (nCCModel.nCCParam.Metric == "use_polarity") { MetricBox.SelectedIndex = 0; } else if (nCCModel.nCCParam.Metric == "ignore_global_polarity") { MetricBox.SelectedIndex = 1; } if (nCCModel.nCCParam.SubPixel == "true") { comboBox1.SelectedIndex = 0; } else if (nCCModel.nCCParam.SubPixel == "false") { comboBox1.SelectedIndex = 1; } SafeSetUpDownRange(numericUpDown6, nCCModel.nCCParam.MinScore * 100); SafeSetUpDownRange(numericUpDown7, nCCModel.nCCParam.NumMatches); SafeSetUpDownRange(numericUpDown1, nCCModel.nCCParam.MaxOverlap * 100); SafeSetUpDownRange(numericUpDown2, nCCModel.OutTime); checkBox2.Checked = nCCModel.nCCParam.IsAuto(NCCParam.AUTO_ANGLE_STEP); checkBox3.Checked = nCCModel.nCCParam.IsAuto(NCCParam.AUTO_NUM_LEVEL); }
private void Frm_ShapeModelControl_Load(object sender, EventArgs e) { tabControl2.TabPages.Remove(tabPage4); tabControl3.TabPages.Remove(tabPage6); hWndCtrller = new HWndCtrller(hWindowControl1); hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); }; hWindowControl1.HMouseMove += HWindowControl1_HMouseMove; hWindowControl1.HMouseUp += HWindowControl1_HMouseUp; hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel; hWndCtrller.RegisterROICtroller(ctrller); comboBox2.Items.Clear(); comboBox2.Items.Add("矩形"); comboBox2.Items.Add("圆"); comboBox2.Items.Add("矩形2"); comboBox2.SelectedIndex = 0; if (Model == null) { Model = new ShapeModel(); } if (Model.ModelImg != null && Model.ModelImg.IsInitialized()) { Model.ModelImg.GetImageSize(out imageWidth, out imageHeigh); hWndCtrller.AddIconicVar(Model.ModelImg); //hWndCtrller.Repaint(); } toolStripStatusLabel1.Text = "耗时:" + Model.OutputResult.Time.ToString(); if (Model.shapeModel == null || !Model.shapeModel.IsInitialized()) { button6.Enabled = false; button5.Enabled = false; } else { InspectModel(); } AdjHalconWindow(panel2, hWindowControl1); SafeSetUpDownRange(StartingAngleUpDown, DegFromRad(Model.shapeParam.mStartingAngle)); SafeSetUpDownRange(AngleExtentUpDown, DegFromRad(Model.shapeParam.mAngleExtent)); SafeSetUpDownRange(AngleStepUpDown, DegFromRad(Model.shapeParam.mAngleStep) * 10); SafeSetUpDownRange(numericUpDown5, Model.shapeParam.mMinScale); SafeSetUpDownRange(numericUpDown4, Model.shapeParam.mMaxScale); SafeSetUpDownRange(numericUpDown3, Model.shapeParam.mScaleStep * 100); SafeSetUpDownRange(numUpDwnNumLevels, Model.shapeParam.mNumLevel); SafeSetUpDownRange(numericUpDown9, Model.shapeParam.mContrast); SafeSetUpDownRange(numericUpDown8, Model.shapeParam.mMinContrast); if (Model.shapeParam.mOptimization == "none") { comboBox4.SelectedIndex = 0; } else if (Model.shapeParam.mOptimization == "point_reduction_low") { comboBox4.SelectedIndex = 1; } else if (Model.shapeParam.mOptimization == "point_reduction_medium") { comboBox4.SelectedIndex = 2; } else if (Model.shapeParam.mOptimization == "point_reduction_high") { comboBox4.SelectedIndex = 3; } if (Model.shapeParam.mMetric == "use_polarity") { comboBox3.SelectedIndex = 0; } else if (Model.shapeParam.mMetric == "ignore_global_polarity") { comboBox3.SelectedIndex = 1; } if (Model.shapeParam.mSubpixel == "none") { comboBox1.SelectedIndex = 0; } else if (Model.shapeParam.mSubpixel == "least_squares") { comboBox1.SelectedIndex = 1; } else if (Model.shapeParam.mSubpixel == "interpolation") { comboBox1.SelectedIndex = 2; } SafeSetUpDownRange(numericUpDown6, Model.shapeParam.mMinScore * 100); SafeSetUpDownRange(numericUpDown7, Model.shapeParam.mNumMatches); SafeSetUpDownRange(numericUpDown1, Model.shapeParam.mMaxOverlap * 100); SafeSetUpDownRange(numericUpDown2, Model.OutTime); SafeSetUpDownRange(numericUpDown10, Model.shapeParam.mGreediness); checkBox1.Checked = Model.TimeOutEnable; checkBox2.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_ANGLE_STEP); checkBox4.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_SCALE_STEP); checkBox3.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_NUM_LEVEL); checkBox7.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_OPTIMIZATION); checkBox5.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_CONTRAST); checkBox6.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_MIN_CONTRAST); }
int DrawRegionCtrlFlag = 0; // 1 - 绘制搜索区域 2 - 绘制模板区域 3 - 绘制十字叉 private void Button1_Click(object sender, EventArgs e) { hWndCtrller.AddIconicVar(Model.ModelImg); rOI = new ROIRectangle1(); ctrller.Reset(); ctrller.SetROISign(ROICtrller.SIGN_ROI_POS); hWndCtrller.Repaint(); ctrller.SetROIShape(rOI); DrawRegionCtrlFlag = 1; }