Ejemplo n.º 1
0
 /// <summary>
 /// Clears all variables managing ROI objects
 /// </summary>
 public void Reset()
 {
     ROIList.Clear();
     ActiveROIIndex = -1;
     _ROIMode       = null;
     if (ModelROI != null)
     {
         ModelROI.Dispose();
     }
     ModelROI = null;
     this.NotifyIconic(EVENT_DELETED_ALL_ROIS);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 鼠标按下时的处理函数
        /// </summary>
        /// <param name="y"></param>
        /// <param name="x"></param>
        /// <returns></returns>
        public int MouseDownAction(double y, double x)
        {
            int candidateidx = -1;

            _activeROIIdx = -1;
            //_epsilon *= HWndCtrller.ZoomWndFactor;

            if (_ROIShape != null)                         //either a new ROI object is created,创建新的ROI
            {
                _ROIShape.CreateROI(y, x);
                ROIList.Add(_ROIShape);
                _ROIShape     = null;
                _activeROIIdx = ROIList.Count - 1;
                HWndCtrller.Repaint();  //ROI--创建ROI,重新渲染图形

                IconicUpdatedDel(EVENT_CREATED_ROI);
            }
            else if (ROIList.Count > 0)                  //an existing ROI object is manipulated,已有ROI
            {
                double[] distArr  = new double[ROIList.Count];
                double   minvalue = 0;
                int      tmpIdx   = -1;

                for (int i = 0; i < ROIList.Count; i++)
                {
                    distArr[i] = ((ROI)ROIList[i]).DistanceToClosestHandle(y, x);
                }

                Communal.Functions.MinValueAndIndex(distArr, out minvalue, out tmpIdx);

                if (minvalue < _epsilon)
                {
                    candidateidx = tmpIdx;
                }

                if (candidateidx >= 0)
                {
                    _activeROIIdx = candidateidx;
                    IconicUpdatedDel(EVENT_ACTIVATED_ROI);
                }

                HWndCtrller.Repaint(); //ROI--激活ROI,重新渲染图形
            } //没有ROI,也未创建ROI,则什么都不做

            return(_activeROIIdx);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 鼠标按下时的处理函数
        /// </summary>
        /// <param name="y"></param>
        /// <param name="x"></param>
        /// <returns></returns>
        internal int MouseDownAction(HalconDotNet.HWindow window, double y, double x)
        {
            double epsilon      = 35; //maximal shortest distance to one of the handles,距离最近操作柄最大距离值,超出该值表示未选中
            int    candidateidx = -1;

            if (_ROIMode != null)                         //either a new ROI object is created,创建新的ROI
            {
                _ROIMode.CreateROI(window, y, x);
                ROIList.Add(_ROIMode);
                _ROIMode       = null;
                ActiveROIIndex = ROIList.Count - 1;
                HWndCtrller.Repaint();
                this.NotifyIconic(EVENT_CREATED_ROI);
            }
            else if (ROIList.Count > 0)                  //an existing ROI object is manipulated,已有ROI
            {
                ActiveROIIndex = -1;

                double[] distArr  = new double[ROIList.Count];
                double   minvalue = 0;
                int      tmpIdx   = -1;

                for (int i = 0; i < ROIList.Count; i++)
                {
                    distArr[i] = ((ROI)ROIList[i]).DistanceToClosestHandle(y, x);
                }

                MinValueAndIndex(distArr, out minvalue, out tmpIdx);

                if (minvalue < epsilon)
                {
                    candidateidx = tmpIdx;
                }

                if (candidateidx >= 0)
                {
                    ActiveROIIndex = candidateidx;
                    this.NotifyIconic(EVENT_ACTIVATED_ROI);
                }

                this.HWndCtrller.Repaint();
            }                                         //没有ROI,也未创建ROI,则什么都不做

            return(ActiveROIIndex);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deletes this ROI instance if a 'seed' ROI object has been passed
 /// to the ROICtrller by the application class.
 /// 删除即时ROI
 /// </summary>
 public void ResetInstantROI()
 {
     _activeROIIdx = -1;
     _ROIShape     = null;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// To create a new ROI object the application class initializes a
 /// 'seed' ROI instance and passes it to the ROICtrller.
 /// The ROICtrller now responds by manipulating this new ROI instance.
 /// </summary>
 /// <param name="r">
 /// 'Seed' ROI object forwarded by the application forms class.</param>
 public void SetROIShape(ROI r)
 {
     _ROIShape = r;
     _ROIShape.SetOperationFlag(_operationFlag);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Deletes this ROI instance if a 'seed' ROI object has been passed
 /// to the ROICtrller by the application class.
 /// </summary>
 internal void ResetROI()
 {
     ActiveROIIndex = -1;
     _ROIMode       = null;
     this.NotifyIconic(EVENT_DELETED_ACTROI);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// To create a new ROI object the application class initializes a
 /// 'seed' ROI instance and passes it to the ROICtrller.
 /// The ROICtrller now responds by manipulating this new ROI instance.
 /// </summary>
 /// <param name="r">
 /// 'Seed' ROI object forwarded by the application forms class.</param>
 public void SetROIShape(ROI r)
 {
     _ROIMode = r;
     _ROIMode.SetROISign(_signROI);
 }