private void StartTeachBtn1_Click(object sender, EventArgs e) { HObject RoiContour = new HObject(); HTuple ArcType = new HTuple(); if (StartTeachBtn1.Text == "开始示教") { GroupBoxEnable(groupBox3, false); StartTeachBtn1.Enabled = true; StartTeachBtn1.Text = "保存"; view1.Refresh(); view1.AddImage(GrabedImg); ActionIsDrawingRoi(true); view1.roiController.reset(); view1.roiController.setROIShape(new ViewROI.ROICircularArc()); } else if (StartTeachBtn1.Text == "保存") { ActionIsDrawingRoi(false); GroupBoxEnable(groupBox3, true); ViewROI.ROICircularArc arc = new ViewROI.ROICircularArc(); if (view1.roiController.getActiveROI() is ViewROI.ROICircularArc) { StartTeachBtn1.Enabled = false; StartTeachBtn1.Text = "开始示教"; arc = (ViewROI.ROICircularArc)view1.roiController.getActiveROI(); arc.GetCircleArc(out TeachCenterRow, out TeachCenterCol, out TeachCircleR, out TeachStartPhi, out TeachEndPhi); if (ArcType.Length > 0) { TeachArcType = ArcType.S; } Thread TeachThd = new Thread(TeachProcess); TeachThd.IsBackground = true; TeachThd.Start(); } else { MessageBox.Show("请选中形状"); return; } } }
private void DrawCircleRoi() { try{ if (StartTeachBtn1.Text == "开始示教") { this.StartTeachBtn1.Text = "保存"; this.EnableGroupbox(groupBox3, false); this.StartTeachBtn1.Enabled = true; this.myView.Refresh(); this.myView.AddImage(GrabedImg); ActionIsDrawingRoi(true); this.myView.roiController.reset(); this.myView.roiController.setROIShape(new ViewROI.ROICircularArc()); } else if (StartTeachBtn1.Text == "保存") { ViewROI.ROICircularArc myCircleArc = new ViewROI.ROICircularArc(); if (myView.roiController.getActiveROI() is ViewROI.ROICircularArc) { this.EnableGroupbox(groupBox3, true); StartTeachBtn1.Text = "开始示教"; groupBox3.Enabled = true; myCircleArc = (ViewROI.ROICircularArc)myView.roiController.getActiveROI(); double CenterRow, CenterCol, CirR, StartPhi, EndPhi; myCircleArc.GetCircleArc(out CenterRow, out CenterCol, out CirR, out StartPhi, out EndPhi); HTuple ListRow = new HTuple(), ListCol = new HTuple(); MyVisionBase.GenCirclePts2(CenterRow, CenterCol, CirR, StartPhi, EndPhi, "positive", out DrawRows, out DrawCols); ActionIsDrawingRoi(false); Thread TeachThd = new Thread(DrawCircleProcess); TeachThd.IsBackground = true; TeachThd.Start(); } else { MessageBox.Show("请选中示教的圆弧,选中后,圆心的小矩形会变红"); } } } catch (Exception e0) { Logger.PopError(e0.Message, true); } }