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) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2011 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 27 matching lines...) Expand all Loading... |
38 #include "beam.hh" | 38 #include "beam.hh" |
39 | 39 |
40 #include "align-interface.hh" | 40 #include "align-interface.hh" |
41 #include "beam-scoring-problem.hh" | 41 #include "beam-scoring-problem.hh" |
42 #include "beaming-pattern.hh" | 42 #include "beaming-pattern.hh" |
43 #include "directional-element-interface.hh" | 43 #include "directional-element-interface.hh" |
44 #include "grob-array.hh" | 44 #include "grob-array.hh" |
45 #include "international.hh" | 45 #include "international.hh" |
46 #include "interval-set.hh" | 46 #include "interval-set.hh" |
47 #include "item.hh" | 47 #include "item.hh" |
48 #include "least-squares.hh" | |
49 #include "lookup.hh" | 48 #include "lookup.hh" |
50 #include "main.hh" | 49 #include "main.hh" |
51 #include "misc.hh" | 50 #include "misc.hh" |
52 #include "note-head.hh" | 51 #include "note-head.hh" |
53 #include "output-def.hh" | 52 #include "output-def.hh" |
54 #include "pointer-group-interface.hh" | 53 #include "pointer-group-interface.hh" |
55 #include "rhythmic-head.hh" | 54 #include "rhythmic-head.hh" |
56 #include "spanner.hh" | 55 #include "spanner.hh" |
57 #include "staff-symbol.hh" | 56 #include "staff-symbol.hh" |
58 #include "staff-symbol-referencer.hh" | 57 #include "staff-symbol-referencer.hh" |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 ? UP : DOWN; | 876 ? UP : DOWN; |
878 | 877 |
879 stem->set_property ("direction", scm_from_int (d)); | 878 stem->set_property ("direction", scm_from_int (d)); |
880 | 879 |
881 head_extents.intersect (max_gap); | 880 head_extents.intersect (max_gap); |
882 assert (head_extents.is_empty () || head_extents.length () < 1e-6); | 881 assert (head_extents.is_empty () || head_extents.length () < 1e-6); |
883 } | 882 } |
884 } | 883 } |
885 } | 884 } |
886 | 885 |
887 /* Set stem's shorten property if unset. | |
888 | |
889 TODO: | |
890 take some y-position (chord/beam/nearest?) into account | |
891 scmify forced-fraction | |
892 | |
893 This is done in beam because the shorten has to be uniform over the | |
894 entire beam. | |
895 */ | |
896 | |
897 void | |
898 Beam::set_minimum_dy (Grob *me, Real *dy) | |
899 { | |
900 if (*dy) | |
901 { | |
902 /* | |
903 If dy is smaller than the smallest quant, we | |
904 get absurd direction-sign penalties. | |
905 */ | |
906 | |
907 Real ss = Staff_symbol_referencer::staff_space (me); | |
908 Real beam_thickness = Beam::get_beam_thickness (me) / ss; | |
909 Real slt = Staff_symbol_referencer::line_thickness (me) / ss; | |
910 Real sit = (beam_thickness - slt) / 2; | |
911 Real inter = 0.5; | |
912 Real hang = 1.0 - (beam_thickness - slt) / 2; | |
913 | |
914 *dy = sign (*dy) * max (fabs (*dy), | |
915 min (min (sit, inter), hang)); | |
916 } | |
917 } | |
918 | |
919 MAKE_SCHEME_CALLBACK (Beam, calc_stem_shorten, 1) | 886 MAKE_SCHEME_CALLBACK (Beam, calc_stem_shorten, 1) |
920 SCM | 887 SCM |
921 Beam::calc_stem_shorten (SCM smob) | 888 Beam::calc_stem_shorten (SCM smob) |
922 { | 889 { |
923 Grob *me = unsmob_grob (smob); | 890 Grob *me = unsmob_grob (smob); |
924 | 891 |
925 /* | 892 /* |
926 shortening looks silly for x staff beams | 893 shortening looks silly for x staff beams |
927 */ | 894 */ |
928 if (is_knee (me)) | 895 if (is_knee (me)) |
(...skipping 13 matching lines...) Expand all Loading... |
942 SCM shorten_elt | 909 SCM shorten_elt |
943 = robust_list_ref (beam_count - 1, shorten_list); | 910 = robust_list_ref (beam_count - 1, shorten_list); |
944 Real shorten = scm_to_double (shorten_elt) * staff_space; | 911 Real shorten = scm_to_double (shorten_elt) * staff_space; |
945 | 912 |
946 shorten *= forced_fraction; | 913 shorten *= forced_fraction; |
947 | 914 |
948 if (shorten) | 915 if (shorten) |
949 return scm_from_double (shorten); | 916 return scm_from_double (shorten); |
950 | 917 |
951 return scm_from_double (0.0); | 918 return scm_from_double (0.0); |
952 } | |
953 | |
954 Interval | |
955 Beam::no_visible_stem_positions (Grob *me, Interval default_value) | |
956 { | |
957 extract_grob_set (me, "stems", stems); | |
958 if (stems.empty ()) | |
959 return default_value; | |
960 | |
961 Interval head_positions; | |
962 Slice multiplicity; | |
963 for (vsize i = 0; i < stems.size (); i++) | |
964 { | |
965 head_positions.unite (Stem::head_positions (stems[i])); | |
966 multiplicity.unite (Stem::beam_multiplicity (stems[i])); | |
967 } | |
968 | |
969 Direction dir = get_grob_direction (me); | |
970 | |
971 if (!dir) | |
972 programming_error ("The beam should have a direction by now."); | |
973 | |
974 Real y = head_positions.linear_combination (dir) | |
975 * 0.5 * Staff_symbol_referencer::staff_space (me) | |
976 + dir * get_beam_translation (me) * (multiplicity.length () + 1); | |
977 | |
978 y /= Staff_symbol_referencer::staff_space (me); | |
979 return Interval (y, y); | |
980 } | 919 } |
981 | 920 |
982 MAKE_SCHEME_CALLBACK (Beam, quanting, 1); | 921 MAKE_SCHEME_CALLBACK (Beam, quanting, 1); |
983 SCM | 922 SCM |
984 Beam::quanting (SCM smob) | 923 Beam::quanting (SCM smob) |
985 { | 924 { |
986 Grob *me = unsmob_grob (smob); | 925 Grob *me = unsmob_grob (smob); |
987 Drul_array<Real> ys (0, 0); | 926 Drul_array<Real> ys (0, 0); |
988 Beam_scoring_problem problem (me, ys); | 927 Beam_scoring_problem problem (me, ys); |
989 | 928 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 "length-fraction " | 1437 "length-fraction " |
1499 "least-squares-dy " | 1438 "least-squares-dy " |
1500 "neutral-direction " | 1439 "neutral-direction " |
1501 "normal-stems " | 1440 "normal-stems " |
1502 "positions " | 1441 "positions " |
1503 "quantized-positions " | 1442 "quantized-positions " |
1504 "shorten " | 1443 "shorten " |
1505 "skip-quanting " | 1444 "skip-quanting " |
1506 "stems " | 1445 "stems " |
1507 ); | 1446 ); |
LEFT | RIGHT |