if autoload is set in graph and a filename is given (rawfile graph attr) load raw file immediately when drawing graph. Don`t wait for user to load an intiial raw file to trigger auto loading

This commit is contained in:
stefan schippers 2024-09-08 13:43:29 +02:00
parent e5015488f3
commit ad96e222f1
8 changed files with 80 additions and 65 deletions

View File

@ -3679,7 +3679,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
clear_cairo_surface(xctx->cairo_ctx, gr->sx1, gr->sy1, sw, sh);
#endif
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload",0), "1");
if(autoload == 0) autoload = 2;
if(autoload == 0) autoload = 2; /* 2: switch */
/* graph box, gridlines and axes */
draw_graph_grid(gr, ct);
/* get data to plot */
@ -3714,8 +3714,9 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
measure_p = -1;
measure_x = 0.0;
measure_prev_x = 0.0;
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) {
if(extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type, -1.0, -1.0) == 0) {
if(custom_rawfile[0]) {
if(extra_rawfile(autoload, custom_rawfile, sim_type[0] ? sim_type :
(xctx->raw && xctx->raw->sim_type ? xctx->raw->sim_type : NULL), -1.0, -1.0) == 0) {
continue;
}
}

View File

@ -1074,6 +1074,9 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
int i;
int ret = 1;
char f[PATH_MAX];
if(type && !type[0]) type = NULL; /* empty string as type will be considered NULL */
dbg(1, "extra_rawfile(): what=%d, file=%s, type=%s\n",
what, file ? file : "NULL", type ? type : "NULL");
if(what == 0) return 0;
@ -1104,7 +1107,7 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
xctx->extra_raw_n++;
} else {
ret = 0; /* not found so did not switch */
dbg(0, "extra_rawfile() read: %s not found or no %s analysis\n", f, type);
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type);
xctx->raw = save; /* restore */
xctx->extra_prev_idx = xctx->extra_idx;
}
@ -1135,14 +1138,15 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
xctx->raw = NULL;
read_ret = raw_read(f, &xctx->raw, type, sweep1, sweep2);
if(read_ret) {
dbg(1, "extra_rawfile(): read %s %s, switch to it. raw->sim_type=%s\n", f, type, xctx->raw->sim_type);
dbg(1, "extra_rawfile(): read %s %s, switch to it. raw->sim_type=%s\n", f,
type ? type : "NULL", xctx->raw->sim_type ? xctx->raw->sim_type : "NULL");
xctx->extra_raw_arr[xctx->extra_raw_n] = xctx->raw;
xctx->extra_prev_idx = xctx->extra_idx;
xctx->extra_idx = xctx->extra_raw_n;
xctx->extra_raw_n++;
} else {
ret = 0; /* not found so did not switch */
dbg(0, "extra_rawfile() read: %s not found or no %s analysis\n", f, type ? type : "<unspecified>");
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type ? type : "<unspecified>");
xctx->raw = save; /* restore */
xctx->extra_prev_idx = xctx->extra_idx;
}

View File

@ -328,7 +328,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
/* clear all raw files */
extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 1); */
draw();
raw_read(f, &xctx->raw, "op", -1.0, -1.0);
if(level >= 0) {
xctx->raw->level = level;

View File

@ -2565,8 +2565,8 @@ proc graph_update_nodelist {} {
proc graph_fill_listbox {} {
global graph_selected
if { [xschem raw loaded] == -1 } return
set retval [.graphdialog.center.left.search get]
set pattern [.graphdialog.center.left.search get]
set retval {}
set autoload [uplevel #0 {subst [xschem getprop rect 2 $graph_selected autoload 2]}]
set rawfile [uplevel #0 {subst [xschem getprop rect 2 $graph_selected rawfile 2]}]
set sim_type [uplevel #0 {subst [xschem getprop rect 2 $graph_selected sim_type 2]}]
@ -2579,14 +2579,12 @@ proc graph_fill_listbox {} {
set res [xschem raw $autoload $rawfile $sim_type]
}
if {$res} {
set retval [graph_get_signal_list [xschem raw_query list] $retval]
set retval [graph_get_signal_list [xschem raw_query list] $pattern]
xschem raw switch_back
} else {
set retval {}
}
# puts "switch back"
} else {
set retval [graph_get_signal_list [xschem raw_query list] $retval]
} elseif {[xschem raw loaded] != -1} {
set retval [graph_get_signal_list [xschem raw_query list] $pattern]
}
.graphdialog.center.left.list1 delete 0 end
eval .graphdialog.center.left.list1 insert 0 $retval
@ -2766,9 +2764,7 @@ proc graph_edit_properties {n} {
if { [info tclversion] > 8.4} {
bind .graphdialog.center.right.list <<ComboboxSelected>> {
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
if {[raw_is_loaded [.graphdialog.center.right.rawentry get] [.graphdialog.center.right.list get]]} {
graph_fill_listbox
}
graph_fill_listbox
}
if { [xschem getprop rect 2 $graph_selected sim_type 2] ne {}} {
.graphdialog.center.right.list set [xschem getprop rect 2 $graph_selected sim_type 2]
@ -2786,9 +2782,7 @@ proc graph_edit_properties {n} {
bind .graphdialog.center.right.list <KeyRelease> {
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
if {[raw_is_loaded [.graphdialog.center.right.rawentry get] [.graphdialog.center.right.list get]]} {
graph_fill_listbox
}
graph_fill_listbox
}
@ -2799,18 +2793,14 @@ proc graph_edit_properties {n} {
.graphdialog.center.right.rawentry insert 0 [string map [list $netlist_dir {$netlist_dir}] [select_raw]]
xschem setprop rect 2 $graph_selected rawfile [.graphdialog.center.right.rawentry get] fast
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
if {[raw_is_loaded [.graphdialog.center.right.rawentry get] [.graphdialog.center.right.list get]]} {
graph_fill_listbox
}
graph_fill_listbox
}
bind .graphdialog.center.right.rawentry <KeyRelease> {
xschem setprop rect 2 $graph_selected rawfile [.graphdialog.center.right.rawentry get] fast
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
if {[raw_is_loaded [.graphdialog.center.right.rawentry get] [.graphdialog.center.right.list get]]} {
graph_fill_listbox
}
graph_fill_listbox
}
.graphdialog.center.right.rawentry insert 0 [xschem getprop rect 2 $graph_selected rawfile 2]
.graphdialog.center.right.rawentry xview moveto 1
@ -3168,7 +3158,6 @@ proc graph_edit_properties {n} {
wm protocol .graphdialog WM_DELETE_WINDOW {
.graphdialog.bottom.cancel invoke
}
# fill data in left listbox
graph_fill_listbox

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.5 file_version=1.2
v {xschem version=3.4.6RC file_version=1.2
*
* This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.5 file_version=1.2
v {xschem version=3.4.6RC file_version=1.2
*
* This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -41,7 +41,7 @@ ylabmag=1.0
node="\\"dB(out) comp; out db20() %0\\"
\\"dB(out) uncomp; out db20() %1\\"
\\"0 dB; 0"
color="4 5 8"
color="4 5 8 4 4"
dataset=-1
unitx=1
logx=1
@ -49,7 +49,7 @@ logy=0
divx=10
rainbow=0
lock=0
autoload=1
autoload=0
sim_type=ac}
B 2 1340 -1200 2310 -670 {flags=graph,unlocked
y1=-38
@ -76,7 +76,7 @@ divx=10
rainbow=0
lock=0
dataset=-1
autoload=1
autoload=0
sim_type=ac}
B 2 2330 -725 3150 -10 {flags=graph,unlocked
y1=-5.4178481
@ -104,9 +104,9 @@ logy=0
divx=10
sweep=re_out
divy=10
lock=0
lock=1
rainbow=0
autoload=1
autoload=0
sim_type=ac}
B 2 2330 -1460 3150 -745 {flags=graph,unlocked
y1=-9400
@ -116,8 +116,8 @@ ypos2=2
subdivy=1
unity=1
x1=-323.03335
x2=18222.877
x1=-323.03362
x2=18222.875
subdivx=1
xlabmag=1.4
@ -134,10 +134,10 @@ logy=0
divx=10
sweep=re_out
divy=10
lock=0
lock=1
rainbow=0
dataset=1
autoload=1
autoload=0
sim_type=ac}
B 4 930 -440 1050 -260 {fill=0 dash=6}
A 6 2450 -1100 40 0 360 {}
@ -156,7 +156,8 @@ Unstable} 1950 -1280 0 0 0.6 0.6 { layer=5}
T {Compensated
Stable} 1480 -1280 0 0 0.6 0.6 { layer=4}
T {Some graphs are locked (lock=1)
Double click and set lock=0 to edit} 1370 -1410 0 0 0.8 0.8 {}
Double click close to the inner border
and set lock=0 to edit} 1370 -1450 0 0 0.8 0.8 {}
T {AC signal
gen} 530 -770 0 0 0.4 0.4 {}
N 30 -310 30 -280 {
@ -349,7 +350,7 @@ C {lab_pin.sym} 500 -430 0 0 {name=p12 lab=G}
C {launcher.sym} 700 -60 0 0 {name=h1
descr=Backannotate
tclcommand="
xschem raw_read $netlist_dir/test_nyquist.raw ac
xschem raw read $netlist_dir/test_nyquist.raw ac
xschem raw add re_out \{out ph(out) re() -1 *\}
xschem raw add im_out \{out ph(out) im() -1 *\}
xschem raw read $netlist_dir/test_nyquist.raw op

View File

@ -1,4 +1,4 @@
v {xschem version=3.4.5 file_version=1.2
v {xschem version=3.4.6RC file_version=1.2
*
* This file is part of XSCHEM,
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
@ -88,22 +88,28 @@ y1 = -0.00068
y2 = 22
divy = 6
subdivy=1
x1=5e-10
x2=0.001
x1=2.9358714e-05
x2=0.0010293582
divx=8
node="PANEL
LED" unitx=m
color="7 4"
jpeg_quality=30
linewidth_mult=2.0
hilight_wave=-1}
hilight_wave=-1
autoload=1
rawfile=$netlist_dir/solar_panel.raw
sim_type=tran}
B 2 1260 -390 1680 -220 {flags=graph
y1 = -0.0012
y2 = 6.8
divy = 4
subdivy=1
x1=5e-10
x2=0.001
x1=2.9358714e-05
x2=0.0010293582
divx=8
unitx=m
color="7 4 6"
@ -111,14 +117,17 @@ node="i(Vpanel)
i(Vled)
\\"R.Avg. I(VPANEL); i(VPANEL) 20u ravg()\\""
jpeg_quality=30
linewidth_mult=2.0}
linewidth_mult=2.0
autoload=1
rawfile=$netlist_dir/solar_panel.raw
sim_type=tran}
B 2 1260 -750 1680 -560 {flags=graph
y1 = -2.7e-05
y2 = 100
divy = 5
subdivy=1
x1=5e-10
x2=0.001
x1=2.9358714e-05
x2=0.0010293582
divx=9
unitx=m subdivx=4
@ -129,14 +138,17 @@ node="\\"Panel power; i(Vpanel) v(PANEL) *\\"
\\"SUN \\\\%; SUN 100 *\\""
hilight_wave=-1
jpeg_quality=30
linewidth_mult=2.0}
linewidth_mult=2.0
autoload=1
rawfile=$netlist_dir/solar_panel.raw
sim_type=tran}
B 2 1260 -940 1680 -750 {flags=graph
y1 = 0
y2 = 1
divy = 5
subdivy=1
x1=5e-10
x2=0.001
x1=2.9358714e-05
x2=0.0010293582
divx=9
unitx=u subdivx=4
@ -149,14 +161,16 @@ ypos1=0.00261891
ypos2=0.51596
jpeg_quality=30
linewidth_mult=2.0
}
autoload=1
rawfile=$netlist_dir/solar_panel.raw
sim_type=tran}
B 2 1260 -1140 1680 -950 {flags=graph
y1 = 0
y2 = 1
divy = 5
subdivy=1
x1=5e-10
x2=0.001
x1=2.9358714e-05
x2=0.0010293582
divx=9
unitx=u subdivx=4
@ -169,7 +183,10 @@ ypos2=0.51596
color=8
node="\\"CTRL1 Duty cycle; CTRL1 20u ravg()\\""
jpeg_quality=30
linewidth_mult=2.0}
linewidth_mult=2.0
autoload=1
rawfile=$netlist_dir/solar_panel.raw
sim_type=tran}
B 18 65 -960 320 -775 {}
A 5 320 -960 5.590169943749475 243.434948822922 360 {fill=true}
P 7 6 395 -775 340 -931.25 335 -945 322.5 -960 310 -965 65 -975 {}