/// <summary> /// Reaction of ROI objects to the 'mouse button down' event: changing /// the shape of the ROI and adding it to the ROIList if it is a 'seed' /// ROI. /// </summary> /// <param name="imgX">x coordinate of mouse event</param> /// <param name="imgY">y coordinate of mouse event</param> /// <returns></returns> public int mouseDownAction(double imgX, double imgY) { int idxROI = -1; double max = 10000, dist = 0; double epsilon = 35.0; //maximal shortest distance to one of //the handles if (roiMode != null) //either a new ROI object is created { roiMode.createROI(imgX, imgY); ROIList.Add(roiMode); roiMode = null; activeROIidx = ROIList.Count - 1; viewController.repaint(); NotifyRCObserver(ROIController.EVENT_CREATED_ROI); } else if (ROIList.Count > 0) // ... or an existing one is manipulated { // identify activated ROI activeROIidx = -1; for (int i = 0; i < ROIList.Count; i++) { dist = ((ROI)ROIList[i]).distToClosestHandle(imgX, imgY); if ((dist < max) && (dist < epsilon)) { max = dist; idxROI = i; } }//end of for // if (idxROI >= 0) { activeROIidx = idxROI; NotifyRCObserver(ROIController.EVENT_ACTIVATED_ROI); } //viewController.repaint(); NotifyRCObserver(ROIController.EVENT_REPAINT_ROI); } return(activeROIidx); }