mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-24 14:56:26 +02:00
sch2fig/fig.c: make glabels work when rotated by 180 degrees
This commit is contained in:
parent
e3a0229946
commit
1aaf1f8fb2
@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -85,6 +86,31 @@ void fig_poly(int points, int x[points], int y[points],
|
|||||||
/* ----- Schematics items -------------------------------------------------- */
|
/* ----- Schematics items -------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
enum box_type { // ___
|
||||||
|
box_simple, // [___]
|
||||||
|
box_left, // <___]
|
||||||
|
box_right, // [___>
|
||||||
|
box_both, // <___>
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static enum box_type flip_box(enum box_type box)
|
||||||
|
{
|
||||||
|
switch (box) {
|
||||||
|
case box_simple:
|
||||||
|
return box_simple;
|
||||||
|
case box_left:
|
||||||
|
return box_right;
|
||||||
|
case box_right:
|
||||||
|
return box_left;
|
||||||
|
case box_both:
|
||||||
|
return box_both;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
||||||
enum fig_shape shape)
|
enum fig_shape shape)
|
||||||
{
|
{
|
||||||
@ -101,19 +127,48 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
|||||||
int vx[7];
|
int vx[7];
|
||||||
int vy[7];
|
int vy[7];
|
||||||
int half = (dim >> 1) + GLABEL_OFFSET;
|
int half = (dim >> 1) + GLABEL_OFFSET;
|
||||||
|
enum box_type box;
|
||||||
|
int dx, shift_flat, shift_tip;
|
||||||
|
bool anchor_right = 1;
|
||||||
|
|
||||||
switch (dir) {
|
switch (shape) {
|
||||||
case 0:
|
case fig_in:
|
||||||
txt.rot = 0;
|
box = box_right;
|
||||||
txt.hor = text_max;
|
break;
|
||||||
|
case fig_out:
|
||||||
|
box = box_left;
|
||||||
|
break;
|
||||||
|
case fig_bidir:
|
||||||
|
box = box_both;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (shape) {
|
switch (dir) {
|
||||||
case fig_in:
|
case 0:
|
||||||
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET - half, 0);
|
txt.rot = 0;
|
||||||
|
txt.hor = text_max;
|
||||||
|
dx = -1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
txt.rot = 0;
|
||||||
|
txt.hor = text_min;
|
||||||
|
dx = 1;
|
||||||
|
box = flip_box(box);
|
||||||
|
anchor_right = !anchor_right;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
shift_flat = dx * GLABEL_OFFSET;
|
||||||
|
shift_tip = dx * (GLABEL_OFFSET + half);
|
||||||
|
|
||||||
|
switch (box) {
|
||||||
|
case box_right:
|
||||||
|
text_shift(&txt, txt.hor, text_mid,
|
||||||
|
anchor_right ? shift_tip : shift_flat, 0);
|
||||||
text_rel(&txt, text_min, text_min,
|
text_rel(&txt, text_min, text_min,
|
||||||
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
||||||
text_rel(&txt, text_max, text_min,
|
text_rel(&txt, text_max, text_min,
|
||||||
@ -125,8 +180,9 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
|||||||
text_rel(&txt, text_min, text_max,
|
text_rel(&txt, text_min, text_max,
|
||||||
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
|
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
|
||||||
break;
|
break;
|
||||||
case fig_out:
|
case box_left:
|
||||||
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET, 0);
|
text_shift(&txt, txt.hor, text_mid,
|
||||||
|
anchor_right ? shift_flat : shift_tip, 0);
|
||||||
text_rel(&txt, text_min, text_min,
|
text_rel(&txt, text_min, text_min,
|
||||||
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
||||||
text_rel(&txt, text_max, text_min,
|
text_rel(&txt, text_max, text_min,
|
||||||
@ -138,9 +194,9 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
|
|||||||
text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
|
text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
|
||||||
vx + 5, vy + 5);
|
vx + 5, vy + 5);
|
||||||
break;
|
break;
|
||||||
case fig_bidir:
|
case box_both:
|
||||||
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET - half, 0);
|
|
||||||
n = 7;
|
n = 7;
|
||||||
|
text_shift(&txt, txt.hor, text_mid, shift_tip, 0);
|
||||||
text_rel(&txt, text_min, text_min,
|
text_rel(&txt, text_min, text_min,
|
||||||
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
|
||||||
text_rel(&txt, text_max, text_min,
|
text_rel(&txt, text_max, text_min,
|
||||||
|
Loading…
Reference in New Issue
Block a user