/// <summary>
 /// 初始化
 /// </summary>
 /// <param name="roiController"></param>
 public void Init(ROIController roiController, HWndCtrl mView, GeoDataGridViewManager geoManager)
 {
     _roiController = roiController;
     _mView = mView;
     _geoManager = geoManager;
     if (_roiController != null)
     {
         _roiController.NotifyRCObserver += new IconicDelegate(resetFinalCheckedBox);
     }
 }
 /// <summary>
 /// 初始化狀態列事件
 /// </summary>
 /// <param name="viewPort"></param>
 /// <param name="viewController"></param>
 public bool Init(HWindowControl viewPort, HWndCtrl viewController, GrabImageWorkingMan camera)
 {
     bool success = true;
     try
     {
         setMessageStore();
         setWatchCoordinate(viewPort);
         setWachtZoomChanged(viewController);
         setWatchOperationModeChange(viewController);
         setWatchGrayLevel(viewPort, viewController);
         setWatchCameraStatus(camera);
     }
     catch (Exception ex)
     {
         success = false;
         Hanbo.Log.LogManager.Error("UC_StatusStrip Error");
         Hanbo.Log.LogManager.Error(ex);
     }
     return success;
 }
        /// <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();
        }
        /**************************************************************************/
        /* Setup the GUI for the SmartWindow application
         **************************************************************************/
        private void SmartWindowForm_Load(object sender, System.EventArgs e)
        {
            hWndControl = new HWndCtrl(viewPort);
            String fileName = "patras";
            HImage image;

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

            hWndControl.addIconicVar(image);
            hWndControl.repaint();
        }
 /**************************************************************************/
 /* Setup the GUI for the SmartWindow application in terms of
  * registering the Window Control class and setting up all values
  * and flags to use the GUI based viewfunctions (zoom and move)
  **************************************************************************/
 private void SmartWindow1Form_Load(object sender, System.EventArgs e)
 {
     hWndControl = new HWndCtrl(viewPort);
     Init();
 }
 /**************************************************************************
  * Initialize the GraphicsStack application in terms of:
  * register the window controller and perform the image processing
  * beforehand, to create a list of iconic objects to be added
  * to the graphics stack by the user during the application.
 /**************************************************************************/
 private void GraphicsStackForm_Load(object sender, System.EventArgs e)
 {
     viewControl = new HWndCtrl(viewPort);
     viewControl.NotifyIconObserver = new IconicDelegate(UpdateHWnd);
     Init();
 }
        /// <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;
        }
Ejemplo n.º 8
0
 /// <summary>Registers the HWndCtrl to this ROIController instance</summary>
 public void setViewController(HWndCtrl view)
 {
     viewController = view;
     if (viewController != null)
     {
         viewController.OnZoomChanged -= viewController_OnZoomChanged;
         viewController.OnZoomChanged += viewController_OnZoomChanged;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// In the beginning, some initialization tasks are performed. 
        /// The control instances, like ROIController and WindowController,
        /// are initialized and registered with each other. Also, the
        /// delegates of the models are linked to update methods
        /// to get notified about changes.
        /// </summary>
        public MatchingForm()
        {
            InitializeComponent();

            mView = new HWndCtrl(viewPort);

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

            roiController = new ROIController();
            mView.useROIController(roiController);

            roiController.setROISign(ROIController.MODE_ROI_POS);

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

            mView.setViewState(HWndCtrl.MODE_VIEW_NONE);

            locked = true;
            parameterSet = new MatchingParam();
            Init(parameterSet);
            locked = false;

            mAssistant = new MatchingAssistant(parameterSet);
            mAssistant.NotifyIconObserver  = new MatchingDelegate(UpdateMatching);
            mAssistant.NotifyParamObserver = new AutoParamDelegate(UpdateButton);

            speedOptHandler		= new MatchingOptSpeed(mAssistant, parameterSet);
            speedOptHandler.NotifyStatisticsObserver = new  StatisticsDelegate(UpdateStatisticsData);

            inspectOptHandler	= new MatchingOptStatistics(mAssistant, parameterSet);
            inspectOptHandler.NotifyStatisticsObserver = new  StatisticsDelegate(UpdateStatisticsData);
        }
        /// <summary>
        /// <para>******************</para>
        /// Watch Gray Level (灰階
        /// <para>******************</para>
        /// </summary>
        /// <param name="viewPort"></param>
        private void setWatchGrayLevel(HWindowControl viewPort, HWndCtrl viewController)
        {
            if (viewPort != null)
            {
                viewPort.HMouseMove += (sender, e) =>
                {
                    if (viewController == null) return;
                    var currImage = viewController.GetLastHImage();
                    if (currImage != null)
                    {
                        var row = (int)Math.Round(e.Y, 0);
                        var col = (int)Math.Round(e.X, 0);
                        try
                        {
                            HTuple width, height, grayval;
                            currImage.GetImageSize(out width, out height);
                            var mouseInImage = (row <= height.I && col <= width.I && row >= 0 && col >= 0);
                            if (mouseInImage)
                            {
                                HOperatorSet.GetGrayval(currImage, row, col, out grayval);
                                var dispText = grayval.I.ToString();
                                SetStatus(SystemStatusType.GrayLevel, dispText);
                            }
                        }
                        catch (Exception ex)
                        {
                            AddMessage(ex.Message);
                        }
                    }

                };
            }
        }
        /// <summary>
        /// <para>***************************************</para>
        /// Watch OperationMode Change
        /// <para>觀察影像操作模式 (移動, 放大/縮小, 放大鏡)</para>
        /// <para>***************************************</para>
        /// </summary>
        /// <param name="viewController"></param>
        private void setWatchOperationModeChange(HWndCtrl viewController)
        {
            if (viewController != null)
            {
                viewController.On_OperationModeChanged += (mode) =>
                {
                    var modeText = Hanbo.Resources.Resource.ResourceManager.GetString(mode);
                    SetStatus(SystemStatusType.ControlMode, modeText);
                };

            }
        }
 /// <summary>
 /// <para>***********************</para>
 /// Zoom Change Observer (縮放)
 /// <para>***********************</para>
 /// </summary>
 /// <param name="viewController"></param>
 private void setWachtZoomChanged(HWndCtrl viewController)
 {
     if (viewController != null)
     {
         viewController.OnZoomChanged += (zoomFactor) =>
         {
             var rate = Math.Round(100 * 1.0 / zoomFactor, 2);
             var dispText = String.Format("{0}%", rate);
             SetStatus(SystemStatusType.ZoomFactor, dispText);
         };
     }
 }
        /*****************************************************************
         * During the load process the HWndCtrl instance is initialized -
         * besides some other variables, needed to manipulate the
         * window panel.
         *****************************************************************/
        private void GraphicsWindowForm_Load(object sender, System.EventArgs e)
        {
            locked = false;
            viewControl = new HWndCtrl(viewPort);

            // current screen resolution, height and width
            ScreenHeight = Screen.PrimaryScreen.WorkingArea.Height;
            ScreenWidth  = Screen.PrimaryScreen.WorkingArea.Width;

            ScreenCastH = (int)(ScreenHeight/4.0*3.0);
            ScreenCastW = (int)(ScreenWidth/4.0*3.0);

            Init();
        }
Ejemplo n.º 14
0
        /********************************************************************/
        private void CalibrationForm_Load(object sender, System.EventArgs e)
        {
            mView = new HWndCtrl(viewPort);
            mView.setViewState(HWndCtrl.MODE_VIEW_NONE);
            mView.changeGraphicSettings(GraphicsContext.GC_DRAWMODE, comboBoxDraw.Text);
            mView.changeGraphicSettings(GraphicsContext.GC_LINEWIDTH, 1);

            mAssistant = new CalibrationAssistant();
            mAssistant.NotifyCalibObserver = new CalibDelegate(UpdateCalibResults);
            Init();
        }
Ejemplo n.º 15
0
 /// <summary>Registers the HWndCtrl to this ROIController instance</summary>
 public void setViewController(HWndCtrl view)
 {
     viewController = view;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Loads MeasureForm and initializes view functions
        /// to include in the MeasureAssistant.
        /// </summary>
        private void MeasureForm_Load(object sender, System.EventArgs e)
        {
            mView = new HWndCtrl(viewPort);
            roiController = new ROIController();
            mView.useROIController(roiController);
            mAssistant = new MeasureAssistant(roiController);
            mShadow = new HXLDCont();

            mView.setViewState(HWndCtrl.MODE_VIEW_NONE);
            mView.changeGraphicSettings(GraphicsContext.GC_LINEWIDTH, 1);

            roiController.NotifyRCObserver = new IconicDelegate(UpdateROIData);
            mAssistant.NotifyMeasureObserver = new MeasureDelegate(UpdateMeasureResults);

            plotGraphWindow = new FunctionPlot(panelAxis, true);

              openImageFileDialog.InitialDirectory =
            (string)(HSystem.GetSystem("image_dir").TupleSplit(";"));
            Init();

            mView.setDispLevel(HWndCtrl.MODE_EXCLUDE_ROI);
        }