backannotate_at_cursor_b_pos(): allow backannotating b cursor on graphs created from multiple OP points

This commit is contained in:
stefan schippers 2023-11-09 04:10:06 +01:00
parent 7d92a32f5e
commit 35359aed20
1 changed files with 18 additions and 0 deletions

View File

@ -217,6 +217,20 @@ static void backannotate_at_cursor_b_pos(xRect *r, Graph_ctx *gr)
int sweepvar_wrap = 0, sweep_idx;
double xx, cursor2; /* xx is the p-th sweep variable value, cursor2 is cursor 'b' x position */
Raw *raw = xctx->raw;
int save_datasets = -1, save_npoints = -1;
/* transform multiple OP points into a dc sweep */
if(raw && raw->sim_type && !strcmp(raw->sim_type, "op") && raw->datasets > 1 && raw->npoints[0] == 1) {
save_datasets = raw->datasets;
raw->datasets = 1;
save_npoints = raw->npoints[0];
raw->npoints[0] = raw->allpoints;
}
sweep_idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1));
if(sweep_idx < 0) sweep_idx = 0;
cursor2 = xctx->graph_cursor2_x;
@ -299,6 +313,10 @@ static void backannotate_at_cursor_b_pos(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);
}
if(save_npoints != -1) { /* restore multiple OP points from artificial dc sweep */
raw->datasets = save_datasets;
raw->npoints[0] = save_npoints;
}
}
}