set_modify() returns now # of floaters, use this info to redraw all viewport in `xschn setprop` commands

This commit is contained in:
Stefan Schippers 2023-10-29 20:02:23 +01:00
parent d776d6a351
commit 958c5a1525
3 changed files with 18 additions and 12 deletions

View File

@ -136,8 +136,9 @@ const char *get_text_floater(int i)
/* mod=-1 used to force set title /* mod=-1 used to force set title
* mod=-2 used to reset floaters cache * mod=-2 used to reset floaters cache
* if floaters are present set_modify(1) (after a modify opration) must be done before draw() * if floaters are present set_modify(1) (after a modify opration) must be done before draw()
* to invalidate cached floater string values before redrawing*/ * to invalidate cached floater string values before redrawing
void set_modify(int mod) * return 1 if floaters are found (mod==-2 or mod == 1 or mod == -1) */
int set_modify(int mod)
{ {
int i, floaters = 0; int i, floaters = 0;
@ -169,6 +170,7 @@ void set_modify(int mod)
if(xctx->modified) tcleval("set_tab_names *"); if(xctx->modified) tcleval("set_tab_names *");
else tcleval("set_tab_names"); else tcleval("set_tab_names");
} }
return floaters;
} }
void print_version() void print_version()

View File

@ -4179,12 +4179,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
return TCL_ERROR; return TCL_ERROR;
} else { } else {
char *type; char *type;
int cond; int floaters = 0, cond;
char *subst = NULL; char *subst = NULL;
floaters = set_modify(1);
if(!fast) { if(!fast) {
bbox(START,0.0,0.0,0.0,0.0); if(!floaters) bbox(START,0.0,0.0,0.0,0.0);
symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2); symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2);
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2); if(!floaters)
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
xctx->push_undo(); xctx->push_undo();
} }
xctx->prep_hash_inst=0; xctx->prep_hash_inst=0;
@ -4209,16 +4211,18 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_strdup2(_ALLOC_ID_, &xctx->inst[inst].lab, get_tok_value(xctx->inst[inst].prop_ptr, "lab", 0)); my_strdup2(_ALLOC_ID_, &xctx->inst[inst].lab, get_tok_value(xctx->inst[inst].prop_ptr, "lab", 0));
} }
else xctx->inst[inst].flags &= ~PIN_OR_LABEL; else xctx->inst[inst].flags &= ~PIN_OR_LABEL;
set_modify(1);
if(!fast) { if(!fast) {
/* new symbol bbox after prop changes (may change due to text length) */ /* new symbol bbox after prop changes (may change due to text length) */
symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2); symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2);
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2); if(!floaters) {
/* redraw symbol with new props */ bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
bbox(SET,0.0,0.0,0.0,0.0); /* redraw symbol with new props */
bbox(SET,0.0,0.0,0.0,0.0);
}
draw(); draw();
bbox(END,0.0,0.0,0.0,0.0); if(!floaters) {
bbox(END,0.0,0.0,0.0,0.0);
}
} }
Tcl_SetResult(interp, xctx->inst[inst].instname , TCL_VOLATILE); Tcl_SetResult(interp, xctx->inst[inst].instname , TCL_VOLATILE);
} }

View File

@ -1229,7 +1229,7 @@ extern void enable_layers(void);
extern void set_snap(double); extern void set_snap(double);
extern void set_grid(double); extern void set_grid(double);
extern void create_plot_cmd(void); extern void create_plot_cmd(void);
extern void set_modify(int mod); extern int set_modify(int mod); /* return number of floaters */
extern int there_are_floaters(void); extern int there_are_floaters(void);
extern void dbg(int level, char *fmt, ...); extern void dbg(int level, char *fmt, ...);
extern unsigned int hash_file(const char *f, int skip_path_lines); extern unsigned int hash_file(const char *f, int skip_path_lines);