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