add bus attribute (thick lines) for polygon, fix rubber display of wires and lines with bus=1 (missing rectorder() in XCopyArea)

This commit is contained in:
stefan schippers 2025-04-08 01:11:15 +02:00
parent 5ee8b862ea
commit b2e5a5235e
3 changed files with 111 additions and 88 deletions

View File

@ -597,7 +597,9 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
{
int dash;
int bezier;
int bus;
polygon = &(symptr->poly[layer])[j];
bus = !strboolcmp(get_tok_value(polygon->prop_ptr, "bus", 0), "true") ? 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);
@ -607,7 +609,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
x[k]+= x0;
y[k] += y0;
}
drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier); /* added fill */
drawpolygon(c, bus, x, y, polygon->points, polygon->fill, dash, bezier); /* added fill */
my_free(_ALLOC_ID_, &x);
my_free(_ALLOC_ID_, &y);
}
@ -1349,6 +1351,7 @@ void drawtempline(GC gc, int what, double linex1,double liney1,double linex2,dou
if( clip(&x1,&y1,&x2,&y2) )
{
if((fix_broken_tiled_fill || !_unix) && gc == xctx->gctiled) {
RECTORDER(linex1, liney1, linex2, liney2);
MyXCopyAreaDouble(display, xctx->save_pixmap, xctx->window, xctx->gc[0],
linex1, liney1, linex2, liney2, linex1, liney1, BUS_WIDTH * xctx->lw);
} else {
@ -1933,12 +1936,25 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil
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) {
char dash_arr[2];
dash_arr[0] = dash_arr[1] = (char)dash;
XSetDashes(display, xctx->gc[c], 0, dash_arr, 1);
XSetLineAttributes (display, xctx->gc[c], XLINEWIDTH(xctx->lw), xDashType, xCap, xJoin);
if(what == NOW) {
if(dash) {
char dash_arr[2];
dash_arr[0] = dash_arr[1] = (char)dash;
XSetDashes(display, xctx->gc[c], 0, dash_arr, 1);
XSetLineAttributes (display, xctx->gc[c], XLINEWIDTH(xctx->lw), xDashType, xCap, xJoin);
}
} else if(what == THICK) {
if(dash) {
char dash_arr[2];
dash_arr[0] = dash_arr[1] = (char) dash;
XSetDashes(display, xctx->gc[c], 0, dash_arr, 1);
XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, xCap, xJoin);
} else {
XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, LINECAP, LINEJOIN);
}
}
if(xctx->draw_window) {
if(bezier) {
drawbezier(xctx->window, xctx->gc[c], c, x, y, points, fill ? poly_fill : 0 );
@ -1961,7 +1977,7 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil
if(xctx->draw_pixmap)
XFillPolygon(display, xctx->save_pixmap, gc, p, points, Polygontype, CoordModeOrigin);
}
if(dash) {
if(dash || what == THICK) {
XSetLineAttributes (display, xctx->gc[c], XLINEWIDTH(xctx->lw) ,LineSolid, LINECAP , LINEJOIN);
}
my_free(_ALLOC_ID_, &p);
@ -5012,8 +5028,9 @@ 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;
bezier = 2 + !strboolcmp(get_tok_value(p->prop_ptr, "bezier", 0), "true");
drawpolygon(cc, NOW, p->x, p->y, p->points, p->fill, p->dash, bezier);
drawpolygon(cc, bus, 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;

View File

@ -1264,7 +1264,7 @@ static int edit_polygon_property(void)
int oldbezier, bezier;
int k;
double x1=0., y1=0., x2=0., y2=0.;
int c, i, ii, old_dash;
int c, i, ii, old_dash, old_bus, bus;
int drw = 0;
char *oldprop = NULL;
const char *dash;
@ -1291,6 +1291,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") ;
if(oldprop && preserve == 1) {
set_different_token(&xctx->poly[c][i].prop_ptr, (char *) tclgetvar("retval"), oldprop);
} else {
@ -1299,6 +1300,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") ;
fill_ptr = get_tok_value(xctx->poly[c][i].prop_ptr,"fill",0);
if( !strcmp(fill_ptr,"full") )
@ -1313,7 +1315,8 @@ static int edit_polygon_property(void)
xctx->poly[c][i].dash = (short)(d >= 0 ? d : 0);
} else
xctx->poly[c][i].dash = 0;
if(old_fill != xctx->poly[c][i].fill || old_dash != xctx->poly[c][i].dash || oldbezier != bezier) {
if(old_fill != xctx->poly[c][i].fill || old_dash != xctx->poly[c][i].dash ||
oldbezier != bezier || old_bus != bus) {
if(!drw) {
bbox(START,0.0,0.0,0.0,0.0);
drw = 1;

View File

@ -4,83 +4,87 @@ K {}
V {}
S {}
E {}
L 14 80 -480 80 -400 {lock=0}
L 14 160 -480 160 -400 {lock=0}
L 14 240 -480 240 -400 {lock=0}
L 14 320 -480 320 -400 {lock=0}
L 14 400 -480 400 -400 {lock=0}
L 14 480 -480 480 -400 {lock=0}
L 14 560 -480 560 -400 {lock=0}
L 14 640 -480 640 -400 {lock=0}
L 14 720 -480 720 -400 {lock=0}
L 14 800 -480 800 -400 {lock=0}
L 14 880 -480 880 -400 {lock=0}
L 14 960 -480 960 -400 {lock=0}
L 14 1040 -480 1040 -400 {lock=0}
L 14 80 -400 80 -320 {lock=0}
L 14 160 -400 160 -320 {lock=0}
L 14 240 -400 240 -320 {lock=0}
L 14 320 -400 320 -320 {lock=0}
L 14 400 -400 400 -320 {lock=0}
L 14 480 -400 480 -320 {lock=0}
L 14 560 -400 560 -320 {lock=0}
L 14 640 -400 640 -320 {lock=0}
L 14 720 -400 720 -320 {lock=0}
L 14 800 -400 800 -320 {lock=0}
L 14 880 -400 880 -320 {lock=0}
L 14 960 -400 960 -320 {lock=0}
L 14 1040 -400 1040 -320 {lock=0}
L 14 0 -400 1200 -400 {lock=0}
L 14 0 -320 1200 -320 {lock=0}
L 14 120 -320 120 -240 {lock=0}
L 14 200 -320 200 -240 {lock=0}
L 14 280 -320 280 -240 {lock=0}
L 14 360 -320 360 -240 {lock=0}
L 14 440 -320 440 -240 {lock=0}
L 14 520 -320 520 -240 {lock=0}
L 14 600 -320 600 -240 {lock=0}
L 14 680 -320 680 -240 {lock=0}
L 14 760 -320 760 -240 {lock=0}
L 14 840 -320 840 -240 {lock=0}
L 14 920 -320 920 -240 {lock=0}
L 14 1000 -320 1000 -240 {lock=0}
L 14 1080 -320 1080 -240 {lock=0}
L 14 0 -240 1200 -240 {lock=0}
L 14 160 -240 160 -160 {lock=0}
L 14 240 -240 240 -160 {lock=0}
L 14 320 -240 320 -160 {lock=0}
L 14 400 -240 400 -160 {lock=0}
L 14 480 -240 480 -160 {lock=0}
L 14 560 -240 560 -160 {lock=0}
L 14 640 -240 640 -160 {lock=0}
L 14 720 -240 720 -160 {lock=0}
L 14 800 -240 800 -160 {lock=0}
L 14 880 -240 880 -160 {lock=0}
L 14 960 -240 960 -160 {lock=0}
L 14 1040 -240 1040 -160 {lock=0}
L 14 0 -160 1200 -160 {lock=0}
L 14 1120 -480 1120 -400 {lock=0}
L 14 200 -160 200 -80 {lock=0}
L 14 280 -160 280 -80 {lock=0}
L 14 360 -160 360 -80 {lock=0}
L 14 440 -160 440 -80 {lock=0}
L 14 520 -160 520 -80 {lock=0}
L 14 600 -160 600 -80 {lock=0}
L 14 680 -160 680 -80 {lock=0}
L 14 760 -160 760 -80 {lock=0}
L 14 840 -160 840 -80 {lock=0}
L 14 920 -160 920 -80 {lock=0}
L 14 1000 -160 1000 -80 {lock=0}
L 14 0 -80 1200 -80 {lock=0}
L 14 150 -80 150 0 {lock=0}
L 14 220 -80 220 0 {lock=0}
L 14 330 -80 330 0 {lock=0}
L 14 870 -80 870 0 {lock=0}
L 14 950 -80 950 0 {lock=0}
L 14 1030 -80 1030 0 {lock=0}
L 14 1200 -480 1280 -480 {lock=0}
L 14 1280 -480 1280 -400 {lock=0}
L 14 1200 -400 1280 -400 {lock=0}
L 14 80 -480 80 -400 {lock=0 bus=1}
L 14 160 -480 160 -400 {lock=0 bus=1}
L 14 240 -480 240 -400 {lock=0 bus=1}
L 14 320 -480 320 -400 {lock=0 bus=1}
L 14 400 -480 400 -400 {lock=0 bus=1}
L 14 480 -480 480 -400 {lock=0 bus=1}
L 14 560 -480 560 -400 {lock=0 bus=1}
L 14 640 -480 640 -400 {lock=0 bus=1}
L 14 720 -480 720 -400 {lock=0 bus=1}
L 14 800 -480 800 -400 {lock=0 bus=1}
L 14 880 -480 880 -400 {lock=0 bus=1}
L 14 960 -480 960 -400 {lock=0 bus=1}
L 14 1040 -480 1040 -400 {lock=0 bus=1}
L 14 80 -400 80 -320 {lock=0 bus=1}
L 14 160 -400 160 -320 {lock=0 bus=1}
L 14 240 -400 240 -320 {lock=0 bus=1}
L 14 320 -400 320 -320 {lock=0 bus=1}
L 14 400 -400 400 -320 {lock=0 bus=1}
L 14 480 -400 480 -320 {lock=0 bus=1}
L 14 560 -400 560 -320 {lock=0 bus=1}
L 14 640 -400 640 -320 {lock=0 bus=1}
L 14 720 -400 720 -320 {lock=0 bus=1}
L 14 800 -400 800 -320 {lock=0 bus=1}
L 14 880 -400 880 -320 {lock=0 bus=1}
L 14 960 -400 960 -320 {lock=0 bus=1}
L 14 1040 -400 1040 -320 {lock=0 bus=1}
L 14 0 -400 1200 -400 {lock=0 bus=1}
L 14 0 -320 1200 -320 {lock=0 bus=1}
L 14 120 -320 120 -240 {lock=0 bus=1}
L 14 200 -320 200 -240 {lock=0 bus=1}
L 14 280 -320 280 -240 {lock=0 bus=1}
L 14 360 -320 360 -240 {lock=0 bus=1}
L 14 440 -320 440 -240 {lock=0 bus=1}
L 14 520 -320 520 -240 {lock=0 bus=1}
L 14 600 -320 600 -240 {lock=0 bus=1}
L 14 680 -320 680 -240 {lock=0 bus=1}
L 14 760 -320 760 -240 {lock=0 bus=1}
L 14 840 -320 840 -240 {lock=0 bus=1}
L 14 920 -320 920 -240 {lock=0 bus=1}
L 14 1000 -320 1000 -240 {lock=0 bus=1}
L 14 1080 -320 1080 -240 {lock=0 bus=1}
L 14 0 -240 1200 -240 {lock=0 bus=1}
L 14 160 -240 160 -160 {lock=0 bus=1}
L 14 240 -240 240 -160 {lock=0 bus=1}
L 14 320 -240 320 -160 {lock=0 bus=1}
L 14 400 -240 400 -160 {lock=0 bus=1}
L 14 480 -240 480 -160 {lock=0 bus=1}
L 14 560 -240 560 -160 {lock=0 bus=1}
L 14 640 -240 640 -160 {lock=0 bus=1}
L 14 720 -240 720 -160 {lock=0 bus=1}
L 14 800 -240 800 -160 {lock=0 bus=1}
L 14 880 -240 880 -160 {lock=0 bus=1}
L 14 960 -240 960 -160 {lock=0 bus=1}
L 14 1040 -240 1040 -160 {lock=0 bus=1}
L 14 0 -160 1200 -160 {lock=0 bus=1}
L 14 1120 -480 1120 -400 {lock=0 bus=1}
L 14 200 -160 200 -80 {lock=0 bus=1}
L 14 280 -160 280 -80 {lock=0 bus=1}
L 14 360 -160 360 -80 {lock=0 bus=1}
L 14 440 -160 440 -80 {lock=0 bus=1}
L 14 520 -160 520 -80 {lock=0 bus=1}
L 14 600 -160 600 -80 {lock=0 bus=1}
L 14 680 -160 680 -80 {lock=0 bus=1}
L 14 760 -160 760 -80 {lock=0 bus=1}
L 14 840 -160 840 -80 {lock=0 bus=1}
L 14 920 -160 920 -80 {lock=0 bus=1}
L 14 1000 -160 1000 -80 {lock=0 bus=1}
L 14 0 -80 1200 -80 {lock=0 bus=1}
L 14 150 -80 150 0 {lock=0 bus=1}
L 14 220 -80 220 0 {lock=0 bus=1}
L 14 330 -80 330 0 {lock=0 bus=1}
L 14 870 -80 870 0 {lock=0 bus=1}
L 14 950 -80 950 0 {lock=0 bus=1}
L 14 1030 -80 1030 0 {lock=0 bus=1}
L 14 1200 -480 1280 -480 {lock=0 bus=1}
L 14 1280 -480 1280 -400 {lock=0 bus=1}
L 14 1200 -400 1280 -400 {lock=0 bus=1}
L 14 0 -480 1200 -480 {lock=0 bus=1}
L 14 1200 -480 1200 -0 {lock=0 bus=1}
L 14 0 -0 1200 -0 {lock=0 bus=1}
L 14 0 -480 0 -0 {lock=0 bus=1}
B 4 1205 -330 1280 -310 {fill=full
lock=0}
B 6 1205 -310 1280 -290 {fill=full
@ -93,7 +97,6 @@ B 10 1205 -390 1280 -370 {fill=full
lock=0}
B 12 1205 -290 1280 -270 {fill=full
lock=0}
P 14 5 0 -480 1200 -480 1200 0 0 0 0 -480 {lock=0}
T {Esc} 2.5 -477.5 0 0 0.4 0.4 {lock=0}
T {F1} 82.5 -477.5 0 0 0.4 0.4 {lock=0}
T {F2} 162.5 -477.5 0 0 0.4 0.4 {lock=0}