option for variable-width grid points for better visibility on hyper-resolution monitors

This commit is contained in:
Stefan Frederik 2020-12-12 13:36:39 +01:00
parent 00c1b47fdf
commit a3e1564c48
6 changed files with 70 additions and 19 deletions

View File

@ -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); */
}

View File

@ -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 */

View File

@ -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;

View File

@ -362,6 +362,8 @@ void free_xschem_data()
my_free(1133, &xctx->maxl);
my_free(1108, &xctx->sel_array);
for(i=0;i<CADMAXHIER;i++) my_free(1139, &xctx->sch_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);

View File

@ -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;

View File

@ -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 {