From f25b40861c0d93c9ceb551e91999923e96ceacb4 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 29 Nov 2025 00:47:46 +0100 Subject: [PATCH] allow arbitrary widths (via ex. bus=5.0 attr) on wires --- src/actions.c | 20 +++++----- src/draw.c | 104 ++++++++++++++++++++++++++++++------------------ src/editprop.c | 51 +++++++++++++----------- src/hilight.c | 6 +-- src/scheduler.c | 11 +++-- src/xschem.h | 2 +- 6 files changed, 115 insertions(+), 79 deletions(-) diff --git a/src/actions.c b/src/actions.c index 3fc98697..4d86011f 100644 --- a/src/actions.c +++ b/src/actions.c @@ -3185,7 +3185,7 @@ void new_wire(int what, double mx_snap, double my_snap) storeobject(-1, nl_xx1,nl_yy1,nl_xx2,nl_yy1,WIRE,0,0,NULL); modified = 1; hash_wire(XINSERT, xctx->wires-1, 1); - drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy1, 0, NULL); + drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy1, 0.0, 0, NULL); } if(xctx->nl_y2!=xctx->nl_y1) { nl_xx1 = xctx->nl_x1; nl_yy1 = xctx->nl_y1; @@ -3194,7 +3194,7 @@ void new_wire(int what, double mx_snap, double my_snap) storeobject(-1, nl_xx2,nl_yy1,nl_xx2,nl_yy2,WIRE,0,0,NULL); modified = 1; hash_wire(XINSERT, xctx->wires-1, 1); - drawline(WIRELAYER,NOW, nl_xx2,nl_yy1,nl_xx2,nl_yy2, 0, NULL); + drawline(WIRELAYER,NOW, nl_xx2,nl_yy1,nl_xx2,nl_yy2, 0.0, 0, NULL); } } else if(xctx->manhattan_lines & 2) { if(xctx->nl_y2!=xctx->nl_y1) { @@ -3204,7 +3204,7 @@ void new_wire(int what, double mx_snap, double my_snap) storeobject(-1, nl_xx1,nl_yy1,nl_xx1,nl_yy2,WIRE,0,0,NULL); modified = 1; hash_wire(XINSERT, xctx->wires-1, 1); - drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx1,nl_yy2, 0, NULL); + drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx1,nl_yy2, 0.0, 0, NULL); } if(xctx->nl_x2!=xctx->nl_x1) { nl_xx1=xctx->nl_x1;nl_yy1=xctx->nl_y1; @@ -3213,7 +3213,7 @@ void new_wire(int what, double mx_snap, double my_snap) storeobject(-1, nl_xx1,nl_yy2,nl_xx2,nl_yy2,WIRE,0,0,NULL); modified = 1; hash_wire(XINSERT, xctx->wires-1, 1); - drawline(WIRELAYER,NOW, nl_xx1,nl_yy2,nl_xx2,nl_yy2, 0, NULL); + drawline(WIRELAYER,NOW, nl_xx1,nl_yy2,nl_xx2,nl_yy2, 0.0, 0, NULL); } } else { nl_xx1 = xctx->nl_x1; nl_yy1 = xctx->nl_y1; @@ -3222,7 +3222,7 @@ void new_wire(int what, double mx_snap, double my_snap) storeobject(-1, nl_xx1,nl_yy1,nl_xx2,nl_yy2,WIRE,0,0,NULL); modified = 1; hash_wire(XINSERT, xctx->wires-1, 1); - drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy2, 0, NULL); + drawline(WIRELAYER,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy2, 0.0, 0, NULL); } xctx->prep_hi_structs = 0; if(tclgetboolvar("autotrim_wires")) trim_wires(); @@ -3390,7 +3390,7 @@ void new_line(int what, double mx_snap, double my_snap) ORDER(nl_xx1,nl_yy1,nl_xx2,nl_yy1); storeobject(-1, nl_xx1,nl_yy1,nl_xx2,nl_yy1,LINE,xctx->rectcolor,0,NULL); modified = 1; - drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy1, 0, NULL); + drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy1, 0.0, 0, NULL); } if(xctx->nl_y2!=xctx->nl_y1) { nl_xx1 = xctx->nl_x1; nl_yy1 = xctx->nl_y1; @@ -3398,7 +3398,7 @@ void new_line(int what, double mx_snap, double my_snap) ORDER(nl_xx2,nl_yy1,nl_xx2,nl_yy2); storeobject(-1, nl_xx2,nl_yy1,nl_xx2,nl_yy2,LINE,xctx->rectcolor,0,NULL); modified = 1; - drawline(xctx->rectcolor,NOW, nl_xx2,nl_yy1,nl_xx2,nl_yy2, 0, NULL); + drawline(xctx->rectcolor,NOW, nl_xx2,nl_yy1,nl_xx2,nl_yy2, 0.0, 0, NULL); } } else if(xctx->manhattan_lines & 2) { if(xctx->nl_y2!=xctx->nl_y1) { @@ -3407,7 +3407,7 @@ void new_line(int what, double mx_snap, double my_snap) ORDER(nl_xx1,nl_yy1,nl_xx1,nl_yy2); storeobject(-1, nl_xx1,nl_yy1,nl_xx1,nl_yy2,LINE,xctx->rectcolor,0,NULL); modified = 1; - drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx1,nl_yy2, 0, NULL); + drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx1,nl_yy2, 0.0, 0, NULL); } if(xctx->nl_x2!=xctx->nl_x1) { nl_xx1=xctx->nl_x1;nl_yy1=xctx->nl_y1; @@ -3415,7 +3415,7 @@ void new_line(int what, double mx_snap, double my_snap) ORDER(nl_xx1,nl_yy2,nl_xx2,nl_yy2); storeobject(-1, nl_xx1,nl_yy2,nl_xx2,nl_yy2,LINE,xctx->rectcolor,0,NULL); modified = 1; - drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy2,nl_xx2,nl_yy2, 0, NULL); + drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy2,nl_xx2,nl_yy2, 0.0, 0, NULL); } } else { nl_xx1 = xctx->nl_x1; nl_yy1 = xctx->nl_y1; @@ -3423,7 +3423,7 @@ void new_line(int what, double mx_snap, double my_snap) ORDER(nl_xx1,nl_yy1,nl_xx2,nl_yy2); storeobject(-1, nl_xx1,nl_yy1,nl_xx2,nl_yy2,LINE,xctx->rectcolor,0,NULL); modified = 1; - drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy2, 0, NULL); + drawline(xctx->rectcolor,NOW, nl_xx1,nl_yy1,nl_xx2,nl_yy2, 0.0, 0, NULL); } if(modified) set_modify(1); } diff --git a/src/draw.c b/src/draw.c index 5981d2da..ca3d000f 100644 --- a/src/draw.c +++ b/src/draw.c @@ -533,7 +533,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in 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); - drawline(layer, what, rx1, ry1, rx2, ry2, 0, NULL); + drawline(layer, what, rx1, ry1, rx2, ry2, 0.0, 0, NULL); } ++pos; a += FONTWIDTH+FONTWHITESPACE; @@ -734,9 +734,9 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, ROTATION(rot, flip, 0.0, 0.0,line->x2,line->y2,x2,y2); ORDER(x1,y1,x2,y2); if(line->bus == -1.0) - drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, dash, NULL); + drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, line->bus, dash, NULL); else - drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, dash, NULL); + drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, line->bus, dash, NULL); } for(j=0;j< symptr->polygons[layer]; ++j) { @@ -887,7 +887,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, my_free(_ALLOC_ID_, &txtptr); #if HAS_CAIRO!=1 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0, -1, -1); - drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0, NULL); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, NULL); #endif #if HAS_CAIRO==1 if( (textfont && textfont[0]) || (symptr->text[j].flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { @@ -1325,7 +1325,8 @@ void draw_xhair_line(GC gc, int size, double linex1, double liney1, double linex } } -void drawline(int c, int what, double linex1, double liney1, double linex2, double liney2, int dash, void *ct) +void drawline(int c, int what, double linex1, double liney1, double linex2, double liney2, + double bus, int dash, void *ct) { static int i = 0; #ifndef __unix__ @@ -1335,6 +1336,18 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub double x1,y1,x2,y2; register XSegment *rr; char dash_arr[2]; + int width; + + if(bus == -1.0) { + what = THICK; + width = INT_BUS_WIDTH(xctx->lw); + } else if(bus > 0.0) { + what = NOW; + width = (int) (bus * xctx->mooz); + } else { + width = XLINEWIDTH(xctx->lw); + } + if(dash && what !=THICK) what = NOW; @@ -1384,10 +1397,25 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub XSetDashes(display, xctx->gc[c], 0, dash_arr, 1); XSetLineAttributes (display, xctx->gc[c], XLINEWIDTH(xctx->lw), xDashType, xCap, xJoin); } + + + if(dash) { + dash_arr[0] = dash_arr[1] = (char)dash; + XSetDashes(display, xctx->gc[c], 0, dash_arr, 1); + XSetLineAttributes (display, xctx->gc[c], width, xDashType, xCap, xJoin); + } else if(bus > 0.0) { + XSetLineAttributes (display, xctx->gc[c], width, LineSolid, CapProjecting, JoinMiter); + } else if(bus == -1.0) { + XSetLineAttributes (display, xctx->gc[c], width, LineSolid, LINECAP, LINEJOIN); + } + + + + if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2); if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2); - if(dash) { + if(dash || bus > 0.0) { XSetLineAttributes (display, xctx->gc[c], XLINEWIDTH(xctx->lw), LineSolid, LINECAP, LINEJOIN); } } @@ -2886,8 +2914,8 @@ static void draw_graph_bus_points(const char *ntok, int n_bits, SPICE_DATA **idx } if(c1 >= gr->ypos1 && c1 <=gr->ypos2) { set_thick_waves(1, wcnt, wave_col, gr); - drawline(wave_col, NOW, lx1, ylow, lx2, ylow, 0, ct); - drawline(wave_col, NOW, lx1, yhigh, lx2, yhigh, 0, ct); + drawline(wave_col, NOW, lx1, ylow, lx2, ylow, 0.0, 0, ct); + drawline(wave_col, NOW, lx1, yhigh, lx2, yhigh, 0.0, 0, ct); for(p = first ; p <= last; p++) { /* calculate value of bus by adding all binary bits */ /* hex_digits = */ @@ -2904,10 +2932,10 @@ static void draw_graph_bus_points(const char *ntok, int n_bits, SPICE_DATA **idx } if(p > first && strcmp(busval, old_busval)) { /* draw transition ('X') */ - drawline(BACKLAYER, NOW, xval-x_size, yhigh, xval+x_size, yhigh, 0, ct); - drawline(BACKLAYER, NOW, xval-x_size, ylow, xval+x_size, ylow, 0, ct); - drawline(wave_col, NOW, xval-x_size, ylow, xval+x_size, yhigh, 0, ct); - drawline(wave_col, NOW, xval-x_size, yhigh, xval+x_size, ylow, 0, ct); + drawline(BACKLAYER, NOW, xval-x_size, yhigh, xval+x_size, yhigh, 0.0, 0, ct); + drawline(BACKLAYER, NOW, xval-x_size, ylow, xval+x_size, ylow, 0.0, 0, ct); + drawline(wave_col, NOW, xval-x_size, ylow, xval+x_size, yhigh, 0.0, 0, ct); + drawline(wave_col, NOW, xval-x_size, yhigh, xval+x_size, ylow, 0.0, 0, ct); /* draw hex bus value if there is enough room */ if( fabs(xval - xval_old) > hex_digits * charwidth) { draw_string(wave_col, NOW, old_busval, 2, 0, 1, 0, (xval + xval_old) * 0.5, @@ -3090,13 +3118,13 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct) subwx = wx + deltax * (double)k / ((double)gr->subdivx + 1.0); if(!axis_within_range(subwx, gr->gx1, gr->gx2, deltax, gr->subdivx)) continue; if(axis_end(subwx, deltax, gr->gx2)) break; - drawline(GRIDLAYER, ADD, W_X(subwx), W_Y(gr->gy2), W_X(subwx), W_Y(gr->gy1), (int)dash_size, ct); + drawline(GRIDLAYER, ADD, W_X(subwx), W_Y(gr->gy2), W_X(subwx), W_Y(gr->gy1), 0.0, (int)dash_size, ct); } if(!axis_within_range(wx, gr->gx1, gr->gx2, deltax, gr->subdivx)) continue; if(axis_end(wx, deltax, gr->gx2)) break; /* swap order of gy1 and gy2 since grap y orientation is opposite to xorg orientation */ - drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy2), W_X(wx), W_Y(gr->gy1), (int)dash_size, ct); - drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy1), W_X(wx), W_Y(gr->gy1) + mark_size, 0, ct); /* axis marks */ + drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy2), W_X(wx), W_Y(gr->gy1), 0.0, (int)dash_size, ct); + drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy1), W_X(wx), W_Y(gr->gy1) + mark_size, 0.0, 0, ct); /* axis marks */ /* X-axis labels */ if(gr->logx) draw_string(3, NOW, dtoa_eng(pow(10, wx) * gr->unitx), 0, 0, 1, 0, W_X(wx), @@ -3106,8 +3134,8 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct) gr->txtsizex, gr->txtsizex); } /* first and last vertical box delimiters */ - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy2), W_X(gr->gx1), W_Y(gr->gy1), 0, ct); - drawline(GRIDLAYER, ADD, W_X(gr->gx2), W_Y(gr->gy2), W_X(gr->gx2), W_Y(gr->gy1), 0, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy2), W_X(gr->gx1), W_Y(gr->gy1), 0.0, 0, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx2), W_Y(gr->gy2), W_X(gr->gx2), W_Y(gr->gy1), 0.0, 0, ct); /* horizontal grid lines */ if(!gr->digital) { deltay = axis_increment(gr->gy1, gr->gy2, gr->divy, gr->logy); @@ -3123,12 +3151,12 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct) subwy = wy + deltay * (double)k / ((double)gr->subdivy + 1.0); if(!axis_within_range(subwy, gr->gy1, gr->gy2, deltay, gr->subdivy)) continue; if(axis_end(subwy, deltay, gr->gy2)) break; - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(subwy), W_X(gr->gx2), W_Y(subwy), (int)dash_size, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(subwy), W_X(gr->gx2), W_Y(subwy), 0.0, (int)dash_size, ct); } if(!axis_within_range(wy, gr->gy1, gr->gy2, deltay, gr->subdivy)) continue; if(axis_end(wy, deltay, gr->gy2)) break; - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(wy), W_X(gr->gx2), W_Y(wy), (int)dash_size, ct); - drawline(GRIDLAYER, ADD, W_X(gr->gx1) - mark_size, W_Y(wy), W_X(gr->gx1), W_Y(wy), 0, ct); /* axis marks */ + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(wy), W_X(gr->gx2), W_Y(wy), 0.0, (int)dash_size, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1) - mark_size, W_Y(wy), W_X(gr->gx1), W_Y(wy), 0.0, 0, ct); /* axis marks */ /* Y-axis labels */ if(gr->logy) draw_string(3, NOW, dtoa_eng(pow(10, wy) * gr->unity), 0, 1, 0, 1, @@ -3139,16 +3167,16 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct) } } /* first and last horizontal box delimiters */ - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy1), W_X(gr->gx2), W_Y(gr->gy1), 0, ct); - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy2), W_X(gr->gx2), W_Y(gr->gy2), 0, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy1), W_X(gr->gx2), W_Y(gr->gy1), 0.0, 0, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(gr->gy2), W_X(gr->gx2), W_Y(gr->gy2), 0.0, 0, ct); /* Horizontal axis (if in viewport) */ if(!gr->digital && gr->gy1 <= 0 && gr->gy2 >= 0) - drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(0), W_X(gr->gx2), W_Y(0), 0, ct); + drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(0), W_X(gr->gx2), W_Y(0), 0.0, 0, ct); /* Vertical axis (if in viewport) * swap order of gy1 and gy2 since grap y orientation is opposite to xorg orientation */ if(gr->gx1 <= 0 && gr->gx2 >= 0) - drawline(GRIDLAYER, ADD, W_X(0), W_Y(gr->gy2), W_X(0), W_Y(gr->gy1), 0, ct); - drawline(GRIDLAYER, END, 0.0, 0.0, 0.0, 0.0, 0, ct); + drawline(GRIDLAYER, ADD, W_X(0), W_Y(gr->gy2), W_X(0), W_Y(gr->gy1), 0.0, 0, ct); + drawline(GRIDLAYER, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, ct); bbox(END, 0.0, 0.0, 0.0, 0.0); } @@ -3361,7 +3389,7 @@ static void draw_cursor(double active_cursorx, double other_cursorx, int cursor_ if(gr->logx) pos = mylog10(pos); xx = W_X(pos); if(xx >= gr->x1 && xx <= gr->x2) { - drawline(cursor_color, NOW, xx, gr->ry1, xx, gr->ry2, 1, NULL); + drawline(cursor_color, NOW, xx, gr->ry1, xx, gr->ry2, 0.0, 1, NULL); if(gr->unitx != 1.0) my_snprintf(tmpstr, S(tmpstr), "%.5g%c", gr->unitx * active_cursorx , gr->unitx_suffix); else @@ -3405,8 +3433,8 @@ static void draw_cursor_difference(double c1, double c2, Graph_ctx *gr) dtmp = a; a = b; b = dtmp; } yline = (ty1 + ty2) * 0.5; - if( tx1 - a > 4.0) drawline(3, NOW, a + 2, yline, tx1 - 2, yline, 1, NULL); - if( b - tx2 > 4.0) drawline(3, NOW, tx2 + 2, yline, b - 2, yline, 1, NULL); + if( tx1 - a > 4.0) drawline(3, NOW, a + 2, yline, tx1 - 2, yline, 0.0, 1, NULL); + if( b - tx2 > 4.0) drawline(3, NOW, tx2 + 2, yline, b - 2, yline, 0.0, 1, NULL); } } @@ -3423,7 +3451,7 @@ static void draw_hcursor(double active_cursory, int cursor_color, Graph_ctx *gr) if(gr->logy) pos = mylog10(pos); yy = W_Y(pos); if(yy >= gr->y1 && yy <= gr->y2) { - drawline(cursor_color, NOW, gr->rx1 + 10, yy, gr->rx2 - 10, yy, 1, NULL); + drawline(cursor_color, NOW, gr->rx1 + 10, yy, gr->rx2 - 10, yy, 0.0, 1, NULL); if(gr->unity != 1.0) my_snprintf(tmpstr, S(tmpstr), " %.5g%c ", gr->unity * active_cursory , gr->unity_suffix); else @@ -3470,8 +3498,8 @@ static void draw_hcursor_difference(double c1, double c2, Graph_ctx *gr) dtmp = a; a = b; b = dtmp; } xline = tx1 + 10; - if( ty1 - a > 4.0) drawline(3, NOW, xline, a + 2, xline, ty1 - 2, 1, NULL); - if( b - ty2 > 4.0) drawline(3, NOW, xline, ty2 + 2, xline, b - 2, 1, NULL); + if( ty1 - a > 4.0) drawline(3, NOW, xline, a + 2, xline, ty1 - 2, 0.0, 1, NULL); + if( b - ty2 > 4.0) drawline(3, NOW, xline, ty2 + 2, xline, b - 2, 0.0, 1, NULL); } } @@ -5175,8 +5203,8 @@ 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 == -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(l->bus == -1.0) drawline(cc, THICK, l->x1, l->y1, l->x2, l->y2, l->bus, l->dash, NULL); + else drawline(cc, ADD, l->x1, l->y1, l->x2, l->y2, l->bus, l->dash, NULL); } if(draw_layer && xctx->enable_layer[c]) for(i=0;irects[c]; ++i) { xRect *r = &xctx->rect[c][i]; @@ -5234,7 +5262,7 @@ void draw(void) 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.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); + drawline(cc, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, NULL); } cc = WIRELAYER; if(xctx->only_probes) cc = GRIDLAYER; if(xctx->draw_single_layer==-1 || xctx->draw_single_layer==WIRELAYER) { @@ -5251,15 +5279,15 @@ void draw(void) } 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); + xctx->wire[i].x2,xctx->wire[i].y2, xctx->wire[i].bus, 0, NULL); } else drawline(cc, ADD, xctx->wire[i].x1,xctx->wire[i].y1, - xctx->wire[i].x2,xctx->wire[i].y2, 0, NULL); + xctx->wire[i].x2,xctx->wire[i].y2, xctx->wire[i].bus, 0, NULL); } update_conn_cues(cc, 1, xctx->draw_window); 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); + drawline(cc, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, NULL); } for(i=0;itexts; ++i) { @@ -5307,7 +5335,7 @@ void draw(void) #endif #if HAS_CAIRO!=1 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0, -1, -1); - drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0, NULL); + drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, NULL); #endif } /* for(i=0;itexts; ++i) */ if(xctx->only_probes) build_colors(1.0, 0); diff --git a/src/editprop.c b/src/editprop.c index fa4322e6..c2a7bc86 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -1106,6 +1106,9 @@ static int edit_line_property(void) const char *dash; int preserve, modified = 0; char *oldprop=NULL; + double bus = 0.0, oldbus = 0.0; + double width; + my_strdup(_ALLOC_ID_, &oldprop, xctx->line[xctx->sel_array[0].col][xctx->sel_array[0].n].prop_ptr); if(oldprop && oldprop[0]) { tclsetvar("tctx::retval", oldprop); @@ -1125,13 +1128,19 @@ static int edit_line_property(void) if(xctx->sel_array[i].type != LINE) continue; c = xctx->sel_array[i].col; n = xctx->sel_array[i].n; + oldbus = xctx->line[c][n].bus; if(oldprop && preserve == 1) { set_different_token(&xctx->line[c][n].prop_ptr, (char *) tclgetvar("tctx::retval"), oldprop); } else { my_strdup(_ALLOC_ID_, &xctx->line[c][n].prop_ptr, (char *) tclgetvar("tctx::retval")); } - xctx->line[c][n].bus = get_attr_val(get_tok_value(xctx->line[c][n].prop_ptr,"bus",0)); + bus = xctx->line[c][n].bus = get_attr_val(get_tok_value(xctx->line[c][n].prop_ptr,"bus",0)); + + if(bus > 0.0) width = bus / 2.0; + else width = INT_BUS_WIDTH(xctx->lw) / 2.0; + if(oldbus / 2.0 > width) width = oldbus / 2.0; + dash = get_tok_value(xctx->line[c][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); @@ -1139,11 +1148,11 @@ static int edit_line_property(void) } else xctx->line[c][n].dash = 0; if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { - y1 = xctx->line[c][n].y1-INT_BUS_WIDTH(xctx->lw); y2 = xctx->line[c][n].y2+INT_BUS_WIDTH(xctx->lw); + y1 = xctx->line[c][n].y1 - width; y2 = xctx->line[c][n].y2 + width; } else { - y1 = xctx->line[c][n].y1+INT_BUS_WIDTH(xctx->lw); y2 = xctx->line[c][n].y2-INT_BUS_WIDTH(xctx->lw); + y1 = xctx->line[c][n].y1 + width; y2 = xctx->line[c][n].y2 - width; } - bbox(ADD, xctx->line[c][n].x1-INT_BUS_WIDTH(xctx->lw), y1, xctx->line[c][n].x2+INT_BUS_WIDTH(xctx->lw), y2); + bbox(ADD, xctx->line[c][n].x1 - width, y1, xctx->line[c][n].x2 + width, y2); } bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); draw(); @@ -1160,7 +1169,8 @@ static int edit_wire_property(void) int i, modified = 0; int preserve; char *oldprop=NULL; - double bus; + double bus = 0.0, oldbus = 0.0; + double width; my_strdup(_ALLOC_ID_, &oldprop, xctx->wire[xctx->sel_array[0].n].prop_ptr); if(oldprop && oldprop[0]) { @@ -1177,7 +1187,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) { - double oldbus=0.0; + double ov, y1, y2; int k = xctx->sel_array[i].n; if(xctx->sel_array[i].type != WIRE) continue; /* does not seem to be necessary */ @@ -1191,21 +1201,15 @@ 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 == -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; } - else { y1 = xctx->wire[k].y1+ov; y2 = xctx->wire[k].y2-ov; } - bbox(ADD, xctx->wire[k].x1-ov, y1 , xctx->wire[k].x2+ov , y2 ); - } else { - if(oldbus){ - 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; } - else { y1 = xctx->wire[k].y1+ov; y2 = xctx->wire[k].y2-ov; } - bbox(ADD, xctx->wire[k].x1-ov, y1 , xctx->wire[k].x2+ov , y2 ); - } - } + + if(bus > 0.0) width = bus / 2.0; + else width = INT_BUS_WIDTH(xctx->lw / 2.0); + if(oldbus / 2.0 > width) width = oldbus / 2.0; + + ov = width > xctx->cadhalfdotsize ? width : xctx->cadhalfdotsize; + if(xctx->wire[k].y1 < xctx->wire[k].y2) { y1 = xctx->wire[k].y1-ov; y2 = xctx->wire[k].y2+ov; } + else { y1 = xctx->wire[k].y1+ov; y2 = xctx->wire[k].y2-ov; } + bbox(ADD, xctx->wire[k].x1-ov, y1 , xctx->wire[k].x2+ov , y2 ); } bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); draw(); @@ -1270,7 +1274,7 @@ static int edit_arc_property(void) bus = xctx->arc[c][i].bus = get_attr_val(get_tok_value(xctx->arc[c][i].prop_ptr,"bus",0)); if(bus > 0.0) width = bus / 2.0; - else width = xctx->cadhalfdotsize; + else width = INT_BUS_WIDTH(xctx->lw) / 2.0; if(oldbus / 2.0 > width) width = oldbus / 2.0; if(oldbus != bus || old_fill != xctx->arc[c][i].fill || old_dash != xctx->arc[c][i].dash) { @@ -1339,7 +1343,8 @@ static int edit_polygon_property(void) xctx->poly[c][i].bus = bus = get_attr_val(get_tok_value(xctx->poly[c][i].prop_ptr,"bus",0)); if(bus > 0.0) width = bus / 2.0; - else width = xctx->cadhalfdotsize; + else width = xctx->cadhalfdotsize > INT_BUS_WIDTH(xctx->lw) / 2.0 ? + xctx->cadhalfdotsize : INT_BUS_WIDTH(xctx->lw) / 2.0; if(oldbus / 2.0 > width) width = oldbus / 2.0; fill_ptr = get_tok_value(xctx->poly[c][i].prop_ptr,"fill",0); diff --git a/src/hilight.c b/src/hilight.c index 6cfed001..044fea60 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -2228,10 +2228,10 @@ void draw_hilight_net(int on_window) if( (entry = bus_hilight_hash_lookup(xctx->wire[i].node, 0, XLOOKUP)) ) { 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); + xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2, xctx->wire[i].bus, 0, NULL); else drawline(get_color(entry->value), NOW, - xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2, 0, NULL); + xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2, xctx->wire[i].bus, 0, NULL); if(xctx->cadhalfdotsize*xctx->mooz>=0.7) { if( xctx->wire[i].end1 >1 ) { filledarc(get_color(entry->value), NOW, xctx->wire[i].x1, xctx->wire[i].y1, @@ -2270,7 +2270,7 @@ void draw_hilight_net(int on_window) 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.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); + drawline(col, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, NULL); } } } diff --git a/src/scheduler.c b/src/scheduler.c index 88aa2ef6..40a40df0 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -215,9 +215,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg drawrect(PINLAYER, NOW, x - 2.5, y - 2.5, x + 2.5, y + 2.5, 0, -1, -1); filledrect(PINLAYER,NOW, x - 2.5, y - 2.5, x + 2.5, y + 2.5, 1, -1, -1); if(flip) { - drawline(linecol, NOW, x -20, y, x, y, 0, NULL); + drawline(linecol, NOW, x -20, y, x, y, 0.0, 0, NULL); } else { - drawline(linecol, NOW, x, y, x + 20, y, 0, NULL); + drawline(linecol, NOW, x, y, x + 20, y, 0.0, 0, NULL); } xctx->draw_window = save; } @@ -2178,6 +2178,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg xctx->xrect[0].height); Tcl_AppendResult(interp, res, NULL); my_snprintf(res, S(res), "INT_LINE_W(lw)=%d\n", INT_LINE_W(xctx->lw)); Tcl_AppendResult(interp, res, NULL); + my_snprintf(res, S(res), "INT_BUS_WIDTH(xctx->lw)=%d\n", INT_BUS_WIDTH(xctx->lw)); + Tcl_AppendResult(interp, res, NULL); + my_snprintf(res, S(res), "cadhalfdotsize=%g\n", xctx->cadhalfdotsize); Tcl_AppendResult(interp, res, NULL); my_snprintf(res, S(res), "lw=%g\n", xctx->lw); Tcl_AppendResult(interp, res, NULL); my_snprintf(res, S(res), "wires=%d\n", xctx->wires); Tcl_AppendResult(interp, res, NULL); my_snprintf(res, S(res), "instances=%d\n", xctx->instances); Tcl_AppendResult(interp, res, NULL); @@ -2912,7 +2915,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg storeobject(pos, x1,y1,x2,y2,LINE,xctx->rectcolor,0,prop_str); if(draw) { save = xctx->draw_window; xctx->draw_window = 1; - drawline(xctx->rectcolor,NOW, x1,y1,x2,y2, 0, NULL); + drawline(xctx->rectcolor,NOW, x1,y1,x2,y2, 0.0, 0, NULL); xctx->draw_window = save; } set_modify(1); @@ -6612,7 +6615,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg xctx->prep_net_structs=0; xctx->prep_hash_wires=0; save = xctx->draw_window; xctx->draw_window = 1; - drawline(WIRELAYER,NOW, x1,y1,x2,y2, 0, NULL); + drawline(WIRELAYER,NOW, x1,y1,x2,y2, 0.0, 0, NULL); xctx->draw_window = save; if(tclgetboolvar("autotrim_wires")) trim_wires(); set_modify(1); diff --git a/src/xschem.h b/src/xschem.h index b643b668..c2edf111 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1435,7 +1435,7 @@ extern Selected find_closest_obj(double mx,double my, int override_lock); /*extern void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y);*/ extern int find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y); -extern void drawline(int c, int what, double x1,double y1,double x2,double y2, int dash, void *ct); +extern void drawline(int c, int what, double x1,double y1,double x2,double y2, double bus, int dash, void *ct); extern void draw_xhair_line(GC gc, int size, double linex1, double liney1, double linex2, double liney2); extern void draw_string(int layer,int what, const char *str, short rot, short flip, int hcenter, int vcenter, double x1, double y1, double xscale, double yscale);