[dia] Improved bounding box calculation for custom shapes
- From: Hans Breuer <hans src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dia] Improved bounding box calculation for custom shapes
- Date: Sun, 24 Jan 2010 11:22:41 +0000 (UTC)
commit 5056ba9cb6d975e56f4cdca24917fce9629a385c
Author: Hans Breuer <hans breuer org>
Date: Wed Jan 13 21:28:16 2010 +0100
Improved bounding box calculation for custom shapes
Formerly the initial size for shapes with bezier was based on
worst case: the box including all control points. Now we are
using the proper API, but still the movement unittest for
"Assorted - Heart" fails.
objects/custom/custom_object.c | 44 +++------------------------------------
objects/custom/shape_info.c | 12 ++++++++++
2 files changed, 16 insertions(+), 40 deletions(-)
---
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 27fe42d..e30303c 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -1352,6 +1352,7 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
line_bbox(&p1,&p2,&extra,&rect);
break;
}
+ case GE_POLYGON:
case GE_POLYLINE: {
PolyBBExtras extra;
@@ -1365,24 +1366,10 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
&g_array_index(arr, Point, i));
polyline_bbox(&g_array_index(arr,Point,0),el->polyline.npoints,
- &extra,FALSE,&rect);
- break;
- }
- case GE_POLYGON: {
- PolyBBExtras extra;
- extra.start_trans = extra.end_trans = extra.middle_trans =
- el->polygon.s.line_width * lwfactor;
- extra.start_long = extra.end_long = 0;
-
- g_array_set_size(arr, el->polygon.npoints);
- for (i = 0; i < el->polygon.npoints; i++)
- transform_coord(custom, &el->polygon.points[i],
- &g_array_index(arr, Point, i));
-
- polyline_bbox(&g_array_index(arr,Point,0),el->polyline.npoints,
- &extra,TRUE,&rect);
+ &extra,el->type==GE_POLYGON,&rect);
break;
}
+ case GE_SHAPE:
case GE_PATH: {
PolyBBExtras extra;
extra.start_trans = extra.end_trans = extra.middle_trans =
@@ -1404,30 +1391,7 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
}
polybezier_bbox(&g_array_index(barr,BezPoint,0),el->path.npoints,
- &extra,FALSE,&rect);
- break;
- }
- case GE_SHAPE: {
- PolyBBExtras extra;
- extra.start_trans = extra.end_trans = extra.middle_trans =
- el->shape.s.line_width * lwfactor;
- extra.start_long = extra.end_long = 0;
-
- g_array_set_size(barr, el->shape.npoints);
- for (i = 0; i < el->shape.npoints; i++)
- switch (g_array_index(barr,BezPoint,i).type=el->shape.points[i].type) {
- case BEZ_CURVE_TO:
- transform_coord(custom, &el->shape.points[i].p3,
- &g_array_index(barr, BezPoint, i).p3);
- transform_coord(custom, &el->shape.points[i].p2,
- &g_array_index(barr, BezPoint, i).p2);
- case BEZ_MOVE_TO:
- case BEZ_LINE_TO:
- transform_coord(custom, &el->shape.points[i].p1,
- &g_array_index(barr, BezPoint, i).p1);
- }
- polybezier_bbox(&g_array_index(barr,BezPoint,0),el->shape.npoints,
- &extra,TRUE,&rect);
+ &extra,el->type==GE_SHAPE,&rect);
break;
}
case GE_ELLIPSE: {
diff --git a/objects/custom/shape_info.c b/objects/custom/shape_info.c
index c851081..b71683d 100644
--- a/objects/custom/shape_info.c
+++ b/objects/custom/shape_info.c
@@ -37,6 +37,7 @@
#include "message.h"
#include "intl.h"
#include "prefs.h"
+#include "boundingbox.h"
#include "units.h"
@@ -582,6 +583,16 @@ update_bounds(ShapeInfo *info)
break;
case GE_PATH:
case GE_SHAPE:
+#if 1
+ {
+ Rectangle bbox;
+ PolyBBExtras extra = { 0, };
+
+ polybezier_bbox(&el->path.points[0],el->path.npoints,
+ &extra,el->type == GE_SHAPE,&bbox);
+ rectangle_union(&info->shape_bounds, &bbox);
+ }
+#else
for (i = 0; i < el->path.npoints; i++)
switch (el->path.points[i].type) {
case BEZ_CURVE_TO:
@@ -591,6 +602,7 @@ update_bounds(ShapeInfo *info)
case BEZ_LINE_TO:
check_point(info, &el->path.points[i].p1);
}
+#endif
break;
case GE_IMAGE:
check_point(info, &(el->image.topleft));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]