1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 19:07:42 +02:00

sch2fig/: display pin numbers

This commit is contained in:
Werner Almesberger 2016-07-24 23:26:54 -03:00
parent d6b73479ad
commit 6f7463c299
3 changed files with 50 additions and 10 deletions

View File

@ -168,6 +168,7 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin,
{
int x[2], y[2];
int dx = 0, dy = 0;
int ox, oy, sx, sy;
int rot;
enum text_align hor, vert;
@ -201,22 +202,47 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin,
y[1] = my(pin->x + dx * pin->length, pin->y + dy * pin->length, m);
fig_poly(2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
dx *= pin->length + comp->name_offset;
dy *= pin->length + comp->name_offset;
ox = dx * (pin->length + comp->name_offset);
oy = dy * (pin->length + comp->name_offset);
struct text txt = {
struct text name_txt = {
.s = pin->name,
.x = mx(pin->x + dx, pin->y + dy, m),
.y = my(pin->x + dx, pin->y + dy, m),
.x = mx(pin->x + ox, pin->y + oy, m),
.y = my(pin->x + ox, pin->y + oy, m),
.size = pin->name_size,
.rot = rot,
.hor = hor,
.vert = text_mid,
};
text_rot(&txt, matrix_to_angle(m));
text_rot(&name_txt, matrix_to_angle(m));
if (comp->show_pin_name)
text_fig(&txt, COLOR_PIN_NAME, LAYER_PIN_NAME);
text_fig(&name_txt, COLOR_PIN_NAME, LAYER_PIN_NAME);
ox = dx * pin->length / 2;
oy = dy * pin->length / 2;
sx = mxr(-dy * PIN_NUM_OFFSET, dx * PIN_NUM_OFFSET, m);
sy = myr(-dy * PIN_NUM_OFFSET, dx * PIN_NUM_OFFSET, m);
if (sx > 0)
sx = -sx;
if (sy > 0)
sy = -sy;
struct text num_txt = {
.s = pin->number,
.x = mx(pin->x + ox, pin->y + oy, m) + sx,
.y = my(pin->x + ox, pin->y + oy, m) + sy,
.size = pin->number_size,
.rot = rot,
.hor = text_mid,
.vert = text_min,
};
text_rot(&num_txt, matrix_to_angle(m));
if (comp->show_pin_num)
text_fig(&num_txt, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER);
}

View File

@ -17,17 +17,30 @@
#include <stdbool.h>
static inline int mxr(int x, int y, int m[6])
{
return x * m[1] + y * m[2];
}
static inline int myr(int x, int y, int m[6])
{
return x * m[4] + y * m[5];
}
static inline int mx(int x, int y, int m[6])
{
return m[0] + x * m[1] + y * m[2];
return m[0] + mxr(x, y, m);
}
static inline int my(int x, int y, int m[6])
{
return m[3] + x * m[4] + y * m[5];
return m[3] + myr(x, y, m);
}
unsigned matrix_to_angle(int m[6]);
#endif /* !MISC_H */

View File

@ -31,7 +31,7 @@
#define COLOR_GLABEL COLOR_RED4
#define COLOR_FIELD COLOR_CYAN3
#define COLOR_PIN_NAME COLOR_FIELD
#define COLOR_PIN_NUMBER COLOR_FIELD
#define COLOR_PIN_NUMBER COLOR_RED4
#define FONT_HELVETICA_BOLD 18
@ -55,5 +55,6 @@
#define NOCONN_LEN 25
#define GLABEL_OFFSET 20
#define PIN_NUM_OFFSET 15
#endif /* !STYLE_H */