示例#1
0
        /// <summary>
        /// Defines the initial settings for the window
        /// control. In the very beginning, the window control needs
        /// to know the view mode of the application form to perform
        /// the right behavior for incoming mouse events on the
        /// HALCON window.
        /// </summary>
        private void InteractiveForm_Load(object sender, System.EventArgs e)
        {
            String fileName = "patras";
            HImage image;

            viewController = new HWndCtrl(viewPort);
            roiController  = new ROIController();
            viewController.useROIController(roiController);
            viewController.setViewState(HWndCtrl.MODE_VIEW_NONE);

            try
            {
                image = new HImage(fileName);
            }
            catch (HOperatorException)
            {
                MessageBox.Show("Problem occured while reading file!",
                                "InteractROIForm",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            viewController.addIconicVar(image);
            viewController.repaint();
        }
示例#2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     _viewCtrl = new HWndCtrl(hWindowControl1);
     _roiCtrl  = new ROIController();
     _viewCtrl.useROIController(_roiCtrl);
     _roiCtrl.viewController.viewPort.HMouseMove += ViewPort_HMouseMove;;
 }
示例#3
0
        public EditHalconFormBase(bool showResult)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            hWindow            = new HWindowControl();
            hWindow.Dock       = DockStyle.Fill;
            this.tabCurrent.Controls.Clear();
            this.tabCurrent.Controls.Add(hWindow);

            mView = new HWndCtrl(this.hWindow);
            mView.changeGraphicSettings(GraphicsContext.GC_LINESTYLE, new HTuple());

            createModelWindowMode = Color.RoyalBlue;
            trainModelWindowMode  = Color.Chartreuse;

            roiController              = new ROIController();
            roiController.ROISelected += RoiController_ROISelected;
            roiController.setROISign(ROIController.MODE_ROI_POS);

            mView.NotifyIconObserver       = new IconicDelegate(UpdateViewData);
            roiController.NotifyRCObserver = new IconicDelegate(UpdateViewData);

            mView.useROIController(roiController);
            mView.setViewState(HWndCtrl.MODE_VIEW_ZOOM_MOVE);

            halconEditable = this as IHalconEditable;

            this.nudSettlingTime.Maximum = 1000;

            this.btnStop.Visible     = showResult;
            this.btnIgnore.Visible   = showResult;
            this.chxFixedROI.Checked = showResult;
        }
示例#4
0
 public Form1()
 {
     InitializeComponent();
     roiController  = new ROIController();
     viewController = new HWndCtrl(this.hWindowControl1);
     viewController.useROIController(roiController);
     viewController.setViewState(HWndCtrl.MODE_VIEW_MOVE);
 }
        CameraOperate Camera = new CameraOperate(); //相机操作
        #endregion
        #region 构造函数
        public MainWindow()
        {
            InitializeComponent();
            PLCButton.AddHandler(System.Windows.Controls.Button.MouseDownEvent, new RoutedEventHandler(Button_MouseDown), true);
            PLCButton.AddHandler(System.Windows.Controls.Button.MouseUpEvent, new RoutedEventHandler(Button_MouseUp), true);

            viewController1 = new HWndCtrl(ImageWindow1);//HWindowControlWPF窗口给到窗口控制器
            roiController1  = new ROIController();
            viewController1.useROIController(roiController1);
            viewController1.setViewState(HWndCtrl.MODE_VIEW_MOVE);
        }
示例#6
0
        public HcImageView()
        {
            InitializeComponent();
            roiController  = new ROIController();
            viewController = new HWndCtrl(this.Viewer);
            viewController.useROIController(roiController);
            viewController.setViewState(HWndCtrl.MODE_VIEW_MOVE);

            roiController.ActiveChanged += roiController_ActiveChanged;
            roiController.ROIChanged    += roiController_ROIChanged;
        }
示例#7
0
        public Form1()
        {
            InitializeComponent();
            hWndCrtl = hWndUnit1.HWndCtrl;

            ROIController = new ROIController();

            ROIController.ROINotifyEvent += new EventHandler <ViewEventArgs>(UpdateViewData);
            roiActUnit1.RoiController     = ROIController;
            hWndCrtl.useROIController(ROIController);

            ROIController.SetROISign(ROIOperation.Positive);
        }
        private void InitializeMyComponent()
        {
            // hWindowControl
            _hWindowControl.Width  = Width;
            _hWindowControl.Height = Height;

            // hWndCtrl
            _hWndCtrl = new HWndCtrl(_hWindowControl);
            ROIController roiController = new ROIController();

            _hWndCtrl.useROIController(roiController);
            _hWndCtrl.setViewState(HWndCtrl.MODE_VIEW_MOVE);

            // hWindow
            _hWindow = _hWindowControl.HalconWindow;
        }
示例#9
0
文件: HDisplay.cs 项目: MarkDDi/Frame
 public HDisplay()
 {
     InitializeComponent();
     searchRegionList = new List <HObject>();
     trainRegionList  = new List <HObject>();
     viewController   = new HWndCtrl(hWindowControl);
     roiController    = new ROIController();
     viewController.useROIController(roiController);
     //减少控件的闪烁
     SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
     hWindowControl.BackColor       = Color.Gray;
     viewController.MouseMoveEvent += viewController_MouseMoveEvent;
     hWindowControl.SizeChanged    += new System.EventHandler(this.hWindowControl_SizeChanged);
     m_Windowhandle = hWindowControl.HalconID;
 }
示例#10
0
        public ImageViewer()
        {
            InitializeComponent();
            //hv_window = this.WPF_HWindow.HalconWindow;
            viewController = new HWndCtrl(this.WPF_HWindow);
            roiController  = new ROIController();



            viewController.useROIController(roiController);
            viewController.setViewState(HWndCtrl.MODE_VIEW_MOVE);
            HObjectList = viewController.HObjList;
            viewController.HObjListChanged += ViewController_HObjListChanged;

            ROIList = roiController.ROIList;
            roiController.ActiveChanged += RoiController_ActiveChanged;
            roiController.ROIChanged    += RoiController_ROIChanged;
        }
示例#11
0
 public void IntialView(HWindowControl hlView, HTuple imageWidth, HTuple imageHeight)
 {
     lock (globalLock) {
         try {
             if (viewController != null)
             {
                 viewController.clearList();
             }
             viewController = new HWndCtrl(hlView);
             viewController.useROIController(roiController);
             viewController.setViewState(HWndCtrl.MODE_VIEW_MOVE);
             roiController.setROISign(ROIController.MODE_ROI_NONE);
             this.imageWidth  = imageWidth;
             this.imageHeight = imageHeight;
             Hwnd             = hlView;
             SetDraw("red", "margin");
             HOperatorSet.GenEmptyObj(out AimShow);
             AddViewCross(imageHeight / 2, imageWidth / 2, imageWidth / 10, 0, true);
             //AddViewRec2(imageHeight / 2, imageWidth / 2, imageWidth / 30, imageWidth / 30, 0, true);
             AddViewLine(imageHeight / 15, imageWidth / 15, imageHeight / 15 + imageHeight / 5, imageWidth / 15, true);
             AddViewLine(imageHeight / 15, imageWidth / 15, imageHeight / 15, imageWidth / 15 + imageWidth / 5, true);
             AddViewLine(imageHeight - imageHeight / 15 - imageHeight / 5, imageWidth / 15, imageHeight - imageHeight / 15, imageWidth / 15, true);
             AddViewLine(imageHeight - imageHeight / 15, imageWidth / 15, imageHeight - imageHeight / 15, imageWidth / 15 + imageWidth / 5, true);
             AddViewLine(imageHeight - imageHeight / 15 - imageHeight / 5, imageWidth - imageWidth / 15, imageHeight - imageHeight / 15, imageWidth - imageWidth / 15, true);
             AddViewLine(imageHeight - imageHeight / 15, imageWidth - imageWidth / 15 - imageWidth / 5, imageHeight - imageHeight / 15, imageWidth - imageWidth / 15, true);
             AddViewLine(imageHeight / 15, imageWidth - imageWidth / 15, imageHeight / 15 + imageHeight / 5, imageWidth - imageWidth / 15, true);
             AddViewLine(imageHeight / 15, imageWidth - imageWidth / 15, imageHeight / 15, imageWidth - imageWidth / 15 - imageWidth / 5, true);
             foreach (var item in hObjectList)
             {
                 if (item != null)
                 {
                     item.Dispose();
                 }
             }
             hObjectList.Clear();
             //this.HMouseClick = this.viewController.HMouseClick;
             this.viewController.HMouseClick += new HMouseEventHandler(HMouseDown);
         }
         catch
         { }
     }
 }
        /// <summary>
        /// Performs the initialization of the HDisplayControl
        /// during loading to the memory.
        /// </summary>
        private void HDisplayControl_Load(object sender, EventArgs e)
        {
            hWndControl = new HWndCtrl(viewPort);

            // Initialization graphic window size
            windowExtents = new Rectangle(0, 0, this.viewPort.WindowSize.Width,
                                          this.viewPort.WindowSize.Height);


            imageWidth = imageHeight = 0;

            displayZoomValue = 100;
            zoomCenter       = new Point(windowExtents.Width / 2, windowExtents.Height / 2);

            if (MoveOnPressedMouseButton)
            {
                hWndControl.setViewState(HWndCtrl.MODE_VIEW_MOVE);
            }
            else
            {
                hWndControl.setViewState(HWndCtrl.MODE_VIEW_NONE);
            }

            // add event handler after zooming the image
            hWndControl.OnImageZoomed += new OnIconicObjectZoomedHandler(
                this.hWndControl_IconicObjectZoomed);
            hWndControl.OnImageMoved += new OnIconicObjectMovedHandler(
                this.hWndControl_IconicObjectMoved);
            // setup ROIController
            roiController = new ROIController();
            hWndControl.useROIController(roiController);

            // handle the changes of regions
            roiController.NotifyRCObserver = null;
            roiController.NotifyRCObserver = new IconicDelegate(UpdateViewData);
            hWndControl.clearList();
            //---------

            // set the sign of the draw region to the value "Add Region"
            roiController.setROISign(ROIController.MODE_ROI_POS);
            this.ShowROI = true;
        }
示例#13
0
        ///<summary>
        ///程序初始化
        ///</summary>
        public void Initialization()
        {
            //实例化:检测画面子菜单
            LineDetect                 = new LineDetect();
            LineDetect.TopLevel        = false;
            LineDetect.Dock            = DockStyle.Fill;
            LineDetect.FormBorderStyle = FormBorderStyle.None;
            LineDetect.Size            = TLPCheckParam.Size;
            ROIRectangle2              = new ROIRectangle2();
            ho_Image       = null;
            hv_ImageWindow = HWControl1.HalconID;

            InspectionStandard                 = new InspectionStandard();
            InspectionStandard.TopLevel        = false;
            InspectionStandard.Dock            = DockStyle.Fill;
            InspectionStandard.FormBorderStyle = FormBorderStyle.None;
            InspectionStandard.Size            = TLPCheckParam.Size;
            SendMessage(this.TLPanel_Bottom.Handle, WM_SETREDRAW, 0, IntPtr.Zero);//禁止重绘
            TLPCheckParam.Controls.Clear();
            TLPCheckParam.Controls.Add(InspectionStandard);
            InspectionStandard.Show();
            SendMessage(TLPanel_Bottom.Handle, WM_SETREDRAW, 1, IntPtr.Zero); //取消禁止
            TLPanel_Bottom.Refresh();                                         //刷新控件
            //

            //画面缩放
            roiController = new ROIController();
            HWndCtrl      = new HWndCtrl(HWControl1);
            HWndCtrl.useROIController(roiController);
            HWndCtrl.setViewState(HWndCtrl.MODE_VIEW_ZOOM);
            HWndCtrl.setViewState(HWndCtrl.MODE_VIEW_MOVE);
            HWndCtrl.ReDrawEvent          += new HWndCtrl.ReDrawDelegate(ReDraw);           //更改测量矩形,重绘直线
            LineDetect.ReviewLineEvent    += new LineDetect.ReviewLineDelegate(ReviewLine); //参数更改,重绘直线
            HWndCtrl.ImageProcessingEvent += HWndCtrl_ImageProcessingEvent;

            if (ho_Image != null)
            {
                HWndCtrl.addIconicVar(ho_Image);
                HWndCtrl.repaint();
            }
            //
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool Init(out string message)
        {
            _isReady = true;
            message  = "";
            try
            {
                _roiController = new ROIController();
                mView          = new HWndCtrl(this.ViewPort);
                mView.useROIController(_roiController);
                _roiController.NotifyRCObserver = new IconicDelegate(On_ROIUpdated);                // ROI 操作通知

                mAssistant = new MeasureAssistant(_roiController);
                mAssistant.NotifyMeasureObserver = new MeasureDelegate(UpdateMeasureResults);

                initFileDialog();
                initializeGrabImage();
            }
            catch (Exception ex)
            {
                _isReady = false;
                message  = ex.Message;
            }
            return(_isReady);
        }