[dia] Prepare DiaRenderer::draw_arc() to be refined



commit c7da45a37c6fbccf93e79e28753030527f21d6e6
Author: Hans Breuer <hans breuer org>
Date:   Sat May 10 17:41:51 2014 +0200

    Prepare DiaRenderer::draw_arc() to be refined
    
     - some comments to make the following change more easy
     - arc-definition.dia: sketching the current and future behavior
     - arcs.dia: dedicated test file for current arc usages

 lib/diasvgrenderer.c            |    4 ++--
 lib/geometry.c                  |    2 +-
 objects/standard/arc.c          |   12 +++++++++---
 samples/Self/arc-definition.dia |  Bin 0 -> 1655 bytes
 samples/arcs.dia                |  Bin 0 -> 3015 bytes
 5 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index 229efb2..bbdcd59 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -529,8 +529,8 @@ draw_arc(DiaRenderer *self,
   real sy=center->y - ry*sin(angle1*G_PI/180);
   real ex=center->x + rx*cos(angle2*G_PI/180);
   real ey=center->y - ry*sin(angle2*G_PI/180);
-  int swp = 0; /* always drawin negative direction */
-  int large_arc; 
+  int swp = 0; /* always drawing negative direction (still) */
+  int large_arc;
   gchar sx_buf[DTOSTR_BUF_SIZE];
   gchar sy_buf[DTOSTR_BUF_SIZE];
   gchar rx_buf[DTOSTR_BUF_SIZE];
diff --git a/lib/geometry.c b/lib/geometry.c
index 004ef38..4936af6 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -582,7 +582,7 @@ fillet(Point *p1, Point *p2, Point *p3, Point *p4,
     /* also this means we need to swap our angles later on */
     righthand = TRUE;
   }
-  /* now calculate the actual angles in a form that the draw arc function
+  /* now calculate the actual angles in a form that the draw_arc function
      of the renderer can use */
   start_angle = start_angle*180.0/G_PI;
   stop_angle  = start_angle + stop_angle*180.0/G_PI;
diff --git a/objects/standard/arc.c b/objects/standard/arc.c
index 14392b0..4afd0bf 100644
--- a/objects/standard/arc.c
+++ b/objects/standard/arc.c
@@ -798,7 +798,7 @@ arc_update_data(Arc *arc)
   y1 = endpoints[0].y;
   x2 = endpoints[1].x;
   y2 = endpoints[1].y;
-  
+
   lensq = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
   if (fabs(arc->curve_distance) > 0.01)
     radius = lensq/(8*arc->curve_distance) + arc->curve_distance/2.0;
@@ -820,6 +820,7 @@ arc_update_data(Arc *arc)
   if (angle2<0)
     angle2+=360.0;
 
+  /* swap: draw_arc is always counter-clockwise */
   if (radius<0.0) {
     real tmp;
     tmp = angle1;
@@ -843,6 +844,10 @@ arc_update_data(Arc *arc)
   arc_update_handles(arc);
   /* startpoint, midpoint, endpoint */
   righthand = is_right_hand (&endpoints[0], &arc->middle_handle.pos, &endpoints[1]);
+  /* there should be no need to calculate the direction once more */
+  if (!(   (righthand && arc->curve_distance <= 0.0)
+        || (!righthand && arc->curve_distance >= 0.0)))
+    g_warning ("Standard - Arc: check invariant!");
   connection_update_boundingbox(conn);
 
   /* fix boundingbox for arc's special shape XXX find a more elegant way: */
@@ -867,8 +872,9 @@ arc_update_data(Arc *arc)
     rectangle_add_point (&obj->bounding_box, &pt);
   }
   if (arc->start_arrow.type != ARROW_NONE) {
-    /* a good from-point would be the chord of arrow length, but draw_arc_with_arrows currently uses the 
tangent
-     * For big arcs the difference is not huge and the minimum size of small arcs should be limited by the 
arror length.
+    /* a good from-point would be the chord of arrow length, but draw_arc_with_arrows
+     * currently uses the tangent For big arcs the difference is not huge and the
+     * minimum size of small arcs should be limited by the arror length.
      */
     Rectangle bbox = {0,};
     real tmp;
diff --git a/samples/Self/arc-definition.dia b/samples/Self/arc-definition.dia
new file mode 100644
index 0000000..53e87b6
Binary files /dev/null and b/samples/Self/arc-definition.dia differ
diff --git a/samples/arcs.dia b/samples/arcs.dia
new file mode 100644
index 0000000..5326968
Binary files /dev/null and b/samples/arcs.dia differ


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