public void Run_transform(ExecuteBuffer _executeBuffer, 点GVName_halcon Point_result, 模板GVName_halcon Model_result, 圆GVName_halcon Circle_result, Dictionary <int, PointName> Point_temp_result, out Dictionary <int, PointName> Point_out_result) { int number_source = this.cbb_Inputsource.SelectedIndex; int number_get = Convert.ToInt32(this.tb_innumber.Text.ToString()); HTuple x, y; HTuple modelangle = 0, modelregionangle = 0; HTuple x2, y2; int inputlength1 = 0; Point_out_result = Point_temp_result; if (number_source == 0) { if (Point_result == null) { MessageBox.Show("算术计算: 输入为空,其中没有点位"); return; } if (Point_result.点X.TupleLength() < 1) { MessageBox.Show("算术计算: 输入阵列长度不够,达不到需求"); return; } else { x = Point_result.点X; y = Point_result.点Y; inputlength1 = Point_result.点X.TupleLength(); } } else if (number_source == 1) { if (Model_result == null) { MessageBox.Show("算术计算: 输入为空,其中没有点位"); return; } if (Model_result.点X.TupleLength() < 1) { MessageBox.Show("算术计算: 输入阵列长度不够,达不到需求"); return; } else { x = Model_result.点Y; y = Model_result.点X; modelangle = Model_result.角度Angle; modelregionangle = Model_result.模板Angle; inputlength1 = Model_result.点X.TupleLength(); } } else if (number_source == 2) { if (Circle_result == null) { MessageBox.Show("算术计算: 输入为空,其中没有点位"); return; } if (Circle_result.圆心X.TupleLength() < 1) { MessageBox.Show("算术计算: 输入阵列长度不够,达不到需求"); return; } else { x = Circle_result.圆心X; y = Circle_result.圆心Y; inputlength1 = Circle_result.圆心X.TupleLength(); } } else { if (Point_temp_result == null) { MessageBox.Show("算术计算: 输入为空,其中没有点位"); return; } if (Point_temp_result.ContainsKey(number_get)) { x = Point_temp_result[number_get].点X; y = Point_temp_result[number_get].点Y; inputlength1 = Point_temp_result[number_get].点X.TupleLength(); } else { MessageBox.Show("算术计算: 输入字典中没有该点位"); return; } } int number2 = this.cbb_inputsource2.SelectedIndex; int inputlength2 = 0; if (number2 == 0) { if (Point_temp_result == null) { MessageBox.Show("算术计算:输入为空,其中没有点位"); return; } int number_get2 = Convert.ToInt32(this.txt_number2.Text.ToString()); if (Point_temp_result.ContainsKey(number_get2)) { x2 = Point_temp_result[number_get2].点X; y2 = Point_temp_result[number_get2].点Y; inputlength2 = Point_temp_result[number_get2].点X.TupleLength(); } else { MessageBox.Show("算术计算: 输入字典中没有该点位"); return; } } else { x2 = Convert.ToDouble(this.tb_inputx.Text.ToString()); y2 = Convert.ToDouble(this.tb_inputy.Text.ToString()); inputlength2 = inputlength1; } HTuple output_x, output_y; int Trans_type = this.cbb_CalcType.SelectedIndex; int Calc_way = this.cbb_CalcType.SelectedIndex; int Calc_way1 = this.cbb_CalcType1.SelectedIndex; if (inputlength1 == inputlength2) { if (Calc_way == 0 && cbb_tri.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_y = x + x2 * Math.Cos(modelregionangle - modelangle); } else { output_y = x + x2 * Math.Cos(Convert.ToDouble(tb_angle.Text)); } } else if (Calc_way == 1 && cbb_tri.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_y = x - x2 * Math.Cos(modelregionangle - modelangle); } else { output_y = x - x2 * Math.Cos(Convert.ToDouble(tb_angle.Text)); } } else if (Calc_way == 2 && cbb_tri.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_y = x2 * Math.Cos(modelregionangle - modelangle) - x; } else { output_y = x2 * Math.Cos(Convert.ToDouble(tb_angle.Text)) - x; } } else if (Calc_way == 0 && cbb_tri.SelectedIndex == 1) { if (check_angle.Checked && number_source == 1) { output_y = x + x2 * Math.Sin(modelregionangle - modelangle); } else { output_y = x + x2 * Math.Sin(Convert.ToDouble(tb_angle.Text)); } } else if (Calc_way == 1 && cbb_tri.SelectedIndex == 1) { if (check_angle.Checked && number_source == 1) { output_y = x - x2 * Math.Sin(modelregionangle - modelangle); } else { output_y = x - x2 * Math.Sin(Convert.ToDouble(tb_angle.Text)); } } else { if (check_angle.Checked && number_source == 1) { output_y = x2 * Math.Sin(modelregionangle - modelangle) - x; } else { output_y = x2 * Math.Sin(Convert.ToDouble(tb_angle.Text)) - x; } } if (Calc_way1 == 0 && cbb_tri1.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_x = y + y2 * Math.Cos(modelregionangle - modelangle); } else { output_x = y + y2 * Math.Cos(Convert.ToDouble(tb_angle1.Text)); } } else if (Calc_way1 == 1 && cbb_tri1.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_x = y - y2 * Math.Cos(modelregionangle - modelangle); } else { output_x = y - y2 * Math.Cos(Convert.ToDouble(tb_angle1.Text)); } } else if (Calc_way1 == 2 && cbb_tri1.SelectedIndex == 0) { if (check_angle.Checked && number_source == 1) { output_x = y2 * Math.Cos(modelregionangle - modelangle) - y; } else { output_x = y2 * Math.Cos(Convert.ToDouble(tb_angle1.Text)) - y; } } else if (Calc_way1 == 0 && cbb_tri1.SelectedIndex == 1) { if (check_angle.Checked && number_source == 1) { output_x = y + y2 * Math.Sin(modelregionangle - modelangle); } else { output_x = y + y2 * Math.Sin(Convert.ToDouble(tb_angle1.Text)); } } else if (Calc_way1 == 1 && cbb_tri1.SelectedIndex == 1) { if (check_angle.Checked && number_source == 1) { output_x = y - y2 * Math.Sin(modelregionangle - modelangle); } else { output_x = y - y2 * Math.Sin(Convert.ToDouble(tb_angle1.Text)); } } else { if (check_angle.Checked && number_source == 1) { output_x = y2 * Math.Sin(modelregionangle - modelangle) - y; } else { output_x = y2 * Math.Sin(Convert.ToDouble(tb_angle1.Text)) - y; } } int out_number_list = Convert.ToInt32(this.tb_outnumber.Text.ToString()); if (Point_temp_result.ContainsKey(out_number_list)) { Point_temp_result[out_number_list].点X = output_x; Point_temp_result[out_number_list].点Y = output_y; } else { Point_temp_result.Add(out_number_list, new PointName(output_x, output_y)); } Point_out_result = Point_temp_result; this.label2.Text = "x 偏移:" + output_x.ToString() + "\n" + "y偏移是:" + output_y.ToString(); } }
public bool Run_transform(ExecuteBuffer _executeBuffer, 模板GVName_halcon Model_result, 圆GVName_halcon Circle_result, Dictionary <int, PointName> Point_temp_result, out Dictionary <int, PointName> Point_out_result, List <直线GVName> newline) { int number_source = this.cbb_Inputsource.SelectedIndex; int number_get = Convert.ToInt32(this.tb_innumber.Text.ToString()); HTuple x, y; HTuple modelangle = 0, modelregionangle = 0; int inputlength1 = 0; int number_line = Convert.ToInt32(this.txt_number2.Text); Point_out_result = Point_temp_result; if (newline == null) { // MessageBox.Show("线线交点:直线为空,请设置"); return(false); } if (newline.Count < 2) { // MessageBox.Show("线线交点:直线为空,请设置"); return(false); } if (newline.Count <= number_line) { //MessageBox.Show("线线交点:直线编号过大,请修改"); return(false); } if (newline.Count <= number_get) { // MessageBox.Show("线线交点:直线编号过大,请修改"); return(false); } double xrow1a = Convert.ToDouble(newline[number_get].点1X); double xcol1a = Convert.ToDouble(newline[number_get].点1Y); double xrow2a = Convert.ToDouble(newline[number_get].点2X); double xcol2a = Convert.ToDouble(newline[number_get].点2Y); double xrow1 = Convert.ToDouble(newline[number_line].点1X); double xcol1 = Convert.ToDouble(newline[number_line].点1Y); double xrow2 = Convert.ToDouble(newline[number_line].点2X); double xcol2 = Convert.ToDouble(newline[number_line].点2Y); HTuple output_x, output_y, distance; HOperatorSet.IntersectionLines(xrow1, xcol1, xrow2, xcol2, xrow1a, xcol1a, xrow2a, xcol2a, out output_x, out output_y, out distance); int out_number_list = Convert.ToInt32(this.tb_outnumber.Text.ToString()); if (Point_temp_result.ContainsKey(out_number_list)) { Point_temp_result[out_number_list].点X = output_x; Point_temp_result[out_number_list].点Y = output_y; } else { Point_temp_result.Add(out_number_list, new PointName(output_x, output_y)); } Point_out_result = Point_temp_result; this.label_show.Text = "点线距离:" + distance.ToString() + "\n" + "焦点X:" + output_x.ToString() + "\n" + "焦点y:" + output_y.ToString(); return(true); }
public bool Run_show(string color_set, 圆GVName_halcon Circle_result, 圆弧GVName_halcon Circlearc_result, 直线GVName_halcon Line_result, HWndCtrl hWndCtrl, out string out_info) { out_info = ""; if (color_set == "") { color_set = "red"; } HObject Circle1; HObject CircleArc1; HObject Line1; if (Circle_result == null) { MessageBox.Show("轮廓显示: 显示圆列表为空"); out_info = "轮廓显示: 圆为空"; } else { int Circle_result_number = Circle_result.圆心X.TupleLength(); for (int j = 0; j < Circle_result_number; j++) { //HOperatorSet.GenCircle(out Circle1, Circle_result.圆心X[j], Circle_result.圆心Y[j], Circle_result.半径R[j]); HOperatorSet.GenCircleContourXld(out Circle1, Circle_result.圆心X[j], Circle_result.圆心Y[j], Circle_result.半径R[j], 0, 2 * Math.PI, "positive", 1); hWndCtrl.changeGraphicSettings(GraphicsContext.GC_COLOR, color_set); hWndCtrl.addIconicVar(Circle1); } } if (Circlearc_result == null) { MessageBox.Show("轮廓显示: 圆弧为空"); out_info = out_info + " 圆弧为空"; } else { int Circlearc_result_number = Circlearc_result.半径R.TupleLength(); for (int m = 0; m < Circlearc_result_number; m++) { //HOperatorSet.GenCircleSector(out CircleArc1, Circlearc_result.圆心X[m], Circlearc_result.圆心Y[m], Circlearc_result.半径R[m], Circlearc_result.圆弧Start[m], Circlearc_result.圆弧End[m]); HOperatorSet.GenCircleContourXld(out CircleArc1, Circlearc_result.圆心X[m], Circlearc_result.圆心Y[m], Circlearc_result.半径R[m], Circlearc_result.圆弧Start[m], Circlearc_result.圆弧End[m], "positive", 1); hWndCtrl.changeGraphicSettings(GraphicsContext.GC_COLOR, color_set); hWndCtrl.addIconicVar(CircleArc1); } } if (Line_result == null) { MessageBox.Show("轮廓显示: 直线为空"); out_info = out_info + "直线为空"; } else { int line_result_number = Line_result.点1X.TupleLength(); for (int l = 0; l < line_result_number; l++) { HOperatorSet.GenContourPolygonXld(out Line1, ((HTuple)Line_result.点1X[l]).TupleConcat( (HTuple)Line_result.点2X[l]), ((HTuple)Line_result.点1Y[l]).TupleConcat((HTuple)Line_result.点2Y[l])); hWndCtrl.changeGraphicSettings(GraphicsContext.GC_COLOR, color_set); hWndCtrl.addIconicVar(Line1); } } hWndCtrl.repaint(); return(true); }
public void Run_transform(ExecuteBuffer _executeBuffer, 模板GVName_halcon Model_result, 圆GVName_halcon Circle_result, Dictionary <int, PointName> Point_temp_result, out Dictionary <int, PointName> Point_out_result, List <直线GVName> newline) { int number_source = this.cbb_Inputsource.SelectedIndex; int number_get = Convert.ToInt32(this.tb_innumber.Text.ToString()); HTuple x, y; HTuple modelangle = 0, modelregionangle = 0; int inputlength1 = 0; int number_line = Convert.ToInt32(this.txt_number2.Text); Point_out_result = Point_temp_result; if (number_source == 0) { if (Model_result == null) { MessageBox.Show("点线距离: 输入为空,其中没有点位"); return; } if (Model_result.点X.TupleLength() < 1) { MessageBox.Show("点线距离: 输入阵列长度不够,达不到需求"); return; } else { x = Model_result.点Y; y = Model_result.点X; modelangle = Model_result.角度Angle; modelregionangle = Model_result.模板Angle; inputlength1 = Model_result.点X.TupleLength(); } } else if (number_source == 1) { if (Circle_result == null) { MessageBox.Show("点线距离: 输入为空,其中没有点位"); return; } if (Circle_result.圆心X.TupleLength() < 1) { MessageBox.Show("点线距离: 输入阵列长度不够,达不到需求"); return; } else { x = Circle_result.圆心X; y = Circle_result.圆心Y; inputlength1 = Circle_result.圆心X.TupleLength(); } } else { if (Point_temp_result == null) { MessageBox.Show("点线距离: 输入为空,其中没有点位"); return; } if (Point_temp_result.ContainsKey(number_get)) { x = Point_temp_result[number_get].点X; y = Point_temp_result[number_get].点Y; inputlength1 = Point_temp_result[number_get].点X.TupleLength(); } else { MessageBox.Show("点线距离: 输入字典中没有该点位"); return; } } if (newline == null) { MessageBox.Show("点线距离ROI:直线为空,请设置"); return; } if (newline.Count < 1) { MessageBox.Show("点线距离ROI:直线为空,请设置"); return; } if (newline.Count <= number_line) { MessageBox.Show("点线距离ROI:直线编号过大,请修改"); return; } double xrow1 = Convert.ToDouble(newline[number_line].点1X); double xcol1 = Convert.ToDouble(newline[number_line].点1Y); double xrow2 = Convert.ToDouble(newline[number_line].点2X); double xcol2 = Convert.ToDouble(newline[number_line].点2Y); HTuple output_x, output_y, distance; HOperatorSet.ProjectionPl(x, y, xrow1, xcol1, xrow2, xcol2, out output_x, out output_y); HOperatorSet.DistancePl(x, y, xrow1, xcol1, xrow2, xcol2, out distance); int out_number_list = Convert.ToInt32(this.tb_outnumber.Text.ToString()); if (Point_temp_result.ContainsKey(out_number_list)) { Point_temp_result[out_number_list].点X = output_x; Point_temp_result[out_number_list].点Y = output_y; } else { Point_temp_result.Add(out_number_list, new PointName(output_x, output_y)); } int out_number_list1 = Convert.ToInt32(this.tb_outnumber12.Text.ToString()); if (Point_temp_result.ContainsKey(out_number_list1)) { Point_temp_result[out_number_list].点X = distance; Point_temp_result[out_number_list].点Y = 0; } else { Point_temp_result.Add(out_number_list1, new PointName(distance, 0)); } Point_out_result = Point_temp_result; this.label_show.Text = "点线距离:" + distance.ToString() + "\n" + "焦点X:" + output_x.ToString() + "\n" + "焦点y:" + output_y.ToString(); }
public void Run_transform(ExecuteBuffer _executeBuffer, 点GVName_halcon Point_result_halcon, 模板GVName_halcon Model_result_halcon, 圆GVName_halcon Circle_result_halcon, Dictionary <int, PointName> Point_temp_result, out Dictionary <int, PointName> Point_out_result) { int number_source = this.cbb_Inputsource.SelectedIndex; HTuple x, y; Point_out_result = Point_temp_result; if (number_source == 0) { if (Point_result_halcon == null) { MessageBox.Show("坐标转换: 输入为空,其中没有点位"); return; } if (Point_result_halcon.点X.TupleLength() == 0) { MessageBox.Show("坐标转换: 输入阵列长度不够,达不到需求"); return; } else { x = Point_result_halcon.点X; y = Point_result_halcon.点Y; } } else if (number_source == 1) { if (Model_result_halcon == null) { MessageBox.Show("坐标转换: 输入为空,其中没有点位"); return; } if (Model_result_halcon.点X.TupleLength() == 0) { MessageBox.Show("坐标转换: 输入阵列长度不够,达不到需求"); return; } else { x = Model_result_halcon.点X; y = Model_result_halcon.点Y; } } else if (number_source == 2) { if (Circle_result_halcon == null) { MessageBox.Show("坐标转换: 输入为空,其中没有点位"); return; } if (Circle_result_halcon.圆心X.TupleLength() == 0) { MessageBox.Show("坐标转换: 输入阵列长度不够,达不到需求"); return; } else { x = Circle_result_halcon.圆心X; y = Circle_result_halcon.圆心Y; } } else if (number_source == 3) { int number_get = Convert.ToInt32(this.tb_innumber.Text.ToString()); if (Point_temp_result == null) { MessageBox.Show("坐标转换: 输入为空,其中没有点位"); return; } if (Point_temp_result.ContainsKey(number_get)) { x = Point_temp_result[number_get].点X; y = Point_temp_result[number_get].点Y; } else { MessageBox.Show("坐标转换: 输入字典中没有该点位"); return; } } else { x = Convert.ToDouble(this.tb_inputx.Text.ToString()); y = Convert.ToDouble(this.tb_inputy.Text.ToString()); } if (this.cbb_HM_PTW.SelectedItem == null) { MessageBox.Show("坐标转换: 图像转世界为空,请设置"); return; } if (this.cbb_HM_WTP.SelectedItem == null) { MessageBox.Show("坐标转换: 世界转图像为空,请设置"); return; } HTuple output_x, output_y; int Trans_type = this.cbb_TransType.SelectedIndex; if (Trans_type == 0) { HOperatorSet.AffineTransPoint2d((HTuple)_executeBuffer.controlBuffer[this.cbb_HM_PTW.SelectedItem.ToString() + ".tuple"], x, y, out output_x, out output_y); } else { HOperatorSet.AffineTransPoint2d((HTuple)_executeBuffer.controlBuffer[this.cbb_HM_WTP.SelectedItem.ToString() + ".tuple"], x, y, out output_x, out output_y); } int out_number_list = Convert.ToInt32(this.tb_outnumber.Text.ToString()); //MessageBox.Show(""+_executeBuffer.controlBuffer[this.cbb_HM_WTP.SelectedItem.ToString()].GetType()); if (Point_temp_result.ContainsKey(out_number_list)) { Point_temp_result[out_number_list].点X = output_x; Point_temp_result[out_number_list].点Y = output_y; } else { Point_temp_result.Add(out_number_list, new PointName(output_x, output_y)); } //this.tb_outputx.Text = output_x.ToString(); // this.tb_outputy.Text = output_y.ToString(); Point_out_result = Point_temp_result; }