restructured graph dialog box, added min/max x, adjusted sweep variables vertical aligmnent, added atof_spice() that recognizes spice suffixes (12p, 4.2MEG etc)
This commit is contained in:
parent
f286b376f7
commit
52405a29c7
|
|
@ -314,9 +314,9 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
gr->master_gx1 = 0;
|
||||
gr->master_gx2 = 1e-6;
|
||||
val = get_tok_value(xctx->rect[GRIDLAYER][xctx->graph_master].prop_ptr,"x1",0);
|
||||
if(val[0]) gr->master_gx1 = atof(val);
|
||||
if(val[0]) gr->master_gx1 = atof_spice(val);
|
||||
val = get_tok_value(xctx->rect[GRIDLAYER][xctx->graph_master].prop_ptr,"x2",0);
|
||||
if(val[0]) gr->master_gx2 = atof(val);
|
||||
if(val[0]) gr->master_gx2 = atof_spice(val);
|
||||
if(gr->master_gx1 == gr->master_gx2) gr->master_gx2 += 1e-6;
|
||||
gr->master_gw = gr->master_gx2 - gr->master_gx1;
|
||||
|
||||
|
|
|
|||
14
src/draw.c
14
src/draw.c
|
|
@ -1978,9 +1978,9 @@ void setup_graph_data(int i, const int flags, int skip, Graph_ctx *gr)
|
|||
gr->gx1 = 0;
|
||||
gr->gx2 = 1e-6;
|
||||
val = get_tok_value(r->prop_ptr,"x1",0);
|
||||
if(val[0]) gr->gx1 = atof(val);
|
||||
if(val[0]) gr->gx1 = atof_spice(val);
|
||||
val = get_tok_value(r->prop_ptr,"x2",0);
|
||||
if(val[0]) gr->gx2 = atof(val);
|
||||
if(val[0]) gr->gx2 = atof_spice(val);
|
||||
if(gr->gx1 == gr->gx2) gr->gx2 += 1e-6;
|
||||
gr->gw = gr->gx2 - gr->gx1;
|
||||
}
|
||||
|
|
@ -2044,17 +2044,17 @@ void setup_graph_data(int i, const int flags, int skip, Graph_ctx *gr)
|
|||
val = get_tok_value(r->prop_ptr,"logy",0);
|
||||
if(val[0] == '1') gr->logy = 1;
|
||||
val = get_tok_value(r->prop_ptr,"y1",0);
|
||||
if(val[0]) gr->gy1 = atof(val);
|
||||
if(val[0]) gr->gy1 = atof_spice(val);
|
||||
val = get_tok_value(r->prop_ptr,"y2",0);
|
||||
if(val[0]) gr->gy2 = atof(val);
|
||||
if(val[0]) gr->gy2 = atof_spice(val);
|
||||
if(gr->gy1 == gr->gy2) gr->gy2 += 1.0;
|
||||
val = get_tok_value(r->prop_ptr,"digital",0);
|
||||
if(val[0]) gr->digital = atoi(val);
|
||||
if(gr->digital) {
|
||||
val = get_tok_value(r->prop_ptr,"ypos1",0);
|
||||
if(val[0]) gr->ypos1 = atof(val);
|
||||
if(val[0]) gr->ypos1 = atof_spice(val);
|
||||
val = get_tok_value(r->prop_ptr,"ypos2",0);
|
||||
if(val[0]) gr->ypos2 = atof(val);
|
||||
if(val[0]) gr->ypos2 = atof_spice(val);
|
||||
if(gr->ypos2 == gr->ypos1) gr->ypos2 += 1.0;
|
||||
}
|
||||
gr->posh = gr->ypos2 - gr->ypos1;
|
||||
|
|
@ -2193,7 +2193,7 @@ static void draw_graph_variables(int wcnt, int wave_color, int n_nodes, int swee
|
|||
if(gr->unitx != 1.0) my_snprintf(tmpstr, S(tmpstr), "%s[%c]", stok ? stok : "" , gr->unitx_suffix);
|
||||
else my_snprintf(tmpstr, S(tmpstr), "%s", stok ? stok : "");
|
||||
draw_string(wave_color, NOW, tmpstr, 2, 1, 0, 0,
|
||||
gr->rx1 + 2 + gr->rw / n_nodes * wcnt, gr->ry2-1, gr->txtsizelab, gr->txtsizelab);
|
||||
gr->rx1 + 2 + gr->rw / n_nodes * wcnt, gr->ry2-5, gr->txtsizelab, gr->txtsizelab);
|
||||
}
|
||||
/* draw node labels in graph */
|
||||
if(bus_msb) {
|
||||
|
|
|
|||
|
|
@ -287,6 +287,40 @@ size_t my_strdup2(int id, char **dest, const char *src) /* 20150409 duplicates a
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* recognizes spice suffixes: 12p --> 1.2e11, 3MEG --> 3e6 */
|
||||
double atof_spice(const char *s)
|
||||
{
|
||||
int n;
|
||||
double a = 0.0, mul=1.0;
|
||||
char lower_s[100];
|
||||
const char *p;
|
||||
|
||||
if(!s) return 0.0;
|
||||
my_strncpy(lower_s, s, S(lower_s));
|
||||
strtolower(lower_s);
|
||||
n = sscanf(lower_s, "%lf", &a);
|
||||
if(n == 1) {
|
||||
p = strpbrk(lower_s, "tgmkunpfa");
|
||||
if(!p) mul = 1.0;
|
||||
else if(*p == 't') mul=1e12;
|
||||
else if(*p == 'g') mul=1e9;
|
||||
else if(*p == 'm') {
|
||||
if(strstr(p, "meg") == p) mul=1e6;
|
||||
else if(strstr(p, "mil") == p) mul=25.4e-6;
|
||||
else mul=1e-3;
|
||||
}
|
||||
else if(*p == 'k') mul=1e3;
|
||||
else if(*p == 'u') mul=1e-6;
|
||||
else if(*p == 'n') mul=1e-9;
|
||||
else if(*p == 'p') mul=1e-12;
|
||||
else if(*p == 'f') mul=1e-15;
|
||||
else if(*p == 'a') mul=1e-18;
|
||||
else mul = 1.0;
|
||||
a *= mul;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
char *my_itoa(int i)
|
||||
{
|
||||
static char s[30];
|
||||
|
|
|
|||
|
|
@ -3080,7 +3080,7 @@ double tclgetdoublevar(const char *s)
|
|||
dbg(0, "%s\n", tclresult());
|
||||
return 0.0;
|
||||
}
|
||||
return atof(p);
|
||||
return atof_spice(p);
|
||||
}
|
||||
|
||||
int tclgetintvar(const char *s)
|
||||
|
|
|
|||
|
|
@ -1315,6 +1315,7 @@ extern void my_free(int id, void *ptr);
|
|||
extern size_t my_strcat(int id, char **, const char *);
|
||||
extern size_t my_mstrcat(int id, char **str, const char *append_str, ...);
|
||||
extern char *my_itoa(int i);
|
||||
extern double atof_spice(const char *s);
|
||||
extern char *dtoa(double i);
|
||||
extern char *dtoa_prec(double i);
|
||||
extern double my_round(double a);
|
||||
|
|
|
|||
|
|
@ -1690,7 +1690,6 @@ proc graph_edit_properties {n} {
|
|||
|
||||
# center right frame
|
||||
label .graphdialog.center.right.lab1 -text {Signals in graph}
|
||||
checkbutton .graphdialog.center.right.unlocked -text {Unlocked X axis} -variable graph_unlocked
|
||||
text .graphdialog.center.right.text1 -wrap none -width 50 -height 10 -bg grey70 -fg black \
|
||||
-insertbackground grey40 -exportselection 1 \
|
||||
-yscrollcommand {.graphdialog.center.right.yscroll set} \
|
||||
|
|
@ -1698,7 +1697,7 @@ proc graph_edit_properties {n} {
|
|||
scrollbar .graphdialog.center.right.yscroll -command {.graphdialog.center.right.text1 yview}
|
||||
scrollbar .graphdialog.center.right.xscroll -orient horiz -command {.graphdialog.center.right.text1 xview}
|
||||
|
||||
grid .graphdialog.center.right.lab1 .graphdialog.center.right.unlocked
|
||||
grid .graphdialog.center.right.lab1
|
||||
grid .graphdialog.center.right.text1 - .graphdialog.center.right.yscroll -sticky nsew
|
||||
grid .graphdialog.center.right.xscroll - -sticky nsew
|
||||
grid rowconfig .graphdialog.center.right 0 -weight 0
|
||||
|
|
@ -1716,8 +1715,10 @@ proc graph_edit_properties {n} {
|
|||
if { [xschem get schname] eq $graph_schname } {
|
||||
|
||||
update_graph_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
|
||||
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top.min get] fast
|
||||
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top.max get] fast
|
||||
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
|
||||
|
||||
if {$graph_unlocked} {
|
||||
xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast
|
||||
|
|
@ -1737,8 +1738,10 @@ proc graph_edit_properties {n} {
|
|||
if { [xschem get schname] eq $graph_schname } {
|
||||
|
||||
update_graph_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
|
||||
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top.min get] fast
|
||||
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top.max get] fast
|
||||
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
|
||||
if {$graph_unlocked} {
|
||||
xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast
|
||||
} else {
|
||||
|
|
@ -1849,6 +1852,7 @@ proc graph_edit_properties {n} {
|
|||
checkbutton .graphdialog.top.bus -text Bus -padx 2 -variable graph_bus
|
||||
checkbutton .graphdialog.top.incr -text {Incr. sort} -variable graph_sort -indicatoron 1 \
|
||||
-command fill_graph_listbox
|
||||
checkbutton .graphdialog.top.unlocked -text {Unlocked X axis} -variable graph_unlocked
|
||||
checkbutton .graphdialog.top.dig -text {Digital} -variable graph_digital -indicatoron 1 \
|
||||
-command {
|
||||
if { [xschem get schname] eq $graph_schname } {
|
||||
|
|
@ -1857,17 +1861,32 @@ proc graph_edit_properties {n} {
|
|||
}
|
||||
}
|
||||
|
||||
label .graphdialog.top.labmin -text { Min Value:}
|
||||
entry .graphdialog.top.min -width 5
|
||||
bind .graphdialog.top.min <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top.min get]
|
||||
label .graphdialog.top3.xlabmin -text { X min:}
|
||||
entry .graphdialog.top3.xmin -width 7
|
||||
bind .graphdialog.top3.xmin <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected x1 [.graphdialog.top3.xmin get]
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
|
||||
label .graphdialog.top.labmax -text { Max Value:}
|
||||
entry .graphdialog.top.max -width 5
|
||||
bind .graphdialog.top.max <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top.max get]
|
||||
label .graphdialog.top3.xlabmax -text { X max:}
|
||||
entry .graphdialog.top3.xmax -width 7
|
||||
bind .graphdialog.top3.xmax <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected x2 [.graphdialog.top3.xmax get]
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
|
||||
|
||||
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]
|
||||
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]
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
|
||||
|
|
@ -1880,9 +1899,11 @@ proc graph_edit_properties {n} {
|
|||
pack .graphdialog.top.incr -side left
|
||||
pack .graphdialog.top.bus -side left
|
||||
pack .graphdialog.top.dig -side left
|
||||
pack .graphdialog.top.labmin .graphdialog.top.min .graphdialog.top.labmax .graphdialog.top.max -side left
|
||||
.graphdialog.top.min insert 0 [xschem getprop rect 2 $graph_selected y1]
|
||||
.graphdialog.top.max insert 0 [xschem getprop rect 2 $graph_selected y2]
|
||||
pack .graphdialog.top.unlocked -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.xmin insert 0 [xschem getprop rect 2 $graph_selected x1]
|
||||
.graphdialog.top3.xmax insert 0 [xschem getprop rect 2 $graph_selected x2]
|
||||
|
||||
# top3 frame
|
||||
set graph_logx [xschem getprop rect 2 $graph_selected logx]
|
||||
|
|
@ -1923,6 +1944,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
|
||||
# binding
|
||||
bind .graphdialog.top.search <KeyRelease> {
|
||||
fill_graph_listbox
|
||||
|
|
|
|||
Loading…
Reference in New Issue