Honor `bus` attribute on lines / wires / polygons in svg and pdf exports

This commit is contained in:
stefan schippers 2025-04-14 12:31:59 +02:00
parent f22307afad
commit b74c0f4ac4
10 changed files with 111 additions and 87 deletions

View File

@ -218,10 +218,8 @@ void trim_wires(void)
}
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[j].prop_ptr);
if(!strboolcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
xctx->wire[xctx->wires].bus=1;
else
xctx->wire[xctx->wires].bus=0;
xctx->wire[xctx->wires].bus =
get_attr_val(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0));
xctx->wire[xctx->wires].node=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].node, xctx->wire[j].node);
@ -500,10 +498,8 @@ void break_wires_at_point(double x0, double y0, int align)
xctx->wire[xctx->wires].sel=0;
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strboolcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
xctx->wire[xctx->wires].bus=1;
else
xctx->wire[xctx->wires].bus=0;
xctx->wire[xctx->wires].bus =
get_attr_val(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0));
xctx->wire[xctx->wires].node=NULL;
hash_wire(XINSERT, xctx->wires, 0); /* insertion happens at beginning of list */
dbg(1, "break_wires_at_pins(): hashing new wire %d: %g %g %g %g\n",
@ -577,10 +573,8 @@ void break_wires_at_pins(int remove)
xctx->wire[xctx->wires].sel=xctx->wire[i].sel;
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strboolcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
xctx->wire[xctx->wires].bus=1;
else
xctx->wire[xctx->wires].bus=0;
xctx->wire[xctx->wires].bus =
get_attr_val(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus", 0));
xctx->wire[xctx->wires].node=NULL;
hash_wire(XINSERT, xctx->wires, 0); /* insertion happens at beginning of list */
dbg(1, "break_wires_at_pins(): hashing new wire %d: %g %g %g %g\n",
@ -673,10 +667,8 @@ void break_wires_at_pins(int remove)
set_first_sel(WIRE, xctx->wires, 0);
xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strboolcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
xctx->wire[xctx->wires].bus=1;
else
xctx->wire[xctx->wires].bus=0;
xctx->wire[xctx->wires].bus =
get_attr_val(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0));
xctx->wire[xctx->wires].node=NULL;
hash_wire(XINSERT, xctx->wires, 0); /* insertion happens at beginning of list */
xctx->need_reb_sel_arr=1;

View File

@ -599,7 +599,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 = !strboolcmp(get_tok_value(polygon->prop_ptr, "bus", 0), "true") ? THICK : NOW;
bus = get_attr_val(get_tok_value(polygon->prop_ptr, "bus", 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);
@ -2389,7 +2389,7 @@ int graph_fullxzoom(int i, Graph_ctx *gr, int dataset)
const char *ptr;
raw = xctx->raw;
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1");
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "true");
if(autoload == 0) autoload = 2;
ptr = get_tok_value(r->prop_ptr,"rawfile", 0);
if(!ptr[0]) {
@ -2487,7 +2487,7 @@ int graph_fullyzoom(xRect *r, Graph_ctx *gr, int graph_dataset)
int autoload = 0, save_datasets = -1, save_npoints = -1;
const char *ptr;
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1");
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "true");
if(autoload == 0) autoload = 2;
dbg(1, "graph_fullyzoom(): graph_dataset=%d\n", graph_dataset);
my_strdup2(_ALLOC_ID_, &node, get_tok_value(r->prop_ptr,"node", 0));
@ -3694,7 +3694,7 @@ int find_closest_wave(int i, Graph_ctx *gr)
}
if(gr->digital) return -1;
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1");
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "true");
if(autoload == 0) autoload = 2;
yval = G_Y(xctx->mousey);
xval = G_X(xctx->mousex);
@ -3912,7 +3912,7 @@ void draw_graph(int i, int flags, Graph_ctx *gr, void *ct)
clear_cairo_surface(xctx->cairo_save_ctx, gr->sx1, gr->sy1, sw, sh);
clear_cairo_surface(xctx->cairo_ctx, gr->sx1, gr->sy1, sw, sh);
#endif
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1");
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "true");
if(autoload == 0) autoload = 2; /* 2: switch */
else if(autoload == 1) autoload = 33; /* 1: read, 32: no_warning */
/* graph box, gridlines and axes */
@ -5028,7 +5028,7 @@ void draw(void)
if(draw_layer && xctx->enable_layer[c]) for(i=0;i<xctx->polygons[c]; ++i) {
int bezier;
xPoly *p = &xctx->poly[c][i];
int bus = !strboolcmp(get_tok_value(p->prop_ptr, "bus", 0), "true") ? THICK : NOW;
int bus = get_attr_val(get_tok_value(p->prop_ptr, "bus", 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);
}

View File

@ -79,20 +79,47 @@ 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
*/
int get_attr_val(const char *str)
{
int s = 0;
if(isonlydigit(str)) {
s = atoi(str);
}
else if(!my_strcasecmp(str, "true") ||
!my_strcasecmp(str, "on") ||
!my_strcasecmp(str, "yes")) s = 1;
else if(!my_strcasecmp(str, "false") ||
!my_strcasecmp(str, "off") ||
!my_strcasecmp(str, "no")) s = 0;
return s;
}
/* same as case insensitive strcmp(), but allow '1, true, on, yes' for true value
* any integer > 0 on str considered as 1
* both in str and boolean */
int strboolcmp(const char *str, const char *boolean)
{
int retval, s = 0, b = 0;
int strval = -1;
if(!my_strcasecmp(boolean, "true")) b = 1;
else if(!my_strcasecmp(boolean, "false")) b = 0;
else b = -1;
if(!my_strcasecmp(str, "true") ||
!my_strcasecmp(str, "1") ||
if(isonlydigit(str)) {
strval = atoi(str);
s = strval ? 1 : 0;
}
else if(!my_strcasecmp(str, "true") ||
!my_strcasecmp(str, "on") ||
!my_strcasecmp(str, "yes")) s = 1;
else if(!my_strcasecmp(str, "false") ||
!my_strcasecmp(str, "0") ||
!my_strcasecmp(str, "off") ||
!my_strcasecmp(str, "no")) s = 0;
else s = -1;
@ -1100,7 +1127,7 @@ static int edit_line_property(void)
my_strdup(_ALLOC_ID_, &xctx->line[c][n].prop_ptr,
(char *) tclgetvar("retval"));
}
xctx->line[c][n].bus = !strboolcmp(get_tok_value(xctx->line[c][n].prop_ptr,"bus",0), "true");
xctx->line[c][n].bus = get_attr_val(get_tok_value(xctx->line[c][n].prop_ptr,"bus",0));
dash = get_tok_value(xctx->line[c][n].prop_ptr,"dash",0);
if( strcmp(dash, "") ) {
int d = atoi(dash);
@ -1129,7 +1156,7 @@ static int edit_wire_property(void)
int i, modified = 0;
int preserve;
char *oldprop=NULL;
const char *bus_ptr;
int bus;
my_strdup(_ALLOC_ID_, &oldprop, xctx->wire[xctx->sel_array[0].n].prop_ptr);
if(oldprop && oldprop[0]) {
@ -1159,8 +1186,8 @@ static int edit_wire_property(void)
} else {
my_strdup(_ALLOC_ID_, &xctx->wire[k].prop_ptr,(char *) tclgetvar("retval"));
}
bus_ptr = get_tok_value(xctx->wire[k].prop_ptr,"bus",0);
if(!strboolcmp(bus_ptr, "true")) {
bus = get_attr_val(get_tok_value(xctx->wire[k].prop_ptr,"bus",0));
if(bus) {
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; }
@ -1291,7 +1318,7 @@ static int edit_polygon_property(void)
c = xctx->sel_array[ii].col;
oldbezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr,"bezier",0),"true") ;
old_bus = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0),"true") ;
old_bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0));
if(oldprop && preserve == 1) {
set_different_token(&xctx->poly[c][i].prop_ptr, (char *) tclgetvar("retval"), oldprop);
} else {
@ -1300,7 +1327,7 @@ static int edit_polygon_property(void)
old_fill = xctx->poly[c][i].fill;
old_dash = xctx->poly[c][i].dash;
bezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr,"bezier",0),"true") ;
bus = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0),"true") ;
bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0));
fill_ptr = get_tok_value(xctx->poly[c][i].prop_ptr,"fill",0);
if( !strcmp(fill_ptr,"full") )

View File

@ -267,10 +267,7 @@ static void merge_line(FILE *fd)
} else {
ptr[i].dash = 0;
}
if(!strboolcmp(get_tok_value(ptr[i].prop_ptr, "bus", 0), "true") )
ptr[i].bus = 1;
else
ptr[i].bus = 0;
ptr[i].bus = get_attr_val(get_tok_value(ptr[i].prop_ptr, "bus", 0));
select_line(c,i, SELECTED, 1, 1);
xctx->lines[c]++;
}

View File

@ -402,12 +402,12 @@ static int ps_embedded_graph(int i, double rx1, double ry1, double rx2, double r
#endif
return 1;
}
static void set_lw(void)
static void set_lw(double lw)
{
if(xctx->lw==0.0)
fprintf(fd, "%g setlinewidth\n",0.5);
if(lw==0.0)
fprintf(fd, "%g setlinewidth\n", 0.5);
else
fprintf(fd, "%g setlinewidth\n",xctx->lw/1.2);
fprintf(fd, "%g setlinewidth\n", lw / 1.2);
}
static void set_ps_colors(unsigned int pixel)
@ -519,7 +519,8 @@ 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)
static void ps_drawpolygon(int c, int what, double *x, double *y, int points,
int poly_fill, int dash, int flags, int bus)
{
double x1,y1,x2,y2;
double xx, yy;
@ -537,6 +538,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, in
if(dash) {
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
}
if(bus) set_lw(BUS_WIDTH * xctx->lw);
bezier = flags && (points > 2);
if(bezier) {
ps_drawbezier(x, y, points);
@ -556,6 +558,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, in
if(dash) {
fprintf(fd, "[] 0 setdash\n");
}
if(bus) set_lw(xctx->lw);
}
@ -625,7 +628,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)
static void ps_drawline(int gc, double linex1,double liney1,double linex2,double liney2, int dash, int bus)
{
double x1,y1,x2,y2;
double psdash;
@ -637,13 +640,11 @@ static void ps_drawline(int gc, double linex1,double liney1,double linex2,double
if( clip(&x1,&y1,&x2,&y2) )
{
psdash = dash / xctx->zoom;
if(dash) {
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
}
if(dash) fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
if(bus) set_lw(xctx->lw * BUS_WIDTH);
ps_xdrawline(gc, x1, y1, x2, y2);
if(dash) {
fprintf(fd, "[] 0 setdash\n");
}
if(dash) fprintf(fd, "[] 0 setdash\n");
if(bus) set_lw(xctx->lw);
}
}
@ -847,7 +848,7 @@ static void old_ps_draw_string(int gctext, const char *str,
ROTATION(rot, flip, x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(rot, flip, x1,y1,curr_x2,curr_y2,rx2,ry2);
ORDER(rx1,ry1,rx2,ry2);
ps_drawline(gctext, rx1, ry1, rx2, ry2, 0);
ps_drawline(gctext, rx1, ry1, rx2, ry2, 0, 0);
}
++pos;
}
@ -1017,14 +1018,16 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
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);
ps_drawline(c, x0+x1, y0+y1, x0+x2, y0+y2, dash);
ps_drawline(c, x0+x1, y0+y1, x0+x2, y0+y2, dash, line->bus);
}
for(j=0;j< symptr->polygons[layer]; ++j)
{
int dash;
int bezier;
int bus;
polygon = &(symptr->poly[layer])[j];
bezier = !strboolcmp(get_tok_value(polygon->prop_ptr, "bezier", 0), "true");
bus = get_attr_val(get_tok_value(polygon->prop_ptr, "bus", 0));
dash = (disabled == 1) ? 3 : polygon->dash;
{ /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */
int k;
@ -1035,7 +1038,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho
x[k]+= x0;
y[k] += y0;
}
ps_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier);
ps_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier, bus);
my_free(_ALLOC_ID_, &x);
my_free(_ALLOC_ID_, &y);
}
@ -1423,7 +1426,7 @@ void create_ps(char **psfile, int what, int fullzoom, int eps)
fprintf(fd, "%g %g scale\n", scale, -scale);
fprintf(fd, "1 setlinejoin 1 setlinecap\n");
set_lw();
set_lw(xctx->lw);
ps_drawgrid();
for(c=0;c<cadlayers; ++c)
@ -1431,7 +1434,7 @@ void create_ps(char **psfile, int what, int fullzoom, int eps)
set_ps_colors(c);
for(i=0;i<xctx->lines[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);
xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash, xctx->line[c][i].bus);
if(xctx->rects[c]) fprintf(fd, "NP\n"); /* newpath */
for(i=0;i<xctx->rects[c]; ++i)
{
@ -1461,8 +1464,9 @@ void create_ps(char **psfile, int what, int fullzoom, int eps)
}
for(i=0;i<xctx->polygons[c]; ++i) {
int bezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr, "bezier", 0), "true");
int bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr, "bus", 0));
ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points,
xctx->poly[c][i].fill, xctx->poly[c][i].dash, bezier);
xctx->poly[c][i].fill, xctx->poly[c][i].dash, bezier, bus);
}
dbg(1, "create_ps(): starting drawing symbols on layer %d\n", c);
} /* for(c=0;c<cadlayers; ++c) */
@ -1481,7 +1485,8 @@ void create_ps(char **psfile, int what, int fullzoom, int eps)
color = get_color(entry->value);
}
set_ps_colors(color);
ps_drawline(color, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0);
ps_drawline(color, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2,
0 ,xctx->wire[i].bus);
}
{

View File

@ -2799,10 +2799,11 @@ static void load_wire(FILE *fd)
return;
}
ptr[i].prop_ptr = NULL;
ptr[i].end1 = ptr[i].end2 = ptr[i].bus = ptr[i].sel = 0;
ptr[i].end1 = ptr[i].end2 = ptr[i].sel = 0;
ptr[i].bus = 0;
load_ascii_string( &ptr[i].prop_ptr, fd);
ORDER(ptr[i].x1, ptr[i].y1, ptr[i].x2, ptr[i].y2);
if(!strboolcmp(get_tok_value(ptr[i].prop_ptr, "bus", 0), "true") ) ptr[i].bus = 1;
ptr[i].bus = get_attr_val(get_tok_value(ptr[i].prop_ptr, "bus", 0));
ptr[i].node = NULL;
xctx->wires++;
}
@ -3043,12 +3044,7 @@ static void load_line(FILE *fd)
ptr[i].prop_ptr=NULL;
ptr[i].sel=0;
load_ascii_string( &ptr[i].prop_ptr, fd);
if(!strboolcmp(get_tok_value(ptr[i].prop_ptr, "bus", 0), "true") )
ptr[i].bus = 1;
else
ptr[i].bus = 0;
ptr[i].bus = get_attr_val(get_tok_value(ptr[i].prop_ptr, "bus", 0));
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
if(strcmp(dash, "")) {
int d = atoi(dash);
@ -4438,10 +4434,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
}
ORDER(ll[c][i].x1, ll[c][i].y1, ll[c][i].x2, ll[c][i].y2);
dbg(2, "l_s_d(): loaded line: ptr=%lx\n", (unsigned long)ll[c]);
if(!strboolcmp(get_tok_value(ll[c][i].prop_ptr,"bus", 0), "true") )
ll[c][i].bus = 1;
else
ll[c][i].bus = 0;
ll[c][i].bus = get_attr_val(get_tok_value(ll[c][i].prop_ptr,"bus", 0));
attr = get_tok_value(ll[c][i].prop_ptr,"dash", 0);
if( strcmp(attr, "") ) {
int d = atoi(attr);
@ -4799,10 +4792,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
ORDER(ll[WIRELAYER][i].x1, ll[WIRELAYER][i].y1, ll[WIRELAYER][i].x2, ll[WIRELAYER][i].y2);
dbg(2, "l_s_d(): loaded line: ptr=%lx\n", (unsigned long)ll[WIRELAYER]);
ll[WIRELAYER][i].dash = 0;
if(!strboolcmp(get_tok_value(ll[WIRELAYER][i].prop_ptr, "bus", 0), "true"))
ll[WIRELAYER][i].bus = 1;
else
ll[WIRELAYER][i].bus = 0;
ll[WIRELAYER][i].bus = get_attr_val(get_tok_value(ll[WIRELAYER][i].prop_ptr, "bus", 0));
ll[WIRELAYER][i].sel = 0;
lastl[WIRELAYER]++;
break;

View File

@ -250,10 +250,10 @@ 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);
if( prop_ptr && !strboolcmp(get_tok_value(prop_ptr, "bus", 0), "true") )
xctx->line[rectc][n].bus = 1;
else
xctx->line[rectc][n].bus = 0;
xctx->line[rectc][n].bus = 0;
if(prop_ptr) {
xctx->line[rectc][n].bus = get_attr_val(get_tok_value(prop_ptr, "bus", 0));
}
if(prop_ptr && (attr = get_tok_value(prop_ptr,"dash",0))[0]) {
int d = atoi(attr);
xctx->line[rectc][n].dash = (char) (d >= 0 ? d : 0);
@ -342,8 +342,10 @@ 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);
if(prop_ptr && !strboolcmp(get_tok_value(prop_ptr,"bus",0), "true")) xctx->wire[n].bus=1;
else xctx->wire[n].bus=0;
xctx->wire[n].bus = 0;
if(prop_ptr) {
xctx->wire[n].bus = get_attr_val(get_tok_value(prop_ptr,"bus",0));
}
xctx->wire[n].sel=sel;
if(sel == SELECTED) set_first_sel(WIRE, n, 0);
xctx->wires++;

View File

@ -118,7 +118,8 @@ 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)
static void svg_drawpolygon(int c, int what, double *x, double *y, int points,
int fill, int dash, int flags, int bus)
{
double x1,y1,x2,y2;
double xx, yy;
@ -133,10 +134,16 @@ static void svg_drawpolygon(int c, int what, double *x, double *y, int points, i
}
fprintf(fd, "<path class=\"l%d\" ", c);
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 == 2) {
fprintf(fd, "style=\"fill-opacity:1.0;\" ");
if(bus || fill == 0 || fill == 2) {
if(bus) fprintf(fd, "style=\"stroke-width:%g; ", BUS_WIDTH * svg_linew);
else fprintf(fd, "style=\"");
if(fill == 0) {
fprintf(fd,"fill:none;\" ");
} else if(fill == 2) {
fprintf(fd, "fill-opacity:1.0;\" ");
} else {
fprintf(fd, "\" ");
}
}
bezier = flags && (points > 2);
if(bezier) {
@ -702,7 +709,9 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
for(j=0;j< symptr->polygons[layer]; ++j) {
int dash;
int bezier;
int bus;
polygon =&(symptr->poly[layer])[j];
bus = get_attr_val(get_tok_value(polygon->prop_ptr, "bus", 0));
bezier = !strboolcmp(get_tok_value(polygon->prop_ptr, "bezier", 0), "true");
dash = (disabled == 1) ? 3 : polygon->dash;
{ /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */
@ -714,7 +723,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
x[k]+= x0;
y[k] += y0;
}
svg_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier);
svg_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier, bus);
my_free(_ALLOC_ID_, &x);
my_free(_ALLOC_ID_, &y);
}
@ -1062,8 +1071,9 @@ void svg_draw(void)
}
for(i=0;i<xctx->polygons[c]; ++i) {
int bezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr, "bezier", 0), "true");
int bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr, "bus", 0));
svg_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points,
xctx->poly[c][i].fill, xctx->poly[c][i].dash, bezier);
xctx->poly[c][i].fill, xctx->poly[c][i].dash, bezier, bus);
}
for(i=0;i<xctx->instances; ++i) {
svg_draw_symbol(c,i,c,0,0,0.0,0.0);

View File

@ -3464,7 +3464,7 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int
int isonlydigit(const char *s)
{
char c;
int res = 1;
int res = 0;
int first = 1;
if(s == NULL || *s == '\0') return 0;
while( (c = *s++) ) {
@ -3477,7 +3477,7 @@ int isonlydigit(const char *s)
if(c < '0' || c > '9') {
res = 0;
break;
}
} else res = 1;
}
return res;
}

View File

@ -452,7 +452,7 @@ typedef struct
short sel;
char *node;
char *prop_ptr;
short bus; /* 20171201 cache here wire "bus" property, to avoid too many get_tok_value() calls */
int bus; /* 20171201 cache here wire "bus" property, to avoid too many get_tok_value() calls */
} xWire;
typedef struct
@ -464,7 +464,7 @@ typedef struct
unsigned short sel;
char *prop_ptr;
short dash;
short bus;
int bus;
} xLine;
#if HAS_CAIRO==1
@ -1644,6 +1644,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 int strboolcmp(const char *str, const char *boolean);
extern char *my_strcasestr(const char *haystack, const char *needle);
extern double mylog10(double x);