improve cursor display and move with multiple graphs with different sweep variables (2)
This commit is contained in:
parent
ba76f42277
commit
27c065327e
|
|
@ -2276,7 +2276,7 @@ int descend_schematic(int instnumber, int fallback, int alert)
|
|||
Graph_ctx *gr = &xctx->graph_struct;
|
||||
xRect *r = &xctx->rect[GRIDLAYER][0];
|
||||
if(r->flags & 1) {
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(2, 0, gr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -223,8 +223,9 @@ static double interpolate_yval(int idx, int point_not_last, int p, double x, int
|
|||
return val;
|
||||
}
|
||||
|
||||
void backannotate_at_cursor_pos(int cursor, xRect *r, Graph_ctx *gr)
|
||||
void backannotate_at_cursor_pos(int cursor, int i, Graph_ctx *gr)
|
||||
{
|
||||
xRect *r = &xctx->rect[GRIDLAYER][i];
|
||||
if(sch_waves_loaded() >= 0) {
|
||||
int dset, first = -1, last, dataset = gr->dataset, i, p, ofs = 0, ofs_end;
|
||||
double start, end;
|
||||
|
|
@ -245,13 +246,13 @@ void backannotate_at_cursor_pos(int cursor, xRect *r, Graph_ctx *gr)
|
|||
else cursorpos = xctx->graph_cursor2_x;
|
||||
start = (gr->gx1 <= gr->gx2) ? gr->gx1 : gr->gx2;
|
||||
end = (gr->gx1 <= gr->gx2) ? gr->gx2 : gr->gx1;
|
||||
dbg(1, "start=%g, end=%g\n", start, end);
|
||||
dbg(1, "backannotate_at_cursor_pos(): start=%g, end=%g\n", start, end);
|
||||
if(gr->logx) {
|
||||
cursorpos = pow(10, cursorpos);
|
||||
start = pow(10, start);
|
||||
end = pow(10, end);
|
||||
}
|
||||
dbg(1, "cursor%d pos: %g dataset=%d\n", cursor, cursorpos, gr->dataset);
|
||||
dbg(1, "backannotate_at_cursor_pos(): cursor%d pos: %g dataset=%d\n", cursor, cursorpos, gr->dataset);
|
||||
if(dataset < 0) dataset = 0; /* if all datasets are plotted use first for backannotation */
|
||||
dbg(1, "dataset=%d\n", dataset);
|
||||
ofs = 0;
|
||||
|
|
@ -323,9 +324,13 @@ void backannotate_at_cursor_pos(int cursor, xRect *r, Graph_ctx *gr)
|
|||
Tcl_SetVar2(interp, "ngspice::ngspice_data", "n\\ vars", my_itoa( raw->nvars), TCL_GLOBAL_ONLY);
|
||||
Tcl_SetVar2(interp, "ngspice::ngspice_data", "n\\ points", "1", TCL_GLOBAL_ONLY);
|
||||
} else { /* cursor == 1 */
|
||||
dbg(1, "backannotate_at_cursor_pos(): updating cursor_a_val with sweep_idx=%d\n", sweep_idx);
|
||||
dbg(1, " : cursorpos=%g\n", cursorpos);
|
||||
dbg(1, " : p=%d\n", p);
|
||||
for(i = 0; i < raw->nvars; ++i) {
|
||||
raw->cursor_a_val[i] = interpolate_yval(i, (p < ofs_end), p, cursorpos, sweep_idx);
|
||||
}
|
||||
dbg(1, " : cursor_a_val[0]=%g\n", raw->cursor_a_val[0]);
|
||||
}
|
||||
}
|
||||
if(save_npoints != -1) { /* restore multiple OP points from artificial dc sweep */
|
||||
|
|
@ -387,14 +392,14 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
/* set cursor position from master graph x-axis */
|
||||
if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 16 )) {
|
||||
xctx->graph_cursor1_x = G_X(xctx->mousex);
|
||||
backannotate_at_cursor_pos(1, r, gr);
|
||||
backannotate_at_cursor_pos(1, i, gr);
|
||||
}
|
||||
/* move cursor2 */
|
||||
/* set cursor position from master graph x-axis */
|
||||
else if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 32 )) {
|
||||
int floaters = there_are_floaters();
|
||||
xctx->graph_cursor2_x = G_X(xctx->mousex);
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(2, i, gr);
|
||||
if(tclgetboolvar("live_cursor2_backannotate")) {
|
||||
if(floaters) set_modify(-2); /* update floater caches to reflect actual backannotation */
|
||||
redraw_all_at_end = 1;
|
||||
|
|
@ -430,10 +435,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
double cursorx;
|
||||
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
|
||||
cursorx = xctx->graph_cursor1_x;
|
||||
if(idx >= 0 ) {
|
||||
if(idx < 0) idx = 0;
|
||||
if(xctx->raw && xctx->raw->cursor_a_val) {
|
||||
cursorx = xctx->raw->cursor_a_val[idx];
|
||||
}
|
||||
if(idx < 0) idx = 0;
|
||||
if(gr->logx) cursorx = log10(cursorx);
|
||||
/* dragging cursors when mouse is very close */
|
||||
if( fabs(xctx->mousex - W_X(cursorx)) < 10) {
|
||||
xctx->graph_flags |= 16; /* Start move cursor1 */
|
||||
|
|
@ -444,10 +450,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
double cursorx;
|
||||
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
|
||||
cursorx = xctx->graph_cursor2_x;
|
||||
if(idx >= 0) {
|
||||
if(idx < 0) idx = 0;
|
||||
if(xctx->raw && xctx->raw->cursor_b_val) {
|
||||
cursorx = xctx->raw->cursor_b_val[idx];
|
||||
}
|
||||
if(idx < 0) idx = 0;
|
||||
if(gr->logx) cursorx = log10(cursorx);
|
||||
/* dragging cursors when mouse is very close */
|
||||
if(fabs(xctx->mousex - W_X(cursorx)) < 10) {
|
||||
xctx->graph_flags |= 32; /* Start move cursor2 */
|
||||
|
|
@ -496,7 +503,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
need_all_redraw = 1;
|
||||
if(xctx->graph_flags & 2) {
|
||||
xctx->graph_cursor1_x = G_X(xctx->mousex);
|
||||
backannotate_at_cursor_pos(1, r, gr);
|
||||
dbg(0, "waves_callback(): graph_cursor1_x=%g\n", xctx->graph_cursor1_x);
|
||||
backannotate_at_cursor_pos(1, i, gr);
|
||||
}
|
||||
}
|
||||
/* x cursor2 toggle */
|
||||
|
|
@ -505,7 +513,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
xctx->graph_flags ^= 4;
|
||||
if(xctx->graph_flags & 4) {
|
||||
xctx->graph_cursor2_x = G_X(xctx->mousex);
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(2, i, gr);
|
||||
if(tclgetboolvar("live_cursor2_backannotate")) {
|
||||
if(floaters) set_modify(-2); /* update floater caches to reflect actual backannotation */
|
||||
redraw_all_at_end = 1;
|
||||
|
|
@ -526,8 +534,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
tmp = xctx->graph_cursor2_x;
|
||||
xctx->graph_cursor2_x = xctx->graph_cursor1_x;
|
||||
xctx->graph_cursor1_x = tmp;
|
||||
backannotate_at_cursor_pos(1, r, gr);
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(1, i, gr);
|
||||
backannotate_at_cursor_pos(2, i, gr);
|
||||
if(tclgetboolvar("live_cursor2_backannotate")) {
|
||||
if(floaters) set_modify(-2); /* update floater caches to reflect actual backannotation */
|
||||
redraw_all_at_end = 1;
|
||||
|
|
@ -793,12 +801,12 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
}
|
||||
if((xctx->graph_flags & 2)) {
|
||||
if(i == xctx->graph_master) {
|
||||
backannotate_at_cursor_pos(1, r, gr);
|
||||
backannotate_at_cursor_pos(1, i, gr);
|
||||
}
|
||||
}
|
||||
if((xctx->graph_flags & 4)) {
|
||||
if(i == xctx->graph_master) {
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(2, i, gr);
|
||||
}
|
||||
}
|
||||
if((xctx->graph_flags & 4) && tclgetboolvar("live_cursor2_backannotate")) {
|
||||
|
|
|
|||
|
|
@ -2920,8 +2920,9 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g
|
|||
other_cursorx = xctx->graph_cursor1_x;
|
||||
}
|
||||
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
|
||||
if(idx >= 0) {
|
||||
dbg(1, "draw_cursor(): idx=%d, cursor=%g\n", idx, xctx->raw->cursor_a_val[idx]);
|
||||
dbg(1, "draw_cursor(): before: idx=%d, cursor=%g\n", idx, active_cursorx);
|
||||
if(idx < 0) idx = 0;
|
||||
if(xctx->raw && xctx->raw->cursor_a_val && xctx->raw->cursor_b_val) {
|
||||
if(active_cursor == 1) {
|
||||
active_cursorx = xctx->raw->cursor_a_val[idx];
|
||||
other_cursorx = xctx->raw->cursor_b_val[idx];
|
||||
|
|
@ -2930,7 +2931,9 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g
|
|||
other_cursorx = xctx->raw->cursor_a_val[idx];
|
||||
}
|
||||
}
|
||||
if(idx < 0) idx = 0;
|
||||
if(gr->logx) active_cursorx = log10(active_cursorx);
|
||||
if(gr->logx) other_cursorx = log10(other_cursorx);
|
||||
dbg(1, "draw_cursor(): after: idx=%d, cursor=%g\n", idx, active_cursorx);
|
||||
xx = W_X(active_cursorx);
|
||||
flip = (other_cursorx > active_cursorx) ? 0 : 1;
|
||||
xoffs = flip ? 3 : -3;
|
||||
|
|
|
|||
|
|
@ -4704,7 +4704,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
Graph_ctx *gr = &xctx->graph_struct;
|
||||
xRect *r = &xctx->rect[GRIDLAYER][0];
|
||||
if(r->flags & 1) {
|
||||
backannotate_at_cursor_pos(1, r, gr);
|
||||
backannotate_at_cursor_pos(1, 0, gr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4715,7 +4715,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
Graph_ctx *gr = &xctx->graph_struct;
|
||||
xRect *r = &xctx->rect[GRIDLAYER][0];
|
||||
if(r->flags & 1) {
|
||||
backannotate_at_cursor_pos(2, r, gr);
|
||||
backannotate_at_cursor_pos(2, 0, gr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1383,7 +1383,7 @@ extern int select_dangling_nets(void);
|
|||
extern int Tcl_AppInit(Tcl_Interp *interp);
|
||||
extern void abort_operation(void);
|
||||
extern void draw_crosshair(int del);
|
||||
extern void backannotate_at_cursor_pos(int cursor, xRect *r, Graph_ctx *gr);
|
||||
extern void backannotate_at_cursor_pos(int cursor, int i, Graph_ctx *gr);
|
||||
extern int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
||||
int button, int aux, int state);
|
||||
extern void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h);
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ divy = 6
|
|||
x1=0
|
||||
x2=3
|
||||
divx=6
|
||||
node="z
|
||||
a"
|
||||
color="4 6"
|
||||
sweep="v(a) v(z)"
|
||||
}
|
||||
|
||||
|
||||
sweep="z a"
|
||||
color="4 8"
|
||||
node="a 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}
|
||||
P 4 5 0 -1160 1840 -1160 1840 0 -0 0 0 -1160 {dash=4}
|
||||
|
|
|
|||
Loading…
Reference in New Issue