private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { var roi = RoiController.getActiveROI(); if (roi == null) { return; } var roiParameters = new HTuple(); for (var i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[1].Value != null) { if (dataGridView1.Rows[i].Cells[1].Value.ToString() != "") { roiParameters[i] = Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value); } else { roiParameters[i] = 100; } } } roi.createROI(roiParameters); RoiController.viewController.repaint(); }
/// <summary> /// Update the current ROI (region of interest) according to /// the changes that were performed through user interaction. /// </summary> public void UpdateViewData(int val) { switch (val) { case ROIController.EVENT_CHANGED_ROI_SIGN: CalcCurrentROI(); if (OnROISignChanged != null) { OnROICreated(this, roiController.getActiveROI()); } break; case ROIController.EVENT_DELETED_ACTROI: case ROIController.EVENT_DELETED_ALL_ROIS: CalcCurrentROI(); if (OnActiveROIDeleted != null) { // if activated ROI is deleted or all ROIs // are deleted, the event parameter for ROI // is set NULL OnActiveROIDeleted(this, null); } break; case ROIController.EVENT_CREATED_ROI: CalcCurrentROI(); if (OnROICreated != null) { OnROICreated(this, roiController.getActiveROI()); } break; case ROIController.EVENT_UPDATE_ROI: CalcCurrentROI(); if (OnROIChanged != null) { OnROIChanged(this, roiController.getActiveROI()); } break; case ROIController.EVENT_REPAINT_ROI: this.Invalidate(); break; default: break; } this.Invalidate(); }
void ShowSection() { ROI line = roiController.getActiveROI(); HTuple lineCoord = line.getModelData(); HObject Rline = new HObject(); HOperatorSet.GenRegionLine(out Rline, lineCoord[0], lineCoord[1], lineCoord[2], lineCoord[3]); HTuple row, col; HObject Rline1 = new HObject(); HOperatorSet.GenContourRegionXld(Rline, out Rline1, "border"); HOperatorSet.GetContourXld(Rline1, out row, out col); HTuple Zpoint = new HTuple(), Xpoint = new HTuple(); if (row.Length == 0) { return; } HTuple width, height, lessId1, lessId2; HOperatorSet.GetImageSize(sw.hwnd[1].Image, out width, out height); HOperatorSet.TupleLessElem(row, height, out lessId1); HOperatorSet.TupleFind(lessId1, 1, out lessId1); row = row[lessId1]; col = col[lessId1]; HOperatorSet.TupleLessElem(col, width, out lessId2); HOperatorSet.TupleFind(lessId2, 1, out lessId2); row = row[lessId2]; col = col[lessId2]; HOperatorSet.GetGrayval(sw.hwnd[1].Image, row, col, out Zpoint); HTuple EqId = new HTuple(); HOperatorSet.TupleNotEqualElem(Zpoint, -30, out EqId); HOperatorSet.TupleFind(EqId, 1, out EqId); Zpoint = Zpoint[EqId]; HOperatorSet.TupleGenSequence(0, Zpoint.Length, context.xResolution, out Xpoint); Zpoint = Zpoint * 50; Xpoint = Xpoint * 50; HTuple RowNew, ColNew; HObject Region, Contour, ConstImage; GenProfile(true, Zpoint, Xpoint, out RowNew, out ColNew, out Region, out Contour); HOperatorSet.GenImageConst(out ConstImage, "byte", 1000, 1000); sw.hwnd[0].HobjectToHimage(ConstImage); sw.hwnd[0].viewWindow.displayHobject(Region, "red", true); Rline.Dispose(); Rline1.Dispose(); ConstImage.Dispose(); Region.Dispose(); Contour.Dispose(); }
private void ViewPort_HMouseMove(object sender, HMouseEventArgs e) { var roi = _roiCtrl.getActiveROI(); if (roi == null) { return; } for (var i = 0; i < roi.getModelDataName().Length; i++) { Debug.WriteLine($"{roi.getModelDataName()[i].S} : {roi.getModelData()[i].D}"); } }
/// <summary> /// ROI 操作事件通知 /// </summary> /// <param name="mode"></param> private void On_ROIUpdated(int mode) { switch (mode) { case ROIController.EVENT_CREATED_ROI: mAssistant.AddMeasureObject(); break; case ROIController.EVENT_Reload_ROI: mAssistant.AddMeasureObject(); mAssistant.UpdateMeasure(_roiController.getActiveROIIdx()); break; case ROIController.EVENT_ACTIVATED_ROI: mAssistant.ClickedActiveROI(); ROI activeROI = _roiController.getActiveROI(); //Todo //_geoManager.SetTreeViewNodeActivate(activeROI); break; case ROIController.EVENT_MOVING_ROI: mAssistant.UpdateMeasure(_roiController.getActiveROIIdx()); break; case ROIController.EVENT_DELETED_ACTROI: mAssistant.RemoveMeasureObjectActIdx(); break; case ROIController.EVENT_DELETED_ALL_ROIS: mAssistant.RemoveAllMeasureObjects(); break; } //顯示ROI 資訊 //Todo //showROIInfo(); //ToDo /*if (updateLineProfile) * PaintGraph();*/ }
private void RoiController_ROISelected(int obj) { this.activeROI = roiController.getActiveROI(); this.halconEditable?.SelectROI(this.activeROI); }