Esempio n. 1
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);
        }
Esempio n. 2
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);
        }