mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-12-22 13:30:49 +02:00
track bounding box also on a per-package basis and use this to scale Postscript
Until now, everything used the bounding box of the root frame which contains all the packages, visible or not. We now also record what ends up in which package, allowing inst_get_bbox to return the bounding box of a specific package. This is mainly useful for scaling Postscript output where only one package is printed per sheet and there is not much point in reserving space for any other packages that may be generated from the same footprint definition.
This commit is contained in:
parent
e2ce0eecf7
commit
86c082f5a9
8
gui.c
8
gui.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui.c - Editor GUI core
|
||||
*
|
||||
* Written 2009-2011 by Werner Almesberger
|
||||
* Copyright 2009-2011 by Werner Almesberger
|
||||
* Written 2009-2012 by Werner Almesberger
|
||||
* Copyright 2009-2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -326,7 +326,7 @@ void change_world(void)
|
||||
|
||||
inst_deselect();
|
||||
status_begin_reporting();
|
||||
before = inst_get_bbox();
|
||||
before = inst_get_bbox(NULL);
|
||||
reachable_is_active = reachable_pkg && reachable_pkg == active_pkg;
|
||||
instantiate();
|
||||
if (reachable_is_active && reachable_pkg &&
|
||||
@ -334,7 +334,7 @@ void change_world(void)
|
||||
active_pkg = reachable_pkg;
|
||||
instantiate();
|
||||
}
|
||||
after = inst_get_bbox();
|
||||
after = inst_get_bbox(NULL);
|
||||
label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED);
|
||||
do_build_frames();
|
||||
if (after.min.x < before.min.x || after.min.y < before.min.y ||
|
||||
|
10
gui_canvas.c
10
gui_canvas.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui_canvas.c - GUI, canvas
|
||||
*
|
||||
* Written 2009, 2010 by Werner Almesberger
|
||||
* Copyright 2009, 2010 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -94,7 +94,7 @@ static void center(const struct bbox *this_bbox)
|
||||
{
|
||||
struct bbox bbox;
|
||||
|
||||
bbox = this_bbox ? *this_bbox : inst_get_bbox();
|
||||
bbox = this_bbox ? *this_bbox : inst_get_bbox(NULL);
|
||||
draw_ctx.center.x = (bbox.min.x+bbox.max.x)/2;
|
||||
draw_ctx.center.y = (bbox.min.y+bbox.max.y)/2;
|
||||
}
|
||||
@ -107,7 +107,7 @@ static void auto_scale(const struct bbox *this_bbox)
|
||||
int sx, sy;
|
||||
float aw, ah;
|
||||
|
||||
bbox = this_bbox ? *this_bbox : inst_get_bbox();
|
||||
bbox = this_bbox ? *this_bbox : inst_get_bbox(NULL);
|
||||
aw = draw_ctx.widget->allocation.width;
|
||||
ah = draw_ctx.widget->allocation.height;
|
||||
h = bbox.max.x-bbox.min.x;
|
||||
@ -332,7 +332,7 @@ static void zoom_out(struct coord pos)
|
||||
{
|
||||
struct bbox bbox;
|
||||
|
||||
bbox = inst_get_bbox();
|
||||
bbox = inst_get_bbox(NULL);
|
||||
bbox.min = translate(bbox.min);
|
||||
bbox.max = translate(bbox.max);
|
||||
if (bbox.min.x >= ZOOM_STOP_BORDER &&
|
||||
|
15
inst.c
15
inst.c
@ -581,6 +581,14 @@ static void propagate_bbox(const struct inst *inst)
|
||||
|
||||
update_bbox(&frame->bbox, inst->bbox.min);
|
||||
update_bbox(&frame->bbox, inst->bbox.max);
|
||||
|
||||
if (curr_pkg->bbox.min.x || curr_pkg->bbox.min.y ||
|
||||
curr_pkg->bbox.max.x || curr_pkg->bbox.max.y) {
|
||||
update_bbox(&curr_pkg->bbox, inst->bbox.min);
|
||||
update_bbox(&curr_pkg->bbox, inst->bbox.max);
|
||||
} else {
|
||||
curr_pkg->bbox = inst->bbox;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1225,9 +1233,12 @@ void inst_select_pkg(const char *name, int active)
|
||||
/* ----- misc. ------------------------------------------------------------- */
|
||||
|
||||
|
||||
struct bbox inst_get_bbox(void)
|
||||
struct bbox inst_get_bbox(const struct pkg *pkg)
|
||||
{
|
||||
return pkgs->insts[ip_frame]->bbox;
|
||||
if (pkg)
|
||||
return pkg->bbox;
|
||||
else
|
||||
return pkgs->insts[ip_frame]->bbox;
|
||||
}
|
||||
|
||||
|
||||
|
3
inst.h
3
inst.h
@ -124,6 +124,7 @@ struct pkg {
|
||||
const char *name; /* NULL if global package */
|
||||
struct inst *insts[ip_n];
|
||||
struct inst **next_inst[ip_n];
|
||||
struct bbox bbox; /* bbox only of items in this package */
|
||||
struct sample **samples;
|
||||
int n_samples;
|
||||
struct pkg *next;
|
||||
@ -198,7 +199,7 @@ void inst_end_frame(const struct frame *frame);
|
||||
|
||||
void inst_select_pkg(const char *name, int active);
|
||||
|
||||
struct bbox inst_get_bbox(void);
|
||||
struct bbox inst_get_bbox(const struct pkg *pkg);
|
||||
|
||||
void inst_start(void);
|
||||
void inst_commit(void);
|
||||
|
@ -809,7 +809,7 @@ static void ps_package(FILE *file, const struct pkg *pkg, int page)
|
||||
x = 2*PAGE_HALF_WIDTH-2*PS_DIVIDER_BORDER;
|
||||
y = PAGE_HALF_HEIGHT-PS_HEADER_HEIGHT-3*PS_DIVIDER_BORDER;
|
||||
|
||||
bbox = inst_get_bbox();
|
||||
bbox = inst_get_bbox(pkg);
|
||||
w = 2*(-bbox.min.x > bbox.max.x ? -bbox.min.x : bbox.max.x);
|
||||
h = 2*(-bbox.min.y > bbox.max.y ? -bbox.min.y : bbox.max.y);
|
||||
|
||||
@ -1132,7 +1132,7 @@ static void ps_package_fullpage(FILE *file, const struct pkg *pkg, int page)
|
||||
|
||||
ps_page(file, page, pkg);
|
||||
active_params = postscript_params;
|
||||
bbox = inst_get_bbox();
|
||||
bbox = inst_get_bbox(pkg);
|
||||
cx = (bbox.min.x+bbox.max.x)/2;
|
||||
cy = (bbox.min.y+bbox.max.y)/2;
|
||||
if (active_params.zoom) {
|
||||
|
Loading…
Reference in New Issue
Block a user