From 47605368e91e04ff2cc7a54b9c12c53f5460084d Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 11 Jul 2023 01:14:06 +0800 Subject: [PATCH] draw --- scf_def.h | 1 + ses_layout.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/scf_def.h b/scf_def.h index 707a2a8..87c4c39 100644 --- a/scf_def.h +++ b/scf_def.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/ses_layout.c b/ses_layout.c index 0f36a07..9b08cac 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -511,17 +511,6 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ scf_logw("j: %ld, c->id: %ld, n_pins: %ld, ", j, c->id, c->n_pins); - for (k = 0; k < c->n_pins; k++) { - p = c->pins[k]; - - printf("p[%ld]: %d,%d, ", k, p->x, p->y); - - if (0 == k) - cairo_move_to(cr, p->x, p->y); - else - cairo_line_to(cr, p->x, p->y); - } - switch (c->type) { case SCF_EDA_Battery: @@ -540,10 +529,25 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ cairo_move_to(cr, c->x - 7, c->y + 5); cairo_line_to(cr, c->x + 7, c->y + 5); } + + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + + p = c->pins[SCF_EDA_Battery_NEG]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); break; case SCF_EDA_Resistor: cairo_rectangle(cr, c->x - 5, c->y - 5, 10, 10); + + p = c->pins[0]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + + p = c->pins[1]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); break; case SCF_EDA_Diode: @@ -560,7 +564,30 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ cairo_line_to(cr, c->x, c->y - 3); cairo_line_to(cr, c->x + 5, c->y + 5); } + + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + + p = c->pins[SCF_EDA_Diode_NEG]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); break; + + case SCF_EDA_Transistor: + cairo_arc(cr, c->x, c->y, 5, 0, 2 * M_PI); + + p = c->pins[SCF_EDA_Transistor_E]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + + p = c->pins[SCF_EDA_Transistor_C]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + + p = c->pins[SCF_EDA_Transistor_B]; + cairo_move_to(cr, c->x, c->y); + cairo_line_to(cr, p->x, p->y); + default: break; }; -- 2.25.1