LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 Real dy = (newp - p) * state.staff_space_ / 2.0; | 66 Real dy = (newp - p) * state.staff_space_ / 2.0; |
67 | 67 |
68 bez.control_[1][Y_AXIS] += dy; | 68 bez.control_[1][Y_AXIS] += dy; |
69 bez.control_[2][Y_AXIS] += dy; | 69 bez.control_[2][Y_AXIS] += dy; |
70 } | 70 } |
71 } | 71 } |
72 return bez; | 72 return bez; |
73 } | 73 } |
74 | 74 |
75 Real | 75 Real |
76 fit_factor (Offset dz_unit, Offset dz_perp, | 76 fit_factor (Offset dz_unit, Offset dz_perp, Real close_to_edge_length, |
77 Bezier curve, Direction d, vector<Offset> const &avoid) | 77 Bezier curve, Direction d, vector<Offset> const &avoid) |
78 { | 78 { |
79 Real fit_factor = 0.0; | 79 Real fit_factor = 0.0; |
80 Offset x0 = curve.control_[0]; | 80 Offset x0 = curve.control_[0]; |
81 curve.translate (-x0); | 81 curve.translate (-x0); |
82 curve.rotate (-dz_unit.arg ()); | 82 curve.rotate (-dz_unit.arg ()); |
83 curve.scale (1, d); | 83 curve.scale (1, d); |
84 | 84 |
85 Interval curve_xext; | 85 Interval curve_xext; |
86 curve_xext.add_point (curve.control_[0][X_AXIS]); | 86 curve_xext.add_point (curve.control_[0][X_AXIS]); |
87 curve_xext.add_point (curve.control_[3][X_AXIS]); | 87 curve_xext.add_point (curve.control_[3][X_AXIS]); |
88 | 88 |
89 for (vsize i = 0; i < avoid.size (); i++) | 89 for (vsize i = 0; i < avoid.size (); i++) |
90 { | 90 { |
91 Offset z = (avoid[i] - x0); | 91 Offset z = (avoid[i] - x0); |
92 Offset p (dot_product (z, dz_unit), | 92 Offset p (dot_product (z, dz_unit), |
93 d * dot_product (z, dz_perp)); | 93 d * dot_product (z, dz_perp)); |
94 | 94 |
| 95 bool close_to_edge = false; |
| 96 Direction d = LEFT; |
| 97 do |
| 98 close_to_edge = close_to_edge || -d * (p[X_AXIS] - curve_xext[d]) < clos
e_to_edge_length; |
| 99 while (flip (&d) != LEFT); |
| 100 |
| 101 if (close_to_edge) |
| 102 continue; |
| 103 |
95 Real eps = 0.01; | 104 Real eps = 0.01; |
96 Interval pext = eps * Interval (-1, 1) + p[X_AXIS]; | 105 Interval pext = eps * Interval (-1, 1) + p[X_AXIS]; |
97 pext.intersect (curve_xext); | 106 pext.intersect (curve_xext); |
98 if ((pext.is_empty () | 107 |
99 || pext.length () <= 1.999 * eps | 108 if (pext.is_empty () || pext.length () <= 1.999 * eps) |
100 || (p[X_AXIS] - curve_xext[LEFT]) < 2.5 | |
101 || (curve_xext[RIGHT] - p[X_AXIS]) < 2.5)) | |
102 continue; | 109 continue; |
103 | 110 |
104 Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]); | 111 Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]); |
105 if (y) | 112 if (y) |
106 fit_factor = max (fit_factor, (p[Y_AXIS] / y)); | 113 fit_factor = max (fit_factor, (p[Y_AXIS] / y)); |
107 } | 114 } |
108 return fit_factor; | 115 return fit_factor; |
109 } | 116 } |
110 | 117 |
111 void | 118 void |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 Real x2 = (eccentricity - indent); | 162 Real x2 = (eccentricity - indent); |
156 | 163 |
157 Bezier curve; | 164 Bezier curve; |
158 curve.control_[0] = attachment_[LEFT]; | 165 curve.control_[0] = attachment_[LEFT]; |
159 curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ | 166 curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ |
160 + dz_unit * x1; | 167 + dz_unit * x1; |
161 curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ | 168 curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ |
162 + dz_unit * x2; | 169 + dz_unit * x2; |
163 curve.control_[3] = attachment_[RIGHT]; | 170 curve.control_[3] = attachment_[RIGHT]; |
164 | 171 |
165 Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid); | 172 Real ff = fit_factor (dz_unit, dz_perp, state.parameters_.close_to_edge_length
_, |
| 173 curve, state.dir_, avoid); |
166 | 174 |
167 height = max (height, min (height * ff, max_h)); | 175 height = max (height, min (height * ff, max_h)); |
168 | 176 |
169 curve.control_[0] = attachment_[LEFT]; | 177 curve.control_[0] = attachment_[LEFT]; |
170 curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ | 178 curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ |
171 + dz_unit * x1; | 179 + dz_unit * x1; |
172 curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ | 180 curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ |
173 + dz_unit * x2; | 181 + dz_unit * x2; |
174 curve.control_[3] = attachment_[RIGHT]; | 182 curve.control_[3] = attachment_[RIGHT]; |
175 | 183 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 517 |
510 Slur_configuration * | 518 Slur_configuration * |
511 Slur_configuration::new_config (Drul_array<Offset> const &offs, int idx) | 519 Slur_configuration::new_config (Drul_array<Offset> const &offs, int idx) |
512 { | 520 { |
513 Slur_configuration *conf = new Slur_configuration; | 521 Slur_configuration *conf = new Slur_configuration; |
514 conf->attachment_ = offs; | 522 conf->attachment_ = offs; |
515 conf->index_ = idx; | 523 conf->index_ = idx; |
516 conf->next_scorer_todo = INITIAL_SCORE + 1; | 524 conf->next_scorer_todo = INITIAL_SCORE + 1; |
517 return conf; | 525 return conf; |
518 } | 526 } |
LEFT | RIGHT |