diff --git a/src/callback.c b/src/callback.c index d3da5c37..8a1c0ec1 100644 --- a/src/callback.c +++ b/src/callback.c @@ -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; diff --git a/src/save.c b/src/save.c index 0a8aba4a..254c8efc 100644 --- a/src/save.c +++ b/src/save.c @@ -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]; } } } diff --git a/xschem_library/examples/LCC_instances.sch b/xschem_library/examples/LCC_instances.sch index cef04e32..3d7af2cf 100644 --- a/xschem_library/examples/LCC_instances.sch +++ b/xschem_library/examples/LCC_instances.sch @@ -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 {} diff --git a/xschem_library/examples/test_ac.sch b/xschem_library/examples/test_ac.sch index 2b34f7b4..05fc1481 100644 --- a/xschem_library/examples/test_ac.sch +++ b/xschem_library/examples/test_ac.sch @@ -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:-"