fix connection bubbles not updated when adding "2 segment manhattan lines" , svg export draws highlighed nets if any

This commit is contained in:
Stefan Frederik 2020-12-23 02:14:27 +01:00
parent 26b5b67262
commit c58645b8e6
3 changed files with 58 additions and 36 deletions

View File

@ -1631,6 +1631,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1,WIRE,0,0,NULL); storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1,WIRE,0,0,NULL);
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1, 0); drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1, 0);
} }
if(xctx->nl_yy2!=xctx->nl_yy1) { if(xctx->nl_yy2!=xctx->nl_yy1) {
@ -1638,6 +1639,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
storeobject(-1, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL); storeobject(-1, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL);
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0); drawline(WIRELAYER,NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0);
} }
} else if(manhattan_lines==2) { } else if(manhattan_lines==2) {
@ -1646,6 +1648,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2,WIRE,0,0,NULL); storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2,WIRE,0,0,NULL);
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2, 0); drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2, 0);
} }
if(xctx->nl_xx2!=xctx->nl_xx1) { if(xctx->nl_xx2!=xctx->nl_xx1) {
@ -1653,6 +1656,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2; xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2);
storeobject(-1, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL); storeobject(-1, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL);
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2, 0); drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2, 0);
} }
} else { } else {
@ -1660,9 +1664,9 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL); storeobject(-1, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2,WIRE,0,0,NULL);
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0); drawline(WIRELAYER,NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0);
} }
hash_wire(XINSERT, xctx->wires-1, 1);
/* xctx->prep_hash_wires = 0; */ /* xctx->prep_hash_wires = 0; */
xctx->prep_hi_structs = 0; xctx->prep_hi_structs = 0;

View File

@ -1478,9 +1478,11 @@ void draw(void)
rebuild_selected_array(); rebuild_selected_array();
if(has_x) { if(has_x) {
if(draw_pixmap) if(draw_pixmap)
XFillRectangle(display, xctx->save_pixmap, gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); XFillRectangle(display, xctx->save_pixmap, gc[BACKLAYER], xctx->areax1, xctx->areay1,
xctx->areaw, xctx->areah);
if(draw_window) if(draw_window)
XFillRectangle(display, xctx->window, gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); XFillRectangle(display, xctx->window, gc[BACKLAYER], xctx->areax1, xctx->areay1,
xctx->areaw, xctx->areah);
dbg(2, "draw(): window: %d %d %d %d\n",xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2); dbg(2, "draw(): window: %d %d %d %d\n",xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2);
drawgrid(); drawgrid();
x1 = X_TO_XSCHEM(xctx->areax1); x1 = X_TO_XSCHEM(xctx->areax1);

View File

@ -387,7 +387,7 @@ static void svg_drawgrid()
static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot, static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
double xoffset, double yoffset) double xoffset, double yoffset)
/* draws current layer only, should be called within */ /* draws current layer only, should be called within */
{ /* a "for(i=0;i<cadlayers;i++)" loop */ { /* a "for(i=0;i<cadlayers;i++)" loop */
@ -431,7 +431,7 @@ static void svg_draw_symbol(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.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2); ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2); ORDER(x1,y1,x2,y2);
svg_drawline(layer, line.bus, x0+x1, y0+y1, x0+x2, y0+y2, line.dash); svg_drawline(c, line.bus, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
} }
for(j=0;j< symptr->polygons[layer];j++) { for(j=0;j< symptr->polygons[layer];j++) {
polygon = (symptr->poly[layer])[j]; polygon = (symptr->poly[layer])[j];
@ -444,7 +444,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
x[k]+= x0; x[k]+= x0;
y[k] += y0; y[k] += y0;
} }
svg_drawpolygon(layer, NOW, x, y, polygon.points, polygon.fill, polygon.dash); svg_drawpolygon(c, NOW, x, y, polygon.points, polygon.fill, polygon.dash);
my_free(961, &x); my_free(961, &x);
my_free(962, &y); my_free(962, &y);
} }
@ -460,7 +460,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
angle = fmod(angle, 360.); angle = fmod(angle, 360.);
if(angle<0.) angle+=360.; if(angle<0.) angle+=360.;
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1); ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
svg_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash); svg_drawarc(c, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
} }
if( enable_layer[layer] ) for(j=0;j< symptr->rects[layer];j++) { if( enable_layer[layer] ) for(j=0;j< symptr->rects[layer];j++) {
@ -468,7 +468,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1); ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2); ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
RECTORDER(x1,y1,x2,y2); RECTORDER(x1,y1,x2,y2);
svg_filledrect(layer, x0+x1, y0+y1, x0+x2, y0+y2, box.dash); svg_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
} }
if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) || if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) ||
(sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) { (sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) {
@ -478,11 +478,11 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot,
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */ /* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
txtptr= translate(n, text.txt_ptr); txtptr= translate(n, text.txt_ptr);
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
textlayer = layer; textlayer = c;
/* do not allow custom text color on PINLAYER hilighted instances */ /* do not allow custom text color on PINLAYER hilighted instances */
if( !(xctx->inst[n].color == PINLAYER)) { if( !(xctx->inst[n].color == PINLAYER)) {
textlayer = symptr->text[j].layer; textlayer = symptr->text[j].layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = c;
} }
/* display PINLAYER colored instance texts even if PINLAYER disabled */ /* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) { if(xctx->inst[n].color == PINLAYER || enable_layer[textlayer]) {
@ -554,9 +554,10 @@ void svg_draw(void)
int modified_save; int modified_save;
char *tmpstring=NULL; char *tmpstring=NULL;
const char *r, *textfont; const char *r, *textfont;
int *used_layer; int *unused_layer;
xSymbol *symptr; int color;
struct hilight_hashentry *entry;
if(!plotfile[0]) { if(!plotfile[0]) {
my_strdup(61, &tmpstring, "tk_getSaveFile -title {Select destination file} -initialdir [pwd]"); my_strdup(61, &tmpstring, "tk_getSaveFile -title {Select destination file} -initialdir [pwd]");
tcleval(tmpstring); tcleval(tmpstring);
@ -579,8 +580,8 @@ void svg_draw(void)
modified_save=xctx->modified; modified_save=xctx->modified;
push_undo(); push_undo();
trim_wires(); /* 20161121 add connection boxes on wires but undo at end */ /* Warning: sets xctx->prep_hi_structs to 0 */
trim_wires(); /* add connection boxes on wires but undo at end */
if(plotfile[0]) { if(plotfile[0]) {
fd=fopen(plotfile, "w"); fd=fopen(plotfile, "w");
if(!fd) { if(!fd) {
@ -596,25 +597,27 @@ void svg_draw(void)
} }
my_strncpy(plotfile,"", S(plotfile)); my_strncpy(plotfile,"", S(plotfile));
/* Determine used layers */ unused_layer = my_calloc(873, cadlayers, sizeof(int));
used_layer = my_calloc(873, cadlayers, sizeof(int)); #if 0
used_layer[0] = 1; /* background */ /* Determine used layers. Disabled since we want hilight colors */
for(c=0;c<cadlayers;c++) unused_layer[c] = 1;
unused_layer[0] = 0; /* background */
for(i=0;i<xctx->texts;i++) for(i=0;i<xctx->texts;i++)
{ {
textlayer = xctx->text[i].layer; textlayer = xctx->text[i].layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
used_layer[textlayer] = 1; unused_layer[textlayer] = 0;
} }
for(c=0;c<cadlayers;c++) for(c=0;c<cadlayers;c++)
{ {
if(xctx->lines[c] || xctx->rects[c] || xctx->arcs[c] || xctx->polygons[c]) used_layer[c] = 1; xSymbol symptr = (xctx->inst[i].ptr + xctx->sym);
if(xctx->wires) used_layer[WIRELAYER] = 1; if(xctx->lines[c] || xctx->rects[c] || xctx->arcs[c] || xctx->polygons[c]) unused_layer[c] = 0;
if(xctx->wires) unused_layer[WIRELAYER] = 0;
for(i=0;i<xctx->instances;i++) { for(i=0;i<xctx->instances;i++) {
symptr = (xctx->inst[i].ptr + xctx->sym); if( (c == PINLAYER || enable_layer[c]) && symptr->lines[c] ) unused_layer[c] = 0;
if( (c == PINLAYER || enable_layer[c]) && symptr->lines[c] ) used_layer[c] = 1; if( (c == PINLAYER || enable_layer[c]) && symptr->polygons[c] ) unused_layer[c] = 0;
if( (c == PINLAYER || enable_layer[c]) && symptr->polygons[c] ) used_layer[c] = 1; if( (c == PINLAYER || enable_layer[c]) && symptr->arcs[c] ) unused_layer[c] = 0;
if( (c == PINLAYER || enable_layer[c]) && symptr->arcs[c] ) used_layer[c] = 1; if( (c != PINLAYER || enable_layer[c]) && symptr->rects[c] ) unused_layer[c] = 0;
if( (c != PINLAYER || enable_layer[c]) && symptr->rects[c] ) used_layer[c] = 1;
if( (c==TEXTWIRELAYER && !(xctx->inst[i].flags&2) ) || if( (c==TEXTWIRELAYER && !(xctx->inst[i].flags&2) ) ||
(sym_txt && (c==TEXTLAYER) && (xctx->inst[i].flags&2) ) ) (sym_txt && (c==TEXTLAYER) && (xctx->inst[i].flags&2) ) )
{ {
@ -628,7 +631,7 @@ void svg_draw(void)
} }
/* display PINLAYER colored instance texts even if PINLAYER disabled */ /* display PINLAYER colored instance texts even if PINLAYER disabled */
if(xctx->inst[i].color == PINLAYER || enable_layer[textlayer]) { if(xctx->inst[i].color == PINLAYER || enable_layer[textlayer]) {
used_layer[textlayer] = 1; used_layer[textlayer] = 0;
} }
} }
} }
@ -636,17 +639,19 @@ void svg_draw(void)
dbg(1, "used_layer[%d] = %d\n", c, used_layer[c]); dbg(1, "used_layer[%d] = %d\n", c, used_layer[c]);
} }
/* End determine used layer */ /* End determine used layer */
#endif
fprintf(fd, "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%g\" height=\"%g\" version=\"1.1\">\n", dx, dy); fprintf(fd, "<svg xmlns=\"http://www.w3.org/2000/svg\""
" width=\"%g\" height=\"%g\" version=\"1.1\">\n", dx, dy);
fprintf(fd, "<style type=\"text/css\">\n"); /* use css stylesheet 20121119 */ fprintf(fd, "<style type=\"text/css\">\n"); /* use css stylesheet 20121119 */
for(i=0;i<cadlayers;i++){ for(i=0;i<cadlayers;i++){
if(!used_layer[i]) continue; if(unused_layer[i]) continue;
fprintf(fd, ".l%d{\n", i); fprintf(fd, ".l%d{\n", i);
if(fill_type[i] == 1) if(fill_type[i] == 1)
fprintf(fd, " fill: #%02x%02x%02x;\n", svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue); fprintf(fd, " fill: #%02x%02x%02x;\n", svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue);
else if(fill_type[i] == 2) else if(fill_type[i] == 2)
fprintf(fd, " fill: #%02x%02x%02x; fill-opacity: 0.5;\n", fprintf(fd, " fill: #%02x%02x%02x; fill-opacity: 0.5;\n",
svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue); svg_colors[i].red, svg_colors[i].green, svg_colors[i].blue);
else else
fprintf(fd, " fill: none;\n"); fprintf(fd, " fill: none;\n");
@ -712,12 +717,19 @@ void svg_draw(void)
xctx->poly[c][i].fill, xctx->poly[c][i].dash); xctx->poly[c][i].fill, xctx->poly[c][i].dash);
} }
for(i=0;i<xctx->instances;i++) { for(i=0;i<xctx->instances;i++) {
svg_draw_symbol(i,c,0,0,0.0,0.0); color = c;
if(xctx->inst[i].color) color = xctx->inst[i].color;
svg_draw_symbol(color,i,c,0,0,0.0,0.0);
} }
} }
prepare_netlist_structs(0); /* NEEDED: data was cleared by trim_wires() */
for(i=0;i<xctx->wires;i++) for(i=0;i<xctx->wires;i++)
{ {
svg_drawline(WIRELAYER, xctx->wire[i].bus, xctx->wire[i].x1, color = WIRELAYER;
if(xctx->hilight_nets && (entry=bus_hilight_lookup( xctx->wire[i].node, 0, XLOOKUP))) {
color = get_color(entry->value);
}
svg_drawline(color, xctx->wire[i].bus, xctx->wire[i].x1,
xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0); xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0);
} }
{ {
@ -732,11 +744,15 @@ void svg_draw(void)
y2 = Y_TO_XSCHEM(xctx->areay2); y2 = Y_TO_XSCHEM(xctx->areay2);
for(init_wire_iterator(x1, y1, x2, y2); ( wireptr = wire_iterator_next() ) ;) { for(init_wire_iterator(x1, y1, x2, y2); ( wireptr = wire_iterator_next() ) ;) {
i = wireptr->n; i = wireptr->n;
color = WIRELAYER;
if(xctx->hilight_nets && (entry=bus_hilight_lookup( xctx->wire[i].node, 0, XLOOKUP))) {
color = get_color(entry->value);
}
if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */ if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */
svg_drawcircle(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360); svg_drawcircle(color, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360);
} }
if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */ if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */
svg_drawcircle(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360); svg_drawcircle(color, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360);
} }
} }
} }
@ -746,7 +762,7 @@ void svg_draw(void)
draw_grid=old_grid; draw_grid=old_grid;
my_free(964, &svg_colors); my_free(964, &svg_colors);
my_free(1217, &used_layer); my_free(1217, &unused_layer);
pop_undo(0); pop_undo(0);
xctx->modified=modified_save; xctx->modified=modified_save;
Tcl_SetResult(interp,"",TCL_STATIC); Tcl_SetResult(interp,"",TCL_STATIC);