diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html
index d75c05ef..d600ee07 100644
--- a/doc/xschem_man/developer_info.html
+++ b/doc/xschem_man/developer_info.html
@@ -782,6 +782,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
build_date time and date this file was built.
cadlayers number of layers
case_insensitive case_insensitive symbol matching
+ change_lw change line width when zooming
color_ps color postscript flag
constr_mv color postscript flag
current_dirname directory name of current design
@@ -807,6 +808,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
lastsel number of selected objects
line_width get line width
lines (xschem get lines n) number of lines on layer 'n'
+ min_lw minimum line width
modified schematic is in modified state (needs a save)
netlist_name netlist name if set. If 'fallback' given get default name
netlist_type get current netlist type (spice/vhdl/verilog/tedax)
@@ -1503,6 +1505,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
- cadgrid set cad grid (default: 20)
- cadsnap set mouse snap (default: 10)
+ - change_lw allow change line width when zooming
- color_ps set color psoscript (1 or 0)
- crosshair_layer set layer for mouse crosshair
- constr_mv set constrained move (1=horiz, 2=vert, 0=none)
diff --git a/src/actions.c b/src/actions.c
index 8bc16de6..3d842954 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -2896,7 +2896,7 @@ void zoom_full(int dr, int sel, int flags, double shrink)
double bboxw, bboxh, schw, schh;
double cs = tclgetdoublevar("cadsnap");
if(flags & 1) {
- if(tclgetboolvar("change_lw")) {
+ if(xctx->change_lw) {
xctx->lw = 1.;
}
xctx->areax1 = -2*INT_LINE_W(xctx->lw);
diff --git a/src/callback.c b/src/callback.c
index e12e21bc..ae2869b3 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -3724,13 +3724,15 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
break;
case '_': /* toggle change line width */
- if(!tclgetboolvar("change_lw")) {
+ if(!xctx->change_lw) {
tcleval("alert_ { enabling change line width} {}");
tclsetvar("change_lw","1");
+ xctx->change_lw = 1;
}
else {
tcleval("alert_ { disabling change line width} {}");
tclsetvar("change_lw","0");
+ xctx->change_lw = 0;
}
break;
diff --git a/src/draw.c b/src/draw.c
index 0928b628..06946d1d 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -1345,7 +1345,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
width = INT_BUS_WIDTH(xctx->lw);
} else if(bus > 0.0) {
what = NOW;
- width = (int) (bus * xctx->mooz);
+ width = XLINEWIDTH(bus * xctx->mooz);
} else {
width = XLINEWIDTH(xctx->lw);
}
@@ -1424,9 +1424,9 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
if(dash) {
dash_arr[0] = dash_arr[1] = (char) dash;
XSetDashes(display, xctx->gc[c], 0, dash_arr, 1);
- XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, xCap, xJoin);
+ XSetLineAttributes (display, xctx->gc[c], width, xDashType, xCap, xJoin);
} else {
- XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, LINECAP, LINEJOIN);
+ XSetLineAttributes (display, xctx->gc[c], width, LineSolid, LINECAP, LINEJOIN);
}
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2);
if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2);
@@ -1748,7 +1748,7 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
width = INT_BUS_WIDTH(xctx->lw);
} else if(bus > 0.0) {
what = NOW;
- width = (int) (bus * xctx->mooz);
+ width = XLINEWIDTH(bus * xctx->mooz);
} else {
width = XLINEWIDTH(xctx->lw);
}
@@ -2103,7 +2103,7 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil
if(bus == -1.0) {
width = INT_BUS_WIDTH(xctx->lw);
} else if(bus > 0.0) {
- width = (int) (bus * xctx->mooz);
+ width = XLINEWIDTH(bus * xctx->mooz);
} else {
width = XLINEWIDTH(xctx->lw);
}
@@ -2237,7 +2237,7 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
width = INT_BUS_WIDTH(xctx->lw);
} else if(bus > 0.0) {
what = NOW;
- width = (int) (bus * xctx->mooz);
+ width = XLINEWIDTH(bus * xctx->mooz);
} else {
width = XLINEWIDTH(xctx->lw);
}
diff --git a/src/editprop.c b/src/editprop.c
index 9c357b54..52b3fb03 100644
--- a/src/editprop.c
+++ b/src/editprop.c
@@ -1048,9 +1048,11 @@ static int edit_rect_property(int x)
(char *) tclgetvar("tctx::retval"));
}
bus = xctx->rect[c][n].bus = get_attr_val(get_tok_value(xctx->rect[c][n].prop_ptr,"bus",0));
- if(bus > 0.0) width = bus / 2.0;
+
+ if(bus > 0.0) width = XLINEWIDTH(bus) / 2.0;
else width = INT_BUS_WIDTH(xctx->lw) / 2.0;
- if(oldbus / 2.0 > width) width = oldbus / 2.0;
+ if(oldbus / 2.0 > width) width = XLINEWIDTH(oldbus) / 2.0;
+
set_rect_flags(&xctx->rect[c][n]); /* set cached .flags bitmask from attributes */
set_rect_extraptr(0, &xctx->rect[c][n]);
@@ -1144,9 +1146,9 @@ static int edit_line_property(void)
}
bus = xctx->line[c][n].bus = get_attr_val(get_tok_value(xctx->line[c][n].prop_ptr,"bus",0));
- if(bus > 0.0) width = bus / 2.0;
+ if(bus > 0.0) width = XLINEWIDTH(bus) / 2.0;
else width = INT_BUS_WIDTH(xctx->lw) / 2.0;
- if(oldbus / 2.0 > width) width = oldbus / 2.0;
+ if(oldbus / 2.0 > width) width = XLINEWIDTH(oldbus) / 2.0;
dash = get_tok_value(xctx->line[c][n].prop_ptr,"dash",0);
if( strcmp(dash, "") ) {
@@ -1209,9 +1211,9 @@ static int edit_wire_property(void)
}
xctx->wire[k].bus = bus = get_attr_val(get_tok_value(xctx->wire[k].prop_ptr,"bus",0));
- if(bus > 0.0) width = bus / 2.0;
- else width = INT_BUS_WIDTH(xctx->lw / 2.0);
- if(oldbus / 2.0 > width) width = oldbus / 2.0;
+ if(bus > 0.0) width = XLINEWIDTH(bus) / 2.0;
+ else width = INT_BUS_WIDTH(xctx->lw) / 2.0;
+ if(oldbus / 2.0 > width) width = XLINEWIDTH(oldbus) / 2.0;
ov = width > xctx->cadhalfdotsize ? width : xctx->cadhalfdotsize;
if(xctx->wire[k].y1 < xctx->wire[k].y2) { y1 = xctx->wire[k].y1-ov; y2 = xctx->wire[k].y2+ov; }
@@ -1280,9 +1282,9 @@ static int edit_arc_property(void)
xctx->arc[c][i].dash = 0;
bus = xctx->arc[c][i].bus = get_attr_val(get_tok_value(xctx->arc[c][i].prop_ptr,"bus",0));
- if(bus > 0.0) width = bus / 2.0;
+ if(bus > 0.0) width = XLINEWIDTH(bus) / 2.0;
else width = INT_BUS_WIDTH(xctx->lw) / 2.0;
- if(oldbus / 2.0 > width) width = oldbus / 2.0;
+ if(oldbus / 2.0 > width) width = XLINEWIDTH(oldbus) / 2.0;
if(oldbus != bus || old_fill != xctx->arc[c][i].fill || old_dash != xctx->arc[c][i].dash) {
if(!drw) {
@@ -1349,10 +1351,9 @@ static int edit_polygon_property(void)
bezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr,"bezier",0),"true") ;
xctx->poly[c][i].bus = bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0));
- if(bus > 0.0) width = bus / 2.0;
- else width = xctx->cadhalfdotsize > INT_BUS_WIDTH(xctx->lw) / 2.0 ?
- xctx->cadhalfdotsize : INT_BUS_WIDTH(xctx->lw) / 2.0;
- if(oldbus / 2.0 > width) width = oldbus / 2.0;
+ if(bus > 0.0) width = XLINEWIDTH(bus) / 2.0;
+ else width = MAJOR(INT_BUS_WIDTH(xctx->lw) / 2.0, xctx->cadhalfdotsize);
+ if(oldbus / 2.0 > width) width = XLINEWIDTH(oldbus) / 2.0;
fill_ptr = get_tok_value(xctx->poly[c][i].prop_ptr,"fill",0);
if( !strcmp(fill_ptr,"full") )
diff --git a/src/scheduler.c b/src/scheduler.c
index aee402a9..a2ea5d6e 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1420,6 +1420,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
Tcl_SetResult(interp, my_itoa(xctx->case_insensitive), TCL_VOLATILE);
}
+ else if(!strcmp(argv[2], "change_lw")) { /* change line width when zooming */
+ if(xctx->change_lw != 0 ) Tcl_SetResult(interp, "1",TCL_STATIC);
+ else Tcl_SetResult(interp, "0",TCL_STATIC);
+ }
else if(!strcmp(argv[2], "color_ps")) { /* color postscript flag */
if(color_ps != 0 ) Tcl_SetResult(interp, "1",TCL_STATIC);
else Tcl_SetResult(interp, "0",TCL_STATIC);
@@ -1555,6 +1559,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
break;
case 'm':
+ if(!strcmp(argv[2], "min_lw")) { /* minimum line width */
+ if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
+ Tcl_SetResult(interp, dtoa(xctx->min_lw),TCL_VOLATILE);
+ }
if(!strcmp(argv[2], "modified")) { /* schematic is in modified state (needs a save) */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
Tcl_SetResult(interp, my_itoa(xctx->modified),TCL_VOLATILE);
@@ -5422,6 +5430,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
change_linewidth(-1.);
draw();
}
+ else if(!strcmp(argv[2], "change_lw")) { /* allow change line width when zooming */
+ if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
+ xctx->change_lw = atoi(argv[3]);
+ tclsetboolvar("change_lw", xctx->change_lw);
+ }
else if(!strcmp(argv[2], "color_ps")) { /* set color psoscript (1 or 0) */
color_ps=atoi(argv[3]);
}
diff --git a/src/xinit.c b/src/xinit.c
index b4d26888..e300211a 100644
--- a/src/xinit.c
+++ b/src/xinit.c
@@ -716,6 +716,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->x_strcmp = strcmp;
xctx->fill_pattern = 1;
xctx->draw_window = 0;
+ xctx->change_lw = 1;
xctx->do_copy_area = 1;
xctx->time_last_modify = 0;
}
@@ -2147,7 +2148,7 @@ void change_linewidth(double w)
dbg(1, "change_linewidth(): w = %g, win_path=%s lw=%g\n", w, xctx->current_win_path, xctx->lw);
if(w<0. || xctx->lw == -1.0) {
double cs = tclgetdoublevar("cadsnap");
- if(tclgetboolvar("change_lw")) {
+ if(xctx->change_lw) {
xctx->lw=xctx->mooz * 0.09 * cs * (1.0 + MAJOR(xctx->min_lw, 1.0) / 4.0);
if(xctx->lw > 100.) xctx->lw = 100.;
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
@@ -2404,6 +2405,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
#endif
int i;
double l_width;
+ int change_lw;
struct stat buf;
int running_in_src_dir;
int fs;
@@ -2868,6 +2870,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
tclsetboolvar("color_ps", color_ps);
}
l_width=tclgetdoublevar("line_width");
+ change_lw=tclgetboolvar("change_lw");
cadlayers=tclgetintvar("cadlayers");
fix_broken_tiled_fill = tclgetboolvar("fix_broken_tiled_fill");
fix_mouse_coord = tclgetboolvar("fix_mouse_coord");
@@ -3021,7 +3024,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
tclsetvar("has_cairo","1");
#endif
xctx->min_lw = (int)l_width;
- if(tclgetboolvar("change_lw")) l_width = -1.0;
+ xctx->change_lw = change_lw;
+ if(xctx->change_lw) l_width = -1.0;
change_linewidth(l_width);
dbg(1, "Tcl_AppInit(): done xinit()\n");
/* Set backing store window attribute */
diff --git a/src/xschem.h b/src/xschem.h
index 65bcd4b9..21233d90 100644
--- a/src/xschem.h
+++ b/src/xschem.h
@@ -429,9 +429,13 @@ do { \
#define SWAP(a,b, tmp) do { tmp = a; a = b; b = tmp; } while(0)
-#define XLINEWIDTH(x) MAJOR((tclgetboolvar("change_lw") ? ((int)(x) == 0 ? 1 : (int)(x)) : (int)(x)), xctx->min_lw)
+#define XLINEWIDTH(x) MAJOR((xctx->change_lw ? \
+ ((int)(x) == 0 ? 1 : (int)(x)) : \
+ (int)(x)), xctx->min_lw)
#define INT_LINE_W(x) MAJOR(((int)(x) == 0 ? 1 : (int)(x)), xctx->min_lw)
-#define INT_BUS_WIDTH(x) ( (int)( (BUS_WIDTH) * (x) ) == 0 ? 1 : (int)( (BUS_WIDTH) * (x) ) )
+#define INT_BUS_WIDTH(x) MAJOR((xctx->change_lw ? \
+ ((int)( (BUS_WIDTH) * (x) ) == 0 ? 1 : (int)((BUS_WIDTH) * (x))) : \
+ (int)((BUS_WIDTH) * (x)) ), xctx->min_lw)
/* set do double if you need more precision at the expense of memory */
#define SPICE_DATA double
@@ -1167,6 +1171,7 @@ typedef struct {
int fill_pattern;
int draw_pixmap; /* pixmap used as 2nd buffer */
int draw_window; /* MIRRORED IN TCL */
+ int change_lw; /* cached valiue of TCL change_lw */
int do_copy_area;
double cadhalfdotsize;
time_t time_last_modify;
diff --git a/src/xschem.tcl b/src/xschem.tcl
index 0e4f5f53..5f1ebf94 100644
--- a/src/xschem.tcl
+++ b/src/xschem.tcl
@@ -10161,7 +10161,7 @@ proc build_widgets { {topwin {} } } {
}
$topwin.menubar.view add checkbutton -label "Toggle variable line width" -variable change_lw \
- -selectcolor $selectcolor -accelerator {_}
+ -selectcolor $selectcolor -accelerator {_} -command "xschem set change_lw $change_lw"
$topwin.menubar.view add command -label "Set line width" -accelerator {Alt+-} \
-command {
input_line "Enter linewidth (float):" "xschem line_width"