private void btn_TuYa_Click(object sender, EventArgs e)
        {
            double radius;
            ROI    Tuya = RoiController.ROIList.Find(x => x.OperatorFlag == ROIOperation.Tuya);

            if (Tuya != null)
            {
                RoiController.ActiveRoiIdx = RoiController.ROIList.FindIndex(x => x.OperatorFlag == ROIOperation.Tuya);

                if (!double.TryParse(cMB_TuYa_radius.Text, out radius))
                {
                    MessageBox.Show("请输入数值或选择指定涂鸦半径半径", "转换错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Tuya.SetTuYaRadius(radius);
            }
            else
            {
                if (!double.TryParse(cMB_TuYa_radius.Text, out radius))
                {
                    MessageBox.Show("请输入数值或选择指定涂鸦半径半径", "转换错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                RoiController.SetROISign(ROIOperation.Tuya);
                RoiController.SetROIShape(new TuYa(radius));
            }
        }
Пример #2
0
 /// <summary>
 /// Clears all variables managing ROI objects
 /// </summary>
 public void Reset()
 {
     ROIList.Clear();
     activeROIidx = -1;
     modelROI     = null;
     roiSeed      = null;
     TiggerROINotifyEvent(new ViewEventArgs(ViewMessage.DelectedAllROIs));
 }
        /// <summary>
        /// 鼠标按下后对应的roi行为,判断是否在roi区域并记录
        /// </summary>
        /// <param name="imgX">鼠标坐标x</param>
        /// <param name="imgY">鼠标坐标y</param>
        /// <returns>激活的roi序号</returns>
        public int MouseDownAction(double imgX, double imgY)
        {
            int    idxROI = -1;
            double max = 10000, dist = 0;
            double epsilon = 0;

            //判断是否是新建roi
            if (roiSeed != null)             //either a new ROI object is created
            {
                roiSeed.ImageWidth = viewController.ImageWidth;
                roiSeed.CreateROI(imgX, imgY);
                ROIList.Add(roiSeed);
                roiSeed      = null;
                activeROIidx = ROIList.Count - 1;
                if (viewController != null)
                {
                    viewController.Repaint();
                }

                TiggerROINotifyEvent(new ViewEventArgs(ViewMessage.CreatedROI));
            }
            else if (ROIList.Count > 0)     // ... or an existing one is manipulated
            {
                for (int i = 0; i < ROIList.Count; i++)
                {
                    dist    = ROIList[i].DistToClosestHandle(imgX, imgY);
                    epsilon = ROIList[i].GetHandleWidth() + 2.0;
                    if ((dist < max) && (dist < epsilon))
                    {
                        max    = dist;
                        idxROI = i;
                    }
                }//end of for

                if (max > 9999 || max > epsilon)
                {
                    activeROIidx = -1;
                }

                if (idxROI >= 0)
                {
                    activeROIidx = idxROI;
                    TiggerROINotifyEvent(new ViewEventArgs(ViewMessage.ActivatedROI));
                }

                if (viewController != null)
                {
                    viewController.Repaint();
                }
            }
            return(activeROIidx);
        }
 public void SetROIShapeNoOperator(ROI r)
 {
     roiSeed = r;
     roiSeed.OperatorFlag = ROIOperation.None;
     //只能有一个无标志的roi作为搜索框
     for (int i = 0; i < ROIList.Count; i++)
     {
         if (ROIList[i].OperatorFlag == ROIOperation.None)
         {
             ROIList.RemoveAt(i);
         }
     }
 }
        private void cMB_TuYa_radius_TextChanged(object sender, EventArgs e)
        {
            ROI Tuya = RoiController.ROIList.Find(x => x.OperatorFlag == ROIOperation.Tuya);

            if (Tuya == null)
            {
                return;
            }
            double radius;

            if (!double.TryParse(cMB_TuYa_radius.Text, out radius))
            {
                MessageBox.Show("请输入数值或选择指定涂鸦半径半径", "转换错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Tuya.SetTuYaRadius(radius);
        }
 /// <summary>
 /// Deletes this ROI instance if a 'seed' ROI object has been passed
 /// to the ROIController by the application class.
 ///
 /// </summary>
 public void resetROI()
 {
     activeROIidx = -1;
     roiSeed      = null;
 }
 /// <summary>
 /// 为了创建一个新的ROI对象,应用程序类初始化一个“种子”ROI实例并将其传递给ROIController。
 /// ROIController现在通过操纵这个新的ROI实例进行响应。
 /// </summary>
 /// <param name="r">
 /// 'Seed' ROI object forwarded by the application forms class.
 /// </param>
 public void SetROIShape(ROI r)
 {
     roiSeed = r;
     roiSeed.OperatorFlag = stateROIOperation;
 }