Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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;
        }