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