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