add the ability to load multiple raw files with different analyses in a single schematic ( extra_rawfile() )
This commit is contained in:
parent
5da81a7aea
commit
8cfd51d8f9
|
|
@ -886,7 +886,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
} else { /* not graph_left, full X zoom*/
|
||||
/* selected or locked or master */
|
||||
if(r->sel || !(r->flags & 2) || i == xctx->graph_master) {
|
||||
need_redraw = graph_fullxzoom(r, gr, dataset);
|
||||
need_redraw = graph_fullxzoom(i, gr, dataset);
|
||||
}
|
||||
}
|
||||
} /* raw->values */
|
||||
|
|
|
|||
106
src/draw.c
106
src/draw.c
|
|
@ -2008,14 +2008,33 @@ static void set_thick_waves(int what, int wcnt, int wave_col, Graph_ctx *gr)
|
|||
}
|
||||
}
|
||||
|
||||
int graph_fullxzoom(xRect *r, Graph_ctx *gr, int dataset)
|
||||
int graph_fullxzoom(int i, Graph_ctx *gr, int dataset)
|
||||
{
|
||||
xRect *r = &xctx->rect[GRIDLAYER][i];
|
||||
if( sch_waves_loaded() >= 0) {
|
||||
int need_redraw = 0;
|
||||
double xx1, xx2;
|
||||
int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1));
|
||||
int dset = dataset == -1 ? 0 : dataset;
|
||||
char *custom_rawfile = NULL; /* "rawfile" attr. set in graph: load and switch to specified raw */
|
||||
char *sim_type = NULL;
|
||||
|
||||
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) && sch_waves_loaded()!= -1 && 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));
|
||||
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) {
|
||||
extra_rawfile(1, custom_rawfile, xctx->raw->sim_type);
|
||||
}
|
||||
}
|
||||
|
||||
xx1 = get_raw_value(dset, idx, 0);
|
||||
xx2 = get_raw_value(dset, idx, xctx->raw->npoints[dset] -1);
|
||||
if(gr->logx) {
|
||||
|
|
@ -2024,6 +2043,11 @@ int graph_fullxzoom(xRect *r, Graph_ctx *gr, int dataset)
|
|||
}
|
||||
my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1)));
|
||||
my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2)));
|
||||
|
||||
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) extra_rawfile(5, NULL, NULL);
|
||||
my_free(_ALLOC_ID_, &custom_rawfile);
|
||||
my_free(_ALLOC_ID_, &sim_type);
|
||||
|
||||
need_redraw = 1;
|
||||
return need_redraw;
|
||||
} else {
|
||||
|
|
@ -2031,7 +2055,7 @@ int graph_fullxzoom(xRect *r, Graph_ctx *gr, int dataset)
|
|||
}
|
||||
}
|
||||
|
||||
int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset)
|
||||
int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset)
|
||||
{
|
||||
int need_redraw = 0;
|
||||
if( sch_waves_loaded() >= 0) {
|
||||
|
|
@ -2044,32 +2068,55 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset)
|
|||
double min=0.0, max=0.0;
|
||||
int firstyval = 1;
|
||||
char *saves, *sptr, *stok, *sweep = NULL, *saven, *nptr, *ntok, *node = NULL;
|
||||
Raw *raw = xctx->raw;
|
||||
int node_dataset = -1; /* dataset specified as %<n> after node/bus/expression name */
|
||||
char *ntok_copy = NULL; /* copy of ntok without %<n> */
|
||||
char *custom_rawfile = NULL; /* "rawfile" attr. set in graph: load and switch to specified raw */
|
||||
char *sim_type = NULL;
|
||||
Raw *raw = NULL;
|
||||
|
||||
dbg(1, "graph_fullyzoom(): dataset=%d\n", dataset);
|
||||
dbg(1, "graph_fullyzoom(): graph_dataset=%d\n", graph_dataset);
|
||||
my_strdup2(_ALLOC_ID_, &node, get_tok_value(r->prop_ptr,"node",0));
|
||||
my_strdup2(_ALLOC_ID_, &sweep, get_tok_value(r->prop_ptr,"sweep",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(sch_waves_loaded() != -1 && custom_rawfile[0]) {
|
||||
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
|
||||
}
|
||||
raw = xctx->raw;
|
||||
|
||||
nptr = node;
|
||||
sptr = sweep;
|
||||
start = (gr->gx1 <= gr->gx2) ? gr->gx1 : gr->gx2;
|
||||
end = (gr->gx1 <= gr->gx2) ? gr->gx2 : gr->gx1;
|
||||
|
||||
while( (ntok = my_strtok_r(nptr, "\n\t ", "\"", 0, &saven)) ) {
|
||||
while( (ntok = my_strtok_r(nptr, "\n\t ", "\"", 4, &saven)) ) {
|
||||
char *nd = find_nth(ntok, "%", "\"", 0, 2);
|
||||
|
||||
/* if %<n> is specified after node name, <n> is the dataset number to plot in graph */
|
||||
if(nd[0]) {
|
||||
node_dataset = atoi(nd);
|
||||
my_strdup(_ALLOC_ID_, &ntok_copy, find_nth(ntok, "%", "\"", 0, 1));
|
||||
} else {
|
||||
node_dataset = -1;
|
||||
my_strdup(_ALLOC_ID_, &ntok_copy, ntok);
|
||||
}
|
||||
|
||||
stok = my_strtok_r(sptr, "\n\t ", "\"", 0, &saves);
|
||||
nptr = sptr = NULL;
|
||||
if(stok && stok[0]) {
|
||||
sweep_idx = get_raw_index(stok);
|
||||
if( sweep_idx == -1) sweep_idx = 0;
|
||||
}
|
||||
dbg(1, "graph_fullyzoom(): ntok=%s\n", ntok);
|
||||
bus_msb = strstr(ntok, ",");
|
||||
dbg(1, "graph_fullyzoom(): ntok_copy=%s\n", ntok_copy);
|
||||
bus_msb = strstr(ntok_copy, ",");
|
||||
v = -1;
|
||||
if(!bus_msb) {
|
||||
char *express = NULL;
|
||||
if(strstr(ntok, ";")) {
|
||||
my_strdup2(_ALLOC_ID_, &express, find_nth(ntok, ";", "\"", 0, 2));
|
||||
if(strstr(ntok_copy, ";")) {
|
||||
my_strdup2(_ALLOC_ID_, &express, find_nth(ntok_copy, ";", "\"", 0, 2));
|
||||
} else {
|
||||
my_strdup2(_ALLOC_ID_, &express, ntok);
|
||||
my_strdup2(_ALLOC_ID_, &express, ntok_copy);
|
||||
}
|
||||
if(strpbrk(express, " \n\t")) {
|
||||
/* just probe a single point to get the index. custom data column already calculated */
|
||||
|
|
@ -2082,6 +2129,7 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset)
|
|||
dbg(1, "graph_fullyzoom(): v=%d\n", v);
|
||||
}
|
||||
if(xctx->raw && v >= 0) {
|
||||
int dataset = node_dataset >=0 ? node_dataset : graph_dataset;
|
||||
int sweepvar_wrap = 0; /* incremented on new dataset or sweep variable wrap */
|
||||
int ofs = 0, ofs_end;
|
||||
for(dset = 0 ; dset < raw->datasets; dset++) {
|
||||
|
|
@ -2119,12 +2167,16 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset)
|
|||
sweepvar_wrap++;
|
||||
} /* for(dset...) */
|
||||
}
|
||||
} /* while( (ntok = my_strtok_r(nptr, "\n\t ", "\"", 0, &saven)) ) */
|
||||
} /* while( (ntok_copy = my_strtok_r(nptr, "\n\t ", "\"", 0, &saven)) ) */
|
||||
if(max == min) max += 0.01;
|
||||
min = floor_to_n_digits(min, 2);
|
||||
max = ceil_to_n_digits(max, 2);
|
||||
my_free(_ALLOC_ID_, &node);
|
||||
my_free(_ALLOC_ID_, &sweep);
|
||||
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) extra_rawfile(5, NULL, NULL);
|
||||
my_free(_ALLOC_ID_, &custom_rawfile);
|
||||
my_free(_ALLOC_ID_, &sim_type);
|
||||
if(ntok_copy) my_free(_ALLOC_ID_, &ntok_copy);
|
||||
my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(min)));
|
||||
my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(max)));
|
||||
need_redraw = 1;
|
||||
|
|
@ -2985,9 +3037,11 @@ int find_closest_wave(int i, Graph_ctx *gr)
|
|||
xRect *r = &xctx->rect[GRIDLAYER][i];
|
||||
int closest_dataset = -1;
|
||||
double min=-1.0;
|
||||
Raw *raw = xctx->raw;
|
||||
Raw *raw = NULL;
|
||||
char *custom_rawfile = NULL; /* "rawfile" attr. set in graph: load and switch to specified raw */
|
||||
char *sim_type = NULL;
|
||||
|
||||
if(!raw) {
|
||||
if(!xctx->raw) {
|
||||
dbg(0, "find_closest_wave(): no raw struct allocated\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2997,6 +3051,14 @@ int find_closest_wave(int i, Graph_ctx *gr)
|
|||
/* get data to plot */
|
||||
my_strdup2(_ALLOC_ID_, &node, get_tok_value(r->prop_ptr,"node",0));
|
||||
my_strdup2(_ALLOC_ID_, &sweep, get_tok_value(r->prop_ptr,"sweep",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(sch_waves_loaded()!= -1 && custom_rawfile[0]) {
|
||||
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
|
||||
}
|
||||
raw = xctx->raw;
|
||||
|
||||
nptr = node;
|
||||
sptr = sweep;
|
||||
/* process each node given in "node" attribute, get also associated sweep var if any*/
|
||||
|
|
@ -3104,6 +3166,11 @@ int find_closest_wave(int i, Graph_ctx *gr)
|
|||
} /* while( (ntok = my_strtok_r(nptr, "\n\t ", "", 0, &saven)) ) */
|
||||
dbg(0, "closest dataset=%d\n", closest_dataset);
|
||||
if(express) my_free(_ALLOC_ID_, &express);
|
||||
|
||||
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) extra_rawfile(5, NULL, NULL);
|
||||
my_free(_ALLOC_ID_, &custom_rawfile);
|
||||
my_free(_ALLOC_ID_, &sim_type);
|
||||
|
||||
my_free(_ALLOC_ID_, &node);
|
||||
my_free(_ALLOC_ID_, &sweep);
|
||||
return closest_dataset;
|
||||
|
|
@ -3134,9 +3201,11 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
double *measure_prev_x = NULL;
|
||||
char *express = NULL;
|
||||
xRect *r = &xctx->rect[GRIDLAYER][i];
|
||||
Raw *raw = xctx->raw;
|
||||
Raw *raw = NULL;
|
||||
int node_dataset = -1; /* dataset specified as %<n> after node/bus/expression name */
|
||||
char *ntok_copy = NULL; /* copy of ntok without %<n> */
|
||||
char *custom_rawfile = NULL; /* "rawfile" attr. set in graph: load and switch to specified raw */
|
||||
char *sim_type = NULL;
|
||||
|
||||
if(xctx->only_probes) return;
|
||||
if(RECT_OUTSIDE( gr->sx1, gr->sy1, gr->sx2, gr->sy2,
|
||||
|
|
@ -3163,6 +3232,12 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
my_strdup2(_ALLOC_ID_, &node, get_tok_value(r->prop_ptr,"node",0));
|
||||
my_strdup2(_ALLOC_ID_, &color, get_tok_value(r->prop_ptr,"color",0));
|
||||
my_strdup2(_ALLOC_ID_, &sweep, get_tok_value(r->prop_ptr,"sweep",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(sch_waves_loaded()!= -1 && custom_rawfile[0]) {
|
||||
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
|
||||
}
|
||||
raw = xctx->raw;
|
||||
nptr = node;
|
||||
cptr = color;
|
||||
sptr = sweep;
|
||||
|
|
@ -3346,6 +3421,9 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
} /* while( (ntok = my_strtok_r(nptr, "\n\t ", "", 0, &saven)) ) */
|
||||
if(ntok_copy) my_free(_ALLOC_ID_, &ntok_copy);
|
||||
if(express) my_free(_ALLOC_ID_, &express);
|
||||
if(sch_waves_loaded()!= -1 && custom_rawfile[0]) extra_rawfile(5, NULL, NULL);
|
||||
my_free(_ALLOC_ID_, &custom_rawfile);
|
||||
my_free(_ALLOC_ID_, &sim_type);
|
||||
my_free(_ALLOC_ID_, &node);
|
||||
my_free(_ALLOC_ID_, &color);
|
||||
my_free(_ALLOC_ID_, &sweep);
|
||||
|
|
|
|||
121
src/save.c
121
src/save.c
|
|
@ -486,6 +486,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
"Use binary format in ngspice (set filetype=binary)\n");
|
||||
tcleval("alert_ {read_dataset(): ASCII raw files can not be read. "
|
||||
"Use binary format in ngspice (set filetype=binary)}");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(rawptr, 0);
|
||||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
|
|
@ -553,6 +554,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
n = sscanf(line, "No. of Data Rows : %d", &npoints);
|
||||
if(n < 1) {
|
||||
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(rawptr, 0);
|
||||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
|
|
@ -581,6 +583,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
|
||||
if(n < 1) {
|
||||
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(rawptr, 0);
|
||||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
|
|
@ -593,6 +596,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
n = sscanf(line, "No. Points: %d", &npoints);
|
||||
if(n < 1) {
|
||||
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(rawptr, 0);
|
||||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
|
|
@ -615,6 +619,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
n = sscanf(line, "%d %s", &i, varname); /* read index and name of saved waveform */
|
||||
if(n < 2) {
|
||||
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(rawptr, 0);
|
||||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
|
|
@ -802,32 +807,106 @@ int raw_read(const char *f, Raw **rawptr, const char *type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* what == 1: read another raw file
|
||||
* what == 2: switch raw file
|
||||
* what == 3: remove a raw file
|
||||
* what == 4: remove all additional raw files
|
||||
/* what == 1: read another raw file and switch to it
|
||||
* what == 2: switch raw file. If filename given switch to that one, else switch to next
|
||||
* what == 3: remove a raw file. If no filename given remove all, keep current in xctx->raw
|
||||
* what == 4: print info
|
||||
* what == 5: switch back to previous
|
||||
*/
|
||||
void read_more_rawfile(int what, const char *f, const char *type)
|
||||
void extra_rawfile(int what, const char *f, const char *type)
|
||||
{
|
||||
static int cnt = 1;
|
||||
static Raw *raw[50];
|
||||
static int nraw = 0;
|
||||
int i;
|
||||
|
||||
if(nraw == 0) {
|
||||
raw[nraw] = xctx->raw;
|
||||
nraw++;
|
||||
dbg(1, "extra_rawfile(): what=%d, f=%s, type=%s\n", what, f ? f : "NULL", type ? type : "NULL");
|
||||
if(xctx->raw && xctx->extra_raw_n == 0) {
|
||||
xctx->extra_raw_arr[xctx->extra_raw_n] = xctx->raw;
|
||||
xctx->extra_raw_n++;
|
||||
}
|
||||
if(what == 1 && xctx->extra_raw_n < MAX_RAW_N && f ) { /* read */
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) break;
|
||||
}
|
||||
if(i >= xctx->extra_raw_n) { /* file not found: read it and switch to it */
|
||||
int ret = 0;
|
||||
Raw *save;
|
||||
save = xctx->raw;
|
||||
xctx->raw = NULL;
|
||||
ret = raw_read(f, &xctx->raw, type);
|
||||
if(ret) {
|
||||
xctx->extra_raw_arr[xctx->extra_raw_n] = xctx->raw;
|
||||
xctx->extra_raw_n++;
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = xctx->extra_raw_n;
|
||||
} else {
|
||||
xctx->raw = save;
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
}
|
||||
if(what == 1 && f && type) {
|
||||
xctx->raw = NULL;
|
||||
raw_read(f, &xctx->raw, type);
|
||||
raw[nraw] = xctx->raw;
|
||||
nraw++;
|
||||
cnt = (cnt + 1) % nraw;
|
||||
draw();
|
||||
} else if(what == 2) {
|
||||
cnt = (cnt + 1) % nraw;
|
||||
xctx->raw = raw[cnt];
|
||||
} else { /* file found: switch to it */
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = i;
|
||||
xctx->raw = xctx->extra_raw_arr[xctx->extra_idx];
|
||||
}
|
||||
} else if(what == 2) { /* switch */
|
||||
if(f) {
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) break;
|
||||
}
|
||||
if(i < xctx->extra_raw_n) { /* if file found switch to it ... */
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = i;
|
||||
}
|
||||
} else { /* switch to next */
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = (xctx->extra_idx + 1) % xctx->extra_raw_n;
|
||||
}
|
||||
xctx->raw = xctx->extra_raw_arr[xctx->extra_idx];
|
||||
} else if(what == 5) { /* switch_back */
|
||||
int tmp;
|
||||
tmp = xctx->extra_idx;
|
||||
xctx->extra_idx = xctx->extra_prev_idx;
|
||||
xctx->extra_prev_idx = tmp;
|
||||
xctx->raw = xctx->extra_raw_arr[xctx->extra_idx];
|
||||
} else if(what == 3) { /* clear */
|
||||
if(!f) { /* clear all , keep only current */
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(i == xctx->extra_idx) {
|
||||
xctx->raw = xctx->extra_raw_arr[i];
|
||||
xctx->extra_raw_arr[i] = NULL;
|
||||
} else {
|
||||
free_rawfile(&xctx->extra_raw_arr[i], 0);
|
||||
}
|
||||
}
|
||||
xctx->extra_prev_idx = 0;
|
||||
xctx->extra_idx = 0;
|
||||
xctx->extra_raw_n = 0;
|
||||
} else { /* clear provided file if found, switch to first in remaining */
|
||||
int found = -1;
|
||||
if(xctx->extra_raw_n > 1 ) {
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) {
|
||||
free_rawfile(&xctx->extra_raw_arr[i], 0);
|
||||
found = i;
|
||||
continue;
|
||||
}
|
||||
if(found != -1) xctx->extra_raw_arr[i - 1] = xctx->extra_raw_arr[i];
|
||||
}
|
||||
if(found != -1) {
|
||||
xctx->extra_raw_n--;
|
||||
xctx->extra_idx = 0;
|
||||
xctx->extra_prev_idx = 0;
|
||||
xctx->raw = xctx->extra_raw_arr[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(what == 4) { /* info */
|
||||
if(xctx->raw) {
|
||||
dbg(1, "extra_raw_n = %d\n", xctx->extra_raw_n);
|
||||
Tcl_AppendResult(interp, my_itoa(xctx->extra_idx), " current\n", NULL);
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
Tcl_AppendResult(interp, my_itoa(i), " ", xctx->extra_raw_arr[i]->filename, "\n", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read data organized as a table
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
}
|
||||
tclsetboolvar("live_cursor2_backannotate", 1);
|
||||
tclsetvar("rawfile_loaded", "0");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 1);
|
||||
tcleval("array unset ngspice::ngspice_data");
|
||||
raw_read(f, &xctx->raw, "op");
|
||||
|
|
@ -281,6 +282,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
for(i = 0; i < xctx->raw->nvars; ++i) {
|
||||
char s[100];
|
||||
int p = 0;
|
||||
xctx->raw->cursor_b_val[i] = xctx->raw->values[i][p];
|
||||
my_snprintf(s, S(s), "%.4g", xctx->raw->values[i][p]);
|
||||
dbg(1, "%s = %g\n", xctx->raw->names[i], xctx->raw->values[i][p]);
|
||||
tclvareval("array set ngspice::ngspice_data [list {", xctx->raw->names[i], "} ", s, "]", NULL);
|
||||
|
|
@ -3072,12 +3074,42 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
else { cmd_found = 0;}
|
||||
break;
|
||||
case 'r': /*----------------------------------------------*/
|
||||
/* raw what [rawfile type]
|
||||
* what = read | clear | info | switch | switch_back
|
||||
* Load /clear / switch additional raw files */
|
||||
if(!strcmp(argv[1], "raw"))
|
||||
{
|
||||
int err = 0;
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
if(argc > 3 && !strcmp(argv[2], "read")) {
|
||||
if(argc > 4) extra_rawfile(1, argv[3], argv[4]);
|
||||
else extra_rawfile(1, argv[3], NULL);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "switch")) {
|
||||
if(argv[3]) {
|
||||
extra_rawfile(2, argv[3], NULL);
|
||||
} else {
|
||||
extra_rawfile(2, NULL, NULL);
|
||||
}
|
||||
} else if(argc > 2 && !strcmp(argv[2], "info")) {
|
||||
extra_rawfile(4, NULL, NULL);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "switch_back")) {
|
||||
extra_rawfile(5, NULL, NULL);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "clear")) {
|
||||
if(argc > 3) extra_rawfile(3, argv[3], NULL);
|
||||
else extra_rawfile(3, NULL, NULL);
|
||||
} else {
|
||||
err = 1;
|
||||
}
|
||||
if(err) {Tcl_SetResult(interp, "Wrong command", TCL_STATIC); return TCL_ERROR;}
|
||||
}
|
||||
|
||||
/* raw_clear
|
||||
* Delete loaded simulation raw file */
|
||||
if(!strcmp(argv[1], "raw_clear"))
|
||||
else if(!strcmp(argv[1], "raw_clear"))
|
||||
{
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
tclsetvar("rawfile_loaded", "0");
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 1);
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
|
@ -3181,9 +3213,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
int res = 0;
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
if(sch_waves_loaded() >= 0) {
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 1);
|
||||
tclsetvar("rawfile_loaded", "0");
|
||||
} else if(argc > 2) {
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 0);
|
||||
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir);
|
||||
tcleval(f);
|
||||
|
|
@ -3209,8 +3243,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
{
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
if(sch_waves_loaded() >= 0) {
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 1);
|
||||
} else {
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 0);
|
||||
if(argc > 2) raw_read_from_attr(&xctx->raw, argv[2]);
|
||||
else raw_read_from_attr(&xctx->raw, NULL);
|
||||
|
|
@ -4227,13 +4263,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
bbox(START,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
if(argc > 5 && c == 2 && !strcmp(argv[5], "fullxzoom")) {
|
||||
xRect *r = &xctx->rect[c][n];
|
||||
Graph_ctx *gr = &xctx->graph_struct;
|
||||
int dataset;
|
||||
setup_graph_data(n, 0, gr);
|
||||
if(xctx->raw && gr->dataset >= 0 && gr->dataset < xctx->raw->datasets) dataset = gr->dataset;
|
||||
else dataset = -1;
|
||||
graph_fullxzoom(r, gr, dataset);
|
||||
graph_fullxzoom(n, gr, dataset);
|
||||
}
|
||||
if(argc > 5 && c == 2 && !strcmp(argv[5], "fullyzoom")) {
|
||||
xRect *r = &xctx->rect[c][n];
|
||||
|
|
@ -4492,12 +4527,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
char f[PATH_MAX + 100];
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
if(sch_waves_loaded() >= 0) {
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 1);
|
||||
tclsetvar("rawfile_loaded", "0");
|
||||
} else if(argc > 2) {
|
||||
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir);
|
||||
tcleval(f);
|
||||
my_strncpy(f, tclresult(), S(f));
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 0);
|
||||
table_read(f);
|
||||
if(sch_waves_loaded() >= 0) {
|
||||
|
|
@ -4527,17 +4564,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
|
||||
/* test [rawfile type]
|
||||
* testmode */
|
||||
else if(!strcmp(argv[1], "test"))
|
||||
{
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
if(argc > 3) read_more_rawfile(1, argv[2], argv[3]);
|
||||
else read_more_rawfile(2, NULL, NULL);
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
/* toggle_colorscheme
|
||||
* Toggle dark/light colorscheme */
|
||||
else if(!strcmp(argv[1], "toggle_colorscheme"))
|
||||
|
|
|
|||
|
|
@ -442,6 +442,9 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
|
|||
xctx->xorigin=CADINITIALX;
|
||||
xctx->yorigin=CADINITIALY;
|
||||
xctx->raw = NULL;
|
||||
xctx->extra_idx = 0;
|
||||
xctx->extra_prev_idx = 0;
|
||||
xctx->extra_raw_n = 0;
|
||||
xctx->graph_master = 0;
|
||||
xctx->graph_cursor1_x = 0;
|
||||
xctx->graph_flags = 0;
|
||||
|
|
@ -669,6 +672,7 @@ static void delete_schematic_data(int delete_pixmap)
|
|||
escape_chars(NULL);
|
||||
sanitize(NULL);
|
||||
is_generator(NULL);
|
||||
extra_rawfile(3, NULL, NULL);
|
||||
free_rawfile(&xctx->raw, 0);
|
||||
free_xschem_data(); /* delete the xctx struct */
|
||||
}
|
||||
|
|
|
|||
14
src/xschem.h
14
src/xschem.h
|
|
@ -273,6 +273,7 @@ extern char win_temp_dir[PATH_MAX];
|
|||
/* 1215497, 1823231, 2734867, 4102283, 6153409, 9230113, 13845163 */
|
||||
|
||||
#define HASHSIZE 31627
|
||||
#define MAX_RAW_N 50 /* max number of raw files that can be loaded */
|
||||
|
||||
/* parameters passed to action functions, see actions.c */
|
||||
#define END 1 /* endop */
|
||||
|
|
@ -1043,6 +1044,13 @@ typedef struct {
|
|||
|
||||
Raw *raw; /* spice simulation data struct pointer */
|
||||
|
||||
/* data for additional raw files */
|
||||
int extra_idx; /* current raw file */
|
||||
int extra_prev_idx; /* previous crrent (to switch back) */
|
||||
Raw *extra_raw_arr[MAX_RAW_N]; /* array of pointers to Raw structure */
|
||||
int extra_raw_n; /* number of elements in array */
|
||||
|
||||
|
||||
/* */
|
||||
/* data related to all graphs, so not stored in per-graph graph_struct */
|
||||
double graph_cursor1_x;
|
||||
|
|
@ -1202,7 +1210,7 @@ extern char *base64_encode(const unsigned char *data, const size_t input_length,
|
|||
extern unsigned char *ascii85_encode(const unsigned char *data, const size_t input_length, size_t *output_length);
|
||||
extern int get_raw_index(const char *node);
|
||||
extern void free_rawfile(Raw **rawptr, int dr);
|
||||
extern void read_more_rawfile(int what, const char *f, const char *type);
|
||||
extern void extra_rawfile(int what, const char *f, const char *type);
|
||||
extern int raw_read(const char *f, Raw **rawptr, const char *type);
|
||||
extern int table_read(const char *f);
|
||||
extern double get_raw_value(int dataset, int idx, int point);
|
||||
|
|
@ -1213,8 +1221,8 @@ extern int edit_wave_attributes(int what, int i, Graph_ctx *gr);
|
|||
extern void draw_graph(int i, int flags, Graph_ctx *gr, void *ct);
|
||||
extern int find_closest_wave(int i, Graph_ctx *gr);
|
||||
extern void setup_graph_data(int i, int skip, Graph_ctx *gr);
|
||||
extern int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset);
|
||||
extern int graph_fullxzoom(xRect *r, Graph_ctx *gr, int dataset);
|
||||
extern int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset);
|
||||
extern int graph_fullxzoom(int i, Graph_ctx *gr, int dataset);
|
||||
extern double timer(int start);
|
||||
extern void enable_layers(void);
|
||||
extern void set_snap(double);
|
||||
|
|
|
|||
|
|
@ -1908,10 +1908,18 @@ proc graph_update_nodelist {} {
|
|||
}
|
||||
|
||||
proc graph_fill_listbox {} {
|
||||
global graph_selected
|
||||
set retval [.graphdialog.top.search get]
|
||||
|
||||
set rawfile [xschem getprop rect 2 $graph_selected rawfile 0]
|
||||
puts "graph_fill_listbox: $rawfile"
|
||||
xschem raw switch $rawfile
|
||||
|
||||
set retval [graph_get_signal_list [xschem raw_query list] $retval]
|
||||
.graphdialog.center.left.list1 delete 0 end
|
||||
eval .graphdialog.center.left.list1 insert 0 $retval
|
||||
|
||||
xschem raw switch_back
|
||||
}
|
||||
|
||||
# called from event handlers (OK, KeyRelease, DoubleClick) in graph_edit_properties
|
||||
|
|
@ -2014,8 +2022,31 @@ proc graph_edit_properties {n} {
|
|||
|
||||
# center right frame
|
||||
label .graphdialog.center.right.lab1 -text { Signals in graph }
|
||||
if { [ info tclversion] > 8.4} {
|
||||
ttk::combobox .graphdialog.center.right.list -values {dc ac tran op sp} -width 4
|
||||
}
|
||||
|
||||
bind .graphdialog.center.right.list <<ComboboxSelected>> {
|
||||
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get]
|
||||
}
|
||||
|
||||
bind .graphdialog.center.right.list <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get]
|
||||
}
|
||||
|
||||
if { [xschem getprop rect 2 $graph_selected sim_type 2] ne {}} {
|
||||
.graphdialog.center.right.list set [xschem getprop rect 2 $graph_selected sim_type 2]
|
||||
} else {
|
||||
.graphdialog.center.right.list set tran
|
||||
}
|
||||
|
||||
label .graphdialog.center.right.rawlab -text { Raw file: }
|
||||
entry .graphdialog.center.right.rawentry -textvariable rawfile -width 30 -state disabled
|
||||
entry .graphdialog.center.right.rawentry -width 30
|
||||
bind .graphdialog.center.right.rawentry <KeyRelease> {
|
||||
xschem setprop rect 2 $graph_selected rawfile [.graphdialog.center.right.rawentry get]
|
||||
}
|
||||
.graphdialog.center.right.rawentry insert 0 [xschem getprop rect 2 $graph_selected rawfile 2]
|
||||
.graphdialog.center.right.rawentry xview moveto 1
|
||||
text .graphdialog.center.right.text1 -wrap none -width 50 -height 5 -bg grey70 -fg black \
|
||||
-insertbackground grey40 -exportselection 1 \
|
||||
-yscrollcommand {.graphdialog.center.right.yscroll set} \
|
||||
|
|
@ -2023,18 +2054,19 @@ proc graph_edit_properties {n} {
|
|||
scrollbar .graphdialog.center.right.yscroll -command {.graphdialog.center.right.text1 yview}
|
||||
scrollbar .graphdialog.center.right.xscroll -orient horiz -command {.graphdialog.center.right.text1 xview}
|
||||
|
||||
grid .graphdialog.center.right.lab1 .graphdialog.center.right.rawlab \
|
||||
grid .graphdialog.center.right.lab1 .graphdialog.center.right.list .graphdialog.center.right.rawlab \
|
||||
.graphdialog.center.right.rawentry -
|
||||
grid configure .graphdialog.center.right.rawentry -sticky ew
|
||||
grid .graphdialog.center.right.text1 - - .graphdialog.center.right.yscroll -sticky nsew
|
||||
grid .graphdialog.center.right.xscroll - - - -sticky ew
|
||||
grid .graphdialog.center.right.text1 - - - .graphdialog.center.right.yscroll -sticky nsew
|
||||
grid .graphdialog.center.right.xscroll - - - - -sticky ew
|
||||
grid rowconfig .graphdialog.center.right 0 -weight 0
|
||||
grid rowconfig .graphdialog.center.right 1 -weight 1 -minsize 3c
|
||||
grid rowconfig .graphdialog.center.right 2 -weight 0
|
||||
grid columnconfig .graphdialog.center.right 0 -weight 0
|
||||
grid columnconfig .graphdialog.center.right 1 -weight 0
|
||||
grid columnconfig .graphdialog.center.right 2 -weight 1
|
||||
grid columnconfig .graphdialog.center.right 3 -weight 0
|
||||
grid columnconfig .graphdialog.center.right 2 -weight 0
|
||||
grid columnconfig .graphdialog.center.right 3 -weight 1
|
||||
grid columnconfig .graphdialog.center.right 4 -weight 0
|
||||
|
||||
# bottom frame
|
||||
button .graphdialog.bottom.cancel -text Cancel -command {
|
||||
|
|
@ -2185,7 +2217,7 @@ proc graph_edit_properties {n} {
|
|||
checkbutton .graphdialog.top.bus -text Bus -padx 2 -variable graph_bus
|
||||
checkbutton .graphdialog.top.incr -text {Incr. sort} -variable graph_sort -indicatoron 1 \
|
||||
-command graph_fill_listbox
|
||||
checkbutton .graphdialog.top.rainbow -text {Rainbow colors} -variable graph_rainbow \
|
||||
checkbutton .graphdialog.top.rainbow -text {Rainbow col.} -variable graph_rainbow \
|
||||
-command {
|
||||
if { [xschem get schname] eq $graph_schname } {
|
||||
graph_push_undo
|
||||
|
|
@ -2205,7 +2237,7 @@ proc graph_edit_properties {n} {
|
|||
} else {
|
||||
.graphdialog.top.lwe insert 0 $custom_lw
|
||||
}
|
||||
checkbutton .graphdialog.top.unlocked -text {Unlocked X axis} -variable graph_unlocked
|
||||
checkbutton .graphdialog.top.unlocked -text {Unlock. X axis} -variable graph_unlocked
|
||||
checkbutton .graphdialog.top.dig -text {Digital} -variable graph_digital -indicatoron 1 \
|
||||
-command {
|
||||
if { [xschem get schname] eq $graph_schname } {
|
||||
|
|
@ -2362,7 +2394,7 @@ proc graph_edit_properties {n} {
|
|||
}
|
||||
|
||||
# fill data in left listbox
|
||||
eval .graphdialog.center.left.list1 insert 0 [graph_get_signal_list [xschem raw_query list] {}]
|
||||
graph_fill_listbox
|
||||
|
||||
# fill data in right textbox
|
||||
set plotted_nodes [xschem getprop rect 2 $n node 0]
|
||||
|
|
@ -5613,7 +5645,7 @@ set tctx::global_list {
|
|||
lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save
|
||||
no_change_attrs nolist_libs noprint_libs old_selected_tok only_probes path pathlist
|
||||
persistent_command preserve_unchanged_attrs prev_symbol ps_colors ps_paper_size rainbow_colors
|
||||
rawfile rawfile_loaded rcode recentfile
|
||||
rawfile_loaded rcode recentfile
|
||||
retval retval_orig rotated_text search_case search_exact search_found search_schematic
|
||||
search_select search_value selected_tok show_hidden_texts show_infowindow
|
||||
show_infowindow_after_netlist show_pin_net_names
|
||||
|
|
@ -6976,7 +7008,6 @@ if {$OS == "Windows"} {
|
|||
}
|
||||
|
||||
set rawfile_loaded 0
|
||||
set rawfile {}
|
||||
|
||||
# flag bound to a checkbutton in symbol editprop form
|
||||
# if set cell is copied when renaming it
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue