1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 12:38:27 +02:00

sch2fig/: support mirrored symbols (matrix -1 0 0 -1)

This commit is contained in:
Werner Almesberger 2016-07-25 14:58:39 -03:00
parent ed02cafaf5
commit 3588992947
4 changed files with 42 additions and 0 deletions

View File

@ -264,6 +264,13 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin,
}; };
text_rot(&name_txt, matrix_to_angle(m)); text_rot(&name_txt, matrix_to_angle(m));
if (matrix_is_mirrored(m)) {
if ((name_txt.rot % 180) == 0)
name_txt.hor = text_flip(name_txt.hor);
else
name_txt.vert = text_flip(name_txt.vert);
}
switch (name_txt.rot) { switch (name_txt.rot) {
case 180: case 180:
text_flip_x(&name_txt); text_flip_x(&name_txt);
@ -295,6 +302,13 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin,
}; };
text_rot(&num_txt, matrix_to_angle(m) % 180); text_rot(&num_txt, matrix_to_angle(m) % 180);
if (matrix_is_mirrored(m)) {
if ((num_txt.rot % 180) == 0)
num_txt.hor = text_flip(num_txt.hor);
else
num_txt.vert = text_flip(num_txt.vert);
}
if (comp->show_pin_num) if (comp->show_pin_num)
text_fig(&num_txt, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER); text_fig(&num_txt, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER);

View File

@ -14,6 +14,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h>
#include "misc.h" #include "misc.h"
@ -34,12 +35,31 @@ unsigned matrix_to_angle(int m[6])
return 180; return 180;
if (eq(m, 0, 1, 1, 0)) if (eq(m, 0, 1, 1, 0))
return 270; return 270;
if (eq(m, -1, 0, 0, -1))
return 0;
fprintf(stderr, "unrecognized matrix %d %d %d %d\n", fprintf(stderr, "unrecognized matrix %d %d %d %d\n",
m[1], m[2], m[4], m[5]); m[1], m[2], m[4], m[5]);
exit(1); exit(1);
} }
bool matrix_is_mirrored(int m[6])
{
if (eq(m, 1, 0, 0, -1))
return 0;
if (eq(m, 0, -1, -1, 0))
return 0;
if (eq(m, -1, 0, 0, 1))
return 0;
if (eq(m, 0, 1, 1, 0))
return 0;
if (eq(m, -1, 0, 0, -1))
return 1;
assert(0);
}
int angle_add(int a, int b) int angle_add(int a, int b)
{ {
a += b; a += b;

View File

@ -42,6 +42,7 @@ static inline int my(int x, int y, int m[6])
unsigned matrix_to_angle(int m[6]); unsigned matrix_to_angle(int m[6]);
bool matrix_is_mirrored(int m[6]);
int angle_add(int a, int b); int angle_add(int a, int b);
#endif /* !MISC_H */ #endif /* !MISC_H */

View File

@ -177,6 +177,13 @@ static void dump_field(const struct sch_field *field, int m[6])
break; break;
} }
if (matrix_is_mirrored(m)) {
if ((txt.rot % 180) == 0)
txt.hor = text_flip(txt.hor);
else
txt.vert = text_flip(txt.vert);
}
text_fig(&txt, COLOR_FIELD, LAYER_FIELD); text_fig(&txt, COLOR_FIELD, LAYER_FIELD);
} }