/// <summary> /// �e��u /// </summary> private void drawGridLines(HalconDotNet.HWindow window) { if (this.HLines > 0 || this.VLines > 0) { //��X����u���j var interval_H = this.imageHeight / (this.HLines + 1); //��X�����u���j var interval_W = this.imageWidth / (this.VLines + 1); //�]�w�u�q�˦� HTuple dotLineStyle = new HTuple(new int[4] { 7, 7, 7, 7 }); HOperatorSet.SetLineStyle(window, dotLineStyle); window.SetColor("red"); //�e����u for (int i = 0; i < this.HLines; i++) { var rowBegin = (i + 1) * interval_H; var rowEnd = rowBegin; var colBegin = 0; var colEnd = this.imageWidth; HOperatorSet.DispLine(window, rowBegin, colBegin, rowEnd, colEnd); } //�e�����u for (int i = 0; i < this.VLines; i++) { var rowBegin = 0; var rowEnd = this.imageHeight; var colBegin = (i + 1) * interval_W; var colEnd = colBegin; HOperatorSet.DispLine(window, rowBegin, colBegin, rowEnd, colEnd); } //Reset LineStyle HOperatorSet.SetLineStyle(window, null); } }
/// <summary> /// draw, 決定要畫什麼在 window 上 /// </summary> /// <param name="window">Halcon Window</param> public override void draw(HalconDotNet.HWindow window) { //虛線 HTuple dotLineStyle = new HTuple(new int[4] { 20, 7, 3, 7 }); //寫字 if (!String.IsNullOrEmpty(Name)) { if (!this.IsActive) window.SetColor("red"); HOperatorSet.SetTposition(window, _rawCenterRow, _rawCenterCol); window.WriteString(Name); } //Draw 中線 window.SetLineStyle(dotLineStyle); window.DispLine(_model.RowBegin, _model.ColBegin, _model.RowEnd, _model.ColEnd); //Reset line Style HOperatorSet.SetLineStyle(window, null); //畫相依的線元素 (ROI) window.SetLineWidth(2); if (!this.IsActive) HOperatorSet.SetColor(window, "magenta"); for (var i = 0; i < _lines.Count; i++) { var line = _lines[i]; window.DispLine(line.RowBegin, line.ColBegin, line.RowEnd, line.ColEnd); } }
/// <summary> /// Paints all objects from the ROIList into the HALCON window /// </summary> /// <param name="window">HALCON window</param> public void paintData(HalconDotNet.HWindow window) { window.SetDraw("margin"); window.SetLineWidth(1); //�e�٥������� ROI if (_waitForClickROI != null) { _waitForClickROI.draw(window); } if (ROIList.Count > 0) { window.SetColor(inactiveCol); window.SetDraw("margin"); //�e�Ҧ��� ROI for (int i = 0; i < ROIList.Count; i++) { if (i == activeROIidx) continue; var roi = (ROI)ROIList[i]; roi.IsActive = false; if (roi.Visiable) { window.SetLineStyle(roi.flagLineStyle); roi.SetZoomRatio(_zoomFactor); roi.draw(window); } } //�e Active ROI if (activeROIidx != -1) { var activeROI = (ROI)ROIList[activeROIidx]; activeROI.IsActive = true; if (activeROI.Visiable) { window.SetColor(activeCol); window.SetLineStyle(activeROI.flagLineStyle); activeROI.draw(window); window.SetColor(activeHdlCol); activeROI.displayActive(window); } } } }
/// <summary> /// Repaints the HALCON window 'window' /// </summary> public void repaint(HalconDotNet.HWindow window) { try { int count = HObjList.Count; HObjectEntry entry; HSystem.SetSystem("flush_graphic", "false"); window.ClearWindow(); mGC.stateOfSettings.Clear(); for (int i = 0; i < count; i++) { entry = ((HObjectEntry)HObjList[i]); mGC.applyContext(window, entry.gContext); window.DispObj(entry.HObj); } addInfoDelegate(); if (_roiManager != null && (_dispROI == MODE_INCLUDE_ROI)) _roiManager.paintData(window); var prevScaleC = (double)((ImgCol2 - ImgCol1) / imageWidth); foreach (var wViewModel in WriteStringList) { window.SetColor("red"); HOperatorSet.SetTposition(window, wViewModel.Row, wViewModel.Col); HOperatorSet.WriteString(window, wViewModel.Text); } //Display Arrow var arrowSize = 5 * prevScaleC; arrowSize = (arrowSize < 2) ? 2 : arrowSize; foreach (var arrowModel in ArrowList) { HOperatorSet.DispArrow(window, arrowModel.CenterY, arrowModel.CenterX, arrowModel.FirstArrowY, arrowModel.FirstArrowX, arrowSize); HOperatorSet.DispArrow(window, arrowModel.CenterY, arrowModel.CenterX, arrowModel.SecArrowY, arrowModel.SecArrowX, arrowSize); } //�e��u if (ShowGrid) { drawGridLines(window); } HSystem.SetSystem("flush_graphic", "true"); window.SetColor(this.RepaintWindowColor); window.DispLine(-100.0, -100.0, -101.0, -101.0); } catch (HOperatorException ex) { var errorNumber = ex.GetErrorNumber(); /* 5106 �o�ͱ��Ҭ� * 1�C�}���^���v����A���_�u�N���� MDI ���� */ if (errorNumber != 5106 && errorNumber != 5100) { Hanbo.Log.LogManager.Error(ex); } } }
/// <summary> /// draw, 決定要畫什麼在 window 上 /// </summary> /// <param name="window">Halcon Window</param> public override void draw(HalconDotNet.HWindow window) { double crossSize = 12; double crossAngle = 0.785398; //寫字 if (!String.IsNullOrEmpty(Name)) { if (!this.IsActive) window.SetColor("red"); HOperatorSet.SetTposition(window, _model.RowBegin, _model.ColBegin); window.WriteString(Name); } //畫交點 if (!this.IsActive) HOperatorSet.SetColor(window, "magenta"); //HOperatorSet.SetDraw(window, "fill"); HOperatorSet.SetLineWidth(window, 2); HOperatorSet.DispCross(window, _model.RowBegin, _model.ColBegin, crossSize, crossAngle); //畫相依的線元素 (ROI) window.SetLineWidth(2); if (!this.IsActive) HOperatorSet.SetColor(window, "magenta"); for (var i = 0; i < _lines.Count; i++) { var line = _lines[i]; window.DispLine(line.RowBegin, line.ColBegin, line.RowEnd, line.ColEnd); } }
/// <summary> /// draw, 決定要畫什麼在 window 上 /// </summary> /// <param name="window">Halcon Window</param> public override void draw(HalconDotNet.HWindow window) { double crossSize = 12; double crossAngle = 0.785398; //寫字 if (!String.IsNullOrEmpty(Name)) { if (!this.IsActive) window.SetColor("red"); HOperatorSet.SetTposition(window, _model.RowBegin, _model.ColBegin); window.WriteString(Name); } //畫圓 if (!this.IsActive) window.SetColor("magenta"); window.SetLineWidth(2); var radius = _model.Distance / CircleDistanceSetting; window.DispCross(_model.RowBegin, _model.ColBegin, crossSize, crossAngle); window.DispCircle(_model.RowBegin, _model.ColBegin, radius); //畫圓內虛線 /**/ window.SetLineWidth(1); HTuple dotLineStyle = new HTuple(new int[4] { 20, 7, 3, 7 }); window.SetLineStyle(dotLineStyle); var hLineRowBegin = _model.RowBegin; var hLineColBegin = _model.ColBegin - radius; var hLineRowEnd = _model.RowBegin; var hLineColEnd = _model.ColBegin + radius; var vLineRowBegin = _model.RowBegin - radius; var vLineColBegin = _model.ColBegin; var vLineRowEnd = _model.RowBegin + radius; var vLineColEnd = _model.ColBegin; window.DispLine(hLineRowBegin, hLineColBegin, hLineRowEnd, hLineColEnd); window.DispLine(vLineRowBegin, vLineColBegin, vLineRowEnd, vLineColEnd); //Reset line Style HOperatorSet.SetLineStyle(window, null); }
/// <summary> /// Paints all objects from the ROIList into the HALCON window /// </summary> /// <param name="window">HALCON window</param> public void paintData(HalconDotNet.HWindow window) { window.SetDraw("margin"); window.SetLineWidth(1); if (ROIList.Count > 0) { window.SetColor(inactiveCol); window.SetDraw("margin"); for (int i=0; i < ROIList.Count; i++) { window.SetLineStyle(((ROI)ROIList[i]).flagLineStyle); ((ROI)ROIList[i]).draw(window); } if (activeROIidx != -1) { window.SetColor(activeCol); window.SetLineStyle(((ROI)ROIList[activeROIidx]).flagLineStyle); ((ROI)ROIList[activeROIidx]).draw(window); window.SetColor(activeHdlCol); ((ROI)ROIList[activeROIidx]).displayActive(window); } } }
/// <summary> /// Paints specified region from the ROIList into the HALCON window /// </summary> /// <param name="window">HALCON window</param> public void paintSpecifiedROI(HalconDotNet.HWindow window, int RegionID) { window.SetDraw("margin"); window.SetLineWidth(1); if ((ROIList.Count > 0) && (ROIList.Count > RegionID)) { window.SetColor(inactiveCol); window.SetDraw("margin"); window.SetLineStyle(((ROI)ROIList[RegionID]).flagLineStyle); ((ROI)ROIList[RegionID]).draw(window); if ((activeROIidx != -1) && (activeROIidx == RegionID)) { window.SetColor(activeCol); window.SetLineStyle(((ROI)ROIList[activeROIidx]).flagLineStyle); ((ROI)ROIList[activeROIidx]).draw(window); window.SetColor(activeHdlCol); ((ROI)ROIList[activeROIidx]).displayActive(window); } } }
/// <summary> /// Paints all objects from the ROIList into the HALCON window /// </summary> /// <param name="window">HALCON window</param> public void paintData(HalconDotNet.HWindow window) { window.SetDraw("margin"); window.SetLineWidth(1); if (ROIList.Count > 0) { window.SetDraw("fill"); window.SetLineStyle(new HTuple()); window.SetColor("blue"); defineModelROI(); if (ModelROI != null) window.DispRegion(ModelROI); window.SetColor(inactiveCol); window.SetDraw("margin"); for (int i=0; i < ROIList.Count; i++) { window.SetLineStyle(((ROI)ROIList[i]).flagLineStyle); ((ROI)ROIList[i]).draw(window); } if (activeROIidx != -1) { window.SetColor(activeCol); window.SetLineStyle(((ROI)ROIList[activeROIidx]).flagLineStyle); ((ROI)ROIList[activeROIidx]).draw(window); window.SetColor(activeHdlCol); ((ROI)ROIList[activeROIidx]).displayActive(window); } } }