/* * fig.c - Generate FIG output for Eeschema items * * Written 2016 by Werner Almesberger * Copyright 2016 by Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include #include "style.h" #include "text.h" #include "fig.h" /* * FIG works with 1/1200 in * KiCad works with mil * 1 point = 1/72 in */ static inline int cx(int x) { return x * 1200 / 1000; } static inline int cy(int y) { return y * 1200 / 1000; } static inline float pt(int x) { return cx(x) * 72 * 1.5 / 1200.0; } void fig_rect(int sx, int sy, int ex, int ey) { // Type Thick Depth StyleV Rad // SubTy Color Pen Join FwdAr // Style FillCol AreaFil Cap BwdAr printf("2 2 0 %d %d 7 %d -1 -1 0.0 1 1 -1 0 0 5\n", WIDTH_COMP_DWG, COLOR_COMP_DWG, LAYER_COMP_DWG); printf("\t%d %d %d %d %d %d %d %d %d %d\n", cx(sx), cy(sy), cx(ex), cy(sy), cx(ex), cy(ey), cx(sx), cy(ey), cx(sx), cy(sy)); } void fig_poly(int points, int x[points], int y[points]) { int i; char ch = '\t'; // Type Thick Depth StyleV Rad // SubTy Color Pen Join FwdAr // Style FillCol AreaFil Cap BwdAr printf("2 1 0 %d %d 7 %d -1 -1 0.0 1 1 -1 0 0 %d\n", WIDTH_COMP_DWG, COLOR_COMP_DWG, LAYER_COMP_DWG, points); for (i = 0; i != points; i++) { printf("%c%d %d", ch, cx(x[i]), cy(y[i])); ch = ' '; } printf("\n"); } void fig_glabel(int x, int y, const char *s, int dir, int dim, enum fig_shape shape) { } void fig_junction(int x, int y) { // Type Thick Depth StyleV Cx Rx Sx Ex // SubTy Color Pen Dir Cy Ry Sy Ey // Style FillCol AreaFil Angle printf("1 3 0 0 -1 %d %d -1 20 0.0 1 0.0 %d %d %d %d %d %d %d %d\n", COLOR_WIRE, LAYER_WIRES, cx(x), cy(y), JUNCTION_R, JUNCTION_R, cx(x), cy(y), cx(x) + JUNCTION_R, cy(y)); } void fig_wire(int sx, int sy, int ex, int ey) { // TypeStyle FillCol AreaFil Cap FwdAr // SubTy Color Pen StyleV Rad BwdAr // Thick Depth Join Points printf("2 1 0 %d %d 7 %d -1 -1 0.0 1 1 -1 0 0 2\n", WIDTH_WIRE, COLOR_WIRE, LAYER_WIRES); printf("\t%d %d %d %d\n", cx(sx), cy(sy), cx(ex), cy(ey)); } void fig_line(int sx, int sy, int ex, int ey) { // TypeStyle FillCol AreaFil Cap FwdAr // SubTy Color Pen StyleV Rad BwdAr // Thick Depth Join Points printf("2 1 2 %d %d 7 %d -1 -1 3.0 1 1 -1 0 0 2\n", WIDTH_LINE, COLOR_SHEET_DWG, LAYER_LINES); printf("\t%d %d %d %d\n", cx(sx), cy(sy), cx(ex), cy(ey)); } void fig_text(int x, int y, const char *s, unsigned size, enum text_align align, int rot, unsigned color, unsigned layer) { // Type Depth FontSiz Height // Just Pen Angle Length // Color Font Flags X Y printf("4 %u %d %d -1 %d %f %f 4 0.0 0.0 %d %d %s\\001\n", align, color, layer, FONT_HELVETICA_BOLD, pt(size), rot / 3.1415926 * 180, cx(x), cy(y), s); } void fig_init(void) { printf("#FIG 3.2\n"); printf("Landscape\n"); printf("Center\n"); printf("Metric\n"); printf("A4\n"); printf("100.00\n"); printf("Single\n"); printf("-2\n"); printf("1200 2\n"); }