]> git.donarmstrong.com Git - lilypond.git/blob - lily/tie-details.cc
Add new features/bugfixes to changes.tely
[lilypond.git] / lily / tie-details.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2011 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 "tie.hh"
22 #include "bezier.hh"
23 #include "grob.hh"
24 #include "staff-symbol-referencer.hh"
25 #include "warn.hh"
26 #include "tie-details.hh"
27
28 /*
29   this is a macro because we want ly_symbol2scm()
30  */
31 #define get_real_detail(src, defvalue) \
32   robust_scm2double(ly_assoc_get (ly_symbol2scm (src), details, SCM_EOL), defvalue)
33 #define get_int_detail(src, defvalue) \
34   robust_scm2int(ly_assoc_get (ly_symbol2scm (src), details, SCM_EOL), defvalue)
35
36 void
37 Tie_details::from_grob (Grob *me)
38 {
39   staff_symbol_referencer_ = me;
40   staff_space_ = Staff_symbol_referencer::staff_space (me);
41
42   neutral_direction_ = to_dir (me->get_property ("neutral-direction"));
43   if (!neutral_direction_)
44     neutral_direction_ = DOWN;
45
46   SCM details = me->get_property ("details");
47
48   height_limit_ = get_real_detail ("height-limit", 0.75);
49   ratio_ = get_real_detail ("ratio", .333);
50   between_length_limit_ = get_real_detail ("between-length-limit", 1.0);
51
52   wrong_direction_offset_penalty_ = get_real_detail ("wrong-direction-offset-penalty", 10);
53
54   min_length_ = get_real_detail ("min-length", 1.0);
55   min_length_penalty_factor_ = get_real_detail ("min-length-penalty-factor", 1.0);
56
57   // in half-space
58   center_staff_line_clearance_ = get_real_detail ("center-staff-line-clearance", 0.4);
59   tip_staff_line_clearance_ = get_real_detail ("tip-staff-line-clearance", 0.4);
60   staff_line_collision_penalty_ = get_real_detail ("staff-line-collision-penalty", 5);
61   dot_collision_clearance_ = get_real_detail ( "dot-collision-clearance", 0.25);
62   dot_collision_penalty_ = get_real_detail ( "dot-collision-penalty", 0.25);
63   x_gap_ = get_real_detail ("note-head-gap", 0.2);
64   stem_gap_ = get_real_detail ("stem-gap", 0.3);
65   tie_column_monotonicity_penalty_ = get_real_detail ("tie-column-monotonicity-penalty", 100);
66   tie_tie_collision_penalty_ = get_real_detail ("tie-tie-collision-penalty", 30);
67   tie_tie_collision_distance_ = get_real_detail ("tie-tie-collision-distance", .25);
68   horizontal_distance_penalty_factor_ = get_real_detail ("horizontal-distance-penalty-factor", 5);
69   same_dir_as_stem_penalty_ = get_real_detail ("same-dir-as-stem-penalty", 20);
70   vertical_distance_penalty_factor_ = get_real_detail ("vertical-distance-penalty-factor", 5);
71   intra_space_threshold_ = get_real_detail ("intra-space-threshold", 1.0);
72   outer_tie_length_symmetry_penalty_factor_ = get_real_detail ("outer-tie-length-symmetry-penalty-factor", 3.0);
73   outer_tie_vertical_distance_symmetry_penalty_factor_ = get_real_detail ("outer-tie-vertical-distance-symmetry-penalty-factor", 3.0);
74
75   outer_tie_vertical_gap_ = get_real_detail ("outer-tie-vertical-gap", 0.15);
76
77   single_tie_region_size_ = get_int_detail ("single-tie-region-size", 3);
78   skyline_padding_ = get_real_detail ("skyline-padding", 0.05);
79   multi_tie_region_size_ = get_int_detail ("multi-tie-region-size", 1);
80 }
81
82 Tie_details::Tie_details ()
83 {
84   staff_space_ = 1.0;
85   height_limit_ = 1.0;
86   ratio_ = .333;
87 }
88