mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-27 02:49:22 +02:00
sch2fig/: slight cleanup
This commit is contained in:
parent
da22f1cc57
commit
1bab610e9e
@ -45,6 +45,9 @@ static inline float pt(int x)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Library items ----------------------------------------------------- */
|
||||
|
||||
|
||||
void fig_rect(int sx, int sy, int ex, int ey)
|
||||
{
|
||||
// Type Thick Depth StyleV Rad
|
||||
@ -76,7 +79,8 @@ void fig_poly(int points, int x[points], int y[points])
|
||||
}
|
||||
|
||||
|
||||
#define OFF 20
|
||||
/* ----- Schematics items -------------------------------------------------- */
|
||||
|
||||
|
||||
void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
||||
enum fig_shape shape)
|
||||
@ -93,7 +97,7 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
||||
int n = 6;
|
||||
int vx[5];
|
||||
int vy[5];
|
||||
int half = (dim >> 1) + OFF;
|
||||
int half = (dim >> 1) + GLABEL_OFFSET;
|
||||
|
||||
switch (dir) {
|
||||
case 0:
|
||||
@ -106,21 +110,29 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
||||
|
||||
switch (shape) {
|
||||
case fig_in:
|
||||
text_shift(&txt, txt.hor, text_mid, -OFF - half, 0);
|
||||
text_rel(&txt, text_min, text_min, -OFF, OFF, vx + 1, vy + 1);
|
||||
text_rel(&txt, text_max, text_min, OFF, OFF, vx + 2, vy + 2);
|
||||
text_rel(&txt, text_max, text_mid, OFF + half, 0,
|
||||
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET - half, 0);
|
||||
text_rel(&txt, text_min, text_min,
|
||||
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
||||
text_rel(&txt, text_max, text_min,
|
||||
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
|
||||
text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
|
||||
vx + 3, vy + 3);
|
||||
text_rel(&txt, text_max, text_max, OFF, -OFF, vx + 4, vy + 4);
|
||||
text_rel(&txt, text_min, text_max, -OFF, -OFF, vx + 5, vy + 5);
|
||||
text_rel(&txt, text_max, text_max,
|
||||
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
|
||||
text_rel(&txt, text_min, text_max,
|
||||
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
|
||||
break;
|
||||
case fig_out:
|
||||
text_shift(&txt, txt.hor, text_mid, -OFF, 0);
|
||||
text_rel(&txt, text_min, text_min, -OFF, OFF, vx + 1, vy + 1);
|
||||
text_rel(&txt, text_max, text_min, OFF, OFF, vx + 2, vy + 2);
|
||||
text_rel(&txt, text_max, text_max, OFF, -OFF, vx + 3, vy + 3);
|
||||
text_rel(&txt, text_min, text_max, -OFF, -OFF, vx + 4, vy + 4);
|
||||
text_rel(&txt, text_min, text_mid, -OFF - half, 0,
|
||||
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET, 0);
|
||||
text_rel(&txt, text_min, text_min,
|
||||
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
||||
text_rel(&txt, text_max, text_min,
|
||||
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
|
||||
text_rel(&txt, text_max, text_max,
|
||||
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 3, vy + 3);
|
||||
text_rel(&txt, text_min, text_max,
|
||||
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
|
||||
text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
|
||||
vx + 5, vy + 5);
|
||||
break;
|
||||
default:
|
||||
@ -168,6 +180,9 @@ void fig_line(int sx, int sy, int ex, int ey)
|
||||
}
|
||||
|
||||
|
||||
/* ----- General items ----------------------------------------------------- */
|
||||
|
||||
|
||||
void fig_text(int x, int y, const char *s, unsigned size,
|
||||
enum text_align align, int rot, unsigned color, unsigned layer)
|
||||
{
|
||||
@ -180,6 +195,9 @@ void fig_text(int x, int y, const char *s, unsigned size,
|
||||
}
|
||||
|
||||
|
||||
/* ----- FIG file header --------------------------------------------------- */
|
||||
|
||||
|
||||
void fig_init(void)
|
||||
{
|
||||
printf("#FIG 3.2\n");
|
||||
|
@ -91,6 +91,9 @@ struct comp {
|
||||
};
|
||||
|
||||
|
||||
/* ----- Drawing ----------------------------------------------------------- */
|
||||
|
||||
|
||||
static struct comp *comps = NULL;
|
||||
static struct comp **next_comp = &comps;
|
||||
static struct obj **next_obj;
|
||||
@ -206,6 +209,9 @@ found:
|
||||
}
|
||||
|
||||
|
||||
/* ----- Text -------------------------------------------------------------- */
|
||||
|
||||
|
||||
static enum text_style decode_style(const char *s)
|
||||
{
|
||||
if (!strcmp(s, "Normal"))
|
||||
@ -214,6 +220,9 @@ static enum text_style decode_style(const char *s)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Polygons ---------------------------------------------------------- */
|
||||
|
||||
|
||||
static bool parse_poly(struct obj *obj, const char *line, int points)
|
||||
{
|
||||
int i, n;
|
||||
@ -233,6 +242,9 @@ static bool parse_poly(struct obj *obj, const char *line, int points)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Library parser ---------------------------------------------------- */
|
||||
|
||||
|
||||
bool lib_parse(struct lib_ctx *ctx, const char *line)
|
||||
{
|
||||
int n = 0;
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include "sch.h"
|
||||
|
||||
|
||||
/* ----- (Global) Labels --------------------------------------------------- */
|
||||
|
||||
|
||||
static enum fig_shape do_decode_shape(const char *s)
|
||||
{
|
||||
if (!strcmp(s, "UnSpc"))
|
||||
@ -50,6 +53,9 @@ static enum fig_shape decode_shape(const char *s)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Text -------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void draw_text(int x, int y, const char *s, int dir, int dim,
|
||||
enum fig_shape shape)
|
||||
{
|
||||
@ -57,6 +63,9 @@ static void draw_text(int x, int y, const char *s, int dir, int dim,
|
||||
}
|
||||
|
||||
|
||||
/* ----- Component fields -------------------------------------------------- */
|
||||
|
||||
|
||||
struct sch_field {
|
||||
struct text txt;
|
||||
struct sch_field *next;
|
||||
@ -179,6 +188,9 @@ static void dump_fields(struct sch_field *fields, int m[6])
|
||||
}
|
||||
|
||||
|
||||
/* ----- Schematics parser ------------------------------------------------- */
|
||||
|
||||
|
||||
bool sch_parse(struct sch_ctx *ctx, const char *line)
|
||||
{
|
||||
int n = 0;
|
||||
|
@ -42,4 +42,6 @@
|
||||
|
||||
#define JUNCTION_R 40
|
||||
|
||||
#define GLABEL_OFFSET 20
|
||||
|
||||
#endif /* !STYLE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user