removed some dead code (what & START) in draw.c, paste/merge of lines/polygons/arcs/lines did not correctly restore dash attributes. Boiler plate code for draw waves
This commit is contained in:
parent
61e9c0e4e3
commit
969f4ec1c7
70
src/draw.c
70
src/draw.c
|
|
@ -818,7 +818,6 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
|
|||
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if((what & END) && i)
|
||||
{
|
||||
#ifdef __unix__
|
||||
|
|
@ -898,7 +897,6 @@ void drawtempline(GC gc, int what, double linex1,double liney1,double linex2,dou
|
|||
}
|
||||
}
|
||||
|
||||
else if(what & START) i=0;
|
||||
else if((what & END) && i)
|
||||
{
|
||||
#ifdef __unix__
|
||||
|
|
@ -963,7 +961,6 @@ void drawtemparc(GC gc, int what, double x, double y, double r, double a, double
|
|||
XDrawArc(display, xctx->window, gc, xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if((what & END) && i)
|
||||
{
|
||||
XDrawArcs(display, xctx->window, gc, xarc,i);
|
||||
|
|
@ -1059,7 +1056,6 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b
|
|||
if(xctx->draw_pixmap) XFillArc(display, xctx->save_pixmap, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if((what & END) && i)
|
||||
{
|
||||
if(xctx->draw_window) XFillArcs(display, xctx->window, xctx->gc[c], xarc,i);
|
||||
|
|
@ -1150,7 +1146,6 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if((what & END) && i)
|
||||
{
|
||||
if(xctx->draw_window) XDrawArcs(display, xctx->window, xctx->gc[c], xarc,i);
|
||||
|
|
@ -1186,7 +1181,6 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
|
|||
(unsigned int)y2 - (unsigned int)y1);
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if(what & ADD)
|
||||
{
|
||||
if(i>=CADDRAWBUFFERSIZE)
|
||||
|
|
@ -1396,7 +1390,6 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if(what & ADD)
|
||||
{
|
||||
if(i>=CADDRAWBUFFERSIZE)
|
||||
|
|
@ -1449,7 +1442,6 @@ void drawtemprect(GC gc, int what, double rectx1,double recty1,double rectx2,dou
|
|||
(unsigned int)y2 - (unsigned int)y1);
|
||||
}
|
||||
}
|
||||
else if(what & START) i=0;
|
||||
else if(what & ADD)
|
||||
{
|
||||
if(i>=CADDRAWBUFFERSIZE)
|
||||
|
|
@ -1478,6 +1470,57 @@ void drawtemprect(GC gc, int what, double rectx1,double recty1,double rectx2,dou
|
|||
}
|
||||
}
|
||||
|
||||
/* boiler plate code for future draw waves in xschem */
|
||||
void draw_waves(int c, int i)
|
||||
{
|
||||
double x1, y1, x2, y2, w, h;
|
||||
double txtsize;
|
||||
double txtx, txty;
|
||||
char dash_arr[2] = {3, 3};
|
||||
double dash_size;
|
||||
const double margin = 0.05;
|
||||
|
||||
x1 = xctx->rect[c][i].x1;
|
||||
y1 = xctx->rect[c][i].y1;
|
||||
x2 = xctx->rect[c][i].x2;
|
||||
y2 = xctx->rect[c][i].y2;
|
||||
w = (x2 - x1);
|
||||
h = (y2 - y1);
|
||||
/* set a margin */
|
||||
x1 += w * margin;
|
||||
x2 -= w * margin;
|
||||
y1 += h * margin;
|
||||
y2 -= h * margin;
|
||||
w = (x2 - x1);
|
||||
h = (y2 - y1);
|
||||
|
||||
dash_size = (x2 - x1) * xctx->mooz / 80.0;
|
||||
dash_arr[0] = dash_arr[1] = dash_size > 127.0 ? 127 : dash_size;
|
||||
txtx = (x2 + x1) / 2;
|
||||
txty = (y2 + y1) / 2;
|
||||
txtsize = (x2 - x1) / 400;
|
||||
/* thin / dashed lines (axis etc) */
|
||||
XSetDashes(display, xctx->gc[7], 0, dash_arr, 2);
|
||||
XSetLineAttributes (display, xctx->gc[7], 0, xDashType, CapButt, JoinBevel);
|
||||
XSetLineAttributes (display, xctx->gc[9], 0, LineSolid, CapRound , JoinRound);
|
||||
drawline(7, NOW, x1, y1, x2, y2, 0);
|
||||
drawline(9, NOW, x1, y2, x2, y1, 0);
|
||||
|
||||
#if HAS_CAIRO==1
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
#endif
|
||||
draw_string(10, NOW, "Hello World!", 0, 0, 1, 1, txtx, txty, txtsize, txtsize);
|
||||
#if HAS_CAIRO==1
|
||||
cairo_restore(xctx->cairo_ctx);
|
||||
cairo_restore(xctx->cairo_save_ctx);
|
||||
#endif
|
||||
XSetLineAttributes (display, xctx->gc[7], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
|
||||
XSetLineAttributes (display, xctx->gc[9], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
|
||||
}
|
||||
|
||||
void draw(void)
|
||||
{
|
||||
/* inst_ptr and wire hash iterator 20171224 */
|
||||
|
|
@ -1526,6 +1569,14 @@ void draw(void)
|
|||
if(xctx->enable_layer[c]) for(i=0;i<xctx->rects[c];i++) {
|
||||
xRect *r = &xctx->rect[c][i];
|
||||
drawrect(c, ADD, r->x1, r->y1, r->x2, r->y2, r->dash);
|
||||
if(r->flags == 1) {
|
||||
/* flush pending data... */
|
||||
filledrect(c, END, 0.0, 0.0, 0.0, 0.0);
|
||||
drawarc(c, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0);
|
||||
drawrect(c, END, 0.0, 0.0, 0.0, 0.0, 0);
|
||||
drawline(c, END, 0.0, 0.0, 0.0, 0.0, 0);
|
||||
draw_waves(c, i); /* <<<< */
|
||||
}
|
||||
filledrect(c, ADD, r->x1, r->y1, r->x2, r->y2);
|
||||
}
|
||||
if(xctx->enable_layer[c]) for(i=0;i<xctx->arcs[c];i++) {
|
||||
|
|
@ -1557,7 +1608,6 @@ void draw(void)
|
|||
symptr->polygons[c] ||
|
||||
((c==TEXTWIRELAYER || c==TEXTLAYER) && symptr->texts) )
|
||||
{
|
||||
|
||||
draw_symbol(ADD, c, i,c,0,0,0.0,0.0); /* ... then draw current layer */
|
||||
}
|
||||
}
|
||||
|
|
@ -1638,8 +1688,6 @@ void draw(void)
|
|||
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
|
||||
}
|
||||
draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
|
||||
|
||||
dbg(1, "draw(): INT_WIDTH(lw)=%d\n",INT_WIDTH(xctx->lw));
|
||||
} /* if(has_x) */
|
||||
}
|
||||
|
||||
|
|
|
|||
42
src/paste.c
42
src/paste.c
|
|
@ -91,6 +91,7 @@ void merge_box(FILE *fd)
|
|||
{
|
||||
int i,c,n;
|
||||
xRect *ptr;
|
||||
const char *dash, *flags;
|
||||
|
||||
n = fscanf(fd, "%d",&c);
|
||||
if(n != 1 || c < 0 || c >= cadlayers) {
|
||||
|
|
@ -111,6 +112,21 @@ void merge_box(FILE *fd)
|
|||
RECTORDER(ptr[i].x1, ptr[i].y1, ptr[i].x2, ptr[i].y2);
|
||||
ptr[i].sel=0;
|
||||
load_ascii_string( &ptr[i].prop_ptr, fd);
|
||||
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
|
||||
if(strcmp(dash, "")) {
|
||||
int d = atoi(dash);
|
||||
ptr[i].dash = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].dash = 0;
|
||||
}
|
||||
flags = get_tok_value(ptr[i].prop_ptr,"flags",0);
|
||||
if(strcmp(flags, "")) {
|
||||
int d = atoi(flags);
|
||||
ptr[i].flags = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].flags = 0;
|
||||
}
|
||||
|
||||
select_box(c,i, SELECTED, 1);
|
||||
xctx->rects[c]++;
|
||||
set_modify(1);
|
||||
|
|
@ -120,6 +136,7 @@ void merge_arc(FILE *fd)
|
|||
{
|
||||
int i,c,n;
|
||||
xArc *ptr;
|
||||
const char *dash;
|
||||
|
||||
n = fscanf(fd, "%d",&c);
|
||||
if(n != 1 || c < 0 || c >= cadlayers) {
|
||||
|
|
@ -144,6 +161,14 @@ void merge_arc(FILE *fd)
|
|||
ptr[i].fill =1;
|
||||
else
|
||||
ptr[i].fill =0;
|
||||
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
|
||||
if(strcmp(dash, "")) {
|
||||
int d = atoi(dash);
|
||||
ptr[i].dash = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].dash = 0;
|
||||
}
|
||||
|
||||
select_arc(c,i, SELECTED, 1);
|
||||
xctx->arcs[c]++;
|
||||
set_modify(1);
|
||||
|
|
@ -154,6 +179,7 @@ void merge_polygon(FILE *fd)
|
|||
{
|
||||
int i,c, j, points;
|
||||
xPoly *ptr;
|
||||
const char *dash;
|
||||
|
||||
if(fscanf(fd, "%d %d",&c, &points)<2) {
|
||||
fprintf(errfp,"merge_polygon(): WARNING: missing fields for POLYGON object, ignoring.\n");
|
||||
|
|
@ -192,6 +218,14 @@ void merge_polygon(FILE *fd)
|
|||
ptr[i].fill =1;
|
||||
else
|
||||
ptr[i].fill =0;
|
||||
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
|
||||
if(strcmp(dash, "")) {
|
||||
int d = atoi(dash);
|
||||
ptr[i].dash = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].dash = 0;
|
||||
}
|
||||
|
||||
select_polygon(c,i, SELECTED, 1);
|
||||
xctx->polygons[c]++;
|
||||
set_modify(1);
|
||||
|
|
@ -201,6 +235,7 @@ void merge_line(FILE *fd)
|
|||
{
|
||||
int i,c,n;
|
||||
xLine *ptr;
|
||||
const char *dash;
|
||||
|
||||
n = fscanf(fd, "%d",&c);
|
||||
if(n != 1 || c < 0 || c >= cadlayers) {
|
||||
|
|
@ -220,6 +255,13 @@ void merge_line(FILE *fd)
|
|||
ptr[i].prop_ptr=NULL;
|
||||
ptr[i].sel=0;
|
||||
load_ascii_string( &ptr[i].prop_ptr, fd);
|
||||
dash = get_tok_value(ptr[i].prop_ptr,"dash",0);
|
||||
if(strcmp(dash, "")) {
|
||||
int d = atoi(dash);
|
||||
ptr[i].dash = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].dash = 0;
|
||||
}
|
||||
select_line(c,i, SELECTED, 1);
|
||||
xctx->lines[c]++;
|
||||
set_modify(1);
|
||||
|
|
|
|||
10
src/save.c
10
src/save.c
|
|
@ -677,7 +677,7 @@ static void load_box(FILE *fd)
|
|||
{
|
||||
int i,n,c;
|
||||
xRect *ptr;
|
||||
const char *dash;
|
||||
const char *dash, *flags;
|
||||
|
||||
dbg(3, "load_box(): start\n");
|
||||
n = fscanf(fd, "%d",&c);
|
||||
|
|
@ -706,6 +706,13 @@ static void load_box(FILE *fd)
|
|||
} else {
|
||||
ptr[i].dash = 0;
|
||||
}
|
||||
flags = get_tok_value(ptr[i].prop_ptr,"flags",0);
|
||||
if(strcmp(flags, "")) {
|
||||
int d = atoi(flags);
|
||||
ptr[i].flags = d >= 0 ? d : 0;
|
||||
} else {
|
||||
ptr[i].flags = 0;
|
||||
}
|
||||
xctx->rects[c]++;
|
||||
}
|
||||
|
||||
|
|
@ -1947,6 +1954,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
|||
bb[c][i].prop_ptr=NULL;
|
||||
load_ascii_string( &bb[c][i].prop_ptr, lcc[level].fd);
|
||||
dbg(2, "l_s_d(): loaded rect: ptr=%lx\n", (unsigned long)bb[c]);
|
||||
|
||||
dash = get_tok_value(bb[c][i].prop_ptr,"dash", 0);
|
||||
if( strcmp(dash, "") ) {
|
||||
int d = atoi(dash);
|
||||
|
|
|
|||
Loading…
Reference in New Issue