enable "bus=true" attribute for lines as wellas for wires. As a side effect LCC schematics with bussed wires will display thick buses

This commit is contained in:
Stefan Schippers 2020-09-07 13:12:34 +02:00
parent fce8ab8d1e
commit fde072720d
7 changed files with 84 additions and 35 deletions

View File

@ -517,7 +517,10 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
ROTATION(0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
if(line.bus)
drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
else
drawline(c,what, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
}
for(j=0;j< symptr->polygons[layer];j++) /* 20171115 */
{
@ -1565,8 +1568,12 @@ void draw(void)
{
if(draw_single_layer!=-1 && c != draw_single_layer) continue; /* 20151117 */
for(i=0;i<lastline[c];i++)
drawline(c, ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2, line[c][i].dash);
for(i=0;i<lastline[c];i++) {
if(line[c][i].bus)
drawline(c, THICK, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2, line[c][i].dash);
else
drawline(c, ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2, line[c][i].dash);
}
for(i=0;i<lastrect[c];i++)
{
drawrect(c, ADD, rect[c][i].x1, rect[c][i].y1, rect[c][i].x2, rect[c][i].y2, rect[c][i].dash);

View File

@ -452,8 +452,7 @@ void edit_rect_property(void)
void edit_line_property(void)
{
int i, c, n, old_dash;
int drw=0;
int i, c, n;
const char *dash;
int preserve;
char *oldprop=NULL;
@ -467,8 +466,10 @@ void edit_line_property(void)
preserve = atoi(tclgetvar("preserve_unchanged_attrs"));
if(strcmp(tclgetvar("rcode"),"") )
{
int y1, y2;
push_undo();
set_modify(1);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
for(i=0; i<lastselected; i++) {
if(selectedgroup[i].type != LINE) continue;
c = selectedgroup[i].col;
@ -480,26 +481,20 @@ void edit_line_property(void)
my_strdup(102, &line[c][n].prop_ptr,
(char *) tclgetvar("retval"));
}
old_dash = line[c][n].dash;
dash = get_tok_value(line[c][n].prop_ptr,"dash",0);
line[c][n].bus = !strcmp(get_tok_value(line[c][n].prop_ptr,"bus",0), "true");
if( strcmp(dash, "") ) {
int d = atoi(dash);
line[c][n].dash = d >= 0? d : 0;
} else
line[c][n].dash = 0;
if(old_dash != line[c][n].dash) {
if(!drw) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
drw = 1;
}
bbox(ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2);
}
}
if(drw) {
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
if(line[c][n].y1 < line[c][n].y2) { y1 = line[c][n].y1-bus_width; y2 = line[c][n].y2+bus_width; }
else { y1 = line[c][n].y1+bus_width; y2 = line[c][n].y2-bus_width; }
bbox(ADD, line[c][n].x1-bus_width, y1 , line[c][n].x2+bus_width , y2 );
}
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
}
my_free(726, &oldprop);
}
@ -524,6 +519,7 @@ void edit_wire_property(void)
{
push_undo(); /* 20150327 */
set_modify(1);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
for(i=0; i<lastselected; i++) {
int oldbus=0;
int k = selectedgroup[i].n;
@ -541,30 +537,25 @@ void edit_wire_property(void)
bus_ptr = get_tok_value(wire[k].prop_ptr,"bus",0);
if(!strcmp(bus_ptr, "true")) {
int ov, y1, y2;
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
ov = bus_width > cadhalfdotsize ? bus_width : CADHALFDOTSIZE;
if(wire[k].y1 < wire[k].y2) { y1 = wire[k].y1-ov; y2 = wire[k].y2+ov; }
else { y1 = wire[k].y1+ov; y2 = wire[k].y2-ov; }
bbox(ADD, wire[k].x1-ov, y1 , wire[k].x2+ov , y2 );
wire[k].bus=1;
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
} else {
if(oldbus){ /* 20171201 */
int ov, y1, y2;
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
ov = bus_width> cadhalfdotsize ? bus_width : CADHALFDOTSIZE;
if(wire[k].y1 < wire[k].y2) { y1 = wire[k].y1-ov; y2 = wire[k].y2+ov; }
else { y1 = wire[k].y1+ov; y2 = wire[k].y2-ov; }
bbox(ADD, wire[k].x1-ov, y1 , wire[k].x2+ov , y2 );
wire[k].bus=0;
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
}
}
}
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
}
my_free(727, &oldprop);
}

View File

@ -356,15 +356,24 @@ void draw_selection(GC g, int interruptable)
ORDER(rx1,ry1,rx2,ry2);
if(line[c][n].sel==SELECTED)
{
drawtempline(g, ADD, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay);
if(line[c][n].bus)
drawtempline(g, THICK, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay);
else
drawtempline(g, ADD, rx1+deltax, ry1+deltay, rx2+deltax, ry2+deltay);
}
else if(line[c][n].sel==SELECTED1)
{
drawtempline(g, ADD, rx1+deltax, ry1+deltay, rx2, ry2);
if(line[c][n].bus)
drawtempline(g, THICK, rx1+deltax, ry1+deltay, rx2, ry2);
else
drawtempline(g, ADD, rx1+deltax, ry1+deltay, rx2, ry2);
}
else if(line[c][n].sel==SELECTED2)
{
drawtempline(g, ADD, rx1, ry1, rx2+deltax, ry2+deltay);
if(line[c][n].bus)
drawtempline(g, THICK, rx1, ry1, rx2+deltax, ry2+deltay);
else
drawtempline(g, ADD, rx1, ry1, rx2+deltax, ry2+deltay);
}
break;
case ARC:
@ -597,7 +606,10 @@ void copy_objects(int what)
if(line[c][n].sel == SELECTED1) line[c][n].sel = SELECTED2;
else if(line[c][n].sel == SELECTED2) line[c][n].sel = SELECTED1;
}
drawline(k, ADD, rx1,ry1,rx2,ry2, line[c][n].dash);
if(line[c][n].bus)
drawline(k, THICK, rx1,ry1,rx2,ry2, line[c][n].dash);
else
drawline(k, ADD, rx1,ry1,rx2,ry2, line[c][n].dash);
selectedgroup[i].n=lastline[c];
storeobject(-1, rx1, ry1, rx2, ry2, LINE, c, line[c][n].sel, line[c][n].prop_ptr);
line[c][n].sel=0;
@ -1010,7 +1022,10 @@ void move_objects(int what, int merge, double dx, double dy)
line[c][n].y1=ry1;
line[c][n].x2=rx2;
line[c][n].y2=ry2;
drawline(k, ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, line[c][n].dash);
if(line[c][n].bus)
drawline(k, THICK, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, line[c][n].dash);
else
drawline(k, ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, line[c][n].dash);
break;
case POLYGON: /* 20171115 */

View File

@ -705,6 +705,12 @@ static void load_line(FILE *fd)
ptr[i].prop_ptr=NULL;
ptr[i].sel=0;
load_ascii_string( &ptr[i].prop_ptr, fd);
if(!strcmp(get_tok_value(ptr[i].prop_ptr, "bus", 0), "true") )
ptr[i].bus = 1;
else
ptr[i].bus = 0;
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
if(strcmp(dash, "")) {
int d = atoi(dash);
@ -1400,6 +1406,10 @@ int load_sym_def(const char *name, FILE *embed_fd)
load_ascii_string( &ll[c][i].prop_ptr, lcc[level].fd);
dbg(2, "l_d_s(): loaded line: ptr=%lx\n", (unsigned long)ll[c]);
if(!strcmp(get_tok_value(ll[c][i].prop_ptr,"bus", 0), "true") )
ll[c][i].bus = 1;
else
ll[c][i].bus = 0;
dash = get_tok_value(ll[c][i].prop_ptr,"dash", 0);
if( strcmp(dash, "") ) {
int d = atoi(dash);
@ -1595,6 +1605,10 @@ int load_sym_def(const char *name, FILE *embed_fd)
load_ascii_string( &ll[WIRELAYER][i].prop_ptr, lcc[level].fd);
dbg(2, "l_d_s(): loaded line: ptr=%lx\n", (unsigned long)ll[WIRELAYER]);
ll[WIRELAYER][i].dash = 0;
if(!strcmp(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].sel = 0;
lastl[WIRELAYER]++;
break;

View File

@ -123,7 +123,15 @@ static void del_rect_line_arc_poly(void)
if(line[c][i].sel == SELECTED)
{
j++;
bbox(ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
if(line[c][i].bus){ /* 20171201 */
int ov, y1, y2;
ov = bus_width;
if(line[c][i].y1 < line[c][i].y2) { y1 = line[c][i].y1-ov; y2 = line[c][i].y2+ov; }
else { y1 = line[c][i].y1+ov; y2 = line[c][i].y2-ov; }
bbox(ADD, line[c][i].x1-ov, y1 , line[c][i].x2+ov , y2 );
} else {
bbox(ADD, line[c][i].x1, line[c][i].y1 , line[c][i].x2 , line[c][i].y2 );
}
set_modify(1);
my_free(929, &line[c][i].prop_ptr);
continue;
@ -522,7 +530,10 @@ void unselect_all(void)
if(line[c][i].sel)
{
line[c][i].sel = 0;
drawtempline(gctiled, ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
if(line[c][i].bus)
drawtempline(gctiled, THICK, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
else
drawtempline(gctiled, ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
}
}
for(i=0;i<lastpolygon[c];i++)
@ -815,10 +826,16 @@ void select_line(int c, int i, unsigned short select_mode, int fast )
else
line[c][i].sel = select_mode;
if(select_mode) {
drawtempline(gc[SELLAYER], ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
if(line[c][i].bus)
drawtempline(gc[SELLAYER], THICK, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
else
drawtempline(gc[SELLAYER], ADD, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
}
else
drawtempline(gctiled, NOW, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
if(line[c][i].bus)
drawtempline(gctiled, THICK, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
else
drawtempline(gctiled, NOW, line[c][i].x1, line[c][i].y1, line[c][i].x2, line[c][i].y2);
need_rebuild_selected_array=1;
}

View File

@ -260,6 +260,10 @@ void storeobject(int pos, double x1,double y1,double x2,double y2,
line[rectcolor][n].prop_ptr=NULL;
my_strdup(412, &line[rectcolor][n].prop_ptr, prop_ptr);
line[rectcolor][n].sel=sel;
if( !strcmp(get_tok_value(line[rectcolor][n].prop_ptr, "bus", 0), "true") )
line[rectcolor][n].bus = 1;
else
line[rectcolor][n].bus = 0;
dash = get_tok_value(line[rectcolor][n].prop_ptr,"dash",0);
if( strcmp(dash, "") ) {
int d = atoi(dash);

View File

@ -315,6 +315,7 @@ typedef struct
unsigned short sel;
char *prop_ptr;
int dash;
int bus;
} Line;
typedef struct