From 25db8b8f9acaaea05f04d72dc4482e5417bb1bbd Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 18 Feb 2025 02:25:55 +0100 Subject: [PATCH] ellipses rendered in ps/pdf export. Do not allow to select objects with mouse button press if a poligon insertion is ongoing. my_fopen() for read mode open, check for regular file. More checks for failed fopen()s. --- src/actions.c | 2 +- src/cairo_jpg.c | 4 +-- src/callback.c | 7 ++-- src/draw.c | 36 +++++++++---------- src/editprop.c | 27 ++++++++++---- src/hilight.c | 2 +- src/netlist.c | 3 +- src/options.c | 3 +- src/paste.c | 20 +++++------ src/psprint.c | 84 ++++++++++++++++++++++++++++++++++++++----- src/save.c | 61 +++++++++++++++---------------- src/scheduler.c | 2 +- src/select.c | 2 +- src/spice_netlist.c | 6 ++++ src/store.c | 18 +++++----- src/svgdraw.c | 12 +++---- src/verilog_netlist.c | 6 ++++ src/vhdl_netlist.c | 6 ++++ src/xinit.c | 8 ++--- src/xschem.h | 3 +- 20 files changed, 206 insertions(+), 106 deletions(-) diff --git a/src/actions.c b/src/actions.c index 59afb731..ba5bac99 100644 --- a/src/actions.c +++ b/src/actions.c @@ -45,7 +45,7 @@ unsigned int hash_file(const char *f, int skip_path_lines) int cr = 0; unsigned int h=5381; char *line = NULL; - fd = fopen(f, "r"); /* windows won't return \r in the lines and we chop them out anyway in the code */ + fd = my_fopen(f, "r"); /* windows won't return \r in the lines and we chop them out anyway in the code */ if(fd) { while((line = my_fgets(fd, &n))) { /* skip lines of type: '** sch_path: ...' or '-- sch_path: ...' or '// sym_path: ...' diff --git a/src/cairo_jpg.c b/src/cairo_jpg.c index 62bc20cf..5c8b3359 100644 --- a/src/cairo_jpg.c +++ b/src/cairo_jpg.c @@ -460,7 +460,7 @@ cairo_surface_t *cairo_image_surface_create_from_jpeg_stream(cairo_read_func_t r * @return Returns a pointer to a cairo_surface_t structure. It should be * checked with cairo_surface_status() for errors. * @note If the returned surface is invalid you can use errno to determine - * further reasons. Errno is set according to fopen(3) and malloc(3). If you + * further reasons. Errno is set according to my_fopen(3) and malloc(3). If you * intend to check errno you shall set it to 0 before calling this function * because it does not modify errno itself. */ @@ -520,7 +520,7 @@ static cairo_status_t cj_read(void *closure, unsigned char *data, unsigned int l * @return Returns a pointer to a cairo_surface_t structure. It should be * checked with cairo_surface_status() for errors. * @note If the returned surface is invalid you can use errno to determine - * further reasons. Errno is set according to fopen(3) and malloc(3). If you + * further reasons. Errno is set according to my_fopen(3) and malloc(3). If you * intend to check errno you shall set it to 0 before calling this function * because it does not modify errno itself. */ diff --git a/src/callback.c b/src/callback.c index 1853799d..374b4389 100644 --- a/src/callback.c +++ b/src/callback.c @@ -2763,12 +2763,12 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m { int x; xctx->fill_pattern++; - if(xctx->fill_pattern==3) xctx->fill_pattern=0; + if(xctx->fill_pattern==2) xctx->fill_pattern=0; if(xctx->fill_pattern==1) { tcleval("alert_ { Stippled pattern fill} {}"); for(x=0;xfill_type[x]==1) XSetFillStyle(display,xctx->gcstipple[x],FillSolid); + if(xctx->fill_type[x]==2) XSetFillStyle(display,xctx->gcstipple[x],FillSolid); else XSetFillStyle(display,xctx->gcstipple[x],FillStippled); } } @@ -4182,7 +4182,8 @@ static void handle_button_press(int event, int state, int rstate, KeySym key, in if(end_place_move_copy_zoom()) return; /* Button1Press to select objects */ - if( !(xctx->ui_state & STARTSELECT) && !(xctx->ui_state & STARTWIRE) && !(xctx->ui_state & STARTLINE) ) { + if( !(xctx->ui_state & STARTPOLYGON) && !(xctx->ui_state & STARTSELECT) && + !(xctx->ui_state & STARTWIRE) && !(xctx->ui_state & STARTLINE) ) { Selected sel; int already_selected = 0; int prev_last_sel = xctx->lastsel; diff --git a/src/draw.c b/src/draw.c index b8dd83b6..bee7b42b 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1591,9 +1591,9 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b, (int)(xx2-xx1), (int)(yy2-yy1), (int)(a*64), (int)(b*64)); } - if(xctx->fill_pattern && (xctx->fill_type[c] || arc_fill == 3) ){ + if(xctx->fill_pattern && (xctx->fill_type[c] || arc_fill == 2) ){ - if(arc_fill & 2) gc = xctx->gc[c]; + if(arc_fill == 2) gc = xctx->gc[c]; else gc = xctx->gcstipple[c]; if(arc_fill) { if(xctx->draw_window) @@ -1631,8 +1631,8 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl if(!has_x) return; if(!xctx->fill_pattern) return; - if(fill != 3 && !xctx->fill_type[c]) return; - if(fill == 3) { /* full fill */ + if(fill != 2 && !xctx->fill_type[c]) return; + if(fill == 2) { /* full fill */ gc = xctx->gc[c]; r = rf; i = &iif; @@ -1782,7 +1782,7 @@ void arc_bbox(double x, double y, double r, double a, double b, /* Convex Nonconvex Complex */ #define Polygontype Nonconvex -/* fill = 1: stippled fill, fill == 3: solid fill */ +/* fill = 1: stippled fill, fill == 2: solid fill */ void drawbezier(Drawable w, GC gc, int c, double *x, double *y, int points, int fill) { const double bez_steps = 1.0/32.0; /* divide the t = [0,1] interval into 32 steps */ @@ -1846,7 +1846,7 @@ void drawbezier(Drawable w, GC gc, int c, double *x, double *y, int points, int XDrawLines(display, w, gc, p, i, CoordModeOrigin); if(fill == 1) XFillPolygon(display, w, xctx->gcstipple[c], p, i, Polygontype, CoordModeOrigin); - else if(fill==3) + else if(fill==2) XFillPolygon(display, w, xctx->gc[c], p, i, Polygontype, CoordModeOrigin); } @@ -1882,7 +1882,7 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil for(i=0;ifill_pattern && ((xctx->fill_type[c] && poly_fill == 1) || poly_fill == 3 ) && + fill = xctx->fill_pattern && ((xctx->fill_type[c] && poly_fill == 1) || poly_fill == 2 ) && (x[0] == x[points-1]) && (y[0] == y[points-1]); bezier = (flags & 1) && (points > 2); if(dash) { @@ -1893,19 +1893,19 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil } if(xctx->draw_window) { if(bezier) { - drawbezier(xctx->window, xctx->gc[c], c, x, y, points, fill | (poly_fill & 2) ); + drawbezier(xctx->window, xctx->gc[c], c, x, y, points, fill ? poly_fill : 0 ); } else { XDrawLines(display, xctx->window, xctx->gc[c], p, points, CoordModeOrigin); } } if(xctx->draw_pixmap) { if(bezier) { - drawbezier(xctx->save_pixmap, xctx->gc[c], c, x, y, points, fill | (poly_fill & 2) ); + drawbezier(xctx->save_pixmap, xctx->gc[c], c, x, y, points, fill ? poly_fill : 0); } else { XDrawLines(display, xctx->save_pixmap, xctx->gc[c], p, points, CoordModeOrigin); } } - if(poly_fill & 2) gc = xctx->gc[c]; + if(poly_fill == 2) gc = xctx->gc[c]; else gc = xctx->gcstipple[c]; if(fill && !bezier) { if(xctx->draw_window) @@ -2836,9 +2836,9 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct) /* clipping everything outside container area */ /* background */ - filledrect(0, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 3, -1, -1); + filledrect(0, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 2, -1, -1); /* graph bounding box */ - drawrect(GRIDLAYER, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 2, -1, -1); + drawrect(GRIDLAYER, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 0, -1, -1); bbox(START, 0.0, 0.0, 0.0, 0.0); bbox(ADD, gr->rx1, gr->ry1, gr->rx2, gr->ry2); @@ -3133,7 +3133,7 @@ static void draw_cursor(double active_cursorx, double other_cursorx, int cursor_ else my_snprintf(tmpstr, S(tmpstr), "%s", dtoa_eng(active_cursorx)); text_bbox(tmpstr, txtsize, txtsize, 2, flip, 0, 0, xx + xoffs, gr->ry2-1, &tx1, &ty1, &tx2, &ty2, &tmp, &dtmp); - filledrect(0, NOW, tx1, ty1, tx2, ty2, 3, -1, -1); + filledrect(0, NOW, tx1, ty1, tx2, ty2, 2, -1, -1); draw_string(cursor_color, NOW, tmpstr, 2, flip, 0, 0, xx + xoffs, gr->ry2-1, txtsize, txtsize); } } @@ -3198,7 +3198,7 @@ static void draw_hcursor(double active_cursory, int cursor_color, Graph_ctx *gr) th = (ty2 - ty1) / 2.; /* half text height */ ty1 -= th; ty2 -= th; - filledrect(0, NOW, tx1, ty1, tx2, ty2, 3, -1, -1); + filledrect(0, NOW, tx1, ty1, tx2, ty2, 2, -1, -1); draw_string(cursor_color, NOW, tmpstr, 0, 0, 0, 0, gr->rx1 + 5, yy - th, txtsize, txtsize); } } @@ -3230,7 +3230,7 @@ static void draw_hcursor_difference(double c1, double c2, Graph_ctx *gr) my_snprintf(tmpstr, S(tmpstr), " %s ", dtoa_eng(diffh)); text_bbox(tmpstr, txtsize, txtsize, 0, 0, 0, 1, xx, yy, &tx1, &ty1, &tx2, &ty2, &tmp, &dtmp); if( 2 * (ty2 - ty1) < diff ) { - filledrect(0, NOW, tx1, ty1, tx2, ty2, 3, -1, -1); + filledrect(0, NOW, tx1, ty1, tx2, ty2, 2, -1, -1); draw_string(3, NOW, tmpstr, 0, 0, 0, 1, xx, yy, txtsize, txtsize); if( a > b) { dtmp = a; a = b; b = dtmp; @@ -4476,7 +4476,7 @@ static cairo_surface_t *get_surface_from_file(const char *filename, const char * } filesize = (size_t)buf.st_size; if(filesize > 0) { - fd = fopen(filename, fopen_read_mode); + fd = my_fopen(filename, fopen_read_mode); if(fd) { size_t bytes_read; filedata = my_malloc(_ALLOC_ID_, filesize); @@ -4990,7 +4990,7 @@ void draw(void) draw_symbol(ADD, cc, i,c, 0, 0, 0.0, 0.0); /* ... then draw current layer */ } } - filledrect(cc, END, 0.0, 0.0, 0.0, 0.0, 3, -1, -1); /* last parameter must be 3! */ + filledrect(cc, END, 0.0, 0.0, 0.0, 0.0, 2, -1, -1); /* fill parameter must be 2! */ drawarc(cc, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0); drawrect(cc, END, 0.0, 0.0, 0.0, 0.0, 0, -1, -1); drawline(cc, END, 0.0, 0.0, 0.0, 0.0, 0, NULL); @@ -5017,7 +5017,7 @@ void draw(void) xctx->wire[i].x2,xctx->wire[i].y2, 0, NULL); } update_conn_cues(cc, 1, xctx->draw_window); - filledrect(cc, END, 0.0, 0.0, 0.0, 0.0, 3, -1, -1); /* fill parameter must be 3! */ + filledrect(cc, END, 0.0, 0.0, 0.0, 0.0, 2, -1, -1); /* fill parameter must be 2! */ drawline(cc, END, 0.0, 0.0, 0.0, 0.0, 0, NULL); } if(xctx->draw_single_layer ==-1 || xctx->draw_single_layer==TEXTLAYER) { diff --git a/src/editprop.c b/src/editprop.c index 44a5d8e0..3a7f9323 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -586,6 +586,19 @@ char *dtoa_prec(double i) return s; } +FILE *my_fopen(const char *f, const char *m) +{ + struct stat buf; + FILE *fd = NULL; + int st; + + st = stat(f, &buf); + if(st) return NULL; /* not existing or error */ + if(!S_ISREG(buf.st_mode)) return NULL; /* not a regular file/symlink to a regular file */ + fd = fopen(f, m); + return fd; +} + size_t my_mstrcat(int id, char **str, const char *add, ...) { va_list args; @@ -1020,7 +1033,7 @@ static int edit_rect_property(int x) } attr = get_tok_value(xctx->rect[c][n].prop_ptr,"fill", 0); - if(!strcmp(attr, "full")) xctx->rect[c][n].fill = 3; + if(!strcmp(attr, "full")) xctx->rect[c][n].fill = 2; else if(!strboolcmp(attr, "false")) xctx->rect[c][n].fill = 0; else xctx->rect[c][n].fill = 1; @@ -1203,11 +1216,11 @@ static int edit_arc_property(void) old_fill = xctx->arc[c][i].fill; fill_ptr = get_tok_value(xctx->arc[c][i].prop_ptr,"fill",0); if( !strcmp(fill_ptr,"full") ) - xctx->arc[c][i].fill =3; /* bit 1: solid fill (not stippled) */ + xctx->arc[c][i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr,"true") ) - xctx->arc[c][i].fill =1; + xctx->arc[c][i].fill = 1; else - xctx->arc[c][i].fill =0; + xctx->arc[c][i].fill = 0; old_dash = xctx->arc[c][i].dash; dash = get_tok_value(xctx->arc[c][i].prop_ptr,"dash",0); if( strcmp(dash, "") ) { @@ -1281,11 +1294,11 @@ static int edit_polygon_property(void) fill_ptr = get_tok_value(xctx->poly[c][i].prop_ptr,"fill",0); if( !strcmp(fill_ptr,"full") ) - xctx->poly[c][i].fill =3; /* bit 1: solid fill (not stippled) */ + xctx->poly[c][i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr,"true") ) - xctx->poly[c][i].fill =1; + xctx->poly[c][i].fill = 1; else - xctx->poly[c][i].fill =0; + xctx->poly[c][i].fill = 0; dash = get_tok_value(xctx->poly[c][i].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); diff --git a/src/hilight.c b/src/hilight.c index fa7b8916..f7081c33 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -2226,7 +2226,7 @@ void draw_hilight_net(int on_window) ((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts)) { draw_symbol(ADD, col, i,c,0,0,0.0,0.0); } - filledrect(col, END, 0.0, 0.0, 0.0, 0.0, 3, -1, -1); /* last parameter must be 3! */ + filledrect(col, END, 0.0, 0.0, 0.0, 0.0, 2, -1, -1); /* last parameter must be 2! */ drawarc(col, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0); drawrect(col, END, 0.0, 0.0, 0.0, 0.0, 0, -1, -1); drawline(col, END, 0.0, 0.0, 0.0, 0.0, 0, NULL); diff --git a/src/netlist.c b/src/netlist.c index 4180d46d..afa7f5b0 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -1665,8 +1665,7 @@ int sym_vs_sch_pins(int all) /* pass through symbols, duplicated pins: do not check with schematic */ if(rects > unique_pins) continue; get_sch_from_sym(filename, xctx->sym + i, -1, 0); - if(!stat(filename, &buf)) { - fd = fopen(filename, "r"); + if(!stat(filename, &buf) && (fd = my_fopen(filename, fopen_read_mode))) { pin_cnt = 0; endfile = 0; f_version[0] = '\0'; diff --git a/src/options.c b/src/options.c index e2872111..732cc3ed 100644 --- a/src/options.c +++ b/src/options.c @@ -111,10 +111,11 @@ static void check_opt(char *opt, char *optval, int type) } else if( (type == SHORT && *opt == 'l') || (type == LONG && !strcmp("log", opt)) ) { if(optval) { errfp = fopen(optval, "w"); - setvbuf(errfp, NULL, _IOLBF, 0); /* line (_IOLBF) or disable (_IONBF) buffering on error log */ if(!errfp) { errfp = stderr; dbg(0, "Problems opening log file: %s\n", optval); + } else { + setvbuf(errfp, NULL, _IOLBF, 0); /* line (_IOLBF) or disable (_IONBF) buffering on error log */ } } } else if( (type == SHORT && *opt == 'o') || (type == LONG && !strcmp("netlist_path", opt)) ) { diff --git a/src/paste.c b/src/paste.c index 125905e9..7ed3c536 100644 --- a/src/paste.c +++ b/src/paste.c @@ -120,11 +120,11 @@ static void merge_box(FILE *fd) fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; + ptr[i].fill = 2; else if( !strboolcmp(fill_ptr, "false") ) - ptr[i].fill =0; + ptr[i].fill = 0; else - ptr[i].fill =1; + ptr[i].fill = 1; set_rect_flags(&xctx->rect[c][i]); /* set cached .flags bitmask from on attributes */ select_box(c,i, SELECTED, 1, 1); xctx->rects[c]++; @@ -159,11 +159,11 @@ static void merge_arc(FILE *fd) fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; /* bit 1: solid fill (not stippled) */ + ptr[i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr, "true") ) - ptr[i].fill =1; + ptr[i].fill = 1; else - ptr[i].fill =0; + ptr[i].fill = 0; dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); @@ -219,11 +219,11 @@ static void merge_polygon(FILE *fd) load_ascii_string( &ptr[i].prop_ptr, fd); fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; /* bit 1: solid fill (not stippled) */ + ptr[i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr, "true") ) - ptr[i].fill =1; + ptr[i].fill = 1; else - ptr[i].fill =0; + ptr[i].fill = 0; dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); @@ -379,7 +379,7 @@ void merge_file(int selection_load, const char ext[]) my_free(_ALLOC_ID_, &cmd); } else fd = NULL; } else { - fd=fopen(name, fopen_read_mode); + fd=my_fopen(name, fopen_read_mode); } if(fd) { xctx->prep_hi_structs=0; diff --git a/src/psprint.c b/src/psprint.c index 26a003fd..3332aeb8 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -443,11 +443,27 @@ static void ps_xdrawpoint(int layer, double x1, double y1) fprintf(fd, "%g %g %g %g L\n", x1, y1,x1,y1); } -static void ps_xfillrectange(int layer, double x1, double y1, double x2, +/* fill_pattern: + * 0 : no fill + * 1 : stippled fill + * 2 : solid fill + * + * fill_type[i]: + * 0 : no fill + * 1 : patterned (stippled) fill + * 2 : solid fill + * + * fill: + * 0 : no fill + * 1 : stippled fill + * 2 : solid fill + */ + +static void ps_xfillrectangle(int layer, double x1, double y1, double x2, double y2, int fill) { fprintf(fd, "%g %g %g %g R\n", x1,y1,x2-x1,y2-y1); - if(fill && (xctx->fill_type[layer] == 1) && xctx->fill_pattern) { + if(xctx->fill_pattern && xctx->fill_type[layer] && fill) { fprintf(fd, "%g %g %g %g RF\n", x1,y1,x2-x1,y2-y1); /* fprintf(fd,"fill\n"); */ } @@ -545,7 +561,8 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, in } -static void ps_filledrect(int gc, double rectx1,double recty1,double rectx2,double recty2, int dash, int fill) +static void ps_filledrect(int gc, double rectx1,double recty1,double rectx2,double recty2, + int dash, int fill, int e_a, int e_b) { double x1,y1,x2,y2, tmp; double psdash; @@ -560,7 +577,21 @@ static void ps_filledrect(int gc, double rectx1,double recty1,double rectx2,doub if(dash) { fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash); } - ps_xfillrectange(gc, x1,y1,x2,y2, fill); + if(e_a != -1) { + double rx = (x2 - x1) / 2.0; + double ry = (y2 - y1) / 2.0; + double cx = (x2 + x1) / 2.0; + double cy = (y2 + y1) / 2.0; + + if(xctx->fill_pattern && xctx->fill_type[gc] && fill) { + fprintf(fd, "%g %g MT %g %g %g %g %d %d E %g %g LT C F S\n", + cx, cy, cx, cy, rx, ry, -e_a, -e_a-e_b, cx, cy); + } else { + fprintf(fd, "%g %g %g %g %d %d E S\n", cx, cy, rx, ry, -e_a, -e_a-e_b); + } + } else { + ps_xfillrectangle(gc, x1,y1,x2,y2, fill); + } if(dash) { fprintf(fd, "[] 0 setdash\n"); } @@ -935,7 +966,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho #endif else if((xctx->inst[n].x2 - xctx->inst[n].x1) * xctx->mooz < 3 && (xctx->inst[n].y2 - xctx->inst[n].y1) * xctx->mooz < 3) { - ps_filledrect(c, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 0, 0); + ps_filledrect(c, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 0, 0, -1, -1); xctx->inst[n].flags|=1; return; } @@ -944,7 +975,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho } if(hide) { int color = (disabled==1) ? GRIDLAYER : (disabled == 2) ? PINLAYER : SYMLAYER; - ps_filledrect(color, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 2, 0); + ps_filledrect(color, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 2, 0, -1, -1); } /* pdfmarks, only if doing hierarchy print and if symbol has a subcircuit */ if(what != 7) { @@ -1031,6 +1062,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho if( (!hide && xctx->enable_layer[layer]) || (hide && layer == PINLAYER && xctx->enable_layer[layer]) ) { + if(symptr->rects[layer]) fprintf(fd, "NP\n"); /* newpath */ for(j=0;j< symptr->rects[layer]; ++j) { int dash; @@ -1042,9 +1074,27 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho if (layer == GRIDLAYER && rect->flags & 1024) /* image */ { ps_embedded_image(rect, x0 + x1, y0 + y1, x0 + x2, y0 + y2, rot, flip); - continue; + } else { + int ellipse_a = rect->ellipse_a; + int ellipse_b = rect->ellipse_b; + + if(ellipse_a != -1 && ellipse_b != 360) { + if(flip) { + ellipse_a = 180 - ellipse_a - ellipse_b; + } + if(rot) { + if(rot == 3) { + ellipse_a += 90; + } else if(rot == 2) { + ellipse_a += 180; + } else if(rot == 1) { + ellipse_a += 270; + } + ellipse_a %= 360; + } + } + ps_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, dash, rect->fill, ellipse_a, ellipse_b); } - ps_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, dash, rect->fill); } } /* if( (!hide && xctx->enable_layer[layer]) || ... */ @@ -1331,6 +1381,19 @@ void create_ps(char **psfile, int what, int fullzoom, int eps) fprintf(fd,"/C {closepath} bind def\n"); fprintf(fd,"/F {fill} bind def\n"); fprintf(fd,"/RF {rectfill} bind def\n"); + fprintf(fd,"/E {\n"); /* function for drawing ellipses */ + fprintf(fd,"/endangle exch def\n"); + fprintf(fd,"/startangle exch def\n"); + fprintf(fd,"/yrad exch def\n"); + fprintf(fd,"/xrad exch def\n"); + fprintf(fd,"/y exch def\n"); + fprintf(fd,"/x exch def\n"); + fprintf(fd,"/savematrix matrix currentmatrix def\n"); + fprintf(fd,"x y translate\n"); + fprintf(fd,"xrad yrad scale\n"); + fprintf(fd,"0 0 1 startangle endangle arcn\n"); + fprintf(fd,"savematrix setmatrix\n"); + fprintf(fd,"} def %% ellipse\n"); fprintf(fd, "%%%%EndProlog\n"); } @@ -1375,6 +1438,7 @@ void create_ps(char **psfile, int what, int fullzoom, int eps) for(i=0;ilines[c]; ++i) ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1, xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash); + if(xctx->rects[c]) fprintf(fd, "NP\n"); /* newpath */ for(i=0;irects[c]; ++i) { @@ -1390,7 +1454,9 @@ void create_ps(char **psfile, int what, int fullzoom, int eps) } if(c != GRIDLAYER || !(xctx->rect[c][i].flags & 1) ) { ps_filledrect(c, xctx->rect[c][i].x1, xctx->rect[c][i].y1, - xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash, xctx->rect[c][i].fill); + xctx->rect[c][i].x2, xctx->rect[c][i].y2, + xctx->rect[c][i].dash, xctx->rect[c][i].fill, + xctx->rect[c][i].ellipse_a, xctx->rect[c][i].ellipse_b); } } if(xctx->arcs[c]) fprintf(fd, "NP\n"); /* newpath */ diff --git a/src/save.c b/src/save.c index 4445f20a..cefd1a04 100644 --- a/src/save.c +++ b/src/save.c @@ -909,7 +909,7 @@ char *base64_from_file(const char *f, size_t *length) stat_res = stat(f, &st); if (stat_res == 0 && ( (st.st_mode & S_IFMT) == S_IFREG) ) { len = st.st_size; - fd = fopen(f, fopen_read_mode); + fd = my_fopen(f, fopen_read_mode); if(fd) { size_t bytes_read; s = my_malloc(_ALLOC_ID_, len); @@ -1023,7 +1023,7 @@ int raw_read(const char *f, Raw **rawptr, const char *type, int no_warning, doub raw->annot_sweep_idx = -1; int_hash_init(&raw->table, HASHSIZE); - fd = fopen(f, fopen_read_mode); + fd = my_fopen(f, fopen_read_mode); if(fd) { if((res = read_dataset(fd, rawptr, type, no_warning)) == 1) { int i; @@ -1467,7 +1467,7 @@ int table_read(const char *f) close(ufd); int_hash_init(&raw->table, HASHSIZE); - fd = fopen(f, fopen_read_mode); + fd = my_fopen(f, fopen_read_mode); if(fd) { int nline = 0; int field; @@ -2852,11 +2852,11 @@ static void load_polygon(FILE *fd) load_ascii_string( &ptr[i].prop_ptr, fd); fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; /* bit 1: solid fill (not stippled) */ + ptr[i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr, "true") ) - ptr[i].fill =1; + ptr[i].fill = 1; else - ptr[i].fill =0; + ptr[i].fill = 0; dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); @@ -2895,11 +2895,11 @@ static void load_arc(FILE *fd) fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; /* bit 1: solid fill (not stippled) */ + ptr[i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr, "true") ) - ptr[i].fill =1; + ptr[i].fill = 1; else - ptr[i].fill =0; + ptr[i].fill = 0; dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); @@ -2939,11 +2939,11 @@ static void load_box(FILE *fd) load_ascii_string( &ptr[i].prop_ptr, fd); fill_ptr = get_tok_value(ptr[i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - ptr[i].fill =3; + ptr[i].fill = 2; else if( !strboolcmp(fill_ptr, "false") ) - ptr[i].fill =0; + ptr[i].fill = 0; else - ptr[i].fill =1; + ptr[i].fill = 1; attr = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(attr, "")) { int d = atoi(attr); @@ -3544,7 +3544,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler my_free(_ALLOC_ID_, &cmd); } else fd = NULL; } - else fd=fopen(name,fopen_read_mode); + else fd=my_fopen(name,fopen_read_mode); if( fd == NULL) { size_t len; ret = 0; @@ -3823,7 +3823,7 @@ void pop_undo(int redo, int set_modify_status) fd=fdopen(pd[0],"r"); #else /* uncompressed undo */ my_snprintf(diff_name, S(diff_name), "%s/undo%d", xctx->undo_dirname, xctx->cur_undo_ptr%MAX_UNDO); - fd=fopen(diff_name, "r"); + fd=my_fopen(diff_name, fopen_read_mode); if(!fd) { fprintf(errfp, "pop_undo(): failed to open read pipe %s\n", diff_name); xctx->no_undo=1; @@ -3894,9 +3894,9 @@ static void get_sym_type(const char *symname, char **type, if( !found ) { dbg(1, "get_sym_type(): open file %s, pintable %s\n",name, pintable ? "set" : ""); /* ... if not found open file and look for 'type' into the global attributes. */ - + if(embed_fd) fd = embed_fd; - else fd=fopen(name,fopen_read_mode); + else fd=my_fopen(name,fopen_read_mode); if(fd==NULL) { dbg(1, "get_sym_type(): Symbol not found: %s\n",name); @@ -4238,15 +4238,15 @@ int load_sym_def(const char *name, FILE *embed_fd) } else { my_strncpy(sympath, abs_sym_path(transl_name, ""), S(sympath)); } - if((lcc[level].fd=fopen(sympath,fopen_read_mode))==NULL) { + if((lcc[level].fd=my_fopen(sympath,fopen_read_mode))==NULL) { /* not found: try web URL */ if(is_from_web(xctx->current_dirname)) { my_snprintf(sympath, S(sympath), "%s/%s", xschem_web_dirname, get_cell_w_ext(transl_name, 0)); - if((lcc[level].fd=fopen(sympath,fopen_read_mode))==NULL) { + if((lcc[level].fd=my_fopen(sympath,fopen_read_mode))==NULL) { /* not already cached in .../xschem_web_xxxxx/ so download */ tclvareval("try_download_url {", xctx->current_dirname, "} {", transl_name, "}", NULL); } - lcc[level].fd=fopen(sympath,fopen_read_mode); + lcc[level].fd=my_fopen(sympath,fopen_read_mode); } } dbg(1, "l_s_d(): fopen1(%s), level=%d, fd=%p\n",sympath, level, lcc[level].fd); @@ -4258,7 +4258,7 @@ int load_sym_def(const char *name, FILE *embed_fd) /* issue warning only on top level symbol loading */ if(recursion_counter == 1) dbg(0, "l_s_d(): Symbol not found: %s\n", transl_name); my_snprintf(sympath, S(sympath), "%s/%s", tclgetvar("XSCHEM_SHAREDIR"), "systemlib/missing.sym"); - if((lcc[level].fd=fopen(sympath, fopen_read_mode))==NULL) + if((lcc[level].fd=my_fopen(sympath, fopen_read_mode))==NULL) { fprintf(errfp, "l_s_d(): systemlib/missing.sym missing, I give up\n"); tcleval("exit"); @@ -4453,11 +4453,11 @@ int load_sym_def(const char *name, FILE *embed_fd) fill_ptr = get_tok_value(pp[c][i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - pp[c][i].fill =3; /* bit 1: solid fill (not stippled) */ + pp[c][i].fill = 2; /* bit 1: solid fill (not stippled) */ else if( !strboolcmp(fill_ptr, "true") ) - pp[c][i].fill =1; + pp[c][i].fill = 1; else - pp[c][i].fill =0; + pp[c][i].fill = 0; attr = get_tok_value(pp[c][i].prop_ptr,"dash", 0); if( strcmp(attr, "") ) { @@ -4519,11 +4519,11 @@ int load_sym_def(const char *name, FILE *embed_fd) } fill_ptr = get_tok_value(aa[c][i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - aa[c][i].fill =3; /* bit 1: solid fill (not stiaaled) */ + aa[c][i].fill = 2; /* bit 1: solid fill (not stiaaled) */ else if( !strboolcmp(fill_ptr, "true") ) - aa[c][i].fill =1; + aa[c][i].fill = 1; else - aa[c][i].fill =0; + aa[c][i].fill = 0; attr = get_tok_value(aa[c][i].prop_ptr,"dash", 0); if( strcmp(attr, "") ) { int d = atoi(attr); @@ -4582,11 +4582,11 @@ int load_sym_def(const char *name, FILE *embed_fd) dbg(2, "l_s_d(): loaded rect: ptr=%lx\n", (unsigned long)bb[c]); fill_ptr = get_tok_value(bb[c][i].prop_ptr,"fill",0); if( !strcmp(fill_ptr, "full") ) - bb[c][i].fill =3; + bb[c][i].fill = 2; else if( !strboolcmp(fill_ptr, "false") ) - bb[c][i].fill =0; + bb[c][i].fill = 0; else - bb[c][i].fill =1; + bb[c][i].fill = 1; attr = get_tok_value(bb[c][i].prop_ptr,"dash", 0); if( strcmp(attr, "") ) { int d = atoi(attr); @@ -4799,6 +4799,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dbg(1, "l_s_d(): level=%d, symname=%s symtype=%s\n", level, symname, symtype); if( /* add here symbol types not to consider when loading schematic-as-symbol instances */ + !symtype || !strcmp(symtype, "logo") || !strcmp(symtype, "netlist_commands") || !strcmp(symtype, "netlist_options") || @@ -4829,7 +4830,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dbg(1, "l_s_d(): fopen2(%s), level=%d\n",sympath, level); /* find out if symbol is in an external file or embedded, set fd_tmp accordingly */ - if ((fd_tmp = fopen(sympath, fopen_read_mode)) == NULL) { + if ((fd_tmp = my_fopen(sympath, fopen_read_mode)) == NULL) { char c; fprintf(errfp, "l_s_d(): unable to open file to read schematic: %s\n", sympath); if(!generator) { diff --git a/src/scheduler.c b/src/scheduler.c index c7aaf8e4..21292799 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -5574,7 +5574,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg set_rect_flags(r); /* set cached .flags bitmask from attributes */ if(argc > 5 && !strcmp(argv[5], "fill")) { const char *attr = get_tok_value(r->prop_ptr,"fill", 0); - if(!strcmp(attr, "full")) xctx->rect[c][n].fill = 3; + if(!strcmp(attr, "full")) xctx->rect[c][n].fill = 2; else if(!strboolcmp(attr, "false")) xctx->rect[c][n].fill = 0; else xctx->rect[c][n].fill = 1; } diff --git a/src/select.c b/src/select.c index ca5105d2..620bac21 100644 --- a/src/select.c +++ b/src/select.c @@ -439,7 +439,7 @@ static void del_rect_line_arc_poly() { ++j; - if(xctx->arc[c][i].fill & 1) /* .fill: 1: stippled fill, 3: solid fill */ + if(xctx->arc[c][i].fill) /* .fill: 1: stippled fill, 2: solid fill */ arc_bbox(xctx->arc[c][i].x, xctx->arc[c][i].y, xctx->arc[c][i].r, 0, 360, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); else diff --git a/src/spice_netlist.c b/src/spice_netlist.c index c341895a..663a2a7d 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -635,6 +635,11 @@ int spice_block_netlist(FILE *fd, int i, int alert) tclgetvar("netlist_dir"), get_cell(name, 0), getpid()); dbg(1, "spice_block_netlist(): split_files: netl_filename=%s\n", netl_filename); fd=fopen(netl_filename, "w"); + if(!fd) { + dbg(0, "spice_block_netlist(): unable to write file %s\n", netl_filename); + err = 1; + goto err; + } my_snprintf(cellname, S(cellname), "%s.spice", get_cell(name, 0)); } fprintf(fd, "\n* expanding symbol: %s # of pins=%d\n", name,xctx->sym[i].rects[PINLAYER] ); @@ -689,6 +694,7 @@ int spice_block_netlist(FILE *fd, int i, int alert) set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } + err: xctx->netlist_count++; my_free(_ALLOC_ID_, &name); return err; diff --git a/src/store.c b/src/store.c index e9fed4f1..ce02bdb6 100644 --- a/src/store.c +++ b/src/store.c @@ -156,11 +156,11 @@ void store_arc(int pos, double x, double y, double r, double a, double b, fill_ptr = get_tok_value(xctx->arc[rectc][n].prop_ptr,"fill",0); if(!strcmp(fill_ptr, "full") ) - xctx->arc[rectc][n].fill =3; /* bit 1: solid fill (not stippled) */ + xctx->arc[rectc][n].fill = 2; /* bit 1: solid fill (not stippled) */ else if(!strboolcmp(fill_ptr, "true") ) - xctx->arc[rectc][n].fill =1; + xctx->arc[rectc][n].fill = 1; else - xctx->arc[rectc][n].fill =0; + xctx->arc[rectc][n].fill = 0; dash = get_tok_value(xctx->arc[rectc][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); @@ -206,11 +206,11 @@ void store_poly(int pos, double *x, double *y, int points, unsigned int rectc, fill_ptr = get_tok_value(xctx->poly[rectc][n].prop_ptr,"fill",0); if(!strcmp(fill_ptr, "full") ) - xctx->poly[rectc][n].fill =3; /* bit 1: solid fill (not stippled) */ + xctx->poly[rectc][n].fill = 2; /* bit 1: solid fill (not stippled) */ else if(!strboolcmp(fill_ptr, "true") ) - xctx->poly[rectc][n].fill =1; + xctx->poly[rectc][n].fill = 1; else - xctx->poly[rectc][n].fill =0; + xctx->poly[rectc][n].fill = 0; dash = get_tok_value(xctx->poly[rectc][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); @@ -307,11 +307,11 @@ int storeobject(int pos, double x1,double y1,double x2,double y2, fill_ptr = get_tok_value(xctx->rect[rectc][n].prop_ptr, "fill", 0); if(!strcmp(fill_ptr, "full") ) - xctx->rect[rectc][n].fill =3; + xctx->rect[rectc][n].fill = 2; else if(!strboolcmp(fill_ptr,"false") ) - xctx->rect[rectc][n].fill =0; + xctx->rect[rectc][n].fill = 0; else - xctx->rect[rectc][n].fill =1; + xctx->rect[rectc][n].fill = 1; set_rect_flags(&xctx->rect[rectc][n]); /* set cached .flags bitmask from on attributes */ if(rectc == GRIDLAYER && (xctx->rect[rectc][n].flags & 1024)) { xRect *r = &xctx->rect[GRIDLAYER][n]; diff --git a/src/svgdraw.c b/src/svgdraw.c index 4db04c17..44e0229a 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -62,7 +62,7 @@ static void svg_xfillrectangle(int layer, double x1, double y1, double x2, doubl if(dash) fprintf(fd, "stroke-dasharray=\"%g,%g\" ", 1.4*dash/xctx->zoom, 1.4*dash/xctx->zoom); if(fill == 0) { fprintf(fd,"style=\"fill:none;\" "); - } else if(fill == 3) { + } else if(fill == 2) { fprintf(fd, "style=\"fill-opacity:1.0;\" "); } fprintf(fd,"d=\"M%g %gL%g %gL%g %gL%g %gL%g %gz\"/>\n", x1, y1, x2, y1, x2, y2, x1, y2, x1, y1); @@ -135,7 +135,7 @@ static void svg_drawpolygon(int c, int what, double *x, double *y, int points, i if(dash) fprintf(fd, "stroke-dasharray=\"%g,%g\" ", 1.4*dash/xctx->zoom, 1.4*dash/xctx->zoom); if(fill == 0) { fprintf(fd,"style=\"fill:none;\" "); - } else if(fill == 3) { + } else if(fill == 2) { fprintf(fd, "style=\"fill-opacity:1.0;\" "); } bezier = flags && (points > 2); @@ -175,7 +175,7 @@ static void svg_filledrect(int gc, double rectx1,double recty1,double rectx2,dou fprintf(fd, "zoom, 1.4*dash/xctx->zoom); if(fill == 0) fprintf(fd, "style=\"fill:none;\" "); - else if(fill == 3) fprintf(fd, "style=\"fill-opacity:1.0;\" "); + else if(fill == 2) fprintf(fd, "style=\"fill-opacity:1.0;\" "); fprintf(fd, "/>\n"); } else { double xx1 = rx * cos(e_a * XSCH_PI / 180.) + cx; @@ -190,7 +190,7 @@ static void svg_filledrect(int gc, double rectx1,double recty1,double rectx2,dou if(fill == 0) { fprintf(fd,"style=\"fill:none;\" "); fprintf(fd, "d=\"M%g %g A%g %g 0 %d %d %g %g\"/>\n", xx1, yy1, rx, ry, fa, fs, xx2, yy2); - } else if(fill == 3) { + } else if(fill == 2) { fprintf(fd, "style=\"fill-opacity:1.0;\" "); fprintf(fd, "d=\"M%g %g A%g %g 0 %d %d %g %gL%g %gz\"/>\n", xx1, yy1, rx, ry, fa, fs, xx2, yy2, cx, cy); } else { @@ -245,7 +245,7 @@ static void svg_drawarc(int gc, int fillarc, double x,double y,double r,double a fprintf(fd, "zoom, 1.4*dash/xctx->zoom); if(fillarc == 0) fprintf(fd, "style=\"fill:none;\" "); - else if(fillarc == 3) fprintf(fd, "style=\"fill-opacity:1.0;\" "); + else if(fillarc == 2) fprintf(fd, "style=\"fill-opacity:1.0;\" "); fprintf(fd, "/>\n"); } else { @@ -261,7 +261,7 @@ static void svg_drawarc(int gc, int fillarc, double x,double y,double r,double a if(fillarc == 0) { fprintf(fd,"style=\"fill:none;\" "); fprintf(fd, "d=\"M%g %g A%g %g 0 %d %d %g %g\"/>\n", xx1, yy1, rr, rr, fa, fs, xx2, yy2); - } else if(fillarc == 3) { + } else if(fillarc == 2) { fprintf(fd, "style=\"fill-opacity:1.0;\" "); fprintf(fd, "d=\"M%g %g A%g %g 0 %d %d %g %gL%g %gz\"/>\n", xx1, yy1, rr, rr, fa, fs, xx2, yy2, xx, yy); } else { diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index bb675e55..630acc58 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -453,6 +453,11 @@ int verilog_block_netlist(FILE *fd, int i, int alert) tclgetvar("netlist_dir"), get_cell(name, 0), getpid()); dbg(1, "global_vhdl_netlist(): split_files: netl_filename=%s\n", netl_filename); fd=fopen(netl_filename, "w"); + if(!fd) { + dbg(0, "verilog_block_netlist(): unable to write file %s\n", netl_filename); + err = 1; + goto err; + } my_snprintf(cellname, S(cellname), "%s.v", get_cell(name, 0)); } @@ -619,6 +624,7 @@ int verilog_block_netlist(FILE *fd, int i, int alert) set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } + err: xctx->netlist_count++; my_free(_ALLOC_ID_, &name); return err; diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 5db254b2..c7d218c4 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -538,6 +538,11 @@ int vhdl_block_netlist(FILE *fd, int i, int alert) tclgetvar("netlist_dir"), get_cell(xctx->sym[i].name, 0), getpid()); dbg(1, "vhdl_block_netlist(): split_files: netl_filename=%s\n", netl_filename); fd=fopen(netl_filename, "w"); + if(!fd) { + dbg(0, "vhdl_block_netlist(): unable to write file %s\n", netl_filename); + err = 1; + goto err; + } my_snprintf(cellname, S(cellname), "%s.vhdl", get_cell(xctx->sym[i].name, 0) ); } @@ -721,6 +726,7 @@ int vhdl_block_netlist(FILE *fd, int i, int alert) set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } + err: xctx->netlist_count++; return err; } diff --git a/src/xinit.c b/src/xinit.c index a13674a5..288b4e8c 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -361,10 +361,10 @@ void init_pixdata()/* populate xctx->fill_type array that is used in create_gc() if(pixdata[i][j]!=0xff) full=0; if(pixdata[i][j]!=0x00) empty=0; } - if(full) xctx->fill_type[i] = 1; + if(full) xctx->fill_type[i] = 2; else if(empty) xctx->fill_type[i] = 0; - else xctx->fill_type[i]=2; - if(rainbow_colors && i>5) xctx->fill_type[i]=1; /* 20171212 solid fill style */ + else xctx->fill_type[i]=1; + if(rainbow_colors && i>5) xctx->fill_type[i]=2; /* 20171212 solid fill style */ /*fprintf(errfp, "fill_type[%d]= %d\n", i, xctx->fill_type[i]); */ } } @@ -434,7 +434,7 @@ void create_gc(void) xctx->gc[i] = XCreateGC(display,xctx->window,0L,NULL); xctx->gcstipple[i] = XCreateGC(display,xctx->window,0L,NULL); XSetStipple(display,xctx->gcstipple[i],pixmap[i]); - if(xctx->fill_type[i]==1) XSetFillStyle(display,xctx->gcstipple[i],FillSolid); + if(xctx->fill_type[i]==2) XSetFillStyle(display,xctx->gcstipple[i],FillSolid); else XSetFillStyle(display,xctx->gcstipple[i],FillStippled); } } diff --git a/src/xschem.h b/src/xschem.h index a6f5007b..27700e9f 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -491,7 +491,7 @@ typedef struct unsigned short sel; char *prop_ptr; void *extraptr; /* generic data pointer (images) */ - short fill; + short fill; /* 0: no fill, 1: stippled fill, 2: solid fill */ short dash; int ellipse_a, ellipse_b; /* bit0=1 for graph function, bit1=1 for unlocked x axis @@ -1648,6 +1648,7 @@ extern char *my_free(int id, void *ptr); extern size_t my_strcat(int id, char **, const char *); extern size_t my_strcat2(int id, char **, const char *); extern size_t my_mstrcat(int id, char **str, const char *append_str, ...); +extern FILE * my_fopen(const char *f, const char *m); extern void *my_memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen); extern char *my_itoa(int i); extern double atof_spice(const char *s);