From a3e1564c485d52586cf9d8d338bbff97891b7434 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sat, 12 Dec 2020 13:36:39 +0100 Subject: [PATCH] option for variable-width grid points for better visibility on hyper-resolution monitors --- src/draw.c | 44 +++++++++++++++++++++++++++++++++++++------- src/globals.c | 2 +- src/scheduler.c | 9 +++++++++ src/xinit.c | 6 ++++-- src/xschem.h | 5 +++-- src/xschem.tcl | 23 ++++++++++++++++------- 6 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/draw.c b/src/draw.c index 49be772d..085aadfc 100644 --- a/src/draw.c +++ b/src/draw.c @@ -778,18 +778,48 @@ void drawgrid() { if(i>=CADMAXGRIDPOINTS) { - if(draw_window) XDrawPoints(display,xctx->window,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); - if(draw_pixmap) - XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); + if(draw_window) { + if(big_grid_points) { + XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i); + } else { + XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + } + } + if(draw_pixmap) { + if(big_grid_points) { + XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i); + } else { + XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + } + } i=0; } - gridpoint[i].x=(int)(x);gridpoint[i++].y=(int)(y); + if(big_grid_points) { + xctx->biggridpoint[i].x1 = xctx->biggridpoint[i].x2 = (short)(x); + xctx->biggridpoint[i].y1 = xctx->biggridpoint[i].y2 = (short)(y); + i++; + } else { + xctx->gridpoint[i].x=(int)(x); + xctx->gridpoint[i].y=(int)(y); + i++; + } } } - if(draw_window) XDrawPoints(display,xctx->window,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); - if(draw_pixmap) - XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],gridpoint,i,CoordModeOrigin); + if(draw_window) { + if(big_grid_points) { + XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i); + } else { + XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + } + } + if(draw_pixmap) { + if(big_grid_points) { + XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i); + } else { + XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + } + } /* debug ... */ /* XFlush(display); */ } diff --git a/src/globals.c b/src/globals.c index 9f2078f1..4fd19317 100644 --- a/src/globals.c +++ b/src/globals.c @@ -99,7 +99,6 @@ GC *gcstipple,*gc; Pixmap *pixmap = NULL; Display *display; Pixmap cad_icon_pixmap=0, cad_icon_mask=0; -XPoint *gridpoint; /* pointer to array of gridpoints, used in draw() */ XColor xcolor_array[256]; Visual *visual; #if HAS_XRENDER==1 @@ -129,6 +128,7 @@ int split_files=0; /* split netlist files 20081202 */ double cadgrid = CADGRID; double cadsnap = CADSNAP; int draw_grid=1; +int big_grid_points=0; int rainbow_colors=0; int dis_uniq_names=0; /* if set allow instances with duplicate names */ int persistent_command=0; /* remember last command 20181022 */ diff --git a/src/scheduler.c b/src/scheduler.c index 2064a911..49dc65e8 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -493,6 +493,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_snprintf(res, S(res), "%g %g %g %g", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2); Tcl_SetResult(interp, res, TCL_VOLATILE); } + else if(!strcmp(argv[2],"big_grid_points")) { + if( big_grid_points != 0 ) + Tcl_SetResult(interp, "1",TCL_STATIC); + else + Tcl_SetResult(interp, "0",TCL_STATIC); + } else if(!strcmp(argv[2],"cadlayers")) { char s[30]; /* overflow safe 20161212 */ my_snprintf(s, S(s), "%d",cadlayers); @@ -1958,6 +1964,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg draw(); Tcl_ResetResult(interp); } + else if(!strcmp(argv[2],"big_grid_points")) { + big_grid_points=atoi(argv[3]); + } else if(!strcmp(argv[2],"cairo_font_scale")) { double s = atof(argv[3]); if(s>0.1 && s<10.0) cairo_font_scale = s; diff --git a/src/xinit.c b/src/xinit.c index aae8d498..979d9d0a 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -362,6 +362,8 @@ void free_xschem_data() my_free(1133, &xctx->maxl); my_free(1108, &xctx->sel_array); for(i=0;isch_path[i]); + my_free(1099, &xctx->gridpoint); + my_free(1099, &xctx->biggridpoint); my_free(269, &xctx); } @@ -507,6 +509,8 @@ void alloc_xschem_data() xctx->lines=my_calloc(635, cadlayers, sizeof(int)); xctx->maxsel=MAXGROUP; xctx->sel_array=my_calloc(619, xctx->maxsel, sizeof(Selected)); + xctx->biggridpoint=(XSegment*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XSegment)); + xctx->gridpoint=(XPoint*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XPoint)); } void alloc_data() @@ -515,7 +519,6 @@ void alloc_data() alloc_xschem_data(); /* global context / graphic preferences/settings */ - gridpoint=(XPoint*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XPoint)); color_array=my_calloc(637, cadlayers, sizeof(char*)); gc=my_calloc(638, cadlayers, sizeof(GC)); gcstipple=my_calloc(639, cadlayers, sizeof(GC)); @@ -580,7 +583,6 @@ void xwin_exit(void) my_free(1121, &active_layer); my_free(1122, &pixdata); my_free(1123, &enable_layer); - my_free(1099, &gridpoint); my_free(1135, &gc); my_free(1136, &gcstipple); my_free(1137, &color_array); diff --git a/src/xschem.h b/src/xschem.h index 64529b89..1bc2b77b 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -584,7 +584,8 @@ typedef struct { /* select_rect */ double nl_xr, nl_yr, nl_xr2, nl_yr2; int nl_sel, nl_sem; - + XSegment *biggridpoint; + XPoint *gridpoint; } Xschem_ctx; @@ -698,6 +699,7 @@ extern int incr_hilight; extern int auto_hilight; extern int fill; /* fill rectangles */ extern int draw_grid; +extern int big_grid_points; extern int text_svg; extern double cadgrid; extern double cadhalfdotsize; @@ -773,7 +775,6 @@ extern unsigned char pixdata_init[22][32]; extern GC *gc, *gcstipple, gctiled; extern Display *display; extern XRectangle *rectangle; -extern XPoint *gridpoint; extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap; extern XColor xcolor_array[]; extern Visual *visual; diff --git a/src/xschem.tcl b/src/xschem.tcl index 8fc9dc03..824d6c81 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3422,6 +3422,7 @@ set_ne enable_stretch 0 set_ne horizontal_move 0 ; # 20171023 set_ne vertical_move 0 ; # 20171023 set_ne draw_grid 1 +set_ne big_grid_points 0 set_ne snap 10 set_ne grid 20 set_ne persistent_command 0 @@ -3733,13 +3734,22 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] 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 "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 { @@ -3763,10 +3773,6 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] -command { input_line "Enter Symbol width ($symbol_width)" "set symbol_width" $symbol_width } - .menubar.option.menu add checkbutton -label "Allow duplicated instance names (refdes)" \ - -variable disable_unique_names -command { - xschem set disable_unique_names $disable_unique_names - } .menubar.option.menu add separator .menubar.option.menu add radiobutton -label "Spice netlist" -variable netlist_type -value spice \ @@ -3952,7 +3958,10 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] -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 \ -accelerator {} \ -command {