]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/slur-scoring.hh
(move_away_from_staffline): new function.
[lilypond.git] / lily / include / slur-scoring.hh
1 /* 
2   slur-scoring.hh -- declare Slur_score_parameters
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   
8 */
9
10 #ifndef SLUR_SCORING_HH
11 #define SLUR_SCORING_HH
12
13 #include "box.hh"
14 #include "lily-proto.hh"
15 #include "parray.hh"
16
17 struct Slur_score_parameters
18 {
19   int region_size_;
20   Real head_encompass_penalty_;
21   Real stem_encompass_penalty_;
22   Real closeness_factor_;
23   Real edge_attraction_factor_;
24   Real same_slope_penalty_;
25   Real steeper_slope_factor_;
26   Real non_horizontal_penalty_;
27   Real max_slope_;
28   Real max_slope_factor_;
29   Real extra_object_collision_;
30   Real accidental_collision_;
31   Real free_slur_distance_;
32   Real free_head_distance_;
33   Real extra_encompass_free_distance_;
34   Real absolute_closeness_measure_;
35   Real edge_slope_exponent_;
36   Real head_slur_distance_max_ratio_;
37   Real head_slur_distance_factor_;
38
39   void fill (Grob *him);
40 };
41
42
43
44 struct Extra_collision_info
45 {
46   Real idx_;
47   Box extents_;
48   Real penalty_;
49   Grob * grob_;
50
51   Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p)
52   {
53     idx_ = idx;
54     extents_[X_AXIS] = x;
55     extents_[Y_AXIS] = y;
56     penalty_ = p;
57     grob_ = g;
58   }
59   Extra_collision_info ()
60   {
61     idx_ = 0.0;
62     penalty_ = 0.;
63     grob_ = 0;
64   }
65 };
66
67
68 struct Encompass_info
69 {
70   Real x_;
71   Real stem_;
72   Real head_;
73   Encompass_info ()
74   {
75     x_ = 0.0;
76     stem_ = 0.0;
77     head_ = 0.0;
78   }
79   Real get_point (Direction dir) const
80   {
81     Interval y;
82     y.add_point (stem_);
83     y.add_point (head_);
84     return y[dir];
85   }
86 };
87
88 struct Bound_info
89 {
90   Box stem_extent_;
91   Direction stem_dir_;
92   Item *bound_;
93   Grob *note_column_;
94   Grob *slur_head_;
95   Grob *staff_;
96   Grob *stem_;
97   Interval slur_head_extent_;
98   Real staff_space_;
99
100   Bound_info ()
101   {
102     stem_ = 0;
103     staff_ = 0;
104     slur_head_ = 0;
105     stem_dir_ = CENTER;
106     note_column_ = 0;
107   }
108 };
109
110 struct Slur_score_state
111 {
112   Spanner *slur_;
113   Grob *common_[NO_AXES];
114   bool valid_;
115   bool edge_has_beams_;
116   bool is_broken_;
117   bool has_same_beam_;
118   
119   Real musical_dy_;
120   Link_array<Grob> columns_;
121   Array<Encompass_info> encompass_infos_;
122   Array<Extra_collision_info> extra_encompass_infos_;
123   
124   Direction dir_;
125   Slur_score_parameters parameters_;
126   Drul_array<Bound_info> extremes_;
127   Drul_array<Offset> base_attachments_;
128   Link_array<Slur_configuration> configurations_;
129   Real staff_space_;
130   Real thickness_;
131   
132   Slur_score_state();
133   ~Slur_score_state();
134
135   Bezier get_best_curve ();
136   void fill (Grob*);
137   void set_next_direction ();
138   
139   Drul_array<Bound_info> get_bound_info () const;
140   void generate_curves () const; 
141   Link_array<Slur_configuration> enumerate_attachments (Drul_array<Real> end_ys) const;
142   Drul_array<Offset> get_base_attachments() const;
143   Drul_array<Real> get_y_attachment_range() const;
144   Encompass_info get_encompass_info (Grob *col) const;
145   Array<Extra_collision_info> get_extra_encompass_infos () const;
146   Real move_away_from_staffline (Real y, Grob *on_staff) const;
147 };
148
149
150 void set_slur_control_points (Grob *me);
151
152 #endif /* SLUR_SCORING_HH */