source file of the GNU LilyPond music typesetter
- (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
-
#include "tie.hh"
#include "bezier.hh"
#include "grob.hh"
#include "staff-symbol-referencer.hh"
#include "warn.hh"
-
-int
-Tie_configuration::compare (Tie_configuration const &a,
- Tie_configuration const &b)
-{
- if (a.position_ - b.position_)
- return sign (a.position_ - b.position_);
- return sign (a.dir_ - b.dir_);
-}
-
-
-Tie_configuration::Tie_configuration ()
-{
- dir_ = CENTER;
- position_ = 0;
- delta_y_ = 0.0;
-}
-
-
-void
-Tie_configuration::center_tie_vertically (Tie_details const &details)
-{
- Bezier b = get_bezier (details);
- Offset middle = b.curve_point (0.5);
- Offset edge = b.curve_point (0.0);
-
- Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0;
-
- delta_y_ = - dir_ * center;
-}
+#include "tie-formatting-problem.hh"
/*
- Get bezier with left control at (0,0)
+ this is a macro because we want ly_symbol2scm()
*/
-Bezier
-Tie_configuration::get_bezier (Tie_details const &details) const
-{
- Real l = attachment_x_.length();
- if (isnan (l) || isnan (l))
- {
- programming_error ("Inf or NaN encountered");
- l = 1.0;
- }
- return slur_shape (l,
- details.height_limit_,
- details.ratio_);
-}
-
-Real
-Tie_configuration::distance (Tie_configuration const &a,
- Tie_configuration const &b)
-{
-
- Real d = 3 * (a.position_ - b.position_);
- if (d < 0)
- return d + (2 + (b.dir_ - a.dir_));
- else
- return d + (2 + (a.dir_ - b.dir_));
-}
-
-Real
-Tie_configuration::height (Tie_details const &details) const
-{
- Real l = attachment_x_.length();
-
- return slur_shape (l,
- details.height_limit_,
- details.ratio_).curve_point (0.5)[Y_AXIS];
-}
-
-
+#define get_real_detail(src, defvalue) \
+ robust_scm2double(ly_assoc_get (ly_symbol2scm (src), details, SCM_EOL), defvalue)
void
-Tie_details::init (Grob *me)
+Tie_details::from_grob (Grob *me)
{
+ staff_symbol_referencer_ = me;
staff_space_ = Staff_symbol_referencer::staff_space (me);
- SCM details = me->get_property ("details");
+ SCM details = me->get_property ("details");
- height_limit_ = robust_scm2double (ly_assoc_get (ly_symbol2scm ("height-limit"), details, SCM_EOL),
- 0.75) * staff_space_;
+ height_limit_ = get_real_detail("height-limit", 0.75);
+ ratio_ = get_real_detail("ratio", .333);
+ between_length_limit_ = get_real_detail ("between-length-limit", 1.0);
- ratio_ = robust_scm2double (ly_assoc_get (ly_symbol2scm ("ratio"), details, SCM_EOL),
- .333);
+ wrong_direction_offset_penalty_ = get_real_detail("wrong-direction-offset-penalty", 10);
- x_gap_ = robust_scm2double (me->get_property ("x-gap"), 0.2);
- between_length_limit_
- = robust_scm2double (ly_assoc_get (ly_symbol2scm ("between-length-limit"), details, SCM_EOL),
- 1.0);
+ length_penalty_factor_ = get_real_detail("length-penalty-factor", 1.0);
+ min_length_ = get_real_detail("min-length", 0.333);
+
+ // in half-space
+ center_staff_line_clearance_ = get_real_detail ("center-staff-line-clearance", 0.4);
+ tip_staff_line_clearance_ = get_real_detail ("tip-staff-line-clearance", 0.4);
+ staff_line_collision_penalty_ = get_real_detail("staff-line-collision-penalty", 5);
+ dot_collision_clearance_ = get_real_detail ( "dot-collision-clearance", 0.25);
+ dot_collision_penalty_ = get_real_detail ( "dot-collision-penalty", 0.25);
+ x_gap_ = get_real_detail ("note-head-gap", 0.2);
+ stem_gap_ = get_real_detail ("stem-gap", 0.3);
+ tie_column_monotonicity_penalty_ = get_real_detail ("tie-column-monotonicity-penalty", 100);
+ tie_tie_collision_penalty_ = get_real_detail ("tie-tie-collision-penalty", 30);
+ tie_tie_collision_distance_ = get_real_detail ("tie-tie-collision-distance", .25);
+ horizontal_distance_penalty_factor_ = get_real_detail ("horizontal-distance-penalty-factor", 5);
+ vertical_distance_penalty_factor_ = get_real_detail ("vertical-distance-penalty-factor", 5);
+ intra_space_threshold_ = get_real_detail ("intra-space-threshold", 1.0);
+ outer_tie_length_symmetry_penalty_factor_ = get_real_detail ("outer-tie-length-symmetry-penalty-factor", 3.0);
+ outer_tie_vertical_distance_symmetry_penalty_factor_ = get_real_detail ("outer-tie-vertical-distance-symmetry-penalty-factor", 3.0);
}