graphs: add xmag and ymag entry boxes for custom magnification factor for x/y axis labels, fix current_dirname handling when netlisting hierarchical http(s) designs. The goal is to allow netlisting remote designs seamlessly

This commit is contained in:
stefan schippers 2023-05-20 23:21:43 +02:00
parent 616364106f
commit c2e5c61b35
9 changed files with 108 additions and 40 deletions

View File

@ -1544,6 +1544,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst)
if(is_from_web(xctx->current_dirname)) {
web_url = 1;
}
dbg(1, "get_sch_from_sym(): current_dirname= %s\n", xctx->current_dirname);
dbg(1, "get_sch_from_sym(): symbol %s inst=%d web_url=%d\n", sym->name, inst, web_url);
if(inst >= 0) my_strdup(_ALLOC_ID_, &str_tmp, get_tok_value(xctx->inst[inst].prop_ptr, "schematic", 2));
if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 2));

View File

@ -2328,6 +2328,7 @@ void setup_graph_data(int i, int skip, Graph_ctx *gr)
dbg(1, "setup_graph_data: i=%d\n", i);
/* default values */
gr->magx = gr->magy = 1.0;
gr->divx = gr->divy = 5;
gr->subdivx = gr->subdivy = 0;
gr->logx = gr->logy = 0;
@ -2390,6 +2391,10 @@ void setup_graph_data(int i, int skip, Graph_ctx *gr)
gr->unity_suffix = val[0];
gr->unity = get_unit(val);
}
val = get_tok_value(r->prop_ptr,"xlabmag",0);
if(val[0]) gr->magx = atof(val);
val = get_tok_value(r->prop_ptr,"ylabmag",0);
if(val[0]) gr->magy = atof(val);
val = get_tok_value(r->prop_ptr,"subdivx",0);
if(val[0]) gr->subdivx = atoi(val);
val = get_tok_value(r->prop_ptr,"subdivy",0);
@ -2461,10 +2466,12 @@ void setup_graph_data(int i, int skip, Graph_ctx *gr)
if(tmp < gr->txtsizey) gr->txtsizey = tmp;
tmp = gr->marginy * 0.02;
if(tmp < gr->txtsizey) gr->txtsizey = tmp;
gr->txtsizey *= gr->magy;
gr->txtsizex = gr->w / gr->divx * 0.0033;
tmp = gr->marginy * 0.0063;
if(tmp < gr->txtsizex) gr->txtsizex = tmp;
gr->txtsizex *= gr->magx;
/* cache coefficients for faster graph --> xschem coord transformations */
gr->cx = gr->w / gr->gw;

View File

@ -189,6 +189,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
"x2=10e-6\n"
"divx=5\n"
"subdivx=1\n"
"xlabmag=1.0\n"
"ylabmag=1.0\n"
"node=\"\"\n"
"color=\"\"\n"
"dataset=-1\n"

View File

@ -387,6 +387,10 @@ int global_spice_netlist(int global) /* netlister driver */
if(global)
{
int saved_hilight_nets = xctx->hilight_nets;
int web_url = is_from_web(xctx->current_dirname);
char *current_dirname_save = NULL;
my_strdup2(_ALLOC_ID_, &current_dirname_save, xctx->current_dirname);
unselect_all(1);
remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */
/* reload data without popping undo stack, this populates embedded symbols if any */
@ -407,8 +411,10 @@ int global_spice_netlist(int global) /* netlister driver */
my_strdup(_ALLOC_ID_, &abs_path, abs_sym_path(xctx->sym[i].name, ""));
if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(1, abs_path))
{
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(!web_url) {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(_ALLOC_ID_, &subckt_name, get_cell(xctx->sym[i].name, 0));
dbg(1, "global_spice_netlist(): subckt_name=%s\n", subckt_name);
@ -434,14 +440,19 @@ int global_spice_netlist(int global) /* netlister driver */
unselect_all(1);
dbg(1, "global_spice_netlist(): invoking pop_undo(0, 0)\n");
xctx->pop_undo(4, 0);
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(web_url) {
my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname));
} else {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name));
dbg(1, "spice_netlist(): invoke prepare_netlist_structs for %s\n", xctx->current_name);
err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */
/* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */
err |= sym_vs_sch_pins();
if(!xctx->hilight_nets) xctx->hilight_nets = saved_hilight_nets;
my_free(_ALLOC_ID_, &current_dirname_save);
}
/* restore hilight flags from errors found analyzing top level before descending hierarchy */
for(i=0;i<xctx->instances; ++i) if(!xctx->inst[i].color) xctx->inst[i].color = stored_flags[i];

View File

@ -189,6 +189,9 @@ int global_tedax_netlist(int global) /* netlister driver */
if(global) /* was if(global) ... 20180901 no hierarchical tEDAx netlist for now */
{
int saved_hilight_nets = xctx->hilight_nets;
int web_url = is_from_web(xctx->current_dirname);
char *current_dirname_save = NULL;
unselect_all(1);
remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */
/* reload data without popping undo stack, this populates embedded symbols if any */
@ -208,8 +211,10 @@ int global_tedax_netlist(int global) /* netlister driver */
my_strdup2(_ALLOC_ID_, &abs_path, abs_sym_path(tcl_hook2(xctx->sym[i].name), ""));
if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(1, abs_path))
{
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(!web_url) {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(_ALLOC_ID_, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (str_hash_lookup(&subckt_table, subckt_name, "", XLOOKUP)==NULL)
@ -229,14 +234,19 @@ int global_tedax_netlist(int global) /* netlister driver */
xctx->currsch--;
unselect_all(1);
xctx->pop_undo(4, 0);
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(web_url) {
my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname));
} else {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name));
err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */
/* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */
err |= sym_vs_sch_pins();
if(!xctx->hilight_nets) xctx->hilight_nets = saved_hilight_nets;
my_free(_ALLOC_ID_, &current_dirname_save);
}
/* restore hilight flags from errors found analyzing top level before descending hierarchy */
for(i=0;i<xctx->instances; ++i) if(!xctx->inst[i].color) xctx->inst[i].color = stored_flags[i];

View File

@ -328,6 +328,9 @@ int global_verilog_netlist(int global) /* netlister driver */
if(global)
{
int saved_hilight_nets = xctx->hilight_nets;
int web_url = is_from_web(xctx->current_dirname);
char *current_dirname_save = NULL;
unselect_all(1);
remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */
/* reload data without popping undo stack, this populates embedded symbols if any */
@ -347,8 +350,10 @@ int global_verilog_netlist(int global) /* netlister driver */
if(!xctx->sym[i].type) continue;
my_strdup2(_ALLOC_ID_, &abs_path, abs_sym_path(tcl_hook2(xctx->sym[i].name), ""));
if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(1, abs_path)) {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(!web_url) {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(_ALLOC_ID_, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (str_hash_lookup(&subckt_table, subckt_name, "", XLOOKUP)==NULL)
@ -372,13 +377,18 @@ int global_verilog_netlist(int global) /* netlister driver */
xctx->currsch--;
unselect_all(1);
xctx->pop_undo(4, 0);
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(web_url) {
my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname));
} else {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name));
err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */
/* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */
err |= sym_vs_sch_pins();
if(!xctx->hilight_nets) xctx->hilight_nets = saved_hilight_nets;
my_free(_ALLOC_ID_, &current_dirname_save);
}
/* restore hilight flags from errors found analyzing top level before descending hierarchy */
for(i=0;i<xctx->instances; ++i) if(!xctx->inst[i].color) xctx->inst[i].color = stored_flags[i];

View File

@ -414,6 +414,9 @@ int global_vhdl_netlist(int global) /* netlister driver */
if(global)
{
int saved_hilight_nets = xctx->hilight_nets;
int web_url = is_from_web(xctx->current_dirname);
char *current_dirname_save = NULL;
str_hash_init(&subckt_table, HASHSIZE);
unselect_all(1);
remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */
@ -435,8 +438,10 @@ int global_vhdl_netlist(int global) /* netlister driver */
my_strdup(_ALLOC_ID_, &abs_path, abs_sym_path(xctx->sym[i].name, ""));
if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(1, abs_path))
{
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(!web_url) {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(_ALLOC_ID_, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (str_hash_lookup(&subckt_table, subckt_name, "", XLOOKUP)==NULL)
@ -460,13 +465,18 @@ int global_vhdl_netlist(int global) /* netlister driver */
xctx->currsch--;
unselect_all(1);
xctx->pop_undo(4, 0);
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
if(web_url) {
my_strncpy(xctx->current_dirname, current_dirname_save, S(xctx->current_dirname));
} else {
tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL);
my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname));
}
my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name));
err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */
/* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */
err |= sym_vs_sch_pins();
if(!xctx->hilight_nets) xctx->hilight_nets = saved_hilight_nets;
my_free(_ALLOC_ID_, &current_dirname_save);
}
/* restore hilight flags from errors found analyzing top level before descending hierarchy */
for(i=0;i<xctx->instances; ++i) if(!xctx->inst[i].color) xctx->inst[i].color = stored_flags[i];

View File

@ -785,12 +785,10 @@ typedef struct {
/* direct graph->screen transform */
double scx, sdx, scy, sdy;
double dscy, dsdy;
int divx;
int divy;
int subdivx;
int subdivy;
double unitx;
double unity;
int divx, divy;
int subdivx, subdivy;
double magx, magy;
double unitx, unity;
int unitx_suffix; /* 'n' or 'u' or 'M' or 'k' ... */
int unity_suffix;
double txtsizelab, digtxtsizelab, txtsizey, txtsizex;

View File

@ -2006,8 +2006,8 @@ proc graph_edit_properties {n} {
update_graph_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
xschem setprop rect 2 $graph_selected x1 [.graphdialog.top3.xmin get] fast
xschem setprop rect 2 $graph_selected x2 [.graphdialog.top3.xmax get] fast
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.min get] fast
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.max get] fast
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.ymin get] fast
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.ymax get] fast
if {$graph_unlocked} {
xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast
@ -2029,8 +2029,8 @@ proc graph_edit_properties {n} {
update_graph_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
xschem setprop rect 2 $graph_selected x1 [.graphdialog.top3.xmin get] fast
xschem setprop rect 2 $graph_selected x2 [.graphdialog.top3.xmax get] fast
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.min get] fast
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.max get] fast
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.ymin get] fast
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.ymax get] fast
if {$graph_unlocked} {
xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast
} else {
@ -2182,20 +2182,35 @@ proc graph_edit_properties {n} {
}
label .graphdialog.top3.labmin -text { Y min:}
entry .graphdialog.top3.min -width 7
bind .graphdialog.top3.min <KeyRelease> {
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.min get]
label .graphdialog.top3.ylabmin -text { Y min:}
entry .graphdialog.top3.ymin -width 7
bind .graphdialog.top3.ymin <KeyRelease> {
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.ymin get]
xschem draw_graph $graph_selected
}
label .graphdialog.top3.labmax -text { Y max:}
entry .graphdialog.top3.max -width 7
bind .graphdialog.top3.max <KeyRelease> {
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.max get]
label .graphdialog.top3.ylabmax -text { Y max:}
entry .graphdialog.top3.ymax -width 7
bind .graphdialog.top3.ymax <KeyRelease> {
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.ymax get]
xschem draw_graph $graph_selected
}
label .graphdialog.top3.xlabmag -text { X/Y lab mag:}
entry .graphdialog.top3.xmag -width 4
bind .graphdialog.top3.xmag <KeyRelease> {
xschem setprop rect 2 $graph_selected xlabmag [.graphdialog.top3.xmag get]
xschem draw_graph $graph_selected
}
label .graphdialog.top3.ylabmag -text { }
entry .graphdialog.top3.ymag -width 4
bind .graphdialog.top3.ymag <KeyRelease> {
xschem setprop rect 2 $graph_selected ylabmag [.graphdialog.top3.ymag get]
xschem draw_graph $graph_selected
}
button .graphdialog.top.clear -text Clear -padx 2 -command {
.graphdialog.top.search delete 0 end
fill_graph_listbox
@ -2209,10 +2224,12 @@ proc graph_edit_properties {n} {
pack .graphdialog.top.rainbow -side left
pack .graphdialog.top.lw -side left
pack .graphdialog.top.lwe -side left
.graphdialog.top3.min insert 0 [xschem getprop rect 2 $graph_selected y1]
.graphdialog.top3.max insert 0 [xschem getprop rect 2 $graph_selected y2]
.graphdialog.top3.ymin insert 0 [xschem getprop rect 2 $graph_selected y1]
.graphdialog.top3.ymax insert 0 [xschem getprop rect 2 $graph_selected y2]
.graphdialog.top3.xmin insert 0 [xschem getprop rect 2 $graph_selected x1]
.graphdialog.top3.xmax insert 0 [xschem getprop rect 2 $graph_selected x2]
.graphdialog.top3.xmag insert 0 [xschem getprop rect 2 $graph_selected xlabmag]
.graphdialog.top3.ymag insert 0 [xschem getprop rect 2 $graph_selected ylabmag]
# top3 frame
set graph_rainbow [xschem getprop rect 2 $graph_selected rainbow]
@ -2221,7 +2238,7 @@ proc graph_edit_properties {n} {
if { $graph_rainbow eq {} } { set graph_rainbow 0 }
if { $graph_logx eq {} } { set graph_logx 0 }
if { $graph_logy eq {} } { set graph_logy 0 }
checkbutton .graphdialog.top3.logx -padx 2 -text {Log X scale} -variable graph_logx \
checkbutton .graphdialog.top3.logx -padx 2 -text {Log X} -variable graph_logx \
-command {
if { [xschem get schname] eq $graph_schname } {
xschem setprop rect 2 $graph_selected logx $graph_logx fast
@ -2238,7 +2255,7 @@ proc graph_edit_properties {n} {
}
}
checkbutton .graphdialog.top3.logy -text {Log Y scale} -variable graph_logy \
checkbutton .graphdialog.top3.logy -text {Log Y} -variable graph_logy \
-command {
if { [xschem get schname] eq $graph_schname } {
xschem setprop rect 2 $graph_selected logy $graph_logy fast
@ -2256,7 +2273,8 @@ proc graph_edit_properties {n} {
}
pack .graphdialog.top3.logx .graphdialog.top3.logy -side left
pack .graphdialog.top3.xlabmin .graphdialog.top3.xmin .graphdialog.top3.xlabmax .graphdialog.top3.xmax -side left
pack .graphdialog.top3.labmin .graphdialog.top3.min .graphdialog.top3.labmax .graphdialog.top3.max -side left
pack .graphdialog.top3.ylabmin .graphdialog.top3.ymin .graphdialog.top3.ylabmax .graphdialog.top3.ymax -side left
pack .graphdialog.top3.xlabmag .graphdialog.top3.xmag .graphdialog.top3.ylabmag .graphdialog.top3.ymag -side left
# binding
bind .graphdialog.top.search <KeyRelease> {
fill_graph_listbox
@ -3651,7 +3669,7 @@ proc tclpropeval {s instname symname} {
regsub {\)([ \t\n]*)$} $s {\1} s
# puts "tclpropeval: $s $instname $symname"
if { [catch {subst $s} res] } {
# puts $res
# puts stderr $res
set res ?\n
}
return $res
@ -4592,6 +4610,7 @@ proc get_directory {f} {
# fetch a remote url into ${XSCHEM_TMP_DIR}/xschem_web
proc download_url {url} {
global XSCHEM_TMP_DIR download_url_helper OS
# puts "download_url: $url"
if {![file exists ${XSCHEM_TMP_DIR}/xschem_web]} {
file mkdir ${XSCHEM_TMP_DIR}/xschem_web
}