send selected nets to last selected graph if graph configure dialog not open

This commit is contained in:
Stefan Frederik 2022-01-29 12:27:54 +01:00
parent 552bfcac4e
commit 4ec5d2ce9e
7 changed files with 71 additions and 35 deletions

View File

@ -630,6 +630,7 @@ int set_rect_extraptr(int what, xRect *drptr)
void clear_drawing(void)
{
int i,j;
xctx->graph_lastsel = -1;
del_inst_table();
del_wire_table();
my_free(685, &xctx->schtedaxprop);

View File

@ -1725,7 +1725,11 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
tcleval("winfo exists .graphdialog");
if(tclresult()[0] == '1') tool = XSCHEM_GRAPH;
else if(xctx->graph_lastsel >=0 &&
xctx->rects[2] > xctx->graph_lastsel &&
xctx->rect[2][xctx->graph_lastsel].flags & 1) {
tool = XSCHEM_GRAPH;
}
tcleval("info exists sim");
if(tclresult()[0] == '1') exists = 1;
xctx->enable_drill = 0;

View File

@ -840,17 +840,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_SetResult(interp, xctx->current_win_path, TCL_VOLATILE);
}
else if(!strcmp(argv[2],"currsch")) {
char s[30]; /* overflow safe 20161122 */
char s[30];
my_snprintf(s, S(s), "%d",xctx->currsch);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
else if(!strcmp(argv[2],"debug_var")) {
char s[30]; /* overflow safe 20161122 */
char s[30];
my_snprintf(s, S(s), "%d",debug_var);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
else if(!strcmp(argv[2],"draw_window")) {
char s[30]; /* overflow safe 20161122 */
char s[30];
my_snprintf(s, S(s), "%d",xctx->draw_window);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
@ -860,8 +860,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else
Tcl_SetResult(interp, "0",TCL_STATIC);
}
else if(!strcmp(argv[2],"graph_lastsel")) {
char s[30];
my_snprintf(s, S(s), "%d",xctx->graph_lastsel);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
else if(!strcmp(argv[2],"gridlayer")) {
char s[30]; /* overflow safe 20161122 */
char s[30];
my_snprintf(s, S(s), "%d",GRIDLAYER);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
@ -872,7 +877,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_SetResult(interp, "0",TCL_STATIC);
}
else if(!strcmp(argv[2],"instances")) {
char s[30]; /* overflow safe 20161122 */
char s[30];
my_snprintf(s, S(s), "%d",xctx->instances);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}

View File

@ -826,6 +826,7 @@ void select_box(int c, int i, unsigned short select_mode, int fast)
if(select_mode) {
if(select_mode==SELECTED) {
xctx->rect[c][i].sel = select_mode;
if(xctx->rect[c][i].flags & 1) xctx->graph_lastsel = i; /* remember last selected graph */
} else {
xctx->rect[c][i].sel |= select_mode;
}

View File

@ -446,6 +446,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->graph_top = 0;
xctx->graph_bottom = 0;
xctx->graph_left = 0;
xctx->graph_lastsel = -1;
xctx->graph_struct.hilight_wave[0] = -1; /* graph index of hilight wave */
xctx->graph_struct.hilight_wave[1] = -1; /* index of wave */
xctx->raw_schname = NULL;

View File

@ -895,6 +895,7 @@ typedef struct {
int graph_top; /* regions of graph where mouse events occur */
int graph_bottom;
int graph_left;
int graph_lastsel; /* last graph that was clicked (selected) */
Int_hashentry **raw_table;
char *raw_schname;
/* */

View File

@ -1349,37 +1349,60 @@ proc graph_add_nodes_from_list {nodelist} {
} else {
set sep \n
}
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]} {
.graphdialog.center.right.text1 insert end \n
}
set change_done 0
set first 0
foreach {i c} $nodelist {
if {$sel ne {}} {append sel $sep}
if {!$first || !$graph_bus } {
regsub {\[.*} $i {} busname
lappend col $c
if { [winfo exists .graphdialog] } {
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]} {
.graphdialog.center.right.text1 insert end \n
}
set change_done 0
set first 0
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"
}
if {$change_done} {
.graphdialog.center.right.text1 insert end $sel
if { [xschem get schname] eq $graph_schname } {
set node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
xschem setprop rect 2 $graph_selected color $col fastundo
graph_update_nodelist
xschem setprop rect 2 $graph_selected node $node fast
xschem draw_graph $graph_selected
}
}
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"
}
if {$change_done} {
.graphdialog.center.right.text1 insert end $sel
if { [xschem get schname] eq $graph_schname } {
set node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
xschem setprop rect 2 $graph_selected color $col fastundo
graph_update_nodelist
xschem setprop rect 2 $graph_selected node $node fast
xschem draw_graph $graph_selected
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 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
xschem setprop rect 2 [xschem get graph_lastsel] node $nnn
xschem setprop rect 2 [xschem get graph_lastsel] color $ccc
puts $nodelist
}
}
@ -1520,7 +1543,6 @@ proc graph_edit_properties {n} {
set graph_selected $n
set graph_schname [xschem get schname]
set_ne graph_sel_color 4
set_ne graph_bus 0
set_ne graph_sort 0
set graph_digital 0
if {[xschem getprop rect 2 $n digital] == 1} {set graph_digital 1}
@ -5432,6 +5454,7 @@ set_ne to_png {gm convert}
set_ne to_pdf {ps2pdf}
# selected graph user is editing attributes with graph GUI
set_ne graph_bus 0
set_ne graph_selected {}
set_ne graph_schname {}
set_ne graph_unitx 1