various fixes for corner cases where changing labels of hilight nets (update inst[].color), update symbol bboxes when toggling show_pin_net_names

This commit is contained in:
Stefan Frederik 2021-01-06 05:47:05 +01:00
parent b25bd1d06d
commit 7fc5b4cf1a
3 changed files with 37 additions and 24 deletions

View File

@ -922,6 +922,7 @@ void update_symbol(const char *result, int x)
int cond;
int pushed=0;
int big = xctx->wires> 400 || xctx->instances > 400 ;
dbg(1, "update_symbol(): entering\n");
i=xctx->sel_array[0].n;
if(!result) {
@ -945,7 +946,7 @@ void update_symbol(const char *result, int x)
no_change_props=atoi(tclgetvar("no_change_attrs") );
only_different=atoi(tclgetvar("preserve_unchanged_attrs") );
copy_cell=atoi(tclgetvar("user_wants_copy_cell") );
bbox(START,0.0,0.0,0.0,0.0);
if(!big) bbox(START,0.0,0.0,0.0,0.0);
if(show_pin_net_names) {
prepare_netlist_structs(0);
for(k = 0; k < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; k++) {
@ -981,7 +982,7 @@ void update_symbol(const char *result, int x)
/* 20171220 calculate bbox before changes to correctly redraw areas */
/* must be recalculated as cairo text extents vary with zoom factor. */
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
if(!big) symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
if(sym_number>=0) /* changing symbol ! */
{
if(!pushed) { push_undo(); pushed=1;}
@ -991,7 +992,7 @@ void update_symbol(const char *result, int x)
my_strdup(82, &xctx->inst[i].name, rel_sym_path(symbol));
xctx->inst[i].ptr=sym_number; /* update instance to point to new symbol */
}
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
if(!big) bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
/* update property string from tcl dialog */
if(!no_change_props)
@ -1050,6 +1051,7 @@ void update_symbol(const char *result, int x)
} /* end for(k=0;k<xctx->lastsel;k++) */
/* new symbol bbox after prop changes (may change due to text length) */
if(xctx->modified) {
int j;
xctx->prep_hash_inst=0;
xctx->prep_net_structs=0;
xctx->prep_hi_structs=0;
@ -1057,28 +1059,36 @@ void update_symbol(const char *result, int x)
if(xctx->sel_array[k].type!=ELEMENT) continue;
i=xctx->sel_array[k].n;
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
if(!big) bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
/* in case of net hilights, when changing 'lab' of net labels/pins we must re-run
prepare_netlist_structs() so the .node field of that instance will be reset
and drawn back unhilighted .
|
\|/ */
if(show_pin_net_names || xctx->hilight_nets) {
prepare_netlist_structs(0);
for(j = 0; j < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; j++) {
if( xctx->inst[i].node && xctx->inst[i].node[j]) {
if(!big) find_inst_to_be_redrawn(xctx->inst[i].node[j]);
}
}
}
if(!big) find_inst_hash_clear();
}
}
/* in case of net hilights, when changing 'lab' of net labels/pins we must re-run
prepare_netlist_structs() so the .node field of that instance will be reset
and drawn back unhilighted .
|
\|/ */
if(show_pin_net_names || xctx->hilight_nets) {
prepare_netlist_structs(0);
for(k = 0; k < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; k++) {
if( xctx->inst[i].node && xctx->inst[i].node[k]) {
find_inst_to_be_redrawn(xctx->inst[i].node[k]);
if(xctx->hilight_nets) for(i=0; i < xctx->instances; i++) {
char *type = (xctx->inst[i].ptr+ xctx->sym)->type;
if(type && xctx->inst[i].node && IS_LABEL_SH_OR_PIN(type)) {
if(!bus_hilight_lookup( xctx->inst[i].node[0], 0, XLOOKUP)) {
xctx->inst[i].color = -10000;
}
}
}
find_inst_hash_clear();
}
/* redraw symbol with new props */
bbox(SET,0.0,0.0,0.0,0.0);
if(!big) bbox(SET,0.0,0.0,0.0,0.0);
dbg(1, "update_symbol(): redrawing inst_ptr.txtprop string\n");
draw();
bbox(END,0.0,0.0,0.0,0.0);
if(!big) bbox(END,0.0,0.0,0.0,0.0);
my_free(731, &name);
my_free(732, &ptr);
my_free(733, &new_prop);

View File

@ -535,7 +535,7 @@ int search(const char *tok, const char *val, int sub, int sel)
{
if(!sel) {
type = (xctx->inst[i].ptr+ xctx->sym)->type;
if( type && IS_LABEL_SH_OR_PIN(type) ) {
if( type && xctx->inst[i].node && IS_LABEL_SH_OR_PIN(type) ) {
bus_hilight_lookup(xctx->inst[i].node[0], col, XINSERT_NOREPLACE); /* sets xctx->hilight_nets=1; */
} else {
dbg(1, "search(): setting hilight flag on inst %d\n",i);
@ -852,8 +852,8 @@ void propagate_hilights(int set, int clear, int mode)
xctx->inst[i].color=-10000;
}
}
} else if( type && IS_LABEL_SH_OR_PIN(type) ) {
entry=bus_hilight_lookup( xctx->inst[i].lab, 0, XLOOKUP);
} else if(type && xctx->inst[i].node && IS_LABEL_SH_OR_PIN(type) ) {
entry=bus_hilight_lookup( xctx->inst[i].node[0], 0, XLOOKUP);
if(entry && set) xctx->inst[i].color = entry->value;
else if(!entry && clear) xctx->inst[i].color = -10000;
}
@ -1334,8 +1334,8 @@ void select_hilight_net(void)
}
}
}
} else if( type && IS_LABEL_SH_OR_PIN(type) ) {
entry=bus_hilight_lookup(xctx->inst[i].lab , 0, XLOOKUP);
} else if( type && xctx->inst[i].node && IS_LABEL_SH_OR_PIN(type) ) {
entry=bus_hilight_lookup(xctx->inst[i].node[0], 0, XLOOKUP);
if(entry) xctx->inst[i].sel = SELECTED;
}
}

View File

@ -2156,8 +2156,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
hide_symbols=s;
}
else if(!strcmp(argv[2],"show_pin_net_names")) {
int s = atoi(argv[3]);
int i, s = atoi(argv[3]);
show_pin_net_names=s;
for(i = 0; i < xctx->instances; i++) {
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
}
}
else if(!strcmp(argv[2],"netlist_name")) {
my_strncpy(xctx->netlist_name, argv[3], S(xctx->netlist_name));