1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 18:42:28 +02:00

sch2fig/sch.c (draw_text): move to dwg

This commit is contained in:
Werner Almesberger 2016-07-31 14:14:18 -03:00
parent 8dddf961b6
commit d70f8bc7fe
3 changed files with 40 additions and 38 deletions

View File

@ -365,6 +365,43 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
} }
/* ----- Text -------------------------------------------------------------- */
void dwg_text(int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape)
{
struct text txt = {
.s = s,
.size = dim,
.x = x,
.y = y,
.rot = 0,
.hor = text_min,
.vert = text_min,
};
switch (dir) {
case 0: /* right */
break;
case 1: /* up */
text_rot(&txt, 90);
break;
case 2: /* left */
txt.hor = text_max;
break;
case 3: /* down */
text_rot(&txt, 90);
txt.hor = text_max;
break;
default:
assert(2 + 2 == 5);
}
text_fig(&txt, COLOR_TEXT, LAYER_TEXT);
}
/* ----- Connections ------------------------------------------------------- */ /* ----- Connections ------------------------------------------------------- */

View File

@ -32,6 +32,8 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape); enum dwg_shape shape);
void dwg_glabel(int x, int y, const char *s, int dir, int dim, void dwg_glabel(int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape); enum dwg_shape shape);
void dwg_text(int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape);
void dwg_junction(int x, int y); void dwg_junction(int x, int y);
void dwg_noconn(int x, int y); void dwg_noconn(int x, int y);

View File

@ -209,43 +209,6 @@ static enum dwg_shape decode_shape(const char *s)
} }
/* ----- Text -------------------------------------------------------------- */
static void draw_text(int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape)
{
struct text txt = {
.s = s,
.size = dim,
.x = x,
.y = y,
.rot = 0,
.hor = text_min,
.vert = text_min,
};
switch (dir) {
case 0: /* right */
break;
case 1: /* up */
text_rot(&txt, 90);
break;
case 2: /* left */
txt.hor = text_max;
break;
case 3: /* down */
text_rot(&txt, 90);
txt.hor = text_max;
break;
default:
assert(2 + 2 == 5);
}
text_fig(&txt, COLOR_TEXT, LAYER_TEXT);
}
/* ----- Component fields -------------------------------------------------- */ /* ----- Component fields -------------------------------------------------- */
@ -494,7 +457,7 @@ bool sch_parse(struct sch_ctx *ctx, const char *line)
if (sscanf(line, "Text Notes %d %d %d %d", if (sscanf(line, "Text Notes %d %d %d %d",
&obj->x, &obj->y, &text->dir, &text->dim) == 4) { &obj->x, &obj->y, &text->dir, &text->dim) == 4) {
ctx->state = sch_text; ctx->state = sch_text;
obj->u.text.fn = draw_text; obj->u.text.fn = dwg_text;
return 1; return 1;
} }
if (sscanf(line, "Text GLabel %d %d %d %d %ms", if (sscanf(line, "Text GLabel %d %d %d %d %ms",