From 77a6bd2bb88301d73b1828e1a68c17489eb2e23a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 9 Feb 2025 12:23:51 +0100 Subject: [PATCH 1/7] change order of last statements in hier_psprint() to avoid displaying garbage while moving crosshair cursor and ps->pdf conversion is in progres... --- src/spice_netlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 21d80d05..c341895a 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -133,9 +133,9 @@ void hier_psprint(char **res, int what) /* netlister driver */ xctx->prev_set_modify = save_prev_mod; my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); xctx->do_copy_area = save; - if(what & 1) ps_draw(4, 1, 0); /* trailer */ zoom_full(0, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); draw(); + if(what & 1) ps_draw(4, 1, 0); /* trailer */ } static char *model_name_result = NULL; /* safe even with multiple schematics */ From b5a25e5925665f64ac15058eeb85bd99d21a9683 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 9 Feb 2025 13:48:39 +0100 Subject: [PATCH 2/7] fix update not working in proc cellview --- src/xschem.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index 9b0a145c..43bcd714 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1986,7 +1986,7 @@ proc cellview { {derived_symbols {}} {upd 0} } { if {$upd} {return} frame .cv.bottom - button .cv.bottom.update -text Update -command "cellview $derived_symbols 1" + button .cv.bottom.update -text Update -command "cellview [list $derived_symbols] 1" pack .cv.bottom.update -side left label .cv.bottom.status -text {STATUS LINE} pack .cv.bottom.status -fill x -expand yes From 8bd9c3d93935c7318ec8721a56ece19e7fd4283c Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 9 Feb 2025 15:27:55 +0100 Subject: [PATCH 3/7] fix bitrots in proc cellview (Update function) --- src/xschem.tcl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index 43bcd714..e2fe4ec5 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1799,6 +1799,8 @@ proc cellview_setlabels {w symbol derived_symbol} { if { $sym_spice_sym_def eq {}} { if { ![file exists [abs_sym_path [$w get]]] } { $w configure -bg $missingbg + } elseif {$new_sch ne $default_sch } { + $w configure -bg $symbg } } puts =============== @@ -1814,7 +1816,7 @@ proc cellview_setlabels {w symbol derived_symbol} { xschem set schsymbolprop $newprop xschem set_modify 3 ;# set only modified flag to force a save, do not update window/tab titles xschem save fast - xschem remove_symbols ;# purge all symbols to force a reload from disk + # xschem remove_symbols ;# purge all symbols to force a reload from disk xschem load -keep_symbols -nodraw -noundoreset $current xschem netlist -keep_symbols -noalert;# traverse the hierarchy and retain all encountered symbols puts "get netlist" @@ -1834,7 +1836,6 @@ proc cellview_edit_item {symbol w} { } elseif { $sym_spice_sym_def eq {}} { xschem load_new_window [$w get] } else { - puts $symbol set current [xschem get current_name] set old_sym_def [xschem getprop symbol $symbol spice_sym_def 2] set new_sym_def [editdata $sym_spice_sym_def {Symbol spice_sym_def attribute}] @@ -1906,15 +1907,17 @@ proc cellview { {derived_symbols {}} {upd 0} } { } set syms [join [lsort -index 1 [xschem symbols $derived_symbols]]] + # puts "syms=$syms" foreach {i symbol} $syms { if { [catch {set base_name [xschem symbol_base_name $symbol]}] } { set base_name $symbol } + # puts "i=$i, symbol=$symbol" set derived_symbol 0 if {$base_name ne {}} { set derived_symbol 1 } - if { [catch {set abs_sch [xschem get_sch_from_sym -1 $symbol]} ]} { + if { [catch {xschem get_sch_from_sym -1 $symbol} abs_sch ]} { set abs_sch [abs_sym_path [add_ext $symbol .sch]] } if {$derived_symbol} { @@ -1931,6 +1934,9 @@ proc cellview { {derived_symbols {}} {upd 0} } { } if {$skip} { continue } set sym_sch [rel_sym_path $abs_sch] + if {[catch {xschem getprop symbol $symbol type} type]} { + puts "error: $symbol not found: $type" + } set type [xschem getprop symbol $symbol type] set sym_spice_sym_def [xschem getprop symbol $symbol spice_sym_def 2] if {$type eq {subcircuit}} { From a50b3681c895b7a767b9175f46a6e689e4f2d14e Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 9 Feb 2025 19:44:40 +0100 Subject: [PATCH 4/7] calc_drawing_bbox(): initialize xctx->show_hidden_texts before calculating bbox. --- src/actions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/actions.c b/src/actions.c index 99d2710a..b7a0b00d 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2592,6 +2592,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) #endif char *estr = NULL; + xctx->show_hidden_texts = tclgetboolvar("show_hidden_texts"); boundbox->x1=-100; boundbox->x2=100; boundbox->y1=-100; From 5e3c27d7eebb8a486e651d221f10d36cd11ebd59 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 9 Feb 2025 20:52:15 +0100 Subject: [PATCH 5/7] load_schematic(): ability to load / preview a generator (adds () to filename) --- src/save.c | 56 ++++++++++++++++++++++++++++++-------------------- src/xschem.tcl | 2 +- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/save.c b/src/save.c index 28f135cc..05638341 100644 --- a/src/save.c +++ b/src/save.c @@ -3446,6 +3446,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler { FILE *fd; char name[PATH_MAX]; + char *ffname = NULL; /*copy of fname so I can change it */ char msg[PATH_MAX+100]; struct stat buf; int i, ret = 1; /* success */ @@ -3454,24 +3455,31 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler xctx->prep_net_structs=0; xctx->prep_hash_inst=0; xctx->prep_hash_wires=0; + my_strdup2(_ALLOC_ID_, &ffname, trim_chars(fname, " \t\n")); if(reset_undo) { xctx->clear_undo(); xctx->prev_set_modify = -1; /* will force set_modify(0) to set window title */ } else xctx->prev_set_modify = 0; /* will prevent set_modify(0) from setting window title */ - if(fname && fname[0]) { + if(ffname && ffname[0]) { int generator = 0; - if(is_generator(fname)) generator = 1; - my_strncpy(name, fname, S(name)); - dbg(1, "load_schematic(): fname=%s\n", fname); + /* if ffname is a generator add () at end of filename if not already present */ + tclvareval("is_xschem_file {", ffname, "}", NULL); + if(!strcmp(tclresult(), "GENERATOR")) { + size_t len = strlen(ffname); + if( ffname[len - 1] != ')') my_strcat(_ALLOC_ID_, &ffname, "()"); + } + if(is_generator(ffname)) generator = 1; + my_strncpy(name, ffname, S(name)); + dbg(1, "load_schematic(): name=%s generator=%d\n", name, generator); /* remote web object specified */ - if(is_from_web(fname) && xschem_web_dirname[0]) { + if(is_from_web(ffname) && xschem_web_dirname[0]) { /* download into ${XSCHEM_TMP_DIR}/xschem_web */ - tclvareval("download_url {", fname, "}", NULL); + tclvareval("download_url {", ffname, "}", NULL); /* build local file name of downloaded object */ - my_snprintf(name, S(name), "%s/%s", xschem_web_dirname, get_cell_w_ext(fname, 0)); + my_snprintf(name, S(name), "%s/%s", xschem_web_dirname, get_cell_w_ext(ffname, 0)); /* build current_dirname by stripping off last filename from url */ - my_snprintf(msg, S(msg), "get_directory {%s}", fname); + my_snprintf(msg, S(msg), "get_directory {%s}", ffname); my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname)); /* local file name */ my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], name); @@ -3482,29 +3490,32 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler /* ... but not local file from web download --> reset current_dirname */ char sympath[PATH_MAX]; my_snprintf(sympath, S(sympath), "%s", xschem_web_dirname); - /* fname does not begin with $XSCHEM_TMP_DIR/xschem_web and fname does not exist */ + /* ffname does not begin with $XSCHEM_TMP_DIR/xschem_web and ffname does not exist */ - if(strstr(fname, sympath) != fname /* && stat(fname, &buf)*/) { - my_snprintf(msg, S(msg), "get_directory {%s}", fname); + if(strstr(ffname, sympath) != ffname /* && stat(ffname, &buf)*/) { + my_snprintf(msg, S(msg), "get_directory {%s}", ffname); my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname)); } /* local file name */ - my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], fname); + my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], ffname); /* local relative reference */ - my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name)); + my_strncpy(xctx->current_name, rel_sym_path(ffname), S(xctx->current_name)); } else { /* local file specified and not coming from web url */ /* build current_dirname by stripping off last filename from url */ - my_snprintf(msg, S(msg), "get_directory {%s}", fname); + my_snprintf(msg, S(msg), "get_directory {%s}", ffname); my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname)); /* local file name */ - my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], fname); + my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], ffname); /* local relative reference */ - my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name)); + my_strncpy(xctx->current_name, rel_sym_path(ffname), S(xctx->current_name)); } - dbg(1, "load_schematic(): opening file for loading:%s, fname=%s\n", name, fname); + dbg(1, "load_schematic(): opening file for loading:%s, ffname=%s\n", name, ffname); dbg(1, "load_schematic(): sch[currsch]=%s\n", xctx->sch[xctx->currsch]); - if(!name[0]) return 0; /* empty filename */ + if(!name[0]) { + my_free(_ALLOC_ID_, &ffname); + return 0; /* empty filename */ + } if(reset_undo) { if(!stat(name, &buf)) { /* file exists */ xctx->time_last_modify = buf.st_mtime; @@ -3515,7 +3526,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler } else {xctx->time_last_modify = 0;} /* undefined */ if(generator) { char *cmd; - cmd = get_generator_command(fname); + cmd = get_generator_command(ffname); if(cmd) { fd = popen(cmd, "r"); my_free(_ALLOC_ID_, &cmd); @@ -3526,9 +3537,9 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler size_t len; ret = 0; if(alert) { - fprintf(errfp, "load_schematic(): unable to open file: %s, fname=%s\n", name, fname ); + fprintf(errfp, "load_schematic(): unable to open file: %s, ffname=%s\n", name, ffname ); if(has_x) { - my_snprintf(msg, S(msg), "update; alert_ {Unable to open file: %s}", fname); + my_snprintf(msg, S(msg), "update; alert_ {Unable to open file: %s}", ffname); tcleval(msg); } } @@ -3567,7 +3578,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler } } dbg(1, "load_schematic(): %s, returning\n", xctx->sch[xctx->currsch]); - } else { /* fname == NULL or empty */ + } else { /* ffname == NULL or empty */ /* if(reset_undo) xctx->time_last_modify = time(NULL); */ /* no file given, set mtime to current time */ if(reset_undo) xctx->time_last_modify = 0; /* no file given, set mtime to 0 (undefined) */ clear_drawing(); @@ -3602,6 +3613,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler set_netlist_dir(2, NULL); drc_check(-1); } + my_free(_ALLOC_ID_, &ffname); return ret; } diff --git a/src/xschem.tcl b/src/xschem.tcl index e2fe4ec5..1f1ae22b 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4253,7 +4253,7 @@ proc file_dialog_place_symbol {} { proc file_dialog_display_preview {f} { set type [is_xschem_file $f] - if { $type ne {0} && $type ne {GENERATOR} } { + if { $type ne {0} } { if { [winfo exists .load] } { .load.l.paneright.draw configure -background {} xschem preview_window draw .load.l.paneright.draw "$f" From 724869638e63a6398678d0394f82125e835183e1 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 10 Feb 2025 01:21:22 +0100 Subject: [PATCH 6/7] fix max size of graph bitmap calculation in svg_embedded_graph() and ps_embedded_graph() --- src/draw.c | 7 +++---- src/psprint.c | 6 +++--- src/xinit.c | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/draw.c b/src/draw.c index 34d7d8f7..ea1b9513 100644 --- a/src/draw.c +++ b/src/draw.c @@ -4777,7 +4777,7 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2, cairo_surface_t *png_sfc; int save, save_draw_window, save_draw_grid, rwi, rhi; size_t olength; - const double max_size = 3000.0; + const double max_size = 2500.0; if(!has_x) return; @@ -4792,9 +4792,9 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2, rw = fabs(rx2 -rx1); rh = fabs(ry2 - ry1); scale = 3.0; - if(rw > rh && rw > max_size) { + if(rw > rh && rw * scale > max_size) { scale = max_size / rw; - } else if(rh > max_size) { + } else if(rh * scale > max_size) { scale = max_size / rh; } rwi = (int) (rw * scale + 1.0); @@ -4882,7 +4882,6 @@ void draw(void) #endif dbg(1, "draw()\n"); - if(!xctx || xctx->no_draw) return; cs = tclgetdoublevar("cadsnap"); diff --git a/src/psprint.c b/src/psprint.c index 6ea4281a..3f2f46e7 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -257,7 +257,7 @@ static int ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, doubl double rw, rh, scale; cairo_surface_t* png_sfc; int save, save_draw_window, save_draw_grid, rwi, rhi; - const double max_size = 3000.0; + const double max_size = 2500.0; int d_c; unsigned char* jpgData = NULL; size_t fileSize = 0; @@ -292,10 +292,10 @@ static int ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, doubl rw = fabs(rx2 - rx1); rh = fabs(ry2 - ry1); scale = 3.0; - if (rw > rh && rw > max_size) { + if (rw > rh && rw * scale > max_size) { scale = max_size / rw; } - else if (rh > max_size) { + else if (rh * scale > max_size) { scale = max_size / rh; } rwi = (int)(rw * scale + 1.0); diff --git a/src/xinit.c b/src/xinit.c index b4cc86a0..0ee4bca2 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -2185,6 +2185,8 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h) #else XWindowAttributes wattr; #endif + dbg(1, "resetwin(): create=%d, clear=%d, force=%d, w=%d, h=%d\n", + create_pixmap, clear_pixmap, force, w, h); if(w && h) { width = w; height = h; From 3d972e8e42f917872ec3f75b2d99be0ca45c0365 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 10 Feb 2025 02:43:23 +0100 Subject: [PATCH 7/7] `AUTO SET` button in graph edit dialog box to automatically assign increasing colors to displayed waves --- src/xschem.tcl | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index 1f1ae22b..c9f1aadd 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -2961,6 +2961,14 @@ proc touches {sel tag} { return $res } +proc set_graph_default_colors {} { + global graph_selected graph_schname + if { [xschem get schname] ne $graph_schname } return + xschem setprop -fast rect 2 $graph_selected color "4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21" + graph_update_nodelist + xschem draw_graph $graph_selected +} + # change color of selected wave in text widget and redraw graph # OR # change color attribute of wave given as parameter, redraw graph @@ -3352,13 +3360,13 @@ proc graph_edit_properties {n} { grid columnconfig .graphdialog.center.right 5 -weight 0 # bottom frame - button .graphdialog.bottom.cancel -text Cancel -command { + button .graphdialog.bottom.cancel -padx 1 -borderwidth 1 -pady 0 -text Cancel -command { set graph_dialog_default_geometry [winfo geometry .graphdialog] destroy .graphdialog set graph_selected {} set graph_schname {} } - button .graphdialog.bottom.ok -text OK -command { + button .graphdialog.bottom.ok -padx 1 -borderwidth 1 -pady 0 -text OK -command { if { [xschem get schname] eq $graph_schname } { graph_push_undo graph_update_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"] @@ -3373,7 +3381,7 @@ proc graph_edit_properties {n} { set graph_selected {} set graph_schname {} } - button .graphdialog.bottom.apply -text Apply -command { + button .graphdialog.bottom.apply -padx 1 -borderwidth 1 -pady 0 -text Apply -command { if { [xschem get schname] eq $graph_schname } { graph_push_undo graph_update_node [string trim [.graphdialog.center.right.text1 get 1.0 {end - 1 chars}] " \n"] @@ -3390,9 +3398,16 @@ proc graph_edit_properties {n} { pack .graphdialog.bottom.apply -side left pack .graphdialog.bottom.cancel -side left - for {set i 4} {$i < $cadlayers} {incr i} { - radiobutton .graphdialog.bottom.r$i -value $i -background [lindex $tctx::colors $i] \ - -variable graph_sel_color -command graph_change_wave_color -selectcolor white -foreground black + for {set i 4} {$i <= $cadlayers} {incr i} { + if {$i == $cadlayers } { + button .graphdialog.bottom.r$i -padx 1 -borderwidth 1 -pady 0 \ + -command "set_graph_default_colors" \ + -text {AUTO SET} + } else { + radiobutton .graphdialog.bottom.r$i -value $i -background [lindex $tctx::colors $i] \ + -variable graph_sel_color -command graph_change_wave_color \ + -selectcolor white -foreground black + } pack .graphdialog.bottom.r$i -side left }