dia r4061 - in trunk: . objects/UML



Author: hans
Date: Sat May 31 11:43:32 2008
New Revision: 4061
URL: http://svn.gnome.org/viewvc/dia?rev=4061&view=rev

Log:
2008-05-31  Hans Breuer  <hans breuer org>

	* objects/UML/association.c : moved calculation of the direction 
	triangle into it's own function and use it for bounding box 
	calculation and drawing. Fixes bug #158265


Modified:
   trunk/ChangeLog
   trunk/objects/UML/association.c

Modified: trunk/objects/UML/association.c
==============================================================================
--- trunk/objects/UML/association.c	(original)
+++ trunk/objects/UML/association.c	Sat May 31 11:43:32 2008
@@ -365,6 +365,36 @@
   return change;
 }
 
+/** calculate the point of the small triangle for show_direction  */
+static gboolean
+assoc_get_direction_poly (Association *assoc, Point* poly)
+{
+  if (assoc->show_direction) {
+    if (assoc->direction == ASSOC_RIGHT) {
+      poly[0].x = assoc->text_pos.x + assoc->text_width + 0.1;
+      if (assoc->text_align == ALIGN_CENTER)
+        poly[0].x -= assoc->text_width/2.0;
+      poly[0].y = assoc->text_pos.y;
+      poly[1].x = poly[0].x;
+      poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
+      poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
+      poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+      return TRUE;
+    } else if (assoc->direction == ASSOC_LEFT) {
+      poly[0].x = assoc->text_pos.x - 0.2;
+      if (assoc->text_align == ALIGN_CENTER)
+        poly[0].x -= assoc->text_width/2.0;
+      poly[0].y = assoc->text_pos.y;
+      poly[1].x = poly[0].x;
+      poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
+      poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
+      poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
 static void
 association_draw(Association *assoc, DiaRenderer *renderer)
 {
@@ -426,37 +456,8 @@
   /* Direction: */
   renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
 
-  switch (assoc->direction) {
-  case ASSOC_NODIR:
-    break;
-  case ASSOC_RIGHT:
-    if (assoc->show_direction) {
-      poly[0].x = assoc->text_pos.x + assoc->text_width + 0.1;
-      if (assoc->text_align == ALIGN_CENTER)
-        poly[0].x -= assoc->text_width/2.0;
-      poly[0].y = assoc->text_pos.y;
-      poly[1].x = poly[0].x;
-      poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
-      poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
-      poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
-      renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
-    }
-    break;
-  case ASSOC_LEFT:
-    if (assoc->show_direction) {
-      poly[0].x = assoc->text_pos.x - 0.2;
-      if (assoc->text_align == ALIGN_CENTER)
-        poly[0].x -= assoc->text_width/2.0;
-      poly[0].y = assoc->text_pos.y;
-      poly[1].x = poly[0].x;
-      poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
-      poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
-      poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
-      renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
-    }
-    break;
-  }
-
+  if (assoc_get_direction_poly (assoc, poly))
+    renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
 
   for (i=0;i<2;i++) {
     AssociationEnd *end = &assoc->end[i];
@@ -590,6 +591,7 @@
   AssociationEnd *end;
   Orientation dir;
   int n = orth->numpoints - 1, fp, sp;
+  Point dir_poly[3];
 
   /* Find the first and second points depending on which end: */
   if (endnum) {
@@ -653,6 +655,12 @@
   rect.bottom = rect.top + 2*ASSOCIATION_FONTHEIGHT;
   
   rectangle_union(&obj->bounding_box, &rect);
+  
+  if (assoc_get_direction_poly (assoc, dir_poly)) {
+    int i;
+    for (i = 0; i < 3; ++i)
+      rectangle_add_point (&obj->bounding_box, &dir_poly[i]);
+  }
 }
 
 static void



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