summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-15 19:15:51 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-10-15 20:28:11 (GMT)
commit691128f611669cad769f8a1b7a15406704741019 (patch)
tree6b4f242bb648b0921122d77d4df35b5cd12f3155
parenta27bb1e1f7aa4f23d2a377f757277562e5bb39f9 (diff)
downloadeeshow-691128f611669cad769f8a1b7a15406704741019.zip
eeshow-691128f611669cad769f8a1b7a15406704741019.tar.gz
eeshow-691128f611669cad769f8a1b7a15406704741019.tar.bz2
gui/comp.c (get_bbox): apply transformation matrix
-rw-r--r--gui/comp.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gui/comp.c b/gui/comp.c
index 076f5a5..cc7d6a6 100644
--- a/gui/comp.c
+++ b/gui/comp.c
@@ -18,6 +18,7 @@
#include "misc/util.h"
#include "kicad/dwg.h"
+#include "gfx/misc.h"
#include "gui/aoi.h"
#include "gui/over.h"
#include "gui/pop.h"
@@ -68,6 +69,8 @@ static struct dwg_bbox get_bbox(const struct sch_obj *sch_obj)
int xa = 0, ya = 0, xb = 0, yb = 0;
bool first = 1;
int i;
+ struct dwg_bbox bbox;
+ const int *m = sch_obj->u.comp.m;
for (obj = sch_obj->u.comp.comp->objs; obj; obj = obj->next)
switch (obj->type) {
@@ -95,12 +98,19 @@ static struct dwg_bbox get_bbox(const struct sch_obj *sch_obj)
break;
}
- struct dwg_bbox bbox = {
- .x = xa + sch_obj->x,
- .y = ya + sch_obj->y,
- .w = xb - xa + 1,
- .h = yb - ya + 1,
- };
+ bbox.x = mx(xa, ya, m);
+ bbox.y = my(xa, ya, m);
+ bbox.w = mx(xb, yb, m) - bbox.x + 1;
+ bbox.h = my(xb, yb, m) - bbox.y + 1;
+ if (bbox.w < 0) {
+ bbox.w = -bbox.w;
+ bbox.x -= bbox.w;
+ }
+ if (bbox.h < 0) {
+ bbox.h = -bbox.h;
+ bbox.y -= bbox.h;
+ }
+
return bbox;
}