diff --git a/src/actions.c b/src/actions.c index 3ad090b7..154c158e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2812,7 +2812,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) if(!xctx->hilight_nets || !xctx->wire[i].node || !xctx->wire[i].node[0] || !bus_hilight_hash_lookup(xctx->wire[i].node, 0,XLOOKUP)) continue; } - if(xctx->wire[i].bus){ + if(xctx->wire[i].bus == -1.0){ ov = INT_BUS_WIDTH(xctx->lw)> xctx->cadhalfdotsize ? INT_BUS_WIDTH(xctx->lw) : CADHALFDOTSIZE; if(xctx->wire[i].y1 < xctx->wire[i].y2) { y1 = xctx->wire[i].y1-ov; y2 = xctx->wire[i].y2+ov; } else { y1 = xctx->wire[i].y1+ov; y2 = xctx->wire[i].y2-ov; } diff --git a/src/draw.c b/src/draw.c index a091b2fe..26a62a1a 100644 --- a/src/draw.c +++ b/src/draw.c @@ -733,7 +733,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, ROTATION(rot, flip, 0.0, 0.0,line->x1,line->y1,x1,y1); ROTATION(rot, flip, 0.0, 0.0,line->x2,line->y2,x2,y2); ORDER(x1,y1,x2,y2); - if(line->bus) + if(line->bus == -1.0) drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, dash, NULL); else drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, dash, NULL); @@ -744,7 +744,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, int bezier; int bus; polygon = &(symptr->poly[layer])[j]; - bus = polygon->bus ? THICK : NOW; + bus = (polygon->bus == -1.0) ? THICK : NOW; bezier = !strboolcmp(get_tok_value(polygon->prop_ptr, "bezier", 0), "true"); dash = (disabled == 1) ? 3 : polygon->dash; x = my_malloc(_ALLOC_ID_, sizeof(double) * polygon->points); @@ -984,7 +984,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot ROTATION(rot, flip, 0.0, 0.0,line->x1,line->y1,x1,y1); ROTATION(rot, flip, 0.0, 0.0,line->x2,line->y2,x2,y2); ORDER(x1,y1,x2,y2); - if(line->bus) + if(line->bus == -1.0) drawtempline(gc,THICK, x0+x1, y0+y1, x0+x2, y0+y2); else drawtempline(gc,what, x0+x1, y0+y1, x0+x2, y0+y2); @@ -5157,7 +5157,7 @@ void draw(void) cc = c; if(xctx->only_probes) cc = GRIDLAYER; if(draw_layer && xctx->enable_layer[c]) for(i=0;ilines[c]; ++i) { xLine *l = &xctx->line[c][i]; - if(l->bus) drawline(cc, THICK, l->x1, l->y1, l->x2, l->y2, l->dash, NULL); + if(l->bus == -1.0) drawline(cc, THICK, l->x1, l->y1, l->x2, l->y2, l->dash, NULL); else drawline(cc, ADD, l->x1, l->y1, l->x2, l->y2, l->dash, NULL); } if(draw_layer && xctx->enable_layer[c]) for(i=0;irects[c]; ++i) { @@ -5180,9 +5180,9 @@ void draw(void) if(draw_layer && xctx->enable_layer[c]) for(i=0;ipolygons[c]; ++i) { int bezier; xPoly *p = &xctx->poly[c][i]; - int bus = p->bus ? THICK : NOW; + int what = (p->bus == -1.0) ? THICK : NOW; bezier = 2 + !strboolcmp(get_tok_value(p->prop_ptr, "bezier", 0), "true"); - drawpolygon(cc, bus, p->x, p->y, p->points, p->fill, p->dash, bezier); + drawpolygon(cc, what, p->x, p->y, p->points, p->fill, p->dash, bezier); } if(use_hash) init_inst_iterator(&ctx, x1, y1, x2, y2); else i = -1; @@ -5232,7 +5232,7 @@ void draw(void) ++i; if(i >= xctx->wires) break; } - if(xctx->wire[i].bus) { + if(xctx->wire[i].bus == -1.0) { drawline(cc, THICK, xctx->wire[i].x1,xctx->wire[i].y1, xctx->wire[i].x2,xctx->wire[i].y2, 0, NULL); } diff --git a/src/editprop.c b/src/editprop.c index 4d046b6f..a829e9d2 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -79,23 +79,27 @@ int my_strncasecmp(const char *s1, const char *s2, size_t n) return tolower(*s1) - tolower(*s2); } -/* if s is an integer return integer value - * else if s == (true | on | yes) return 1 - * else if s == (false | off | no) return 0 - * else return 0 +/* if s is an double return double value + * else if s == ( 1 | true | on | yes) return -1.0 + * else if s == (false | off | no) return 0.0 + * else return 0.0 */ -int get_attr_val(const char *str) +double get_attr_val(const char *str) { - int s = 0; - if(isonlydigit(str)) { - s = atoi(str); - } + double s = 0.0; + char *endptr; + + if(!str) return 0.0; else if(!my_strcasecmp(str, "true") || + !my_strcasecmp(str, "1") || !my_strcasecmp(str, "on") || - !my_strcasecmp(str, "yes")) s = 1; + !my_strcasecmp(str, "yes")) s = -1.0; else if(!my_strcasecmp(str, "false") || !my_strcasecmp(str, "off") || - !my_strcasecmp(str, "no")) s = 0; + !my_strcasecmp(str, "no")) s = 0.0; + else if((strtod(str, &endptr), endptr) > str) { /* NUMBER */ + s = atof(str); + } return s; } @@ -1156,7 +1160,7 @@ static int edit_wire_property(void) int i, modified = 0; int preserve; char *oldprop=NULL; - int bus; + double bus; my_strdup(_ALLOC_ID_, &oldprop, xctx->wire[xctx->sel_array[0].n].prop_ptr); if(oldprop && oldprop[0]) { @@ -1173,7 +1177,7 @@ static int edit_wire_property(void) xctx->push_undo(); bbox(START, 0.0 , 0.0 , 0.0 , 0.0); for(i=0; ilastsel; ++i) { - int oldbus=0; + double oldbus=0.0; int k = xctx->sel_array[i].n; if(xctx->sel_array[i].type != WIRE) continue; /* does not seem to be necessary */ @@ -1187,7 +1191,7 @@ static int edit_wire_property(void) my_strdup(_ALLOC_ID_, &xctx->wire[k].prop_ptr,(char *) tclgetvar("tctx::retval")); } xctx->wire[k].bus = bus = get_attr_val(get_tok_value(xctx->wire[k].prop_ptr,"bus",0)); - if(bus) { + if(bus == -1.0) { double ov, y1, y2; ov = INT_BUS_WIDTH(xctx->lw) > xctx->cadhalfdotsize ? INT_BUS_WIDTH(xctx->lw) : CADHALFDOTSIZE; if(xctx->wire[k].y1 < xctx->wire[k].y2) { y1 = xctx->wire[k].y1-ov; y2 = xctx->wire[k].y2+ov; } @@ -1288,8 +1292,8 @@ static int edit_polygon_property(void) int old_fill; int oldbezier, bezier; int k; - double x1=0., y1=0., x2=0., y2=0.; - int c, i, ii, old_dash, oldbus, bus; + double x1=0., y1=0., x2=0., y2=0., oldbus = 0.0, bus = 0.0; + int c, i, ii, old_dash; int drw = 0; char *oldprop = NULL; const char *dash; diff --git a/src/hilight.c b/src/hilight.c index f90bfc92..9dfcdddd 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -2226,7 +2226,7 @@ void draw_hilight_net(int on_window) if(i >= xctx->wires) break; } if( (entry = bus_hilight_hash_lookup(xctx->wire[i].node, 0, XLOOKUP)) ) { - if(xctx->wire[i].bus) + if(xctx->wire[i].bus == -1.0) drawline(get_color(entry->value), THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2, 0, NULL); else diff --git a/src/move.c b/src/move.c index acd9bb27..08eb6b0c 100644 --- a/src/move.c +++ b/src/move.c @@ -382,7 +382,7 @@ void draw_selection(GC g, int interruptable) double x2 = xctx->rx2 + xctx->deltax; double y2 = xctx->ry2 + xctx->deltay; dbg(1, "draw_selection() wire: %g %g - %g %g manhattan=%d\n", x1, y1, x2, y2, xctx->manhattan_lines); - if(xctx->wire[n].bus) { + if(xctx->wire[n].bus == -1.0) { drawtemp_manhattanline(g, THICK, x1, y1, x2, y2, 1); } else { drawtemp_manhattanline(g, ADD, x1, y1, x2, y2, 1); @@ -395,7 +395,7 @@ void draw_selection(GC g, int interruptable) double x2 = xctx->rx2; double y2 = xctx->ry2; dbg(1, "draw_selection() wire: %g %g - %g %g manhattan=%d\n", x1, y1, x2, y2, xctx->manhattan_lines); - if(xctx->wire[n].bus) { + if(xctx->wire[n].bus == -1.0) { drawtemp_manhattanline(g, THICK, x2, y2, x1, y1, 1); } else { drawtemp_manhattanline(g, ADD, x2, y2, x1, y1, 1); @@ -408,7 +408,7 @@ void draw_selection(GC g, int interruptable) double x2 = xctx->rx2 + xctx->deltax; double y2 = xctx->ry2 + xctx->deltay; dbg(1, "draw_selection() wire: %g %g - %g %g manhattan=%d\n", x1, y1, x2, y2, xctx->manhattan_lines); - if(xctx->wire[n].bus) { + if(xctx->wire[n].bus == -1.0) { drawtemp_manhattanline(g, THICK, x1, y1, x2, y2, 1); } else { drawtemp_manhattanline(g, ADD, x1, y1, x2, y2, 1); @@ -430,7 +430,7 @@ void draw_selection(GC g, int interruptable) ORDER(xctx->rx1,xctx->ry1,xctx->rx2,xctx->ry2); if(xctx->line[c][n].sel==SELECTED) { - if(xctx->line[c][n].bus) + if(xctx->line[c][n].bus == -1.0) drawtempline(g, THICK, xctx->rx1+xctx->deltax, xctx->ry1+xctx->deltay, xctx->rx2+xctx->deltax, xctx->ry2+xctx->deltay); else @@ -439,14 +439,14 @@ void draw_selection(GC g, int interruptable) } else if(xctx->line[c][n].sel==SELECTED1) { - if(xctx->line[c][n].bus) + if(xctx->line[c][n].bus == -1.0) drawtempline(g, THICK, xctx->rx1+xctx->deltax, xctx->ry1+xctx->deltay, xctx->rx2, xctx->ry2); else drawtempline(g, ADD, xctx->rx1+xctx->deltax, xctx->ry1+xctx->deltay, xctx->rx2, xctx->ry2); } else if(xctx->line[c][n].sel==SELECTED2) { - if(xctx->line[c][n].bus) + if(xctx->line[c][n].bus == -1.0) drawtempline(g, THICK, xctx->rx1, xctx->ry1, xctx->rx2+xctx->deltax, xctx->ry2+xctx->deltay); else drawtempline(g, ADD, xctx->rx1, xctx->ry1, xctx->rx2+xctx->deltax, xctx->ry2+xctx->deltay); diff --git a/src/psprint.c b/src/psprint.c index 1b78d324..7adb2cc3 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -521,7 +521,7 @@ static void ps_drawbezier(double *x, double *y, int points) /* Convex Nonconvex Complex */ #define Polygontype Nonconvex static void ps_drawpolygon(int c, int what, double *x, double *y, int points, - int poly_fill, int dash, int flags, int bus) + int poly_fill, int dash, int flags, double bus) { double x1,y1,x2,y2; double xx, yy; @@ -539,7 +539,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, if(dash) { fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash); } - if(bus) set_lw(BUS_WIDTH * xctx->lw); + if(bus == -1.0) set_lw(BUS_WIDTH * xctx->lw); bezier = flags && (points > 2); if(bezier) { ps_drawbezier(x, y, points); @@ -559,7 +559,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, if(dash) { fprintf(fd, "[] 0 setdash\n"); } - if(bus) set_lw(xctx->lw); + if(bus == -1.0) set_lw(xctx->lw); } @@ -634,7 +634,7 @@ static void ps_drawarc(int gc, int fillarc, double x,double y,double r,double a, } -static void ps_drawline(int gc, double linex1,double liney1,double linex2,double liney2, int dash, int bus) +static void ps_drawline(int gc, double linex1,double liney1,double linex2,double liney2, int dash, double bus) { double x1,y1,x2,y2; double psdash; @@ -647,10 +647,10 @@ static void ps_drawline(int gc, double linex1,double liney1,double linex2,double { psdash = dash / xctx->zoom; if(dash) fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash); - if(bus) set_lw(xctx->lw * BUS_WIDTH); + if(bus == -1.0) set_lw(xctx->lw * BUS_WIDTH); ps_xdrawline(gc, x1, y1, x2, y2); if(dash) fprintf(fd, "[] 0 setdash\n"); - if(bus) set_lw(xctx->lw); + if(bus == -1.0) set_lw(xctx->lw); } } diff --git a/src/save.c b/src/save.c index 0afd977b..ea25062c 100644 --- a/src/save.c +++ b/src/save.c @@ -1904,7 +1904,7 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c else if(!strcmp(n, "exch()")) stack1[stackptr1++].i = EXCH; else if(!strcmp(n, "dup()")) stack1[stackptr1++].i = DUP; else if(!strcmp(n, "idx()")) stack1[stackptr1++].i = IDX; - else if( (strtod(n, &endptr)), endptr > n) { /* NUMBER */ + else if( (strtod(n, &endptr), endptr) > n) { /* NUMBER */ stack1[stackptr1].i = NUMBER; stack1[stackptr1++].d = atof_spice(n); } @@ -2812,7 +2812,7 @@ static void load_wire(FILE *fd) } ptr[i].prop_ptr = NULL; ptr[i].end1 = ptr[i].end2 = ptr[i].sel = 0; - ptr[i].bus = 0; + ptr[i].bus = 0.0; load_ascii_string( &ptr[i].prop_ptr, fd); ORDER(ptr[i].x1, ptr[i].y1, ptr[i].x2, ptr[i].y2); ptr[i].bus = get_attr_val(get_tok_value(ptr[i].prop_ptr, "bus", 0)); diff --git a/src/select.c b/src/select.c index 0b8b0c0a..e50148c0 100644 --- a/src/select.c +++ b/src/select.c @@ -795,7 +795,7 @@ void unselect_all(int dr) xctx->wire[i].sel = 0; { if(dr) { - if(xctx->wire[i].bus) + if(xctx->wire[i].bus == -1.0) drawtempline(xctx->gctiled, THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2); else @@ -861,7 +861,7 @@ void unselect_all(int dr) { xctx->line[c][i].sel = 0; if(dr) { - if(xctx->line[c][i].bus) + if(xctx->line[c][i].bus == -1.0) drawtempline(xctx->gctiled, THICK, xctx->line[c][i].x1, xctx->line[c][i].y1, xctx->line[c][i].x2, xctx->line[c][i].y2); else @@ -926,7 +926,7 @@ void select_wire(int i,unsigned short select_mode, int fast, int override_lock) if( xctx->wire[i].sel == SELECTED) set_first_sel(WIRE, i, 0); if(select_mode) { dbg(1, "select(): wire[%d].end1=%d, ,end2=%d\n", i, xctx->wire[i].end1, xctx->wire[i].end2); - if(xctx->wire[i].bus) { + if(xctx->wire[i].bus == -1.0) { if(!(fast & 2)) drawtempline(xctx->gc[SELLAYER], THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2); } else { @@ -935,7 +935,7 @@ void select_wire(int i,unsigned short select_mode, int fast, int override_lock) } } else { - if(xctx->wire[i].bus) { + if(xctx->wire[i].bus == -1.0) { if(!(fast & 2)) drawtempline(xctx->gctiled, THICK, xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2); } else { @@ -1253,7 +1253,7 @@ void select_line(int c, int i, unsigned short select_mode, int fast, int overrid } if(xctx->line[c][i].sel == SELECTED) set_first_sel(LINE, i, c); if(select_mode) { - if(xctx->line[c][i].bus) { + if(xctx->line[c][i].bus == -1.0) { if(!(fast & 2)) drawtempline(xctx->gc[SELLAYER], THICK, xctx->line[c][i].x1, xctx->line[c][i].y1, xctx->line[c][i].x2, xctx->line[c][i].y2); } else { @@ -1262,7 +1262,7 @@ void select_line(int c, int i, unsigned short select_mode, int fast, int overrid } } else { - if(xctx->line[c][i].bus) { + if(xctx->line[c][i].bus == -1.0) { if(!(fast & 2)) drawtempline(xctx->gctiled, THICK, xctx->line[c][i].x1, xctx->line[c][i].y1, xctx->line[c][i].x2, xctx->line[c][i].y2); } else { diff --git a/src/store.c b/src/store.c index 49ec687a..abdc162c 100644 --- a/src/store.c +++ b/src/store.c @@ -250,7 +250,7 @@ int storeobject(int pos, double x1,double y1,double x2,double y2, my_strdup(_ALLOC_ID_, &xctx->line[rectc][n].prop_ptr, prop_ptr); xctx->line[rectc][n].sel=sel; if(sel == SELECTED) set_first_sel(LINE, n, rectc); - xctx->line[rectc][n].bus = 0; + xctx->line[rectc][n].bus = 0.0; if(prop_ptr) { xctx->line[rectc][n].bus = get_attr_val(get_tok_value(prop_ptr, "bus", 0)); } @@ -342,7 +342,7 @@ int storeobject(int pos, double x1,double y1,double x2,double y2, xctx->wire[n].end1=0; xctx->wire[n].end2=0; my_strdup(_ALLOC_ID_, &xctx->wire[n].prop_ptr, prop_ptr); - xctx->wire[n].bus = 0; + xctx->wire[n].bus = 0.0; if(prop_ptr) { xctx->wire[n].bus = get_attr_val(get_tok_value(prop_ptr,"bus",0)); } diff --git a/src/svgdraw.c b/src/svgdraw.c index 0d52a183..c887dbd7 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -42,11 +42,11 @@ static void svg_restore_lw(void) svg_linew = (xctx->lw <= 0.01 ? 0.2 : xctx->lw) * 1.2; } -static void svg_xdrawline(int layer, int bus, double x1, double y1, double x2, double y2, int dash) +static void svg_xdrawline(int layer, double bus, double x1, double y1, double x2, double y2, int dash) { fprintf(fd,"zoom, 1.4*dash/xctx->zoom); - if(bus) fprintf(fd, "style=\"stroke-width:%g;\" ", BUS_WIDTH * svg_linew); + if(bus == -1.0) fprintf(fd, "style=\"stroke-width:%g;\" ", BUS_WIDTH * svg_linew); fprintf(fd,"d=\"M%g %gL%g %g\"/>\n", x1, y1, x2, y2); } @@ -119,7 +119,7 @@ static void svg_drawbezier(double *x, double *y, int points) } static void svg_drawpolygon(int c, int what, double *x, double *y, int points, - int fill, int dash, int flags, int bus) + int fill, int dash, int flags, double bus) { double x1,y1,x2,y2; double xx, yy; @@ -134,8 +134,8 @@ static void svg_drawpolygon(int c, int what, double *x, double *y, int points, } fprintf(fd, "zoom, 1.4*dash/xctx->zoom); - if(bus || fill == 0 || fill == 2) { - if(bus) fprintf(fd, "style=\"stroke-width:%g; ", BUS_WIDTH * svg_linew); + if(bus == -1.0 || fill == 0 || fill == 2) { + if(bus == -1.0) fprintf(fd, "style=\"stroke-width:%g; ", BUS_WIDTH * svg_linew); else fprintf(fd, "style=\""); if(fill == 0) { fprintf(fd,"fill:none;\" "); @@ -282,7 +282,7 @@ static void svg_drawarc(int gc, int fillarc, double x,double y,double r,double a } } -static void svg_drawline(int gc, int bus, double linex1,double liney1,double linex2,double liney2, int dash) +static void svg_drawline(int gc, double bus, double linex1,double liney1,double linex2,double liney2, int dash) { double x1,y1,x2,y2; diff --git a/src/xschem.h b/src/xschem.h index d7620707..31c89bdd 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -459,7 +459,7 @@ typedef struct short sel; char *node; char *prop_ptr; - int bus; /* 20171201 cache here wire "bus" property, to avoid too many get_tok_value() calls */ + double bus; /* 20171201 cache here wire "bus" property, to avoid too many get_tok_value() calls */ } xWire; typedef struct @@ -471,7 +471,7 @@ typedef struct unsigned short sel; char *prop_ptr; short dash; - int bus; + double bus; } xLine; #if HAS_CAIRO==1 @@ -519,7 +519,7 @@ typedef struct char *prop_ptr; short fill; short dash; - int bus; + double bus; } xPoly; typedef struct @@ -1671,7 +1671,7 @@ extern char *my_strtok_r(char *str, const char *delim, const char *quote, int ke extern char **parse_cmd_string(const char *cmd, int *argc); extern int my_strncpy(char *d, const char *s, size_t n); extern int my_strcasecmp(const char *s1, const char *s2); -extern int get_attr_val(const char *str); +extern double get_attr_val(const char *str); extern int strboolcmp(const char *str, const char *boolean); extern char *my_strcasestr(const char *haystack, const char *needle); extern double mylog10(double x);