2 tie-configuration.cc -- implement Tie_configuration
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "tie-configuration.hh"
12 #include "tie-formatting-problem.hh"
16 Tie_configuration::compare (Tie_configuration const &a,
17 Tie_configuration const &b)
19 if (a.position_ - b.position_)
20 return sign (a.position_ - b.position_);
21 return sign (a.dir_ - b.dir_);
25 Tie_configuration::Tie_configuration ()
36 Tie_configuration::center_tie_vertically (Tie_details const &details)
38 Bezier b = get_untransformed_bezier (details);
39 Offset middle = b.curve_point (0.5);
40 Offset edge = b.curve_point (0.0);
41 Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
43 delta_y_ = - dir_ * center;
48 Tie_configuration::get_transformed_bezier (Tie_details const &details) const
50 Bezier b (get_untransformed_bezier (details));
53 b.translate (Offset (attachment_x_[LEFT],
54 delta_y_ + details.staff_space_ * 0.5 * position_));
60 Get bezier with left control at (0,0)
63 Tie_configuration::get_untransformed_bezier (Tie_details const &details) const
65 Real l = attachment_x_.length();
66 if (isinf (l) || isnan (l))
68 programming_error ("Inf or NaN encountered");
72 details.height_limit_,
77 Tie_configuration::distance (Tie_configuration const &a,
78 Tie_configuration const &b)
81 Real d = 3 * (a.position_ - b.position_);
83 return d + (2 + (b.dir_ - a.dir_));
85 return d + (2 + (a.dir_ - b.dir_));
90 Tie_configuration::add_score (Real s, string desc)
95 score_card_ += to_string ("%s=%.2f ", desc.c_str (), s);
99 Tie_configuration::height (Tie_details const &details) const
101 Real l = attachment_x_.length();
103 return slur_shape (l,
104 details.height_limit_,
105 details.ratio_).curve_point (0.5)[Y_AXIS];
108 Ties_configuration::Ties_configuration()
115 Ties_configuration::reset_score ()
120 tie_score_cards_.clear ();
124 Ties_configuration::add_tie_score (Real s, int i, string desc)
130 while (tie_score_cards_.size () < size ())
131 tie_score_cards_.push_back ("");
133 tie_score_cards_[i] += to_string ("%s=%.2f ", desc.c_str (), s);
138 Ties_configuration::add_score (Real s, string desc)
143 score_card_ += to_string ("%s=%.2f ", desc.c_str (), s);
147 Ties_configuration::score () const
153 Ties_configuration::card () const