allow loading more and different analyses from the same raw file. Implied tcleval() in rawfile given in graphdialog, transform multiple saved OP sims into a dc sweep.
This commit is contained in:
parent
745e3fc5f4
commit
b165720bc8
14
src/draw.c
14
src/draw.c
|
|
@ -3220,6 +3220,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
/* draw stuff */
|
||||
if(flags & 8) {
|
||||
int k;
|
||||
int save_datasets = -1, save_npoints = -1;
|
||||
#if !defined(__unix__) && HAS_CAIRO==1
|
||||
double sw = (gr->sx2 - gr->sx1);
|
||||
double sh = (gr->sy2 - gr->sy1);
|
||||
|
|
@ -3238,6 +3239,15 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
extra_rawfile(1, custom_rawfile, sim_type[0] ? sim_type : xctx->raw->sim_type);
|
||||
}
|
||||
raw = xctx->raw;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
nptr = node;
|
||||
cptr = color;
|
||||
sptr = sweep;
|
||||
|
|
@ -3419,6 +3429,10 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
|
|||
++wcnt;
|
||||
if(bus_msb) my_free(_ALLOC_ID_, &bus_msb);
|
||||
} /* while( (ntok = my_strtok_r(nptr, "\n\t ", "", 0, &saven)) ) */
|
||||
if(save_npoints != -1) { /* restore multiple OP points from artificial dc sweep */
|
||||
raw->datasets = save_datasets;
|
||||
raw->npoints[0] = save_npoints;
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
136
src/save.c
136
src/save.c
|
|
@ -464,6 +464,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
int n = 0, done_header = 0, ac = 0;
|
||||
int exit_status = 0, npoints, nvars;
|
||||
int dbglev=1;
|
||||
const char *sim_type = NULL;
|
||||
Raw *raw;
|
||||
|
||||
if(!rawptr) {
|
||||
|
|
@ -475,7 +476,6 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
dbg(0, "read_dataset(): no raw struct allocated\n");
|
||||
return 0;
|
||||
}
|
||||
raw->sim_type = NULL;
|
||||
dbg(1, "read_dataset(): type=%s\n", type ? type : "<NULL>");
|
||||
while((line = my_fgets(fd, NULL))) {
|
||||
my_strdup2(_ALLOC_ID_, &lowerline, line);
|
||||
|
|
@ -493,7 +493,8 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
}
|
||||
/* after this line comes the binary blob made of nvars * npoints * sizeof(double) bytes */
|
||||
if(!strcmp(line, "Binary:\n") || !strcmp(line, "Binary:\r\n")) {
|
||||
if(raw->sim_type) {
|
||||
if(sim_type) {
|
||||
my_strdup(_ALLOC_ID_, &raw->sim_type, sim_type);
|
||||
done_header = 1;
|
||||
dbg(dbglev, "read_dataset(): read binary block, nvars=%d npoints=%d\n", nvars, npoints);
|
||||
read_binary_block(fd, raw, ac);
|
||||
|
|
@ -503,48 +504,42 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
dbg(dbglev, "read_dataset(): skip binary block, nvars=%d npoints=%d\n", nvars, npoints);
|
||||
fseek(fd, nvars * npoints * sizeof(double), SEEK_CUR); /* skip binary block */
|
||||
}
|
||||
sim_type = NULL; /* ready for next header */
|
||||
done_points = 0;
|
||||
ac = 0;
|
||||
}
|
||||
/* if type is given (not NULL) choose the simulation that matches type, else take the first one */
|
||||
/* if raw->sim_type is set skip all datasets that do not match */
|
||||
/* if sim_type is set skip all datasets that do not match */
|
||||
else if(!strncmp(line, "Plotname:", 9) && strstr(lowerline, "transient analysis")) {
|
||||
if(raw->sim_type && strcmp(raw->sim_type, "tran")) raw->sim_type = NULL;
|
||||
else if(type && !strcmp(type, "tran")) raw->sim_type = "tran";
|
||||
else if(type && strcmp(type, "tran")) raw->sim_type = NULL;
|
||||
else raw->sim_type = "tran";
|
||||
dbg(dbglev, "read_dataset(): tran raw->sim_type=%s\n", raw->sim_type ? raw->sim_type : "<NULL>");
|
||||
if(!type) type = "tran";
|
||||
if(!strcmp(type, "tran")) sim_type = "tran";
|
||||
dbg(dbglev, "read_dataset(): tran sim_type=%s\n", sim_type ? sim_type : "<NULL>");
|
||||
}
|
||||
else if(!strncmp(line, "Plotname:", 9) && strstr(lowerline, "dc transfer characteristic")) {
|
||||
if(raw->sim_type && strcmp(raw->sim_type, "dc")) raw->sim_type = NULL;
|
||||
else if(type && !strcmp(type, "dc")) raw->sim_type = "dc";
|
||||
else if(type && strcmp(type, "dc")) raw->sim_type = NULL;
|
||||
else raw->sim_type = "dc";
|
||||
dbg(dbglev, "read_dataset(): dc raw->sim_type=%s\n", raw->sim_type ? raw->sim_type : "<NULL>");
|
||||
if(!type) type = "dc";
|
||||
if(!strcmp(type, "dc")) sim_type = "dc";
|
||||
dbg(dbglev, "read_dataset(): dc sim_type=%s\n", sim_type ? sim_type : "<NULL>");
|
||||
}
|
||||
else if(!strncmp(line, "Plotname:", 9) && strstr(lowerline, "operating point")) {
|
||||
if(raw->sim_type && strcmp(raw->sim_type, "op")) raw->sim_type = NULL;
|
||||
else if(type && !strcmp(type, "op")) raw->sim_type = "op";
|
||||
else if(type && strcmp(type, "op")) raw->sim_type = NULL;
|
||||
else raw->sim_type = "op";
|
||||
dbg(dbglev, "read_dataset(): op raw->sim_type=%s\n", raw->sim_type ? raw->sim_type : "<NULL>");
|
||||
|
||||
if(!type) type = "op";
|
||||
if(!strcmp(type, "op")) sim_type = "op";
|
||||
dbg(dbglev, "read_dataset(): op sim_type=%s\n", sim_type ? sim_type : "<NULL>");
|
||||
}
|
||||
else if(!strncmp(line, "Plotname:", 9) &&
|
||||
( strstr(lowerline, "ac analysis") || strstr(lowerline, "sp analysis")) ) {
|
||||
ac = 1;
|
||||
if(raw->sim_type && strcmp(raw->sim_type, "ac")) raw->sim_type = NULL;
|
||||
else if(type && !strcmp(type, "ac")) raw->sim_type = "ac";
|
||||
else if(type && strcmp(type, "ac")) raw->sim_type = NULL;
|
||||
else raw->sim_type = "ac";
|
||||
dbg(dbglev, "read_dataset(): ac raw->sim_type=%s\n", raw->sim_type ? raw->sim_type : "<NULL>");
|
||||
if(!type) type = "ac";
|
||||
if(!strcmp(type, "ac")) sim_type = "ac";
|
||||
dbg(dbglev, "read_dataset(): ac sim_type=%s\n", sim_type ? sim_type : "<NULL>");
|
||||
}
|
||||
else if(!strncmp(line, "Plotname:", 9)) {
|
||||
char name[PATH_MAX];
|
||||
raw->sim_type = NULL;
|
||||
n = sscanf(line, "Plotname: %s", name);
|
||||
if(n==1) {
|
||||
if(raw->sim_type && strcmp(raw->sim_type, "custom")) raw->sim_type = NULL;
|
||||
else if(type && !strcmp(type, name)) raw->sim_type = "custom";
|
||||
if(!type) type = name;
|
||||
if(!strcmp(type, name)) sim_type = name;
|
||||
dbg(dbglev, "read_dataset(): ac sim_type=%s\n", sim_type ? sim_type : "<NULL>");
|
||||
}
|
||||
}
|
||||
/* points and vars are needed for all sections (also ones we are not interested in)
|
||||
|
|
@ -559,12 +554,12 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
}
|
||||
if(raw->sim_type) {
|
||||
if(sim_type) {
|
||||
my_realloc(_ALLOC_ID_, &raw->npoints, (raw->datasets+1) * sizeof(int));
|
||||
raw->npoints[raw->datasets] = npoints;
|
||||
/* multi-point OP is equivalent to a DC sweep. Change raw->sim_type */
|
||||
if(raw->npoints[raw->datasets] > 1 && !strcmp(raw->sim_type, "op") ) {
|
||||
raw->sim_type = "dc";
|
||||
/* multi-point OP is equivalent to a DC sweep. Change sim_type */
|
||||
if(raw->npoints[raw->datasets] > 1 && !strcmp(sim_type, "op") ) {
|
||||
sim_type = "dc";
|
||||
}
|
||||
}
|
||||
done_points = 1;
|
||||
|
|
@ -574,7 +569,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
dbg(dbglev, "read_dataset(): nvars=%d\n", nvars);
|
||||
|
||||
if(ac) nvars <<= 1;
|
||||
if(raw->datasets > 0 && raw->nvars != nvars && raw->sim_type) {
|
||||
if(raw->datasets > 0 && raw->nvars != nvars && sim_type) {
|
||||
dbg(0, "Xschem requires all datasets to be saved with identical and same number of variables\n");
|
||||
dbg(0, "There is a mismatch, so this and following datasets will not be read\n");
|
||||
/* exit_status = 1; */ /* do not set, if something useful has been read keep exit status as is */
|
||||
|
|
@ -588,7 +583,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
}
|
||||
if(raw->sim_type) {
|
||||
if(sim_type) {
|
||||
raw->nvars = nvars;
|
||||
}
|
||||
}
|
||||
|
|
@ -601,16 +596,16 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
exit_status = 0;
|
||||
goto read_dataset_done;
|
||||
}
|
||||
if(raw->sim_type) {
|
||||
if(sim_type) {
|
||||
my_realloc(_ALLOC_ID_, &raw->npoints, (raw->datasets+1) * sizeof(int));
|
||||
raw->npoints[raw->datasets] = npoints;
|
||||
/* multi-point OP is equivalent to a DC sweep. Change raw->sim_type */
|
||||
if(raw->npoints[raw->datasets] > 1 && !strcmp(raw->sim_type, "op") ) {
|
||||
raw->sim_type = "dc";
|
||||
/* multi-point OP is equivalent to a DC sweep. Change sim_type */
|
||||
if(raw->npoints[raw->datasets] > 1 && !strcmp(sim_type, "op") ) {
|
||||
sim_type = "dc";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(raw->sim_type && !done_header && variables) {
|
||||
if(sim_type && !done_header && variables) {
|
||||
char *ptr;
|
||||
/* get the list of lines with index and node name */
|
||||
if(!raw->names) raw->names = my_calloc(_ALLOC_ID_, raw->nvars, sizeof(char *));
|
||||
|
|
@ -631,7 +626,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
if(*ptr == ':') *ptr = '.';
|
||||
++ptr;
|
||||
}
|
||||
if(raw->sim_type && !strcmp(raw->sim_type, "ac")) { /* AC */
|
||||
if(sim_type && !strcmp(sim_type, "ac")) { /* AC */
|
||||
my_strcat(_ALLOC_ID_, &raw->names[i << 1], varname);
|
||||
int_hash_lookup(&raw->table, raw->names[i << 1], (i << 1), XINSERT_NOREPLACE);
|
||||
if(strstr(varname, "v(") == varname || strstr(varname, "i(") == varname)
|
||||
|
|
@ -647,7 +642,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
|
|||
dbg(dbglev, "read_dataset(): get node list -> names[%d] = %s\n", i, raw->names[i]);
|
||||
}
|
||||
/* after this line comes the list of indexes and associated nodes */
|
||||
if(raw->sim_type && !strncmp(line, "Variables:", 10)) {
|
||||
if(sim_type && !strncmp(line, "Variables:", 10)) {
|
||||
variables = 1 ;
|
||||
}
|
||||
my_free(_ALLOC_ID_, &line);
|
||||
|
|
@ -688,6 +683,7 @@ void free_rawfile(Raw **rawptr, int dr)
|
|||
}
|
||||
my_free(_ALLOC_ID_, &raw->values);
|
||||
}
|
||||
if(raw->sim_type) my_free(_ALLOC_ID_, &raw->sim_type);
|
||||
if(raw->npoints) my_free(_ALLOC_ID_, &raw->npoints);
|
||||
if(raw->filename) my_free(_ALLOC_ID_, &raw->filename);
|
||||
if(raw->schname) my_free(_ALLOC_ID_, &raw->schname);
|
||||
|
|
@ -795,9 +791,10 @@ int raw_read(const char *f, Raw **rawptr, const char *type)
|
|||
raw->allpoints += raw->npoints[i];
|
||||
}
|
||||
dbg(0, "Raw file data read: %s\n", f);
|
||||
dbg(0, "points=%d, vars=%d, datasets=%d\n",
|
||||
raw->allpoints, raw->nvars, raw->datasets);
|
||||
dbg(0, "points=%d, vars=%d, datasets=%d sim_type=%s\n",
|
||||
raw->allpoints, raw->nvars, raw->datasets, raw->sim_type ? raw->sim_type : "NULL");
|
||||
} else {
|
||||
free_rawfile(rawptr, 0);
|
||||
dbg(0, "raw_read(): no useful data found\n");
|
||||
}
|
||||
fclose(fd);
|
||||
|
|
@ -812,48 +809,69 @@ int raw_read(const char *f, Raw **rawptr, const char *type)
|
|||
* 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
|
||||
* return 1 if sucessfull, 0 otherwise
|
||||
*/
|
||||
void extra_rawfile(int what, const char *f, const char *type)
|
||||
int extra_rawfile(int what, const char *file, const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
dbg(1, "extra_rawfile(): what=%d, f=%s, type=%s\n", what, f ? f : "NULL", type ? type : "NULL");
|
||||
int ret = 1;
|
||||
char f[PATH_MAX];
|
||||
dbg(1, "extra_rawfile(): what=%d, file=%s, type=%s\n",
|
||||
what, file ? file : "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 */
|
||||
if(what == 1 && xctx->extra_raw_n < MAX_RAW_N && file && type) { /* read */
|
||||
tclvareval("subst {", file, "}", NULL);
|
||||
my_strncpy(f, tclresult(), S(f));
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) break;
|
||||
if(xctx->extra_raw_arr[i]->sim_type &&
|
||||
!strcmp(xctx->extra_raw_arr[i]->filename, f) &&
|
||||
!strcmp(xctx->extra_raw_arr[i]->sim_type, type)
|
||||
) break;
|
||||
}
|
||||
if(i >= xctx->extra_raw_n) { /* file not found: read it and switch to it */
|
||||
int ret = 0;
|
||||
if(i >= xctx->extra_raw_n) { /* file not found: read it and switch to it */
|
||||
int read_ret = 0;
|
||||
Raw *save;
|
||||
save = xctx->raw;
|
||||
xctx->raw = NULL;
|
||||
ret = raw_read(f, &xctx->raw, type);
|
||||
if(ret) {
|
||||
read_ret = raw_read(f, &xctx->raw, type);
|
||||
if(read_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;
|
||||
ret = 0; /* not found so did not switch */
|
||||
dbg(0, "extra_rawfile() read: %s %s not found\n", f, type);
|
||||
xctx->raw = save; /* restore */
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
}
|
||||
} else { /* file found: switch to it */
|
||||
dbg(1, "extra_rawfile() read: found: switch to it\n");
|
||||
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) {
|
||||
if(file && type) {
|
||||
tclvareval("subst {", file, "}", NULL);
|
||||
my_strncpy(f, tclresult(), S(f));
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) break;
|
||||
dbg(1, " extra_rawfile(): checking with %s\n", xctx->extra_raw_arr[i]->filename);
|
||||
if(xctx->extra_raw_arr[i]->sim_type &&
|
||||
!strcmp(xctx->extra_raw_arr[i]->filename, f) &&
|
||||
!strcmp(xctx->extra_raw_arr[i]->sim_type, type)
|
||||
) break;
|
||||
}
|
||||
if(i < xctx->extra_raw_n) { /* if file found switch to it ... */
|
||||
dbg(1, "extra_rawfile() switch: found: switch to it\n");
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
xctx->extra_idx = i;
|
||||
} else {
|
||||
dbg(0, "extra_rawfile() switch: %s %s not found\n", f, type);
|
||||
ret = 0;
|
||||
}
|
||||
} else { /* switch to next */
|
||||
xctx->extra_prev_idx = xctx->extra_idx;
|
||||
|
|
@ -867,7 +885,7 @@ void extra_rawfile(int what, const char *f, const char *type)
|
|||
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 */
|
||||
if(!file) { /* 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];
|
||||
|
|
@ -881,6 +899,8 @@ void extra_rawfile(int what, const char *f, const char *type)
|
|||
xctx->extra_raw_n = 0;
|
||||
} else { /* clear provided file if found, switch to first in remaining */
|
||||
int found = -1;
|
||||
tclvareval("subst {", file, "}", NULL);
|
||||
my_strncpy(f, tclresult(), S(f));
|
||||
if(xctx->extra_raw_n > 1 ) {
|
||||
for(i = 0; i < xctx->extra_raw_n; i++) {
|
||||
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) {
|
||||
|
|
@ -895,18 +915,20 @@ void extra_rawfile(int what, const char *f, const char *type)
|
|||
xctx->extra_idx = 0;
|
||||
xctx->extra_prev_idx = 0;
|
||||
xctx->raw = xctx->extra_raw_arr[0];
|
||||
}
|
||||
}
|
||||
} else ret = 0;
|
||||
} else ret = 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);
|
||||
Tcl_AppendResult(interp, my_itoa(i), " ", xctx->extra_raw_arr[i]->filename, " ",
|
||||
xctx->extra_raw_arr[i]->sim_type ? xctx->extra_raw_arr[i]->sim_type : "NULL", "\n", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Read data organized as a table
|
||||
|
|
|
|||
|
|
@ -3080,23 +3080,28 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
if(!strcmp(argv[1], "raw"))
|
||||
{
|
||||
int err = 0;
|
||||
int ret = 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);
|
||||
if(argc > 4) ret = extra_rawfile(1, argv[3], argv[4]);
|
||||
else ret = extra_rawfile(1, argv[3], NULL);
|
||||
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "switch")) {
|
||||
if(argv[3]) {
|
||||
extra_rawfile(2, argv[3], NULL);
|
||||
if(argc > 4) {
|
||||
ret = extra_rawfile(2, argv[3], argv[4]);
|
||||
} else {
|
||||
extra_rawfile(2, NULL, NULL);
|
||||
ret = extra_rawfile(2, NULL, NULL);
|
||||
}
|
||||
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "info")) {
|
||||
extra_rawfile(4, NULL, NULL);
|
||||
ret = extra_rawfile(4, NULL, NULL);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "switch_back")) {
|
||||
extra_rawfile(5, NULL, NULL);
|
||||
ret = extra_rawfile(5, NULL, NULL);
|
||||
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
|
||||
} else if(argc > 2 && !strcmp(argv[2], "clear")) {
|
||||
if(argc > 3) extra_rawfile(3, argv[3], NULL);
|
||||
else extra_rawfile(3, NULL, NULL);
|
||||
if(argc > 3) ret = extra_rawfile(3, argv[3], NULL);
|
||||
else ret = extra_rawfile(3, NULL, NULL);
|
||||
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
|
||||
} else {
|
||||
err = 1;
|
||||
}
|
||||
|
|
@ -3173,7 +3178,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
idx = get_raw_index(argv[3]);
|
||||
if(argc > 4) dataset = atoi(argv[4]);
|
||||
if(idx >= 0) {
|
||||
int np = raw->npoints[dataset];
|
||||
int np;
|
||||
if(dataset < 0 )
|
||||
np = raw->allpoints;
|
||||
else
|
||||
np = raw->npoints[dataset];
|
||||
Tcl_ResetResult(interp);
|
||||
for(p = 0; p < np; p++) {
|
||||
sprintf(n, "%.10e", get_raw_value(dataset, idx, p));
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ typedef struct {
|
|||
int allpoints; /* all points of all datasets combined */
|
||||
int datasets;
|
||||
Int_hashtable table;
|
||||
const char *sim_type; /* type of sim, "tran", "dc", "ac", "op", ... */
|
||||
char *sim_type; /* type of sim, "tran", "dc", "ac", "op", ... */
|
||||
int annot_p; /* point in raw file to use for annotating schematic voltages/currents/etc
|
||||
* this is the closest available simulated point *before* the point
|
||||
* calculated from mouse in graph */
|
||||
|
|
@ -1210,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 extra_rawfile(int what, const char *f, const char *type);
|
||||
extern int 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);
|
||||
|
|
|
|||
133
src/xschem.tcl
133
src/xschem.tcl
|
|
@ -199,7 +199,7 @@ proc completer { text start end line } { return {}}
|
|||
# set 'var' with '$val' if 'var' not existing
|
||||
proc set_ne { var val } {
|
||||
upvar #0 $var v
|
||||
if { ![ info exists v ] } {
|
||||
if { ![info exists v ] } {
|
||||
set v $val
|
||||
}
|
||||
}
|
||||
|
|
@ -1911,15 +1911,24 @@ 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]
|
||||
set rawfile [uplevel #0 {subst [xschem getprop rect 2 $graph_selected rawfile 2]}]
|
||||
set sim_type [uplevel #0 {subst [xschem getprop rect 2 $graph_selected sim_type 2]}]
|
||||
# puts "graph_fill_listbox: $rawfile $sim_type"
|
||||
if {$rawfile ne {}} {
|
||||
set res [xschem raw switch $rawfile $sim_type]
|
||||
if {$res} {
|
||||
set retval [graph_get_signal_list [xschem raw_query list] $retval]
|
||||
} else {
|
||||
set retval {}
|
||||
}
|
||||
# puts "switch back"
|
||||
xschem raw switch_back
|
||||
} else {
|
||||
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
|
||||
|
|
@ -2022,28 +2031,47 @@ proc graph_edit_properties {n} {
|
|||
|
||||
# center right frame
|
||||
label .graphdialog.center.right.lab1 -text { Signals in graph }
|
||||
if { [ info tclversion] > 8.4} {
|
||||
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
|
||||
entry .graphdialog.center.right.list -width 4
|
||||
}
|
||||
if { [info tclversion] > 8.4} {
|
||||
bind .graphdialog.center.right.list <<ComboboxSelected>> {
|
||||
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
|
||||
if {[file exists [subst [.graphdialog.center.right.rawentry get]]]} {
|
||||
graph_fill_listbox
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
} else {
|
||||
.graphdialog.center.right.list delete 0 end
|
||||
if { [xschem getprop rect 2 $graph_selected sim_type 2] ne {}} {
|
||||
.graphdialog.center.right.list insert 0 [xschem getprop rect 2 $graph_selected sim_type 2]
|
||||
} else {
|
||||
.graphdialog.center.right.list insert 0 tran
|
||||
}
|
||||
}
|
||||
|
||||
bind .graphdialog.center.right.list <FocusOut> {
|
||||
xschem setprop rect 2 $graph_selected sim_type [.graphdialog.center.right.list get] fast
|
||||
if {[file exists [subst [.graphdialog.center.right.rawentry get]]]} {
|
||||
graph_fill_listbox
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
label .graphdialog.center.right.rawlab -text { Raw file: }
|
||||
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]
|
||||
bind .graphdialog.center.right.rawentry <FocusOut> {
|
||||
xschem setprop rect 2 $graph_selected rawfile [.graphdialog.center.right.rawentry get] fast
|
||||
if {[file exists [subst [.graphdialog.center.right.rawentry get]]]} {
|
||||
graph_fill_listbox
|
||||
}
|
||||
}
|
||||
.graphdialog.center.right.rawentry insert 0 [xschem getprop rect 2 $graph_selected rawfile 2]
|
||||
.graphdialog.center.right.rawentry xview moveto 1
|
||||
|
|
@ -2138,19 +2166,19 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top2.labdivx -text { X div.}
|
||||
entry .graphdialog.top2.divx -width 2
|
||||
bind .graphdialog.top2.divx <KeyRelease> {
|
||||
bind .graphdialog.top2.divx <FocusOut> {
|
||||
graph_update_div $graph_selected divx
|
||||
}
|
||||
|
||||
label .graphdialog.top2.labdivy -text { Y div.}
|
||||
entry .graphdialog.top2.divy -width 2
|
||||
bind .graphdialog.top2.divy <KeyRelease> {
|
||||
bind .graphdialog.top2.divy <FocusOut> {
|
||||
graph_update_div $graph_selected divy
|
||||
}
|
||||
|
||||
label .graphdialog.top2.labsubdivx -text { X subdiv.}
|
||||
entry .graphdialog.top2.subdivx -width 2
|
||||
bind .graphdialog.top2.subdivx <KeyRelease> {
|
||||
bind .graphdialog.top2.subdivx <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected subdivx [.graphdialog.top2.subdivx get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2158,7 +2186,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top2.labsubdivy -text { Y subdiv.}
|
||||
entry .graphdialog.top2.subdivy -width 2
|
||||
bind .graphdialog.top2.subdivy <KeyRelease> {
|
||||
bind .graphdialog.top2.subdivy <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected subdivy [.graphdialog.top2.subdivy get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2166,7 +2194,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top2.labdset -text { Dataset}
|
||||
entry .graphdialog.top2.dset -width 4
|
||||
bind .graphdialog.top2.dset <KeyRelease> {
|
||||
bind .graphdialog.top2.dset <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected dataset [.graphdialog.top2.dset get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2175,11 +2203,20 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top2.labsweep -text { Sweep}
|
||||
entry .graphdialog.top2.sweep -width 10
|
||||
bind .graphdialog.top2.sweep <KeyRelease> {
|
||||
|
||||
# bind .graphdialog.top2.sweep <KeyRelease> {
|
||||
# graph_push_undo
|
||||
# xschem setprop rect 2 $graph_selected sweep [.graphdialog.top2.sweep get]
|
||||
# xschem draw_graph $graph_selected
|
||||
# }
|
||||
|
||||
bind .graphdialog.top2.sweep <FocusOut> {
|
||||
puts [.graphdialog.top2.sweep get]
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected sweep [.graphdialog.top2.sweep get]
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
}
|
||||
|
||||
.graphdialog.top2.sweep insert 0 [xschem getprop rect 2 $graph_selected sweep]
|
||||
|
||||
set graph_divx [xschem getprop rect 2 $graph_selected divx]
|
||||
|
|
@ -2227,7 +2264,7 @@ proc graph_edit_properties {n} {
|
|||
}
|
||||
label .graphdialog.top.lw -text " Line width:"
|
||||
entry .graphdialog.top.lwe -width 4
|
||||
bind .graphdialog.top.lwe <KeyRelease> {
|
||||
bind .graphdialog.top.lwe <FocusOut> {
|
||||
graph_set_linewidth $graph_selected
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
|
|
@ -2248,14 +2285,14 @@ proc graph_edit_properties {n} {
|
|||
}
|
||||
label .graphdialog.top3.xlabmin -text { X min:}
|
||||
entry .graphdialog.top3.xmin -width 7
|
||||
bind .graphdialog.top3.xmin <KeyRelease> {
|
||||
bind .graphdialog.top3.xmin <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected x1 [.graphdialog.top3.xmin get]
|
||||
xschem draw_graph $graph_selected
|
||||
}
|
||||
label .graphdialog.top3.xlabmax -text { X max:}
|
||||
entry .graphdialog.top3.xmax -width 7
|
||||
bind .graphdialog.top3.xmax <KeyRelease> {
|
||||
bind .graphdialog.top3.xmax <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected x2 [.graphdialog.top3.xmax get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2264,7 +2301,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top3.ylabmin -text { Y min:}
|
||||
entry .graphdialog.top3.ymin -width 7
|
||||
bind .graphdialog.top3.ymin <KeyRelease> {
|
||||
bind .graphdialog.top3.ymin <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected y1 [.graphdialog.top3.ymin get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2272,7 +2309,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top3.ylabmax -text { Y max:}
|
||||
entry .graphdialog.top3.ymax -width 7
|
||||
bind .graphdialog.top3.ymax <KeyRelease> {
|
||||
bind .graphdialog.top3.ymax <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected y2 [.graphdialog.top3.ymax get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2280,7 +2317,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top3.xlabmag -text { X/Y lab mag:}
|
||||
entry .graphdialog.top3.xmag -width 4
|
||||
bind .graphdialog.top3.xmag <KeyRelease> {
|
||||
bind .graphdialog.top3.xmag <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected xlabmag [.graphdialog.top3.xmag get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2288,7 +2325,7 @@ proc graph_edit_properties {n} {
|
|||
|
||||
label .graphdialog.top3.ylabmag -text { }
|
||||
entry .graphdialog.top3.ymag -width 4
|
||||
bind .graphdialog.top3.ymag <KeyRelease> {
|
||||
bind .graphdialog.top3.ymag <FocusOut> {
|
||||
graph_push_undo
|
||||
xschem setprop rect 2 $graph_selected ylabmag [.graphdialog.top3.ymag get]
|
||||
xschem draw_graph $graph_selected
|
||||
|
|
@ -2368,7 +2405,7 @@ proc graph_edit_properties {n} {
|
|||
.graphdialog.top3.xlabmag .graphdialog.top3.xmag .graphdialog.top3.ylabmag .graphdialog.top3.ymag \
|
||||
-fill x -expand yes -side left
|
||||
# binding
|
||||
bind .graphdialog.top.search <KeyRelease> {
|
||||
bind .graphdialog.top.search <FocusOut> {
|
||||
graph_fill_listbox
|
||||
}
|
||||
bind .graphdialog.center.left.list1 <Double-Button-1> {
|
||||
|
|
@ -2378,7 +2415,7 @@ proc graph_edit_properties {n} {
|
|||
}
|
||||
}
|
||||
|
||||
bind .graphdialog.center.right.text1 <KeyRelease> {
|
||||
bind .graphdialog.center.right.text1 <FocusOut> {
|
||||
if { [xschem get schname] eq $graph_schname } {
|
||||
graph_update_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"]
|
||||
}
|
||||
|
|
@ -3022,7 +3059,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
|
|||
"
|
||||
|
||||
### update
|
||||
if { [ info exists myload_sash_pos] } {
|
||||
if { [info exists myload_sash_pos] } {
|
||||
eval .load.l sash mark 0 [.load.l sash coord 0]
|
||||
eval .load.l sash dragto 0 [subst $myload_sash_pos]
|
||||
}
|
||||
|
|
@ -3100,7 +3137,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
|
|||
set myload_retval { }
|
||||
}
|
||||
};# bind .load.l.paneright.list <<ListboxSelect>>
|
||||
if { [ info exists myload_yview]} {
|
||||
if { [info exists myload_yview]} {
|
||||
.load.l.paneright.list yview moveto [lindex $myload_yview 0]
|
||||
}
|
||||
if {$loadfile != 2} {
|
||||
|
|
@ -3142,7 +3179,7 @@ proc path_head {s n } {
|
|||
|
||||
|
||||
proc delete_files { dir } {
|
||||
if { [ info tclversion] >=8.4} {
|
||||
if { [info tclversion] >=8.4} {
|
||||
set x [tk_getOpenFile -title "DELETE FILES" -multiple 1 -initialdir [file dirname $dir] ]
|
||||
} else {
|
||||
set x [tk_getOpenFile -title "DELETE FILES" -initialdir [file dirname $dir] ]
|
||||
|
|
@ -4212,7 +4249,7 @@ proc edit_prop {txtlabel} {
|
|||
set selected_tok {<ALL>}
|
||||
set old_selected_tok {<ALL>}
|
||||
label .dialog.f2.r4 -text { Edit Attr:}
|
||||
if { [ info tclversion] > 8.4} {
|
||||
if { [info tclversion] > 8.4} {
|
||||
ttk::combobox .dialog.f2.r5 -values $tok_list -textvariable selected_tok -width 14
|
||||
}
|
||||
pack .dialog.f1.l2 .dialog.f1.e2 .dialog.f1.b1 .dialog.f1.b2 .dialog.f1.b3 \
|
||||
|
|
@ -4226,7 +4263,7 @@ proc edit_prop {txtlabel} {
|
|||
pack .dialog.f2.r2 -side left
|
||||
pack .dialog.f2.r3 -side left
|
||||
pack .dialog.f2.r4 -side left
|
||||
if { [ info tclversion] > 8.4 } { pack .dialog.f2.r5 -side left }
|
||||
if { [info tclversion] > 8.4 } { pack .dialog.f2.r5 -side left }
|
||||
pack .dialog.yscroll -side right -fill y
|
||||
pack .dialog.xscroll -side bottom -fill x
|
||||
pack .dialog.symprop -fill both -expand yes
|
||||
|
|
@ -4237,7 +4274,7 @@ proc edit_prop {txtlabel} {
|
|||
.dialog.f1.b2 invoke
|
||||
}
|
||||
}
|
||||
if { [ info tclversion] > 8.4} {
|
||||
if { [info tclversion] > 8.4} {
|
||||
bind .dialog.f2.r5 <<ComboboxSelected>> {
|
||||
if {$old_selected_tok ne $selected_tok} {
|
||||
if { $old_selected_tok eq {<ALL>} } {
|
||||
|
|
@ -4390,7 +4427,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
|
|||
.dialog.textinput delete 1.0 end
|
||||
}
|
||||
label .dialog.f1.r4 -text { Edit Attr:}
|
||||
if { [ info tclversion] > 8.4} {
|
||||
if { [info tclversion] > 8.4} {
|
||||
ttk::combobox .dialog.f1.r5 -values $tok_list -textvariable selected_tok -width 14
|
||||
}
|
||||
checkbutton .dialog.f0.l2 -text "preserve unchanged props" -variable preserve_unchanged_attrs \
|
||||
|
|
@ -4404,7 +4441,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
|
|||
pack .dialog.f1.b3 -side left -fill x -expand yes
|
||||
pack .dialog.f1.b4 -side left -fill x -expand yes
|
||||
pack .dialog.f1.r4 -side left
|
||||
if { [ info tclversion] > 8.4} {pack .dialog.f1.r5 -side left}
|
||||
if { [info tclversion] > 8.4} {pack .dialog.f1.r5 -side left}
|
||||
|
||||
|
||||
pack .dialog.yscroll -side right -fill y
|
||||
|
|
@ -4416,7 +4453,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
|
|||
}
|
||||
}
|
||||
|
||||
if { [ info tclversion] > 8.4} {
|
||||
if { [info tclversion] > 8.4} {
|
||||
bind .dialog.f1.r5 <<ComboboxSelected>> {
|
||||
if {$old_selected_tok ne $selected_tok} {
|
||||
if { $old_selected_tok eq {<ALL>} } {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue