[dia] uml: fix autogap calculation of Note



commit 3b8ca91397cf2df156689029d0cd6ca9f4c316ce
Author: Hans Breuer <hans breuer org>
Date:   Thu Oct 6 21:48:54 2011 +0200

    uml: fix autogap calculation of Note
    
    so that the cut corner is considered in distance_from()

 objects/UML/note.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/objects/UML/note.c b/objects/UML/note.c
index 0c71de3..0010c24 100644
--- a/objects/UML/note.c
+++ b/objects/UML/note.c
@@ -167,8 +167,20 @@ note_set_props(Note *note, GPtrArray *props)
 static real
 note_distance_from(Note *note, Point *point)
 {
-  DiaObject *obj = &note->element.object;
-  return distance_rectangle_point(&obj->bounding_box, point);
+  Element *elem = &note->element;
+  real x = elem->corner.x;
+  real y = elem->corner.y;
+  real w = elem->width;
+  real h = elem->height;
+  Point pts[] = {
+    { x, y },
+    { x + w - NOTE_CORNER, y },
+    { x + w, y + NOTE_CORNER },
+    { x + w, y + h },
+    { x, y + h }
+  };
+  /* not using the line_width parameter to the arrow on the line */
+  return distance_polygon_point(pts, G_N_ELEMENTS(pts), 0.0, point);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]