/// <summary> /// draw, 決定要畫什麼在 window 上 /// </summary> /// <param name="window">Halcon Window</param> public override void draw(HalconDotNet.HWindow window) { double arrowSize = 2; double crossSize = 12; double crossAngle = 0.785398; HTuple dotLineStyle = new HTuple(new int[4] { 7, 7, 7, 7 }); //Reset line Style HOperatorSet.SetLineStyle(window, null); //寫字 if (!String.IsNullOrEmpty(Name)) { HOperatorSet.SetTposition(window, this.NewCenterRow, this.NewCenterCol); if (!this.IsActive) HOperatorSet.SetColor(window, "red"); window.WriteString(Name); } // 畫箭頭, 由線段的中心點向兩端畫箭頭 window.SetLineWidth(1); //計算兩箭頭端點位置 var arrowPointRowBegin = _arrowLineRowBegin = this.NewCenterRow + (Math.Sin(_phiStart) * _halfDistance); var arrowPointColBegin = _arrowLineColBegin = this.NewCenterCol + (Math.Cos(_phiStart) * _halfDistance); var arrowPointRowEnd = _arrowLineRowEnd = this.NewCenterRow + (Math.Sin(_phiEnd) * _halfDistance); var arrowPointColEnd = _arrowLineColEnd = this.NewCenterCol + (Math.Cos(_phiEnd) * _halfDistance); window.DispArrow(this.NewCenterRow, this.NewCenterCol, arrowPointRowBegin, arrowPointColBegin, arrowSize); window.DispArrow(this.NewCenterRow, this.NewCenterCol, arrowPointRowEnd, arrowPointColEnd, arrowSize); //畫虛線,如果使用者改變了原始中心點的位置 //由兩箭頭端點連結原始的起始兩端點 if (_rawCenterRow != this.NewCenterRow || _rawCenterCol != this.NewCenterCol) { HOperatorSet.SetLineStyle(window, dotLineStyle); //決定兩個端點的連結,將座標點 以左上排序 var arrowPoints = new List<PositionModel>() { new PositionModel(){ RowBegin =arrowPointRowBegin, ColBegin = arrowPointColBegin }, new PositionModel(){ RowBegin =arrowPointRowEnd, ColBegin = arrowPointColEnd }, }; arrowPoints = arrowPoints.OrderBy(x => x.ColBegin).OrderBy(y => y.RowBegin).ToList(); for (int i = 0; i < _ROIModelPoints.Count; i++) window.DispLine(arrowPoints[i].RowBegin, arrowPoints[i].ColBegin, _ROIModelPoints[i].RowBegin, _ROIModelPoints[i].ColBegin); } //reset Style HOperatorSet.SetLineStyle(window, null); //畫ROI window.SetLineWidth(1); if (!this.IsActive) HOperatorSet.SetColor(window, "magenta"); for (var i = 0; i < _dependROIModels.Count; i++) { var line = _dependROIModels[i]; if (isLine(line)) { //draw line,ROI 的線 window.DispLine(line.RowBegin, line.ColBegin, line.RowEnd, line.ColEnd); } else { //draw point,ROI 的點 HXLDCont crossPoint = new HXLDCont(); crossPoint.GenEmptyObj(); crossPoint.GenCrossContourXld(line.RowBegin, line.ColBegin, crossSize, crossAngle); crossPoint.DispObj(window); //window.DispCross(line.RowBegin, line.ColBegin, crossSize, crossAngle); } } }
/// <summary>Paints the ROI into the supplied window.</summary> public override void draw(HalconDotNet.HWindow window) { window.DispLine(row1, col1, row2, col2); window.DispRectangle2(row1, col1, 0, 5, 5); window.DispObj(arrowHandleXLD); //window.DispRectangle2( row2, col2, 0, 5, 5); window.DispRectangle2(midR, midC, 0, 5, 5); }
/// <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> /// Repaints the HALCON window 'window' /// </summary> public void repaintUsingFlushGraphic(HalconDotNet.HWindow window) { int count = HObjList.Count; HObjectEntry entry; if (window != null) { HSystem.SetSystem("flush_graphic", "false"); window.ClearWindow(); // check the boundatries of the image part if ((ImgRow2 > ImgRow1) && (ImgCol2 > ImgCol1)) window.SetPart((int)ImgRow1, (int)ImgCol1, (int)ImgRow2, (int)ImgCol2); // set the image part to window size else window.SetPart(0, 0, windowHeight - 1, windowWidth - 1); mGC.stateOfSettings.Clear(); for (int i = 0; i < count; i++) { entry = ((HObjectEntry)HObjList[i]); if (entry != null) { mGC.applyContext(window, entry.gContext); window.DispObj(entry.HObj); } } addInfoDelegate(); if (roiManager != null && (dispROI == MODE_INCLUDE_ROI)) roiManager.paintData(window); HSystem.SetSystem("flush_graphic", "true"); window.DispLine(-1000.0, -1000.0, -1001.0, -1001.0); } }
/// <summary> /// draw, 決定要畫什麼在 window 上 /// </summary> /// <param name="window">Halcon Window</param> public override void draw(HalconDotNet.HWindow window) { double arrowSize = 2; //double crossSize = 12; //double crossAngle = 0.785398; HTuple dotLineStyle = new HTuple(new int[4] { 7, 7, 7, 7 }); //Reset line Style HOperatorSet.SetLineStyle(window, null); //寫字 if (!String.IsNullOrEmpty(Name)) { if (!this.IsActive) HOperatorSet.SetColor(window, "red"); HOperatorSet.SetTposition(window, this.NewCenterRow, this.NewCenterCol); window.WriteString(Name); } //畫線段,水平 + 30 度角 var lineLength = 50; var angle = Math.PI / 6.0; var hLineRow = this.NewCenterRow + Math.Sin(Math.PI) * lineLength; var hLineCol = this.NewCenterCol - Math.Cos(Math.PI) * lineLength; var degLineRow = this.NewCenterRow - Math.Sin(angle) * lineLength; var degLineCol = this.NewCenterCol + Math.Cos(angle) * lineLength; HOperatorSet.DispLine(window, this.NewCenterRow, this.NewCenterCol, hLineRow, hLineCol); HOperatorSet.DispLine(window, this.NewCenterRow, this.NewCenterCol, degLineRow, degLineCol); //畫 arc // angle 為正時,會順時針畫, // angle 為負時,會逆時針畫, // 因此要注意兩線段夾角的開口方向來選擇 var arcBeginRow = this.NewCenterRow - Math.Sin(angle) * (lineLength / 2.0); var arcBeginCol = this.NewCenterCol + Math.Cos(angle) * (lineLength / 2.0); window.DispArc(this.NewCenterRow, this.NewCenterCol, angle, arcBeginRow, arcBeginCol); // 畫箭頭, window.SetLineWidth(1); HOperatorSet.SetLineStyle(window, dotLineStyle); window.DispArrow(this.NewCenterRow, this.NewCenterCol, _lineACenterRow, _lineACenterCol, arrowSize); window.DispArrow(this.NewCenterRow, this.NewCenterCol, _lineBCenterRow, _lineBCenterCol, arrowSize); //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]; if (isLine(line)) { //draw line,ROI 的線 window.DispLine(line.RowBegin, line.ColBegin, line.RowEnd, line.ColEnd); } } }
/// <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>Paints the ROI into the supplied window.</summary> public override void draw(HalconDotNet.HWindow window) { window.DispLine(_StartRow, _StartColumn, _EndRow, _EndCol); //window.DispRectangle2(_StartRow, _StartColumn, 0, 5, 5);//開始 //window.DispObj(_AuxLineHandleXLD); //window.DispRectangle2( row2, col2, 0, 5, 5); //箭頭 //window.DispRectangle2(_MidRow, _MidCol, 0, 5, 5);//中間 }
/// <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); }