update all text_bbox() calls to account for tabs in bbox calculation

This commit is contained in:
stefan schippers 2024-05-24 18:05:37 +02:00
parent d04162b31e
commit 2060ca8871
8 changed files with 51 additions and 16 deletions

View File

@ -2433,6 +2433,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
#if HAS_CAIRO==1
int customfont;
#endif
char *estr = NULL;
boundbox->x1=-100;
boundbox->x2=100;
@ -2533,7 +2534,8 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
#if HAS_CAIRO==1
customfont = set_text_custom_font(&xctx->text[i]);
#endif
if(text_bbox(get_text_floater(i), xctx->text[i].xscale,
estr = my_expand(get_text_floater(i), tclgetintvar("tabstop"));
if(text_bbox(estr, xctx->text[i].xscale,
xctx->text[i].yscale,xctx->text[i].rot, xctx->text[i].flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
@ -2541,6 +2543,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
++count;
updatebbox(count,boundbox,&rect);
}
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);

View File

@ -1349,6 +1349,7 @@ static int edit_text_property(int x)
}
if(strcmp(tclgetvar("tctx::rcode"),"") )
{
char *estr = NULL;
dbg(1, "edit_text_property(): tctx::rcode !=\"\"\n");
if(text_changed || size_changed || props_changed) {
modified = 1;
@ -1364,10 +1365,12 @@ static int edit_text_property(int x)
#if HAS_CAIRO==1
customfont = set_text_custom_font(&xctx->text[sel]);
#endif
text_bbox(get_text_floater(sel), xctx->text[sel].xscale,
estr = my_expand(get_text_floater(sel), tclgetintvar("tabstop"));
text_bbox(estr, xctx->text[sel].xscale,
xctx->text[sel].yscale, (short)rot, (short)flip, xctx->text[sel].hcenter,
xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);

View File

@ -356,6 +356,7 @@ static void find_closest_text(double mx,double my)
#if HAS_CAIRO==1
int customfont;
#endif
char *estr = NULL;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
for(i=0;i<xctx->texts; ++i)
{
@ -364,11 +365,13 @@ static void find_closest_text(double mx,double my)
#if HAS_CAIRO==1
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(get_text_floater(i),
estr = my_expand(get_text_floater(i), tclgetintvar("tabstop"));
text_bbox(estr,
xctx->text[i].xscale, xctx->text[i].yscale, rot, flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2, &tmp, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);

View File

@ -519,6 +519,7 @@ void copy_objects(int what)
double angle, dtmp;
int newpropcnt;
double tmpx, tmpy;
char *estr = NULL;
#if HAS_CAIRO==1
int customfont;
@ -813,11 +814,13 @@ void copy_objects(int what)
#if HAS_CAIRO==1 /* bbox after copy */
customfont = set_text_custom_font(&xctx->text[l]);
#endif
text_bbox(get_text_floater(l), xctx->text[l].xscale,
estr = my_expand(get_text_floater(l), tclgetintvar("tabstop"));
text_bbox(estr, xctx->text[l].xscale,
xctx->text[l].yscale, xctx->text[l].rot,xctx->text[l].flip,
xctx->text[l].hcenter, xctx->text[l].vcenter,
xctx->text[l].x0, xctx->text[l].y0,
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpi, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);
@ -913,6 +916,7 @@ void move_objects(int what, int merge, double dx, double dy)
int c, i, n, k, tmpint;
double angle, dtmp;
double tx1,ty1; /* temporaries for swapping coordinates 20070302 */
char *estr = NULL;
#if HAS_CAIRO==1
int customfont;
#endif
@ -1263,10 +1267,12 @@ void move_objects(int what, int merge, double dx, double dy)
#if HAS_CAIRO==1 /* bbox before move */
customfont = set_text_custom_font(&xctx->text[n]);
#endif
text_bbox(get_text_floater(n), xctx->text[n].xscale,
estr = my_expand(get_text_floater(n), tclgetintvar("tabstop"));
text_bbox(estr, xctx->text[n].xscale,
xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter,
xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0,
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpint, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);
@ -1288,10 +1294,12 @@ void move_objects(int what, int merge, double dx, double dy)
#if HAS_CAIRO==1 /* bbox after move */
customfont = set_text_custom_font(&xctx->text[n]);
#endif
text_bbox(get_text_floater(n), xctx->text[n].xscale,
estr = my_expand(get_text_floater(n), tclgetintvar("tabstop"));
text_bbox(estr, xctx->text[n].xscale,
xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter,
xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0,
&xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2, &tmpint, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);

View File

@ -202,6 +202,7 @@ void hash_object(int what, int type, int n, int c)
double x1, y1, x2, y2;
int x1a, x2a, y1a, y2a;
int skip = 0;
char *estr = NULL;
switch(type) {
case ELEMENT:
@ -236,11 +237,13 @@ void hash_object(int what, int type, int n, int c)
xctx->arc[c][n].a, xctx->arc[c][n].b, &x1, &y1, &x2, &y2);
break;
case xTEXT:
text_bbox(get_text_floater(n),
estr = my_expand(get_text_floater(n), tclgetintvar("tabstop"));
text_bbox(estr,
xctx->text[n].xscale, xctx->text[n].yscale, xctx->text[n].rot, xctx->text[n].flip,
xctx->text[n].hcenter, xctx->text[n].vcenter,
xctx->text[n].x0, xctx->text[n].y0,
&x1,&y1, &x2,&y2, &tmpi, &tmpd);
my_free(_ALLOC_ID_, &estr);
break;
default:
skip = 1;

View File

@ -3779,11 +3779,13 @@ static void calc_symbol_bbox(int pos)
*
* for(i=0;i<lastt; ++i)
* {
int tmp;
* int tmp;
* count++;
* rot=tt[i].rot;flip=tt[i].flip;
* text_bbox(get_text_floater(i), tt[i].xscale, tt[i].yscale, rot, flip,
* estr = my_expand(get_text_floater(i), tclgetintvar("tabstop"));
* text_bbox(estr, tt[i].xscale, tt[i].yscale, rot, flip,
* tt[i].x0, tt[i].y0, &rx1,&ry1,&rx2,&ry2, &dtmp);
* my_free(_ALLOC_ID_, &estr);
* tmp.x1=rx1;tmp.y1=ry1;tmp.x2=rx2;tmp.y2=ry2;
* updatebbox(count,&boundbox,&tmp);
* }

View File

@ -5219,11 +5219,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
bbox(START,0.0,0.0,0.0,0.0);
}
if(argc > 5) {
char *estr = NULL;
if(!fast) {
text_bbox(get_text_floater(n), t->xscale,
estr = my_expand(get_text_floater(n), tclgetintvar("tabstop"));
text_bbox(estr, t->xscale,
t->yscale, t->rot, t->flip, t->hcenter,
t->vcenter, t->x0, t->y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
my_free(_ALLOC_ID_, &estr);
bbox(ADD, xx1, yy1, xx2, yy2);
}
/* verify if there is some difference */
@ -5247,12 +5250,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
}
if(change_done) {
char *estr = NULL;
set_modify(1);
set_text_flags(t);
text_bbox(get_text_floater(n), t->xscale,
estr = my_expand(get_text_floater(n), tclgetintvar("tabstop"));
text_bbox(estr, t->xscale,
t->yscale, t->rot, t->flip, t->hcenter,
t->vcenter, t->x0, t->y0,
&xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
my_free(_ALLOC_ID_, &estr);
if(!fast) bbox(ADD, xx1, yy1, xx2, yy2);
}
if(!fast) {

View File

@ -353,7 +353,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
for(j=0;j< (xctx->inst[i].ptr+ xctx->sym)->texts; ++j)
{
double xscale, yscale;
char *estr = NULL;
get_sym_text_size(i, j, &xscale, &yscale);
text = (xctx->inst[i].ptr+ xctx->sym)->text[j];
@ -367,12 +367,14 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
#if HAS_CAIRO==1
customfont=set_text_custom_font(&text);
#endif
text_bbox(tmp_txt, xscale, yscale,
estr = my_expand(tmp_txt, tclgetintvar("tabstop"));
text_bbox(estr, xscale, yscale,
(text.rot + ( (sym_flip && (text.rot & 1) ) ? sym_rot+2 : sym_rot)) &0x3,
sym_flip ^ text.flip, text.hcenter, text.vcenter,
x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
dbg(1, "symbol bbox: text bbox: %s, %g %g %g %g\n", tmp_txt, xx1, yy1, xx2, yy2);
dbg(1, "symbol bbox: text bbox: zoom=%g, lw=%g\n", xctx->zoom, xctx->lw);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);
@ -1302,6 +1304,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u
#if HAS_CAIRO==1
int customfont;
#endif
char *estr = NULL;
en_s = tclgetboolvar("enable_stretch");
for(i=0;i<xctx->wires; ++i)
@ -1337,12 +1340,13 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u
#if HAS_CAIRO==1
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(get_text_floater(i),
estr = my_expand(get_text_floater(i), tclgetintvar("tabstop"));
text_bbox(estr,
xctx->text[i].xscale, xctx->text[i].yscale, (short)select_rot, (short)select_flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2, &tmpint, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);
@ -1526,6 +1530,7 @@ void select_touch(double x1,double y1, double x2, double y2, int sel) /*added un
#if HAS_CAIRO==1
int customfont;
#endif
char *estr = NULL;
for(i=0;i<xctx->wires; ++i)
{
@ -1547,11 +1552,13 @@ void select_touch(double x1,double y1, double x2, double y2, int sel) /*added un
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(get_text_floater(i),
estr = my_expand(get_text_floater(i), tclgetintvar("tabstop"));
text_bbox(estr,
xctx->text[i].xscale, xctx->text[i].yscale, (short)select_rot, (short)select_flip,
xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2, &tmpint, &dtmp);
my_free(_ALLOC_ID_, &estr);
#if HAS_CAIRO==1
if(customfont) {
cairo_restore(xctx->cairo_ctx);