some parameter checks in xschem commands, global var removal in simulation help window - No use for production yet

This commit is contained in:
Stefan Frederik 2021-11-16 22:28:10 +01:00
parent 290fc3c793
commit ad05513838
31 changed files with 1302 additions and 951 deletions

View File

@ -18,6 +18,9 @@ $(BIN)/gui/find_gtk2.o: $(SRC)/gui/find_gtk2.c
$(BIN)/gui/find_gtk3.o: $(SRC)/gui/find_gtk3.c
$(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk3.c -o $(BIN)/gui/find_gtk3.o
$(BIN)/gui/find_gtk4.o: $(SRC)/gui/find_gtk4.c
$(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk4.c -o $(BIN)/gui/find_gtk4.o
$(BIN)/gui/find_lesstif2.o: $(SRC)/gui/find_lesstif2.c
$(CC) $(CFLAGS) -c $(SRC)/gui/find_lesstif2.c -o $(BIN)/gui/find_lesstif2.o

View File

@ -94,3 +94,33 @@ int find_gtk4_modversion(const char *name, int logdepth, int fatal)
}
int find_epoxy(const char *name, int logdepth, int fatal)
{
static const char *node = "libs/gui/epoxy";
static const char *pkgname = "epoxy";
const char *test_c =
NL "#include <stdio.h>"
NL "#include <epoxy/gl.h>"
NL "int main() {"
NL " const char *list = \"foo bar baz\";"
NL " if (epoxy_extension_in_string(list, \"bar\") && !epoxy_extension_in_string(list, \"foobar\"))"
NL " printf(\"OK\\n\");"
NL " return 0;"
NL "}"
NL;
if (require("cc/cc", logdepth, fatal))
return try_fail(logdepth, node);
report("Checking for epoxy... ");
logprintf(logdepth, "find_epoxy: running pkg-config...\n");
logdepth++;
if (try_icl_pkg_config(logdepth, node, test_c, NULL, "epoxy", NULL))
return 0;
if (try_icl(logdepth, node, test_c, NULL, "", "-lepoxy"))
return 0;
return try_fail(logdepth, node);
}

View File

@ -1,4 +1,6 @@
int find_gtk4(const char *name, int logdepth, int fatal);
int find_gtk4_modversion(const char *name, int logdepth, int fatal);
int find_epoxy(const char *name, int logdepth, int fatal, const char *call, const char *arg);

View File

@ -29,6 +29,7 @@ void deps_gui_init()
dep_add("libs/gui/gtk3/*", find_gtk3);
dep_add("libs/gui/gtk4/*", find_gtk4);
dep_add("libs/gui/gtk4/modversion", find_gtk4_modversion);
dep_add("libs/gui/epoxy/*", find_epoxy);
dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi);
dep_add("libs/gui/lesstif2/*", find_lesstif2);
dep_add("libs/gui/libstroke/*", find_libstroke);

View File

@ -33,17 +33,20 @@ void here(int i)
void set_modify(int mod)
{
static int prev = -1;
char *top_path;
top_path = xctx->top_path[0] ? xctx->top_path : ".";
xctx->modified = mod;
dbg(1, "set_modify(): %d\n", mod);
if(mod != prev) {
prev = mod;
if(has_x && strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font")) {
if(mod == 1) {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]*\"");
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]*\"");
Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL);
Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL);
} else {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\"");
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\"");
Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
}
}
}
@ -118,9 +121,9 @@ void set_snap(double newsnap) /* 20161212 set new snap factor and just notify n
}
cs = newsnap ? newsnap : default_snap;
if(cs == default_snap) {
tcleval(".statusbar.3 configure -background PaleGreen");
Tcl_VarEval(interp, xctx->top_path, ".statusbar.3 configure -background PaleGreen", NULL);
} else {
tcleval(".statusbar.3 configure -background OrangeRed");
Tcl_VarEval(interp, xctx->top_path, ".statusbar.3 configure -background OrangeRed", NULL);
}
tclsetdoublevar("cadsnap", cs);
}
@ -138,9 +141,9 @@ void set_grid(double newgrid)
cg = newgrid ? newgrid : default_grid;
dbg(1, "set_grid(): default_grid = %.16g, cadgrid=%.16g\n", default_grid, cg);
if(cg == default_grid) {
tcleval(".statusbar.5 configure -background PaleGreen");
Tcl_VarEval(interp, xctx->top_path, ".statusbar.5 configure -background PaleGreen", NULL);
} else {
tcleval(".statusbar.5 configure -background OrangeRed");
Tcl_VarEval(interp, xctx->top_path, ".statusbar.5 configure -background OrangeRed", NULL);
}
tclsetdoublevar("cadgrid", cg);
}
@ -213,7 +216,6 @@ void toggle_only_probes()
void toggle_fullscreen(const char *topwin)
{
char *mytopwin = NULL;
char fullscr[]="add,fullscreen";
char normal[]="remove,fullscreen";
static int menu_removed = 0;
@ -225,13 +227,10 @@ void toggle_fullscreen(const char *topwin)
if(!strcmp(topwin, ".drw")) {
my_strdup2(1290, &mytopwin, "");
tcleval( "winfo id .");
sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id);
} else {
Tcl_VarEval(interp, "winfo toplevel ", topwin, NULL);
my_strdup2(1291, &mytopwin, tclresult());
Tcl_VarEval(interp, "winfo id ", mytopwin, NULL);
Tcl_VarEval(interp, "winfo id ", xctx->top_path, NULL);
sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id);
}
@ -246,12 +245,13 @@ void toggle_fullscreen(const char *topwin)
dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs);
if(fs==2) {
Tcl_VarEval(interp, "pack forget ", mytopwin, ".menubar ", mytopwin, ".statusbar; update", NULL);
Tcl_VarEval(interp, "pack forget ", xctx->top_path, ".menubar ", xctx->top_path, ".statusbar; update", NULL);
menu_removed = 1;
}
if(fs !=2 && menu_removed) {
Tcl_VarEval(interp, "pack ", mytopwin, ".menubar -anchor n -side top -fill x -before ", mytopwin, ".drw\n\
pack ", mytopwin, ".statusbar -after ", mytopwin, ".drw -anchor sw -fill x; update", NULL);
Tcl_VarEval(interp, "pack ", xctx->top_path,
".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ",
xctx->top_path, ".statusbar -after ", xctx->top_path, ".drw -anchor sw -fill x; update", NULL);
menu_removed=0;
}
@ -265,7 +265,6 @@ void toggle_fullscreen(const char *topwin)
window_state(display , parent_id,normal);
}
xctx->pending_fullzoom=1;
my_free(1291, &mytopwin);
}
#ifdef __unix__
@ -312,12 +311,12 @@ void new_window(const char *cell, int symbol)
} else {
/* error */
fprintf(errfp, "new_window(): fork error 1\n");
tcleval( "exit");
tcleval("exit");
}
} else {
/* error */
fprintf(errfp, "new_window(): fork error 2\n");
tcleval( "exit");
tcleval("exit");
}
}
#else
@ -597,15 +596,15 @@ void enable_layers(void)
{
int i;
char tmp[50];
n_active_layers = 0;
xctx->n_active_layers = 0;
for(i = 0; i< cadlayers; i++) {
my_snprintf(tmp, S(tmp), "enable_layer(%d)",i);
if(tclgetvar(tmp)[0] == '0') enable_layer[i] = 0;
if(tclgetvar(tmp)[0] == '0') xctx->enable_layer[i] = 0;
else {
enable_layer[i] = 1;
xctx->enable_layer[i] = 1;
if(i>=7) {
active_layer[n_active_layers] = i;
n_active_layers++;
xctx->active_layer[xctx->n_active_layers] = i;
xctx->n_active_layers++;
}
}
}
@ -921,9 +920,9 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
if(draw_sym & 4 ) {
select_element(n, SELECTED,0, 0);
drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
xctx->need_reb_sel_arr = 1;
rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION; */
}
@ -1142,7 +1141,7 @@ void go_back(int confirm) /* 20171006 add confirm */
int prev_sch_type;
save_ok=0;
prev_sch_type = netlist_type; /* if CAD_SYMBOL_ATTRS do not hilight_parent_pins */
prev_sch_type = xctx->netlist_type; /* if CAD_SYMBOL_ATTRS do not hilight_parent_pins */
if(xctx->currsch>0)
{
/* if current sym/schematic is changed ask save before going up */
@ -1528,12 +1527,12 @@ void zoom_rectangle(int what)
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
bbox(END,0.0, 0.0, 0.0, 0.0);
xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2;
RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(xctx->gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
}
@ -1563,7 +1562,7 @@ void draw_stuff(void)
xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2, xRECT,xctx->rectcolor, 0, NULL);
#else
drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
#endif
}
@ -1580,7 +1579,7 @@ void draw_stuff(void)
xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2,xRECT,xctx->rectcolor, 0, NULL);
#else
drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
#endif
}
@ -1597,11 +1596,11 @@ void draw_stuff(void)
xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4;
storeobject(-1, x1, y1, x2, y2,xRECT,xctx->rectcolor, 0, NULL);
#else
drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2);
#endif
}
#ifndef STORE
drawtemprect(gc[xctx->rectcolor], END, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[xctx->rectcolor], END, 0.0, 0.0, 0.0, 0.0);
}
#else
draw();
@ -1618,7 +1617,7 @@ void restore_selection(double x1, double y1, double x2, double y2)
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xx1, yy1, xx2, yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
bbox(END,0.0, 0.0, 0.0, 0.0);
}
@ -1703,27 +1702,27 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
} else if(xctx->manhattan_lines==2) {
xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap;
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
} else {
xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap;
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
}
xctx->ui_state |= STARTWIRE;
@ -1747,11 +1746,11 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
} else if(xctx->manhattan_lines==2) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
@ -1768,11 +1767,11 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
}
} else {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
@ -1785,7 +1784,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
}
}
@ -1872,7 +1871,7 @@ void new_arc(int what, double sweep)
xctx->nl_yy2 = xctx->mousey_snap;
xctx->nl_xx1 = xctx->nl_x1;xctx->nl_yy1 = xctx->nl_y1;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
else if(xctx->nl_state==1) {
xctx->nl_x3 = xctx->mousex_snap;
@ -1881,7 +1880,7 @@ void new_arc(int what, double sweep)
arc_3_points(xctx->nl_x1, xctx->nl_y1, xctx->nl_x2, xctx->nl_y2,
xctx->nl_x3, xctx->nl_y3, &xctx->nl_x, &xctx->nl_y, &xctx->nl_r, &xctx->nl_a, &xctx->nl_b);
if(xctx->nl_sweep_angle==360.) xctx->nl_b=360.;
if(xctx->nl_r>0.) drawtemparc(gc[xctx->rectcolor], NOW, xctx->nl_x, xctx->nl_y, xctx->nl_r, xctx->nl_a, xctx->nl_b);
if(xctx->nl_r>0.) drawtemparc(xctx->gc[xctx->rectcolor], NOW, xctx->nl_x, xctx->nl_y, xctx->nl_r, xctx->nl_a, xctx->nl_b);
}
}
}
@ -1956,11 +1955,11 @@ void new_line(int what)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
} else if(xctx->manhattan_lines==2) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
@ -1977,11 +1976,11 @@ void new_line(int what)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
}
} else {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
@ -1994,7 +1993,7 @@ void new_line(int what)
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
}
}
@ -2010,11 +2009,11 @@ void new_rect(int what)
RECTORDER(xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2);
push_undo();
drawrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2, 0);
save_draw = draw_window;
draw_window = 1;
save_draw = xctx->draw_window;
xctx->draw_window = 1;
/* draw fill pattern even in XCopyArea mode */
filledrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2);
draw_window = save_draw;
xctx->draw_window = save_draw;
storeobject(-1, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2,xRECT,xctx->rectcolor, 0, NULL);
}
xctx->nl_x1=xctx->nl_x2=xctx->mousex_snap;xctx->nl_y1=xctx->nl_y2=xctx->mousey_snap;
@ -2032,7 +2031,7 @@ void new_rect(int what)
xctx->nl_x2=xctx->mousex_snap;xctx->nl_y2=xctx->mousey_snap;
xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2;
RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
}
@ -2088,7 +2087,7 @@ void new_polygon(int what)
drawtemppolygon(xctx->gctiled, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1);
store_poly(-1, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points, xctx->rectcolor, 0, NULL);
/* fprintf(errfp, "new_poly: finish: nl_points=%d\n", xctx->nl_points); */
drawtemppolygon(gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points);
drawtemppolygon(xctx->gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points);
xctx->ui_state &= ~STARTPOLYGON;
drawpolygon(xctx->rectcolor, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points, 0, 0);
my_free(711, &xctx->nl_polyx);
@ -2101,7 +2100,7 @@ void new_polygon(int what)
drawtemppolygon(xctx->gctiled, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1);
xctx->nl_polyy[xctx->nl_points] = xctx->mousey_snap;
xctx->nl_polyx[xctx->nl_points] = xctx->mousex_snap;
drawtemppolygon(gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1);
drawtemppolygon(xctx->gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1);
}
}
@ -2326,12 +2325,12 @@ int place_text(int draw_text, double mx, double my)
cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight);
}
#endif
save_draw=draw_window;
draw_window=1;
save_draw=xctx->draw_window;
xctx->draw_window=1;
if(draw_text) {
draw_string(textlayer, NOW, t->txt_ptr, 0, 0, t->hcenter, t->vcenter, t->x0,t->y0, t->xscale, t->yscale);
}
draw_window = save_draw;
xctx->draw_window = save_draw;
#if HAS_CAIRO==1
if((textfont && textfont[0]) || t->flags) {
cairo_restore(xctx->cairo_ctx);
@ -2341,8 +2340,8 @@ int place_text(int draw_text, double mx, double my)
xctx->texts++;
select_text(xctx->texts - 1, SELECTED, 0);
rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION */
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
set_modify(1);
return 1;
}
@ -2386,7 +2385,7 @@ void pan(int what)
xpan2=xctx->mousex_snap;ypan2=xctx->mousey_snap;
xx1=xpan;yy1=ypan;xx2=xpan2;yy2=ypan2;
ORDER(xx1,yy1,xx2,yy2);
drawtempline(gc[SELLAYER], NOW, xx1,yy1,xx2,yy2);
drawtempline(xctx->gc[SELLAYER], NOW, xx1,yy1,xx2,yy2);
}
if(what & START)
{
@ -2420,12 +2419,12 @@ void select_rect(int what, int select)
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
if(!xctx->nl_sel) select_inside(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel);
bbox(END,0.0, 0.0, 0.0, 0.0);
xctx->nl_xx1=xctx->nl_xr;xctx->nl_xx2=xctx->nl_xr2;xctx->nl_yy1=xctx->nl_yr;xctx->nl_yy2=xctx->nl_yr2;
RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtemprect(xctx->gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
else if(what & START)
{
@ -2452,14 +2451,14 @@ void select_rect(int what, int select)
{
RECTORDER(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2);
drawtemprect(xctx->gctiled, NOW, xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2);
/* draw_selection(gc[SELLAYER], 0); */
/* draw_selection(xctx->gc[SELLAYER], 0); */
select_inside(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2, xctx->nl_sel);
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xctx->nl_xr, xctx->nl_yr, xctx->nl_xr2, xctx->nl_yr2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
bbox(END,0.0, 0.0, 0.0, 0.0);
/* /20171219 */

View File

@ -141,49 +141,74 @@ void start_wire(double mx, double my)
int callback(const char *winpath, int event, int mx, int my, KeySym key,
int button, int aux, int state)
{
char str[PATH_MAX + 100]; /* overflow safe 20161122 */
char str[PATH_MAX + 100];
struct stat buf;
int redraw_only;
unsigned short sel;
int c_snap;
#ifndef __unix__
short cstate = GetKeyState(VK_CAPITAL);
short nstate = GetKeyState(VK_NUMLOCK);
if(cstate & 0x0001) { /* caps lock */
tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }");
} else if (nstate & 0x0001) { /* num lock */
tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }");
} else { /* normal state */
tcleval(".statusbar.8 configure -state normal -text {}");
}
#else
XKeyboardState kbdstate;
XGetKeyboardControl(display, &kbdstate);
#endif
if(kbdstate.led_mask & 1) { /* caps lock */
tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }");
} else if(kbdstate.led_mask & 2) { /* num lock */
tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }");
#ifndef __unix__
if(cstate & 0x0001) { /* caps lock */
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {CAPS LOCK SET! }", NULL);
} else if (nstate & 0x0001) { /* num lock */
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {NUM LOCK SET! }", NULL);
} else { /* normal state */
tcleval(".statusbar.8 configure -state normal -text {}");
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state normal -text {}", NULL);
}
#else
XGetKeyboardControl(display, &kbdstate);
if(kbdstate.led_mask & 1) { /* caps lock */
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {CAPS LOCK SET! }", NULL);
} else if(kbdstate.led_mask & 2) { /* num lock */
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {NUM LOCK SET! }", NULL);
} else { /* normal state */
Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state normal -text {}", NULL);
}
#endif
#if 0
/* exclude Motion and Expose events */
if(event!=6 /* && event!=12 */) dbg(0, "callback(): event=%d, winpath=%s, old_winpath=%s, semaphore=%d\n",
event, winpath, old_winpath, xctx->semaphore+1);
#endif
/* Schematic window context switch */
redraw_only =0;
if(strcmp(old_winpath, winpath) ) {
if( xctx->semaphore >= 1 || event == Expose) {
dbg(1, "callback(): semaphore >=2 (or Expose) switching window context: %s --> %s\n", old_winpath, winpath);
redraw_only = 1;
} else {
dbg(1, "callback(): switching window context: %s --> %s\n", old_winpath, winpath);
if(old_winpath[0]) Tcl_VarEval(interp, "save_ctx ", old_winpath, NULL);
Tcl_VarEval(interp, "restore_ctx ", winpath, NULL);
Tcl_VarEval(interp, "housekeeping_ctx", NULL);
}
new_schematic("switch", xctx->top_path, winpath, "");
}
/* artificially set semaphore to allow only redraw operations in switched schematic,
* so we don't need to switch tcl context which is costly performance-wise
*/
if(redraw_only) xctx->semaphore++;
xctx->semaphore++; /* to recognize recursive callback() calls */
c_snap = tclgetdoublevar("cadsnap");
state &=~Mod2Mask; /* 20170511 filter out NumLock status */
if(xctx->semaphore)
if(xctx->semaphore >= 2)
{
if(debug_var>=2)
if(event != MotionNotify)
fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d, ev=%d, ui_state=%ld\n",
xctx->semaphore, event, xctx->ui_state);
/* if(event==Expose) {
* XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my);
*
* }
*/
/* return 0; */
}
xctx->semaphore++; /* used to debug Tcl-Tk frontend */
xctx->mousex=X_TO_XSCHEM(mx);
xctx->mousey=Y_TO_XSCHEM(my);
xctx->mousex_snap=ROUND(xctx->mousex / c_snap) * c_snap;
@ -196,7 +221,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
{
case EnterNotify:
tcleval("catch {destroy .ctxmenu}");
if(!xctx->sel_or_clip[0]) my_snprintf(xctx->sel_or_clip, S(xctx->sel_or_clip), "%s/%s", user_conf_dir, ".selection.sch");
if(!xctx->sel_or_clip[0]) my_snprintf(xctx->sel_or_clip, S(xctx->sel_or_clip), "%s/%s",
user_conf_dir, ".selection.sch");
/* xschem window *sending* selected objects
when the pointer comes back in abort copy operation since it has been done
@ -218,6 +244,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
break;
case Expose:
dbg(1, "callback: Expose, winpath=%s, %dx%d+%d+%d\n", winpath, button, aux, mx, my);
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my);
{
XRectangle xr[1];
@ -226,10 +253,10 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
xr[0].width=button;
xr[0].height=aux;
/* redraw selection on expose, needed if no backing store available on the server 20171112 */
XSetClipRectangles(display, gc[SELLAYER], 0,0, xr, 1, Unsorted);
XSetClipRectangles(display, xctx->gc[SELLAYER], 0,0, xr, 1, Unsorted);
rebuild_selected_array();
draw_selection(gc[SELLAYER],0);
XSetClipMask(display, gc[SELLAYER], None);
draw_selection(xctx->gc[SELLAYER],0);
XSetClipMask(display, xctx->gc[SELLAYER], None);
}
dbg(1, "callback(): Expose\n");
break;
@ -368,8 +395,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
if(key == 'b' && state==ControlMask) /* toggle show text in symbol */
{
sym_txt =!sym_txt;
if(sym_txt) {
xctx->sym_txt =!xctx->sym_txt;
if(xctx->sym_txt) {
/* tcleval("alert_ { enabling text in symbol} {}"); */
tclsetvar("sym_txt","1");
draw();
@ -500,8 +527,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
if(key == '$' && (state &ControlMask) ) /* toggle window drawing */
{
draw_window =!draw_window;
if(draw_window) {
xctx->draw_window =!xctx->draw_window;
if(xctx->draw_window) {
tcleval("alert_ { enabling draw window} {}");
tclsetvar("draw_window","1");
} else {
@ -513,25 +540,25 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
if(key == '=' && (state &ControlMask)) /* toggle fill rectangles */
{
int x;
fill_pattern++;
if(fill_pattern==3) fill_pattern=0;
xctx->fill_pattern++;
if(xctx->fill_pattern==3) xctx->fill_pattern=0;
if(fill_pattern==1) {
if(xctx->fill_pattern==1) {
tcleval("alert_ { Stippled pattern fill} {}");
for(x=0;x<cadlayers;x++) {
if(fill_type[x]==1) XSetFillStyle(display,gcstipple[x],FillSolid);
else XSetFillStyle(display,gcstipple[x],FillStippled);
if(xctx->fill_type[x]==1) XSetFillStyle(display,xctx->gcstipple[x],FillSolid);
else XSetFillStyle(display,xctx->gcstipple[x],FillStippled);
}
}
else if(fill_pattern==2) {
else if(xctx->fill_pattern==2) {
tcleval("alert_ { solid pattern fill} {}");
for(x=0;x<cadlayers;x++)
XSetFillStyle(display,gcstipple[x],FillSolid);
XSetFillStyle(display,xctx->gcstipple[x],FillSolid);
}
else {
tcleval("alert_ { No pattern fill} {}");
for(x=0;x<cadlayers;x++)
XSetFillStyle(display,gcstipple[x],FillStippled);
XSetFillStyle(display,xctx->gcstipple[x],FillStippled);
}
draw();
@ -659,7 +686,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
} else {
Tcl_VarEval(interp, "reconfigure_layers_button [winfo parent ", winpath, "]", NULL);
}
dbg(1, "callback(): new color: %d\n",color_index[xctx->rectcolor]);
dbg(1, "callback(): new color: %d\n",xctx->color_index[xctx->rectcolor]);
break;
}
if(key==XK_Delete && (xctx->ui_state & SELECTION) ) /* delete selection */
@ -697,15 +724,26 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
if(key=='q' && state == ControlMask) /* exit */
{
char * top_path;
top_path = xctx->top_path[0] ? xctx->top_path : ".";
if(xctx->semaphore >= 2) break;
if(xctx->modified) {
tcleval("tk_messageBox -type okcancel -message {UNSAVED data: want to exit?}");
if(strcmp(tclresult(),"ok")==0) {
tcleval( "exit");
if(!strcmp(winpath, ".drw")) {
tcleval("new_window destroy_all"); /* close child schematics */
if(tclresult()[0] == '1') {
if(xctx->modified) {
tcleval("tk_messageBox -type okcancel -message \""
"[get_cell [xschem get schname] 0]"
": UNSAVED data: want to exit?\"");
}
if(!xctx->modified || !strcmp(tclresult(),"ok")) tcleval( "exit");
}
}
else {
tcleval( "exit");
} else {
/* xschem new_schematic destroy asks user confirmation if schematic changed */
Tcl_VarEval(interp, "xschem new_schematic destroy ", top_path, " ", winpath," {}" , NULL);
/* ================================================================ */
/* We must return here, since current schematic is no more existing */
/* ================================================================ */
return 0;
}
break;
}
@ -734,7 +772,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
if(key=='V' && state == ShiftMask) /* toggle spice/vhdl netlist */
{
netlist_type++; if(netlist_type==6) netlist_type=1;
xctx->netlist_type++; if(xctx->netlist_type==6) xctx->netlist_type=1;
override_netlist_type(-1);
break;
}
@ -863,8 +901,9 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
d_c = tclgetboolvar("dark_colorscheme");
d_c = !d_c;
tclsetboolvar("dark_colorscheme", d_c);
tclsetdoublevar("color_dim", 0.0);
build_colors(0.0);
tclsetdoublevar("dim_value", 0.0);
tclsetdoublevar("dim_bg", 0.0);
build_colors(0.0, 0.0);
draw();
break;
}
@ -1251,13 +1290,13 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
unselect_all();
if(set_netlist_dir(0, NULL)) {
dbg(1, "callback(): -------------\n");
if(netlist_type == CAD_SPICE_NETLIST)
if(xctx->netlist_type == CAD_SPICE_NETLIST)
global_spice_netlist(1);
else if(netlist_type == CAD_VHDL_NETLIST)
else if(xctx->netlist_type == CAD_VHDL_NETLIST)
global_vhdl_netlist(1);
else if(netlist_type == CAD_VERILOG_NETLIST)
else if(xctx->netlist_type == CAD_VERILOG_NETLIST)
global_verilog_netlist(1);
else if(netlist_type == CAD_TEDAX_NETLIST)
else if(xctx->netlist_type == CAD_TEDAX_NETLIST)
global_tedax_netlist(1);
else
if(has_x) tcleval("tk_messageBox -type ok -message {Please Set netlisting mode (Options menu)}");
@ -1273,13 +1312,13 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
unselect_all();
if( set_netlist_dir(0, NULL) ) {
dbg(1, "callback(): -------------\n");
if(netlist_type == CAD_SPICE_NETLIST)
if(xctx->netlist_type == CAD_SPICE_NETLIST)
global_spice_netlist(0);
else if(netlist_type == CAD_VHDL_NETLIST)
else if(xctx->netlist_type == CAD_VHDL_NETLIST)
global_vhdl_netlist(0);
else if(netlist_type == CAD_VERILOG_NETLIST)
else if(xctx->netlist_type == CAD_VERILOG_NETLIST)
global_verilog_netlist(0);
else if(netlist_type == CAD_TEDAX_NETLIST)
else if(xctx->netlist_type == CAD_TEDAX_NETLIST)
global_tedax_netlist(0);
else
if(has_x) tcleval("tk_messageBox -type ok -message {Please Set netlisting mode (Options menu)}");
@ -1336,9 +1375,9 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
if(key=='b' && state==Mod1Mask) /* hide/show instance details */
{
if(xctx->semaphore >= 2) break;
hide_symbols++;
if(hide_symbols >= 3) hide_symbols = 0;
tclsetintvar("hide_symbols", hide_symbols);
xctx->hide_symbols++;
if(xctx->hide_symbols >= 3) xctx->hide_symbols = 0;
tclsetintvar("hide_symbols", xctx->hide_symbols);
draw();
break;
}
@ -1771,7 +1810,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
rebuild_selected_array();
#ifndef __unix__
draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
#endif
if(sel && state == ControlMask) {
launcher();
@ -1848,9 +1887,19 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
default:
dbg(1, "callback(): Event:%d\n",event);
break;
}
} /* switch(event) */
xctx->semaphore--;
if(redraw_only) {
xctx->semaphore--; /* decrement articially incremented semaphore (see above) */
dbg(1, "callback(): semaphore >=2 restoring window context: %s <-- %s\n", old_winpath, winpath);
if(old_winpath[0]) new_schematic("switch", xctx->top_path, old_winpath, "");
}
else
if(strcmp(old_winpath, winpath)) {
if(old_winpath[0]) dbg(1, "callback(): reset old_winpath: %s <- %s\n", old_winpath, winpath);
my_strncpy(old_winpath, winpath, S(old_winpath));
}
return 0;
}

View File

@ -98,7 +98,7 @@ void update_conn_cues(int draw_cues, int dr_win)
}
dbg(3, "update_conn_cues(): check3\n");
if(draw_cues) {
save_draw = draw_window; draw_window = dr_win;
save_draw = xctx->draw_window; xctx->draw_window = dr_win;
for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) {
i = wireptr->n;
/* optimization when editing small areas (detailed zoom) of a huge schematic */
@ -112,7 +112,7 @@ void update_conn_cues(int draw_cues, int dr_win)
}
}
filledarc(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0, 0.0);
draw_window = save_draw;
xctx->draw_window = save_draw;
}
}

View File

@ -39,7 +39,7 @@ int textclip(int x1,int y1,int x2,int y2,
{
dbg(2, "textclip(): %.16g %.16g %.16g %.16g - %d %d %d %d\n",
X_TO_SCREEN(xa),Y_TO_SCREEN(ya), X_TO_SCREEN(xb),Y_TO_SCREEN(yb),x1,y1,x2,y2);
/* drawtemprect(gc[WIRELAYER],xa,ya,xb,yb); */
/* drawtemprect(xctx->gc[WIRELAYER],xa,ya,xb,yb); */
if (X_TO_SCREEN(xa)>x2) return 0;
else if (Y_TO_SCREEN(ya)>y2) return 0;
else if (X_TO_SCREEN(xb)<x1) return 0;
@ -69,8 +69,8 @@ void print_image()
}
#if 0
* for(tmp=0;tmp<cadlayers;tmp++) {
* XSetClipRectangles(display, gc[tmp], 0,0, xctx->xrect, 1, Unsorted);
* XSetClipRectangles(display, gcstipple[tmp], 0,0, xctx->xrect, 1, Unsorted);
* XSetClipRectangles(display, xctx->gc[tmp], 0,0, xctx->xrect, 1, Unsorted);
* XSetClipRectangles(display, xctx->gcstipple[tmp], 0,0, xctx->xrect, 1, Unsorted);
* }
* XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted);
#endif
@ -102,13 +102,13 @@ void print_image()
void set_cairo_color(int layer)
{
cairo_set_source_rgb(xctx->cairo_ctx,
(double)xcolor_array[layer].red/65535.0,
(double)xcolor_array[layer].green/65535.0,
(double)xcolor_array[layer].blue/65535.0);
(double)xctx->xcolor_array[layer].red/65535.0,
(double)xctx->xcolor_array[layer].green/65535.0,
(double)xctx->xcolor_array[layer].blue/65535.0);
cairo_set_source_rgb(xctx->cairo_save_ctx,
(double)xcolor_array[layer].red/65535.0,
(double)xcolor_array[layer].green/65535.0,
(double)xcolor_array[layer].blue/65535.0);
(double)xctx->xcolor_array[layer].red/65535.0,
(double)xctx->xcolor_array[layer].green/65535.0,
(double)xctx->xcolor_array[layer].blue/65535.0);
}
/* remember to call cairo_restore(xctx->cairo_ctx) when done !! */
@ -243,7 +243,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in
if(c=='\n' || c==0) {
*ss='\0';
/*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, longest_line); */
if(draw_window) cairo_draw_string_line(xctx->cairo_ctx, tt, x, y, rot, flip,
if(xctx->draw_window) cairo_draw_string_line(xctx->cairo_ctx, tt, x, y, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line);
if(xctx->draw_pixmap) cairo_draw_string_line(xctx->cairo_save_ctx, tt, x, y, rot, flip,
lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line);
@ -362,10 +362,10 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
#endif
if(xctx->inst[n].ptr == -1) return;
if( (layer != PINLAYER && !enable_layer[layer]) ) return;
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
if(!has_x) return;
if( (hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr &&
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (hide_symbols == 2) ) {
if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr &&
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) {
hide = 1;
} else {
hide = 0;
@ -461,8 +461,8 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
}
} /* if(!hide) */
if( (!hide && enable_layer[layer]) ||
(hide && layer == PINLAYER && enable_layer[layer]) ) {
if( (!hide && xctx->enable_layer[layer]) ||
(hide && layer == PINLAYER && xctx->enable_layer[layer]) ) {
for(j=0;j< symptr->rects[layer];j++)
{
box = (symptr->rect[layer])[j];
@ -474,7 +474,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
}
}
if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) ||
(sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) {
(xctx->sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) {
const char *txtptr;
for(j=0;j< symptr->texts;j++)
{
@ -490,7 +490,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
}
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == -PINLAYER || enable_layer[textlayer]) {
if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) {
#if HAS_CAIRO==1
textfont = symptr->text[j].font;
if((textfont && textfont[0]) || symptr->text[j].flags) {
@ -632,7 +632,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot
drawtemparc(gc, what, x0+x1, y0+y1, arc.r, angle, arc.b);
}
if(layer==PROPERTYLAYER && sym_txt)
if(layer==PROPERTYLAYER && xctx->sym_txt)
{
const char *txtptr;
for(j=0;j< symptr->texts;j++)
@ -668,31 +668,31 @@ void drawgrid()
while(delta < CADGRIDTHRESHOLD) delta*=CADGRIDMULTIPLY; /* <-- to be improved,but works */
x = xctx->xorigin*xctx->mooz; y = xctx->yorigin*xctx->mooz;
if(y>xctx->areay1 && y < xctx->areay2) {
if(draw_window) XDrawLine(display, xctx->window, gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y);
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y);
if(xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y);
XDrawLine(display, xctx->save_pixmap, xctx->gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y);
}
if(x>xctx->areax1 && x < xctx->areax2) {
if(draw_window) XDrawLine(display, xctx->window, gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1);
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1);
if(xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1);
XDrawLine(display, xctx->save_pixmap, xctx->gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1);
}
tmp = floor((xctx->areay1+1)/delta)*delta-fmod(-xctx->yorigin*xctx->mooz,delta);
for(x=floor((xctx->areax1+1)/delta)*delta-fmod(-xctx->xorigin*xctx->mooz,delta); x < xctx->areax2; x += delta) {
for(y=tmp; y < xctx->areay2; y += delta) {
if(i>=CADMAXGRIDPOINTS) {
if(draw_window) {
if(xctx->draw_window) {
if(big_gr) {
XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i);
XDrawSegments(display,xctx->window,xctx->gc[GRIDLAYER],xctx->biggridpoint,i);
} else {
XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
XDrawPoints(display,xctx->window,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
}
}
if(xctx->draw_pixmap) {
if(big_gr) {
XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i);
XDrawSegments(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->biggridpoint,i);
} else {
XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
XDrawPoints(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
}
}
i=0;
@ -708,18 +708,18 @@ void drawgrid()
}
}
}
if(draw_window) {
if(xctx->draw_window) {
if(big_gr) {
XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i);
XDrawSegments(display,xctx->window,xctx->gc[GRIDLAYER],xctx->biggridpoint,i);
} else {
XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
XDrawPoints(display,xctx->window,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
}
}
if(xctx->draw_pixmap) {
if(big_gr) {
XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i);
XDrawSegments(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->biggridpoint,i);
} else {
XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
XDrawPoints(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin);
}
}
}
@ -745,15 +745,15 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
if(i>=CADDRAWBUFFERSIZE)
{
#ifdef __unix__
if(draw_window) XDrawSegments(display, xctx->window, gc[c], rr,i);
if(xctx->draw_window) XDrawSegments(display, xctx->window, xctx->gc[c], rr,i);
if(xctx->draw_pixmap)
XDrawSegments(display, xctx->save_pixmap, gc[c], rr,i);
XDrawSegments(display, xctx->save_pixmap, xctx->gc[c], rr,i);
#else
for (j = 0; j < i; ++j) {
if (draw_window)
XDrawLine(display, xctx->window, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_window)
XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
}
#endif
i=0;
@ -783,14 +783,14 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
{
if(dash) {
dash_arr[0] = dash_arr[1] = dash;
XSetDashes(display, gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
XSetDashes(display, xctx->gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
}
if(draw_window) XDrawLine(display, xctx->window, gc[c], x1, y1, x2, y2);
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], x1, y1, x2, y2);
if(xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, gc[c], x1, y1, x2, y2);
XDrawLine(display, xctx->save_pixmap, xctx->gc[c], x1, y1, x2, y2);
if(dash) {
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound);
}
}
}
@ -806,28 +806,28 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
{
if(dash) {
dash_arr[0] = dash_arr[1] = dash;
XSetDashes(display, gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
XSetDashes(display, xctx->gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
} else {
XSetLineAttributes (display, gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound);
XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound);
}
if(draw_window) XDrawLine(display, xctx->window, gc[c], x1, y1, x2, y2);
if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, gc[c], x1, y1, x2, y2);
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], x1, y1, x2, y2);
if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], x1, y1, x2, y2);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
}
}
else if(what & START) i=0;
else if((what & END) && i)
{
#ifdef __unix__
if(draw_window) XDrawSegments(display, xctx->window, gc[c], rr,i);
if(xctx->draw_pixmap) XDrawSegments(display, xctx->save_pixmap, gc[c], rr,i);
if(xctx->draw_window) XDrawSegments(display, xctx->window, xctx->gc[c], rr,i);
if(xctx->draw_pixmap) XDrawSegments(display, xctx->save_pixmap, xctx->gc[c], rr,i);
#else
for (j = 0; j < i; ++j) {
if (draw_window)
XDrawLine(display, xctx->window, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_window)
XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
}
#endif
i=0;
@ -1016,8 +1016,8 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b
{
if(i>=CADDRAWBUFFERSIZE)
{
if(draw_window) XFillArcs(display, xctx->window, gc[c], xarc,i);
if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, gc[c], xarc,i);
if(xctx->draw_window) XFillArcs(display, xctx->window, xctx->gc[c], xarc,i);
if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i);
i=0;
}
xx1=X_TO_SCREEN(x-r);
@ -1053,15 +1053,15 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b
y2=Y_TO_SCREEN(y2);
if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) )
{
if(draw_window) XFillArc(display, xctx->window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_pixmap) XFillArc(display, xctx->save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_window) XFillArc(display, xctx->window, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_pixmap) XFillArc(display, xctx->save_pixmap, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
}
else if(what & START) i=0;
else if((what & END) && i)
{
if(draw_window) XFillArcs(display, xctx->window, gc[c], xarc,i);
if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, gc[c], xarc,i);
if(xctx->draw_window) XFillArcs(display, xctx->window, xctx->gc[c], xarc,i);
if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i);
i=0;
}
}
@ -1081,8 +1081,8 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
{
if(i>=CADDRAWBUFFERSIZE)
{
if(draw_window) XDrawArcs(display, xctx->window, gc[c], xarc,i);
if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, gc[c], xarc,i);
if(xctx->draw_window) XDrawArcs(display, xctx->window, xctx->gc[c], xarc,i);
if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i);
i=0;
}
xx1=X_TO_SCREEN(x-r);
@ -1124,35 +1124,35 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
if(dash) {
char dash_arr[2];
dash_arr[0] = dash_arr[1] = dash;
XSetDashes(display, gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
XSetDashes(display, xctx->gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
}
if(draw_window) {
XDrawArc(display, xctx->window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_window) {
XDrawArc(display, xctx->window, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
if(xctx->draw_pixmap) {
XDrawArc(display, xctx->save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
XDrawArc(display, xctx->save_pixmap, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
if(fill_pattern && fill_type[c]){
if(xctx->fill_pattern && xctx->fill_type[c]){
if(arc_fill) {
if(draw_window)
XFillArc(display, xctx->window, gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_window)
XFillArc(display, xctx->window, xctx->gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
if(xctx->draw_pixmap)
XFillArc(display, xctx->save_pixmap, gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
XFillArc(display, xctx->save_pixmap, xctx->gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
}
if(dash) {
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
}
}
}
else if(what & START) i=0;
else if((what & END) && i)
{
if(draw_window) XDrawArcs(display, xctx->window, gc[c], xarc,i);
if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, gc[c], xarc,i);
if(xctx->draw_window) XDrawArcs(display, xctx->window, xctx->gc[c], xarc,i);
if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i);
i=0;
}
}
@ -1165,7 +1165,7 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
double x1,y1,x2,y2;
if(!has_x) return;
if(!fill_pattern || !fill_type[c]) return;
if(!xctx->fill_pattern || !xctx->fill_type[c]) return;
if(what & NOW)
{
x1=X_TO_SCREEN(rectx1);
@ -1175,11 +1175,11 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
if(!only_probes && (x2-x1)< 3.0 && (y2-y1)< 3.0) return;
if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) )
{
if(draw_window) XFillRectangle(display, xctx->window, gcstipple[c], (int)x1, (int)y1,
if(xctx->draw_window) XFillRectangle(display, xctx->window, xctx->gcstipple[c], (int)x1, (int)y1,
(unsigned int)x2 - (unsigned int)x1,
(unsigned int)y2 - (unsigned int)y1);
if(xctx->draw_pixmap)
XFillRectangle(display, xctx->save_pixmap,gcstipple[c], (int)x1, (int)y1,
XFillRectangle(display, xctx->save_pixmap,xctx->gcstipple[c], (int)x1, (int)y1,
(unsigned int)x2 - (unsigned int)x1,
(unsigned int)y2 - (unsigned int)y1);
}
@ -1189,9 +1189,9 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
{
if(i>=CADDRAWBUFFERSIZE)
{
if(draw_window) XFillRectangles(display, xctx->window, gcstipple[c], r,i);
if(xctx->draw_window) XFillRectangles(display, xctx->window, xctx->gcstipple[c], r,i);
if(xctx->draw_pixmap)
XFillRectangles(display, xctx->save_pixmap, gcstipple[c], r,i);
XFillRectangles(display, xctx->save_pixmap, xctx->gcstipple[c], r,i);
i=0;
}
x1=X_TO_SCREEN(rectx1);
@ -1210,8 +1210,8 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
}
else if((what & END) && i)
{
if(draw_window) XFillRectangles(display, xctx->window, gcstipple[c], r,i);
if(xctx->draw_pixmap) XFillRectangles(display, xctx->save_pixmap, gcstipple[c], r,i);
if(xctx->draw_window) XFillRectangles(display, xctx->window, xctx->gcstipple[c], r,i);
if(xctx->draw_pixmap) XFillRectangles(display, xctx->save_pixmap, xctx->gcstipple[c], r,i);
i=0;
}
}
@ -1313,21 +1313,21 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil
if(dash) {
char dash_arr[2];
dash_arr[0] = dash_arr[1] = dash;
XSetDashes(display, gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
XSetDashes(display, xctx->gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
}
if(draw_window) XDrawLines(display, xctx->window, gc[c], p, points, CoordModeOrigin);
if(xctx->draw_window) XDrawLines(display, xctx->window, xctx->gc[c], p, points, CoordModeOrigin);
if(xctx->draw_pixmap)
XDrawLines(display, xctx->save_pixmap, gc[c], p, points, CoordModeOrigin);
if(fill_pattern && fill_type[c]){
XDrawLines(display, xctx->save_pixmap, xctx->gc[c], p, points, CoordModeOrigin);
if(xctx->fill_pattern && xctx->fill_type[c]){
if(poly_fill && (x[0] == x[points-1]) && (y[0] == y[points-1])) {
if(draw_window) XFillPolygon(display, xctx->window, gcstipple[c], p, points, Polygontype, CoordModeOrigin);
if(xctx->draw_window) XFillPolygon(display, xctx->window, xctx->gcstipple[c], p, points, Polygontype, CoordModeOrigin);
if(xctx->draw_pixmap)
XFillPolygon(display, xctx->save_pixmap, gcstipple[c], p, points, Polygontype, CoordModeOrigin);
XFillPolygon(display, xctx->save_pixmap, xctx->gcstipple[c], p, points, Polygontype, CoordModeOrigin);
}
}
if(dash) {
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
}
my_free(722, &p);
@ -1377,20 +1377,20 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
{
if(dash) {
dash_arr[0] = dash_arr[1] = dash;
XSetDashes(display, gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
XSetDashes(display, xctx->gc[c], 0, dash_arr, 2);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel);
}
if(draw_window) XDrawRectangle(display, xctx->window, gc[c], (int)x1, (int)y1,
if(xctx->draw_window) XDrawRectangle(display, xctx->window, xctx->gc[c], (int)x1, (int)y1,
(unsigned int)x2 - (unsigned int)x1,
(unsigned int)y2 - (unsigned int)y1);
if(xctx->draw_pixmap)
{
XDrawRectangle(display, xctx->save_pixmap, gc[c], (int)x1, (int)y1,
XDrawRectangle(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1,
(unsigned int)x2 - (unsigned int)x1,
(unsigned int)y2 - (unsigned int)y1);
}
if(dash) {
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound);
}
}
}
@ -1399,9 +1399,9 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
{
if(i>=CADDRAWBUFFERSIZE)
{
if(draw_window) XDrawRectangles(display, xctx->window, gc[c], r,i);
if(xctx->draw_window) XDrawRectangles(display, xctx->window, xctx->gc[c], r,i);
if(xctx->draw_pixmap)
XDrawRectangles(display, xctx->save_pixmap, gc[c], r,i);
XDrawRectangles(display, xctx->save_pixmap, xctx->gc[c], r,i);
i=0;
}
x1=X_TO_SCREEN(rectx1);
@ -1420,8 +1420,8 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
}
else if((what & END) && i)
{
if(draw_window) XDrawRectangles(display, xctx->window, gc[c], r,i);
if(xctx->draw_pixmap) XDrawRectangles(display, xctx->save_pixmap, gc[c], r,i);
if(xctx->draw_window) XDrawRectangles(display, xctx->window, xctx->gc[c], r,i);
if(xctx->draw_pixmap) XDrawRectangles(display, xctx->save_pixmap, xctx->gc[c], r,i);
i=0;
}
}
@ -1494,10 +1494,10 @@ void draw(void)
rebuild_selected_array();
if(has_x) {
if(xctx->draw_pixmap)
XFillRectangle(display, xctx->save_pixmap, gc[BACKLAYER], xctx->areax1, xctx->areay1,
XFillRectangle(display, xctx->save_pixmap, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1,
xctx->areaw, xctx->areah);
if(draw_window)
XFillRectangle(display, xctx->window, gc[BACKLAYER], xctx->areax1, xctx->areay1,
if(xctx->draw_window)
XFillRectangle(display, xctx->window, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1,
xctx->areaw, xctx->areah);
dbg(2, "draw(): window: %d %d %d %d\n",xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2);
drawgrid();
@ -1516,21 +1516,21 @@ void draw(void)
for(c=0;c<cadlayers;c++) {
if(xctx->draw_single_layer!=-1 && c != xctx->draw_single_layer) continue;
if(enable_layer[c]) for(i=0;i<xctx->lines[c];i++) {
if(xctx->enable_layer[c]) for(i=0;i<xctx->lines[c];i++) {
xLine *l = &xctx->line[c][i];
if(l->bus) drawline(c, THICK, l->x1, l->y1, l->x2, l->y2, l->dash);
else drawline(c, ADD, l->x1, l->y1, l->x2, l->y2, l->dash);
}
if(enable_layer[c]) for(i=0;i<xctx->rects[c];i++) {
if(xctx->enable_layer[c]) for(i=0;i<xctx->rects[c];i++) {
xRect *r = &xctx->rect[c][i];
drawrect(c, ADD, r->x1, r->y1, r->x2, r->y2, r->dash);
filledrect(c, ADD, r->x1, r->y1, r->x2, r->y2);
}
if(enable_layer[c]) for(i=0;i<xctx->arcs[c];i++) {
if(xctx->enable_layer[c]) for(i=0;i<xctx->arcs[c];i++) {
xArc *a = &xctx->arc[c][i];
drawarc(c, ADD, a->x, a->y, a->r, a->a, a->b, a->fill, a->dash);
}
if(enable_layer[c]) for(i=0;i<xctx->polygons[c];i++) {
if(xctx->enable_layer[c]) for(i=0;i<xctx->polygons[c];i++) {
xPoly *p = &xctx->poly[c][i];
drawpolygon(c, NOW, p->x, p->y, p->points, p->fill, p->dash);
}
@ -1584,7 +1584,7 @@ void draw(void)
drawline(WIRELAYER, ADD, xctx->wire[i].x1,xctx->wire[i].y1,
xctx->wire[i].x2,xctx->wire[i].y2, 0);
}
update_conn_cues(1, draw_window);
update_conn_cues(1, xctx->draw_window);
filledrect(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0);
drawline(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0, 0);
}
@ -1595,7 +1595,7 @@ void draw(void)
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
dbg(1, "draw(): drawing string %d = %s\n",i, xctx->text[i].txt_ptr);
#if HAS_CAIRO==1
if(!enable_layer[textlayer]) continue;
if(!xctx->enable_layer[textlayer]) continue;
textfont = xctx->text[i].font;
if( (textfont && textfont[0]) || xctx->text[i].flags) {
cairo_font_slant_t slant;
@ -1630,12 +1630,12 @@ void draw(void)
}
}
} /* !only_probes, 20110112 */
draw_hilight_net(draw_window);
if(!draw_window) {
draw_hilight_net(xctx->draw_window);
if(!xctx->draw_window) {
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
}
draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
dbg(1, "draw(): INT_WIDTH(lw)=%d\n",INT_WIDTH(xctx->lw));
} /* if(has_x) */

View File

@ -296,7 +296,7 @@ void *my_calloc(int id, size_t nmemb, size_t size)
if(size*nmemb > 0) {
ptr=calloc(nmemb, size);
if(ptr == NULL) fprintf(errfp,"my_calloc(%d,): allocation failure\n", id);
dbg(3, "my_calloc(%d,): allocating %p , %lu bytes\n",
dbg(3, "\nmy_calloc(%d,): allocating %p , %lu bytes\n",
id, ptr, (unsigned long) (size*nmemb));
}
else ptr = NULL;
@ -309,7 +309,7 @@ void *my_malloc(int id, size_t size)
if(size>0) {
ptr=malloc(size);
if(ptr == NULL) fprintf(errfp,"my_malloc(%d,): allocation failure\n", id);
dbg(3, "my_malloc(%d,): allocating %p , %lu bytes\n", id, ptr, (unsigned long) size);
dbg(3, "\nmy_malloc(%d,): allocating %p , %lu bytes\n", id, ptr, (unsigned long) size);
}
else ptr=NULL;
return ptr;
@ -321,12 +321,12 @@ void my_realloc(int id, void *ptr,size_t size)
a = *(void **)ptr;
if(size == 0) {
free(*(void **)ptr);
dbg(3, "my_free(%d,): my_realloc_freeing %p\n",id, *(void **)ptr);
dbg(3, "\nmy_free(%d,): my_realloc_freeing %p\n",id, *(void **)ptr);
*(void **)ptr=NULL;
} else {
*(void **)ptr=realloc(*(void **)ptr,size);
if(*(void **)ptr == NULL) fprintf(errfp,"my_realloc(%d,): allocation failure\n", id);
dbg(3, "my_realloc(%d,): reallocating %p --> %p to %lu bytes\n",
dbg(3, "\nmy_realloc(%d,): reallocating %p --> %p to %lu bytes\n",
id, a, *(void **)ptr,(unsigned long) size);
}
@ -336,10 +336,10 @@ void my_free(int id, void *ptr)
{
if(*(void **)ptr) {
free(*(void **)ptr);
dbg(3, "my_free(%d,): freeing %p\n", id, *(void **)ptr);
dbg(3, "\nmy_free(%d,): freeing %p\n", id, *(void **)ptr);
*(void **)ptr=NULL;
} else {
dbg(3, "--> my_free(%d,): trying to free NULL pointer\n", id);
dbg(3, "\n--> my_free(%d,): trying to free NULL pointer\n", id);
}
}
@ -1151,31 +1151,31 @@ void edit_property(int x)
char *old_prop = NULL;
char *new_prop = NULL;
if(netlist_type==CAD_SYMBOL_ATTRS) {
if(xctx->netlist_type==CAD_SYMBOL_ATTRS) {
if(xctx->schsymbolprop!=NULL)
tclsetvar("retval",xctx->schsymbolprop);
else
tclsetvar("retval","");
}
else if(netlist_type==CAD_VHDL_NETLIST) {
else if(xctx->netlist_type==CAD_VHDL_NETLIST) {
if(xctx->schvhdlprop!=NULL)
tclsetvar("retval",xctx->schvhdlprop);
else
tclsetvar("retval","");
}
else if(netlist_type==CAD_VERILOG_NETLIST) {
else if(xctx->netlist_type==CAD_VERILOG_NETLIST) {
if(xctx->schverilogprop!=NULL)
tclsetvar("retval",xctx->schverilogprop);
else
tclsetvar("retval","");
}
else if(netlist_type==CAD_SPICE_NETLIST) {
else if(xctx->netlist_type==CAD_SPICE_NETLIST) {
if(xctx->schprop!=NULL)
tclsetvar("retval",xctx->schprop);
else
tclsetvar("retval","");
}
else if(netlist_type==CAD_TEDAX_NETLIST) {
else if(xctx->netlist_type==CAD_TEDAX_NETLIST) {
if(xctx->schtedaxprop!=NULL)
tclsetvar("retval",xctx->schtedaxprop);
else
@ -1200,27 +1200,27 @@ void edit_property(int x)
if(strcmp(tclgetvar("rcode"),"") )
{
if(netlist_type==CAD_SYMBOL_ATTRS &&
if(xctx->netlist_type==CAD_SYMBOL_ATTRS &&
(!xctx->schsymbolprop || strcmp(xctx->schsymbolprop, tclgetvar("retval") ) ) ) {
set_modify(1); push_undo();
my_strdup(422, &xctx->schsymbolprop, (char *) tclgetvar("retval"));
} else if(netlist_type==CAD_VERILOG_NETLIST &&
} else if(xctx->netlist_type==CAD_VERILOG_NETLIST &&
(!xctx->schverilogprop || strcmp(xctx->schverilogprop, tclgetvar("retval") ) ) ) {
set_modify(1); push_undo();
my_strdup(94, &xctx->schverilogprop, (char *) tclgetvar("retval"));
} else if(netlist_type==CAD_SPICE_NETLIST &&
} else if(xctx->netlist_type==CAD_SPICE_NETLIST &&
(!xctx->schprop || strcmp(xctx->schprop, tclgetvar("retval") ) ) ) {
set_modify(1); push_undo();
my_strdup(95, &xctx->schprop, (char *) tclgetvar("retval"));
} else if(netlist_type==CAD_TEDAX_NETLIST &&
} else if(xctx->netlist_type==CAD_TEDAX_NETLIST &&
(!xctx->schtedaxprop || strcmp(xctx->schtedaxprop, tclgetvar("retval") ) ) ) {
set_modify(1); push_undo();
my_strdup(96, &xctx->schtedaxprop, (char *) tclgetvar("retval"));
} else if(netlist_type==CAD_VHDL_NETLIST &&
} else if(xctx->netlist_type==CAD_VHDL_NETLIST &&
(!xctx->schvhdlprop || strcmp(xctx->schvhdlprop, tclgetvar("retval") ) ) ) {
set_modify(1); push_undo();
my_strdup(97, &xctx->schvhdlprop, (char *) tclgetvar("retval"));

View File

@ -62,7 +62,7 @@ void find_closest_polygon(double mx,double my)
threshold = CADWIREMINDIST * CADWIREMINDIST * cg * cg / 400;
for(c=0;c<cadlayers;c++)
{
if(!enable_layer[c]) continue;
if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->polygons[c];i++)
{
/*fprintf(errfp, "points=%d\n", xctx->poly[c][i].points); */
@ -99,7 +99,7 @@ void find_closest_line(double mx,double my)
threshold = CADWIREMINDIST * CADWIREMINDIST * cg * cg / 400;
for(c=0;c<cadlayers;c++)
{
if(!enable_layer[c]) continue;
if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->lines[c];i++)
{
if( (tmp = dist(xctx->line[c][i].x1,xctx->line[c][i].y1,xctx->line[c][i].x2,xctx->line[c][i].y2,mx,my))
@ -189,7 +189,7 @@ void find_closest_arc(double mx,double my)
for(c=0;c<cadlayers;c++)
{
if(!enable_layer[c]) continue;
if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->arcs[c];i++)
{
dist = sqrt(pow(mx-xctx->arc[c][i].x,2) + pow(my-xctx->arc[c][i].y,2)) - xctx->arc[c][i].r;
@ -236,7 +236,7 @@ void find_closest_box(double mx,double my)
int i,c,r=-1, col = 0;
for(c=0;c<cadlayers;c++)
{
if(!enable_layer[c]) continue;
if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->rects[c];i++)
{
if( POINTINSIDE(mx,my,xctx->rect[c][i].x1,xctx->rect[c][i].y1,xctx->rect[c][i].x2,xctx->rect[c][i].y2) )

View File

@ -23,7 +23,10 @@
#include "xschem.h"
/* X11 specific globals */
/* ------------------------------------------------ */
/* X11 specific globals */
/* ------------------------------------------------ */
Display *display;
Colormap colormap;
unsigned char **pixdata;
unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. */
@ -93,12 +96,12 @@ unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb.
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*20 */
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}/*21 */
};
GC *gcstipple,*gc;
Pixmap *pixmap = NULL;
Display *display;
int screen_number;
int screendepth;
Pixmap cad_icon_pixmap=0, cad_icon_mask=0;
XColor xcolor_array[256];
/* following global is declared in icon.c */
/* char *cad_icon[] */
Pixmap *pixmap = NULL;
Visual *visual;
#if HAS_XRENDER==1
XRenderPictFormat *render_format;
@ -111,71 +114,75 @@ xcb_screen_t *screen_xcb;
xcb_visualtype_t *visual_xcb;
#endif /*HAS_XCB */
/* these variables are mirrored in tcl code */
char *netlist_dir=NULL; /* user set netlist directory via cmd-option or menu or xschemrc */
char initial_netlist_name[PATH_MAX]={0};
int has_x=1;
int color_ps=-1;
int flat_netlist = 0;
/* ---------------------------------------------- */
/* These variables are mirrored in tcl code */
/* ---------------------------------------------- */
int cadlayers=0;
int has_x=1;
int rainbow_colors = 0;
double cairo_font_scale=1.0; /* default: 1.0, allows to adjust font size */
int flat_netlist = 0;
char *netlist_dir = NULL;
int color_ps=-1;
int only_probes = 0;
double nocairo_vert_correct=0.0;
/* lift up the text by 'n' pixels (zoom corrected) within the bbox. */
/* This correction is used to better align existing schematics */
/* compared to the nocairo xschem version. */
/* allowed values should be in the range [-4, 4] */
double cairo_vert_correct=0.0;
double nocairo_vert_correct=0.0;
int constrained_move = 0;
double cairo_font_scale=1.0; /* default: 1.0, allows to adjust font size */
double cairo_font_line_spacing = 1.0; /* value taken from xschemrc / xschem.tcl */
int netlist_type=-1;
int debug_var=-10; /* will be set to 0 in xinit.c */
/* -------------------------------------------- */
/* These variables are NOT mirrored in tcl code */
/* -------------------------------------------- */
int help=0; /* help option set to global scope, printing help is deferred */
/* when configuration ~/.schem has been read 20140406 */
FILE *errfp;
int no_readline=0;
char *filename=NULL; /* filename given on cmdline */
char user_conf_dir[PATH_MAX];
char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */
char user_conf_dir[PATH_MAX];
char pwd_dir[PATH_MAX]; /* obtained via getcwd() */
int load_initfile=1;
char rcfile[PATH_MAX] = {'\0'};
char *tcl_command = NULL; /* tcl command given on command line with --tcl <script> */
char tcl_script[PATH_MAX] = {'\0'};
int tcp_port = 0;
int text_svg=1; /* use <text> svg element for text instead of xschem's internal vector font */
int text_ps=1; /* use ps font for text instead of xschem's internal vector font */
double cadhalfdotsize = CADHALFDOTSIZE;
char initial_netlist_name[PATH_MAX]={0};
char bus_char[3] = {0, 0, 0};
int yyparse_error = 0;
char *xschem_executable=NULL;
Tcl_Interp *interp;
double *character[256]; /* array or per-char coordinates of xschem internal vector font */
int do_netlist=0; /* set by process_options if user wants netllist from cmdline */
int do_simulation=0;
int do_waves=0;
int do_print=0;
int quit=0; /* set from process_options (ex netlist from cmdline and quit) */
int batch_mode = 0; /* no tcl console if set; batch mode */
#ifndef __unix__
char win_temp_dir[PATH_MAX]="";
const char fopen_read_mode[] = "rb";
#else
const char fopen_read_mode[] = "r";
#endif
int load_initfile=1;
char rcfile[PATH_MAX] = {'\0'};
char *tcl_command = NULL;
char tcl_script[PATH_MAX] = {'\0'};
int quit=0; /* set from process_options (ex netlist from cmdline and quit) */
int debug_var=-10; /* will be set to 0 in xinit.c */
int tcp_port = 0;
int do_print=0;
int no_readline=0;
int draw_window=0;
int only_probes = 0;
int hide_symbols = 0;
int sym_txt = 1;
int text_svg=1; /* use <text> svg element for text instead of xschem's internal vector font */
int text_ps=1; /* use ps font for text instead of xschem's internal vector font */
double cadhalfdotsize = CADHALFDOTSIZE;
unsigned int color_index[256]; /* layer color lookup table */
int yyparse_error = 0;
int *enable_layer;
int n_active_layers = 0;
int *active_layer;
int screendepth;
char **color_array;
int *fill_type;
int fill_pattern = 1;
char *xschem_executable=NULL;
double *character[256]; /* array or per-char coordinates of xschem internal vector font */
Tcl_Interp *interp;
int do_netlist=0; /* set by process_options if user wants netllist from cmdline */
int do_simulation=0;
int do_waves=0;
char bus_char[3] = {0, 0, 0};
int constrained_move = 0;
int batch_mode = 0; /* no tcl console if set; batch mode */
/* previous focused schematic window (used to switch context in callback()) */
char old_winpath[PATH_MAX] = ".drw";
/* following data is relative to the current schematic */
/* ---------------------------------------------------------- */
/* Cmdline options (used at xinit, and then not used anymore) */
/* ---------------------------------------------------------- */
int cli_opt_netlist_type = -1;
char cli_opt_plotfile[PATH_MAX] = "";
/* --------------------------------------------------- */
/* Following data is relative to the current schematic */
/* --------------------------------------------------- */
Xschem_ctx *xctx;

View File

@ -99,22 +99,22 @@ void free_hilight_hash(void) /* remove the whole hash table */
}
/* by default:
* active_layer[0] = 7
* active_layer[1] = 8
* active_layer[2] = 10 if 9 is disabled it is skipped
* xctx->active_layer[0] = 7
* xctx->active_layer[1] = 8
* xctx->active_layer[2] = 10 if 9 is disabled it is skipped
* ...
* if a layer is disabled (not viewable) it is skipped
* n_active_layers is the total number of layers for hilights.
* standard xschem conf: cadlayers=22, n_active_layers=15 if no disabled layers.
* xctx->n_active_layers is the total number of layers for hilights.
* standard xschem conf: cadlayers=22, xctx->n_active_layers=15 if no disabled layers.
*/
int get_color(int value)
{
int x;
if(value < 0) return (-value) % cadlayers ;
if(n_active_layers) {
x = value%(n_active_layers);
return active_layer[x];
if(xctx->n_active_layers) {
x = value%(xctx->n_active_layers);
return xctx->active_layer[x];
} else {
return cadlayers > 5 ? 5 : cadlayers -1; /* desperate attempt to return a decent color */
}
@ -123,7 +123,7 @@ int get_color(int value)
void incr_hilight_color(void)
{
xctx->hilight_color = (xctx->hilight_color + 1) % (n_active_layers * cadlayers);
xctx->hilight_color = (xctx->hilight_color + 1) % (xctx->n_active_layers * cadlayers);
}
/* print all highlight signals which are not ports (in/out/inout). */
@ -186,7 +186,7 @@ void create_plot_cmd(void)
idx++;
if(viewer == NGSPICE) {
sprintf(color_str, "%02x/%02x/%02x",
xcolor_array[c].red>>8, xcolor_array[c].green>>8, xcolor_array[c].blue>>8);
xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8, xctx->xcolor_array[c].blue>>8);
if(idx > 9) {
idx = 2;
fprintf(fd, "%s", str);
@ -207,7 +207,7 @@ void create_plot_cmd(void)
if(viewer == GAW) {
char *t=NULL, *p=NULL;
sprintf(color_str, "%02x%02x%02x",
xcolor_array[c].red>>8, xcolor_array[c].green>>8, xcolor_array[c].blue>>8);
xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8, xctx->xcolor_array[c].blue>>8);
my_strdup(1273, &t, tok);
my_strdup2(1274, &p, (entry->path)+1);
if(simtype == 0 ) { /* spice */
@ -228,7 +228,7 @@ void create_plot_cmd(void)
if(viewer == BESPICE) {
char *t=NULL, *p=NULL;
sprintf(color_str, "%d %d %d",
xcolor_array[c].red>>8, xcolor_array[c].green>>8, xcolor_array[c].blue>>8);
xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8, xctx->xcolor_array[c].blue>>8);
my_strdup(241, &t, tok);
my_strdup2(245, &p, (entry->path)+1);
@ -580,8 +580,8 @@ int search(const char *tok, const char *val, int sub, int sel)
fprintf(errfp, "search(): warning: null val key\n");
return TCL_ERROR;
}
save_draw = draw_window;
draw_window=1;
save_draw = xctx->draw_window;
xctx->draw_window=1;
#ifdef __unix__
if(regcomp(&re, val , REG_EXTENDED)) return TCL_ERROR;
#endif
@ -743,14 +743,14 @@ int search(const char *tok, const char *val, int sub, int sel)
}
if(sel) {
rebuild_selected_array(); /* sets or clears xctx->ui_state SELECTION flag */
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
}
else redraw_hilights(0);
}
#ifdef __unix__
regfree(&re);
#endif
draw_window = save_draw;
xctx->draw_window = save_draw;
my_free(771, &tmpname);
return found;
}
@ -853,8 +853,8 @@ static void send_net_to_bespice(int simtype, const char *node)
if(node_entry && (node_entry->d.port == 0 || !strcmp(xctx->sch_path[xctx->currsch], ".") )) {
char *t=NULL, *p=NULL;
c = get_color(xctx->hilight_color);
sprintf(color_str, "%d %d %d", xcolor_array[c].red>>8, xcolor_array[c].green>>8,
xcolor_array[c].blue>>8);
sprintf(color_str, "%d %d %d", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
xctx->xcolor_array[c].blue>>8);
expanded_tok = expandlabel(tok, &tok_mult);
for(k=1; k<=tok_mult; k++) {
my_strdup(1277, &t, find_nth(expanded_tok, ',', k));
@ -914,8 +914,8 @@ static void send_net_to_gaw(int simtype, const char *node)
if(node_entry && (node_entry->d.port == 0 || !strcmp(xctx->sch_path[xctx->currsch], ".") )) {
char *t=NULL, *p=NULL;
c = get_color(xctx->hilight_color);
sprintf(color_str, "%02x%02x%02x", xcolor_array[c].red>>8, xcolor_array[c].green>>8,
xcolor_array[c].blue>>8);
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
xctx->xcolor_array[c].blue>>8);
expanded_tok = expandlabel(tok, &tok_mult);
tcleval("if { ![info exists gaw_fd] } { gaw_setup_tcp }\n");
for(k=1; k<=tok_mult; k++) {
@ -955,8 +955,8 @@ static void send_current_to_bespice(int simtype, const char *node)
tok = node;
/* c = PINLAYER; */
c = get_color(xctx->hilight_color);
sprintf(color_str, "%d %d %d", xcolor_array[c].red>>8, xcolor_array[c].green>>8,
xcolor_array[c].blue>>8);
sprintf(color_str, "%d %d %d", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
xctx->xcolor_array[c].blue>>8);
expanded_tok = expandlabel(tok, &tok_mult);
for(k=1; k<=tok_mult; k++) {
my_strdup(1281, &t, find_nth(expanded_tok, ',', k));
@ -1017,8 +1017,8 @@ static void send_current_to_gaw(int simtype, const char *node)
tok = node;
/* c = PINLAYER; */
c = get_color(xctx->hilight_color);
sprintf(color_str, "%02x%02x%02x", xcolor_array[c].red>>8, xcolor_array[c].green>>8,
xcolor_array[c].blue>>8);
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
xctx->xcolor_array[c].blue>>8);
expanded_tok = expandlabel(tok, &tok_mult);
tcleval("if { ![info exists gaw_fd] } { gaw_setup_tcp }\n");
for(k=1; k<=tok_mult; k++) {
@ -1704,8 +1704,8 @@ void draw_hilight_net(int on_window)
if(!xctx->hilight_nets) return;
dbg(3, "draw_hilight_net(): xctx->prep_hi_structs=%d\n", xctx->prep_hi_structs);
prepare_netlist_structs(0);
save_draw = draw_window;
draw_window = on_window;
save_draw = xctx->draw_window;
xctx->draw_window = on_window;
x1 = X_TO_XSCHEM(xctx->areax1);
y1 = Y_TO_XSCHEM(xctx->areay1);
x2 = X_TO_XSCHEM(xctx->areax2);
@ -1772,7 +1772,7 @@ void draw_hilight_net(int on_window)
}
}
}
draw_window = save_draw;
xctx->draw_window = save_draw;
}
/* show == 0 ==> create pins from highlight nets */
@ -1822,7 +1822,7 @@ void print_hilight_net(int show)
/* before invoking this function, in this case --> skip */
if(node_entry && !strcmp(xctx->sch_path[xctx->currsch], entry->path)) {
if(show==3) {
if(netlist_type == CAD_SPICE_NETLIST)
if(xctx->netlist_type == CAD_SPICE_NETLIST)
fprintf(fd, ".save v(%s%s)\n",
entry->path + 1,
entry->token[0] == '#' ? entry->token + 1 : entry->token );

View File

@ -44,7 +44,6 @@ void sig_handler(int s){
skip_dir(xctx->sch[xctx->currsch]));
if( !(emergency_dir = create_tmpdir(emergency_prefix)) ) {
fprintf(errfp, "xinit(): problems creating emergency save dir\n");
/* tcleval( "exit"); */
tcleval("exit");
}

View File

@ -192,7 +192,7 @@ void draw_selection(GC g, int interruptable)
int customfont;
#endif
if(g == gc[SELLAYER]) xctx->movelastsel = xctx->lastsel;
if(g == xctx->gc[SELLAYER]) xctx->movelastsel = xctx->lastsel;
for(i=0;i<xctx->movelastsel;i++)
{
c = xctx->sel_array[i].col;n = xctx->sel_array[i].n;
@ -561,7 +561,7 @@ void copy_objects(int what)
xctx->x2=xctx->mousex_snap;xctx->y_2=xctx->mousey_snap;
draw_selection(xctx->gctiled,0);
xctx->deltax = xctx->x2-xctx->x1; xctx->deltay = xctx->y_2 - xctx->y_1;
draw_selection(gc[SELLAYER],1);
draw_selection(xctx->gc[SELLAYER],1);
}
if(what & ROTATELOCAL ) {
xctx->rotatelocal=1;
@ -982,7 +982,7 @@ void copy_objects(int what)
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
xctx->rotatelocal=0;
} /* if(what & END) */
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
}
@ -1029,7 +1029,7 @@ void move_objects(int what, int merge, double dx, double dy)
xctx->x2=xctx->mousex_snap;xctx->y_2=xctx->mousey_snap;
draw_selection(xctx->gctiled,0);
xctx->deltax = xctx->x2-xctx->x1; xctx->deltay = xctx->y_2 - xctx->y_1;
draw_selection(gc[SELLAYER],1);
draw_selection(xctx->gc[SELLAYER],1);
}
if(what & ROTATELOCAL) {
xctx->rotatelocal=1;
@ -1529,5 +1529,5 @@ void move_objects(int what, int merge, double dx, double dy)
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
xctx->rotatelocal=0;
}
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
}

View File

@ -593,8 +593,8 @@ int record_global_node(int what, FILE *fp, char *node)
max_globals++;
} else if(what == 0 || what == 2) {
for(i=0;i<max_globals;i++) {
if(what == 0 && netlist_type == CAD_SPICE_NETLIST) fprintf(fp, ".GLOBAL %s\n", globals[i]);
if(what == 0 && netlist_type == CAD_TEDAX_NETLIST) fprintf(fp, "__GLOBAL__ %s\n", globals[i]);
if(what == 0 && xctx->netlist_type == CAD_SPICE_NETLIST) fprintf(fp, ".GLOBAL %s\n", globals[i]);
if(what == 0 && xctx->netlist_type == CAD_TEDAX_NETLIST) fprintf(fp, "__GLOBAL__ %s\n", globals[i]);
my_free(829, &globals[i]);
}
my_free(830, &globals);
@ -603,7 +603,7 @@ int record_global_node(int what, FILE *fp, char *node)
return 0;
}
/* set netlist_type tcl var to specified format, if -1 is given restore to default */
/* set xctx->netlist_type tcl var to specified format, if -1 is given restore to default */
void override_netlist_type(int type)
{
if (type == CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl");
@ -612,11 +612,11 @@ void override_netlist_type(int type)
else if(type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type","symbol");
else if(type == CAD_SPICE_NETLIST) tclsetvar("netlist_type","spice");
else {
if (netlist_type == CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl");
else if(netlist_type == CAD_VERILOG_NETLIST) tclsetvar("netlist_type","verilog");
else if(netlist_type == CAD_TEDAX_NETLIST) tclsetvar("netlist_type","tedax");
else if(netlist_type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type","symbol");
else if(netlist_type == CAD_SPICE_NETLIST) tclsetvar("netlist_type","spice");
if (xctx->netlist_type == CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl");
else if(xctx->netlist_type == CAD_VERILOG_NETLIST) tclsetvar("netlist_type","verilog");
else if(xctx->netlist_type == CAD_TEDAX_NETLIST) tclsetvar("netlist_type","tedax");
else if(xctx->netlist_type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type","symbol");
else if(xctx->netlist_type == CAD_SPICE_NETLIST) tclsetvar("netlist_type","spice");
}
}
@ -717,13 +717,13 @@ void prepare_netlist_structs(int for_netlist)
if(type && inst[i].node && IS_LABEL_OR_PIN(type) ) { /* instance must have a pin! */
if (for_netlist>0) {
/* 20150918 skip labels / pins if ignore property specified on instance */
if( netlist_type == CAD_VERILOG_NETLIST &&
if( xctx->netlist_type == CAD_VERILOG_NETLIST &&
strcmp(get_tok_value(inst[i].prop_ptr,"verilog_ignore",0),"true")==0 ) continue;
if( netlist_type == CAD_SPICE_NETLIST &&
if( xctx->netlist_type == CAD_SPICE_NETLIST &&
strcmp(get_tok_value(inst[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
if( netlist_type == CAD_VHDL_NETLIST &&
if( xctx->netlist_type == CAD_VHDL_NETLIST &&
strcmp(get_tok_value(inst[i].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if( netlist_type == CAD_TEDAX_NETLIST &&
if( xctx->netlist_type == CAD_TEDAX_NETLIST &&
strcmp(get_tok_value(inst[i].prop_ptr,"tedax_ignore",0),"true")==0 ) continue;
}
port=0;

View File

@ -59,7 +59,7 @@ void check_opt(char *opt, char *optval, int type)
} else if( (type == LONG && !strcmp("plotfile", opt)) ) {
dbg(1, "process_options(): user plotfile specified: %s\n", optval ? optval : "NULL");
if(optval) my_strncpy(xctx->plotfile, optval, S(xctx->plotfile));
if(optval) my_strncpy(cli_opt_plotfile, optval, S(cli_opt_plotfile));
} else if( (type == LONG && !strcmp("rcfile", opt)) ) {
dbg(1, "process_options(): user rcfile specified: %s\n", optval ? optval : "NULL");
@ -110,15 +110,15 @@ void check_opt(char *opt, char *optval, int type)
} else if( (type == SHORT && *opt == 's') || (type == LONG && !strcmp("spice", opt)) ) {
dbg(1, "process_options(): set netlist type to spice\n");
netlist_type=CAD_SPICE_NETLIST;
cli_opt_netlist_type=CAD_SPICE_NETLIST;
} else if( (type == SHORT && *opt == 'V') || (type == LONG && !strcmp("vhdl", opt)) ) {
dbg(1, "process_options(): set netlist type to vhdl\n");
netlist_type=CAD_VHDL_NETLIST;
cli_opt_netlist_type=CAD_VHDL_NETLIST;
} else if( (type == SHORT && *opt == 'w') || (type == LONG && !strcmp("verilog", opt)) ) {
dbg(1, "process_options(): set netlist type to verilog\n");
netlist_type=CAD_VERILOG_NETLIST;
cli_opt_netlist_type=CAD_VERILOG_NETLIST;
} else if( (type == SHORT && *opt == 'b') || (type == LONG && !strcmp("detach", opt)) ) {
batch_mode = 1;
@ -128,7 +128,7 @@ void check_opt(char *opt, char *optval, int type)
} else if( (type == SHORT && *opt == 't') || (type == LONG && !strcmp("tedax", opt)) ) {
dbg(1, "process_options(): set netlist type to tEDAx\n");
netlist_type=CAD_TEDAX_NETLIST;
cli_opt_netlist_type=CAD_TEDAX_NETLIST;
} else if( (type == SHORT && *opt == 'q') || (type == LONG && !strcmp("quit", opt)) ) {
quit=1;

View File

@ -32,8 +32,12 @@
#define CAD_SPICE_NETLIST 1
int dbg_var = 0;
extern int netlist_type;
#include "xschem.h"
/*
extern int xctx;
extern int has_x;
extern FILE *errfp;
extern size_t my_strdup(int id, char **dest, const char *src);
@ -42,7 +46,7 @@ extern char bus_char[];
extern const char *tcleval(const char str[]);
extern void *my_malloc(int id, size_t size);
extern int my_snprintf(char *str, int size, const char *fmt, ...);
*/
#ifndef STRINGPTR
#define STRINGPTR
typedef struct /* used in expandlabel.y */
@ -118,7 +122,7 @@ const char *expandlabel(const char *s, int *m)
else
*m=-1;
if(dest_string.str) {
if(netlist_type == CAD_SPICE_NETLIST && bus_char[0] && bus_char[1]) {
if(xctx->netlist_type == CAD_SPICE_NETLIST && bus_char[0] && bus_char[1]) {
str_char_replace(dest_string.str, '[', bus_char[0]);
str_char_replace(dest_string.str, ']', bus_char[1]);
}

View File

@ -118,7 +118,7 @@ static void set_ps_colors(unsigned int pixel)
static void ps_xdrawarc(int layer, int fillarc, double x, double y, double r, double a, double b)
{
if(fill_pattern && fillarc)
if(xctx->fill_pattern && fillarc)
fprintf(fd, "%g %g %g %g %g A %g %g LT C F S\n", x, y, r, -a, -a-b, x, y);
else
fprintf(fd, "%g %g %g %g %g A S\n", x, y, r, -a, -a-b);
@ -140,7 +140,7 @@ static void ps_xfillrectange(int layer, double x1, double y1, double x2,
double y2)
{
fprintf(fd, "%g %g %g %g R\n", x1,y1,x2-x1,y2-y1);
if( (fill_type[layer] == 1) && fill_pattern) {
if( (xctx->fill_type[layer] == 1) && xctx->fill_pattern) {
fprintf(fd, "%g %g %g %g RF\n", x1,y1,x2-x1,y2-y1);
/* fprintf(fd,"fill\n"); */
}
@ -174,7 +174,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, in
if(i==0) fprintf(fd, "NP\n%g %g MT\n", xx, yy);
else fprintf(fd, "%g %g LT\n", xx, yy);
}
if(fill_pattern && fill_type[c] && poly_fill) {
if(xctx->fill_pattern && xctx->fill_type[c] && poly_fill) {
fprintf(fd, "C F S\n");
} else {
fprintf(fd, "S\n");
@ -499,7 +499,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
char *textfont;
if(xctx->inst[n].ptr == -1) return;
if( (layer != PINLAYER && !enable_layer[layer]) ) return;
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
if(layer==0)
{
x1=X_TO_PS(xctx->inst[n].x1);
@ -568,7 +568,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
ps_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
}
if( enable_layer[layer] ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
if( xctx->enable_layer[layer] ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
{
box = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j];
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
@ -577,7 +577,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
ps_filledrect(layer, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
}
if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) ||
(sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) )
(xctx->sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) )
{
const char *txtptr;
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->texts;j++)
@ -593,7 +593,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo
if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer;
}
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == -PINLAYER || enable_layer[textlayer]) {
if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) {
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
textfont = symptr->text[j].font;

View File

@ -37,7 +37,9 @@ void read_record(int firstchar, FILE *fp, int dbg_level)
int c;
char *str = NULL;
dbg(dbg_level, "SKIP RECORD\n");
if(firstchar != '{') dbg(dbg_level, "%c", firstchar);
if(firstchar != '{') {
dbg(dbg_level, "%c", firstchar);
}
while((c = fgetc(fp)) != EOF) {
if (c=='\r') continue;
if(c == '\n') {
@ -963,6 +965,9 @@ int save_schematic(const char *schname) /* 20171020 added return value */
{
FILE *fd;
char name[PATH_MAX]; /* overflow safe 20161122 */
char *top_path;
top_path = xctx->top_path[0] ? xctx->top_path : ".";
if( strcmp(schname,"") ) my_strncpy(xctx->sch[xctx->currsch], schname, S(xctx->sch[xctx->currsch]));
else return -1;
@ -971,8 +976,8 @@ int save_schematic(const char *schname) /* 20171020 added return value */
dbg(1, "save_schematic(): abs_sym_path=%s\n", abs_sym_path(xctx->sch[xctx->currsch], ""));
my_strncpy(name, xctx->sch[xctx->currsch], S(name));
if(has_x) {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\"");
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\"");
Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
}
if(!(fd=fopen(name,"w")))
{
@ -1038,7 +1043,9 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
int i;
static int save_netlist_type = 0;
static int loaded_symbol = 0;
char *top_path;
top_path = xctx->top_path[0] ? xctx->top_path : ".";
xctx->prep_hi_structs=0;
xctx->prep_net_structs=0;
xctx->prep_hash_inst=0;
@ -1071,13 +1078,13 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
if(reset_undo) {
Tcl_VarEval(interp, "is_xschem_file ", xctx->sch[xctx->currsch], NULL);
if(!strcmp(tclresult(), "SYMBOL")) {
save_netlist_type = netlist_type;
netlist_type = CAD_SYMBOL_ATTRS;
save_netlist_type = xctx->netlist_type;
xctx->netlist_type = CAD_SYMBOL_ATTRS;
loaded_symbol = 1;
tclsetvar("netlist_type","symbol");
} else {
if(loaded_symbol) {
netlist_type = save_netlist_type;
xctx->netlist_type = save_netlist_type;
override_netlist_type(-1);
}
loaded_symbol = 0;
@ -1089,7 +1096,7 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
set_modify(0);
clear_drawing();
for(i=0;;i++) {
if(netlist_type == CAD_SYMBOL_ATTRS) {
if(xctx->netlist_type == CAD_SYMBOL_ATTRS) {
if(i == 0) my_snprintf(name, S(name), "%s.sym", "untitled");
else my_snprintf(name, S(name), "%s-%d.sym", "untitled", i);
} else {
@ -1103,8 +1110,8 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
}
if(has_x) { /* 20161207 moved after if( (fd=..)) */
if(reset_undo) {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); /* set window and icon title */
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\"");
Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
}
}
if(tclgetboolvar("autotrim_wires")) trim_wires();

View File

@ -29,19 +29,15 @@ YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
void statusmsg(char str[],int n)
{
static char s[2048];
if(!has_x) return;
tclsetvar("infowindow_text", str);
if(n==2) {
dbg(3, "statusmsg(): n = 2, s = %s\n", s);
dbg(3, "statusmsg(): n = 2, str = %s\n", str);
tcleval("infowindow");
}
else {
my_snprintf(s, S(s), ".statusbar.1 configure -text $infowindow_text", str);
dbg(3, "statusmsg(): n = %d, %s\n", n, s);
dbg(3, "statusmsg(): -> $infowindow_text = %s\n", tclgetvar("infowindow_text"));
tcleval(s);
Tcl_VarEval(interp, xctx->top_path, ".statusbar.1 configure -text $infowindow_text", NULL);
dbg(3, "statusmsg(str, %d): -> $infowindow_text = %s\n", n, tclgetvar("infowindow_text"));
}
}
@ -170,8 +166,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"change_colors"))
{
cmd_found = 1;
build_colors(tclgetdoublevar("color_dim"));
draw();
build_colors(tclgetdoublevar("dim_value"), tclgetdoublevar("dim_bg"));
Tcl_ResetResult(interp);
}
@ -208,7 +203,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
remove_symbols();
clear_drawing();
if(argc>=3 && !strcmp(argv[2],"SYMBOL")) {
netlist_type = CAD_SYMBOL_ATTRS;
xctx->netlist_type = CAD_SYMBOL_ATTRS;
tclsetvar("netlist_type","symbol");
for(i=0;;i++) {
if(i == 0) my_snprintf(name, S(name), "%s.sym", "untitled");
@ -218,7 +213,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_snprintf(xctx->sch[xctx->currsch], S(xctx->sch[xctx->currsch]), "%s/%s", pwd_dir, name);
my_strncpy(xctx->current_name, name, S(xctx->current_name));
} else {
netlist_type = CAD_SPICE_NETLIST;
xctx->netlist_type = CAD_SPICE_NETLIST;
tclsetvar("netlist_type","spice");
for(i=0;;i++) {
if(i == 0) my_snprintf(name, S(name), "%s.sch", "untitled");
@ -235,8 +230,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->prep_net_structs=0;
xctx->prep_hi_structs=0;
if(has_x) {
tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); /* set window and icon title */
tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\"");
char *top_path;
top_path = xctx->top_path[0] ? xctx->top_path : ".";
Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL);
}
}
Tcl_ResetResult(interp);
@ -255,19 +252,20 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_strdup(373, &netlist_dir, "");
}
else if(!strcmp(argv[1],"color_dim"))
else if(!strcmp(argv[1], "color_dim"))
{
double d;
cmd_found = 1;
if(argc==3) {
d = atof(argv[2]);
build_colors(d);
draw();
Tcl_ResetResult(interp);
if(argc > 2) {
tclsetvar("dim_value", argv[2]);
if(tclgetboolvar("enable_dim_bg") ) {
tclsetvar("dim_bg", argv[2]);
}
}
build_colors(tclgetdoublevar("dim_value"), tclgetdoublevar("dim_bg"));
draw();
Tcl_ResetResult(interp);
}
else if(!strcmp(argv[1],"connected_nets")) /* selected nets connected to currently selected ones */
{
int stop_at_junction = 0;
@ -404,12 +402,25 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"exit"))
{
char * top_path;
cmd_found = 1;
if(xctx->modified && has_x) {
tcleval("tk_messageBox -type okcancel -message {UNSAVED data: want to exit?}");
if(strcmp(tclresult(),"ok")==0) tcleval( "exit");
top_path = xctx->top_path[0] ? xctx->top_path : ".";
if(!strcmp(top_path, ".")) {
if(has_x) {
tcleval("new_window destroy_all"); /* close child schematics */
if(tclresult()[0] == '1') {
if(xctx->modified) {
tcleval("tk_messageBox -type okcancel -message \""
"[get_cell [xschem get schname] 0]"
": UNSAVED data: want to exit?\"");
}
if(!xctx->modified || !strcmp(tclresult(),"ok")) tcleval("exit");
}
}
else tcleval("exit"); /* if has_x == 0 there are no additional windows to close */
} else {
Tcl_VarEval(interp, "xschem new_schematic destroy ", top_path, " ", xctx->top_path, ".drw {}" , NULL);
}
else tcleval( "exit");
Tcl_ResetResult(interp);
}
@ -539,7 +550,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
else if(!strcmp(argv[2],"draw_window")) {
char s[30]; /* overflow safe 20161122 */
my_snprintf(s, S(s), "%d",draw_window);
my_snprintf(s, S(s), "%d",xctx->draw_window);
Tcl_SetResult(interp, s,TCL_VOLATILE);
}
else if(!strcmp(argv[2],"flat_netlist")) {
@ -1278,9 +1289,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
pos=-1;
if(argc==7) pos=atol(argv[6]);
storeobject(pos, x1,y1,x2,y2,LINE,xctx->rectcolor,0,NULL);
save = draw_window; draw_window = 1;
save = xctx->draw_window; xctx->draw_window = 1;
drawline(xctx->rectcolor,NOW, x1,y1,x2,y2, 0);
draw_window = save;
xctx->draw_window = save;
}
else xctx->ui_state |= MENUSTARTLINE;
}
@ -1445,13 +1456,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
cmd_found = 1;
yyparse_error = 0;
if( set_netlist_dir(0, NULL) ) {
if(netlist_type == CAD_SPICE_NETLIST)
if(xctx->netlist_type == CAD_SPICE_NETLIST)
global_spice_netlist(1); /* 1 means global netlist */
else if(netlist_type == CAD_VHDL_NETLIST)
else if(xctx->netlist_type == CAD_VHDL_NETLIST)
global_vhdl_netlist(1);
else if(netlist_type == CAD_VERILOG_NETLIST)
else if(xctx->netlist_type == CAD_VERILOG_NETLIST)
global_verilog_netlist(1);
else if(netlist_type == CAD_TEDAX_NETLIST)
else if(xctx->netlist_type == CAD_TEDAX_NETLIST)
global_tedax_netlist(1);
else
if(has_x) tcleval("tk_messageBox -type ok -message {Please Set netlisting mode (Options menu)}");
@ -1461,30 +1472,32 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"netlist_type"))
{
cmd_found = 1;
if(!strcmp(argv[2],"vhdl")) {
netlist_type=CAD_VHDL_NETLIST;
if(argc > 2) {
if(!strcmp(argv[2],"vhdl")) {
xctx->netlist_type=CAD_VHDL_NETLIST;
}
else if(!strcmp(argv[2],"verilog")) {
xctx->netlist_type=CAD_VERILOG_NETLIST;
}
else if(!strcmp(argv[2],"tedax")) {
xctx->netlist_type=CAD_TEDAX_NETLIST;
}
else if(!strcmp(argv[2],"symbol")) {
xctx->netlist_type=CAD_SYMBOL_ATTRS;
}
else if(!strcmp(argv[2],"spice")){
xctx->netlist_type=CAD_SPICE_NETLIST;
}
override_netlist_type(-1); /* set tcl netlist_type variable */
}
else if(!strcmp(argv[2],"verilog")) {
netlist_type=CAD_VERILOG_NETLIST;
}
else if(!strcmp(argv[2],"tedax")) {
netlist_type=CAD_TEDAX_NETLIST;
}
else if(!strcmp(argv[2],"symbol")) {
netlist_type=CAD_SYMBOL_ATTRS;
}
else if(!strcmp(argv[2],"spice")){
netlist_type=CAD_SPICE_NETLIST;
}
override_netlist_type(-1); /* set tcl netlist_type */
}
else if(!strcmp(argv[1],"new_schematic"))
{
cmd_found = 1;
if(argc == 3) new_schematic(argv[2], "{}","{}");
else if(argc == 4) new_schematic(argv[2], argv[3], "{}");
else if(argc == 5) new_schematic(argv[2], argv[3], argv[4]);
if(argc == 4) new_schematic(argv[2], argv[3], "{}","{}");
else if(argc == 5) new_schematic(argv[2], argv[3], argv[4], "{}");
else if(argc == 6) new_schematic(argv[2], argv[3], argv[4], argv[5]);
Tcl_ResetResult(interp);
}
@ -1772,9 +1785,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
pos=-1;
if(argc==7) pos=atol(argv[6]);
storeobject(pos, x1,y1,x2,y2,xRECT,xctx->rectcolor,0,NULL);
save = draw_window; draw_window = 1;
save = xctx->draw_window; xctx->draw_window = 1;
drawrect(xctx->rectcolor,NOW, x1,y1,x2,y2, 0);
draw_window = save;
xctx->draw_window = save;
}
else xctx->ui_state |= MENUSTARTRECT;
}
@ -2002,9 +2015,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int n=atol(argv[3]);
if(n<xctx->texts && n >= 0) select_text(atol(argv[3]), SELECTED, 0);
}
drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
}
else if(!strcmp(argv[1],"select_all"))
@ -2102,20 +2115,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[2],"constrained_move")) {
constrained_move = atoi(argv[3]);
}
else if(!strcmp(argv[2],"dim")) {
double s = atof(argv[3]);
build_colors(s);
draw();
Tcl_ResetResult(interp);
}
else if(!strcmp(argv[2],"draw_window")) {
draw_window=atoi(argv[3]);
xctx->draw_window=atoi(argv[3]);
}
else if(!strcmp(argv[2],"flat_netlist")) {
flat_netlist=atoi(argv[3]);
}
else if(!strcmp(argv[2],"hide_symbols")) {
hide_symbols=atoi(argv[3]);
xctx->hide_symbols=atoi(argv[3]);
}
else if(!strcmp(argv[2],"netlist_name")) {
my_strncpy(xctx->netlist_name, argv[3], S(xctx->netlist_name));
@ -2142,7 +2149,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->semaphore=atoi(argv[3]);
}
else if(!strcmp(argv[2],"sym_txt")) {
sym_txt=atoi(argv[3]);
xctx->sym_txt=atoi(argv[3]);
}
else {
Tcl_AppendResult(interp, "xschem set ", argv[1], argv[3], ": invalid command.", NULL);
@ -2310,8 +2317,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
d_c = tclgetboolvar("dark_colorscheme");
d_c = !d_c;
tclsetboolvar("dark_colorscheme", d_c);
tclsetdoublevar("color_dim", 0.0);
build_colors(0.0);
tclsetdoublevar("dim_value", 0.0);
tclsetdoublevar("dim_bg", 0.0);
build_colors(0.0, 0.0);
draw();
Tcl_ResetResult(interp);
}
@ -2419,9 +2427,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->prep_hi_structs=0;
xctx->prep_net_structs=0;
xctx->prep_hash_wires=0;
save = draw_window; draw_window = 1;
save = xctx->draw_window; xctx->draw_window = 1;
drawline(WIRELAYER,NOW, x1,y1,x2,y2, 0);
draw_window = save;
xctx->draw_window = save;
if(tclgetvar("autotrim_wires")) trim_wires();
}
else xctx->ui_state |= MENUSTARTWIRE;
@ -2512,31 +2520,26 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
double tclgetdoublevar(const char *s)
{
dbg(2, "tclgetdoublevar(): %s\n", s);
return atof(Tcl_GetVar(interp,s, TCL_GLOBAL_ONLY));
}
int tclgetintvar(const char *s)
{
dbg(2, "tclgetintvar(): %s\n", s);
return atoi(Tcl_GetVar(interp,s, TCL_GLOBAL_ONLY));
}
int tclgetboolvar(const char *s)
{
dbg(2, "tclgetboolvar(): %s\n", s);
return Tcl_GetVar(interp,s, TCL_GLOBAL_ONLY)[0] == '1' ? 1 : 0;
}
const char *tclgetvar(const char *s)
{
dbg(2, "tclgetvar(): %s\n", s);
return Tcl_GetVar(interp,s, TCL_GLOBAL_ONLY);
}
const char *tcleval(const char str[])
{
dbg(2, "tcleval(): %s\n", str);
if( Tcl_GlobalEval(interp, str) != TCL_OK) {
fprintf(errfp, "tcleval(): evaluation of script: %s failed\n", str);
}
@ -2549,7 +2552,6 @@ const char *tclresult(void)
void tclsetvar(const char *s, const char *value)
{
dbg(2, "tclsetvar(): %s to %s\n", s, value);
if(!Tcl_SetVar(interp, s, value, TCL_GLOBAL_ONLY)) {
fprintf(errfp, "tclsetvar(): error setting variable %s to %s\n", s, value);
}
@ -2558,7 +2560,6 @@ void tclsetvar(const char *s, const char *value)
void tclsetdoublevar(const char *s, const double value)
{
char str[80];
dbg(2, "tclsetdoublevar(): %s to %g\n", s, value);
sprintf(str, "%.16g", value);
if(!Tcl_SetVar(interp, s, str, TCL_GLOBAL_ONLY)) {
fprintf(errfp, "tclsetdoublevar(): error setting variable %s to %g\n", s, value);
@ -2568,7 +2569,6 @@ void tclsetdoublevar(const char *s, const double value)
void tclsetintvar(const char *s, const int value)
{
char str[80];
dbg(2, "tclsetintvar(): %s to %d\n", s, value);
sprintf(str, "%d", value);
if(!Tcl_SetVar(interp, s, str, TCL_GLOBAL_ONLY)) {
fprintf(errfp, "tclsetintvar(): error setting variable %s to %d\n", s, value);
@ -2577,7 +2577,6 @@ void tclsetintvar(const char *s, const int value)
void tclsetboolvar(const char *s, const int value)
{
dbg(2, "tclsetboolvar(): %s to %d\n", s, value);
if(!Tcl_SetVar(interp, s, (value ? "1" : "0"), TCL_GLOBAL_ONLY)) {
fprintf(errfp, "tclsetboolvar(): error setting variable %s to %d\n", s, value);
}

View File

@ -144,7 +144,7 @@ void select_connected_wires(int stop_at_junction)
} /* switch(...) */
} /* for(... lastsel ...) */
rebuild_selected_array();
draw_selection(gc[SELLAYER], 0);
draw_selection(xctx->gc[SELLAYER], 0);
}
@ -559,8 +559,8 @@ void bbox(int what,double x1,double y1, double x2, double y2)
XSetClipMask(display, xctx->gctiled, None); /* clipping already done in software */
for(i=0;i<cadlayers;i++)
{
XSetClipMask(display, gc[i], None); /* clipping already done in software */
XSetClipMask(display, gcstipple[i], None); /* optimization, clipping already done in software */
XSetClipMask(display, xctx->gc[i], None); /* clipping already done in software */
XSetClipMask(display, xctx->gcstipple[i], None); /* optimization, clipping already done in software */
}
#if HAS_CAIRO==1
cairo_reset_clip(xctx->cairo_ctx);
@ -588,8 +588,8 @@ void bbox(int what,double x1,double y1, double x2, double y2)
if(has_x) {
for(i=0;i<cadlayers;i++)
{
XSetClipRectangles(display, gc[i], 0,0, xctx->xrect, 1, Unsorted);
XSetClipRectangles(display, gcstipple[i], 0,0, xctx->xrect, 1, Unsorted);
XSetClipRectangles(display, xctx->gc[i], 0,0, xctx->xrect, 1, Unsorted);
XSetClipRectangles(display, xctx->gcstipple[i], 0,0, xctx->xrect, 1, Unsorted);
}
XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted);
dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2);
@ -738,9 +738,9 @@ void select_wire(int i,unsigned short select_mode, int fast)
if(select_mode) {
dbg(1, "select(): wire[%d].end1=%d, ,end2=%d\n", i, xctx->wire[i].end1, xctx->wire[i].end2);
if(xctx->wire[i].bus)
drawtempline(gc[SELLAYER], THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2);
drawtempline(xctx->gc[SELLAYER], THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2);
else
drawtempline(gc[SELLAYER], ADD, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2);
drawtempline(xctx->gc[SELLAYER], ADD, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2);
}
else {
if(xctx->wire[i].bus)
@ -790,7 +790,7 @@ void select_element(int i,unsigned short select_mode, int fast, int override_loc
xctx->inst[i].sel = select_mode;
if(select_mode) {
for(c=0;c<cadlayers;c++) {
draw_temp_symbol(ADD, gc[SELLAYER], i,c,0,0,0.0,0.0);
draw_temp_symbol(ADD, xctx->gc[SELLAYER], i,c,0,0,0.0,0.0);
}
} else {
for(c=0;c<cadlayers;c++) {
@ -821,7 +821,7 @@ void select_text(int i,unsigned short select_mode, int fast)
customfont = set_text_custom_font(&xctx->text[i]);
#endif
if(select_mode)
draw_temp_string(gc[SELLAYER],ADD, xctx->text[i].txt_ptr,
draw_temp_string(xctx->gc[SELLAYER],ADD, xctx->text[i].txt_ptr,
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
xctx->text[i].xscale, xctx->text[i].yscale);
@ -858,7 +858,7 @@ void select_box(int c, int i, unsigned short select_mode, int fast)
} else {
xctx->rect[c][i].sel |= select_mode;
}
drawtemprect(gc[SELLAYER], ADD, xctx->rect[c][i].x1, xctx->rect[c][i].y1,
drawtemprect(xctx->gc[SELLAYER], ADD, xctx->rect[c][i].x1, xctx->rect[c][i].y1,
xctx->rect[c][i].x2, xctx->rect[c][i].y2);
} else {
xctx->rect[c][i].sel = 0;
@ -889,7 +889,7 @@ void select_arc(int c, int i, unsigned short select_mode, int fast)
}
if(select_mode) {
xctx->arc[c][i].sel = select_mode;
drawtemparc(gc[SELLAYER], ADD, xctx->arc[c][i].x, xctx->arc[c][i].y,
drawtemparc(xctx->gc[SELLAYER], ADD, xctx->arc[c][i].x, xctx->arc[c][i].y,
xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b);
} else {
xctx->arc[c][i].sel = 0;
@ -917,7 +917,7 @@ void select_polygon(int c, int i, unsigned short select_mode, int fast )
}
xctx->poly[c][i].sel = select_mode;
if(select_mode) {
drawtemppolygon(gc[SELLAYER], NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points);
drawtemppolygon(xctx->gc[SELLAYER], NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points);
}
else
drawtemppolygon(xctx->gctiled, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points);
@ -947,10 +947,10 @@ void select_line(int c, int i, unsigned short select_mode, int fast )
xctx->line[c][i].sel = select_mode;
if(select_mode) {
if(xctx->line[c][i].bus)
drawtempline(gc[SELLAYER], THICK, xctx->line[c][i].x1, xctx->line[c][i].y1,
drawtempline(xctx->gc[SELLAYER], THICK, xctx->line[c][i].x1, xctx->line[c][i].y1,
xctx->line[c][i].x2, xctx->line[c][i].y2);
else
drawtempline(gc[SELLAYER], ADD, xctx->line[c][i].x1, xctx->line[c][i].y1,
drawtempline(xctx->gc[SELLAYER], ADD, xctx->line[c][i].x1, xctx->line[c][i].y1,
xctx->line[c][i].x2, xctx->line[c][i].y2);
}
else
@ -998,9 +998,9 @@ unsigned short select_object(double mx,double my, unsigned short select_mode, in
break;
} /*end switch */
drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
if(sel.type) xctx->ui_state |= SELECTION;
return sel.type;
@ -1066,7 +1066,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u
}
for(c=0;c<cadlayers;c++)
{
if(!enable_layer[c]) continue;
if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->polygons[c]; i++) {
int k, selected_points, flag;
@ -1177,9 +1177,9 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u
} /* end for i */
} /* end for c */
drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
}
void select_all(void)
@ -1217,9 +1217,9 @@ void select_all(void)
select_box(c,i, SELECTED, 1);
}
} /* end for c */
drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0);
drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
rebuild_selected_array(); /* sets or clears xctx->ui_state SELECTION flag */
}

View File

@ -257,7 +257,7 @@ void global_spice_netlist(int global) /* netlister driver */
my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname);
override_netlist_type(CAD_SPICE_NETLIST);
tcleval(tcl_cmd_netlist);
override_netlist_type(-1); /* restore to netlist_type default */
override_netlist_type(-1); /* restore to xctx->netlist_type default */
if(debug_var==0) xunlink(netl_filename);
}
@ -479,7 +479,7 @@ void spice_block_netlist(FILE *fd, int i)
my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname);
override_netlist_type(CAD_SPICE_NETLIST);
tcleval(tcl_cmd_netlist);
override_netlist_type(-1); /* restore to netlist_type default */
override_netlist_type(-1); /* restore to xctx->netlist_type default */
if(debug_var==0) xunlink(netl_filename);
}
}

View File

@ -408,7 +408,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
char *textfont;
if(xctx->inst[n].ptr == -1) return;
if( (layer != PINLAYER && !enable_layer[layer]) ) return;
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
if(layer==0) {
x1=X_TO_SVG(xctx->inst[n].x1);
x2=X_TO_SVG(xctx->inst[n].x2);
@ -467,7 +467,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
svg_drawarc(c, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
}
if( enable_layer[layer] ) for(j=0;j< symptr->rects[layer];j++) {
if( xctx->enable_layer[layer] ) for(j=0;j< symptr->rects[layer];j++) {
box = (symptr->rect[layer])[j];
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
@ -475,7 +475,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
svg_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
}
if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) ||
(sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) {
(xctx->sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) {
const char *txtptr;
for(j=0;j< symptr->texts;j++) {
text = symptr->text[j];
@ -489,7 +489,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
}
/* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) {
if(xctx->inst[n].color == PINLAYER || xctx->enable_layer[textlayer]) {
my_snprintf(svg_font_family, S(svg_font_family), tclgetvar("svg_font_name"));
my_snprintf(svg_font_style, S(svg_font_style), "normal");
my_snprintf(svg_font_weight, S(svg_font_weight), "normal");
@ -617,12 +617,12 @@ void svg_draw(void)
* if(xctx->lines[c] || xctx->rects[c] || xctx->arcs[c] || xctx->polygons[c]) unused_layer[c] = 0;
* if(xctx->wires) unused_layer[WIRELAYER] = 0;
* for(i=0;i<xctx->instances;i++) {
* if( (c == PINLAYER || enable_layer[c]) && symptr->lines[c] ) unused_layer[c] = 0;
* if( (c == PINLAYER || enable_layer[c]) && symptr->polygons[c] ) unused_layer[c] = 0;
* if( (c == PINLAYER || enable_layer[c]) && symptr->arcs[c] ) unused_layer[c] = 0;
* if( (c != PINLAYER || enable_layer[c]) && symptr->rects[c] ) unused_layer[c] = 0;
* if( (c == PINLAYER || xctx->enable_layer[c]) && symptr->lines[c] ) unused_layer[c] = 0;
* if( (c == PINLAYER || xctx->enable_layer[c]) && symptr->polygons[c] ) unused_layer[c] = 0;
* if( (c == PINLAYER || xctx->enable_layer[c]) && symptr->arcs[c] ) unused_layer[c] = 0;
* if( (c != PINLAYER || xctx->enable_layer[c]) && symptr->rects[c] ) unused_layer[c] = 0;
* if( (c==TEXTWIRELAYER && !(xctx->inst[i].flags&2) ) ||
* (sym_txt && (c==TEXTLAYER) && (xctx->inst[i].flags&2) ) )
* (xctx->sym_txt && (c==TEXTLAYER) && (xctx->inst[i].flags&2) ) )
* {
* int j;
* for(j=0;j< symptr->texts;j++)
@ -633,7 +633,7 @@ void svg_draw(void)
* if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
* }
* /* display PINLAYER colored instance texts even if PINLAYER disabled */
* if(xctx->inst[i].color == PINLAYER || enable_layer[textlayer]) {
* if(xctx->inst[i].color == PINLAYER || xctx->enable_layer[textlayer]) {
* used_layer[textlayer] = 0;
* }
* }
@ -651,9 +651,9 @@ void svg_draw(void)
for(i=0;i<cadlayers;i++){
if(unused_layer[i]) continue;
fprintf(fd, ".l%d{\n", i);
if(fill_type[i] == 1)
if(xctx->fill_type[i] == 1)
fprintf(fd, " fill: #%02x%02x%02x;\n", svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue);
else if(fill_type[i] == 2)
else if(xctx->fill_type[i] == 2)
fprintf(fd, " fill: #%02x%02x%02x; fill-opacity: 0.5;\n",
svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue);
else

View File

@ -255,7 +255,7 @@ void check_unique_names(int rename)
}
/* draw_hilight_net(1); */
redraw_hilights(0);
/* draw_window = save_draw; */
/* xctx->draw_window = save_draw; */
}

View File

@ -6,6 +6,7 @@
# and the allocation that was not freed, with the source code line.
# total and leak should indicate same amount of bytes, it is a cross check for the script.
BEGIN{
max = 0
total = 0
malloc = 0
free = 0
@ -19,6 +20,7 @@ BEGIN{
sub(/,.*/,"",id)
idx[$3] = id
total += $5
if(total > max) max = total
address[$3] = $5
malloc++
}
@ -26,7 +28,7 @@ BEGIN{
# my_free(977,): freeing 198efc0
/^my_free\(/{
if(!($3 in address)) {
print "Double free: " $0
print "Double free: " $0 " Log file line: " NR
} else {
total -= address[$3]
delete address[$3]
@ -44,11 +46,13 @@ BEGIN{
idx[$3] = id
if($3=="(nil)") { #malloc
total+=$7
if(total > max) max = total
address[$5] = $7
idx[$5] = id
}
else { # realloc
total += $7 - address[$3]
if(total > max) max = total
delete address[$3]
delete idx[$3]
address[$5] = $7
@ -58,20 +62,22 @@ BEGIN{
}
END{
print "total = " total
print "malloc = " malloc
print "realloc = " realloc
print "free = " free
print "peak allocated memory = " max
print "Total allocated memory after exit = " total
print "# of malloc's = " malloc
print "# of realloc's = " realloc
print "# of free's = " free
stale = 0
leak = 0
for(i in address) {
stale++
leak+= address[i]
print " address[ " i ", " idx[i] " ]= " address[i]
pipe = "grep -n ' \\([^/][^*]\\) *my_.*(" idx[i] ",' *.c xschem.h"
pipe = "egrep -n 'my_(malloc|calloc|realloc|free)\(" idx[i] ",' *.c xschem.h"
while( pipe | getline a) print " " a
close(pipe)
}
print "stale = " stale
print "leak = " leak
print "Number of unfreed pointers = " stale
# as a crosscheck 'leak' should be equal to 'total'.
print "Total leaked memory = " leak
}

View File

@ -269,7 +269,7 @@ void global_verilog_netlist(int global) /* netlister driver */
my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname);
override_netlist_type(CAD_VERILOG_NETLIST);
tcleval(tcl_cmd_netlist);
override_netlist_type(-1); /* restore to netlist_type default */
override_netlist_type(-1); /* restore to xctx->netlist_type default */
if(debug_var==0) xunlink(netl_filename);
}
@ -500,7 +500,7 @@ void verilog_block_netlist(FILE *fd, int i)
my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname);
override_netlist_type(CAD_VERILOG_NETLIST);
tcleval(tcl_cmd_netlist);
override_netlist_type(-1); /* restore to netlist_type default */
override_netlist_type(-1); /* restore to xctx->netlist_type default */
if(debug_var==0) xunlink(netl_filename);
}
my_free(1079, &dir_tmp);

View File

@ -209,6 +209,8 @@ unsigned int find_best_color(char colorname[])
double distance=10000000000.0, dist, r, g, b, red, green, blue;
double deltar,deltag,deltab;
unsigned int idx;
dbg(1, "find_best_color() start: %g\n", timer(1));
#ifdef __unix__
if( XAllocNamedColor(display, colormap, colorname, &xcolor_exact, &xcolor) ==0 )
#else
@ -218,23 +220,22 @@ unsigned int find_best_color(char colorname[])
#endif
{
for(i=0;i<=255;i++) {
xcolor_array[i].pixel=i;
xctx->xcolor_array[i].pixel=i;
#ifdef __unix__
XQueryColor(display, colormap, xcolor_array+i);
XQueryColor(display, colormap, xctx->xcolor_array+i);
#else
xcolor = *xc;
XQueryColors(display, colormap, xc, i);
#endif
}
/* debug ... */
dbg(2,
"find_best_color(): Server failed to allocate requested color, finding substitute\n");
dbg(2, "find_best_color(): Server failed to allocate requested color, finding substitute\n");
XLookupColor(display, colormap, colorname, &xcolor_exact, &xcolor);
red = xcolor.red; green = xcolor.green; blue = xcolor.blue;
idx=0;
for(i = 0;i<=255; i++)
{
r = xcolor_array[i].red ; g = xcolor_array[i].green ; b = xcolor_array[i].blue;
r = xctx->xcolor_array[i].red ; g = xctx->xcolor_array[i].green ; b = xctx->xcolor_array[i].blue;
deltar = (r - red);deltag = (g - green);deltab = (b - blue);
dist = deltar*deltar + deltag*deltag + deltab*deltab;
if( dist <= distance )
@ -253,55 +254,45 @@ unsigned int find_best_color(char colorname[])
idx = xc->pixel;
#endif
}
dbg(1, "find_best_color() return: %g\n", timer(1));
return idx;
}
void init_color_array(double dim)
static void init_color_array(double dim, double dim_bg)
{
char s[256]; /* overflow safe 20161122 */
int i;
int dim_bg;
unsigned int r, g, b;
double rr, gg, bb;
static int done=0;
double tmp_dim;
dim_bg = tclgetboolvar("color_dim");
for(i=0;i<cadlayers;i++) {
my_snprintf(s, S(s), "lindex $colors %d",i);
tcleval(s);
dbg(2, "init_color_array(): color:%s\n",tclresult());
sscanf(tclresult(), "#%02x%02x%02x", &r, &g, &b);
rr=r; gg=g; bb=b;
if(dim_bg || i!=BACKLAYER ) {
if(dim>=0.) {
rr +=(51.-rr/5.)*dim;
gg +=(51.-gg/5.)*dim;
bb +=(51.-bb/5.)*dim;
} else {
rr +=(rr/5.)*dim;
gg +=(gg/5.)*dim;
bb +=(bb/5.)*dim;
}
/* fprintf(errfp, "init_color_array: colors: %.16g %.16g %.16g dim=%.16g c=%d\n", rr, gg, bb, dim, i); */
r=rr;g=gg;b=bb;
if(r>0xff) r=0xff;
if(g>0xff) g=0xff;
if(b>0xff) b=0xff;
if(i == BACKLAYER) tmp_dim = dim_bg;
else tmp_dim = dim;
if(tmp_dim>=0.) {
r +=(51.-r/5.)*tmp_dim;
g +=(51.-g/5.)*tmp_dim;
b +=(51.-b/5.)*tmp_dim;
} else {
r +=(r/5.)*tmp_dim;
g +=(g/5.)*tmp_dim;
b +=(b/5.)*tmp_dim;
}
/* fprintf(errfp, "init_color_array: colors: %.16g %.16g %.16g dim=%.16g c=%d\n", r, g, b, dim, i); */
if(r>0xff) r=0xff;
if(g>0xff) g=0xff;
if(b>0xff) b=0xff;
my_snprintf(s, S(s), "#%02x%02x%02x", r, g, b);
if(!done) {
my_strdup(643, &color_array[i], s);
done = 1;
} else if(dim_bg || i!=BACKLAYER ) {
my_strdup(605, &color_array[i], s);
}
my_strdup(643, &xctx->color_array[i], s);
}
}
void init_pixdata()
void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
{
int i,j, full, empty;
for(i=0;i<cadlayers;i++) {
@ -315,11 +306,11 @@ void init_pixdata()
if(pixdata[i][j]!=0xff) full=0;
if(pixdata[i][j]!=0x00) empty=0;
}
if(full) fill_type[i] = 1;
else if(empty) fill_type[i] = 0;
else fill_type[i]=2;
if(rainbow_colors && i>5) fill_type[i]=1; /* 20171212 solid fill style */
/*fprintf(errfp, "fill_type[%d]= %d\n", i, fill_type[i]); */
if(full) xctx->fill_type[i] = 1;
else if(empty) xctx->fill_type[i] = 0;
else xctx->fill_type[i]=2;
if(rainbow_colors && i>5) xctx->fill_type[i]=1; /* 20171212 solid fill style */
/*fprintf(errfp, "fill_type[%d]= %d\n", i, xctx->fill_type[i]); */
}
}
@ -364,10 +355,54 @@ void free_xschem_data()
for(i=0;i<CADMAXHIER;i++) my_free(1139, &xctx->sch_path[i]);
my_free(1099, &xctx->gridpoint);
my_free(1214, &xctx->biggridpoint);
my_free(1135, &xctx->gc);
my_free(1136, &xctx->gcstipple);
for(i=0;i<cadlayers;i++) my_free(1101, &xctx->color_array[i]);
my_free(605, &xctx->color_array);
my_free(1123, &xctx->enable_layer);
my_free(1121, &xctx->active_layer);
my_free(1295, &xctx->top_path);
my_free(1120, &xctx->fill_type);
my_free(269, &xctx);
}
void alloc_xschem_data()
void create_gc(void)
{
int i;
for(i=0;i<cadlayers;i++)
{
pixmap[i] = XCreateBitmapFromData(display, xctx->window, (char*)(pixdata[i]),16,16);
xctx->gc[i] = XCreateGC(display,xctx->window,0L,NULL);
xctx->gcstipple[i] = XCreateGC(display,xctx->window,0L,NULL);
XSetStipple(display,xctx->gcstipple[i],pixmap[i]);
if(xctx->fill_type[i]==1) XSetFillStyle(display,xctx->gcstipple[i],FillSolid);
else XSetFillStyle(display,xctx->gcstipple[i],FillStippled);
}
}
void free_gc()
{
int i;
for(i=0;i<cadlayers;i++) {
XFreeGC(display,xctx->gc[i]);
XFreeGC(display,xctx->gcstipple[i]);
}
}
void get_netlist_type_from_tcl(void)
{
if(xctx->netlist_type==-1) {
if(!strcmp(tclgetvar("netlist_type"),"vhdl") ) xctx->netlist_type=CAD_VHDL_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"verilog") ) xctx->netlist_type=CAD_VERILOG_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"tedax") ) xctx->netlist_type=CAD_TEDAX_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"symbol") ) xctx->netlist_type=CAD_SYMBOL_ATTRS;
else xctx->netlist_type=CAD_SPICE_NETLIST;
} else {
override_netlist_type(-1); /* set tcl netlist_type */
}
}
void alloc_xschem_data(const char *top_path)
{
int i, j;
@ -381,7 +416,7 @@ void alloc_xschem_data()
/* 20180923 no more mkdtemp (portability issues) */
if( !my_strdup(644, &xctx->undo_dirname, create_tmpdir("xschem_undo_") )) {
fprintf(errfp, "xinit(): problems creating tmp undo dir\n");
tcleval( "exit");
tcleval("exit");
}
dbg(1, "undo_dirname=%s\n", xctx->undo_dirname);
#endif
@ -392,6 +427,7 @@ void alloc_xschem_data()
xctx->wires = 0;
xctx->instances = 0;
xctx->symbols = 0;
xctx->sym_txt = 1;
xctx->texts = 0;
xctx->schprop = NULL; /* SPICE */
xctx->schtedaxprop=NULL; /* tEDAx */
@ -529,26 +565,35 @@ void alloc_xschem_data()
xctx->draw_dots = 1;
xctx->no_draw = 0;
xctx->draw_pixmap = 1;
xctx->gc=my_calloc(638, cadlayers, sizeof(GC));
xctx->gcstipple=my_calloc(639, cadlayers, sizeof(GC));
xctx->color_array=my_calloc(637, cadlayers, sizeof(char*));
xctx->enable_layer=my_calloc(87, cadlayers, sizeof(int));
xctx->n_active_layers = 0;
xctx->active_layer=my_calloc(563, cadlayers, sizeof(int));
xctx->hide_symbols = 0;
xctx->netlist_type = -1;
xctx->top_path = NULL;
my_strdup2(1296, &xctx->top_path, top_path);
xctx->fill_type=my_calloc(640, cadlayers, sizeof(int));
xctx->fill_pattern = 1;
xctx->draw_window = 0;
}
void alloc_data()
void delete_schematic_data(void)
{
int i;
alloc_xschem_data();
/* global context / graphic preferences/settings */
fill_type=my_calloc(640, cadlayers, sizeof(int));
active_layer=my_calloc(563, cadlayers, sizeof(int));
color_array=my_calloc(637, cadlayers, sizeof(char*));
gc=my_calloc(638, cadlayers, sizeof(GC));
gcstipple=my_calloc(639, cadlayers, sizeof(GC));
pixdata=my_calloc(641, cadlayers, sizeof(char*));
for(i=0;i<cadlayers;i++)
{
pixdata[i]=my_calloc(642, 32, sizeof(char));
}
enable_layer=my_calloc(87, cadlayers, sizeof(int));
pixmap=my_calloc(636, cadlayers, sizeof(Pixmap));
dbg(1, "delete_schematic_data()\n");
unselect_all();
delete_netlist_structs(); /* netlist - specific data and hash tables */
clear_all_hilights(); /* data structs for hilighting nets/instances */
get_unnamed_node(0, 0, 0); /* net### enumerator used for netlisting */
if(has_x) {
resetwin(0, 1, 1, 0, 0); /* delete preview pixmap, delete cairo surfaces */
free_gc();
}
clear_drawing(); /* delete instances, wires, lines, rects, ... */
remove_symbols();
free_xschem_data(); /* delete the xctx struct */
}
void xwin_exit(void)
@ -559,53 +604,33 @@ void xwin_exit(void)
dbg(0, "xwin_exit() double call, doing nothing...\n");
return;
}
delete_netlist_structs();
clear_all_hilights();
get_unnamed_node(0, 0, 0);
if(has_x) {
resetwin(0, 1, 1, 0, 0); /* create_pixmap, clear_pixmap, force */
dbg(1, "xwin_exit(): Releasing pixmaps and cairo data structures\n");
for(i=0;i<cadlayers;i++)
{
XFreeGC(display,gc[i]);
XFreeGC(display,gcstipple[i]);
}
Tk_DestroyWindow(mainwindow);
dbg(1, "xwin_exit(): destroying tk windows and releasing X11 stuff\n");
#ifdef __unix__
if(cad_icon_pixmap) {
XFreePixmap(display, cad_icon_pixmap);
XFreePixmap(display, cad_icon_mask);
}
#else
if (cad_icon_pixmap) Tk_FreePixmap(display, cad_icon_pixmap);
#endif
#ifdef __unix__
for(i = 0; i < cadlayers; i++) XFreePixmap(display,pixmap[i]);
#else
for(i = 0; i < cadlayers; i++) Tk_FreePixmap(display, pixmap[i]);
#endif
}
my_free(1134, &pixmap);
dbg(1, "xwin_exit(): clearing drawing data structures\n");
clear_drawing();
remove_symbols();
get_tok_value(NULL, NULL, 0); /* clear static data in function */
free_xschem_data();
delete_schematic_data();
if(has_x) {
Tk_DestroyWindow(mainwindow);
#ifdef __unix__
if(cad_icon_pixmap) {
XFreePixmap(display, cad_icon_pixmap);
XFreePixmap(display, cad_icon_mask);
}
#else
if (cad_icon_pixmap) Tk_FreePixmap(display, cad_icon_pixmap);
#endif
#ifdef __unix__
for(i = 0; i < cadlayers; i++) XFreePixmap(display,pixmap[i]);
#else
for(i = 0; i < cadlayers; i++) Tk_FreePixmap(display, pixmap[i]);
#endif
my_free(1134, &pixmap);
}
dbg(1, "xwin_exit(): clearing drawing data structures\n");
/* global context - graphic preferences/settings */
for(i=0;i<cadlayers;i++) {
my_free(1101, &color_array[i]);
my_free(1102, &pixdata[i]);
}
my_free(1122, &pixdata);
my_free(1123, &enable_layer);
my_free(1135, &gc);
my_free(1136, &gcstipple);
my_free(1137, &color_array);
my_free(1138, &tcl_command);
my_free(1121, &active_layer);
my_free(1120, &fill_type);
clear_expandlabel_data();
get_sym_template(NULL, NULL); /* clear static data in function */
list_tokens(NULL, 0); /* clear static data in function */
@ -617,10 +642,8 @@ void xwin_exit(void)
save_ascii_string(NULL, NULL, 0); /* clear static data in function */
dbg(1, "xwin_exit(): removing font\n");
for(i=0;i<127;i++) my_free(1140, &character[i]);
dbg(1, "xwin_exit(): closed display\n");
my_free(1141, &filename);
my_free(1142, &netlist_dir);
my_free(1143, &xschem_executable);
record_global_node(2, NULL, NULL); /* delete global node array */
@ -634,16 +657,16 @@ void xwin_exit(void)
/*
* color structures in xschem:
* - color_array[]:
* - char *xctx->color_array[]:
* array of color character names ("#xxxxxx" hex) indexed by xschem layer number.
* these are set from tcl 'color' list variable in init_color_array()
* - color_index[]:
* - unsigned int xctx->color_index[]:
* array of integers, pixel values, color lookup table, indexed by xschem layer num.
* this array is initialized in build_colors() by calling find_best_color()
* indexes are returned from XAllocNamedColor()
* these are used in XSetForeground and XSetBackground calls:
* XSetForeground(display, gc, color_index[i])
* - xcolor_array[]:
* XSetForeground(display, gc, xctx->color_index[i])
* - XColor xctx->xcolor_array[]:
* array of 256 XColor structures:
* typedef struct {
* unsigned long pixel; // pixel value
@ -654,19 +677,20 @@ void xwin_exit(void)
* This array is used temporarily in find_best_color() to store all
* allocated colors in case of pseudocolor visuals to find best substitute when
* XAllocNamedColor fails to find the requested "color_array[i]".
* When all color_index[] are populated with pixel values xcolor_array[]
* When all xctx->color_index[] are populated with pixel values xctx->xcolor_array[]
* is reset with the xschem layer colors in build_colors() using XLookupColor():
* for(i=0;i<cadlayers;i++) {
* XLookupColor(display, colormap, color_array[i], &xcolor_exact, &xcolor);
* xcolor_array[i] = xcolor;
* XLookupColor(display, colormap, xctx->color_array[i], &xcolor_exact, &xcolor);
* xctx->xcolor_array[i] = xcolor;
* }
*
*
*
*/
int build_colors(double dim)
int build_colors(double dim, double dim_bg)
{
int i;
dbg(1, "build_colors(): dim=%g, dim_bg=%g\n", dim, dim_bg);
if(tclgetboolvar("dark_colorscheme")) {
tcleval("llength $dark_colors");
if(atoi(tclresult())>=cadlayers){
@ -686,20 +710,20 @@ int build_colors(double dim)
tcleval("regsub -all {\"} $colors {} svg_colors");
tcleval("regsub -all {#} $svg_colors {0x} svg_colors");
}
init_color_array(dim);
init_color_array(dim, dim_bg);
for(i=0;i<cadlayers;i++)
{
color_index[i] = find_best_color(color_array[i]);
xctx->color_index[i] = find_best_color(xctx->color_array[i]);
}
for(i=0;i<cadlayers;i++)
{
XSetBackground(display, gc[i], color_index[0]); /* for dashed lines 'off' color */
XSetForeground(display, gc[i], color_index[i]);
XSetForeground(display, gcstipple[i], color_index[i]);
XSetBackground(display, xctx->gc[i], xctx->color_index[0]); /* for dashed lines 'off' color */
XSetForeground(display, xctx->gc[i], xctx->color_index[i]);
XSetForeground(display, xctx->gcstipple[i], xctx->color_index[i]);
}
for(i=0;i<cadlayers;i++) {
XLookupColor(display, colormap, color_array[i], &xcolor_exact, &xcolor);
xcolor_array[i] = xcolor;
XLookupColor(display, colormap, xctx->color_array[i], &xcolor_exact, &xcolor);
xctx->xcolor_array[i] = xcolor;
}
tcleval("reconfigure_layers_menu");
return 0; /* success */
@ -754,19 +778,6 @@ int source_tcl_file(char *s)
return TCL_OK;
}
void delete_schematic_data(void)
{
dbg(1, "delete_schematic_data()\n");
unselect_all();
delete_netlist_structs(); /* netlist - specific data and hash tables */
clear_all_hilights(); /* data structs for hilighting nets/instances */
get_unnamed_node(0, 0, 0); /* net### enumerator used for netlisting */
remove_symbols();
clear_drawing(); /* delete instances, wires, lines, rects, ... */
resetwin(0, 1, 1, 0, 0); /* delete preview pixmap, delete cairo surfaces */
free_xschem_data(); /* delete the xctx struct */
}
void preview_window(const char *what, const char *tk_win_path, const char *filename)
{
static char *current_file = NULL;
@ -792,9 +803,14 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
}
my_strdup(117, &current_file, filename);
xctx = NULL; /* reset for preview */
alloc_xschem_data(); /* alloc data into xctx */
alloc_xschem_data(""); /* alloc data into xctx */
get_netlist_type_from_tcl();
init_pixdata(); /* populate xctx->fill_type array that is used in create_gc() to set fill styles */
preview_xctx = xctx;
preview_xctx->window = pre_window;
create_gc();
enable_layers();
build_colors(0.0, 0.0);
resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
dbg(1, "preview_window() draw, load schematic\n");
load_schematic(1,filename, 0);
@ -814,14 +830,19 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
my_free(1144, &current_file);
xctx = save_xctx; /* restore schematic */
save_xctx = NULL;
change_linewidth(xctx->lw); /* restore correct linewidth since it was changed in preview
* need to do the XSetLineAttributes */
set_modify(xctx->modified);
}
}
#define MAX_NEW_WINDOWS 20
void new_schematic(const char *what, const char *tk_win_path, const char *filename)
/* top_path is the path prefix of tk_win_path:
*
* tk_win_path top_path
* ".drw" ""
* ".xx.drw" ".xx"
*/
void new_schematic(const char *what, const char *top_path, const char *tk_win_path, const char *filename)
{
static int cnt = 0;
static Xschem_ctx *save_xctx[MAX_NEW_WINDOWS]; /* save pointer to current schematic context structure */
@ -851,63 +872,79 @@ void new_schematic(const char *what, const char *tk_win_path, const char *filena
tknew_window[n] = Tk_NameToWindow(interp, tk_win_path, mainwindow);
Tk_MakeWindowExist(tknew_window[n]);
new_window = Tk_WindowId(tknew_window[n]);
Tk_ChangeWindowAttributes(tknew_window[n], CWBackingStore, &winattr);
dbg(1, "new_schematic() draw\n");
xctx = NULL; /* reset for preview */
alloc_xschem_data(); /* alloc data into xctx */
alloc_xschem_data(top_path); /* alloc data into xctx */
xctx->netlist_type = CAD_SPICE_NETLIST; /* for new windows start with spice netlist mode */
tclsetvar("netlist_type","spice");
init_pixdata();/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
save_xctx[n] = xctx;
dbg(1, "new_schematic() draw, load schematic\n");
xctx->window = new_window;
set_snap(0); /* set default value specified in xschemrc as 'snap' else CADSNAP */
set_grid(0); /* set default value specified in xschemrc as 'grid' else CADGRID */
create_gc();
enable_layers();
build_colors(0.0, 0.0);
resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */
load_schematic(1,filename, 0);
load_schematic(1,filename, 1);
zoom_full(1, 0, 1, 0.97); /* draw */
} else if(!strcmp(what, "destroy")) {
if(cnt) {
int close = 0;
dbg(1, "new_schematic() destroy\n");
/* reset old focused window so callback() will force repaint on expose events */
my_strncpy(old_winpath, "", S(old_winpath));
if(xctx->modified && has_x) {
tcleval("tk_messageBox -type okcancel -message {UNSAVED data: want to exit?}");
tcleval("tk_messageBox -type okcancel -message \""
"[get_cell [xschem get schname] 0]"
": UNSAVED data: want to exit?\"");
if(strcmp(tclresult(),"ok")==0) close = 1;
}
else close = 1;
Tcl_ResetResult(interp);
if(close) {
tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow);
for(i = 1; i < MAX_NEW_WINDOWS; i++) {
tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow); /* NULL if tk_win_path not existing */
if(!tkwin) dbg(0, "new_schematic(destroy, ...): Warning: %s has been destroyed\n", tk_win_path);
if(tkwin) for(i = 1; i < MAX_NEW_WINDOWS; i++) {
if(tkwin == tknew_window[i]) {
n = i;
break;
}
}
if(n >= 1 && n < MAX_NEW_WINDOWS) {
if(tkwin && n >= 1 && n < MAX_NEW_WINDOWS) {
xctx = save_xctx[n];
delete_schematic_data();
save_xctx[n] = NULL;
Tcl_VarEval(interp, "winfo parent ", tk_win_path, NULL);
Tcl_VarEval(interp, "winfo toplevel ", tk_win_path, NULL);
Tk_DestroyWindow(tknew_window[n]);
Tcl_VarEval(interp, "destroy ", tclresult(), NULL);
tknew_window[n] = NULL;
xctx = save_xctx[0]; /* restore schematic */
set_modify(xctx->modified);
/* delete Tcl context of deleted schematic window */
Tcl_VarEval(interp, "delete_ctx ", tk_win_path, "; incr tctx::cnt -1", NULL);
cnt--;
}
}
xctx = save_xctx[0]; /* restore main (.drw) schematic */
tcleval("restore_ctx .drw; housekeeping_ctx");
set_modify(xctx->modified); /* sets window title */
}
} else if(!strcmp(what, "switch")) {
if(cnt) {
dbg(1, "new_schematic() switch\n");
tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow);
for(i = 0; i < MAX_NEW_WINDOWS; i++) {
dbg(1, "new_schematic() switch: %s\n", tk_win_path);
tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow); /* NULL if tk_win_path not existing */
if(!tkwin) dbg(0, "new_schematic(switch,...): Warning: %s has been destroyed\n", tk_win_path);
if(tkwin) for(i = 0; i < MAX_NEW_WINDOWS; i++) {
if(tkwin == tknew_window[i]) {
n = i;
break;
}
}
if(n >= 0 && n < MAX_NEW_WINDOWS) {
/* if window was closed then tkwin == 0 --> do nothing */
if(tkwin && n >= 0 && n < MAX_NEW_WINDOWS) {
xctx = save_xctx[n];
change_linewidth(xctx->lw); /* restore correct linewidth since it was changed in preview
* need to do the XSetLineAttributes */
set_modify(xctx->modified);
/* draw();*/
set_modify(xctx->modified); /* sets window title */
}
}
}
@ -935,7 +972,7 @@ void change_linewidth(double w)
if(!changed) return;
if(has_x) {
for(i=0;i<cadlayers;i++) {
XSetLineAttributes (display, gc[i], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
XSetLineAttributes (display, xctx->gc[i], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
}
XSetLineAttributes (display, xctx->gctiled, INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
}
@ -947,7 +984,6 @@ void change_linewidth(double w)
xctx->areah = xctx->areay2 - xctx->areay1;
}
/* clears and creates cairo_sfc, cairo_ctx, cairo_save_sfc, cairo_save_ctx
* and sets some graphical attributes */
void resetcairo(int create, int clear, int force_or_resize)
@ -1113,8 +1149,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
const char *home_buff;
int running_in_src_dir;
int fs;
/* XVisualInfo vinfo; */
/* XVisualInfo vinfo; */
#if HAS_XCB==1
#if HAS_XRENDER==1
xcb_render_query_pict_formats_reply_t *formats_reply;
@ -1122,6 +1158,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
xcb_render_query_pict_formats_cookie_t formats_cookie;
#endif
#endif
/* get PWD and HOME */
if(!getcwd(pwd_dir, PATH_MAX)) {
fprintf(errfp, "Tcl_AppInit(): getcwd() failed\n");
@ -1137,8 +1174,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
#endif
my_strncpy(home_dir, home_buff, S(home_dir));
/* set error and exit handlers */
XSetErrorHandler(err);
interp=inter;
Tcl_Init(interp);
if(has_x) {
@ -1151,21 +1188,20 @@ int Tcl_AppInit(Tcl_Interp *inter)
tcleval(tmp);
tclsetvar("XSCHEM_LIBRARY_PATH", tclresult());
running_in_src_dir = 0;
/* create user conf dir , remove ~ if present */
my_snprintf(tmp, S(tmp),"regsub {^~/} {%s} {%s/}", USER_CONF_DIR, home_dir);
tcleval(tmp);
my_snprintf(user_conf_dir, S(user_conf_dir), "%s", tclresult());
tclsetvar("USER_CONF_DIR", user_conf_dir);
/* test if running xschem in src/ dir (usually for testing) */
running_in_src_dir = 0;
if( !stat("./xschem.tcl", &buf) && !stat("./systemlib", &buf) && !stat("./xschem", &buf)) {
running_in_src_dir = 1;
tclsetvar("XSCHEM_SHAREDIR",pwd_dir); /* for testing xschem builds in src dir*/
/*
my_snprintf(tmp, S(tmp), "subst .:[file normalize \"%s/../xschem_library/devices\"]", pwd_dir);
tcleval(tmp);
tclsetvar("XSCHEM_LIBRARY_PATH", tclresult());
*/
/* set builtin library path if running in src/ */
my_snprintf(tmp, S(tmp),
"set XSCHEM_LIBRARY_PATH %s/xschem_library", user_conf_dir);
tcleval(tmp);
@ -1198,47 +1234,47 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* ... else give up searching, may set later after loading xschemrc */
}
#else
char install_dir[MAX_PATH]="";
char *up_hier=NULL, *win_xschem_library_path=NULL;
#define WIN_XSCHEM_LIBRARY_PATH_NUM 9
const char *WIN_XSCHEM_LIBRARY_PATH[WIN_XSCHEM_LIBRARY_PATH_NUM] = {
/*1*/ "xschem_library",
/*2*/ "xschem_library/devices",
/*3*/ "xschem_library/examples",
/*4*/ "xschem_library/ngspice",
/*5*/ "xschem_library/logic",
/*6*/ "xschem_library/xschem_simulator"};
/*7*/ "xschem_library/binto7seg",
/*8*/ "xschem_library/pcb",
/*9*/ "xschem_library/rom8k",
GetModuleFileNameA(NULL, install_dir, MAX_PATH);
change_to_unix_fn(install_dir);
int dir_len=strlen(install_dir);
if (dir_len>11)
install_dir[dir_len-11] = '\0'; /* 11 = remove /xschem.exe */
/* debugging in Visual Studio will not have bin */
my_snprintf(tmp, S(tmp), "regexp {bin$} \"%s\"", install_dir);
tcleval(tmp);
running_in_src_dir = 0;
if (atoi(tclresult()) == 0)
{
running_in_src_dir = 1; /* no bin, so it's running in Visual studio source directory*/
my_strdup(62, &up_hier, "../../..");
}
else my_strdup(63, &up_hier, "..");
my_strcat(415, &win_xschem_library_path, ".");
for (i = 0; i < WIN_XSCHEM_LIBRARY_PATH_NUM; ++i) {
my_snprintf(tmp, S(tmp),"%s/%s/%s", install_dir, up_hier, WIN_XSCHEM_LIBRARY_PATH[i]);
my_strcat(416, &win_xschem_library_path, "\;");
my_strcat(431, &win_xschem_library_path, tmp);
}
my_snprintf(tmp, S(tmp), "set tmp2 \"%s\"; "
"while {[regsub {([^/]*\\.*[^./]+[^/]*)/\\.\\./?} $tmp2 {} tmp2]} {}; ", win_xschem_library_path);
const char *result2 = tcleval(tmp);
const char *win_xschem_library_path_clean = tclgetvar("tmp2");
tclsetvar("XSCHEM_LIBRARY_PATH", win_xschem_library_path_clean);
my_free(432, &win_xschem_library_path);
my_free(441, &up_hier);
char install_dir[MAX_PATH]="";
char *up_hier=NULL, *win_xschem_library_path=NULL;
#define WIN_XSCHEM_LIBRARY_PATH_NUM 9
const char *WIN_XSCHEM_LIBRARY_PATH[WIN_XSCHEM_LIBRARY_PATH_NUM] = {
/*1*/ "xschem_library",
/*2*/ "xschem_library/devices",
/*3*/ "xschem_library/examples",
/*4*/ "xschem_library/ngspice",
/*5*/ "xschem_library/logic",
/*6*/ "xschem_library/xschem_simulator",
/*7*/ "xschem_library/binto7seg",
/*8*/ "xschem_library/pcb",
/*9*/ "xschem_library/rom8k" };
GetModuleFileNameA(NULL, install_dir, MAX_PATH);
change_to_unix_fn(install_dir);
int dir_len=strlen(install_dir);
if (dir_len>11)
install_dir[dir_len-11] = '\0'; /* 11 = remove /xschem.exe */
/* debugging in Visual Studio will not have bin */
my_snprintf(tmp, S(tmp), "regexp {bin$} \"%s\"", install_dir);
tcleval(tmp);
running_in_src_dir = 0;
if (atoi(tclresult()) == 0)
{
running_in_src_dir = 1; /* no bin, so it's running in Visual studio source directory*/
my_strdup(62, &up_hier, "../../..");
}
else my_strdup(63, &up_hier, "..");
my_strcat(415, &win_xschem_library_path, ".");
for (i = 0; i < WIN_XSCHEM_LIBRARY_PATH_NUM; ++i) {
my_snprintf(tmp, S(tmp),"%s/%s/%s", install_dir, up_hier, WIN_XSCHEM_LIBRARY_PATH[i]);
my_strcat(416, &win_xschem_library_path, "\;");
my_strcat(431, &win_xschem_library_path, tmp);
}
my_snprintf(tmp, S(tmp), "set tmp2 \"%s\"; "
"while {[regsub {([^/]*\\.*[^./]+[^/]*)/\\.\\./?} $tmp2 {} tmp2]} {}; ", win_xschem_library_path);
const char *result2 = tcleval(tmp);
const char *win_xschem_library_path_clean = tclgetvar("tmp2");
tclsetvar("XSCHEM_LIBRARY_PATH", win_xschem_library_path_clean);
my_free(432, &win_xschem_library_path);
my_free(441, &up_hier);
char *xschem_sharedir=NULL;
if ((xschem_sharedir=getenv("XSCHEM_SHAREDIR")) != NULL) {
if (!stat(xschem_sharedir, &buf)) {
@ -1270,8 +1306,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
tclsetvar("USER_CONF_DIR", user_conf_dir);
#endif
/* create USER_CONF_DIR if it was not installed */
if(stat(user_conf_dir, &buf)) {
if(!mkdir(user_conf_dir, 0700)) {
@ -1327,7 +1361,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
}
}
}
/* END LOOKING FOR xschemrc */
/* END SOURCING xschemrc */
if(rainbow_colors) tclsetvar("rainbow_colors","1");
@ -1363,6 +1397,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): done step a1 of xinit()\n");
/* Execute tcl script given on command line with --tcl */
if(tcl_command) {
tcleval(tcl_command);
}
@ -1397,23 +1433,16 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): sourcing %s\n", name);
source_tcl_file(name);
dbg(1, "Tcl_AppInit(): done executing xschem.tcl\n");
/* END EXECUTE xschem.tcl */
/* */
/* END EXECUTE xschem.tcl */
/* */
/* resolve absolute pathname of xschem (argv[0]) for future usage */
my_strdup(44, &xschem_executable, get_file_path(xschem_executable));
dbg(1, "Tcl_AppInit(): resolved xschem_executable=%s\n", xschem_executable);
/* set global variables fetching data from tcl code 25122002 */
if(netlist_type==-1) {
if(!strcmp(tclgetvar("netlist_type"),"vhdl") ) netlist_type=CAD_VHDL_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"verilog") ) netlist_type=CAD_VERILOG_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"tedax") ) netlist_type=CAD_TEDAX_NETLIST;
else if(!strcmp(tclgetvar("netlist_type"),"symbol") ) netlist_type=CAD_SYMBOL_ATTRS;
else netlist_type=CAD_SPICE_NETLIST;
} else {
override_netlist_type(-1); /* set tcl netlist_type */
}
/* get xschem globals from tcl variables set in xschemrc/xschem.tcl */
cairo_font_line_spacing = tclgetdoublevar("cairo_font_line_spacing");
if(color_ps==-1)
color_ps=atoi(tclgetvar("color_ps"));
@ -1423,7 +1452,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
}
l_width=atoi(tclgetvar("line_width"));
if(tclgetboolvar("change_lw")) l_width = 0.0;
draw_window=atoi(tclgetvar("draw_window"));
cadlayers=atoi(tclgetvar("cadlayers"));
if(debug_var==-10) debug_var=0;
my_snprintf(tmp, S(tmp), "%.16g",CADGRID);
@ -1438,10 +1466,25 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* */
/* [m]allocate dynamic memory */
/* */
alloc_data();
alloc_xschem_data("");
/* global context / graphic preferences/settings */
pixdata=my_calloc(641, cadlayers, sizeof(char*));
for(i=0;i<cadlayers;i++)
{
pixdata[i]=my_calloc(642, 32, sizeof(char));
}
pixmap=my_calloc(636, cadlayers, sizeof(Pixmap));
init_pixdata();
init_color_array(0.0);
my_strncpy(xctx->plotfile, cli_opt_plotfile, S(xctx->plotfile));
xctx->draw_window=atoi(tclgetvar("draw_window"));
/* set global variables fetching data from tcl code */
xctx->netlist_type = cli_opt_netlist_type;
get_netlist_type_from_tcl();
init_pixdata();/* populate xctx->fill_type array that is used in create_gc() to set fill styles */
init_color_array(0.0, 0.0);
my_snprintf(tmp, S(tmp), "%d",debug_var);
tclsetvar("debug_var",tmp );
tclsetvar("menu_debug_var",debug_var ? "1" : "0" );
@ -1464,7 +1507,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
my_strncpy(xctx->file_version, XSCHEM_FILE_VERSION, S(xctx->file_version));
/* compile_font() needs enabled layers, these are set after xschem.tcl loading completed
* so we temporarily enable all them here */
for(i = 0; i < cadlayers; i++) enable_layer[i] = 1;
for(i = 0; i < cadlayers; i++) xctx->enable_layer[i] = 1;
compile_font();
/* restore current dir after loading font */
if(getenv("PWD")) {
@ -1547,17 +1590,11 @@ int Tcl_AppInit(Tcl_Interp *inter)
visual = vinfo.visual;
*/
dbg(1, "Tcl_AppInit(): done step b of xinit()\n");
for(i=0;i<cadlayers;i++)
{
pixmap[i] = XCreateBitmapFromData(display, xctx->window, (char*)(pixdata[i]),16,16);
gc[i] = XCreateGC(display,xctx->window,0L,NULL);
gcstipple[i] = XCreateGC(display,xctx->window,0L,NULL);
XSetStipple(display,gcstipple[i],pixmap[i]);
if(fill_type[i]==1) XSetFillStyle(display,gcstipple[i],FillSolid);
else XSetFillStyle(display,gcstipple[i],FillStippled);
}
create_gc();
dbg(1, "Tcl_AppInit(): done step c of xinit()\n");
if(build_colors(0.0)) exit(-1);
if(build_colors(0.0, 0.0)) exit(-1);
dbg(1, "Tcl_AppInit(): done step e of xinit()\n");
/* xctx->save_pixmap must be created as resetwin() frees it before recreating with new size. */
@ -1572,6 +1609,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
change_linewidth(l_width);
dbg(1, "Tcl_AppInit(): done xinit()\n");
/* Set backing store window attribute */
winattr.backing_store = WhenMapped;
/* winattr.backing_store = NotUseful;*/
Tk_ChangeWindowAttributes(tkwindow, CWBackingStore, &winattr);
@ -1657,7 +1695,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): filename %s given, removing symbols\n", filename);
remove_symbols();
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
to tcl is_xschem_file that could change netlist_type to symbol */
to tcl is_xschem_file that could change xctx->netlist_type to symbol */
load_schematic(1, f, !do_netlist);
Tcl_VarEval(interp, "update_recent_file {", f, "}", NULL);
} else if(!tcl_script[0]) {
@ -1667,15 +1705,13 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): tmp=%s\n", tmp? tmp: "NULL");
my_strncpy(filename, abs_sym_path(tmp, ""), S(filename));
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
to tcl is_xschem_file that could change netlist_type to symbol */
to tcl is_xschem_file that could change xctx->netlist_type to symbol */
load_schematic(1, filename, !do_netlist);
}
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the
* initial area to display
*/
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the initial area to display */
xctx->pending_fullzoom=1;
if(do_netlist) {
if(debug_var>=1) {
@ -1684,16 +1720,16 @@ int Tcl_AppInit(Tcl_Interp *inter)
}
if(!filename) {
fprintf(errfp, "xschem: cant do a netlist without a filename\n");
tcleval( "exit");
tcleval("exit");
}
if(netlist_dir && netlist_dir[0]) {
if(netlist_type == CAD_SPICE_NETLIST)
if(xctx->netlist_type == CAD_SPICE_NETLIST)
global_spice_netlist(1); /* 1 means global netlist */
else if(netlist_type == CAD_VHDL_NETLIST)
else if(xctx->netlist_type == CAD_VHDL_NETLIST)
global_vhdl_netlist(1); /* 1 means global netlist */
else if(netlist_type == CAD_VERILOG_NETLIST)
else if(xctx->netlist_type == CAD_VERILOG_NETLIST)
global_verilog_netlist(1); /* 1 means global netlist */
else if(netlist_type == CAD_TEDAX_NETLIST)
else if(xctx->netlist_type == CAD_TEDAX_NETLIST)
global_tedax_netlist(1); /* 1 means global netlist */
} else {
fprintf(errfp, "xschem: please set netlist_dir in xschemrc\n");
@ -1702,7 +1738,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
if(do_print) {
if(!filename) {
dbg(0, "xschem: can't do a print without a filename\n");
tcleval( "exit");
tcleval("exit");
}
if(do_print==1) {
@ -1732,7 +1768,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
if(do_simulation) {
if(!filename) {
fprintf(errfp, "xschem: can't do a simulation without a filename\n");
tcleval( "exit");
tcleval("exit");
}
tcleval( "simulate");
}
@ -1740,18 +1776,18 @@ int Tcl_AppInit(Tcl_Interp *inter)
if(do_waves) {
if(!filename) {
fprintf(errfp, "xschem: can't show simulation waves without a filename\n");
tcleval( "exit");
tcleval("exit");
}
tcleval( "waves [file tail \"[xschem get schname]\"]");
}
/* source tcl file given on command line with --script */
if(tcl_script[0]) {
Tcl_VarEval(interp, "update; source ", tcl_script, NULL);
}
if(quit) {
tcleval( "exit");
tcleval("exit");
}
/* */
@ -1765,7 +1801,10 @@ int Tcl_AppInit(Tcl_Interp *inter)
#endif
!no_readline) {
tcleval( "if {![catch {package require tclreadline}]} "
"{::tclreadline::readline customcompleter completer; ::tclreadline::Loop }" ) ;
"{::tclreadline::readline builtincompleter 0;"
/* "::tclreadline::readline customcompleter completer;" */
"::tclreadline::Loop }"
);
}
dbg(1, "Tcl_AppInit(): returning TCL_OK\n");

View File

@ -510,6 +510,7 @@ typedef struct {
xArc **arc;
xInstance *inst;
xSymbol *sym;
int sym_txt;
int wires;
int instances;
int symbols;
@ -579,6 +580,14 @@ typedef struct {
cairo_t *cairo_ctx, *cairo_save_ctx;
#endif
GC gctiled;
GC *gc;
GC *gcstipple;
char **color_array;
unsigned int color_index[256];
XColor xcolor_array[256];
int *enable_layer;
int n_active_layers;
int *active_layer;
char *undo_dirname;
int cur_undo_ptr;
int tail_undo_ptr;
@ -631,6 +640,19 @@ typedef struct {
int no_draw;
int draw_pixmap; /* pixmap used as 2nd buffer */
int netlist_count; /* netlist counter incremented at any cell being netlisted */
int hide_symbols;
int netlist_type;
char * top_path;
/* top_path is the path prefix of drawing canvas:
*
* canvas top_path
* ----------------------
* ".drw" ""
* ".xx.drw" ".xx"
*/
int *fill_type; /* for every layer: 0: no fill, 1, solid fill, 2: stipple fill */
int fill_pattern;
int draw_window;
} Xschem_ctx;
struct Lcc { /* used for symbols containing schematics as instances (LCC, Local Custom Cell) */
@ -707,27 +729,44 @@ struct instentry {
};
/* GLOBAL VARIABLES */
extern Xschem_ctx *xctx;
/*********** Variables backed in xschem.tcl ***********/
/*********** X11 specific globals ***********/
extern Colormap colormap;
extern unsigned char **pixdata;
extern unsigned char pixdata_init[22][32];
extern Display *display;
extern int screen_number;
extern int screendepth;
extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap;
extern Visual *visual;
#if HAS_XRENDER==1
extern XRenderPictFormat *render_format;
#endif
#if HAS_XCB==1
extern xcb_connection_t *xcbconn;
extern xcb_screen_t *screen_xcb;
#if HAS_XRENDER==1
extern xcb_render_pictforminfo_t format_rgb, format_rgba;
#endif
extern xcb_visualtype_t *visual_xcb;
#endif /* HAS_XCB */
/*********** These variables are mirrored in tcl code ***********/
extern int cadlayers;
extern int has_x;
extern int rainbow_colors;
extern int draw_window;
extern int only_probes;
extern char *netlist_dir;
extern int color_ps;
extern int constrained_move;
extern int netlist_type;
extern int flat_netlist;
extern int *enable_layer;
extern int hide_symbols;
extern int sym_txt;
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern double cairo_vert_correct;
extern char *netlist_dir;
extern int color_ps;
extern int only_probes;
extern double nocairo_vert_correct;
extern double cairo_vert_correct;
extern int constrained_move;
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern double cairo_font_line_spacing;
extern int debug_var;
/*********** End of variables backed in xschem.tcl ***********/
/*********** These variables are NOT mirrored in tcl code ***********/
extern int help;
extern char *cad_icon[];
extern int do_print;
@ -742,13 +781,6 @@ extern char rcfile[PATH_MAX];
extern char *tcl_command;
extern char tcl_script[PATH_MAX];
extern int tcp_port;
extern char **color_array;
extern unsigned int color_index[];
extern int n_active_layers; /* can not be put in Xctx, since it is bound to enable_layer[] */
extern int *active_layer; /* can not be put in Xctx, since it is bound to enable_layer[] */
extern int *fill_type; /* for every layer: 0: no fill, 1, solid fill, 2: stipple fill */
/* can not be put in Xctx, since it sets XSetFillStyle */
extern int fill_pattern; /* fill rectangles, can not be put in Xctx, since it sets XSetFillStyle */
extern int text_svg;
extern int text_ps;
extern double cadhalfdotsize;
@ -764,29 +796,14 @@ extern int do_waves;
extern int quit;
extern int batch_mode; /* no TCL console */
extern const char fopen_read_mode[]; /* "r" on unix, "rb" on windows */
extern char old_winpath[PATH_MAX]; /* previous focused schematic window (used to switch context) */
/* X11 specific globals */
extern Colormap colormap;
extern unsigned char **pixdata;
extern unsigned char pixdata_init[22][32];
extern GC *gc, *gcstipple;
extern Display *display;
extern int screen_number;
extern int screendepth;
extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap;
extern XColor xcolor_array[];
extern Visual *visual;
#if HAS_XRENDER==1
extern XRenderPictFormat *render_format;
#endif
#if HAS_XCB==1
extern xcb_connection_t *xcbconn;
extern xcb_screen_t *screen_xcb;
#if HAS_XRENDER==1
extern xcb_render_pictforminfo_t format_rgb, format_rgba;
#endif
extern xcb_visualtype_t *visual_xcb;
#endif /* HAS_XCB */
/*********** Cmdline options (used at xinit, and then not used anymore) ***********/
extern int cli_opt_netlist_type;
extern char cli_opt_plotfile[PATH_MAX];
/*********** Following data is relative to the current schematic ***********/
extern Xschem_ctx *xctx;
/* FUNCTIONS */
extern double timer(int start);
@ -1140,13 +1157,13 @@ extern void change_layer();
extern void launcher();
extern void windowid();
extern void preview_window(const char *what, const char *tk_win_path, const char *filename);
extern void new_schematic(const char *what, const char *tk_win_path, const char *filename);
extern void new_schematic(const char *what, const char *top_path, const char *tk_win_path, const char *filename);
extern int window_state (Display *disp, Window win, char *arg);
extern void toggle_fullscreen(const char *topwin);
extern void toggle_only_probes();
extern void update_symbol(const char *result, int x);
extern void tclexit(ClientData s);
extern int build_colors(double dim); /* reparse the TCL 'colors' list and reassign colors 20171113 */
extern int build_colors(double dim, double dim_bg); /* reparse the TCL 'colors' list and reassign colors 20171113 */
extern void drill_hilight(int mode);
extern void get_square(double x, double y, int *xx, int *yy);
extern void del_wire_table(void);

View File

@ -39,7 +39,7 @@ proc set_ne { var val } {
###
# execute service function
proc execute_fileevent {id} {
global execute_pipe execute_data execute_cmd simulate_oldbg
global execute_pipe execute_data execute_cmd
global execute_status execute_callback
append execute_data($id) [read $execute_pipe($id) 1024]
if {[eof $execute_pipe($id)]} {
@ -555,7 +555,11 @@ proc simconf_yview { args } {
proc simconf {} {
global sim USER_CONF_DIR simconf_default_geometry
catch { destroy .sim }
if {[winfo exists .sim]} {
destroy .sim
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
xschem set semaphore [expr {[xschem get semaphore] +1}]
set_sim_defaults
toplevel .sim -class dialog
wm title .sim {Simulation Configuration}
@ -601,9 +605,12 @@ proc simconf {} {
incr toggle
set toggle [expr {$toggle %2}]
}
button .sim.bottom.cancel -text Cancel -command {destroy .sim}
button .sim.bottom.cancel -text Cancel -command {
destroy .sim
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
button .sim.bottom.help -text Help -command {
set h {The following variables are defined and will get substituted by
viewdata {The following variables are defined and will get substituted by
XSCHEM before sending commands to the shell:
- N: complete filename of netlist for current netlisting mode
@ -624,11 +631,12 @@ Foreground checkbutton tells xschem to wait for child process to finish.
Status checkbutton tells xschem to report a status dialog (stdout, stderr,
exit status) when process finishes.
Any changes made in the command or tool name entries will be saved in
~/.xschem/simrc when 'Save Configuration' button is pressed.
~/.xschem/simrc when 'Accept and Save Configuration' button is pressed.
If 'Accept and Close' is pressed then the changes are kept in memory
without writing to a file. If xschem is restarted changes will be lost.
If no ~/.xschem/simrc is present then a bare minumum skeleton setup is presented.
To reset to default just delete the ~/.xschem/simrc file manually.
}
viewdata $h ro
} ro
}
button .sim.bottom.ok -text {Accept and Save Configuration} -command {
foreach tool $sim(tool_list) {
@ -637,20 +645,27 @@ To reset to default just delete the ~/.xschem/simrc file manually.
}
}
# destroy .sim
# xschem set semaphore [expr {[xschem get semaphore] -1}]
save_sim_defaults ${USER_CONF_DIR}/simrc
# puts "saving simrc"
}
button .sim.bottom.close -text {Accept and Close} -command {
set_sim_defaults
destroy .sim
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
wm protocol .sim WM_DELETE_WINDOW {
set_sim_defaults
destroy .sim
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
wm protocol .sim WM_DELETE_WINDOW { set_sim_defaults; destroy .sim }
pack .sim.bottom.cancel -side left -anchor w
pack .sim.bottom.help -side left
#foreach tool $sim(tool_list) {
# button .sim.bottom.add${tool} -text +${tool} -command "
# simconf_add $tool
# destroy .sim
# xschem set semaphore [expr {[xschem get semaphore] -1}]
# save_sim_defaults ${USER_CONF_DIR}/simrc
## simconf
# "
@ -1241,15 +1256,27 @@ proc load_file_dialog_mkdir {dir} {
myload_set_colors2
}
}
proc load_file_dialog_up {dir} {
global myload_dir1
bind .dialog.l.paneright.pre <Expose> {}
.dialog.l.paneright.pre configure -background white
set d [file dirname $dir]
if { [file isdirectory $d]} {
myload_set_home $d
setglob $d
myload_set_colors2
set myload_dir1 $d
}
}
proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {initialfile {}}
{loadfile {1}} {confirm_overwrt {1}}} {
global myload_index1 myload_files2 myload_files1 myload_retval myload_dir1 pathlist OS
global myload_default_geometry myload_sash_pos myload_yview tcl_version globfilter myload_dirs2
# return value
set myload_retval {}
upvar #0 $global_initdir initdir
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class dialog
wm title .dialog $msg
set_ne myload_index1 0
@ -1258,10 +1285,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
set myload_index1 0
}
set_ne myload_files2 {}
panedwindow .dialog.l -orient horizontal
frame .dialog.l.paneleft
if {$tcl_version > 8.5} { set just {-justify right}} else {set just {}}
eval [subst {listbox .dialog.l.paneleft.list -listvariable myload_files1 -width 20 -height 12 $just \
@ -1284,7 +1308,6 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
myload_set_colors2
}
}
frame .dialog.l.paneright
frame .dialog.l.paneright.pre -background white -width 200 -height 200
listbox .dialog.l.paneright.list -listvariable myload_files2 -width 20 -height 12\
@ -1303,9 +1326,14 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
# .dialog.l paneconfigure .dialog.l.paneright -stretch always
frame .dialog.buttons
frame .dialog.buttons_bot
button .dialog.buttons_bot.ok -width 5 -text OK \
-command { set myload_retval [.dialog.buttons_bot.entry get]; destroy .dialog}
button .dialog.buttons_bot.cancel -width 5 -text Cancel -command {set myload_retval {}; destroy .dialog}
button .dialog.buttons_bot.ok -width 5 -text OK -command {
set myload_retval [.dialog.buttons_bot.entry get]
destroy .dialog
}
button .dialog.buttons_bot.cancel -width 5 -text Cancel -command {
set myload_retval {}
destroy .dialog
}
button .dialog.buttons.home -width 5 -text {Home} -command {
bind .dialog.l.paneright.pre <Expose> {}
.dialog.l.paneright.pre configure -background white
@ -1332,17 +1360,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
-command { setglob $myload_dir1 }
radiobutton .dialog.buttons_bot.sch -text .sch -variable globfilter -value {*.sch} \
-command { setglob $myload_dir1 }
button .dialog.buttons.up -width 5 -text Up -command {
bind .dialog.l.paneright.pre <Expose> {}
.dialog.l.paneright.pre configure -background white
set d [file dirname $myload_dir1]
if { [file isdirectory $d]} {
myload_set_home $d
setglob $d
myload_set_colors2
set myload_dir1 $d
}
}
button .dialog.buttons.up -width 5 -text Up -command {load_file_dialog_up $myload_dir1}
label .dialog.buttons.mkdirlab -text { New dir: }
entry .dialog.buttons.newdir -width 16
button .dialog.buttons.mkdir -width 5 -text Create -command {
@ -1355,17 +1373,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
myload_set_colors2
}
}
button .dialog.buttons.pwd -text {Current file dir} -command {
bind .dialog.l.paneright.pre <Expose> {}
.dialog.l.paneright.pre configure -background white
set d [xschem get current_dirname]
if { [file isdirectory $d]} {
myload_set_home $d
setglob $d
myload_set_colors2
set myload_dir1 $d
}
}
button .dialog.buttons.pwd -text {Current file dir} -command {load_file_dialog_up $myload_dir1}
pack .dialog.buttons.home .dialog.buttons.up .dialog.buttons.pwd -side left
pack .dialog.buttons.mkdirlab -side left
pack .dialog.buttons.newdir -expand true -fill x -side left
@ -1393,7 +1401,10 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
destroy .dialog
}
}
bind .dialog <Escape> { set myload_retval {}; destroy .dialog}
bind .dialog <Escape> {
set myload_retval {}
destroy .dialog
}
### update
if { [ info exists myload_sash_pos] } {
@ -1479,6 +1490,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
.dialog.l.paneright.list yview moveto [lindex $myload_yview 0]
}
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
xschem preview_window destroy {} {}
set initdir "$myload_dir1"
if { $myload_retval ne {}} {
@ -1825,6 +1837,7 @@ proc select_netlist_dir { force {dir {} }} {
proc enter_text {textlabel {preserve_disabled disabled}} {
global retval rcode has_cairo preserve_unchanged_attrs wm_fix
set rcode {}
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Enter text}
@ -1909,13 +1922,18 @@ proc enter_text {textlabel {preserve_disabled disabled}} {
bind .dialog <Control-Return> {.dialog.buttons.ok invoke}
#grab set .dialog
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $retval
}
# evaluate a tcl command from GUI
proc tclcmd {} {
global tclcmd_txt
catch {destroy .tclcmd}
if {[winfo exists .tclcmd]} {
destroy .tclcmd
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .tclcmd -class dialog
label .tclcmd.txtlab -text {Enter TCL expression:}
label .tclcmd.result -text {Result:}
@ -1928,6 +1946,7 @@ proc tclcmd {} {
button .tclcmd.b.close -text Close -command {
set tclcmd_txt [.tclcmd.t get 1.0 end]
destroy .tclcmd
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
button .tclcmd.b.ok -text Evaluate -command {
set tclcmd_txt [.tclcmd.t get 1.0 end]
@ -1947,6 +1966,7 @@ proc tclcmd {} {
proc select_layers {} {
global dark_colorscheme colors enable_layer
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .sl -class dialog
if { $dark_colorscheme == 1 } {
set txt_color black
@ -2008,22 +2028,28 @@ proc select_layers {} {
}
}
tkwait window .sl
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
proc color_dim {} {
global color_dim
global dim_bg dim_value enable_dim_bg
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dim -class dialog
wm title .dim {Dim colors}
checkbutton .dim.bg -text {Dim background} -variable color_dim
checkbutton .dim.bg -text {Dim background} -variable enable_dim_bg
# xschem color_dim <scale value> sets also dim_value variable
scale .dim.scale -digits 2 -label {Dim factor} -length 256 \
-showvalue 1 -command {xschem color_dim} -orient horizontal \
-from -5 -to 5 -resolution 0.1
button .dim.ok -text OK -command {destroy .dim}
.dim.scale set $color_dim
.dim.scale set $dim_value
pack .dim.scale
pack .dim.bg -side left
pack .dim.ok -side right -anchor e
tkwait window .dim
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
proc about {} {
if [winfo exists .about] {
bind .about.link <Button-1> {}
@ -2062,6 +2088,7 @@ proc property_search {} {
set search_found 0
while { !$search_found} {
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Search}
if { ![info exists X] } {
@ -2120,6 +2147,7 @@ proc property_search {} {
bind .dialog <Control-Return> {.dialog.but.ok invoke}
grab set .dialog
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
return {}
}
@ -2174,6 +2202,7 @@ proc attach_labels_to_inst {} {
set rcode {}
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Add labels to instances}
@ -2220,6 +2249,7 @@ proc attach_labels_to_inst {} {
bind .dialog <Control-Return> {.dialog.but.ok invoke}
grab set .dialog
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return {}
}
@ -2227,6 +2257,7 @@ proc ask_save { {ask {save file?}} } {
global rcode wm_fix
set rcode {}
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Ask Save}
@ -2259,6 +2290,7 @@ proc ask_save { {ask {save file?}} } {
tkwait visibility .dialog
grab set .dialog
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $rcode
}
@ -2323,10 +2355,11 @@ proc edit_vi_netlist_prop {txtlabel} {
}
proc change_color {} {
global colors dark_colors light_colors dark_colorscheme cadlayers ctrl_down USER_CONF_DIR svg_colors ps_colors
global colors dark_colors light_colors dark_colorscheme cadlayers USER_CONF_DIR svg_colors ps_colors
set n [xschem get rectcolor]
if { $n < 0 || $n >=$cadlayers} return
xschem set semaphore [expr {[xschem get semaphore] +1}]
if { $dark_colorscheme == 1 } {
set c $dark_colors
} else {
@ -2348,12 +2381,14 @@ proc change_color {} {
regsub -all {#} $svg_colors {0x} svg_colors
xschem change_colors
xschem redraw
set savedata "#### THIS FILE IS AUTOMATICALLY GENERATED BY XSCHEM, DO NOT EDIT.\n"
append savedata "set cadlayers $cadlayers\n"
append savedata "set light_colors {$light_colors}\n"
append savedata "set dark_colors {$dark_colors}\n"
write_data $savedata ${USER_CONF_DIR}/colors
}
xschem set semaphore [expr {[xschem get semaphore] -1}]
}
proc edit_prop {txtlabel} {
@ -2365,6 +2400,7 @@ proc edit_prop {txtlabel} {
set retval_orig $retval
if {$debug_var <= -1} {puts " edit_prop{}: retval=$retval"}
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Edit Properties}
set X [expr {[winfo pointerx .dialog] - 60}]
@ -2374,9 +2410,10 @@ proc edit_prop {txtlabel} {
bind .dialog <Configure> {
# puts [wm geometry .dialog]
if { $edit_symbol_prop_new_sel != 1 } {
set geom [wm geometry .dialog]
regsub {\+.*} $geom {} edit_prop_size
regsub {[^+]*\+} $geom {+} edit_prop_pos
set edit_prop_size [wm geometry .dialog]
set edit_prop_pos $edit_prop_size
regsub {\+.*} $edit_prop_size {} edit_prop_size
regsub {[^+]*\+} $edit_prop_pos {+} edit_prop_pos
}
}
wm geometry .dialog "${edit_prop_size}+$X+$Y"
@ -2546,6 +2583,7 @@ proc edit_prop {txtlabel} {
}
set edit_symbol_prop_new_sel 0
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $rcode
}
@ -2588,6 +2626,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
if {$debug_var <= -1} {puts " text_line{}: retval=$retval"}
set rcode {}
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Text input}
set X [expr {[winfo pointerx .dialog] - 60}]
@ -2596,12 +2635,10 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
set tok_list "<ALL> [xschem list_tokens $retval 0]"
set selected_tok {<ALL>}
set old_selected_tok {<ALL>}
# 20160325 change and remember widget size
bind .dialog <Configure> {
# puts [wm geometry .dialog]
set geom [wm geometry .dialog]
regsub {\+.*} $geom {} geom
set text_line_default_geometry $geom
set text_line_default_geometry [wm geometry .dialog]
regsub {\+.*} $text_line_default_geometry {} text_line_default_geometry
}
# 20100203
@ -2727,6 +2764,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } {
#focus .dialog.e1
set rcode {}
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $rcode
}
@ -2816,9 +2854,9 @@ proc textwindow {filename {ro {}}} {
set textwindow_w .win$textwindow_wcounter
global fff
global fileid
set fff $filename
global textwindow_filename
global textwindow_fileid
set textwindow_filename $filename
toplevel $textwindow_w
wm title $textwindow_w $filename
wm iconname $textwindow_w $filename
@ -2829,9 +2867,9 @@ proc textwindow {filename {ro {}}} {
if { $ro eq {} } {
button $textwindow_w.buttons.save -text "Save" -command \
{
set fileid [open $fff "w"]
puts -nonewline $fileid [$textwindow_w.text get 1.0 {end - 1 chars}]
close $fileid
set textwindow_fileid [open $textwindow_filename "w"]
puts -nonewline $textwindow_fileid [$textwindow_w.text get 1.0 {end - 1 chars}]
close $textwindow_fileid
destroy $textwindow_w
}
pack $textwindow_w.buttons.save -side left -expand 1
@ -2845,17 +2883,17 @@ proc textwindow {filename {ro {}}} {
pack $textwindow_w.text -expand yes -fill both
pack $textwindow_w.xscroll -side bottom -fill x
bind $textwindow_w <Escape> "$textwindow_w.buttons.dismiss invoke"
set fileid [open $filename "r"]
set textwindow_fileid [open $filename "r"]
# 20171103 insert at insertion cursor(insert tag) instead of 0.0
$textwindow_w.text insert insert [read $fileid]
close $fileid
$textwindow_w.text insert insert [read $textwindow_fileid]
close $textwindow_fileid
return {}
}
proc viewdata {data {ro {}}} {
global viewdata_wcounter rcode
global viewdata_w OS
global viewdata_wcounter rcode viewdata_filename
global viewdata_w OS viewdata_fileid env
# set viewdata_w .view$viewdata_wcounter
# catch {destroy $viewdata_w}
set viewdata_wcounter [expr {$viewdata_wcounter+1}]
@ -2872,14 +2910,14 @@ proc viewdata {data {ro {}}} {
if { $ro eq {} } {
button $viewdata_w.buttons.saveas -text {Save As} -command {
if {$OS == "Windows"} {
set fff [tk_getSaveFile -initialdir $env(windir) ]
set viewdata_filename [tk_getSaveFile -initialdir $env(windir) ]
} else {
set fff [tk_getSaveFile -initialdir [pwd] ]
set viewdata_filename [tk_getSaveFile -initialdir [pwd] ]
}
if { $fff != "" } {
set fileid [open $fff "w"]
puts -nonewline $fileid [$viewdata_w.text get 1.0 {end - 1 chars}]
close $fileid
if { $viewdata_filename != "" } {
set viewdata_fileid [open $viewdata_filename "w"]
puts -nonewline $viewdata_fileid [$viewdata_w.text get 1.0 {end - 1 chars}]
close $viewdata_fileid
}
}
pack $viewdata_w.buttons.saveas -side left -expand 1
@ -3004,6 +3042,7 @@ proc input_line {txt {cmd {}} {preset {}} {w 12}} {
global input_line_cmd input_line_data wm_fix
set input_line_data {}
if { [winfo exists .dialog] } return
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .dialog -class Dialog
wm title .dialog {Input number}
set X [expr {[winfo pointerx .dialog] - 60}]
@ -3037,6 +3076,7 @@ proc input_line {txt {cmd {}} {preset {}} {w 12}} {
grab set .dialog
focus .dialog.f1.e
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $input_line_data
}
@ -3137,6 +3177,7 @@ proc context_menu { } {
set font fixed
}
set selection [expr {[xschem get lastsel] eq {1}}]
xschem set semaphore [expr {[xschem get semaphore] +1}]
toplevel .ctxmenu
wm overrideredirect .ctxmenu 1
set x [expr {[winfo pointerx .ctxmenu] - 10}]
@ -3246,6 +3287,7 @@ proc context_menu { } {
wm geometry .ctxmenu "+$x+$y";# move away from screen edges
bind .ctxmenu <Leave> {if { {%W} eq {.ctxmenu} } {destroy .ctxmenu} }
tkwait window .ctxmenu
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $retval
}
@ -3276,9 +3318,6 @@ proc setup_toolbar {} {
EditPop
---
ViewRedraw
ViewZoomIn
ViewZoomOut
ViewZoomBox
ViewToggleColors
---
ToolInsertSymbol
@ -3377,8 +3416,9 @@ proc toolbar_hide { { topwin {} } } {
set $toolbar_visible 0
}
proc raise_dialog {window_path } {
if {[winfo exists .dialog] && [winfo ismapped .dialog] && [winfo ismapped .] && [wm stackorder .dialog isbelow . ]} {
proc raise_dialog {parent window_path } {
if {[winfo exists .dialog] && [winfo ismapped .dialog] && [winfo ismapped $parent] &&
[wm stackorder .dialog isbelow $parent ]} {
raise .dialog $window_path
}
}
@ -3397,19 +3437,54 @@ proc set_old_tk_fonts {} {
}
}
proc every {interval script} {
uplevel #0 $script
after $interval [list every $interval $script]
}
#### TEST MODE #####
proc new_window {what {path {}} {filename {}}} {
if { $what eq {create}} {
if {$tctx::cnt == 0} {
save_ctx .drw
}
toplevel $path -bg {} -width 400 -height 400
update
build_widgets $path
pack_widgets $path
pack_widgets $path ;# also does set_bindings $path.drw
update
xschem new_schematic create $path.drw $filename
set_bindings $path.drw
xschem new_schematic create $path $path.drw [file normalize $filename]
save_ctx $path.drw
incr tctx::cnt
} elseif { $what eq {destroy}} {
xschem new_schematic destroy $path.drw {}
# xschem new_schematic destroy also decrements tctx::cnt
xschem new_schematic switch $path $path.drw {}
#### no need to switch tcl context to something that is about to be deleted
# restore_ctx $path.drw
# housekeeping_ctx
xschem new_schematic destroy $path $path.drw {}
#### following 3 lines already done in new_schematic("destroy",...)
# restore_ctx .drw
# housekeeping_ctx
# xschem new_schematic switch . .drw {}
} elseif { $what eq {destroy_all}} {
set all_closed 1
foreach i [info globals .*.drw] {
regsub {\.drw$} $i {} j
xschem new_schematic switch $j $i {}
#### no need to switch tcl context to something that is about to be deleted
# restore_ctx $i
# housekeeping_ctx
xschem new_schematic destroy $j $i {}
#### following 3 lines already done in new_schematic("destroy",...)
# restore_ctx .drw
# housekeeping_ctx
# xschem new_schematic switch . .drw {}
if { [winfo exists $i] } { set all_closed 0}
}
return $all_closed
}
return {}
}
#### TEST MODE #####
@ -3425,33 +3500,178 @@ proc test1_end {} {
new_window destroy .yy
}
## tcl context switching global namespace
namespace eval tctx {
variable tctx
variable i
variable cnt 0
variable global_list
variable global_array_list
variable dialog_list
}
## list of dialogs: when open do not perform context switching
## do not include .infotext as it is always open (in withdrawn mode)
set tctx::dialog_list { .ctxmenu .alert .sim .dialog .tclcmd .sl .dim }
proc no_open_dialogs {} {
set res 1
foreach tctx::i $tctx::dialog_list {
if { [winfo exists $tctx::i] } {
# puts "$tctx::i dialog open"
set res 0
}
}
return $res
}
## list of globals to save/restore on context switching
## EXCEPTIONS, not to be saved/restored:
## "textwindow_wcounter" should be kept global as it is the number of open textwindows
## "viewdata_wcounter" should be kept global as it is the number of open viewdatas
## "execute_id", global is incremented on spawned subprocesses.
## "simulate_bg": read only variable, no need to switch.
set tctx::global_list {
auto_hilight autotrim_wires bespice_listen_port big_grid_points bus_replacement_char
cadgrid cadlayers cadsnap cairo_font_name
change_lw color_ps colors constrained_move copy_cell custom_label_prefix custom_token dark_colors
dark_colorscheme dim_bg dim_value disable_unique_names do_all_inst draw_grid draw_window
edit_prop_pos edit_prop_size editprop_sympath edit_symbol_prop_new_sel enable_dim_bg enable_stretch
en_hilight_conn_inst filetmp
flat_netlist fullscreen gaw_fd gaw_tcp_address globfilter hide_symbols hspice_netlist
incr_hilight infowindow_text INITIALINSTDIR INITIALLOADDIR INITIALPROPDIR INITIALTEXTDIR
input_line_cmd input_line_data launcher_default_program light_colors line_width local_netlist_dir
myload_d myload_default_geometry myload_dir1 myload_dir2 myload_dirs2 myload_files1 myload_files2 myload_index1
myload_retval myload_sash_pos myload_sel myload_type myload_yview netlist_dir netlist_show netlist_type
no_change_attrs noprint_libs old_selected_tok
only_probes path pathlist persistent_command preserve_unchanged_attrs prev_symbol ps_colors rainbow_colors
rcode recentfile replace_key retval retval_orig rotated_text search_exact search_found search_select
search_value selected_tok show_infowindow show_pin_net_names simconf_default_geometry simconf_vpos
spiceprefix split_files svg_colors svg_font_name symbol symbol_width sym_txt tclcmd_txt
text_line_default_geometry textwindow_fileid textwindow_filename textwindow_w tmp_bus_char
toolbar_horiz toolbar_visible top_subckt transparent_svg
use_label_prefix use_lab_wire user_wants_copy_cell verilog_2001
viewdata_fileid viewdata_filename viewdata_w xschem_libs xschem_listen_port
}
## list of global arrays to save/restore on context switching
## EXCEPTIONS, not to be saved/restored:
## execute_pipe execute_data execute_status execute_cmd
set tctx::global_array_list {
dircolor sim enable_layer
}
proc delete_ctx {context} {
set tctx::tctx $context
uplevel #0 {
# puts "delete_ctx $tctx::tctx"
array unset $tctx::tctx
foreach tctx::i $tctx::global_array_list {
if { [array exists ${tctx::tctx}_$tctx::i] } {
array unset ${tctx::tctx}_$tctx::i
}
}
}
}
proc restore_ctx {context} {
set tctx::tctx $context
array unset ::sim
uplevel #0 {
if { [ array exists $tctx::tctx ] } {
# puts "restore_ctx $tctx::tctx"
# Cleanup these vars to avoid side effects from previous ctx
unset -nocomplain gaw_fd
foreach tctx::i $tctx::global_list {
if { [info exists [subst $tctx::tctx]($tctx::i)] } {
set $tctx::i [set [subst $tctx::tctx]($tctx::i)]
}
}
}
foreach tctx::i $tctx::global_array_list {
if { [array exists ${tctx::tctx}_$tctx::i] } {
array set $tctx::i [array get [subst ${tctx::tctx}_$tctx::i]]
}
}
}
}
proc save_ctx {context} {
set tctx::tctx $context
uplevel #0 {
# puts "save_ctx $tctx::tctx"
foreach tctx::i $tctx::global_list {
if { [info exists $tctx::i] } {
set [subst $tctx::tctx]($tctx::i) [set $tctx::i]
}
}
foreach tctx::i $tctx::global_array_list {
if { [array exists $tctx::i] } {
array set [subst ${tctx::tctx}_$tctx::i] [array get $tctx::i]
}
}
}
}
proc housekeeping_ctx {} {
uplevel #0 {
# puts housekeeping_ctx
xschem set flat_netlist $flat_netlist
}
}
proc simulate_button {button_path} {
global simulate_bg
if { [set simulate_bg [$button_path cget -bg]] ne {red} } {
$button_path configure -bg red
simulate "$button_path configure -bg $simulate_bg"
}
}
proc set_bindings {topwin} {
global env has_x OS
###
### Tk event handling
###
if { $topwin eq {.drw} } {
bind . <Expose> [list raise_dialog $topwin]
bind . <Visibility> [list raise_dialog $topwin]
bind . <FocusIn> [list raise_dialog $topwin]
}
bind $topwin <Expose> "+
xschem new_schematic switch $topwin {}
xschem callback %W %T %x %y 0 %w %h %s
set parent [winfo toplevel $topwin]
bind $parent <Expose> [list raise_dialog $parent $topwin]
bind $parent <Visibility> [list raise_dialog $parent $topwin]
bind $parent <FocusIn> [list raise_dialog $parent $topwin]
# send non-existent event just to force change schematic window context.
bind $parent <Enter> "
if { {$parent} eq {.}} {
if { {%W} eq {$parent}} {
# send a fake event just to force context switching in callback()
xschem callback .drw -55 0 0 0 0 0 0
}
} else {
if { {%W} eq {$parent}} {
# send a fake event just to force context switching in callback()
xschem callback $parent.drw -55 0 0 0 0 0 0
}
}
"
bind $topwin <Double-Button-1> {xschem callback %W -3 %x %y 0 %b 0 %s}
bind $topwin <Double-Button-2> {xschem callback %W -3 %x %y 0 %b 0 %s}
bind $topwin <Double-Button-3> {xschem callback %W -3 %x %y 0 %b 0 %s}
bind $topwin <Configure> "
xschem windowid
xschem new_schematic switch $topwin {}
xschem callback %W %T %x %y 0 %w %h 0
"
bind $topwin <ButtonPress> {
xschem callback %W %T %x %y 0 %b 0 %s
}
if {$OS == "Windows"} {
bind $topwin <Expose> "xschem callback %W %T %x %y 0 %w %h %s"
bind $topwin <Double-Button-1> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Double-Button-2> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Double-Button-3> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Configure> "xschem windowid; xschem callback %W %T %x %y 0 %w %h 0"
bind $topwin <ButtonPress> "xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <ButtonRelease> "xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <KeyPress> "xschem callback %W %T %x %y %N 0 0 %s"
bind $topwin <KeyRelease> "xschem callback %W %T %x %y %N 0 0 %s"
bind $topwin <Motion> "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s"
bind $topwin <Enter> "focus $topwin; xschem callback %W %T %x %y 0 0 0 0"
bind $topwin <Unmap> " wm withdraw .infotext; set show_infowindow 0 "
bind $topwin "?" {textwindow "${XSCHEM_SHAREDIR}/xschem.help"}
# on Windows Alt key mask is reported as 131072 (1<<17) so build masks manually with values passed from C code
if {$OS == "Windows" } {
bind $topwin <Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$Mod1Mask}]}
bind $topwin <Control-Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]}
bind $topwin <Shift-Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]}
bind $topwin <MouseWheel> {
if {%D<0} {
xschem callback %W 4 %x %y 0 5 0 %s
@ -3460,26 +3680,6 @@ global env has_x OS
}
}
}
bind $topwin <ButtonRelease> {xschem callback %W %T %x %y 0 %b 0 %s}
# on Windows Alt key mask is reported as 131072 (1<<17) so build masks manually with values passed from C code
if {$OS == "Windows" } {
bind $topwin <Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$Mod1Mask}]}
bind $topwin <Control-Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]}
bind $topwin <Shift-Alt-KeyPress> {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]}
}
bind $topwin <KeyPress> {
xschem callback %W %T %x %y %N 0 0 %s
}
bind $topwin <KeyRelease> {xschem callback %W %T %x %y %N 0 0 %s} ;# 20161118
bind $topwin <Motion> "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s"
bind $topwin <Enter> "
focus $topwin
xschem new_schematic switch $topwin {}
xschem callback %W %T %x %y 0 0 0 0
"
bind $topwin <Leave> {}
bind $topwin <Unmap> { wm withdraw .infotext; set show_infowindow 0 }
bind $topwin "?" { textwindow "${XSCHEM_SHAREDIR}/xschem.help" }
}
## this function sets up all tk windows and binds X events. It is executed by xinit.c after completing
@ -3515,7 +3715,7 @@ proc build_widgets { {topwin {} } } {
global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width
global cadgrid draw_window show_pin_net_names toolbar_visible hide_symbols
global disable_unique_names persistent_command autotrim_wires en_hilight_conn_inst
global local_netlist_dir editor netlist_dir spiceprefix initial_geometry
global local_netlist_dir editor netlist_dir spiceprefix initial_geometry simulate_bg
frame $topwin.menubar -relief raised -bd 2
toolbar_toolbar $topwin
menubutton $topwin.menubar.file -text "File" -menu $topwin.menubar.file.menu -padx 3 -pady 0
@ -3598,8 +3798,12 @@ proc build_widgets { {topwin {} } } {
$topwin.menubar.file.menu add command -label "PNG Export" -command "xschem print png" -accelerator {Ctrl+*}
$topwin.menubar.file.menu add command -label "SVG Export" -command "xschem print svg" -accelerator {Alt+*}
$topwin.menubar.file.menu add separator
$topwin.menubar.file.menu add command -label "Exit" -command {xschem exit} -accelerator {Ctrl+Q}
$topwin.menubar.file.menu add command -label "Exit" -accelerator {Ctrl+Q} -command "
if { {$topwin} eq {} } {
xschem exit
} else {
xschem new_schematic destroy $topwin $topwin.drw {}
}"
$topwin.menubar.option.menu add checkbutton -label "Color Postscript/SVG" -variable color_ps \
-command {
if { $color_ps==1 } {xschem set color_ps 1} else { xschem set color_ps 0}
@ -3621,10 +3825,7 @@ proc build_widgets { {topwin {} } } {
$topwin.menubar.option.menu add checkbutton -label "Split netlist" -variable split_files \
-accelerator {}
$topwin.menubar.option.menu add checkbutton -label "hspice / ngspice netlist" -variable hspice_netlist \
-accelerator {} \
-command {
if { $hspice_netlist==1 } {xschem set hspice_netlist 1} else { xschem set hspice_netlist 0}
}
-accelerator {}
$topwin.menubar.option.menu add command -label "Replace \[ and \] for buses in SPICE netlist" \
-command {
input_line "Enter two characters to replace default bus \[\] delimiters:" "set tmp_bus_char"
@ -3711,13 +3912,7 @@ proc build_widgets { {topwin {} } } {
waves
}
button $topwin.menubar.simulate -text "Simulate" -activebackground red -takefocus 0 -padx 2 -pady 0 \
-command "
if { !\[info exists simulate_oldbg\] } {
set simulate_oldbg \[$topwin.menubar.simulate cget -bg\]
$topwin.menubar.simulate configure -bg red
simulate \"$topwin.menubar.simulate configure -bg \$simulate_oldbg; unset simulate_oldbg\"
}
"
-command "simulate_button $topwin.menubar.simulate"
button $topwin.menubar.netlist -text "Netlist" -activebackground red -takefocus 0 -padx 2 -pady 0 \
-command {
xschem netlist
@ -3737,11 +3932,11 @@ proc build_widgets { {topwin {} } } {
"
$topwin.menubar.view.menu add command -label "Zoom Full" -command "xschem zoom_full" -accelerator F
$topwin.menubar.view.menu add command -label "Zoom In" -command "xschem zoom_in" -accelerator Shift+Z
toolbar_create ViewZoomIn "xschem zoom_in" "Zoom In" $topwin
# toolbar_create ViewZoomIn "xschem zoom_in" "Zoom In" $topwin
$topwin.menubar.view.menu add command -label "Zoom Out" -command "xschem zoom_out" -accelerator Ctrl+Z
toolbar_create ViewZoomOut "xschem zoom_out" "Zoom Out" $topwin
# toolbar_create ViewZoomOut "xschem zoom_out" "Zoom Out" $topwin
$topwin.menubar.view.menu add command -label "Zoom box" -command "xschem zoom_box" -accelerator Z
toolbar_create ViewZoomBox "xschem zoom_box" "Zoom Box" $topwin
# toolbar_create ViewZoomBox "xschem zoom_box" "Zoom Box" $topwin
$topwin.menubar.view.menu add command -label "Half Snap Threshold" -accelerator G -command {
xschem set cadsnap [expr {[xschem get cadsnap] / 2.0} ]
}
@ -3762,21 +3957,22 @@ proc build_widgets { {topwin {} } } {
-command { xschem only_probes }
$topwin.menubar.view.menu add command -label "Toggle colorscheme" -accelerator {Shift+O} -command {
xschem toggle_colorscheme
xschem change_colors
xschem change_colors 1
xschem redraw
}
toolbar_create ViewToggleColors {
xschem toggle_colorscheme
xschem change_colors
xschem change_colors 1
xschem redraw
} "Toggle Color Scheme" $topwin
$topwin.menubar.view.menu add command -label "Dim colors" -accelerator {} -command {
color_dim
xschem color_dim
}
$topwin.menubar.view.menu add command -label "Visible layers" -accelerator {} -command {
select_layers
xschem redraw
}
$topwin.menubar.view.menu add command -label "Change Current Layer color" -accelerator {} -command {
$topwin.menubar.view.menu add command -label "Change current layer color" -accelerator {} -command {
change_color
}
$topwin.menubar.view.menu add checkbutton -label "No XCopyArea drawing model" -variable draw_window \
@ -3934,13 +4130,7 @@ proc build_widgets { {topwin {} } } {
-command {xschem save; xschem reload}
toolbar_create Netlist { xschem netlist } "Create netlist" $topwin
toolbar_create Simulate "
if { ![info exists simulate_oldbg] } {
set simulate_oldbg \[$topwin.menubar.simulate cget -bg\]
$topwin.menubar.simulate configure -bg red
simulate \"$topwin.menubar.simulate configure -bg \$simulate_oldbg; unset simulate_oldbg\"
}
" "Run simulation" $topwin
toolbar_create Simulate "simulate_button $topwin.menubar.simulate" "Run simulation" $topwin
toolbar_create Waves { waves } "View results" $topwin
pack $topwin.menubar.file -side left
@ -3957,7 +4147,7 @@ proc build_widgets { {topwin {} } } {
pack $topwin.menubar.waves -side right
pack $topwin.menubar.simulate -side right
pack $topwin.menubar.netlist -side right
# used to check status of Simulate button later. This variable is constant, never changed
frame $topwin.drw -background {} -takefocus 1
focus $topwin.drw
@ -3970,7 +4160,7 @@ proc build_widgets { {topwin {} } } {
if { $rootwin == {.}} {
wm protocol $rootwin WM_DELETE_WINDOW {xschem exit}
} else {
wm protocol $topwin WM_DELETE_WINDOW "xschem new_schematic destroy $topwin.drw {}"
wm protocol $topwin WM_DELETE_WINDOW "xschem new_schematic destroy $topwin $topwin.drw {}"
}
frame $topwin.statusbar
@ -4207,9 +4397,7 @@ set_ne editor {gvim -f}
set_ne rainbow_colors 0
set_ne initial_geometry {900x600}
set_ne edit_symbol_prop_new_sel {}
#20161102
set_ne launcher_default_program {xdg-open}
#20160413
set_ne auto_hilight 0
set_ne en_hilight_conn_inst 0
## xpm to png conversion
@ -4217,7 +4405,7 @@ set_ne to_png {gm convert}
## ps to pdf conversion
set_ne to_pdf {ps2pdf}
## 20160325 remember edit_prop widget size
## remember edit_prop widget size
set_ne edit_prop_size 80x12
set_ne text_line_default_geometry 80x12
set_ne terminal xterm
@ -4261,7 +4449,9 @@ set_ne svg_font_name {Sans-Serif}
set has_cairo 0
set rotated_text {} ;#20171208
set_ne dark_colorscheme 1
set_ne color_dim 0.0
set_ne enable_dim_bg 0
set_ne dim_bg 0.0
set_ne dim_value 0.0
##### set colors
if {!$rainbow_colors} {
set_ne cadlayers 22
@ -4343,7 +4533,6 @@ set custom_token {lab}
set search_value {}
set search_exact 0
# 20171005
set custom_label_prefix {}

0
xschem_library/gschem_import/convert_script Executable file → Normal file
View File

0
xschem_library/gschem_import/sym/convert_script Executable file → Normal file
View File