dia r4186 - in trunk: . objects/standard



Author: hans
Date: Sat Jan 10 01:08:01 2009
New Revision: 4186
URL: http://svn.gnome.org/viewvc/dia?rev=4186&view=rev

Log:
2009-01-10  Hans Breuer  <hans breuer org>

	* objects/standard/arc.c(arc_move_handle) : maintain a minimum 
	distance between the three arc handles. Two or even all three 
	handles in at the same position did produce unstable results.
	As a side-effect this is fixing bug #501696
	* objects/standard/outline.c(outline_move_handle) : maintain
	minimum distance between the two handles here as well. 
	Otherwise a meaningless font-size of zero could occur.



Modified:
   trunk/ChangeLog
   trunk/objects/standard/arc.c
   trunk/objects/standard/outline.c

Modified: trunk/objects/standard/arc.c
==============================================================================
--- trunk/objects/standard/arc.c	(original)
+++ trunk/objects/standard/arc.c	Sat Jan 10 01:08:01 2009
@@ -405,6 +405,23 @@
   assert(arc!=NULL);
   assert(handle!=NULL);
   assert(to!=NULL);
+  /* A minimum distance between our three points needs to be maintained
+   * Otherwise our math will get unstable with unpredictable results. */
+  {
+    const Point *p1, *p2;
+    
+    if (handle->id == HANDLE_MIDDLE) {
+      p1 = &arc->connection.endpoints[0];
+      p2 = &arc->connection.endpoints[1];
+    } else {
+      p1 = &arc->middle_handle.pos;
+      p2 = &arc->connection.endpoints[(handle == (&arc->connection.endpoint_handles[0])) ? 1 : 0];
+    }
+    if (   (distance_point_point (to, p1) < 0.01)
+        || (distance_point_point (to, p2) < 0.01))
+      return NULL;
+  }
+
   if (handle->id == HANDLE_MIDDLE) {
           TRACE(printf("curve_dist: %.2f \n",arc->curve_distance));
           arc->curve_distance = arc_compute_curve_distance(arc, &arc->connection.endpoints[0], &arc->connection.endpoints[1], to);

Modified: trunk/objects/standard/outline.c
==============================================================================
--- trunk/objects/standard/outline.c	(original)
+++ trunk/objects/standard/outline.c	Sat Jan 10 01:08:01 2009
@@ -471,7 +471,7 @@
   /* we use this to modify angle and scale */
   switch (handle->id) {
   case HANDLE_RESIZE_NW :
-    obj->position = start = *to;
+    start = *to;
     break;
   case HANDLE_RESIZE_SE :
     end = *to;
@@ -480,9 +480,14 @@
     g_warning ("Outline unknown handle");
   }
   dist = distance_point_point (&start, &end);
-  outline->font_height *= (dist / old_dist);
+  /* disallow everything below a certain level, otherwise the font-size could become invalid */
+  if (dist > 0.1) {
+    obj->position = start;
+    
+    outline->font_height *= (dist / old_dist);
   
-  outline_update_data (outline);
+    outline_update_data (outline);
+  }
   return NULL;
 }
 static ObjectChange* 



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