Esempio n. 1
0
 private void ClearWindButton_Click(object sender, System.EventArgs e)
 {
     viewControl.resetWindow();
     viewControl.clearList();
     IconicDisplayStack.Items.Clear();
     StackCountLabel.Text = "" + viewControl.getListCount();
     viewControl.repaint();
 }
 public void AddSingleObject(HObject obj)
 {
     HalconCtrl.clearList();
     using (var image = new HImage(obj))
     {
         HalconCtrl.addIconicVar(image);
         HalconCtrl.repaint();
     }
 }
Esempio n. 3
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;
        }
        /// <summary>
        /// 更新畫面 (影像, ROI, 量測結果)
        /// </summary>
        /// <param name="contour"></param>
        private void updateView(HObject contour)
        {
            var image = contour as HImage;

            if (image != null)
            {
                _curImage = image;
                mAssistant.setImage(image);
            }

            if (_curImage == null)
            {
                mView.clearList();
            }
            else
            {
                mView.addIconicVar(_curImage);
            }
            showMeasureResult();
            mView.repaint();
        }
        /// <summary>
        /// Clears the content in the graphic stack
        /// that is managed by HDisplayControl
        /// </summary>
        public void ClearGraphicStack()
        {
            hWndControl.clearList();
            // set the flag to display the full image
            // in correct aspect ration in graphic window
            if (imageViewState == ImageViewStates.fitToWindow)
            {
                hWndControl.adaptSize = true;
            }
            else
            {
                hWndControl.adaptSize = false;
            }

            if ((imageWidth > 0) && (imageHeight > 0))
            {
                hWndControl.resetImagePart(imageWidth, imageHeight);
            }

            this.Invalidate();
        }