Improve send nets to graph. do not refuse to send top level port signals, allow to send bussed signals even if graphdialog widget is not shown (proc graph_add_nodes_from_list)

This commit is contained in:
stefan schippers 2023-09-09 10:26:58 +02:00
parent ff1216e142
commit 02dddc90ef
2 changed files with 42 additions and 23 deletions

View File

@ -1005,7 +1005,10 @@ static void send_net_to_graph(char **s, int simtype, const char *node)
tok = node;
node_entry = bus_node_hash_lookup(tok, "", XLOOKUP, 0, "", "", "", "");
if(tok[0] == '#') tok++;
if(node_entry && (node_entry->d.port == 0 || !strcmp(xctx->sch_path[xctx->currsch], ".") )) {
if(node_entry && (node_entry->d.port == 0 ||
/* !strcmp(xctx->sch_path[xctx->currsch], ".") */
xctx->currsch == xctx->graph_raw_level
)) {
char *t=NULL, *p=NULL;
char *path;
int start_level;
@ -1733,6 +1736,8 @@ void hilight_net(int viewer)
if(!bus_hilight_hash_lookup(xctx->wire[n].node, xctx->hilight_color, XINSERT_NOREPLACE)) {
if(viewer == XSCHEM_GRAPH) {
send_net_to_graph(&s, sim_is_xyce, xctx->wire[n].node);
dbg(1, "1 hilight_net(): send_net_to_graph() sets s=%s\n", s);
dbg(1, "hilight_net(): wire[n].node=%s\n", xctx->wire[n].node);
} else if(viewer == GAW) send_net_to_gaw(sim_is_xyce, xctx->wire[n].node);
else if(viewer == BESPICE) send_net_to_bespice(sim_is_xyce, xctx->wire[n].node);
if(incr_hi) incr_hilight_color();
@ -1743,7 +1748,11 @@ void hilight_net(int viewer)
if( type && xctx->inst[n].node && IS_LABEL_SH_OR_PIN(type) ) { /* instance must have a pin! */
/* sets xctx->hilight_nets=1 */
if(!bus_hilight_hash_lookup(xctx->inst[n].node[0], xctx->hilight_color, XINSERT_NOREPLACE)) {
if(viewer == XSCHEM_GRAPH) send_net_to_graph(&s, sim_is_xyce, xctx->inst[n].node[0]);
if(viewer == XSCHEM_GRAPH) {
send_net_to_graph(&s, sim_is_xyce, xctx->inst[n].node[0]);
dbg(1, "2 hilight_net(): send_net_to_graph() sets s=%s\n", s);
dbg(1, "hilight_net(): inst[n].node[0]=%s\n", xctx->inst[n].node[0]);
}
else if(viewer == GAW) send_net_to_gaw(sim_is_xyce, xctx->inst[n].node[0]);
else if(viewer == BESPICE) send_net_to_bespice(sim_is_xyce, xctx->inst[n].node[0]);
if(incr_hi) incr_hilight_color();
@ -1754,7 +1763,7 @@ void hilight_net(int viewer)
xctx->inst[n].color = xctx->hilight_color;
inst_hilight_hash_lookup(n, xctx->hilight_color, XINSERT_NOREPLACE);
if(type && (!strcmp(type, "ammeter") || !strcmp(type, "vsource")) ) {
if(viewer == XSCHEM_GRAPH) send_current_to_graph(&s, sim_is_xyce, xctx->inst[n].instname);
if(viewer == XSCHEM_GRAPH) send_current_to_graph(&s, sim_is_xyce, xctx->inst[n].instname);
else if(viewer == GAW) send_current_to_gaw(sim_is_xyce, xctx->inst[n].instname);
else if(viewer == BESPICE) send_current_to_bespice(sim_is_xyce, xctx->inst[n].instname);
}

View File

@ -1698,14 +1698,13 @@ proc graph_edit_wave {n n_wave} {
# add nodes from provided list of {node color} ....
proc graph_add_nodes_from_list {nodelist} {
global graph_bus graph_selected graph_schname
set sel {}
if {$graph_bus} {
set sep ,
} else {
set sep \n
}
if { [winfo exists .graphdialog] } {
set sel {}
set current_node_list [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}]
set col [xschem getprop rect 2 $graph_selected color]
if {[string length $current_node_list] > 0 && ![regexp "\n$" $current_node_list]} {
@ -1740,26 +1739,37 @@ proc graph_add_nodes_from_list {nodelist} {
}
}
} else {
set graph_bus 0
set nn {}
set cc {}
foreach {n c} $nodelist {
if { $nn ne {}} {append nn \n}
if { $cc ne {}} {append cc " "}
append nn $n
append cc $c
set sel {}
set change_done 0
set first 0
set col [xschem getprop rect 2 [xschem get graph_lastsel] color]
set nnn [xschem getprop rect 2 [xschem get graph_lastsel] node]
foreach {i c} $nodelist {
if {$sel ne {}} {append sel $sep}
if {!$first || !$graph_bus } {
regsub {\[.*} $i {} busname
lappend col $c
}
append sel $i
set change_done 1
set first 1
}
if {$change_done && $graph_bus} {
set sel "[string toupper $busname],${sel}\n"
} else {
set sel "${sel}\n"
}
set nnn [xschem getprop rect 2 [xschem get graph_lastsel] node]
set ccc [xschem getprop rect 2 [xschem get graph_lastsel] color]
if { $nnn ne {}} {append nnn "\n"}
if { $ccc ne {}} {append ccc " "}
append nnn $nn
append ccc $cc
regsub -all {\\?(["\\])} $nnn {\\\1} node_quoted ;#"4vim
xschem setprop rect 2 [xschem get graph_lastsel] color $ccc fastundo
xschem setprop rect 2 [xschem get graph_lastsel] node $node_quoted fast
xschem draw_graph [xschem get graph_lastsel]
if {$change_done} {
xschem setprop rect 2 [xschem get graph_lastsel] color $col fastundo
if {[string length $nnn] > 0 && ![regexp "\n$" $nnn]} {
append nnn "\n"
}
append nnn $sel
regsub -all {\\?(["\\])} $nnn {\\\1} node_quoted ;#"4vim
xschem setprop rect 2 [xschem get graph_lastsel] node $node_quoted fast
xschem draw_graph [xschem get graph_lastsel]
}
}
}