1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-30 08:56:13 +02:00

sch2fig/: support subsheet box and exported labels (WIP)

This commit is contained in:
Werner Almesberger 2016-07-29 20:48:06 -03:00
parent 8721964568
commit 2e68f85914
3 changed files with 84 additions and 3 deletions

View File

@ -255,6 +255,69 @@ static void dump_fields(struct sch_field *fields, int m[6])
} }
/* ----- Sheet field ------------------------------------------------------- */
static enum fig_shape decode_form(char form)
{
switch (form) {
case 'O':
return fig_in;
case 'I':
return fig_out;
case 'B':
/* fall through */
case 'T':
return fig_bidir;
case 'U':
return fig_unspec;
default:
fprintf(stderr, "unknown form: \"%c\"\n", form);
exit(1);
}
}
static int decode_side(char side)
{
switch (side) {
case 'L':
return 2; /* left */
case 'B':
return 1; /* up */
case 'R':
return 0; /* right */
case 'T':
return 3; /* down */
default:
fprintf(stderr, "unknown side: \"%c\"\n", side);
exit(1);
}
}
static bool parse_hsheet_field(struct sch_ctx *ctx, const char *line)
{
char *s;
int x, y;
char form, side;
unsigned n, dim;
if (sscanf(line, "F%d \"%m[^\"]\" %u", &n, &s, &dim) == 3) {
assert(n < 2);
return 1; /* @@@ later */
}
if (sscanf(line, "F%d \"%m[^\"]\" %c %c %d %d %u",
&n, &s, &form, &side, &x, &y, &dim) != 7)
return 0;
assert(n >= 2);
dwg_hlabel(x, y, s, decode_side(side), dim, decode_form(form));
free(s);
return 1;
}
/* ----- Schematics parser ------------------------------------------------- */ /* ----- Schematics parser ------------------------------------------------- */
@ -406,10 +469,22 @@ bool sch_parse(struct sch_ctx *ctx, const char *line)
} }
break; break;
case sch_sheet: case sch_sheet:
if (sscanf(line, "$EndSheet%n", &n) || !n) if (sscanf(line, "$EndSheet%n", &n) == 0 && n) {
return 1;
ctx->state = sch_basic; ctx->state = sch_basic;
return 1; return 1;
}
if (sscanf(line, "S %d %d %u %u",
&ctx->x, &ctx->y, &ctx->w, &ctx->h) == 4) {
fig_rect(ctx->x, ctx->y,
ctx->x + ctx->w, ctx->y + ctx->h,
COLOR_HSHEET, COLOR_NONE, LAYER_HSHEET);
return 1;
}
if (sscanf(line, "U %*x%n", &n) == 0 && n)
return 1;
if (parse_hsheet_field(ctx, line))
return 1;
break;
case sch_text: case sch_text:
ctx->state = sch_basic; ctx->state = sch_basic;
if (ctx->text) if (ctx->text)

View File

@ -51,6 +51,10 @@ struct sch_ctx {
unsigned unit; /* unit of current component */ unsigned unit; /* unit of current component */
struct sch_field *fields; struct sch_field *fields;
/* subsheet */
unsigned h, w;
unsigned lineno; unsigned lineno;
}; };

View File

@ -32,6 +32,7 @@
#define COLOR_NOCONN COLOR_BLUE #define COLOR_NOCONN COLOR_BLUE
#define COLOR_GLABEL COLOR_RED4 #define COLOR_GLABEL COLOR_RED4
#define COLOR_HLABEL COLOR_BROWN2 /* @@@ */ #define COLOR_HLABEL COLOR_BROWN2 /* @@@ */
#define COLOR_HSHEET COLOR_HLABEL
#define COLOR_LABEL COLOR_BLACK #define COLOR_LABEL COLOR_BLACK
#define COLOR_FIELD COLOR_CYAN4 #define COLOR_FIELD COLOR_CYAN4
#define COLOR_PIN_NAME COLOR_FIELD #define COLOR_PIN_NAME COLOR_FIELD
@ -48,6 +49,7 @@
#define LAYER_FIELD 60 #define LAYER_FIELD 60
#define LAYER_PIN_NAME LAYER_FIELD #define LAYER_PIN_NAME LAYER_FIELD
#define LAYER_PIN_NUMBER LAYER_FIELD #define LAYER_PIN_NUMBER LAYER_FIELD
#define LAYER_HSHEET 70
#define LAYER_LINES 100 #define LAYER_LINES 100
#define LAYER_COMP_DWG 120 #define LAYER_COMP_DWG 120
#define LAYER_COMP_DWG_BG 200 #define LAYER_COMP_DWG_BG 200