2 tie-column.cc -- implement Tie_column
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "tie-column.hh"
13 #include "output-def.hh"
16 #include "paper-column.hh"
18 #include "pointer-group-interface.hh"
20 #include "directional-element-interface.hh"
21 #include "tie-column-format.hh"
22 #include "tie-formatting-problem.hh"
23 #include "tie-configuration.hh"
28 Tie_column::add_tie (Grob *me, Grob *tie)
30 if (tie->get_parent (Y_AXIS)
31 && Tie_column::has_interface (tie->get_parent (Y_AXIS)))
34 if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties")))
36 dynamic_cast<Spanner *> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
37 dynamic_cast<Spanner *> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
40 tie->set_parent (me, Y_AXIS);
41 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
45 Extend the spanner over its Tie constituents.
47 MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
49 Tie_column::before_line_breaking (SCM smob)
51 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
52 for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
54 Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s)));
58 if (dir * tie->get_bound (dir)->get_column ()->get_rank ()
59 > dir * me->get_bound (dir)->get_column ()->get_rank ())
60 me->set_bound (dir, Tie::head (tie, dir));
62 while (flip (&dir) != LEFT);
65 return SCM_UNSPECIFIED;
68 MAKE_SCHEME_CALLBACK(Tie_column, calc_positioning_done, 1)
70 Tie_column::calc_positioning_done (SCM smob)
72 Grob *me = unsmob_grob (smob);
73 extract_grob_set (me, "ties", ro_ties);
74 vector<Grob*> ties (ro_ties);
81 Already handled by standard mechanisms.
86 vector_sort (ties, Tie::less);
88 Tie_formatting_problem problem;
89 problem.from_ties (ties);
91 SCM manual_configs = me->get_property ("tie-configuration");
92 problem.set_manual_tie_configuration (manual_configs);
95 Ties_configuration base = problem.generate_optimal_chord_configuration ();
97 for (vsize i = 0; i < base.size(); i++)
99 Tie::set_control_points (ties[i], problem.common_x_refpoint (),
102 set_grob_direction (ties[i],
105 #if DEBUG_TIE_SCORING
106 if (to_boolean (me->layout ()
107 ->lookup_variable (ly_symbol2scm ("debug-tie-scoring"))))
109 string card = to_string ("%d (%.2f): ", base[i].position_, base[i].delta_y_)
110 + base[i].card () + base.tie_card (i);
114 card += base.card ();
115 if (i == base.size () - 1)
116 card += to_string ("TOTAL=%.2f", base.score ());
118 ties[i]->set_property ("quant-score",
119 scm_makfrom0str (card.c_str ()));
129 ADD_INTERFACE (Tie_column, "tie-column-interface",
130 "Object that sets directions of multiple ties in a tied chord",