[dia] Bug 312641 - better handling for degenerated arcs (part 1)
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Bug 312641 - better handling for degenerated arcs (part 1)
- Date: Mon, 13 Jun 2011 15:17:59 +0000 (UTC)
commit d07b294b9d0dcdc29d8452ff285e190d615f4f30
Author: Hans Breuer <hans breuer org>
Date: Mon Jun 13 17:11:29 2011 +0200
Bug 312641 - better handling for degenerated arcs (part 1)
With all three points on a straight line there was some serious
miscalculation not only leading to abandoned rendering but also
having a hard time to select the arc again (the distance_from
method was not taking care for degeneration)
objects/standard/arc.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/objects/standard/arc.c b/objects/standard/arc.c
index 141f5cc..6c43773 100644
--- a/objects/standard/arc.c
+++ b/objects/standard/arc.c
@@ -193,6 +193,15 @@ in_angle(real angle, real startangle, real endangle)
return (angle>=startangle) && (angle<=endangle);
}
+/* Degenerated arc is a line */
+static gboolean
+arc_is_line (Arc *arc)
+{
+ if (fabs(arc->curve_distance) <= 0.01)
+ return TRUE;
+ return FALSE;
+}
+
static real
arc_distance_from(Arc *arc, Point *point)
{
@@ -203,6 +212,10 @@ arc_distance_from(Arc *arc, Point *point)
endpoints = &arc->connection.endpoints[0];
+ if (arc_is_line (arc))
+ return distance_line_point (&endpoints[0], &endpoints[1],
+ arc->line_width, point);
+
from_center = *point;
point_sub(&from_center, &arc->center);
@@ -561,7 +574,7 @@ arc_draw(Arc *arc, DiaRenderer *renderer)
renderer_ops->set_linecaps(renderer, arc->line_caps);
/* Special case when almost line: */
- if (fabs(arc->curve_distance) <= 0.01) {
+ if (arc_is_line (arc)) {
TRACE(printf("drawing like a line\n"));
renderer_ops->draw_line_with_arrows(renderer,
&gaptmp[0], &gaptmp[1],
@@ -707,8 +720,8 @@ arc_update_data(Arc *arc)
lensq = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
radius = lensq/(8*arc->curve_distance) + arc->curve_distance/2.0;
- if (lensq == 0.0)
- alpha = 1.0; /* arbitrary, but /not/ 1/0 */
+ if (lensq == 0.0 || arc_is_line (arc))
+ alpha = 1.0; /* arbitrary, but /not/ 1/0 */
else
alpha = (radius - arc->curve_distance) / sqrt(lensq);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]