Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CreatModel = false;
            pictureBox1.Focus();
            if (PublicData.GetImage == false)
            {
                MessageBox.Show("未获取到图片");
                return;
            }
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                HalconCommonFunc.DrawRegion(WindowsHandle, DrawModel.Rectangle1, out HRegion);
                break;

            case 1:
                HalconCommonFunc.DrawRegion(WindowsHandle, DrawModel.Rectangle2, out HRegion);
                break;

            case 2:
                HalconCommonFunc.DrawRegion(WindowsHandle, DrawModel.Circle, out HRegion);
                break;

            default: return;
            }
            switch (comboBox2.SelectedIndex)
            {
            case 0:
                HalconCommonFunc.RegionOperatorset(PublicData.createNewCheckModel.VisualModelRegion, HRegion, OperatorModel.Union, out PublicData.createNewCheckModel.VisualModelRegion);
                break;

            case 1:
                HalconCommonFunc.RegionOperatorset(PublicData.createNewCheckModel.VisualModelRegion, HRegion, OperatorModel.Difference, out PublicData.createNewCheckModel.VisualModelRegion);
                break;

            case 2:
                HalconCommonFunc.RegionOperatorset(PublicData.createNewCheckModel.VisualModelRegion, HRegion, OperatorModel.Intersection, out PublicData.createNewCheckModel.VisualModelRegion);
                break;

            default: return;
            }
            HalconCommonFunc.DisplayImage(PublicData.createNewCheckModel.ModelImage, WindowsHandle);
            HalconCommonFunc.DisplayRegionOrXld(PublicData.createNewCheckModel.VisualModelRegion, "blue", WindowsHandle, 2);
            CreatModel = true;
        }