LEFT | RIGHT |
(no file at all) | |
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) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 this routine should take into account the stemlength scoring | 841 this routine should take into account the stemlength scoring |
842 of a possible knee/nonknee beam. | 842 of a possible knee/nonknee beam. |
843 */ | 843 */ |
844 void | 844 void |
845 Beam::consider_auto_knees (Grob *me) | 845 Beam::consider_auto_knees (Grob *me) |
846 { | 846 { |
847 SCM scm = me->get_property ("auto-knee-gap"); | 847 SCM scm = me->get_property ("auto-knee-gap"); |
848 if (!scm_is_number (scm)) | 848 if (!scm_is_number (scm)) |
849 return; | 849 return; |
850 | 850 |
851 Interval_set gaps; | 851 vector<Interval> forbidden_intervals; |
852 | |
853 gaps.set_full (); | |
854 | 852 |
855 extract_grob_set (me, "normal-stems", stems); | 853 extract_grob_set (me, "normal-stems", stems); |
856 | 854 |
857 Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); | 855 Grob *common = common_refpoint_of_array (stems, me, Y_AXIS); |
858 Real staff_space = Staff_symbol_referencer::staff_space (me); | 856 Real staff_space = Staff_symbol_referencer::staff_space (me); |
859 | 857 |
860 vector<Interval> head_extents_array; | 858 vector<Interval> head_extents_array; |
861 for (vsize i = 0; i < stems.size (); i++) | 859 for (vsize i = 0; i < stems.size (); i++) |
862 { | 860 { |
863 Grob *stem = stems[i]; | 861 Grob *stem = stems[i]; |
(...skipping 13 matching lines...) Expand all Loading... |
877 head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); | 875 head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); |
878 | 876 |
879 if (to_dir (stem->get_property_data ("direction"))) | 877 if (to_dir (stem->get_property_data ("direction"))) |
880 { | 878 { |
881 Direction stemdir = to_dir (stem->get_property ("direction")); | 879 Direction stemdir = to_dir (stem->get_property ("direction")); |
882 head_extents[-stemdir] = -stemdir * infinity_f; | 880 head_extents[-stemdir] = -stemdir * infinity_f; |
883 } | 881 } |
884 } | 882 } |
885 head_extents_array.push_back (head_extents); | 883 head_extents_array.push_back (head_extents); |
886 | 884 |
887 gaps.remove_interval (head_extents); | 885 forbidden_intervals.push_back (head_extents); |
888 } | 886 } |
889 | 887 |
890 Interval max_gap; | 888 Interval max_gap; |
891 Real max_gap_len = 0.0; | 889 Real max_gap_len = 0.0; |
892 | 890 |
893 for (vsize i = gaps.allowed_regions_.size () - 1; i != VPOS; i--) | 891 vector<Interval> allowed_regions |
894 { | 892 = Interval_set::interval_union (forbidden_intervals).complement ().intervals
(); |
895 Interval gap = gaps.allowed_regions_[i]; | 893 for (vsize i = allowed_regions.size () - 1; i != VPOS; i--) |
| 894 { |
| 895 Interval gap = allowed_regions[i]; |
896 | 896 |
897 /* | 897 /* |
898 the outer gaps are not knees. | 898 the outer gaps are not knees. |
899 */ | 899 */ |
900 if (isinf (gap[LEFT]) || isinf (gap[RIGHT])) | 900 if (isinf (gap[LEFT]) || isinf (gap[RIGHT])) |
901 continue; | 901 continue; |
902 | 902 |
903 if (gap.length () >= max_gap_len) | 903 if (gap.length () >= max_gap_len) |
904 { | 904 { |
905 max_gap_len = gap.length (); | 905 max_gap_len = gap.length (); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 } | 1354 } |
1355 | 1355 |
1356 /* In stems with several heads, use the one closest to the beam. */ | 1356 /* In stems with several heads, use the one closest to the beam. */ |
1357 Direction beamdir = get_grob_direction (beam); | 1357 Direction beamdir = get_grob_direction (beam); |
1358 Real shift = min (max ( (Stem::head_positions (left)[beamdir] | 1358 Real shift = min (max ( (Stem::head_positions (left)[beamdir] |
1359 + Stem::head_positions (right)[beamdir]) / 2.0, | 1359 + Stem::head_positions (right)[beamdir]) / 2.0, |
1360 rest_max_pos[DOWN]), | 1360 rest_max_pos[DOWN]), |
1361 rest_max_pos[UP] | 1361 rest_max_pos[UP] |
1362 ) * ss / 2.0 | 1362 ) * ss / 2.0 |
1363 - previous; | 1363 - previous; |
| 1364 |
| 1365 // So that ceil below kicks in for rests that would otherwise brush |
| 1366 // up against a beam quanted to a ledger line, add a bit of space |
| 1367 // between the beam and the rest. |
| 1368 shift += (0.01 * beamdir); |
| 1369 |
1364 /* Always move by a whole number of staff spaces */ | 1370 /* Always move by a whole number of staff spaces */ |
1365 shift = ceil (fabs (shift / ss)) * ss * sign (shift); | 1371 shift = ceil (fabs (shift / ss)) * ss * sign (shift); |
1366 | 1372 |
1367 return scm_from_double (previous + shift); | 1373 return scm_from_double (previous + shift); |
1368 } | 1374 } |
1369 | 1375 |
1370 bool | 1376 bool |
1371 Beam::is_knee (Grob *me) | 1377 Beam::is_knee (Grob *me) |
1372 { | 1378 { |
1373 SCM k = me->get_property ("knee"); | 1379 SCM k = me->get_property ("knee"); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 "least-squares-dy " | 1501 "least-squares-dy " |
1496 "neutral-direction " | 1502 "neutral-direction " |
1497 "normal-stems " | 1503 "normal-stems " |
1498 "positions " | 1504 "positions " |
1499 "quantized-positions " | 1505 "quantized-positions " |
1500 "shorten " | 1506 "shorten " |
1501 "skip-quanting " | 1507 "skip-quanting " |
1502 "stems " | 1508 "stems " |
1503 "X-positions " | 1509 "X-positions " |
1504 ); | 1510 ); |
LEFT | RIGHT |