1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-10-04 07:05:26 +03:00

sch2fig/: add unit letter(s) to component reference of multi-unit components

This commit is contained in:
Werner Almesberger 2016-07-26 08:23:28 -03:00
parent f3abf8f622
commit c2e1d60e2e
4 changed files with 37 additions and 17 deletions

View File

@ -4,7 +4,6 @@
- unify alignment, direction
- support fonts attributes ?
- support line thickness ?
- show unit in component reference
- ~ as space (grep for ~ in out.fig)
- ~ as overline (grep for ~ in out.fig)
- support pin name not inside component

View File

@ -92,19 +92,6 @@ struct obj {
};
struct comp {
const char *name;
unsigned visible; /* visible fields, bit mask */
bool show_pin_name;
bool show_pin_num;
unsigned name_offset;
struct obj *objs;
struct comp *next;
};
/* ----- Drawing ----------------------------------------------------------- */
@ -436,15 +423,17 @@ static bool parse_def(const char *line)
char *s;
char draw_num, draw_name;
unsigned name_offset;
unsigned units;
if (sscanf(line, "DEF %ms %*s %*d %u %c %c",
&s, &name_offset, &draw_num, &draw_name) != 4)
if (sscanf(line, "DEF %ms %*s %*d %u %c %c %u",
&s, &name_offset, &draw_num, &draw_name, &units) != 5)
return 0;
curr_comp = alloc_type(struct comp);
if (*s == '~')
s++;
curr_comp->name = s;
curr_comp->units = units;
curr_comp->visible = 0;
curr_comp->show_pin_name = draw_name == 'Y';

View File

@ -28,7 +28,21 @@ struct lib_ctx {
unsigned lineno;
};
struct comp;
struct obj;
struct comp {
const char *name;
unsigned units;
unsigned visible; /* visible fields, bit mask */
bool show_pin_name;
bool show_pin_num;
unsigned name_offset;
struct obj *objs;
struct comp *next;
};
const struct comp *lib_find(const char *name);

View File

@ -122,6 +122,24 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
return 1;
}
if (n == 0 && ctx->comp->units > 1) {
int len = strlen(txt->s);
char *s;
s = realloc((void *) txt->s, len + 3);
if (!s) {
perror("realloc");
exit(1);
}
if (ctx->unit <= 26)
sprintf(s + len, "%c", 'A' + ctx->unit - 1);
else
sprintf(s + len, "%c%c",
'A' + (ctx->unit - 1) / 26 - 1,
'A' + (ctx->unit - 1) % 26);
txt->s = s;
}
field->next = ctx->fields;
ctx->fields = field;