From 60e55212d5ba48a522bff624ab5b304fb6da1d5b Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 6 Apr 2024 23:13:14 +0200 Subject: [PATCH] handle rot/flip transfofmations for ellipses inside symbols --- src/draw.c | 22 ++++++++++++++++++++-- src/move.c | 11 ++++------- src/xschem.h | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/draw.c b/src/draw.c index 5369ec5d..0e3c48a0 100644 --- a/src/draw.c +++ b/src/draw.c @@ -660,10 +660,28 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, } else #endif { + int ellipse_a = rect->ellipse_a; + int ellipse_b = rect->ellipse_b; + + if(ellipse_a != -1 && ellipse_b != 360) { + if(flip) { + ellipse_a = 180 - ellipse_a - ellipse_b; + } + if(rot) { + if(rot == 3) { + ellipse_a += 90; + } else if(rot == 2) { + ellipse_a += 180; + } else if(rot == 1) { + ellipse_a += 270; + } + ellipse_a %= 360; + } + } RECTORDER(x1,y1,x2,y2); - drawrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2, dash, rect->ellipse_a, rect->ellipse_b); + drawrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2, dash, ellipse_a, ellipse_b); if(rect->fill) filledrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2, rect->fill, - rect->ellipse_a, rect->ellipse_b); + ellipse_a, ellipse_b); } } } diff --git a/src/move.c b/src/move.c index fdfa2776..d21af1ba 100644 --- a/src/move.c +++ b/src/move.c @@ -23,9 +23,8 @@ #include "xschem.h" -void flip_rotate_ellipse(int c, int n, int rot, int flip) +void flip_rotate_ellipse(xRect *r, int rot, int flip) { - xRect *r = &xctx->rect[c][n]; if(r->ellipse_a == -1) return; else if(r->ellipse_b == 360) return; else { @@ -38,14 +37,12 @@ void flip_rotate_ellipse(int c, int n, int rot, int flip) if(rot) { if(rot == 3) { r->ellipse_a += 90; - r->ellipse_a %= 360; } else if(rot == 2) { r->ellipse_a += 180; - r->ellipse_a %= 360; } else if(rot == 1) { r->ellipse_a += 270; - r->ellipse_a %= 360; } + r->ellipse_a %= 360; my_snprintf(str, S(str), "%d,%d", r->ellipse_a, r->ellipse_b); my_strdup2(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "ellipse", str)); } @@ -775,7 +772,7 @@ void copy_objects(int what) storeobject(-1, xctx->rx1+xctx->deltax, xctx->ry1+xctx->deltay, xctx->rx2+xctx->deltax, xctx->ry2+xctx->deltay,xRECT, c, SELECTED, xctx->rect[c][n].prop_ptr); l = xctx->rects[c] - 1; - flip_rotate_ellipse(c, l, xctx->move_rot, xctx->move_flip); + flip_rotate_ellipse(&xctx->rect[c][l], xctx->move_rot, xctx->move_flip); break; case xTEXT: @@ -1195,7 +1192,7 @@ void move_objects(int what, int merge, double dx, double dy) xctx->rect[c][n].x2, xctx->rect[c][n].y2, xctx->rx2,xctx->ry2); } - flip_rotate_ellipse(c, n, xctx->move_rot, xctx->move_flip); + flip_rotate_ellipse(&xctx->rect[c][n], xctx->move_rot, xctx->move_flip); if( xctx->rect[c][n].sel == SELECTED) { xctx->rx1+=xctx->deltax; diff --git a/src/xschem.h b/src/xschem.h index 3ffbc848..d1cb5495 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1535,7 +1535,7 @@ extern void select_rect(int what, int select); extern void new_rect(int what, double mousex_snap, double mousey_snap); extern void new_polygon(int what, double mousex_snap, double mousey_snap); extern void compile_font(void); -extern void flip_rotate_ellipse(int c, int n, int rot, int flip); +extern void flip_rotate_ellipse(xRect *r, int rot, int flip); extern void rebuild_selected_array(void); extern int get_instance(const char *s);