2016-07-22 06:04:42 +03:00
|
|
|
/*
|
|
|
|
* sch.h - Parse Eeschema .sch file
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-07-22 05:54:32 +03:00
|
|
|
#ifndef SCH_H
|
|
|
|
#define SCH_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-07-27 02:34:12 +03:00
|
|
|
#include "text.h"
|
2016-07-24 04:52:15 +03:00
|
|
|
#include "lib.h"
|
|
|
|
|
2016-07-22 05:54:32 +03:00
|
|
|
|
|
|
|
enum sch_state {
|
|
|
|
sch_basic, /* basic state */
|
|
|
|
sch_descr, /* prelude and description */
|
|
|
|
sch_comp, /* component */
|
|
|
|
sch_sheet, /* sub-sheet */
|
|
|
|
sch_text, /* text or label */
|
|
|
|
sch_wire, /* wire */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sch_ctx {
|
|
|
|
enum sch_state state;
|
|
|
|
void (*wire)(int sx, int sy, int ex, int ey);
|
|
|
|
|
|
|
|
/* text and component */
|
|
|
|
|
|
|
|
int x, y; /* saved coordinates */
|
|
|
|
|
|
|
|
/* text */
|
|
|
|
|
|
|
|
void (*text)(int x, int y, const char *s, int dir, int dim,
|
|
|
|
enum fig_shape shape);
|
|
|
|
int dir; /* orientation */
|
|
|
|
int dim; /* dimension */
|
|
|
|
enum fig_shape shape;
|
|
|
|
|
|
|
|
/* component */
|
|
|
|
|
2016-07-24 04:52:15 +03:00
|
|
|
const struct comp *comp; /* current component */
|
2016-07-22 05:54:32 +03:00
|
|
|
unsigned unit; /* unit of current component */
|
2016-07-23 20:59:37 +03:00
|
|
|
struct sch_field *fields;
|
2016-07-22 05:54:32 +03:00
|
|
|
|
2016-07-30 02:48:06 +03:00
|
|
|
/* subsheet */
|
|
|
|
|
|
|
|
unsigned h, w;
|
2016-07-30 03:43:27 +03:00
|
|
|
const char *sheet;
|
|
|
|
unsigned sheet_dim;
|
|
|
|
const char *file;
|
|
|
|
unsigned file_dim;
|
|
|
|
bool rotated;
|
2016-07-30 02:48:06 +03:00
|
|
|
|
2016-07-22 05:54:32 +03:00
|
|
|
unsigned lineno;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-27 02:34:12 +03:00
|
|
|
void decode_alignment(struct text *txt, char hor, char vert);
|
|
|
|
|
2016-07-22 05:54:32 +03:00
|
|
|
bool sch_parse(struct sch_ctx *ctx, const char *line);
|
|
|
|
void sch_init(struct sch_ctx *ctx);
|
|
|
|
|
|
|
|
#endif /* !SCH_H */
|