draw
authoryu.dongliang <18588496441@163.com>
Mon, 10 Jul 2023 17:14:06 +0000 (01:14 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 10 Jul 2023 17:14:06 +0000 (01:14 +0800)
scf_def.h
ses_layout.c

index 707a2a820b3d4d92e1553ef8bb0cb73d79fcb73d..87c4c3918d11cf583f9480774c1b0c7f77320cc1 100644 (file)
--- a/scf_def.h
+++ b/scf_def.h
@@ -3,6 +3,7 @@
 
 #include<stdio.h>
 #include<stdint.h>
+#include<math.h>
 #include<stdlib.h>
 #include<stddef.h>
 #include<string.h>
index 0f36a07932cf54f7fcbbd90247067545dbf63dcf..9b08caceecc81a4ae6c81a7d974d660166d6353e 100644 (file)
@@ -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;
                        };