mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
Fix arrows at ends of math decorations
For math decorations with arrows at both ends the code was simply stretching a prototype symbol, thus distorting the arrows. Another drawing mode is introduced allowing to draw an element by maintaining its aspect ratio also when it has to be drawn at the other end of a decoration. An element drawn using this mode is simply shifted to the other side by adding either the width or the height, and a finer adjustment can be obtained by specifying an additional horizontal or vertical shift.
This commit is contained in:
parent
d8c6bc7c1f
commit
11392b7b33
@ -84,7 +84,8 @@ namespace {
|
||||
/*
|
||||
* Internal struct of a drawing: code n x1 y1 ... xn yn, where code is:
|
||||
* 0 = end, 1 = line, 2 = polyline, 3 = square line, 4 = square polyline
|
||||
* 5 = rounded thick line (i.e. dot for short line)
|
||||
* 5 = rounded thick line (i.e. dot for short line),
|
||||
* 6 = shifted square polyline drawn at the other end
|
||||
*/
|
||||
|
||||
|
||||
@ -141,81 +142,90 @@ double const mapsto[] = {
|
||||
|
||||
|
||||
double const lhook[] = {
|
||||
2, 3,
|
||||
0.25, 0.015, 0.05, 0.5, 0.25, 0.985,
|
||||
1, 0.015, 0.475, 0.7, 0.475,
|
||||
2, 5,
|
||||
0.7, 0.015, 0.825, 0.15, 0.985, 0.25,
|
||||
0.825, 0.35, 0.7, 0.475,
|
||||
4, 7,
|
||||
1.40, -0.30, 1.10, 0.00, 0.60, 0.35,
|
||||
0.00, 0.60, 0.60, 0.85, 1.10, 1.20,
|
||||
1.40, 1.50,
|
||||
3, 0.05, 0.6, 1.0, 0.6,
|
||||
6, -0.5, 0.0, 6,
|
||||
0.65, -0.40, 0.95, -0.35, 1.15, -0.10,
|
||||
1.15, 0.25, 0.95, 0.50, 0.65, 0.60,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const rhook[] = {
|
||||
2, 3,
|
||||
0.75, 0.015, 0.95, 0.5, 0.75, 0.985,
|
||||
1, 0.3, 0.475, 0.985, 0.475,
|
||||
2, 5,
|
||||
0.3, 0.015, 0.175, 0.15, 0.05, 0.25,
|
||||
0.175, 0.35, 0.3, 0.475,
|
||||
4, 6,
|
||||
0.50, -0.40, 0.20, -0.35, 0.00, -0.10,
|
||||
0.00, 0.25, 0.20, 0.50, 0.50, 0.60,
|
||||
3, 0.55, 0.60, 1.00, 0.60,
|
||||
6, -0.8, 0.0, 7,
|
||||
0.00, -0.30, 0.30, 0.00, 0.80, 0.35, 1.40, 0.60,
|
||||
0.80, 0.85, 0.30, 1.20, 0.00, 1.50,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const LRArrow[] = {
|
||||
2, 3,
|
||||
0.25, 0.015, 0.05, 0.5, 0.25, 0.985,
|
||||
2, 3,
|
||||
0.75, 0.015, 0.95, 0.5, 0.75, 0.985,
|
||||
1, 0.2, 0.8, 0.8, 0.8,
|
||||
1, 0.2, 0.2, 0.8, 0.2,
|
||||
4, 7,
|
||||
1.300, -0.300, 1.100, 0.000, 0.600, 0.350,
|
||||
0.000, 0.600, 0.600, 0.850, 1.100, 1.200,
|
||||
1.300, 1.500,
|
||||
6, -0.1, 0.0, 7,
|
||||
-0.300, -0.300, -0.100, 0.000, 0.400, 0.350,
|
||||
1.000, 0.600, 0.400, 0.850, -0.100, 1.200,
|
||||
-0.300, 1.500,
|
||||
3, 0.85, 1.0, 1.0, 1.0,
|
||||
3, 0.85, 0.2, 1.0, 0.2,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const LArrow[] = {
|
||||
2, 3,
|
||||
0.25, 0.015, 0.05, 0.5, 0.25, 0.985,
|
||||
1, 0.2, 0.8, 0.985, 0.8,
|
||||
1, 0.2, 0.2, 0.985, 0.2,
|
||||
4, 7,
|
||||
1.300, -0.300, 1.100, 0.000, 0.600, 0.350,
|
||||
0.000, 0.600, 0.600, 0.850, 1.100, 1.200,
|
||||
1.300, 1.500,
|
||||
3, 0.85, 1.0, 1.0, 1.0,
|
||||
3, 0.85, 0.2, 1.0, 0.2,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const lharpoondown[] = {
|
||||
2, 2,
|
||||
0.015, 0.5, 0.25, 0.985,
|
||||
1, 0.02, 0.475, 0.985, 0.475,
|
||||
4, 4,
|
||||
0.0, 0.6, 0.6, 0.85, 1.1, 1.2, 1.4, 1.5,
|
||||
3, 0.05, 0.6, 1.0, 0.6,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const lharpoonup[] = {
|
||||
2, 2,
|
||||
0.25, 0.015, 0.015, 0.5,
|
||||
1, 0.02, 0.525, 0.985, 0.525,
|
||||
4, 4,
|
||||
0.0, 0.6, 0.6, 0.35, 1.1, 0.0, 1.4, -0.3,
|
||||
3, 0.05, 0.6, 1.0, 0.6,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const lrharpoons[] = {
|
||||
2, 2,
|
||||
0.25, 0.015, 0.015, 0.225,
|
||||
1, 0.02, 0.23, 0.985, 0.23,
|
||||
2, 2,
|
||||
0.75, 0.985, 0.985, 0.775,
|
||||
1, 0.02, 0.7, 0.980, 0.7,
|
||||
4, 4,
|
||||
0.0, 0.6, 0.6, 0.35, 1.1, 0.0, 1.4, -0.3,
|
||||
3, 0.05, 0.6, 1.0, 0.6,
|
||||
3, 0.05, 1.2, 1.0, 1.2,
|
||||
6, -1.0, 0.0, 4,
|
||||
1.1, 1.3, 0.4, 1.55, -0.1, 1.9, -0.4, 2.2,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const rlharpoons[] = {
|
||||
2, 2,
|
||||
0.75, 0.015, 0.985, 0.225,
|
||||
1, 0.02, 0.23, 0.985, 0.23,
|
||||
2, 2,
|
||||
0.25, 0.985, 0.015, 0.775,
|
||||
1, 0.02, 0.7, 0.980, 0.7,
|
||||
6, -1.0, 0.0, 4,
|
||||
-0.4, -0.4, -0.1, -0.1, 0.4, 0.25, 1.0, 0.5,
|
||||
3, 0.05, 0.6, 1.0, 0.6,
|
||||
3, 0.05, 1.2, 1.0, 1.2,
|
||||
4, 4,
|
||||
0.0, 1.2, 0.6, 1.45, 1.1, 1.8, 1.4, 2.1,
|
||||
0
|
||||
};
|
||||
|
||||
@ -242,32 +252,40 @@ double const arrow[] = {
|
||||
|
||||
double const Arrow[] = {
|
||||
4, 7,
|
||||
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
|
||||
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
|
||||
0.9500, 0.7500,
|
||||
3, 0.3500, 0.5000, 0.3500, 0.9500,
|
||||
3, 0.6500, 0.5000, 0.6500, 0.9500,
|
||||
0.0000, 0.7500, 0.1500, 0.6000, 0.3500, 0.3500,
|
||||
0.5000, 0.0500, 0.6500, 0.3500, 0.8500, 0.6000,
|
||||
1.0000, 0.7500,
|
||||
3, 0.3000, 0.4500, 0.3000, 1.0000,
|
||||
3, 0.7000, 0.4500, 0.7000, 1.0000,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const udarrow[] = {
|
||||
2, 3,
|
||||
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
|
||||
2, 3,
|
||||
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
|
||||
1, 0.5, 0.1, 0.5, 0.9,
|
||||
4, 7,
|
||||
0.0500, 0.6500, 0.2000, 0.5000, 0.3500, 0.2500,
|
||||
0.5000, -0.0500, 0.6500, 0.2500, 0.8000, 0.5000,
|
||||
0.9500, 0.6500,
|
||||
6, 0.0, -1.0, 7,
|
||||
0.0500, 0.2500, 0.2000, 0.4000, 0.3500, 0.6500,
|
||||
0.5000, 0.9500, 0.6500, 0.6500, 0.8000, 0.4000,
|
||||
0.9500, 0.2500,
|
||||
3, 0.5, 0.0, 0.5, 1.0,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
double const Udarrow[] = {
|
||||
2, 3,
|
||||
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
|
||||
2, 3,
|
||||
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
|
||||
1, 0.35, 0.2, 0.35, 0.8,
|
||||
1, 0.65, 0.2, 0.65, 0.8,
|
||||
4, 7,
|
||||
0.0000, 0.7500, 0.1500, 0.6000, 0.3500, 0.3500,
|
||||
0.5000, 0.0500, 0.6500, 0.3500, 0.8500, 0.6000,
|
||||
1.0000, 0.7500,
|
||||
6, 0.0, -1.0, 7,
|
||||
0.0000, 0.2500, 0.1500, 0.4000, 0.3500, 0.6500,
|
||||
0.5000, 0.9500, 0.6500, 0.6500, 0.8500, 0.4000,
|
||||
1.0000, 0.2500,
|
||||
3, 0.3000, 0.4500, 0.3000, 0.9500,
|
||||
3, 0.7000, 0.4500, 0.7000, 0.9500,
|
||||
0
|
||||
};
|
||||
|
||||
@ -701,14 +719,22 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
|
||||
} else {
|
||||
int xp[32];
|
||||
int yp[32];
|
||||
double xshift = (code == 6 ? d[i++] : 0.0);
|
||||
double yshift = (code == 6 ? d[i++] : 0.0);
|
||||
int const n2 = int(d[i++]);
|
||||
for (int j = 0; j < n2; ++j) {
|
||||
double xx = d[i++];
|
||||
double yy = d[i++];
|
||||
double xx = d[i++] + xshift;
|
||||
double yy = d[i++] + yshift;
|
||||
// lyxerr << ' ' << xx << ' ' << yy << ' ';
|
||||
if (code == 4)
|
||||
if (code == 4 || code == 6) {
|
||||
sqmt.transform(xx, yy);
|
||||
else
|
||||
if (code == 6) {
|
||||
if (r == 0 && xshift == 0.0)
|
||||
yy += h;
|
||||
else
|
||||
xx += w;
|
||||
}
|
||||
} else
|
||||
mt.transform(xx, yy);
|
||||
xp[j] = int(x + xx + 0.5);
|
||||
yp[j] = int(y + yy + 0.5);
|
||||
|
Loading…
Reference in New Issue
Block a user