fix fullxzoom if a single curve is selected with find_closest_wave() (returns a dataset number) in a double variable DC sweep (there are no multiple datasets, just sweep var wrapping)

This commit is contained in:
stefan schippers 2023-10-23 17:20:51 +02:00
parent 2aeafac85c
commit fec9c1b7e3
2 changed files with 10 additions and 4 deletions

View File

@ -2023,13 +2023,11 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset)
dbg(1, "graph_fullxzoom(): sweep idx=%d\n", idx);
if(idx < 0 ) idx = 0;
my_strdup2(_ALLOC_ID_, &custom_rawfile, get_tok_value(r->prop_ptr,"rawfile",0));
my_strdup2(_ALLOC_ID_, &sim_type, get_tok_value(r->prop_ptr,"sim_type",0));
if((i == xctx->graph_master) && custom_rawfile[0]) {
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
}
if(i != xctx->graph_master ) {
my_strdup2(_ALLOC_ID_, &custom_rawfile,
get_tok_value(xctx->rect[GRIDLAYER][xctx->graph_master].prop_ptr,"rawfile",0));
@ -2039,7 +2037,13 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset)
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
}
}
raw = xctx->raw;
/* if doing double variable DC sweeps raw->datasets == 1 but there are multiple curves.
* find_closest_wave() may return a dataset number that is > 0 but its a "virtual" dataset
* since double DC sweeps just do multiple sweeps by wrapping the sweep variable
*/
if(dset >= raw->datasets) dset = 0;
/* 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) {
@ -2048,7 +2052,6 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset)
save_npoints = raw->npoints[0];
raw->npoints[0] = raw->allpoints;
}
xx1 = xx2 = get_raw_value(dset, idx, 0);
for(k = 0; k < xctx->raw->npoints[dset]; k++) {
double v = get_raw_value(dset, idx, k);

View File

@ -1565,7 +1565,10 @@ double get_raw_value(int dataset, int idx, int point)
{
int i, ofs;
ofs = 0;
if(xctx->raw && xctx->raw->values) {
if(dataset >= xctx->raw->datasets) {
dbg(0, "get_raw_value(): dataset(%d) >= datasets(%d)\n", dataset, xctx->raw->datasets);
}
if(xctx->raw && xctx->raw->values && dataset < xctx->raw->datasets) {
if(dataset == -1) {
if(point < xctx->raw->allpoints)
return xctx->raw->values[idx][point];