From c3c1b39cb57762cd640b22caa153661e8b432557 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Tue, 9 Nov 2021 19:05:56 +0100 Subject: [PATCH] (2) full widget creation for xschem new windows, code cleanup, removed old stuff --- src/actions.c | 58 +- src/callback.c | 13 +- src/scheduler.c | 9 +- src/xinit.c | 110 ++- src/xschem.h | 6 +- src/xschem.tcl | 1467 ++++++++++++++--------------- src/xschemrc | 10 +- xschem_library/examples/tesla.sch | 11 +- xschem_library/ngspice/buck.sch | 4 +- 9 files changed, 858 insertions(+), 830 deletions(-) diff --git a/src/actions.c b/src/actions.c index e0f71db1..a4ddc026 100644 --- a/src/actions.c +++ b/src/actions.c @@ -216,11 +216,34 @@ void toggle_only_probes() draw(); } -void toggle_fullscreen() +void toggle_fullscreen(const char *topwin) { + char *mytopwin = NULL; char fullscr[]="add,fullscreen"; char normal[]="remove,fullscreen"; static int menu_removed = 0; + unsigned int topwin_id; + Window rootwindow, parent_id; + Window *framewin_child_ptr; + unsigned int framewindow_nchildren; + + + + 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); + sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); + } + + XQueryTree(display, topwin_id, &rootwindow, &parent_id, &framewin_child_ptr, &framewindow_nchildren); + + + fullscreen = (fullscreen+1)%2; if(fullscreen==1) tclsetvar("fullscreen","1"); else if(fullscreen==2) tclsetvar("fullscreen","2"); @@ -228,25 +251,26 @@ void toggle_fullscreen() dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fullscreen); if(fullscreen==2) { - tcleval("pack forget .menubar .statusbar; update"); + Tcl_VarEval(interp, "pack forget ", mytopwin, ".menubar ", mytopwin, ".statusbar; update", NULL); menu_removed = 1; } if(fullscreen !=2 && menu_removed) { - tcleval("pack .menubar -anchor n -side top -fill x -before .drw\n\ - pack .statusbar -after .drw -anchor sw -fill x; update"); + 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); menu_removed=0; } if(fullscreen == 1) { - window_state(display , parent_of_topwindow,fullscr); + window_state(display , parent_id,fullscr); } else if(fullscreen == 2) { - window_state(display , parent_of_topwindow,normal); - window_state(display , parent_of_topwindow,fullscr); + window_state(display , parent_id,normal); + window_state(display , parent_id,fullscr); } else { - window_state(display , parent_of_topwindow,normal); + window_state(display , parent_id,normal); } xctx->pending_fullzoom=1; + my_free(1291, &mytopwin); } #ifdef __unix__ @@ -967,7 +991,7 @@ void schematic_in_new_window(void) void launcher(void) { - const char *str; + const char *url; char program[PATH_MAX]; int n; rebuild_selected_array(); @@ -979,19 +1003,13 @@ void launcher(void) select_object(mx,my,0, 0); n=xctx->sel_array[0].n; my_strncpy(program, get_tok_value(xctx->inst[n].prop_ptr,"program",0), S(program)); /* handle backslashes */ - str = get_tok_value(xctx->inst[n].prop_ptr,"url",0); /* handle backslashes */ - dbg(1, "launcher(): str=%s\n", str); - if(str[0] || (program[0])) { - tclsetvar("launcher_var",str); - if(program[0]) { /* 20170413 leave launcher_program empty if unspecified */ - tclsetvar("launcher_program",program); - } else { - tclsetvar("launcher_program",""); - } - tcleval( "launcher"); + url = get_tok_value(xctx->inst[n].prop_ptr,"url",0); /* handle backslashes */ + dbg(1, "launcher(): url=%s\n", url); + if(url[0] || (program[0])) { /* open url with appropriate program */ + Tcl_VarEval(interp, "launcher {", url, "} {", program, "}", NULL); } else { my_strncpy(program, get_tok_value(xctx->inst[n].prop_ptr,"tclcommand",0), S(program)); - if(program[0]) { /* 20170415 execute tcl command */ + if(program[0]) { /* execute tcl command */ tcleval(program); } } diff --git a/src/callback.c b/src/callback.c index 6e5c2eb2..7e931429 100644 --- a/src/callback.c +++ b/src/callback.c @@ -138,7 +138,7 @@ void start_wire(double mx, double my) } /* main window callback */ /* mx and my are set to the mouse coord. relative to window */ -int callback(int event, int mx, int my, KeySym key, +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 */ @@ -648,6 +648,12 @@ int callback(int event, int mx, int my, KeySym key, xctx->rectcolor = key - '0'+4; my_snprintf(n, S(n), "%d", xctx->rectcolor); Tcl_VarEval(interp, "xschem set rectcolor ", n, NULL); + + if(!strcmp(winpath, ".drw")) { + Tcl_VarEval(interp, "reconfigure_layers_button {}", NULL); + } else { + Tcl_VarEval(interp, "reconfigure_layers_button [winfo parent ", winpath, "]", NULL); + } dbg(1, "callback(): new color: %d\n",color_index[xctx->rectcolor]); break; } @@ -1139,8 +1145,9 @@ int callback(int event, int mx, int my, KeySym key, } if(key=='\\' && state==0) /* fullscreen */ { - dbg(1, "callback(): toggle fullscreen\n"); - toggle_fullscreen(); + + dbg(1, "callback(): toggle fullscreen, winpath=%s\n", winpath); + toggle_fullscreen(winpath); break; } if(key=='f' && state==Mod1Mask) /* flip objects around their anchor points 20171208 */ diff --git a/src/scheduler.c b/src/scheduler.c index 2e71c33a..0219f95b 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -161,9 +161,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(!strcmp(argv[1],"callback") ) { cmd_found = 1; - callback( atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), (KeySym)atol(argv[5]), - atoi(argv[6]), atoi(argv[7]), atoi(argv[8]) ); - dbg(2, "callback %s %s %s %s %s %s %s\n", argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]); + callback( argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), (KeySym)atol(argv[6]), + atoi(argv[7]), atoi(argv[8]), atoi(argv[9]) ); + dbg(2, "callback %s %s %s %s %s %s %s %s\n", argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]); Tcl_ResetResult(interp); } @@ -458,7 +458,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { cmd_found = 1; dbg(1, "scheduler(): xschem fullscreen, fullscreen=%d\n", fullscreen); - toggle_fullscreen(); + toggle_fullscreen(argv[2]); Tcl_ResetResult(interp); } } @@ -2323,7 +2323,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } else if(!strcmp(argv[2],"rectcolor")) { xctx->rectcolor=atoi(argv[3]); - tcleval("reconfigure_layers_button"); rebuild_selected_array(); if(xctx->lastsel) { change_layer(); diff --git a/src/xinit.c b/src/xinit.c index 72cfe8da..f53dc2fe 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -267,7 +267,7 @@ void init_color_array(double dim) double rr, gg, bb; static int done=0; - dim_bg = tclgetvar("dim_background")[0] == '1' ? 1: 0; + dim_bg = tclgetvar("color_dim")[0] == '1' ? 1: 0; for(i=0;ischsymbolprop=NULL; /* symbol property string */ xctx->schverilogprop=NULL;/* verilog */ xctx->version_string = NULL; + xctx->rectcolor= 4; /* this is the current layer when xschem started. */ xctx->currsch = 0; xctx->ui_state = 0; xctx->need_reb_sel_arr = 1; @@ -466,7 +467,6 @@ void alloc_xschem_data() xctx->hilight_time = 0; /* timestamp for sims */ xctx->hilight_nets = 0; xctx->hilight_color = 0; - xctx->rectcolor = 0; for(i=0;isch_path[i]=NULL; xctx->sch_path_hash[i]=0; @@ -862,40 +862,35 @@ void new_schematic(const char *what, const char *tk_win_path, const char *filena zoom_full(1, 0, 1, 0.97); /* draw */ } else if(!strcmp(what, "destroy")) { if(cnt) { + int close = 0; dbg(1, "new_schematic() destroy\n"); - tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow); - for(i = 1; i < MAX_NEW_WINDOWS; i++) { - if(tkwin == tknew_window[i]) { - n = i; - break; + if(xctx->modified && has_x) { + tcleval("tk_messageBox -type okcancel -message {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++) { + if(tkwin == tknew_window[i]) { + n = i; + break; + } } - } - if(n >= 1 && n < MAX_NEW_WINDOWS) { - xctx = save_xctx[n]; - delete_schematic_data(); - save_xctx[n] = NULL; - Tk_DestroyWindow(tknew_window[n]); - tknew_window[n] = NULL; - xctx = save_xctx[0]; /* restore schematic */ - set_modify(xctx->modified); - cnt--; - } - } - } else if(!strcmp(what, "destroy_all")) { - if(cnt) { - dbg(1, "new_schematic() destroy_all\n"); - for(i = 1; i < MAX_NEW_WINDOWS; i++) { - if(tknew_window[i]) { - xctx = save_xctx[i]; + if(n >= 1 && n < MAX_NEW_WINDOWS) { + xctx = save_xctx[n]; delete_schematic_data(); - save_xctx[i] = NULL; - Tk_DestroyWindow(tknew_window[i]); - tknew_window[i] = NULL; + save_xctx[n] = NULL; + Tcl_VarEval(interp, "winfo parent ", 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); cnt--; } } - xctx = save_xctx[0]; /* restore schematic */ - set_modify(xctx->modified); } } else if(!strcmp(what, "switch")) { if(cnt) { @@ -1152,6 +1147,11 @@ int Tcl_AppInit(Tcl_Interp *inter) 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) */ if( !stat("./xschem.tcl", &buf) && !stat("./systemlib", &buf) && !stat("./xschem", &buf)) { running_in_src_dir = 1; @@ -1161,18 +1161,37 @@ int Tcl_AppInit(Tcl_Interp *inter) tcleval(tmp); tclsetvar("XSCHEM_LIBRARY_PATH", tclresult()); */ - my_snprintf(tmp, S(tmp), "subst [file dirname \"%s\"]/xschem_library/devices", pwd_dir); + my_snprintf(tmp, S(tmp), + "set XSCHEM_LIBRARY_PATH %s/xschem_library", user_conf_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/devices", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/examples", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/ngspice", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/logic", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/xschem_simulator", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/binto7seg", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/pcb", pwd_dir); + tcleval(tmp); + my_snprintf(tmp, S(tmp), + "append XSCHEM_LIBRARY_PATH : [file dirname \"%s\"]/xschem_library/rom8k", pwd_dir); tcleval(tmp); - tclsetvar("XSCHEM_LIBRARY_PATH", tclresult()); } else if( !stat(XSCHEM_SHAREDIR, &buf) ) { tclsetvar("XSCHEM_SHAREDIR",XSCHEM_SHAREDIR); /* ... else give up searching, may set later after loading xschemrc */ } - /* 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); #else char install_dir[MAX_PATH]=""; char *up_hier=NULL, *win_xschem_library_path=NULL; @@ -1183,10 +1202,10 @@ int Tcl_AppInit(Tcl_Interp *inter) /*3*/ "xschem_library/examples", /*4*/ "xschem_library/ngspice", /*5*/ "xschem_library/logic", - /*6*/ "xschem_library/binto7seg", - /*7*/ "xschem_library/pcb", - /*8*/ "xschem_library/rom8k", - /*9*/ "xschem_library/xschem_simulator"}; + /*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); @@ -1215,7 +1234,7 @@ int Tcl_AppInit(Tcl_Interp *inter) tclsetvar("XSCHEM_LIBRARY_PATH", win_xschem_library_path_clean); my_free(432, &win_xschem_library_path); my_free(441, &up_hier); - char* gxschem_library=NULL, *xschem_sharedir=NULL; + char *xschem_sharedir=NULL; if ((xschem_sharedir=getenv("XSCHEM_SHAREDIR")) != NULL) { if (!stat(xschem_sharedir, &buf)) { tclsetvar("XSCHEM_SHAREDIR", xschem_sharedir); @@ -1532,7 +1551,6 @@ int Tcl_AppInit(Tcl_Interp *inter) visual = vinfo.visual; */ dbg(1, "Tcl_AppInit(): done step b of xinit()\n"); - xctx->rectcolor= 4; /* this is the current layer when xschem started. */ for(i=0;iwindow, (char*)(pixdata[i]),16,16); @@ -1595,16 +1613,16 @@ int Tcl_AppInit(Tcl_Interp *inter) /* leaving undo buffer and other garbage around. */ /* */ - /* Completing tk windows creation (see xschem.tcl, build_windows) and event binding */ + /* Completing tk windows creation (see xschem.tcl, pack_widgets) and event binding */ /* *AFTER* X initialization done */ /* */ - if(has_x) tcleval("build_windows"); + if(has_x) tcleval("pack_widgets"); fullscreen=atoi(tclgetvar("fullscreen")); if(fullscreen) { fullscreen = 0; tcleval("update"); - toggle_fullscreen(); + toggle_fullscreen("."); } /* */ diff --git a/src/xschem.h b/src/xschem.h index 164b1892..43f79fed 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -752,6 +752,7 @@ extern char cairo_font_name[80]; extern double cairo_font_line_spacing; /* allows to change line spacing: default: 1.0 */ extern double cairo_vert_correct; extern int debug_var; +extern double color_dim; /* can not be put in Xctx unless all X11 colors are reset on window change */ /*********** End of variables backed in xschem.tcl ***********/ extern int help; extern char *cad_icon[]; @@ -768,7 +769,6 @@ extern char *tcl_command; extern char tcl_script[PATH_MAX]; extern int tcp_port; extern char **color_array; -extern double color_dim; /* can not be put in Xctx unless all X11 colors are reset on window change */ 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[] */ @@ -908,7 +908,7 @@ extern void xwin_exit(void); extern void resetcairo(int create, int clear, int force_or_resize); extern int Tcl_AppInit(Tcl_Interp *interp); extern int source_tcl_file(char *s); -extern int callback(int event, int mx, int my, KeySym key, +extern int callback(const char *winpath, int event, int mx, int my, KeySym key, int button, int aux, int state); extern void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h); extern void find_closest_net(double mx,double my); @@ -1170,7 +1170,7 @@ 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 int window_state (Display *disp, Window win, char *arg); -extern void toggle_fullscreen(); +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); diff --git a/src/xschem.tcl b/src/xschem.tcl index 73a8b221..fde55c92 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -192,12 +192,12 @@ proc netlist {source_file show netlist_file} { # 20161121 proc convert_to_pdf {filename dest} { - global to_pdf + global to_pdf OS if { [regexp -nocase {\.pdf$} $dest] } { set pdffile [file rootname $filename].pdf # puts "---> $to_pdf $filename $pdffile" set cmd "exec $to_pdf \$filename \$pdffile" - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set cmd "exec $to_pdf \$pdffile \$filename" } if { ![catch {eval $cmd} msg] } { @@ -216,10 +216,10 @@ proc convert_to_pdf {filename dest} { # 20161121 proc convert_to_png {filename dest} { - global to_png debug_var + global to_png debug_var OS # puts "---> $to_png $filename $dest" set cmd "exec $to_png \$filename png:\$dest" - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set cmd "exec $to_png \$dest \$filename" } if { ![catch {eval $cmd} msg] } { @@ -239,7 +239,7 @@ proc convert_to_png {filename dest} { # Alt-Key-c # ButtonPress-4 # -proc key_binding { s d } { +proc key_binding { s d { topwin {} } } { regsub {.*-} $d {} key @@ -273,14 +273,14 @@ proc key_binding { s d } { if { [regexp ButtonPress-3 $d] } { set state [expr {$state +0x400}] } # puts "$state $key <${s}>" if {[regexp ButtonPress- $d]} { - bind .drw "<${s}>" "xschem callback %T %x %y 0 $key 0 $state" + bind $topwin.drw "<${s}>" "xschem callback %W %T %x %y 0 $key 0 $state" } else { if {![string compare $d {} ] } { # puts "bind .drw <${s}> {}" - bind .drw "<${s}>" {} + bind $topwin.drw "<${s}>" {} } else { - # puts "bind .drw <${s}> xschem callback %T %x %y $keysym 0 0 $state" - bind .drw "<${s}>" "xschem callback %T %x %y $keysym 0 0 $state" + # puts "bind .drw <${s}> xschem callback %W %T %x %y $keysym 0 0 $state" + bind $topwin.drw "<${s}>" "xschem callback %W %T %x %y $keysym 0 0 $state" } } @@ -344,9 +344,22 @@ proc save_sim_defaults {f} { close $fd } +proc load_recent_file {} { + global USER_CONF_DIR recentfile has_x + # recent files + set recentfile {} + if { [file exists $USER_CONF_DIR/recent_files] } { + if {[catch { source $USER_CONF_DIR/recent_files } err] } { + puts "Problems opening recent_files: $err" + if {[info exists has_x]} { + tk_messageBox -message "Problems opening recent_files: $err" -icon warning -parent . -type ok + } + } + } +} -proc update_recent_file {f} { - global recentfile +proc update_recent_file {f {topwin {} } } { + global recentfile has_x set old $recentfile set recentfile {} lappend recentfile $f @@ -360,7 +373,7 @@ proc update_recent_file {f} { set recentfile [lreplace $recentfile 10 end] } write_recent_file - if { [info exists ::has_x] } setup_recent_menu + if { [info exists has_x] } setup_recent_menu $topwin } proc write_recent_file {} { @@ -375,13 +388,13 @@ proc write_recent_file {} { close $fd } -proc setup_recent_menu {} { +proc setup_recent_menu { { topwin {} } } { global recentfile - .menubar.file.menu.recent delete 0 9 + $topwin.menubar.file.menu.recent delete 0 9 set i 0 if { [info exists recentfile] } { foreach i $recentfile { - .menubar.file.menu.recent add command \ + $topwin.menubar.file.menu.recent add command \ -command "xschem load {$i}" \ -label [file tail $i] } @@ -405,7 +418,7 @@ proc sim_is_xyce {} { proc set_sim_defaults {} { ### spice - global sim terminal USER_CONF_DIR has_x bespice_listen_port env + global sim terminal USER_CONF_DIR has_x bespice_listen_port env OS set failure 0 if { [info exists has_x] && [winfo exists .sim] } { @@ -431,7 +444,7 @@ proc set_sim_defaults {} { if {[info exists sim]} {unset sim} # no simrc, set a reasonable default set sim(tool_list) {spice spicewave verilog verilogwave vhdl vhdlwave} - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set_ne sim(spice,0,cmd) {ngspice -i "$N" -a} } else { set_ne sim(spice,0,cmd) {$terminal -e 'ngspice -i "$N" -a || sh'} @@ -850,7 +863,7 @@ proc simulate {{callback {}}} { ## $d : netlist directory global netlist_dir netlist_type computerfarm terminal sim - global execute_callback XSCHEM_SHAREDIR has_x + global execute_callback XSCHEM_SHAREDIR has_x OS simuldir set_sim_defaults @@ -879,7 +892,7 @@ proc simulate {{callback {}}} { set fg {execute} } set cmd [subst $sim($tool,$def,cmd)] - if {$::OS == "Windows"} { + if {$OS == "Windows"} { # $cmd cannot be surrounded by {} as exec will change forward slash to backward slash eval exec $cmd } else { @@ -1049,7 +1062,7 @@ proc get_shell { curpath } { proc edit_netlist {schname } { global netlist_dir netlist_type debug_var - global editor terminal + global editor terminal OS simuldir set tmpname [file rootname "$schname"] @@ -1060,21 +1073,21 @@ proc edit_netlist {schname } { if { $netlist_type=="verilog" } { execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.v\"" } elseif { $netlist_type=="spice" } { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set cmd "$editor \"$netlist_dir/${tmpname}.spice\"" eval exec $cmd } else { execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.spice\"" } } elseif { $netlist_type=="tedax" } { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set cmd "$editor \"$netlist_dir/${tmpname}.tdx\"" eval exec $cmd } else { execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.tdx\"" } } elseif { $netlist_type=="vhdl" } { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set cmd "$editor \"$netlist_dir/${tmpname}.vhdl\"" eval exec $cmd } else { @@ -1142,48 +1155,6 @@ proc is_xschem_file {f} { return $ret } -proc list_dirs {pathlist } { - global list_dirs_selected_dir INITIALINSTDIR - toplevel .list -class dialog - wm title .list {Select Library:} - wm protocol .list WM_DELETE_WINDOW { set list_dirs_selected_dir {} } - set X [expr {[winfo pointerx .list] - 30}] - set Y [expr {[winfo pointery .list] - 25}] - if { $::wm_fix } { tkwait visibility .list } - wm geometry .list "+$X+$Y" - - set x 0 - set dir {} - label .list.title \ - -text "Choose path to start from. You can navigate anywhere\n with the file selector from there \n" \ - -background {#77dddd} - pack .list.title -fill x -side top - foreach elem $pathlist { - frame .list.${x} - label .list.${x}.l -text [expr {$x+1}] -width 4 - button .list.${x}.b -text $elem -command "set list_dirs_selected_dir $elem" - pack .list.${x}.l -side left - pack .list.${x}.b -side left -fill x -expand yes - pack .list.${x} -side top -fill x - incr x - } - frame .list.${x} - label .list.${x}.l -text [expr {$x+1}] -width 4 - button .list.${x}.b -text {Last used dir} -command "set list_dirs_selected_dir $INITIALINSTDIR" - pack .list.${x}.l -side left - pack .list.${x}.b -side left -fill x -expand yes - pack .list.${x} -side top -fill x - frame .list.but - button .list.but.cancel -text Cancel -command {set list_dirs_selected_dir {} } - - pack .list.but.cancel -side bottom - pack .list.but -fill x -side top - vwait list_dirs_selected_dir - destroy .list - return $list_dirs_selected_dir -} - - proc myload_set_colors1 {} { global myload_files1 dircolor for {set i 0} { $i< [.dialog.l.paneleft.list index end] } { incr i} { @@ -1273,7 +1244,7 @@ proc load_file_dialog_mkdir {dir} { 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 + 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 {} @@ -1461,7 +1432,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init } elseif { $myload_dir2 eq {.} } { set myload_d $myload_dir1 } else { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { if {[regexp {^[A-Za-z]\:/$} $myload_dir1]} { set myload_d "$myload_dir1$myload_dir2" } else { @@ -1486,8 +1457,8 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init } else { .dialog.buttons_bot.entry delete 0 end .dialog.buttons_bot.entry insert 0 $myload_dir2 - set t [is_xschem_file $myload_dir1/$myload_dir2] - if { $t ne {0} } { + set myload_type [is_xschem_file $myload_dir1/$myload_dir2] + if { $myload_type ne {0} } { ### update if { [winfo exists .dialog] } { .dialog.l.paneright.pre configure -background {} @@ -1529,8 +1500,8 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init } } } - set t [is_xschem_file "$myload_dir1/$myload_retval"] - if { $t eq {0} } { + set myload_type [is_xschem_file "$myload_dir1/$myload_retval"] + if { $myload_type eq {0} } { set answer [ tk_messageBox -message "$myload_dir1/$myload_retval does not seem to be an xschem file...\nContinue?" \ -icon warning -parent . -type yesno] @@ -1540,7 +1511,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init } else { return "$myload_dir1/$myload_retval" } - } elseif { $t ne {SYMBOL} && ($ext eq {.sym}) } { + } elseif { $myload_type ne {SYMBOL} && ($ext eq {.sym}) } { set answer [ tk_messageBox -message "$myload_dir1/$myload_retval does not seem to be a SYMBOL file...\nContinue?" \ -icon warning -parent . -type yesno] @@ -1813,7 +1784,7 @@ proc simuldir {} { # else set netlist_dir to dir # proc select_netlist_dir { force {dir {} }} { - global netlist_dir env + global netlist_dir env OS if { ( $force == 0 ) && ( $netlist_dir ne {} ) } { if {![file exist $netlist_dir]} { @@ -1827,7 +1798,7 @@ proc select_netlist_dir { force {dir {} }} { if { $netlist_dir ne {} } { set initdir $netlist_dir } else { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set initdir $env(windir) } else { set initdir [pwd] @@ -1852,7 +1823,7 @@ proc select_netlist_dir { force {dir {} }} { proc enter_text {textlabel {preserve_disabled disabled}} { - global retval rcode has_cairo preserve_unchanged_attrs + global retval rcode has_cairo preserve_unchanged_attrs wm_fix set rcode {} toplevel .dialog -class Dialog wm title .dialog {Enter text} @@ -1861,7 +1832,7 @@ proc enter_text {textlabel {preserve_disabled disabled}} { set Y [expr {[winfo pointery .dialog] - 25}] # 20100203 - if { $::wm_fix } { tkwait visibility .dialog } + if { $wm_fix } { tkwait visibility .dialog } wm geometry .dialog "+$X+$Y" frame .dialog.f1 label .dialog.f1.txtlab -text $textlabel @@ -2042,7 +2013,7 @@ proc select_layers {} { proc color_dim {} { toplevel .dim -class dialog wm title .dim {Dim colors} - checkbutton .dim.bg -text {Dim background} -variable dim_background + checkbutton .dim.bg -text {Dim background} -variable color_dim 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 @@ -2085,7 +2056,7 @@ proc property_search {} { global search_value search_found global search_exact global search_select - global custom_token + global custom_token OS set search_found 0 while { !$search_found} { @@ -2123,7 +2094,7 @@ proc property_search {} { button .dialog.but.cancel -text Cancel -command { set search_found 1; destroy .dialog } # Window doesn't support regular expression, has to be exact match for now - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set search_exact 1 checkbutton .dialog.but.sub -text Exact_search -variable search_exact -state disable } else { @@ -2252,7 +2223,7 @@ proc attach_labels_to_inst {} { } proc ask_save { {ask {save file?}} } { - global rcode + global rcode wm_fix set rcode {} if { [winfo exists .dialog] } return toplevel .dialog -class Dialog @@ -2260,7 +2231,7 @@ proc ask_save { {ask {save file?}} } { set X [expr {[winfo pointerx .dialog] - 60}] set Y [expr {[winfo pointery .dialog] - 35}] - if { $::wm_fix } { tkwait visibility .dialog } + if { $wm_fix } { tkwait visibility .dialog } wm geometry .dialog "+$X+$Y" label .dialog.l1 -text $ask @@ -2376,10 +2347,10 @@ proc change_color {} { regsub -all {#} $svg_colors {0x} svg_colors xschem change_colors - set savedata "#### THIS FILE IS AUTOMATICALLY GENERATED BY XSCHEM, DO NOT EDIT.\n" - set savedata "$savedata set cadlayers $cadlayers\n" - set savedata "$savedata set light_colors {$light_colors}\n" - set savedata "$savedata set dark_colors {$dark_colors}\n" + 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 } } @@ -2608,7 +2579,7 @@ proc write_data {data f} { } proc text_line {txtlabel clear {preserve_disabled disabled} } { - global text_line_default_geometry preserve_unchanged_attrs + global text_line_default_geometry preserve_unchanged_attrs wm_fix global retval rcode debug_var selected_tok retval_orig old_selected_tok set retval_orig $retval if $clear==1 then {set retval ""} @@ -2633,7 +2604,7 @@ proc text_line {txtlabel clear {preserve_disabled disabled} } { } # 20100203 - if { $::wm_fix } { tkwait visibility .dialog } + if { $wm_fix } { tkwait visibility .dialog } wm geometry .dialog "${text_line_default_geometry}+$X+$Y" frame .dialog.f0 @@ -2883,7 +2854,7 @@ proc textwindow {filename {ro {}}} { proc viewdata {data {ro {}}} { global viewdata_wcounter rcode - global viewdata_w + global viewdata_w OS # set viewdata_w .view$viewdata_wcounter # catch {destroy $viewdata_w} set viewdata_wcounter [expr {$viewdata_wcounter+1}] @@ -2899,7 +2870,7 @@ proc viewdata {data {ro {}}} { if { $ro eq {} } { button $viewdata_w.buttons.saveas -text {Save As} -command { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set fff [tk_getSaveFile -initialdir $env(windir) ] } else { set fff [tk_getSaveFile -initialdir [pwd] ] @@ -2951,7 +2922,7 @@ proc rel_sym_path {symbol} { # given a library/symbol return its absolute path proc abs_sym_path {fname {ext {} } } { - global pathlist + global pathlist OS set curr_dirname [xschem get current_dirname] @@ -2963,7 +2934,7 @@ proc abs_sym_path {fname {ext {} } } { set fname [file rootname $fname]$ext } - if {$::OS eq "Windows"} { + if {$OS eq "Windows"} { # absolute path: return as is if { [regexp {^[A-Za-z]\:/} $fname ] } { return "$fname" @@ -3029,7 +3000,7 @@ proc add_ext {fname ext} { } proc input_line {txt {cmd {}} {preset {}} {w 12}} { - global input_line_cmd input_line_data + global input_line_cmd input_line_data wm_fix set input_line_data {} if { [winfo exists .dialog] } return toplevel .dialog -class Dialog @@ -3037,7 +3008,7 @@ proc input_line {txt {cmd {}} {preset {}} {w 12}} { set X [expr {[winfo pointerx .dialog] - 60}] set Y [expr {[winfo pointery .dialog] - 35}] # 20100203 - if { $::wm_fix } { tkwait visibility .dialog } + if { $wm_fix } { tkwait visibility .dialog } wm geometry .dialog "+$X+$Y" set input_line_cmd $cmd frame .dialog.f1 @@ -3068,26 +3039,26 @@ proc input_line {txt {cmd {}} {preset {}} {w 12}} { return $input_line_data } -proc launcher {} { - # XSCHEM_SHAREDIR and netlist_dir not used directly but useful in paths passed thru launcher_var - global launcher_var launcher_default_program launcher_program env XSCHEM_SHAREDIR netlist_dir +proc launcher {launcher_var {launcher_program {} } } { + # env, XSCHEM_SHAREDIR and netlist_dir not used directly but useful in paths passed thru launcher_var + global launcher_default_program env XSCHEM_SHAREDIR netlist_dir if { ![string compare $launcher_program {}] } { set launcher_program $launcher_default_program} eval exec [subst $launcher_program] {[subst $launcher_var]} & } -proc reconfigure_layers_button {} { +proc reconfigure_layers_button { { topwin {} } } { global colors dark_colorscheme set c [xschem get rectcolor] - .menubar.layers configure -background [lindex $colors $c] + $topwin.menubar.layers configure -background [lindex $colors $c] if { $dark_colorscheme == 1 && $c == 0} { - .menubar.layers configure -foreground white + $topwin.menubar.layers configure -foreground white } else { - .menubar.layers configure -foreground black + $topwin.menubar.layers configure -foreground black } } -proc reconfigure_layers_menu {} { +proc reconfigure_layers_menu { {topwin {} } } { global colors dark_colorscheme set j 0 foreach i $colors { @@ -3105,19 +3076,19 @@ proc reconfigure_layers_menu {} { set layfg white } } - .menubar.layers.menu entryconfigure $j -activebackground $i \ + $topwin.menubar.layers.menu entryconfigure $j -activebackground $i \ -background $i -foreground $layfg -activeforeground $layfg incr j } - reconfigure_layers_button + reconfigure_layers_button $topwin } proc get_file_path {ff} { - global env + global env OS # Absolute path ? return as is. # Linux Windows if { [regexp {^/} $ff] || [regexp {^[a-zA-Z]:} $ff] } { return $ff } - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set mylist [split $env(PATH) \;] } else { set mylist [split $env(PATH) :] @@ -3281,7 +3252,7 @@ proc context_menu { } { # toolbar: Public variables that we allow to be overridden # proc setup_toolbar {} { - global toolbar_visible toolbar_horiz toolbar_list toolbar_sepn XSCHEM_SHAREDIR + global toolbar_visible toolbar_horiz toolbar_list XSCHEM_SHAREDIR set_ne toolbar_visible 0 set_ne toolbar_horiz 1 set_ne toolbar_list { @@ -3330,52 +3301,52 @@ proc setup_toolbar {} { # # Separation bar counter # - set toolbar_sepn 0 } # # Toolbar constructor # -proc toolbar_toolbar {} { - frame .toolbar -relief raised -bd 1 -bg white +proc toolbar_toolbar { {topwin {} } } { + frame $topwin.toolbar -relief raised -bd 1 -bg white } # # Create a tool button which may be displayed # -proc toolbar_create {name cmd { help "" } } { - button .toolbar.b$name -image img$name -relief flat -bd 3 -bg white -fg white -command $cmd - if { $help == "" } { balloon .toolbar.b$name $name } else { balloon .toolbar.b$name $help } +proc toolbar_create {name cmd { help "" } {topwin {} } } { + button $topwin.toolbar.b$name -image img$name -relief flat -bd 3 -bg white -fg white -command $cmd + if { $help == "" } { balloon $topwin.toolbar.b$name $name } else { balloon $topwin.toolbar.b$name $help } } # # Show the toolbar in horizontal or vertical position, parsing the toolbar list and # adding any separators as needed. # -proc toolbar_show {} { - global toolbar_horiz toolbar_list toolbar_sepn toolbar_visible +proc toolbar_show { { topwin {} } } { + global toolbar_horiz toolbar_list toolbar_visible if { ! $toolbar_visible } { return } if { $toolbar_horiz } { - pack .toolbar -fill x -before .drw + pack $topwin.toolbar -fill x -before $topwin.drw } else { - pack .toolbar -side left -anchor w -fill y -before .drw + pack $topwin.toolbar -side left -anchor w -fill y -before $topwin.drw } set pos "top" if { $toolbar_horiz } { set pos "left" } - set tlist [ winfo children .toolbar ] + set tlist [ winfo children $topwin.toolbar ] + set toolbar_sepn 0 foreach b $toolbar_list { if { $b == "---" } { if { $toolbar_horiz } { - frame .toolbar.sep$toolbar_sepn -bg lightgrey -width 2 - pack .toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill y + frame $topwin.toolbar.sep$toolbar_sepn -bg lightgrey -width 2 + pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill y } else { - frame .toolbar.sep$toolbar_sepn -bg lightgrey -height 2 - pack .toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill x + frame $topwin.toolbar.sep$toolbar_sepn -bg lightgrey -height 2 + pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill x } incr toolbar_sepn } else { - if { [ lsearch -exact $tlist ".toolbar.b$b" ] != -1 } { - pack .toolbar.b$b -side $pos + if { [ lsearch -exact $tlist "$topwin.toolbar.b$b" ] != -1 } { + pack $topwin.toolbar.b$b -side $pos } else { puts "Error: unknown toolbar item \"$b\"" } @@ -3384,7 +3355,7 @@ proc toolbar_show {} { set pos "bottom" if { $toolbar_horiz } { set pos "right" } foreach b { Waves Simulate Netlist } { - pack .toolbar.b$b -side $pos + pack $topwin.toolbar.b$b -side $pos } set $toolbar_visible 1 } @@ -3392,17 +3363,16 @@ proc toolbar_show {} { # # Hide the toolbar, unpack the buttons, and remove any separators # -proc toolbar_hide {} { - global toolbar_sepn toolbar_visible - set tlist [ winfo children .toolbar ] +proc toolbar_hide { { topwin {} } } { + global toolbar_visible + set tlist [ winfo children $topwin.toolbar ] foreach b $tlist { pack forget $b - if { [ string match ".toolbar.sep*" $b ] == 1 } { + if { [ string match "$topwin.toolbar.sep*" $b ] == 1 } { destroy $b } } - set toolbar_sepn 0 - pack forget .toolbar + pack forget $topwin.toolbar set $toolbar_visible 0 } @@ -3431,13 +3401,13 @@ proc new_window {what {path {}} {filename {}}} { if { $what eq {create}} { toplevel $path -bg {} -width 400 -height 400 update - xschem new_schematic create $path $filename - set_bindings $path - wm protocol $path WM_DELETE_WINDOW "xschem new_schematic destroy $path {}" - } elseif { $what eq {destroy_all}} { - xschem new_schematic destroy_all {} {} + build_widgets $path + pack_widgets $path + update + xschem new_schematic create $path.drw $filename + set_bindings $path.drw } elseif { $what eq {destroy}} { - xschem new_schematic destroy $path {} + xschem new_schematic destroy $path.drw {} } } @@ -3454,55 +3424,61 @@ proc test1_end {} { new_window destroy .yy } -proc set_bindings {window_path} { -global env has_x +proc set_bindings {topwin} { +global env has_x OS ### ### Tk event handling ### - if { $window_path eq {.drw} } { - bind . [list raise_dialog $window_path] - bind . [list raise_dialog $window_path] - bind . [list raise_dialog $window_path] + + if { $topwin eq {.drw} } { + bind . [list raise_dialog $topwin] + bind . [list raise_dialog $topwin] + bind . [list raise_dialog $topwin] } - bind $window_path {xschem callback -3 %x %y 0 %b 0 %s} - bind $window_path {xschem callback -3 %x %y 0 %b 0 %s} - bind $window_path {xschem callback -3 %x %y 0 %b 0 %s} - bind $window_path "xschem new_schematic switch $window_path {} - xschem callback %T %x %y 0 %w %h %s" - bind $window_path {xschem windowid; xschem callback %T %x %y 0 %w %h 0} - bind $window_path { - xschem callback %T %x %y 0 %b 0 %s + bind $topwin "+ + xschem new_schematic switch $topwin {} + xschem callback %W %T %x %y 0 %w %h %s + " + bind $topwin {xschem callback %W -3 %x %y 0 %b 0 %s} + bind $topwin {xschem callback %W -3 %x %y 0 %b 0 %s} + bind $topwin {xschem callback %W -3 %x %y 0 %b 0 %s} + bind $topwin " + xschem windowid + xschem new_schematic switch $topwin {} + xschem callback %W %T %x %y 0 %w %h 0 + " + bind $topwin { + xschem callback %W %T %x %y 0 %b 0 %s } - if {$::OS == "Windows"} { - bind $window_path { + if {$OS == "Windows"} { + bind $topwin { if {%D<0} { - xschem callback 4 %x %y 0 5 0 %s + xschem callback %W 4 %x %y 0 5 0 %s } else { - xschem callback 4 %x %y 0 4 0 %s + xschem callback %W 4 %x %y 0 4 0 %s } } } - bind $window_path {xschem callback %T %x %y 0 %b 0 %s} + bind $topwin {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 $window_path {xschem callback %T %x %y %N 0 0 [expr {$Mod1Mask}]} - bind $window_path {xschem callback %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]} - bind $window_path {xschem callback %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]} + if {$OS == "Windows" } { + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$Mod1Mask}]} + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]} + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]} } - bind $window_path { - xschem callback %T %x %y %N 0 0 %s + bind $topwin { + xschem callback %W %T %x %y %N 0 0 %s } - bind $window_path {xschem callback %T %x %y %N 0 0 %s} ;# 20161118 - bind $window_path "focus $window_path; xschem callback %T %x %y 0 0 0 %s" - bind $window_path "focus $window_path - xschem new_schematic switch $window_path {} - xschem callback %T %x %y 0 0 0 0" - bind $window_path {} - bind $window_path { - wm withdraw .infotext - set show_infowindow 0 - } - bind $window_path "?" { textwindow "${XSCHEM_SHAREDIR}/xschem.help" } + bind $topwin {xschem callback %W %T %x %y %N 0 0 %s} ;# 20161118 + bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s" + bind $topwin " + focus $topwin + xschem new_schematic switch $topwin {} + xschem callback %W %T %x %y 0 0 0 0 + " + bind $topwin {} + bind $topwin { 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 @@ -3510,32 +3486,550 @@ global env has_x ## In previous flow xschem.tcl was setting up windows and events before X initialization was completed by xinit.c. ## this could lead to crashes on some (may be slow) systems due to Configure/Expose events being delivered ## before xschem being ready to handle them. -proc build_windows {} { - global env has_x - if {($::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} { - pack .statusbar.2 -side left - pack .statusbar.3 -side left - pack .statusbar.4 -side left - pack .statusbar.5 -side left - pack .statusbar.6 -side left - pack .statusbar.7 -side left - pack .statusbar.8 -side left - pack .statusbar.1 -side left -fill x - pack .drw -anchor n -side top -fill both -expand true - pack .menubar -anchor n -side top -fill x -before .drw - toolbar_show - pack .statusbar -after .drw -anchor sw -fill x - bind .statusbar.5 { xschem set cadgrid $cadgrid; focus .drw} - bind .statusbar.3 { xschem set cadsnap $cadsnap; focus .drw} - set_bindings {.drw} +proc pack_widgets { { topwin {} } } { + global env has_x OS + if {($OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} { + pack $topwin.statusbar.2 -side left + pack $topwin.statusbar.3 -side left + pack $topwin.statusbar.4 -side left + pack $topwin.statusbar.5 -side left + pack $topwin.statusbar.6 -side left + pack $topwin.statusbar.7 -side left + pack $topwin.statusbar.8 -side left + pack $topwin.statusbar.1 -side left -fill x + pack $topwin.drw -anchor n -side top -fill both -expand true + pack $topwin.menubar -anchor n -side top -fill x -before $topwin.drw + toolbar_show $topwin + pack $topwin.statusbar -after $topwin.drw -anchor sw -fill x + bind $topwin.statusbar.5 {xschem set cadgrid $cadgrid} + bind $topwin.statusbar.3 {xschem set cadsnap $cadsnap} + set_bindings $topwin.drw } } +proc build_widgets { {topwin {} } } { + global XSCHEM_SHAREDIR + global colors recentfile color_ps transparent_svg menu_debug_var enable_stretch + global netlist_show flat_netlist split_files hspice_netlist tmp_bus_char + 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 + 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 + menu $topwin.menubar.file.menu -tearoff 0 + menubutton $topwin.menubar.edit -text "Edit" -menu $topwin.menubar.edit.menu -padx 3 -pady 0 + menu $topwin.menubar.edit.menu -tearoff 0 + menubutton $topwin.menubar.option -text "Options" -menu $topwin.menubar.option.menu -padx 3 -pady 0 + menu $topwin.menubar.option.menu -tearoff 0 + menubutton $topwin.menubar.view -text "View" -menu $topwin.menubar.view.menu -padx 3 -pady 0 + menu $topwin.menubar.view.menu -tearoff 0 + menubutton $topwin.menubar.prop -text "Properties" -menu $topwin.menubar.prop.menu -padx 3 -pady 0 + menu $topwin.menubar.prop.menu -tearoff 0 + menubutton $topwin.menubar.layers -text "Layers" -menu $topwin.menubar.layers.menu -padx 3 -pady 0 \ + -background [lindex $colors 4] + menu $topwin.menubar.layers.menu -tearoff 0 + menubutton $topwin.menubar.tools -text "Tools" -menu $topwin.menubar.tools.menu -padx 3 -pady 0 + menu $topwin.menubar.tools.menu -tearoff 0 + menubutton $topwin.menubar.sym -text "Symbol" -menu $topwin.menubar.sym.menu -padx 3 -pady 0 + menu $topwin.menubar.sym.menu -tearoff 0 + menubutton $topwin.menubar.hilight -text "Highlight" -menu $topwin.menubar.hilight.menu -padx 3 -pady 0 + menu $topwin.menubar.hilight.menu -tearoff 0 + menubutton $topwin.menubar.simulation -text "Simulation" -menu $topwin.menubar.simulation.menu -padx 3 -pady 0 + menu $topwin.menubar.simulation.menu -tearoff 0 + menubutton $topwin.menubar.help -text "Help" -menu $topwin.menubar.help.menu -padx 3 -pady 0 + menu $topwin.menubar.help.menu -tearoff 0 + $topwin.menubar.help.menu add command -label "Help" -command "textwindow \"${XSCHEM_SHAREDIR}/xschem.help\" ro" \ + -accelerator {?} + $topwin.menubar.help.menu add command -label "Keys" -command "textwindow \"${XSCHEM_SHAREDIR}/keys.help\" ro" + $topwin.menubar.help.menu add command -label "About XSCHEM" -command "about" + + $topwin.menubar.file.menu add command -label "New Schematic" -accelerator Ctrl+N\ + -command { + xschem clear SCHEMATIC + } + # toolbar_create FileNew {xschem clear SCHEMATIC} "New Schematic" $topwin + $topwin.menubar.file.menu add command -label "New Symbol" -accelerator Ctrl+Shift+N \ + -command { + xschem clear SYMBOL + } + # toolbar_create FileNewSym {xschem clear SYMBOL} "New Symbol" $topwin + $topwin.menubar.file.menu add command -label "New empty Schematic window" -accelerator {Alt+N} \ + -command { + xschem new_window + } + $topwin.menubar.file.menu add command -label "New empty Symbol window" -accelerator {Alt+Shift+N} \ + -command { + xschem new_symbol_window + } + $topwin.menubar.file.menu add command -label "Open" -command "xschem load" -accelerator {Ctrl+O} + toolbar_create FileOpen "xschem load" "Open File" $topwin + $topwin.menubar.file.menu add command -label "Delete files" -command "xschem delete_files" -accelerator {Shift-D} + + menu $topwin.menubar.file.menu.recent -tearoff 0 + setup_recent_menu $topwin + $topwin.menubar.file.menu add cascade -label "Open Recent" -menu $topwin.menubar.file.menu.recent + + $topwin.menubar.file.menu add command -label "Open Most Recent" \ + -command {xschem load [lindex "$recentfile" 0]} -accelerator {Ctrl+Shift+O} + $topwin.menubar.file.menu add command -label "Save" -command "xschem save" -accelerator {Ctrl+S} + toolbar_create FileSave "xschem save" "Save File" $topwin + $topwin.menubar.file.menu add command -label "Merge" -command "xschem merge" -accelerator {Shift+B} + # toolbar_create FileMerge "xschem merge" "Merge File" $topwin + $topwin.menubar.file.menu add command -label "Reload" -accelerator {Alt+S} \ + -command { + if { [string compare [tk_messageBox -type okcancel -message {Are you sure you want to reload?}] ok]==0 } { + xschem reload + } + } + toolbar_create FileReload { + if { [string compare [tk_messageBox -type okcancel -message {Are you sure you want to reload?}] ok]==0 } { + xschem reload + } + } "Reload File" $topwin + $topwin.menubar.file.menu add command -label "Save as" -command "xschem saveas" -accelerator {Ctrl+Shift+S} + $topwin.menubar.file.menu add command -label "Save as symbol" \ + -command "xschem saveas {} SYMBOL" -accelerator {Ctrl+Alt+S} + # added svg, png 20171022 + $topwin.menubar.file.menu add command -label "PDF/PS Export" -command "xschem print pdf" -accelerator {*} + $topwin.menubar.file.menu add command -label "Hierarchical PDF/PS Export" -command "xschem hier_psprint" + $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.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} + } + $topwin.menubar.option.menu add checkbutton -label "Transparent SVG background" -variable transparent_svg \ + -command { + if { $transparent_svg==1 } {xschem set transparent_svg 1} else { xschem set transparent_svg 0} + } + $topwin.menubar.option.menu add checkbutton -label "Debug mode" -variable menu_debug_var \ + -command { + if { $menu_debug_var==1 } {xschem debug 1} else { xschem debug 0} + } + $topwin.menubar.option.menu add checkbutton -label "Enable stretch" -variable enable_stretch \ + -accelerator Y \ + -command { + if { $enable_stretch==1 } {xschem set enable_stretch 1} else { xschem set enable_stretch 0} + } + $topwin.menubar.option.menu add checkbutton -label "Show netlist win" -variable netlist_show \ + -accelerator {Shift+A} \ + -command { + if { $netlist_show==1 } {xschem set netlist_show 1} else { xschem set netlist_show 0} + } + $topwin.menubar.option.menu add checkbutton -label "Flat netlist" -variable flat_netlist \ + -accelerator : \ + -command { + if { $flat_netlist==1 } {xschem set flat_netlist 1} else { xschem set flat_netlist 0} + } + $topwin.menubar.option.menu add checkbutton -label "Split netlist" -variable split_files \ + -accelerator {} \ + -command { + if { $split_files==1 } {xschem set split_files 1} else { xschem set split_files 0} + } + $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} + } + $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" + if { [info exists tmp_bus_char] && [string length $tmp_bus_char] >=2} { + set bus_replacement_char $tmp_bus_char + } + } + $topwin.menubar.option.menu add checkbutton -label "Verilog 2001 netlist variant" -variable verilog_2001 + $topwin.menubar.option.menu add checkbutton -label "Draw grid" -variable draw_grid \ + -accelerator {%} \ + -command { + if { $draw_grid == 1} { xschem set draw_grid 1; xschem redraw} else { xschem set draw_grid 0; xschem redraw} + } + $topwin.menubar.option.menu add checkbutton -label "Variable grid point size" -variable big_grid_points \ + -command { + if { $big_grid_points == 1} { + xschem set big_grid_points 1 + xschem redraw + } else { + xschem set big_grid_points 0 + xschem redraw + } + } + $topwin.menubar.option.menu add checkbutton -label "Symbol text" -variable sym_txt \ + -accelerator {Ctrl+B} \ + -command { + if { $sym_txt == 1} { xschem set sym_txt 1; xschem redraw} else { xschem set sym_txt 0; xschem redraw} + } + $topwin.menubar.option.menu add checkbutton -label "Toggle variable line width" -variable change_lw \ + -accelerator {_} \ + -command { + if { $change_lw == 1} { xschem set change_lw 1} else { xschem set change_lw 0} + } + $topwin.menubar.option.menu add checkbutton -label "Increment Hilight Color" -variable incr_hilight \ + -command { + if { $incr_hilight == 1} { xschem set incr_hilight 1} else { xschem set incr_hilight 0} + } + + $topwin.menubar.option.menu add command -label "Set line width" \ + -command { + input_line "Enter linewidth (float):" "xschem line_width" + } + $topwin.menubar.option.menu add command -label "Set symbol width" \ + -command { + input_line "Enter Symbol width ($symbol_width)" "set symbol_width" $symbol_width + } + + $topwin.menubar.option.menu add separator + $topwin.menubar.option.menu add radiobutton -label "Spice netlist" -variable netlist_type -value spice \ + -accelerator {Shift+V} \ + -command "xschem netlist_type spice" + $topwin.menubar.option.menu add radiobutton -label "VHDL netlist" -variable netlist_type -value vhdl \ + -accelerator {Shift+V} \ + -command "xschem netlist_type vhdl" + $topwin.menubar.option.menu add radiobutton -label "Verilog netlist" -variable netlist_type -value verilog \ + -accelerator {Shift+V} \ + -command "xschem netlist_type verilog" + $topwin.menubar.option.menu add radiobutton -label "tEDAx netlist" -variable netlist_type -value tedax \ + -accelerator {Shift+V} \ + -command "xschem netlist_type tedax" + $topwin.menubar.option.menu add radiobutton -label "Symbol global attrs" -variable netlist_type -value symbol \ + -accelerator {Shift+V} \ + -command "xschem netlist_type symbol" + $topwin.menubar.edit.menu add command -label "Undo" -command "xschem undo; xschem redraw" -accelerator U + toolbar_create EditUndo "xschem undo; xschem redraw" "Undo" $topwin + $topwin.menubar.edit.menu add command -label "Redo" -command "xschem redo; xschem redraw" -accelerator {Shift+U} + toolbar_create EditRedo "xschem redo; xschem redraw" "Redo" $topwin + toolbar_create EditCut "xschem cut" "Cut" $topwin + $topwin.menubar.edit.menu add command -label "Copy" -command "xschem copy" -accelerator Ctrl+C + toolbar_create EditCopy "xschem copy" "Copy" $topwin + $topwin.menubar.edit.menu add command -label "Cut" -command "xschem cut" -accelerator Ctrl+X + $topwin.menubar.edit.menu add command -label "Paste" -command "xschem paste" -accelerator Ctrl+V + toolbar_create EditPaste "xschem paste" "Paste" $topwin + $topwin.menubar.edit.menu add command -label "Delete" -command "xschem delete" -accelerator Del + toolbar_create EditDelete "xschem delete" "Delete" $topwin + $topwin.menubar.edit.menu add command -label "Select all" -command "xschem select_all" -accelerator Ctrl+A + $topwin.menubar.edit.menu add command -label "Edit selected schematic in new window" \ + -command "xschem schematic_in_new_window" -accelerator Alt+E + $topwin.menubar.edit.menu add command -label "Edit selected symbol in new window" \ + -command "xschem symbol_in_new_window" -accelerator Alt+I + $topwin.menubar.edit.menu add command -label "Duplicate objects" -command "xschem copy_objects" -accelerator C + toolbar_create EditDuplicate "xschem copy_objects" "Duplicate objects" $topwin + $topwin.menubar.edit.menu add command -label "Move objects" -command "xschem move_objects" -accelerator M + toolbar_create EditMove "xschem move_objects" "Move objects" $topwin + $topwin.menubar.edit.menu add command -label "Flip selected objects" -command "xschem flip" -accelerator {Alt-F} + $topwin.menubar.edit.menu add command -label "Rotate selected objects" -command "xschem rotate" -accelerator {Alt-R} + $topwin.menubar.edit.menu add radiobutton -label "Unconstrained move" -variable constrained_move \ + -value 0 -command {xschem set constrained_move 0} + $topwin.menubar.edit.menu add radiobutton -label "Constrained Horizontal move" -variable constrained_move \ + -value 1 -accelerator H -command {xschem set constrained_move 1} + $topwin.menubar.edit.menu add radiobutton -label "Constrained Vertical move" -variable constrained_move \ + -value 2 -accelerator V -command {xschem set constrained_move 2} + $topwin.menubar.edit.menu add command -label "Push schematic" -command "xschem descend" -accelerator E + toolbar_create EditPushSch "xschem descend" "Push schematic" $topwin + $topwin.menubar.edit.menu add command -label "Push symbol" -command "xschem descend_symbol" -accelerator I + toolbar_create EditPushSym "xschem descend_symbol" "Push symbol" $topwin + $topwin.menubar.edit.menu add command -label "Pop" -command "xschem go_back" -accelerator Ctrl+E + toolbar_create EditPop "xschem go_back" "Pop" $topwin + button $topwin.menubar.waves -text "Waves" -activebackground red -takefocus 0 -padx 2 -pady 0 \ + -command { + 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\" + } + " + button $topwin.menubar.netlist -text "Netlist" -activebackground red -takefocus 0 -padx 2 -pady 0 \ + -command { + xschem netlist + } + # create $topwin.menubar.layers.menu + create_layers_menu $topwin + $topwin.menubar.view.menu add checkbutton -label "Show ERC Info window" -variable show_infowindow \ + -command { + if { $show_infowindow != 0 } {wm deiconify .infotext + } else {wm withdraw .infotext} + } + $topwin.menubar.view.menu add command -label "Redraw" -command "xschem redraw" -accelerator Esc + toolbar_create ViewRedraw "xschem redraw" "Redraw" $topwin + $topwin.menubar.view.menu add checkbutton -label "Fullscreen" -variable fullscreen \ + -accelerator {Alt+Shift+F} -command " + xschem fullscreen $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 + $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 + $topwin.menubar.view.menu add command -label "Zoom box" -command "xschem zoom_box" -accelerator Z + 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} ] + } + $topwin.menubar.view.menu add command -label "Double Snap Threshold" -accelerator Shift-G -command { + xschem set cadsnap [expr {[xschem get cadsnap] * 2.0} ] + } + $topwin.menubar.view.menu add command -label "Set snap value" \ + -command { + input_line "Enter snap value ( default: [xschem get cadsnap_default] current: [xschem get cadsnap])" \ + "xschem set cadsnap" [xschem get cadsnap] + } + $topwin.menubar.view.menu add command -label "Set grid spacing" \ + -command { + input_line "Enter grid spacing (float):" "xschem set cadgrid" $cadgrid + } + $topwin.menubar.view.menu add checkbutton -label "View only Probes" -variable only_probes \ + -accelerator {5} \ + -command { xschem only_probes } + $topwin.menubar.view.menu add command -label "Toggle colorscheme" -accelerator {Shift+O} -command { + xschem toggle_colorscheme + xschem change_colors + } + toolbar_create ViewToggleColors { + xschem toggle_colorscheme + xschem change_colors + } "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 { + change_color + } + $topwin.menubar.view.menu add checkbutton -label "No XCopyArea drawing model" -variable draw_window \ + -accelerator {Ctrl+$} \ + -command { + if { $draw_window == 1} { xschem set draw_window 1} else { xschem set draw_window 0} + } + $topwin.menubar.view.menu add checkbutton -label "Show net names on symbol pins" -variable show_pin_net_names \ + -command { + xschem set show_pin_net_names $show_pin_net_names + xschem redraw + } + $topwin.menubar.view.menu add checkbutton -label "Show Toolbar" -variable toolbar_visible \ + -command " + if { \$toolbar_visible } \" toolbar_show $topwin\" else \"toolbar_hide $topwin\" + " + $topwin.menubar.view.menu add checkbutton -label "Horizontal Toolbar" -variable toolbar_horiz \ + -command " + if { \$toolbar_visible } \" toolbar_hide $topwin; toolbar_show $topwin \" + " + $topwin.menubar.prop.menu add command -label "Edit" -command "xschem edit_prop" -accelerator Q + $topwin.menubar.prop.menu add command -label "Edit with editor" -command "xschem edit_vi_prop" -accelerator Shift+Q + $topwin.menubar.prop.menu add command -label "View" -command "xschem view_prop" -accelerator Ctrl+Shift+Q + $topwin.menubar.prop.menu add command -background red -label "Edit file (danger!)" \ + -command "xschem edit_file" -accelerator Alt+Q + $topwin.menubar.sym.menu add radiobutton -label "Show Symbols" -variable hide_symbols -value 0 \ + -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B + $topwin.menubar.sym.menu add radiobutton -label "Show instance Bounding boxes for subcircuit symbols" \ + -variable hide_symbols -value 1 \ + -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B + $topwin.menubar.sym.menu add radiobutton -label "Show instance Bounding boxes for all symbols" \ + -variable hide_symbols -value 2 \ + -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B + $topwin.menubar.sym.menu add command -label "Make symbol from schematic" -command "xschem make_symbol" -accelerator A + $topwin.menubar.sym.menu add command -label "Make schematic from symbol" -command "xschem make_sch" -accelerator Ctrl+L + $topwin.menubar.sym.menu add command -label "Make schematic and symbol from selected components" \ + -command "xschem make_sch_from_sel" -accelerator Ctrl+Shift+H + $topwin.menubar.sym.menu add command -label "Attach pins to component instance" \ + -command "xschem attach_pins" -accelerator Shift+H + $topwin.menubar.sym.menu add command -label "Create symbol pins from selected schematic pins" \ + -command "schpins_to_sympins" -accelerator Alt+H + $topwin.menubar.sym.menu add command -label "Place symbol pin" \ + -command "xschem add_symbol_pin" -accelerator Alt+P + $topwin.menubar.sym.menu add command -label "Print list of highlight nets" \ + -command "xschem print_hilight_net 1" -accelerator J + $topwin.menubar.sym.menu add command -label "Print list of highlight nets, with buses expanded" \ + -command "xschem print_hilight_net 3" -accelerator Alt-Ctrl-J + $topwin.menubar.sym.menu add command -label "Create labels from highlight nets" \ + -command "xschem print_hilight_net 4" -accelerator Alt-J + $topwin.menubar.sym.menu add command -label "Create labels from highlight nets with 'i' prefix" \ + -command "xschem print_hilight_net 2" -accelerator Alt-Shift-J + $topwin.menubar.sym.menu add command -label "Create pins from highlight nets" \ + -command "xschem print_hilight_net 0" -accelerator Ctrl-J + $topwin.menubar.sym.menu add checkbutton -label "Allow duplicated instance names (refdes)" \ + -variable disable_unique_names -command { + xschem set disable_unique_names $disable_unique_names + } + $topwin.menubar.tools.menu add checkbutton -label "Remember last command" -variable persistent_command \ + -command {xschem set persistent_command $persistent_command} + $topwin.menubar.tools.menu add command -label "Insert symbol" -command "xschem place_symbol" -accelerator {Ins, Shift-I} + toolbar_create ToolInsertSymbol "xschem place_symbol" "Insert Symbol" $topwin + $topwin.menubar.tools.menu add command -label "Insert wire label" -command "xschem net_label 1" -accelerator {Alt-L} + $topwin.menubar.tools.menu add command -label "Insert wire label 2" -command "xschem net_label 0" \ + -accelerator {Alt-Shift-L} + $topwin.menubar.tools.menu add command -label "Insert text" -command "xschem place_text" -accelerator T + toolbar_create ToolInsertText "xschem place_text" "Insert Text" $topwin + $topwin.menubar.tools.menu add command -label "Insert wire" -command "xschem wire" -accelerator W + toolbar_create ToolInsertWire "xschem wire" "Insert Wire" $topwin + $topwin.menubar.tools.menu add command -label "Insert snap wire" -command "xschem snap_wire" -accelerator Shift+W + $topwin.menubar.tools.menu add command -label "Insert line" -command "xschem line" -accelerator L + toolbar_create ToolInsertLine "xschem line" "Insert Line" $topwin + $topwin.menubar.tools.menu add command -label "Insert rect" -command "xschem rect" -accelerator R + toolbar_create ToolInsertRect "xschem rect" "Insert Rectangle" $topwin + $topwin.menubar.tools.menu add command -label "Insert polygon" -command "xschem polygon" -accelerator Ctrl+W + toolbar_create ToolInsertPolygon "xschem polygon" "Insert Polygon" $topwin + $topwin.menubar.tools.menu add command -label "Insert arc" -command "xschem arc" -accelerator Shift+C + toolbar_create ToolInsertArc "xschem arc" "Insert Arc" $topwin + $topwin.menubar.tools.menu add command -label "Insert circle" -command "xschem circle" -accelerator Ctrl+Shift+C + toolbar_create ToolInsertCircle "xschem circle" "Insert Circle" $topwin + $topwin.menubar.tools.menu add command -label "Search" -accelerator Ctrl+F -command property_search + toolbar_create ToolSearch property_search "Search" $topwin + $topwin.menubar.tools.menu add command -label "Align to Grid" -accelerator Alt+U -command "xschem align" + $topwin.menubar.tools.menu add command -label "Execute TCL command" -command "tclcmd" + $topwin.menubar.tools.menu add command -label "Join/Trim wires" \ + -command "xschem trim_wires" -accelerator {&} + toolbar_create ToolJoinTrim "xschem trim_wires" "Join/Trim Wires" $topwin + $topwin.menubar.tools.menu add command -label "Break wires at selected instance pins" \ + -command "xschem break_wires" -accelerator {!} + toolbar_create ToolBreak "xschem break_wires" "Break wires at selected\ninstance pin intersections" $topwin + $topwin.menubar.tools.menu add checkbutton -label "Auto Join/Trim Wires" -variable autotrim_wires \ + -command { + xschem set autotrim_wires $autotrim_wires + if {$autotrim_wires == 1} { + xschem trim_wires + xschem redraw + } + } + $topwin.menubar.tools.menu add command -label "Select all connected wires/labels/pins" -accelerator {Shift-Right Butt.} \ + -command { xschem connected_nets} + $topwin.menubar.tools.menu add command -label "Select conn. wires, stop at junctions" -accelerator {Ctrl-Righ Butt.} \ + -command { xschem connected_nets 1 } + + $topwin.menubar.hilight.menu add command -label {Highlight net-pin name mismatches on selected instancs} \ + -command "xschem net_pin_mismatch" \ + -accelerator {Shift-X} + $topwin.menubar.hilight.menu add command -label {Highlight duplicate instance names} \ + -command "xschem check_unique_names 0" -accelerator {#} + $topwin.menubar.hilight.menu add command -label {Rename duplicate instance names} \ + -command "xschem check_unique_names 1" -accelerator {Ctrl+#} + $topwin.menubar.hilight.menu add command -label {Propagate Highlight selected net/pins} \ + -command "xschem hilight drill" -accelerator {Ctrl+Shift+K} + $topwin.menubar.hilight.menu add command -label {Highlight selected net/pins} \ + -command "xschem hilight" -accelerator K + $topwin.menubar.hilight.menu add command -label {Send selected net/pins to Viewer} \ + -command "xschem send_to_viewer" -accelerator Alt+G + $topwin.menubar.hilight.menu add command -label {Select hilight nets / pins} -command "xschem select_hilight_net" \ + -accelerator Alt+K + $topwin.menubar.hilight.menu add command -label {Un-highlight all net/pins} \ + -command "xschem unhilight_all" -accelerator Shift+K + $topwin.menubar.hilight.menu add command -label {Un-highlight selected net/pins} \ + -command "xschem unhilight" -accelerator Ctrl+K + # 20160413 + $topwin.menubar.hilight.menu add checkbutton -label {Auto-highlight net/pins} -variable auto_hilight \ + -command { + if { $auto_hilight == 1} { + xschem set auto_hilight 1 + } else { + xschem set auto_hilight 0 + } + } + $topwin.menubar.hilight.menu add checkbutton -label {Enable highlight connected instances} \ + -variable en_hilight_conn_inst -command {xschem set en_hilight_conn_inst $en_hilight_conn_inst} + + $topwin.menubar.simulation.menu add command -label "Set netlist Dir" \ + -command { + select_netlist_dir 1 + } + $topwin.menubar.simulation.menu add command -label "Set top level netlist name" \ + -command { + input_line {Set netlist file name} {xschem set netlist_name} [xschem get netlist_name] 40 + } + $topwin.menubar.simulation.menu add checkbutton -label "Use 'simulation' dir under current schematic dir" \ + -variable local_netlist_dir \ + -command { if {$local_netlist_dir == 0 } { select_netlist_dir 1 } else { simuldir} } + $topwin.menubar.simulation.menu add command -label {Configure simulators and tools} -command {simconf} + $topwin.menubar.simulation.menu add command -label {Utile Stimuli Editor (GUI)} \ + -command {utile_gui [file tail [xschem get schname]]} + $topwin.menubar.simulation.menu add command -label "Utile Stimuli Editor ([lindex $editor 0])" \ + -command {utile_edit [file tail [xschem get schname]]} + $topwin.menubar.simulation.menu add command -label {Utile Stimuli Translate} \ + -command {utile_translate [file tail [xschem get schname]]} + $topwin.menubar.simulation.menu add command -label {Shell [simulation path]} \ + -command { + if { [select_netlist_dir 0] ne "" } { + get_shell $netlist_dir + } + } + $topwin.menubar.simulation.menu add command -label {Edit Netlist} \ + -command {edit_netlist [file tail [xschem get schname]]} + $topwin.menubar.simulation.menu add command -label {Send highlighted nets to viewer} \ + -command {xschem create_plot_cmd} -accelerator Shift+J + $topwin.menubar.simulation.menu add separator + $topwin.menubar.simulation.menu add checkbutton -label "LVS netlist: Top level is a .subckt" -variable top_subckt + $topwin.menubar.simulation.menu add checkbutton -label "Use 'spiceprefix' attribute" -variable spiceprefix \ + -command {xschem set spiceprefix $spiceprefix; 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 Waves { waves } "View results" $topwin + + pack $topwin.menubar.file -side left + pack $topwin.menubar.edit -side left + pack $topwin.menubar.option -side left + pack $topwin.menubar.view -side left + pack $topwin.menubar.prop -side left + pack $topwin.menubar.layers -side left + pack $topwin.menubar.tools -side left + pack $topwin.menubar.sym -side left + pack $topwin.menubar.hilight -side left + pack $topwin.menubar.simulation -side left + pack $topwin.menubar.help -side right + pack $topwin.menubar.waves -side right + pack $topwin.menubar.simulate -side right + pack $topwin.menubar.netlist -side right + + frame $topwin.drw -background {} -takefocus 1 + + focus $topwin.drw + if { $topwin == {} } {set rootwin .} else { set rootwin $topwin} + wm title $rootwin "xschem - " + wm iconname $rootwin "xschem - " + $rootwin configure -background {} + wm geometry $rootwin $initial_geometry + #wm maxsize . 1600 1200 + if { $rootwin == {.}} { + wm protocol $rootwin WM_DELETE_WINDOW {xschem exit} + } else { + wm protocol $topwin WM_DELETE_WINDOW "xschem new_schematic destroy $topwin.drw {}" + } + + frame $topwin.statusbar + label $topwin.statusbar.1 -text "STATUS BAR 1" + label $topwin.statusbar.2 -text "SNAP:" + entry $topwin.statusbar.3 -textvariable cadsnap -relief sunken -bg white \ + -width 10 -foreground black -takefocus 0 + label $topwin.statusbar.4 -text "GRID:" + entry $topwin.statusbar.5 -textvariable cadgrid -relief sunken -bg white \ + -width 10 -foreground black -takefocus 0 + label $topwin.statusbar.6 -text "NETLIST MODE:" + entry $topwin.statusbar.7 -textvariable netlist_type -relief sunken -bg white \ + -width 8 -state disabled -disabledforeground black + label $topwin.statusbar.8 -activebackground red -text {} +} + proc set_paths {} { - global XSCHEM_LIBRARY_PATH env pathlist + global XSCHEM_LIBRARY_PATH env pathlist OS set pathlist {} if { [info exists XSCHEM_LIBRARY_PATH] } { - if {$::OS == "Windows"} { + if {$OS == "Windows"} { set pathlist_orig [split $XSCHEM_LIBRARY_PATH \;] } else { set pathlist_orig [split $XSCHEM_LIBRARY_PATH :] @@ -3601,7 +4095,7 @@ proc set_initial_dirs {} { } } -proc create_layers_menu {} { +proc create_layers_menu { {topwin {} } } { global dark_colorscheme colors if { $dark_colorscheme == 1 } { set txt_color black} else { set txt_color white} set j 0 @@ -3630,10 +4124,10 @@ proc create_layers_menu {} { set laylab "[format %2d $j] " set layfg $txt_color } - .menubar.layers.menu add command -label $laylab -activeforeground $layfg \ + $topwin.menubar.layers.menu add command -label $laylab -activeforeground $layfg \ -foreground $layfg -background $i -activebackground $i \ - -command "xschem set rectcolor $j; reconfigure_layers_button" - if { [expr {$j%10}] == 0 } { .menubar.layers.menu entryconfigure $j -columnbreak 1 } + -command "xschem set rectcolor $j; reconfigure_layers_button $topwin" + if { [expr {$j%10}] == 0 } { $topwin.menubar.layers.menu entryconfigure $j -columnbreak 1 } incr j } } @@ -3654,6 +4148,23 @@ proc source_user_tcl_files {} { } } +proc setup_tcp_ports {} { + global xschem_listen_port bespice_listen_port + if { [info exists xschem_listen_port] && ($xschem_listen_port ne {}) } { + if {[catch {socket -server xschem_server $xschem_listen_port} err]} { + puts "problems listening to TCP port: $xschem_listen_port" + puts $err + } + } + + if { [info exists bespice_listen_port] && ($bespice_listen_port ne {}) } { + if {[catch {socket -server bespice_server $bespice_listen_port} err]} { + puts "problems listening to TCP port: $bespice_listen_port" + puts $err + } + } +} + ### ### MAIN PROGRAM ### @@ -3664,7 +4175,7 @@ set env(LC_ALL) C set_paths print_help_and_exit -if {$::OS == "Windows"} { +if {$OS == "Windows"} { set_ne XSCHEM_TMP_DIR [xschem get temp_dir] } else { set_ne XSCHEM_TMP_DIR {/tmp} @@ -3737,9 +4248,7 @@ set_ne rainbow_colors 0 set_ne initial_geometry {900x600} set_ne edit_symbol_prop_new_sel {} #20161102 -set_ne launcher_var {} set_ne launcher_default_program {xdg-open} -set_ne launcher_program {} #20160413 set_ne auto_hilight 0 set_ne en_hilight_conn_inst 0 @@ -3784,7 +4293,7 @@ set_ne cairo_font_line_spacing 1.0 set_ne cairo_vert_correct 0 set_ne nocairo_vert_correct 0 -# Arial, Monospace +# Arial, Monospace Sans-Serif; default font to use if unspecified in text elements set_ne cairo_font_name {Sans-Serif} set_ne svg_font_name {Sans-Serif} @@ -3792,7 +4301,7 @@ set_ne svg_font_name {Sans-Serif} set has_cairo 0 set rotated_text {} ;#20171208 set_ne dark_colorscheme 1 -set_ne dim_background 1 +set_ne color_dim 1 ##### set colors if {!$rainbow_colors} { set_ne cadlayers 22 @@ -3852,7 +4361,7 @@ set_ne preserve_unchanged_attrs 0 set search_select 0 # 20111106 these vars are overwritten by caller with mktemp file names -if {$::OS == "Windows"} { +if {$OS == "Windows"} { set filetmp $env(windir)/.tmp2 } else { set filetmp [pwd]/.tmp2 @@ -3863,19 +4372,7 @@ if {$::OS == "Windows"} { # if set cell is copied when renaming it set_ne copy_cell 0 - -# recent files -set recentfile {} -if { [file exists $USER_CONF_DIR/recent_files] } { - if {[catch { source $USER_CONF_DIR/recent_files } err] } { - puts "Problems opening recent_files: $err" - if {[info exists has_x]} { - tk_messageBox -message "Problems opening recent_files: $err" -icon warning -parent . -type ok - } - - } -} - +load_recent_file # schematic to preload in new windows 20090708 set_ne XSCHEM_START_WINDOW {} @@ -3885,6 +4382,9 @@ set_initial_dirs set custom_token {lab} set search_value {} set search_exact 0 +xschem set persistent_command $persistent_command +xschem set autotrim_wires $autotrim_wires +xschem set disable_unique_names $disable_unique_names # 20171005 @@ -3896,539 +4396,27 @@ xschem set nocairo_font_yscale $nocairo_font_yscale xschem set cairo_font_line_spacing $cairo_font_line_spacing xschem set cairo_vert_correct $cairo_vert_correct xschem set nocairo_vert_correct $nocairo_vert_correct -xschem set persistent_command $persistent_command -xschem set autotrim_wires $autotrim_wires -xschem set disable_unique_names $disable_unique_names # font name can not be set here as we need to wait for X-initialization # to complete. Done in xinit.c ### ### build Tk widgets ### -if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} { +if { ( $OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} { setup_toolbar # for hyperlink in about dialog eval font create Underline-Font [ font actual TkDefaultFont ] font configure Underline-Font -underline true -size 24 - . configure -cursor left_ptr - - set_old_tk_fonts - - if { [info exists tk_scaling] } {tk scaling $tk_scaling} + set_old_tk_fonts ;# for xschem compiled with old tcl-tk libs + if { [info exists tk_scaling] } {tk scaling $tk_scaling} ;# useful for 4k displays (set bigger widgets) set infowindow_text {} infowindow - #proc unknown {comm args} { puts "unknown command-> \<$comm\> $args" } - frame .menubar -relief raised -bd 2 - toolbar_toolbar - - menubutton .menubar.file -text "File" -menu .menubar.file.menu -padx 3 -pady 0 - menu .menubar.file.menu -tearoff 0 - menubutton .menubar.edit -text "Edit" -menu .menubar.edit.menu -padx 3 -pady 0 - menu .menubar.edit.menu -tearoff 0 - menubutton .menubar.option -text "Options" -menu .menubar.option.menu -padx 3 -pady 0 - menu .menubar.option.menu -tearoff 0 - menubutton .menubar.zoom -text "View" -menu .menubar.zoom.menu -padx 3 -pady 0 - menu .menubar.zoom.menu -tearoff 0 - menubutton .menubar.prop -text "Properties" -menu .menubar.prop.menu -padx 3 -pady 0 - menu .menubar.prop.menu -tearoff 0 - menubutton .menubar.layers -text "Layers" -menu .menubar.layers.menu -padx 3 -pady 0 \ - -background [lindex $colors 4] - menu .menubar.layers.menu -tearoff 0 - menubutton .menubar.tools -text "Tools" -menu .menubar.tools.menu -padx 3 -pady 0 - menu .menubar.tools.menu -tearoff 0 - menubutton .menubar.sym -text "Symbol" -menu .menubar.sym.menu -padx 3 -pady 0 - menu .menubar.sym.menu -tearoff 0 - menubutton .menubar.hilight -text "Highlight" -menu .menubar.hilight.menu -padx 3 -pady 0 - menu .menubar.hilight.menu -tearoff 0 - menubutton .menubar.simulation -text "Simulation" -menu .menubar.simulation.menu -padx 3 -pady 0 - menu .menubar.simulation.menu -tearoff 0 - menubutton .menubar.help -text "Help" -menu .menubar.help.menu -padx 3 -pady 0 - menu .menubar.help.menu -tearoff 0 - .menubar.help.menu add command -label "Help" -command "textwindow \"${XSCHEM_SHAREDIR}/xschem.help\" ro" \ - -accelerator {?} - .menubar.help.menu add command -label "Keys" -command "textwindow \"${XSCHEM_SHAREDIR}/keys.help\" ro" - .menubar.help.menu add command -label "About XSCHEM" -command "about" - - .menubar.file.menu add command -label "New Schematic" -accelerator Ctrl+N\ - -command { - xschem clear SCHEMATIC - } - # toolbar_create FileNew {xschem clear SCHEMATIC} "New Schematic" - .menubar.file.menu add command -label "New Symbol" -accelerator Ctrl+Shift+N \ - -command { - xschem clear SYMBOL - } - # toolbar_create FileNewSym {xschem clear SYMBOL} "New Symbol" - .menubar.file.menu add command -label "New empty Schematic window" -accelerator {Alt+N} \ - -command { - xschem new_window - } - .menubar.file.menu add command -label "New empty Symbol window" -accelerator {Alt+Shift+N} \ - -command { - xschem new_symbol_window - } - .menubar.file.menu add command -label "Open" -command "xschem load" -accelerator {Ctrl+O} - toolbar_create FileOpen "xschem load" "Open File" - .menubar.file.menu add command -label "Delete files" -command "xschem delete_files" -accelerator {Shift-D} - - menu .menubar.file.menu.recent -tearoff 0 - setup_recent_menu - .menubar.file.menu add cascade -label "Open Recent" -menu .menubar.file.menu.recent - - .menubar.file.menu add command -label "Open Most Recent" \ - -command {xschem load [lindex "$recentfile" 0]} -accelerator {Ctrl+Shift+O} - .menubar.file.menu add command -label "Save" -command "xschem save" -accelerator {Ctrl+S} - toolbar_create FileSave "xschem save" "Save File" - .menubar.file.menu add command -label "Merge" -command "xschem merge" -accelerator {Shift+B} - # toolbar_create FileMerge "xschem merge" "Merge File" - .menubar.file.menu add command -label "Reload" -accelerator {Alt+S} \ - -command { - if { [string compare [tk_messageBox -type okcancel -message {Are you sure you want to reload?}] ok]==0 } { - xschem reload - } - } - toolbar_create FileReload { - if { [string compare [tk_messageBox -type okcancel -message {Are you sure you want to reload?}] ok]==0 } { - xschem reload - } - } "Reload File" - .menubar.file.menu add command -label "Save as" -command "xschem saveas" -accelerator {Ctrl+Shift+S} - .menubar.file.menu add command -label "Save as symbol" \ - -command "xschem saveas {} SYMBOL" -accelerator {Ctrl+Alt+S} - # added svg, png 20171022 - .menubar.file.menu add command -label "PDF/PS Export" -command "xschem print pdf" -accelerator {*} - .menubar.file.menu add command -label "Hierarchical PDF/PS Export" -command "xschem hier_psprint" - .menubar.file.menu add command -label "PNG Export" -command "xschem print png" -accelerator {Ctrl+*} - .menubar.file.menu add command -label "SVG Export" -command "xschem print svg" -accelerator {Alt+*} - .menubar.file.menu add separator - .menubar.file.menu add command -label "Exit" -command {xschem exit} -accelerator {Ctrl+Q} - - .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} - } - .menubar.option.menu add checkbutton -label "Transparent SVG background" -variable transparent_svg \ - -command { - if { $transparent_svg==1 } {xschem set transparent_svg 1} else { xschem set transparent_svg 0} - } - .menubar.option.menu add checkbutton -label "Debug mode" -variable menu_debug_var \ - -command { - if { $menu_debug_var==1 } {xschem debug 1} else { xschem debug 0} - } - .menubar.option.menu add checkbutton -label "Enable stretch" -variable enable_stretch \ - -accelerator Y \ - -command { - if { $enable_stretch==1 } {xschem set enable_stretch 1} else { xschem set enable_stretch 0} - } - .menubar.option.menu add checkbutton -label "Show netlist win" -variable netlist_show \ - -accelerator {Shift+A} \ - -command { - if { $netlist_show==1 } {xschem set netlist_show 1} else { xschem set netlist_show 0} - } - .menubar.option.menu add checkbutton -label "Flat netlist" -variable flat_netlist \ - -accelerator : \ - -command { - if { $flat_netlist==1 } {xschem set flat_netlist 1} else { xschem set flat_netlist 0} - } - .menubar.option.menu add checkbutton -label "Split netlist" -variable split_files \ - -accelerator {} \ - -command { - if { $split_files==1 } {xschem set split_files 1} else { xschem set split_files 0} - } - .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} - } - .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" - if { [info exists tmp_bus_char] && [string length $tmp_bus_char] >=2} { - set bus_replacement_char $tmp_bus_char - } - } - .menubar.option.menu add checkbutton -label "Verilog 2001 netlist variant" -variable verilog_2001 - .menubar.option.menu add checkbutton -label "Draw grid" -variable draw_grid \ - -accelerator {%} \ - -command { - if { $draw_grid == 1} { xschem set draw_grid 1; xschem redraw} else { xschem set draw_grid 0; xschem redraw} - } - .menubar.option.menu add checkbutton -label "Variable grid point size" -variable big_grid_points \ - -command { - if { $big_grid_points == 1} { - xschem set big_grid_points 1 - xschem redraw - } else { - xschem set big_grid_points 0 - xschem redraw - } - } - .menubar.option.menu add checkbutton -label "Symbol text" -variable sym_txt \ - -accelerator {Ctrl+B} \ - -command { - if { $sym_txt == 1} { xschem set sym_txt 1; xschem redraw} else { xschem set sym_txt 0; xschem redraw} - } - .menubar.option.menu add checkbutton -label "Toggle variable line width" -variable change_lw \ - -accelerator {_} \ - -command { - if { $change_lw == 1} { xschem set change_lw 1} else { xschem set change_lw 0} - } - .menubar.option.menu add checkbutton -label "Increment Hilight Color" -variable incr_hilight \ - -command { - if { $incr_hilight == 1} { xschem set incr_hilight 1} else { xschem set incr_hilight 0} - } - - .menubar.option.menu add command -label "Set line width" \ - -command { - input_line "Enter linewidth (float):" "xschem line_width" - } - .menubar.option.menu add command -label "Set symbol width" \ - -command { - input_line "Enter Symbol width ($symbol_width)" "set symbol_width" $symbol_width - } - - .menubar.option.menu add separator - .menubar.option.menu add radiobutton -label "Spice netlist" -variable netlist_type -value spice \ - -accelerator {Shift+V} \ - -command "xschem netlist_type spice" - .menubar.option.menu add radiobutton -label "VHDL netlist" -variable netlist_type -value vhdl \ - -accelerator {Shift+V} \ - -command "xschem netlist_type vhdl" - .menubar.option.menu add radiobutton -label "Verilog netlist" -variable netlist_type -value verilog \ - -accelerator {Shift+V} \ - -command "xschem netlist_type verilog" - .menubar.option.menu add radiobutton -label "tEDAx netlist" -variable netlist_type -value tedax \ - -accelerator {Shift+V} \ - -command "xschem netlist_type tedax" - .menubar.option.menu add radiobutton -label "Symbol global attrs" -variable netlist_type -value symbol \ - -accelerator {Shift+V} \ - -command "xschem netlist_type symbol" - .menubar.edit.menu add command -label "Undo" -command "xschem undo; xschem redraw" -accelerator U - toolbar_create EditUndo "xschem undo; xschem redraw" "Undo" - .menubar.edit.menu add command -label "Redo" -command "xschem redo; xschem redraw" -accelerator {Shift+U} - toolbar_create EditRedo "xschem redo; xschem redraw" "Redo" - toolbar_create EditCut "xschem cut" "Cut" - .menubar.edit.menu add command -label "Copy" -command "xschem copy" -accelerator Ctrl+C - toolbar_create EditCopy "xschem copy" "Copy" - .menubar.edit.menu add command -label "Cut" -command "xschem cut" -accelerator Ctrl+X - .menubar.edit.menu add command -label "Paste" -command "xschem paste" -accelerator Ctrl+V - toolbar_create EditPaste "xschem paste" "Paste" - .menubar.edit.menu add command -label "Delete" -command "xschem delete" -accelerator Del - toolbar_create EditDelete "xschem delete" "Delete" - .menubar.edit.menu add command -label "Select all" -command "xschem select_all" -accelerator Ctrl+A - .menubar.edit.menu add command -label "Edit selected schematic in new window" \ - -command "xschem schematic_in_new_window" -accelerator Alt+E - .menubar.edit.menu add command -label "Edit selected symbol in new window" \ - -command "xschem symbol_in_new_window" -accelerator Alt+I - .menubar.edit.menu add command -label "Duplicate objects" -command "xschem copy_objects" -accelerator C - toolbar_create EditDuplicate "xschem copy_objects" "Duplicate objects" - .menubar.edit.menu add command -label "Move objects" -command "xschem move_objects" -accelerator M - toolbar_create EditMove "xschem move_objects" "Move objects" - .menubar.edit.menu add command -label "Flip selected objects" -command "xschem flip" -accelerator {Alt-F} - .menubar.edit.menu add command -label "Rotate selected objects" -command "xschem rotate" -accelerator {Alt-R} - .menubar.edit.menu add radiobutton -label "Unconstrained move" -variable constrained_move \ - -value 0 -command {xschem set constrained_move 0} - .menubar.edit.menu add radiobutton -label "Constrained Horizontal move" -variable constrained_move \ - -value 1 -accelerator H -command {xschem set constrained_move 1} - .menubar.edit.menu add radiobutton -label "Constrained Vertical move" -variable constrained_move \ - -value 2 -accelerator V -command {xschem set constrained_move 2} - .menubar.edit.menu add command -label "Push schematic" -command "xschem descend" -accelerator E - toolbar_create EditPushSch "xschem descend" "Push schematic" - .menubar.edit.menu add command -label "Push symbol" -command "xschem descend_symbol" -accelerator I - toolbar_create EditPushSym "xschem descend_symbol" "Push symbol" - .menubar.edit.menu add command -label "Pop" -command "xschem go_back" -accelerator Ctrl+E - toolbar_create EditPop "xschem go_back" "Pop" - button .menubar.waves -text "Waves" -activebackground red -takefocus 0 -padx 2 -pady 0 \ - -command { - waves - } - button .menubar.simulate -text "Simulate" -activebackground red -takefocus 0 -padx 2 -pady 0 \ - -command { - if { ![info exists simulate_oldbg] } { - set simulate_oldbg [.menubar.simulate cget -bg] - .menubar.simulate configure -bg red - simulate {.menubar.simulate configure -bg $::simulate_oldbg; unset ::simulate_oldbg} - } - } - button .menubar.netlist -text "Netlist" -activebackground red -takefocus 0 -padx 2 -pady 0 \ - -command { - xschem netlist - } - # create .menubar.layers.menu - create_layers_menu - .menubar.zoom.menu add checkbutton -label "Show ERC Info window" -variable show_infowindow \ - -command { - if { $show_infowindow != 0 } {wm deiconify .infotext - } else {wm withdraw .infotext} - } - .menubar.zoom.menu add command -label "Redraw" -command "xschem redraw" -accelerator Esc - toolbar_create ViewRedraw "xschem redraw" "Redraw" - .menubar.zoom.menu add checkbutton -label "Fullscreen" -variable fullscreen \ - -accelerator {Alt+Shift+F} -command { - xschem fullscreen - } - .menubar.zoom.menu add command -label "Zoom Full" -command "xschem zoom_full" -accelerator F - .menubar.zoom.menu add command -label "Zoom In" -command "xschem zoom_in" -accelerator Shift+Z - toolbar_create ViewZoomIn "xschem zoom_in" "Zoom In" - .menubar.zoom.menu add command -label "Zoom Out" -command "xschem zoom_out" -accelerator Ctrl+Z - toolbar_create ViewZoomOut "xschem zoom_out" "Zoom Out" - .menubar.zoom.menu add command -label "Zoom box" -command "xschem zoom_box" -accelerator Z - toolbar_create ViewZoomBox "xschem zoom_box" "Zoom Box" - .menubar.zoom.menu add command -label "Half Snap Threshold" -accelerator G -command { - xschem set cadsnap [expr {[xschem get cadsnap] / 2.0} ] - } - .menubar.zoom.menu add command -label "Double Snap Threshold" -accelerator Shift-G -command { - xschem set cadsnap [expr {[xschem get cadsnap] * 2.0} ] - } - .menubar.zoom.menu add command -label "Set snap value" \ - -command { - input_line "Enter snap value ( default: [xschem get cadsnap_default] current: [xschem get cadsnap])" \ - "xschem set cadsnap" [xschem get cadsnap] - } - .menubar.zoom.menu add command -label "Set grid spacing" \ - -command { - input_line "Enter grid spacing (float):" "xschem set cadgrid" $cadgrid - } - .menubar.zoom.menu add checkbutton -label "View only Probes" -variable only_probes \ - -accelerator {5} \ - -command { xschem only_probes } - .menubar.zoom.menu add command -label "Toggle colorscheme" -accelerator {Shift+O} -command { - xschem toggle_colorscheme - xschem change_colors - } - toolbar_create ViewToggleColors { - xschem toggle_colorscheme - xschem change_colors - } "Toggle Color Scheme" - .menubar.zoom.menu add command -label "Dim colors" -accelerator {} -command { - color_dim - xschem color_dim - } - .menubar.zoom.menu add command -label "Visible layers" -accelerator {} -command { - select_layers - xschem redraw - } - .menubar.zoom.menu add command -label "Change Current Layer color" -accelerator {} -command { - change_color - } - .menubar.zoom.menu add checkbutton -label "No XCopyArea drawing model" -variable draw_window \ - -accelerator {Ctrl+$} \ - -command { - if { $draw_window == 1} { xschem set draw_window 1} else { xschem set draw_window 0} - } - .menubar.zoom.menu add checkbutton -label "Show net names on symbol pins" -variable show_pin_net_names \ - -command { - xschem set show_pin_net_names $show_pin_net_names - xschem redraw - } - .menubar.zoom.menu add checkbutton -label "Show Toolbar" -variable toolbar_visible \ - -command { - if { $toolbar_visible } { toolbar_show } else { toolbar_hide } - } - .menubar.zoom.menu add checkbutton -label "Horizontal Toolbar" -variable toolbar_horiz \ - -command { - if { $toolbar_visible } { - toolbar_hide - toolbar_show - } - } - .menubar.prop.menu add command -label "Edit" -command "xschem edit_prop" -accelerator Q - .menubar.prop.menu add command -label "Edit with editor" -command "xschem edit_vi_prop" -accelerator Shift+Q - .menubar.prop.menu add command -label "View" -command "xschem view_prop" -accelerator Ctrl+Shift+Q - .menubar.prop.menu add command -background red -label "Edit file (danger!)" \ - -command "xschem edit_file" -accelerator Alt+Q - .menubar.sym.menu add radiobutton -label "Show Symbols" -variable hide_symbols -value 0 \ - -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B - .menubar.sym.menu add radiobutton -label "Show instance Bounding boxes for subcircuit symbols" \ - -variable hide_symbols -value 1 \ - -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B - .menubar.sym.menu add radiobutton -label "Show instance Bounding boxes for all symbols" \ - -variable hide_symbols -value 2 \ - -command {xschem set hide_symbols $hide_symbols; xschem redraw} -accelerator Alt+B - .menubar.sym.menu add command -label "Make symbol from schematic" -command "xschem make_symbol" -accelerator A - .menubar.sym.menu add command -label "Make schematic from symbol" -command "xschem make_sch" -accelerator Ctrl+L - .menubar.sym.menu add command -label "Make schematic and symbol from selected components" -command "xschem make_sch_from_sel" -accelerator Ctrl+Shift+H - .menubar.sym.menu add command -label "Attach pins to component instance" \ - -command "xschem attach_pins" -accelerator Shift+H - .menubar.sym.menu add command -label "Create symbol pins from selected schematic pins" \ - -command "schpins_to_sympins" -accelerator Alt+H - .menubar.sym.menu add command -label "Place symbol pin" \ - -command "xschem add_symbol_pin" -accelerator Alt+P - .menubar.sym.menu add command -label "Print list of highlight nets" \ - -command "xschem print_hilight_net 1" -accelerator J - .menubar.sym.menu add command -label "Print list of highlight nets, with buses expanded" \ - -command "xschem print_hilight_net 3" -accelerator Alt-Ctrl-J - .menubar.sym.menu add command -label "Create labels from highlight nets" \ - -command "xschem print_hilight_net 4" -accelerator Alt-J - .menubar.sym.menu add command -label "Create labels from highlight nets with 'i' prefix" \ - -command "xschem print_hilight_net 2" -accelerator Alt-Shift-J - .menubar.sym.menu add command -label "Create pins from highlight nets" \ - -command "xschem print_hilight_net 0" -accelerator Ctrl-J - .menubar.sym.menu add checkbutton -label "Allow duplicated instance names (refdes)" \ - -variable disable_unique_names -command { - xschem set disable_unique_names $disable_unique_names - } - .menubar.tools.menu add checkbutton -label "Remember last command" -variable persistent_command \ - -command {xschem set persistent_command $persistent_command} - .menubar.tools.menu add command -label "Insert symbol" -command "xschem place_symbol" -accelerator {Ins, Shift-I} - toolbar_create ToolInsertSymbol "xschem place_symbol" "Insert Symbol" - .menubar.tools.menu add command -label "Insert wire label" -command "xschem net_label 1" -accelerator {Alt-L} - .menubar.tools.menu add command -label "Insert wire label 2" -command "xschem net_label 0" \ - -accelerator {Alt-Shift-L} - .menubar.tools.menu add command -label "Insert text" -command "xschem place_text" -accelerator T - toolbar_create ToolInsertText "xschem place_text" "Insert Text" - .menubar.tools.menu add command -label "Insert wire" -command "xschem wire" -accelerator W - toolbar_create ToolInsertWire "xschem wire" "Insert Wire" - .menubar.tools.menu add command -label "Insert snap wire" -command "xschem snap_wire" -accelerator Shift+W - .menubar.tools.menu add command -label "Insert line" -command "xschem line" -accelerator L - toolbar_create ToolInsertLine "xschem line" "Insert Line" - .menubar.tools.menu add command -label "Insert rect" -command "xschem rect" -accelerator R - toolbar_create ToolInsertRect "xschem rect" "Insert Rectangle" - .menubar.tools.menu add command -label "Insert polygon" -command "xschem polygon" -accelerator Ctrl+W - toolbar_create ToolInsertPolygon "xschem polygon" "Insert Polygon" - .menubar.tools.menu add command -label "Insert arc" -command "xschem arc" -accelerator Shift+C - toolbar_create ToolInsertArc "xschem arc" "Insert Arc" - .menubar.tools.menu add command -label "Insert circle" -command "xschem circle" -accelerator Ctrl+Shift+C - toolbar_create ToolInsertCircle "xschem circle" "Insert Circle" - .menubar.tools.menu add command -label "Search" -accelerator Ctrl+F -command property_search - toolbar_create ToolSearch property_search "Search" - .menubar.tools.menu add command -label "Align to Grid" -accelerator Alt+U -command "xschem align" - .menubar.tools.menu add command -label "Execute TCL command" -command "tclcmd" - .menubar.tools.menu add command -label "Join/Trim wires" \ - -command "xschem trim_wires" -accelerator {&} - toolbar_create ToolJoinTrim "xschem trim_wires" "Join/Trim Wires" - .menubar.tools.menu add command -label "Break wires at selected instance pins" \ - -command "xschem break_wires" -accelerator {!} - toolbar_create ToolBreak "xschem break_wires" "Break wires at selected\ninstance pin intersections" - .menubar.tools.menu add checkbutton -label "Auto Join/Trim Wires" -variable autotrim_wires \ - -command { - xschem set autotrim_wires $autotrim_wires - if {$autotrim_wires == 1} { - xschem trim_wires - xschem redraw - } - } - .menubar.tools.menu add command -label "Select all connected wires/labels/pins" -accelerator {Shift-Right Butt.} \ - -command { xschem connected_nets} - .menubar.tools.menu add command -label "Select conn. wires, stop at junctions" -accelerator {Ctrl-Righ Butt.} \ - -command { xschem connected_nets 1 } - - .menubar.hilight.menu add command -label {Highlight net-pin name mismatches on selected instancs} \ - -command "xschem net_pin_mismatch" \ - -accelerator {Shift-X} - .menubar.hilight.menu add command -label {Highlight duplicate instance names} \ - -command "xschem check_unique_names 0" -accelerator {#} - .menubar.hilight.menu add command -label {Rename duplicate instance names} \ - -command "xschem check_unique_names 1" -accelerator {Ctrl+#} - .menubar.hilight.menu add command -label {Propagate Highlight selected net/pins} \ - -command "xschem hilight drill" -accelerator {Ctrl+Shift+K} - .menubar.hilight.menu add command -label {Highlight selected net/pins} \ - -command "xschem hilight" -accelerator K - .menubar.hilight.menu add command -label {Send selected net/pins to Viewer} \ - -command "xschem send_to_viewer" -accelerator Alt+G - .menubar.hilight.menu add command -label {Select hilight nets / pins} -command "xschem select_hilight_net" \ - -accelerator Alt+K - .menubar.hilight.menu add command -label {Un-highlight all net/pins} \ - -command "xschem unhilight_all" -accelerator Shift+K - .menubar.hilight.menu add command -label {Un-highlight selected net/pins} \ - -command "xschem unhilight" -accelerator Ctrl+K - # 20160413 - .menubar.hilight.menu add checkbutton -label {Auto-highlight net/pins} -variable auto_hilight \ - -command { - if { $auto_hilight == 1} { - xschem set auto_hilight 1 - } else { - xschem set auto_hilight 0 - } - } - .menubar.hilight.menu add checkbutton -label {Enable highlight connected instances} \ - -variable en_hilight_conn_inst -command {xschem set en_hilight_conn_inst $en_hilight_conn_inst} - - .menubar.simulation.menu add command -label "Set netlist Dir" \ - -command { - select_netlist_dir 1 - } - .menubar.simulation.menu add command -label "Set top level netlist name" \ - -command { - input_line {Set netlist file name} {xschem set netlist_name} [xschem get netlist_name] 40 - } - .menubar.simulation.menu add checkbutton -label "Use 'simulation' dir under current schematic dir" \ - -variable local_netlist_dir \ - -command { if {$local_netlist_dir == 0 } { select_netlist_dir 1 } else { simuldir} } - .menubar.simulation.menu add command -label {Configure simulators and tools} -command {simconf} - .menubar.simulation.menu add command -label {Utile Stimuli Editor (GUI)} \ - -command {utile_gui [file tail [xschem get schname]]} - .menubar.simulation.menu add command -label "Utile Stimuli Editor ([lindex $editor 0])" \ - -command {utile_edit [file tail [xschem get schname]]} - .menubar.simulation.menu add command -label {Utile Stimuli Translate} \ - -command {utile_translate [file tail [xschem get schname]]} - .menubar.simulation.menu add command -label {Shell [simulation path]} \ - -command { - if { [select_netlist_dir 0] ne "" } { - get_shell $netlist_dir - } - } - .menubar.simulation.menu add command -label {Edit Netlist} \ - -command {edit_netlist [file tail [xschem get schname]]} - .menubar.simulation.menu add command -label {Send highlighted nets to viewer} \ - -command {xschem create_plot_cmd} -accelerator Shift+J - .menubar.simulation.menu add separator - .menubar.simulation.menu add checkbutton -label "LVS netlist: Top level is a .subckt" -variable top_subckt - .menubar.simulation.menu add checkbutton -label "Use 'spiceprefix' attribute" -variable spiceprefix \ - -command {xschem set spiceprefix $spiceprefix; xschem save; xschem reload} - - toolbar_create Netlist { xschem netlist } "Create netlist" - toolbar_create Simulate { - if { ![info exists simulate_oldbg] } { - set simulate_oldbg [.menubar.simulate cget -bg] - .menubar.simulate configure -bg red - simulate {.menubar.simulate configure -bg $::simulate_oldbg; unset ::simulate_oldbg} - } - } "Run simulation" - toolbar_create Waves { waves } "View results" - - pack .menubar.file -side left - pack .menubar.edit -side left - pack .menubar.option -side left - pack .menubar.zoom -side left - pack .menubar.prop -side left - pack .menubar.layers -side left - pack .menubar.tools -side left - pack .menubar.sym -side left - pack .menubar.hilight -side left - pack .menubar.simulation -side left - pack .menubar.help -side right - pack .menubar.waves -side right - pack .menubar.simulate -side right - pack .menubar.netlist -side right - - frame .drw -background {} -takefocus 1 - - wm title . "xschem - " - wm iconname . "xschem - " - . configure -background {} - wm geometry . $initial_geometry - #wm maxsize . 1600 1200 - wm protocol . WM_DELETE_WINDOW {xschem exit} - focus .drw - - frame .statusbar - label .statusbar.1 -text "STATUS BAR 1" - label .statusbar.2 -text "SNAP:" - entry .statusbar.3 -textvariable cadsnap -relief sunken -bg white \ - -width 10 -foreground black -takefocus 0 - label .statusbar.4 -text "GRID:" - entry .statusbar.5 -textvariable cadgrid -relief sunken -bg white \ - -width 10 -foreground black -takefocus 0 - label .statusbar.6 -text "NETLIST MODE:" - entry .statusbar.7 -textvariable netlist_type -relief sunken -bg white \ - -width 8 -state disabled -disabledforeground black - label .statusbar.8 -activebackground red -text {} + build_widgets {} ## - ## building top windows (pack instructions) and event binding (bind instructions) done in proc build_windows + ## packing top windows (pack instructions) and event binding (bind instructions) done in proc pack_widgets ## executed by xinit.c after finalizing X initialization. This avoid potential race conditions ## like Configure or Expose events being generated before xschem being ready to handle them. ## @@ -4460,17 +4448,6 @@ if { $show_infowindow } { wm deiconify .infotext } # source all files listed in 'tcl_files' variable source_user_tcl_files -if { [info exists xschem_listen_port] && ($xschem_listen_port ne {}) } { - if {[catch {socket -server xschem_server $xschem_listen_port} err]} { - puts "problems listening to TCP port: $xschem_listen_port" - puts $err - } -} - -if { [info exists bespice_listen_port] && ($bespice_listen_port ne {}) } { - if {[catch {socket -server bespice_server $bespice_listen_port} err]} { - puts "problems listening to TCP port: $bespice_listen_port" - puts $err - } -} +# xschem listen and bespice listen +setup_tcp_ports diff --git a/src/xschemrc b/src/xschemrc index 4eda0eef..d7a2ff20 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -26,9 +26,17 @@ # /home/schippes/share/doc/xschem/rom8k #### For testing in build src directory -#### if unset following paths are set: +#### if unset following paths are set and maintained if existing: # +# ~/.xschem/xschem_library # ../xschem_library/devices +# ../xschem_library/examples +# ../xschem_library/ngspice +# ../xschem_library/logic +# ../xschem_library/xschem_simulator +# ../xschem_library/binto7seg +# ../xschem_library/pcb +# ../xschem_library/rom8k #### For testing after installation: uncomment following lines # set xschem_doc_dir [file dirname ${XSCHEM_SHAREDIR}]/doc/xschem diff --git a/xschem_library/examples/tesla.sch b/xschem_library/examples/tesla.sch index cdbb43bd..aa4b2a91 100644 --- a/xschem_library/examples/tesla.sch +++ b/xschem_library/examples/tesla.sch @@ -1,5 +1,6 @@ -v {xschem version=2.9.5_RC8 file_version=1.1} +v {xschem version=3.0.0 file_version=1.2 } G {} +K {} V {} S {} E {} @@ -104,16 +105,16 @@ value=".option SCALE=1e-6 PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 vvss vss 0 dc 0 .save all - +.save tran @q5[p] ** models are generally not free: you must download ** SPICE models for active devices and put them into the below ** referenced file in simulation directory. .include models_tesla.txt .temp 30 .tran 1n 1m uic -.meas tran iavg AVG i(vc) from=950u to=990u -.probe tran p(q1) i(d2) i(d1) i(d3) i(l1) i(l2) i(L3) -.meas tran pavg AVG p(q1) from=950u to=990u +.meas tran iavg AVG i(vvcc) from=950u to=990u +.probe tran p(q5) i(l1) i(l2) +.meas tran pavg AVG @q5[p] from=950u to=990u "} C {lab_pin.sym} 140 -640 0 0 {name=p1 lab=VCC} C {res.sym} 140 -580 0 1 {name=Rs m=1 value=1} diff --git a/xschem_library/ngspice/buck.sch b/xschem_library/ngspice/buck.sch index 53bc2401..9759f6e3 100644 --- a/xschem_library/ngspice/buck.sch +++ b/xschem_library/ngspice/buck.sch @@ -1,5 +1,6 @@ -v {xschem version=2.9.5 file_version=1.1} +v {xschem version=3.0.0 file_version=1.2 } G {} +K {} V {} S {} E {} @@ -70,4 +71,3 @@ C {launcher.sym} 90 -580 0 0 {name=h1 descr="Ctrl-click to go to Delorie's project page for info" url="http://www.delorie.com/electronics/spice-stuff"} -C {test5.sch} 1070 -290 0 0 {}