public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { islastPointConnect = true; //drawArea.Refresh(); //newPolygon.ConnectFirstAndLastPoint( newPolygon = null; base.OnMouseUp(drawArea, e); }
private const int minDistance = 25 * 25;// Changed the distance from 15* 15 to 20* 20 so as to show less number of hit points by sriram on september 1st 2015 /// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { // Create new polygon, add it to the list // and keep reference to it newPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); newPolygon.isCup = DrawArea.isDrawCup; AddNewObject(drawArea, newPolygon); lastX = e.X; lastY = e.Y; }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { if (!AnnotationVariables.isGlaucomaTool) { islastPointConnect = true; //drawArea.Refresh(); //newPolygon.ConnectFirstAndLastPoint( newPolygon = null; base.OnMouseUp(drawArea, e); } }
public bool DeleteSelection() { bool result = false; int n = graphicsList.Count; for (int i = n - 1; i >= 0; i--) { if (((DrawObject)graphicsList[i]).Selected) { if (AnnotationVariables.isGlaucomaTool) { if (graphicsList[i] is DrawPolygon) { DrawPolygon d = graphicsList[i] as DrawPolygon; Args arg = new Args(); arg["ModifyCupPoints"] = false; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to false. when points of polygon are deleted.By Ashutosh 21-7-2017 graphicsList.RemoveAt(i); if (d.isCup) { ToolPolygon.DrawCupPolygon = null; } else { arg["ModifyDiscPoints"] = false; arg["DrawCup"] = false; ToolPolygon.DrawDiscPolygon = null; } _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } else { currentType = graphicsList[i].GetType().ToString(); graphicsList.RemoveAt(i); if (graphicsList.Count == 0)//Added by darshan on 25-07-2016 as per NR:0001211 Note no:(0002558) { Args arg = new Args(); arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to false. when points are deleted.By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.AnnotationButtonsRefresh, arg); } } result = true; } } return(result); }
public void CalculatePolygonArea() { for (int i = 0; i < graphicsList.Count; i++) { if (graphicsList[i] is DrawPolygon) { DrawPolygon polyGon = graphicsList[i] as DrawPolygon; if (iscup_List.Count > 0) { polyGon.isCup = iscup_List[i]; } polyGon.GetContourValue(); } } DrawPolygon.MeasureCDR(); }
/// <summary> /// AddExistingObject will add existing polygon to drawarea. /// </summary> /// <param name="drawArea">drawarea is where the polygon is drawn</param> /// <param name="s">shape class details will be in s</param> public void AddExistingObject(DrawArea drawArea, Shape s) { if (AnnotationVariables.isGlaucomaTool) { if (DrawArea.isDrawCup) { if (DrawCupPolygon == null) { DrawCupPolygon = new DrawPolygon(s.PointArray[0].X, s.PointArray[0].Y, s.PointArray[1].X, s.PointArray[1].Y); DrawCupPolygon.isCup = DrawArea.isDrawCup; DrawObject.LastUsedColor = Color.FromName(AnnotationVariables.cupColor); DrawCupPolygon.Color = DrawObject.LastUsedColor; AddNewObject(drawArea, DrawCupPolygon); ArrayList points = new ArrayList(s.PointArray); DrawCupPolygon.pointArray = points; DrawCupPolygon.Shape.PointArray = points.Cast <Point>().ToList <Point>(); } } else { if (DrawDiscPolygon == null) { DrawDiscPolygon = new DrawPolygon(s.PointArray[0].X, s.PointArray[0].Y, s.PointArray[1].X, s.PointArray[1].Y); DrawDiscPolygon.isCup = DrawArea.isDrawCup; DrawObject.LastUsedColor = Color.Black; DrawDiscPolygon.Color = Color.FromName(AnnotationVariables.discColor); AddNewObject(drawArea, DrawDiscPolygon); ArrayList points = new ArrayList(s.PointArray); DrawDiscPolygon.pointArray = points; DrawDiscPolygon.Shape.PointArray = points.Cast <Point>().ToList <Point>(); } } } else { newPolygon = new DrawPolygon(s.PointArray[0].X, s.PointArray[0].Y, s.PointArray[1].X, s.PointArray[1].Y); DrawObject.LastUsedColor = Color.FromName(AnnotationVariables.annotationMarkingColor); AddNewObject(drawArea, newPolygon); ArrayList points = new ArrayList(s.PointArray); newPolygon.pointArray = points; newPolygon.Shape.PointArray = points.Cast <Point>().ToList <Point>(); } drawArea.ListGraphics.UnselectAll(); drawArea.Refresh(); }
public void DeleteAll() { int n = graphicsList.Count; for (int i = n - 1; i >= 0; i--) { if (AnnotationVariables.isGlaucomaTool) { if (graphicsList[i] is DrawPolygon) { DrawPolygon d = graphicsList[i] as DrawPolygon; if (d.isCup) { ToolPolygon.DrawCupPolygon = null; graphicsList.RemoveAt(i); } else { ToolPolygon.DrawDiscPolygon = null; graphicsList.RemoveAt(i); } } } else { graphicsList.RemoveAt(i); } } if (AnnotationVariables.isGlaucomaTool) { Args arg = new Args(); arg["ModifyDiscPoints"] = false; arg["DrawCup"] = false; arg["ModifyCupPoints"] = false; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to false when all points are deleted.By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } }
/// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point point1 = new Point(e.X, e.Y); if (AnnotationVariables.isGlaucomaTool) { ValidatePointsForGlaucomaTool(point1, drawArea); } else { newPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); AddNewObject(drawArea, newPolygon); lastX = e.X; lastY = e.Y; Args arg = new Args();//Added by darshan on 25-07-2016 as per NR:0001211 Note no:(0002558) arg["Print"] = true; arg["Save"] = true; arg["Export"] = true;//set to true when points drawn . By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.AnnotationButtonsRefresh, arg); } drawArea.Refresh(); }
private void ValidatePointsForGlaucomaTool(Point e, DrawArea drawArea) { #region conditions for GlaucomaTool // Create new polygon, add it to the list // and keep reference to it Point point1 = new Point(e.X, e.Y); if (DrawArea.isDrawCup) { if (DrawCupPolygon == null) { if (DrawDiscPolygon != null && DrawDiscPolygon.pointArray.Count > 2) { if (!ToolPointer.NearestNeighbours((Point[])DrawDiscPolygon.pointArray.ToArray(typeof(Point)), point1)) { Common.CustomMessageBox.Show(AnnotationVariables.addCupPointsWarning, AnnotationVariables.warningHeader, CustomMessageBoxIcon.Warning); } else { DrawCupPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); DrawCupPolygon.isCup = DrawArea.isDrawCup; AddNewObject(drawArea, DrawCupPolygon); DrawCupPolygon.AddPoint(point1); } } lastX = e.X; lastY = e.Y; Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = true; arg["ModifyCupPoints"] = true; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to flase when points not present/deleted . By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } else { Point point = new Point(e.X, e.Y); if (DrawDiscPolygon != null && DrawDiscPolygon.pointArray.Count > 2) { if (!ToolPointer.NearestNeighbours((Point[])DrawDiscPolygon.pointArray.ToArray(typeof(Point)), point)) { Common.CustomMessageBox.Show(AnnotationVariables.addCupPointsWarning, AnnotationVariables.warningHeader, CustomMessageBoxIcon.Warning); } else { bool isSamePosition = DrawCupPolygon.pointArray.Contains(point); if (!isSamePosition) { DrawCupPolygon.AddPoint(point); if (DrawCupPolygon.pointArray.Count > 2) { Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = true; arg["ModifyCupPoints"] = true; arg["MeasureCDR"] = true; arg["Print"] = true; arg["Save"] = true; arg["Export"] = true;//set to true when count greater than 2. By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } } } } } else { { if (DrawDiscPolygon == null) { if (DrawCupPolygon == null || DrawDiscPolygon == null) { Point point = new Point(e.X, e.Y); DrawDiscPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); DrawDiscPolygon.isCup = DrawArea.isDrawCup; AddNewObject(drawArea, DrawDiscPolygon); DrawDiscPolygon.AddPoint(point); Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = false; arg["ModifyCupPoints"] = false; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to false when points is null . By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } else if (DrawCupPolygon.pointArray.Count > 2) { if (ToolPointer.NearestNeighbours((Point[])DrawCupPolygon.pointArray.ToArray(typeof(Point)), point1)) { Common.CustomMessageBox.Show(AnnotationVariables.addDiscPointsWarning, AnnotationVariables.warningHeader, CustomMessageBoxIcon.Warning); } else { DrawDiscPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); DrawDiscPolygon.isCup = DrawArea.isDrawCup; AddNewObject(drawArea, DrawDiscPolygon); Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = false; arg["ModifyCupPoints"] = false; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to false when count lesser than 2 . By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } } else { Point point = new Point(e.X, e.Y); if (DrawCupPolygon != null && DrawCupPolygon.pointArray.Count > 2) { if (ToolPointer.NearestNeighbours((Point[])DrawCupPolygon.pointArray.ToArray(typeof(Point)), point)) { Common.CustomMessageBox.Show(AnnotationVariables.addDiscPointsWarning, AnnotationVariables.warningHeader, CustomMessageBoxIcon.Warning); } else { DrawDiscPolygon.AddPoint(point); if (DrawDiscPolygon.pointArray.Count > 2) { Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = true; arg["MeasureCDR"] = true; if (DrawCupPolygon.pointArray.Count <= 2) { arg["Save"] = false; arg["Print"] = false; arg["Export"] = false;//set to false when count lesser than 2 . By Ashutosh 21-7-2017 } else { arg["Save"] = true; arg["Print"] = true; arg["Export"] = true;//set to true when count greater than 2 . By Ashutosh 21-7-2017 } _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } } else { DrawDiscPolygon.AddPoint(point); if (DrawDiscPolygon.pointArray.Count > 2)// This condition is added in order to enable cup marking only if more than two points added to disc by sriram { Args arg = new Args(); arg["ModifyDiscPoints"] = true; arg["DrawCup"] = true; arg["ModifyCupPoints"] = false; arg["MeasureCDR"] = false; arg["Print"] = false; arg["Save"] = false; arg["Export"] = false;//set to true when count greater than 2 .By Ashutosh 21-7-2017 _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } } } } #endregion }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) int n = drawArea.ListGraphics.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.ListGraphics.GetSelectedObject(i); int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class members resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.ListGraphics.UnselectAll(); o.Selected = true; break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { List <AnnotationComments> annocmt = null; int n1 = drawArea.ListGraphics.Count; DrawObject o = null; if (drawArea.comments.Count != 0) { annocmt = drawArea.comments; annocmt.Reverse(); } string[] str = drawArea.ListGraphics.graphicType; for (int i = 0; i < n1; i++) { int a = drawArea.ListGraphics[i].HitTest(point); if (drawArea.ListGraphics[i].PointContainer(point) == 0) { o = drawArea.ListGraphics[i]; break; } //if (drawArea.ListGraphics[i].HitTest(point) == 0) //{ // o = drawArea.ListGraphics[i]; // //if(annocmt!=null) // // //o.ID = annocmt[i].ID; // break; //} } if (o != null) { isZoom = false; selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.ListGraphics.UnselectAll(); } // Select clicked object o.Selected = true; if (o is DrawPolygon) { DrawPolygon polyGon = o as DrawPolygon; if (AnnotationVariables.isGlaucomaTool) { _eventHandler.Notify(_eventHandler.EnableMovePointInCDRTool, new Args());//public void Notify(String n, Args args) defined in IVLEventHandler.By ashutosh 25-07-2017 } } drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.ListGraphics.UnselectAll(); drawArea.unselectalltext(); } selectMode = SelectionMode.NetSelection; isZoom = true; drawArea.DrawNetRectangle = true; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); }
/// <summary> /// Mouse is moved. /// None button is pressed, ot left button is pressed. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { Point point = new Point(e.X, e.Y); Point point1 = new Point(); // set cursor when mouse button is not pressed if (e.Button == MouseButtons.None) { Cursor cursor = null; for (int i = 0; i < drawArea.ListGraphics.Count; i++) { int n = drawArea.ListGraphics[i].HitTest(point); if (n == 5) { point1 = drawArea.ListGraphics[i].GetHandleCursor(n).HotSpot; //annotateText.Location = drawArea.active_point; } if (n > 0) { cursor = drawArea.ListGraphics[i].GetHandleCursor(n); break; } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } /// Left button is pressed // Find difference between previous and current position int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; int ControlIndx = 0; int shiftVal = 0; // resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { if (AnnotationVariables.isGlaucomaTool) { if (resizedObject is DrawPolygon) { if (ToolPolygon.modifyPolygon) { if (e.Button != MouseButtons.Left) { return; } DrawPolygon poly = resizedObject as DrawPolygon;// this line has been added in order to get the polygon details instead of directly getting from the generic object which solves the problem cup going outside disc and disc coming inside cup by sriram if (!poly.isCup) { if (ToolPolygon.DrawDiscPolygon == null) { return; // precaution } // if (distance < minDistance) { // Distance between last two points is less than minimum - // move last point if (ToolPolygon.DrawCupPolygon != null) { if (!NearestNeighbours((Point[])ToolPolygon.DrawCupPolygon.pointArray.ToArray(typeof(Point)), point)) { resizedObject.MoveHandleTo(point, resizedObjectHandle); } if (AnnotationVariables.isGlaucomaToolViewing) { Args arg = new Args(); arg["Save"] = true; arg["IsViewed"] = false; _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } else { resizedObject.MoveHandleTo(point, resizedObjectHandle); } } } else { if (ToolPolygon.DrawCupPolygon == null) { return; // precaution } // if (distance < minDistance) { // Distance between last two points is less than minimum - // move last point if (ToolPolygon.DrawDiscPolygon != null) { if (NearestNeighbours((Point[])ToolPolygon.DrawDiscPolygon.pointArray.ToArray(typeof(Point)), point)) { //if (!InsidePolygon((Point[])ToolPolygon.DrawDiscPolygon.pointArray.ToArray(typeof(Point)), point)) resizedObject.MoveHandleTo(point, resizedObjectHandle); } if (AnnotationVariables.isGlaucomaToolViewing) { Args arg = new Args(); if (drawArea.ListGraphics[0].HandleCount >= 3 && drawArea.ListGraphics[1].HandleCount >= 3)//this has been added to solve the defect no 0001515 { arg["Save"] = true; arg["IsViewed"] = false; } else { arg["Save"] = false; arg["IsViewed"] = true; } _eventHandler.Notify(_eventHandler.UpdateGlaucomaToolControls, arg); } } else { resizedObject.MoveHandleTo(point, resizedObjectHandle); } } } } } } else { resizedObject.MoveHandleTo(point, resizedObjectHandle); Args arg = new Args(); arg["Save"] = true; arg["IsViewed"] = false; _eventHandler.Notify(_eventHandler.AnnotationButtonsRefresh, arg); } drawArea.Refresh(); Rectangle handleRect = drawArea.ListGraphics[ControlIndx].GetHandleRectangle(5); point.X = handleRect.X; point.Y = handleRect.Y; //drawArea.active_point = point; ////ToolObject.text_move(drawArea, e); //(drawArea.Controls[ControlIndx] as Panel).Location = drawArea.active_point; //drawArea.Controls[ControlIndx].SendToBack(); //drawArea.Refresh(); } } // move if (!AnnotationVariables.isGlaucomaTool) { if (selectMode == SelectionMode.Move) { int n = drawArea.ListGraphics.SelectionCount; for (int i = 0; i < n; i++) { drawArea.ListGraphics.GetSelectedObject(i).Move(dx, dy); //if (i == 5) //{ // drawArea.active_point = drawArea.ListGraphics[i].GetHandleCursor(n).HotSpot; //} } //This below if statement was added by Darshan on 25-08-2015 to solve Defect no 0000596: system is getting crashed. if (n > 0) { Rectangle handleRect = drawArea.ListGraphics[ControlIndx].GetHandleRectangle(5); point.X = handleRect.X; point.Y = handleRect.Y; drawArea.Refresh(); drawArea.active_point = point; } Args arg = new Args(); arg["Save"] = true; arg["IsViewed"] = false; _eventHandler.Notify(_eventHandler.AnnotationButtonsRefresh, arg); //drawArea.Location = new Point(point.X, point.Y); //foreach (AnnotationText item in drawArea.Controls) //{ // item.Location = drawArea.active_point; //} // (drawArea.Controls[ControlIndx] as Panel).Location = drawArea.active_point; // //ToolObject.text_move(drawArea, e); // drawArea.Controls[ControlIndx].SendToBack(); // drawArea.Cursor = Cursors.SizeAll; //drawArea.Refresh(); } if (selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); return; } } }