eda draw Transistor
authoryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 12:08:54 +0000 (20:08 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 12:08:54 +0000 (20:08 +0800)
ses_layout.c

index 5b109683f8548605358d6304570cc8043a021eb0..8562d98537a5a1abb1d42418f193594213128812 100644 (file)
@@ -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;
                        };