/// <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> /// 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); } } }