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) 2011 Mike Solomon <mike@apollinemike.com> | 4 Copyright (C) 2011 Mike Solomon <mike@apollinemike.com> |
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 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
| 20 #include "axis-group-interface.hh" |
20 #include "grob.hh" | 21 #include "grob.hh" |
21 #include "grob-array.hh" | 22 #include "grob-array.hh" |
| 23 #include "moment.hh" |
| 24 #include "paper-column.hh" |
22 #include "pointer-group-interface.hh" | 25 #include "pointer-group-interface.hh" |
23 #include "pure-from-neighbor-interface.hh" | 26 #include "pure-from-neighbor-interface.hh" |
24 #include "spanner.hh" | 27 #include "spanner.hh" |
25 #include "system.hh" | 28 #include "system.hh" |
26 | 29 |
27 MAKE_SCHEME_CALLBACK (Pure_from_neighbor_interface, keep_elements_on_system, 1); | 30 MAKE_SCHEME_CALLBACK (Pure_from_neighbor_interface, calc_pure_relevant_grobs, 1)
; |
28 SCM | 31 SCM |
29 Pure_from_neighbor_interface::keep_elements_on_system (SCM smob) | 32 Pure_from_neighbor_interface::calc_pure_relevant_grobs (SCM smob) |
30 { | 33 { |
31 Grob *me = unsmob_grob (smob); | 34 Grob *me = unsmob_grob (smob); |
32 extract_grob_set (me, "elements", elts); | 35 extract_grob_set ((me->original () && me->original ()->is_live () |
| 36 ? me->original () |
| 37 : me), |
| 38 "neighbors", |
| 39 elts); |
| 40 |
33 vector<Grob *> new_elts; | 41 vector<Grob *> new_elts; |
34 Interval_t<int> srl = me->get_system ()->spanned_rank_interval (); | 42 new_elts.insert (new_elts.end (), elts.begin (), elts.end ()); |
35 for (vsize i = 0; i < elts.size (); i++) | |
36 if (srl.contains (elts[i]->spanned_rank_interval ()[LEFT])) | |
37 new_elts.push_back (elts[i]); | |
38 | 43 |
39 SCM elements_scm = me->get_object ("elements"); | 44 SCM neighbors_scm = me->get_object ("neighbors"); |
40 if (Grob_array::unsmob (elements_scm)) | 45 if (Grob_array::unsmob (neighbors_scm)) |
41 { | 46 { |
42 vector<Grob *> &arr | 47 vector<Grob *> &arr |
43 = unsmob_grob_array (elements_scm)->array_reference (); | 48 = unsmob_grob_array (neighbors_scm)->array_reference (); |
44 arr = new_elts; | 49 arr = new_elts; |
45 } | 50 } |
46 | 51 |
47 return SCM_BOOL_T; | 52 return Axis_group_interface::internal_calc_pure_relevant_grobs (me, "neighbors
"); |
48 } | |
49 | |
50 MAKE_SCHEME_CALLBACK (Pure_from_neighbor_interface, keep_proximal_elements, 1); | |
51 SCM | |
52 Pure_from_neighbor_interface::keep_proximal_elements (SCM smob) | |
53 { | |
54 Grob *me = unsmob_grob (smob); | |
55 extract_grob_set (me, "elements", elts); | |
56 vector<Grob *> new_elts; | |
57 int srl = me->spanned_rank_interval ()[LEFT]; | |
58 Drul_array<vector<Grob *> > new_elt_drul; | |
59 Interval_t<int> srl_drul; | |
60 srl_drul.set_full (); | |
61 ·· | |
62 for (vsize i = 0; i < elts.size (); i++) | |
63 { | |
64 int elt_srl = elts[i]->spanned_rank_interval ()[LEFT]; | |
65 Direction d = LEFT; | |
66 do | |
67 { | |
68 if (minmax (-d, elt_srl, srl_drul[d]) == elt_srl | |
69 && minmax (d, elt_srl, srl) == elt_srl | |
70 && elt_srl != srl) | |
71 { | |
72 if (srl_drul[d] != elt_srl) | |
73 new_elt_drul[d].clear (); | |
74 new_elt_drul[d].push_back (elts[i]); | |
75 srl_drul[d] = elt_srl; | |
76 } | |
77 } | |
78 while (flip (&d) != LEFT); | |
79 } | |
80 | |
81 Direction d = LEFT; | |
82 do | |
83 new_elts.insert (new_elts.end (), new_elt_drul[d].begin (), new_elt_drul[d].
end ()); | |
84 while (flip (&d) != LEFT); | |
85 | |
86 SCM elements_scm = me->get_object ("elements"); | |
87 if (Grob_array::unsmob (elements_scm)) | |
88 { | |
89 vector<Grob *> &arr | |
90 = unsmob_grob_array (elements_scm)->array_reference (); | |
91 arr = new_elts; | |
92 } | |
93 | |
94 return SCM_BOOL_T; | |
95 } | |
96 | |
97 MAKE_SCHEME_CALLBACK (Pure_from_neighbor_interface, keep_proximal_elements_on_sy
stem, 1); | |
98 SCM | |
99 Pure_from_neighbor_interface::keep_proximal_elements_on_system (SCM smob) | |
100 { | |
101 keep_proximal_elements (smob); | |
102 keep_elements_on_system (smob); | |
103 return SCM_BOOL_T; | |
104 } | 53 } |
105 | 54 |
106 ADD_INTERFACE (Pure_from_neighbor_interface, | 55 ADD_INTERFACE (Pure_from_neighbor_interface, |
107 "A collection of routines to allow for objects' pure" | 56 "A collection of routines to allow for objects' pure" |
108 "heights and heights to be calculated based on the" | 57 "heights and heights to be calculated based on the" |
109 "heights of the objects' neighbors.", | 58 "heights of the objects' neighbors.", |
110 | 59 |
111 /* properties */ | 60 /* properties */ |
112 "elements-filtered " | 61 "neighbors " |
113 "pure-relevant-grobs " | 62 "pure-relevant-grobs " |
114 "pure-Y-common " | 63 "pure-Y-common " |
115 ); | 64 ); |
LEFT | RIGHT |