From ba5627cd2e584cbc6f1a7c6833d39e2692eb8ea9 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 11 Jul 2023 20:08:54 +0800 Subject: [PATCH] eda draw Transistor --- ses_layout.c | 56 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index 5b10968..8562d98 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -471,6 +471,9 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ ScfEfunction* f; ScfEline* el; ScfEpin* p; + ScfEpin* pb; + ScfEpin* pc; + ScfEpin* pe; ScfLine* l; cairo_surface_t* surface; @@ -665,20 +668,53 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ break; case SCF_EDA_Transistor: - cairo_arc(cr, c->x, c->y, 5, 0, 2 * M_PI); + pb = c->pins[SCF_EDA_Transistor_B]; + pc = c->pins[SCF_EDA_Transistor_C]; + pe = c->pins[SCF_EDA_Transistor_E]; - p = c->pins[SCF_EDA_Transistor_E]; - cairo_move_to(cr, c->x, c->y); - cairo_line_to(cr, p->x, p->y); + vertical(&dx0, &dy0, c->x - pb->x, c->y - pb->y, 8); + vertical(&dx2, &dy2, c->x - pb->x, c->y - pb->y, -16); + forward (&dx3, &dy3, c->x - pb->x, c->y - pb->y, 16); - p = c->pins[SCF_EDA_Transistor_C]; - cairo_move_to(cr, c->x, c->y); - cairo_line_to(cr, p->x, p->y); + cairo_arc(cr, c->x + dx3 / 4, c->y + dy3 / 4, 12, 0, 2 * M_PI); - p = c->pins[SCF_EDA_Transistor_B]; - cairo_move_to(cr, c->x, c->y); - cairo_line_to(cr, p->x, p->y); + cairo_move_to (cr, pb->x, pb->y); + cairo_line_to (cr, c->x, c->y); + cairo_rel_move_to(cr, dx0, dy0); + cairo_rel_line_to(cr, dx2, dy2); + + if (pc->y < pe->y) { + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, pe->x, pe->y); + + vertical(&dx1, &dy1, dx3 + dx0, dy3 + dy0, 3); + forward (&dx4, &dy4, dx3 + dx0, dy3 + dy0, 8); + cairo_move_to(cr, c->x + dx4 + dx1, c->y + dy4 + dy1); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, c->x + dx4 - dx1, c->y + dy4 - dy1); + + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, pc->x, pc->y); + } else { + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, c->x + dx3 + dx0, c->y + dy3 + dy0); + cairo_line_to(cr, pc->x, pc->y); + + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, pe->x, pe->y); + + vertical(&dx1, &dy1, dx3 - dx0, dy3 - dy0, 3); + forward (&dx4, &dy4, dx3 - dx0, dy3 - dy0, 8); + + cairo_move_to(cr, c->x + dx4 + dx1, c->y + dy4 + dy1); + cairo_line_to(cr, c->x + dx3 - dx0, c->y + dy3 - dy0); + cairo_line_to(cr, c->x + dx4 - dx1, c->y + dy4 - dy1); + } + break; default: break; }; -- 2.25.1