From 41c46bd84b45efea8e1429392ed3062303f0c559 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Fri, 18 Dec 2020 19:43:45 +0100 Subject: [PATCH] fix hilights when descending / going back --- src/actions.c | 36 +++++++++++++++++++++++++++++++++++- src/hilight.c | 27 +++++++++++++++++++++++++++ src/xschem.h | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/actions.c b/src/actions.c index a3e6d7ec..cfbe1891 100644 --- a/src/actions.c +++ b/src/actions.c @@ -996,7 +996,11 @@ void descend_schematic(int instnumber) const char *str; char filename[PATH_MAX]; int inst_mult, inst_number; - int save_ok = 0; + int i, save_ok = 0; + int hilight_connected_inst; + char *type; + struct hilight_hashentry *entry; + rebuild_selected_array(); if(xctx->lastsel !=1 || xctx->sel_array[0].type!=ELEMENT) @@ -1102,6 +1106,36 @@ void descend_schematic(int instnumber) if(xctx->hilight_nets) { prepare_netlist_structs(0); + + + for(i = 0; i < xctx->instances; i++) { + type = (xctx->inst[i].ptr+ xctx->sym)->type; + hilight_connected_inst = + !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || + !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); + if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { + int rects, j; + if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { + dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); + for(j=0;jinst[i].node && xctx->inst[i].node[j]) { + entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); + if(entry) { + xctx->inst[i].flags |= 4; + xctx->inst[i].color=get_color(entry->value); + break; + } + } + } + } + } else if( type && IS_LABEL_SH_OR_PIN(type) ) { + entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); + if(entry) xctx->inst[i].color=get_color(entry->value); + } + } + + + if(enable_drill) drill_hilight(); } dbg(1, "descend_schematic(): before zoom(): prep_hash_inst=%d\n", xctx->prep_hash_inst); diff --git a/src/hilight.c b/src/hilight.c index 73047cc2..11163ef1 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -343,9 +343,11 @@ void hilight_net_pin_mismatches(void) void hilight_parent_pins(void) { + int hilight_connected_inst; int rects, i, j, k; struct hilight_hashentry *entry; const char *pin_name; + char *type; char *pin_node = NULL; char *net_node=NULL; int mult, net_mult, inst_number; @@ -385,6 +387,31 @@ void hilight_parent_pins(void) } } } + for(i = 0; i < xctx->instances; i++) { + type = (xctx->inst[i].ptr+ xctx->sym)->type; + hilight_connected_inst = + !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || + !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); + if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { + int rects, j; + if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { + dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); + for(j=0;jinst[i].node && xctx->inst[i].node[j]) { + entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); + if(entry) { + xctx->inst[i].flags |= 4; + xctx->inst[i].color=get_color(entry->value); + break; + } + } + } + } + } else if( type && IS_LABEL_SH_OR_PIN(type) ) { + entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); + if(entry) xctx->inst[i].color=get_color(entry->value); + } + } my_free(767, &pin_node); my_free(768, &net_node); } diff --git a/src/xschem.h b/src/xschem.h index 93cae0da..b01bab92 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -842,6 +842,7 @@ extern int text_bbox(const char * str,double xscale, double yscale, double *rx2, double *ry2); +extern int get_color(int value); extern void hash_inst(int what, int n); extern void hash_inst_pin(int what, int i, int j); extern void del_inst_table(void);