summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
Diffstat (limited to 'kicad')
-rw-r--r--kicad/dwg.c94
-rw-r--r--kicad/dwg.h21
-rw-r--r--kicad/lib-render.c171
-rw-r--r--kicad/lib.h9
-rw-r--r--kicad/pl-render.c16
-rw-r--r--kicad/pl.h5
-rw-r--r--kicad/sch-render.c41
-rw-r--r--kicad/sch.h11
8 files changed, 200 insertions, 168 deletions
diff --git a/kicad/dwg.c b/kicad/dwg.c
index 799c329..f925539 100644
--- a/kicad/dwg.c
+++ b/kicad/dwg.c
@@ -80,7 +80,7 @@ static enum box_type flip_box(enum box_type box)
}
-void dwg_label(int x, int y, const char *s, int dir, int dim,
+void dwg_label(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -121,11 +121,11 @@ void dwg_label(int x, int y, const char *s, int dir, int dim,
txt.y -= dy * LABEL_OFFSET;
txt.x += dx * LABEL_OFFSET;
- text_fig(&txt, COLOR_LABEL, LAYER_LABEL);
+ text_fig(&txt, gfx, COLOR_LABEL, LAYER_LABEL);
}
-void dwg_glabel(int x, int y, const char *s, int dir, int dim,
+void dwg_glabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -198,75 +198,75 @@ void dwg_glabel(int x, int y, const char *s, int dir, int dim,
switch (box) {
case box_simple:
n = 5;
- text_shift(&txt, txt.hor, text_mid, shift_flat, 0);
- text_rel(&txt, text_min, text_min,
+ text_shift(&txt, gfx, txt.hor, text_mid, shift_flat, 0);
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 3, vy + 3);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
break;
case box_right:
- text_shift(&txt, txt.hor, text_mid,
+ text_shift(&txt, gfx, txt.hor, text_mid,
anchor_right ? shift_tip : shift_flat, 0);
- text_rel(&txt, text_min, text_min,
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
+ text_rel(&txt, gfx, text_max, text_mid, GLABEL_OFFSET + half, 0,
vx + 3, vy + 3);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
break;
case box_left:
- text_shift(&txt, txt.hor, text_mid,
+ text_shift(&txt, gfx, txt.hor, text_mid,
anchor_right ? shift_flat : shift_tip, 0);
- text_rel(&txt, text_min, text_min,
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 3, vy + 3);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
+ text_rel(&txt, gfx, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 5, vy + 5);
break;
case box_both:
n = 7;
- text_shift(&txt, txt.hor, text_mid, shift_tip, 0);
- text_rel(&txt, text_min, text_min,
+ text_shift(&txt, gfx, txt.hor, text_mid, shift_tip, 0);
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
+ text_rel(&txt, gfx, text_max, text_mid, GLABEL_OFFSET + half, 0,
vx + 3, vy + 3);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
- text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
+ text_rel(&txt, gfx, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 6, vy + 6);
break;
default:
assert(0);
}
- text_fig(&txt, COLOR_GLABEL, LAYER_GLABEL);
+ text_fig(&txt, gfx, COLOR_GLABEL, LAYER_GLABEL);
vx[0] = vx[n - 1];
vy[0] = vy[n - 1];
- gfx_poly(n, vx, vy, COLOR_GLABEL, COLOR_NONE, LAYER_GLABEL);
+ gfx_poly(gfx, n, vx, vy, COLOR_GLABEL, COLOR_NONE, LAYER_GLABEL);
if (bbox)
bbox_from_poly(bbox, n, vx, vy);
if (asprintf(&tag, "G:%s", s)) {}
- gfx_tag(tag, n, vx, vy);
+ gfx_tag(gfx, tag, n, vx, vy);
}
@@ -325,7 +325,7 @@ static int make_box(enum box_type box, int h, int *vx, int *vy)
}
-void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
+void dwg_hlabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -396,15 +396,15 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
txt.rot = rot % 180;
- text_fig(&txt, COLOR_HLABEL, LAYER_HLABEL);
- gfx_poly(n + 1, vx, vy, COLOR_HLABEL, COLOR_NONE, LAYER_HLABEL);
+ text_fig(&txt, gfx, COLOR_HLABEL, LAYER_HLABEL);
+ gfx_poly(gfx, n + 1, vx, vy, COLOR_HLABEL, COLOR_NONE, LAYER_HLABEL);
}
/* ----- Text -------------------------------------------------------------- */
-void dwg_text(int x, int y, const char *s, int dir, int dim,
+void dwg_text(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -434,27 +434,27 @@ void dwg_text(int x, int y, const char *s, int dir, int dim,
assert(2 + 2 == 5);
}
- text_fig(&txt, COLOR_TEXT, LAYER_TEXT);
+ text_fig(&txt, gfx, COLOR_TEXT, LAYER_TEXT);
}
/* ----- Connections ------------------------------------------------------- */
-void dwg_junction(int x, int y)
+void dwg_junction(struct gfx *gfx, int x, int y)
{
- gfx_circ(x, y, JUNCTION_R, COLOR_NONE, COLOR_WIRE, LAYER_WIRES);
+ gfx_circ(gfx, x, y, JUNCTION_R, COLOR_NONE, COLOR_WIRE, LAYER_WIRES);
}
-void dwg_noconn(int x, int y)
+void dwg_noconn(struct gfx *gfx, int x, int y)
{
int vx[2] = { x - NOCONN_LEN, x + NOCONN_LEN };
int vy[2] = { y - NOCONN_LEN, y + NOCONN_LEN };
- gfx_poly(2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
+ gfx_poly(gfx, 2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
swap(vy[0], vy[1]);
- gfx_poly(2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
+ gfx_poly(gfx, 2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
}
@@ -469,33 +469,33 @@ void dwg_noconn(int x, int y)
* treat reversed lines as still equal.
*/
-void dwg_line(int sx, int sy, int ex, int ey)
+void dwg_line(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
if (sx < ex || (sx == ex && sy < ey))
- gfx_line(sx, sy, ex, ey, COLOR_SHEET_DWG, LAYER_LINES);
+ gfx_line(gfx, sx, sy, ex, ey, COLOR_SHEET_DWG, LAYER_LINES);
else
- gfx_line(ex, ey, sx, sy, COLOR_SHEET_DWG, LAYER_LINES);
+ gfx_line(gfx, ex, ey, sx, sy, COLOR_SHEET_DWG, LAYER_LINES);
}
/* ----- Wires and busses -------------------------------------------------- */
-void dwg_wire(int sx, int sy, int ex, int ey)
+void dwg_wire(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
int vx[] = { sx, ex };
int vy[] = { sy, ey };
// WIDTH_WIRE
- gfx_poly(2, vx, vy, COLOR_WIRE, COLOR_NONE, LAYER_WIRES);
+ gfx_poly(gfx, 2, vx, vy, COLOR_WIRE, COLOR_NONE, LAYER_WIRES);
}
-void dwg_bus(int sx, int sy, int ex, int ey)
+void dwg_bus(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
int vx[] = { sx, ex };
int vy[] = { sy, ey };
// WIDTH_BUS
- gfx_poly(2, vx, vy, COLOR_BUS, COLOR_NONE, LAYER_BUSSES);
+ gfx_poly(gfx, 2, vx, vy, COLOR_BUS, COLOR_NONE, LAYER_BUSSES);
}
diff --git a/kicad/dwg.h b/kicad/dwg.h
index 2875b48..be1ac60 100644
--- a/kicad/dwg.h
+++ b/kicad/dwg.h
@@ -14,6 +14,9 @@
#ifndef KICAD_DWG_H
#define KICAD_DWG_H
+#include "gfx/gfx.h"
+
+
enum dwg_shape {
dwg_unspec, // UnSpc
dwg_in, // Input
@@ -28,21 +31,21 @@ struct dwg_bbox {
};
-void dwg_label(int x, int y, const char *s, int dir, int dim,
+void dwg_label(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
+void dwg_hlabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_glabel(int x, int y, const char *s, int dir, int dim,
+void dwg_glabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_text(int x, int y, const char *s, int dir, int dim,
+void dwg_text(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_junction(int x, int y);
-void dwg_noconn(int x, int y);
+void dwg_junction(struct gfx *gfx, int x, int y);
+void dwg_noconn(struct gfx *gfx, int x, int y);
-void dwg_line(int sx, int sy, int ex, int ey);
+void dwg_line(struct gfx *gfx, int sx, int sy, int ex, int ey);
-void dwg_wire(int sx, int sy, int ex, int ey);
-void dwg_bus(int sx, int sy, int ex, int ey);
+void dwg_wire(struct gfx *gfx, int sx, int sy, int ex, int ey);
+void dwg_bus(struct gfx *gfx, int sx, int sy, int ex, int ey);
#endif /* !KICAD_DWG_H */
diff --git a/kicad/lib-render.c b/kicad/lib-render.c
index 7a08ea3..3e62bba 100644
--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -60,7 +60,8 @@ static void transform_poly_md(unsigned n, int *vx, int *vy, const int m[6],
/* ----- Polygons and rectangles ------------------------------------------- */
-static void draw_poly(const struct lib_poly *poly, const int m[6])
+static void draw_poly(const struct lib_poly *poly, struct gfx *gfx,
+ const int m[6])
{
int n = poly->points;
int x[n];
@@ -72,17 +73,17 @@ static void draw_poly(const struct lib_poly *poly, const int m[6])
y[i] = my(poly->x[i], poly->y[i], m);
}
- gfx_poly(n, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, n, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
switch (poly->fill) {
case 'N':
break;
case 'F':
- gfx_poly(n, x, y, COLOR_NONE, COLOR_COMP_DWG,
+ gfx_poly(gfx, n, x, y, COLOR_NONE, COLOR_COMP_DWG,
LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_poly(n, x, y, COLOR_NONE, COLOR_COMP_DWG_BG,
+ gfx_poly(gfx, n, x, y, COLOR_NONE, COLOR_COMP_DWG_BG,
LAYER_COMP_DWG_BG);
break;
default:
@@ -91,24 +92,26 @@ static void draw_poly(const struct lib_poly *poly, const int m[6])
}
-static void draw_rect(const struct lib_rect *rect, const int m[6])
+static void draw_rect(const struct lib_rect *rect, struct gfx *gfx,
+ const int m[6])
{
int sx = mx(rect->sx, rect->sy, m);
int sy = my(rect->sx, rect->sy, m);
int ex = mx(rect->ex, rect->ey, m);
int ey = my(rect->ex, rect->ey, m);
- gfx_rect(sx, sy, ex, ey, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_rect(gfx, sx, sy, ex, ey,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
switch (rect->fill) {
case 'N':
break;
case 'F':
- gfx_rect(sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG,
+ gfx_rect(gfx, sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG,
LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_rect(sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG_BG,
+ gfx_rect(gfx, sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG_BG,
LAYER_COMP_DWG_BG);
break;
default:
@@ -120,24 +123,25 @@ 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])
+static void draw_circ(const struct lib_circ *circ, struct gfx *gfx,
+ const int m[6])
{
int x = mx(circ->x, circ->y, m);
int y = my(circ->x, circ->y, m);
int r = circ->r;