]> git.donarmstrong.com Git - lilypond.git/blob - lily/semi-tie-column.cc
Uses only unpure-pure containers to articulate unpure-pure relationships (issue 3199)
[lilypond.git] / lily / semi-tie-column.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6
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
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "semi-tie-column.hh"
22 #include "semi-tie.hh"
23 #include "grob.hh"
24 #include "tie-column.hh"
25 #include "tie.hh"
26 #include "directional-element-interface.hh"
27 #include "pointer-group-interface.hh"
28 #include "staff-symbol-referencer.hh"
29 #include "item.hh"
30 #include "tie-formatting-problem.hh"
31 #include "tie-column-format.hh"
32
33 ADD_INTERFACE (Semi_tie_column,
34                "The interface for a column of l.v. (laissez vibrer) ties.",
35
36                /* properties */
37                "direction "
38                "positioning-done "
39                "head-direction "
40                "tie-configuration "
41                "ties "
42               );
43
44 /*
45   Cut & paste from tie-column.cc
46  */
47 MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_positioning_done, 1);
48 SCM
49 Semi_tie_column::calc_positioning_done (SCM smob)
50 {
51   Grob *me = unsmob_grob (smob);
52
53   me->set_property ("positioning-done", SCM_BOOL_T);
54
55   extract_grob_set (me, "ties", lv_ro_ties);
56   vector<Grob *> lv_ties (lv_ro_ties);
57
58   vector_sort (lv_ties, Semi_tie::less);
59
60   Ties_configuration ties_config;
61
62   Tie_formatting_problem problem;
63
64   problem.from_semi_ties (lv_ties, to_dir (me->get_property ("head-direction")));
65
66   SCM manual_configs = me->get_property ("tie-configuration");
67   problem.set_manual_tie_configuration (manual_configs);
68
69   Ties_configuration base = problem.generate_optimal_configuration ();
70   for (vsize i = 0; i < lv_ties.size (); i++)
71     {
72       SCM cp = Tie::get_control_points (lv_ties[i], problem.common_x_refpoint (), base[i],
73                                         problem.details_);
74
75       lv_ties[i]->set_property ("control-points", cp);
76       set_grob_direction (lv_ties[i], base[i].dir_);
77
78       problem.set_debug_scoring (base);
79     }
80
81   return SCM_BOOL_T;
82 }
83
84 MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_head_direction, 1);
85 SCM
86 Semi_tie_column::calc_head_direction (SCM smob)
87 {
88   Grob *me = unsmob_grob (smob);
89
90   extract_grob_set (me, "ties", ties);
91   Direction d = LEFT;
92   for (vsize i = 0; i < ties.size (); i++)
93     {
94       Direction this_d = to_dir (ties[i]->get_property ("head-direction"));
95       if (i > 0 && d != this_d)
96         {
97           programming_error ("all semi-ties in a semi-tie-column should have the same head-direction");
98           return scm_from_int (d);
99         }
100       d = this_d;
101     }
102   return scm_from_int (d);
103 }