get_raw_value(): return plain value, no implicit log calculation if log scale on axis. Zoom full scale X and X axis pan: use 1st sweep X variable, do not assume spice sweep variable (idx==0)

This commit is contained in:
Stefan Frederik 2022-08-08 09:52:33 +02:00
parent edf185616b
commit 89afd902ea
4 changed files with 29 additions and 16 deletions

View File

@ -708,10 +708,16 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} /* graph_master */
} else { /* not graph_left */
int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", 1));
int dset = dataset == -1 ? 0 : dataset;
if(idx < 0 ) idx = 0;
if(r->sel || !(r->flags & 2) || i == xctx->graph_master) {
xx1 = get_raw_value(dset, 0, 0);
xx2 = get_raw_value(dset, 0, xctx->graph_npoints[dset] -1);
xx1 = get_raw_value(dset, idx, 0);
xx2 = get_raw_value(dset, idx, xctx->graph_npoints[dset] -1);
if(gr->logx) {
xx1 = mylog10(xx1);
xx2 = mylog10(xx2);
}
my_strdup(1409, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1)));
my_strdup(1412, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2)));
need_redraw = 1;
@ -724,10 +730,16 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
if(xctx->graph_values) {
if(r->sel || !(r->flags & 2) || i == xctx->graph_master) {
int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", 1));
int dset = dataset == -1 ? 0 : dataset;
if(idx < 0 ) idx = 0;
delta = gr->gw;
wwx1 = get_raw_value(dset, 0, 0);
wwx2 = get_raw_value(dset, 0, xctx->graph_npoints[dset] - 1);
wwx1 = get_raw_value(dset, idx, 0);
wwx2 = get_raw_value(dset, idx, xctx->graph_npoints[dset] - 1);
if(gr->logx) {
wwx1 = mylog10(wwx1);
wwx2 = mylog10(wwx2);
}
ccx = (gr->x2 - gr->x1) / (wwx2 - wwx1);
ddx = gr->x1 - wwx1 * ccx;
p = (xctx->mousex_snap - ddx) / ccx;

View File

@ -833,8 +833,7 @@ double get_raw_value(int dataset, int idx, int point)
ofs += xctx->graph_npoints[i];
}
if(ofs + point < xctx->graph_allpoints) {
if(gr->logx && idx == 0) return mylog10(xctx->graph_values[idx][ofs + point]);
else return xctx->graph_values[idx][ofs + point];
return xctx->graph_values[idx][ofs + point];
}
}
}

View File

@ -1,4 +1,4 @@
v {xschem version=3.0.0 file_version=1.2 }
v {xschem version=3.1.0 file_version=1.2 }
G {}
K {}
V {}
@ -24,8 +24,8 @@ B 2 750 -490 1410 -260 {flags=graph
y1 = -0.0578106
y2 = 3.04806
divy = 6
x1=-0.0234922
x2=3.11495
x1=0
x2=3
divx=6
node="a
zz
@ -36,13 +36,13 @@ B 2 10 -930 570 -700 {flags=graph
y1 = -0.0578112
y2 = 3.04806
divy = 6
x1=-0.0339625
x2=3.10448
x1=0
x2=3
divx=6
node="a
z"
node="z
a"
color="4 6"
sweep="v(z) v(a)"}
sweep="v(a) v(z)"}
P 4 5 560 -700 560 -510 1350 -510 1350 -700 560 -700 {dash=3}
P 4 5 820 -920 820 -730 1350 -730 1350 -920 820 -920 {dash=3}
T {These 2 instances are equivalent} 260 -310 0 0 0.4 0.4 {}

View File

@ -21,7 +21,8 @@ color=4
unitx=M
divx=10
dataset=1}
dataset=1
logx=1}
B 2 1030 -550 1570 -350 {flags=graph
y1=-180
y2=180
@ -40,7 +41,8 @@ color=7
unitx=M
divx=10
dataset=1
divy=5}
divy=5
logx=1}
B 2 1430 -620 1567 -560 {flags=image
alpha=0.6
filter="gm convert png:- -transparent black png:-"