summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-23 14:26:33 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-23 14:26:33 -0300
commit061dd9094a903be73e3aa7a65aafb8bcb70010b7 (patch)
tree0308cb5d2c81a9f77106652ddc3959e65bef7d81
parent692e72bd999869d113e1d06acfee9783b4a031ac (diff)
downloadeeshow-061dd9094a903be73e3aa7a65aafb8bcb70010b7.tar.gz
eeshow-061dd9094a903be73e3aa7a65aafb8bcb70010b7.tar.bz2
eeshow-061dd9094a903be73e3aa7a65aafb8bcb70010b7.zip
kicad/lib-render.c: improve sectioning
-rw-r--r--kicad/lib-render.c101
1 files changed, 65 insertions, 36 deletions
diff --git a/kicad/lib-render.c b/kicad/lib-render.c
index aedd639..54361ca 100644
--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -25,7 +25,24 @@
#include "kicad/lib.h"
-/* ----- Drawing ----------------------------------------------------------- */
+/* ----- Helper functions -------------------------------------------------- */
+
+
+static void transform_poly(unsigned n, int *vx, int *vy, const int m[6])
+{
+ unsigned i;
+ int x, y;
+
+ for (i = 0; i != n; i++) {
+ x = mx(*vx, *vy, m);
+ y = my(*vx, *vy, m);
+ *vx++ = x;
+ *vy++ = y;
+ }
+}
+
+
+/* ----- Polygons and rectangles ------------------------------------------- */
static void draw_poly(const struct lib_poly *poly, const int m[6])
@@ -85,6 +102,9 @@ static void draw_rect(const struct lib_rect *rect, const int m[6])
}
+/* ----- Circles and arcs -------------------------------------------------- */
+
+
static void draw_circ(const struct lib_circ *circ, const int m[6])
{
int x = mx(circ->x, circ->y, m);
@@ -156,6 +176,9 @@ static void draw_arc(const struct lib_arc *arc, const int m[6])
}
+/* ----- Pin name and number ----------------------------------------------- */
+
+
static void draw_pin_name(const struct comp *comp, const struct lib_pin *pin,
const int m[6], int dx, int dy, int rot, enum text_align hor)
{
@@ -269,18 +292,7 @@ static void draw_pin_num(const struct comp *comp, const struct lib_pin *pin,
}
-static void transform_poly(unsigned n, int *vx, int *vy, const int m[6])
-{
- unsigned i;
- int x, y;
-
- for (i = 0; i != n; i++) {
- x = mx(*vx, *vy, m);
- y = my(*vx, *vy, m);
- *vx++ = x;
- *vy++ = y;
- }
-}
+/* ----- Pin shape --------------------------------------------------------- */
static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
@@ -325,6 +337,11 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
gfx_poly(4, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
+ /*
+ * @@@ known bug: pin_input_low and pin_output_low are "stay up" in
+ * eeschema, while we just rotate them without further ado.
+ */
+
if (shape & pin_input_low) {
x[0] = ex;
y[0] = ey;
@@ -369,6 +386,9 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
}
+/* ----- Pin basics -------------------------------------------------------- */
+
+
static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
const int m[6])
{
@@ -415,6 +435,9 @@ static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
}
+/* ----- Text -------------------------------------------------------------- */
+
+
static void draw_text(const struct lib_text *text, const int m[6])
{
struct text txt = {
@@ -458,6 +481,35 @@ static void draw_text(const struct lib_text *text, const int m[6])
}
+/* ----- Lookup and properties --------------------------------------------- */
+
+
+const struct comp *lib_find(const struct lib *lib, const char *name)
+{
+ const struct comp *comp;
+ const struct comp_alias *alias;
+
+ for (comp = lib->comps; comp; comp = comp->next) {
+ if (!strcmp(comp->name, name))
+ return comp;
+ for (alias = comp->aliases; alias; alias = alias->next)
+ if (!strcmp(alias->name, name))
+ return comp;
+ }
+ error("\"%s\" not found", name);
+ return NULL;
+}
+
+
+bool lib_field_visible(const struct comp *comp, int n)
+{
+ return (comp->visible >> n) & 1;
+}
+
+
+/* ----- Rendering --------------------------------------------------------- */
+
+
static void draw(const struct comp *comp, const struct lib_obj *obj,
const int m[6])
{
@@ -486,29 +538,6 @@ static void draw(const struct comp *comp, const struct lib_obj *obj,
}
-const struct comp *lib_find(const struct lib *lib, const char *name)
-{
- const struct comp *comp;
- const struct comp_alias *alias;
-
- for (comp = lib->comps; comp; comp = comp->next) {
- if (!strcmp(comp->name, name))
- return comp;
- for (alias = comp->aliases; alias; alias = alias->next)
- if (!strcmp(alias->name, name))
- return comp;
- }
- error("\"%s\" not found", name);
- return NULL;
-}
-
-
-bool lib_field_visible(const struct comp *comp, int n)
-{
- return (comp->visible >> n) & 1;
-}
-
-
static void missing_component(const int m[4])
{
int sx = mx(0, 0, m);