コード例 #1
0
ファイル: Ufrm_Circle.cs プロジェクト: Tamiy2020/Vision
        private void btn_DrawCircle_Click(object sender, EventArgs e)
        {
            if (circle == null)
            {
                circle = new Circle();
                data   = circle;
            }

            hWindow_Final1.HobjectToHimage(ho_Image);                                                     //刷新显示区
            DrawMode(true);                                                                               //绘制模式开启
            circle.SetCircle(Func_HalconFunction.DrawCircle(hWindow_Final1.hWindowControl.HalconWindow)); //画圆编辑模式
            DrawMode(false);                                                                              //绘制模式关闭

            getCircleUseThreshold = null;
            nud_Circle_x.Value    = (decimal)circle.hv_Column.D; //赋值
            nud_Circle_y.Value    = (decimal)circle.hv_Row.D;    //赋值
            nud_Radius.Value      = (decimal)circle.hv_Radius.D; //赋值
            prepared = true;                                     //可以运行
            RunOnce();                                           //运行一次
        }
コード例 #2
0
ファイル: Ufrm_Circle.cs プロジェクト: Tamiy2020/Vision
        private void btn_DrawROIs_Click(object sender, EventArgs e)
        {
            if (getCircleUseThreshold == null)
            {
                getCircleUseThreshold = new GetCircleUseThreshold();
                data   = getCircleUseThreshold;
                circle = null;
            }
            getCircleUseThreshold.RemoveAll();                                                                      //删除所有项
            hWindow_Final1.HobjectToHimage(ho_Image);                                                               //刷新图片
            hWindow_Final1.ContextMenuStrip = contextMenuStrip1;                                                    //启用右键菜单
            DrawMode(true);                                                                                         //绘制模式开启
            Rectangle2 rectangle2 = Func_HalconFunction.DrawRectangle2(hWindow_Final1.hWindowControl.HalconWindow); //画矩形

            DrawMode(false);                                                                                        //绘制模式关闭
            HObject ho_Rectangle = Func_HalconFunction.GenRectangle2(rectangle2);                                   //创建矩形

            hWindow_Final1.DispObj(ho_Rectangle, "blue");                                                           //显示矩形
            getCircleUseThreshold.AddRegion(new GetRegionUseThreshold(new Threshold(rectangle2)));                  //添加该项
        }
コード例 #3
0
ファイル: Ufrm_Circle.cs プロジェクト: Tamiy2020/Vision
        private void Ufrm_Circle_Load(object sender, EventArgs e)
        {
            hWindow_Final1.HobjectToHimage(ho_Image);
            if (measureManager == null)
            {
                measureManager = form.measureManager;
            }
            cmb_Transition.SelectedIndex = 0;
            cmb_Select.SelectedIndex     = 0;

            #region 跟踪
            List <MeasuringUnit> translations = measureManager.ListAllTranslation();//所有平移跟踪

            verticalPositions   = new List <MeasuringUnit>();
            horizontalPositions = new List <MeasuringUnit>();
            for (int i = translations.Count - 1; i >= 0; i--)
            {
                if ((translations[i] as TranslationTracking).line.AxByC0.k == null)
                {
                    horizontalPositions.Add(translations[i]);
                    cmb_HorizontalTracking.Items.Add(translations[i].name);
                }

                else if ((translations[i] as TranslationTracking).line.AxByC0.k.D == 0) //?是水平线
                {
                    verticalPositions.Add(translations[i]);                             //添加垂直定位
                    cmb_VerticalTracking_L.Items.Add(translations[i].name);             //添加垂直跟踪
                }
            }
            #endregion

            if (EditMode)//编辑模式
            {
                txt_Name.Text = data.name;
                //txt_Name.Enabled = false;//编辑模式下不能编辑名字

                if (data is GetCircleUseThreshold)
                {
                    tabControl1.TabPages.Remove(tabPage1);
                    tabControl1.TabPages.Remove(tabPage3);
                    getCircleUseThreshold = data as GetCircleUseThreshold;
                    // nud_MaxGray.Value = trb_MaxGray.Value = (getCircleUseThreshold.RegionList[0] as GetRegionUseThreshold).parameter.hv_MaxGray;
                    //nud_MinGray.Value = trb_MinGray.Value = (getCircleUseThreshold.RegionList[0] as GetRegionUseThreshold).parameter.hv_MinGray;
                    tabControl1.SelectedTab = tabPage2;
                    cmb_slg_SelectItem.Items.AddRange(getCircleUseThreshold.GetRegionsName());//添加combobox项
                }
                else if (data is GetCircleUseMetrology)
                {
                    tabControl1.TabPages.Remove(tabPage1);
                    tabControl1.TabPages.Remove(tabPage2);

                    getCircleUseMetrology = data as GetCircleUseMetrology;
                    nud_Length1.Value     = (decimal)getCircleUseMetrology.parameter.measureLength1.D;
                    nud_Length2.Value     = (decimal)getCircleUseMetrology.parameter.measureLength2.D;
                    nud_Distance.Value    = (decimal)getCircleUseMetrology.parameter.measureDistance.D;
                    nud_Threshold.Value   = (decimal)getCircleUseMetrology.parameter.measureThreshold.D;
                    if (getCircleUseMetrology.parameter.measureTransition == "positive")
                    {
                        cmb_Transition.SelectedIndex = 0;
                    }
                    if (getCircleUseMetrology.parameter.measureTransition == "negative")
                    {
                        cmb_Transition.SelectedIndex = 1;
                    }
                    if (getCircleUseMetrology.parameter.measureTransition == "all")
                    {
                        cmb_Transition.SelectedIndex = 2;
                    }
                    if (getCircleUseMetrology.parameter.measureTransition == "uniform")
                    {
                        cmb_Transition.SelectedIndex = 3;
                    }
                    if (getCircleUseMetrology.parameter.measureSelect == "first")
                    {
                        cmb_Select.SelectedIndex = 0;
                    }
                    if (getCircleUseMetrology.parameter.measureSelect == "last")
                    {
                        cmb_Select.SelectedIndex = 1;
                    }
                    if (getCircleUseMetrology.parameter.measureSelect == "all")
                    {
                        cmb_Select.SelectedIndex = 2;
                    }

                    tabControl1.SelectedTab = tabPage3;
                }
                else
                {
                    circle             = data as Circle;
                    nud_Circle_x.Value = (decimal)circle.hv_Column.D;
                    nud_Circle_y.Value = (decimal)circle.hv_Row.D;
                    nud_Radius.Value   = (decimal)circle.hv_Radius.D;


                    if (circle.position_Horizontal != null)
                    {
                        cmb_HorizontalTracking.SelectedItem = circle.position_Horizontal.name;
                    }

                    if (circle.position_Vertical_L != null)
                    {
                        cmb_VerticalTracking_L.SelectedItem = circle.position_Vertical_L.name;
                    }

                    tabControl1.SelectedTab = tabPage1;
                    tabControl1.TabPages.Remove(tabPage2);
                    tabControl1.TabPages.Remove(tabPage3);
                }
                prepared = true;
            }
            else
            {
                circle = new Circle();
                data   = circle;
            }
            RunOnce();
        }