]> git.donarmstrong.com Git - lilypond.git/blob - lily/semi-tie-column.cc
f7a7be4968bf7a98b10f3f971bbe8b54e93a4003
[lilypond.git] / lily / semi-tie-column.cc
1 /*
2   semi-tie-column.cc -- implement Semi_tie_column
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "semi-tie-column.hh"
11 #include "semi-tie.hh"
12 #include "grob.hh"
13 #include "tie-column.hh"
14 #include "tie.hh"
15 #include "directional-element-interface.hh"
16 #include "pointer-group-interface.hh"
17 #include "staff-symbol-referencer.hh"
18 #include "item.hh"
19 #include "tie-formatting-problem.hh"
20 #include "tie-column-format.hh"
21
22
23 ADD_INTERFACE (Semi_tie_column,
24               "The interface for a column of l.v. (laissez vibrer) ties.",
25
26               /* properties */
27               "positioning-done "
28               "head-direction "
29               "tie-configuration "
30               );
31                            
32
33
34 /*
35   Cut & paste from tie-column.cc
36  */   
37 MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_positioning_done, 1);
38 SCM
39 Semi_tie_column::calc_positioning_done (SCM smob)
40 {
41   Grob *me = unsmob_grob (smob);
42
43   me->set_property ("positioning-done", SCM_BOOL_T);
44     
45   extract_grob_set (me, "ties", lv_ro_ties);
46   vector<Grob*> lv_ties (lv_ro_ties);
47
48   vector_sort (lv_ties, Semi_tie::less);
49
50   Ties_configuration ties_config;
51   
52
53   Tie_formatting_problem problem;
54   
55   problem.from_semi_ties (lv_ties, to_dir (me->get_property ("head-direction")));
56
57   SCM manual_configs = me->get_property ("tie-configuration");
58   problem.set_manual_tie_configuration (manual_configs);
59
60   Ties_configuration base = problem.generate_optimal_configuration ();
61   for (vsize i = 0; i < lv_ties.size (); i++)
62     {
63       SCM cp = Tie::get_control_points (lv_ties[i], problem.common_x_refpoint (), base[i],
64                                         problem.details_);
65
66       lv_ties[i]->set_property ("control-points", cp);
67       set_grob_direction (lv_ties[i], base[i].dir_);
68
69       problem.set_debug_scoring (base);
70     }
71   
72   return SCM_BOOL_T;
73 }
74   
75 MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_head_direction, 1);
76 SCM
77 Semi_tie_column::calc_head_direction (SCM smob)
78 {
79   Grob *me = unsmob_grob (smob);
80
81   extract_grob_set (me, "ties", ties);
82   Direction d = LEFT;
83   for (vsize i = 0; i < ties.size (); i++)
84     {
85       Direction this_d = to_dir (ties[i]->get_property ("head-direction"));
86       if (i > 0 && d != this_d)
87         {
88           programming_error ("all semi-ties in a semi-tie-column should have the same head-direction");
89           return scm_from_int (d);
90         }
91       d = this_d;
92     }
93   return scm_from_int (d);
94 }