]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/slur-scoring.hh
* flower
[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 #ifndef SLUR_SCORING_HH
10 #define SLUR_SCORING_HH
11
12 #include "box.hh"
13 #include "lily-proto.hh"
14 #include "parray.hh"
15 #include "lily-guile.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 struct Extra_collision_info
43 {
44   Real idx_;
45   Box extents_;
46   Real penalty_;
47   Grob *grob_;
48
49   Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p)
50   {
51     idx_ = idx;
52     extents_[X_AXIS] = x;
53     extents_[Y_AXIS] = y;
54     penalty_ = p;
55     grob_ = g;
56   }
57   Extra_collision_info ()
58   {
59     idx_ = 0.0;
60     penalty_ = 0.;
61     grob_ = 0;
62   }
63 };
64
65 struct Encompass_info
66 {
67   Real x_;
68   Real stem_;
69   Real head_;
70   Encompass_info ()
71   {
72     x_ = 0.0;
73     stem_ = 0.0;
74     head_ = 0.0;
75   }
76   Real get_point (Direction dir) const
77   {
78     Interval y;
79     y.add_point (stem_);
80     y.add_point (head_);
81     return y[dir];
82   }
83 };
84
85 struct Bound_info
86 {
87   Box stem_extent_;
88   Direction stem_dir_;
89   Item *bound_;
90   Grob *note_column_;
91   Grob *slur_head_;
92   Grob *staff_;
93   Grob *stem_;
94   Interval slur_head_extent_;
95   Real staff_space_;
96
97   Bound_info ()
98   {
99     stem_ = 0;
100     staff_ = 0;
101     slur_head_ = 0;
102     stem_dir_ = CENTER;
103     note_column_ = 0;
104   }
105 };
106
107 struct Slur_score_state
108 {
109   Spanner *slur_;
110   Grob *common_[NO_AXES];
111   bool valid_;
112   bool edge_has_beams_;
113   bool is_broken_;
114   bool has_same_beam_;
115
116   Real musical_dy_;
117   Link_array<Grob> columns_;
118   Array<Encompass_info> encompass_infos_;
119   Array<Extra_collision_info> extra_encompass_infos_;
120
121   Direction dir_;
122   Slur_score_parameters parameters_;
123   Drul_array<Bound_info> extremes_;
124   Drul_array<Offset> base_attachments_;
125   Link_array<Slur_configuration> configurations_;
126   Real staff_space_;
127   Real thickness_;
128
129   Slur_score_state ();
130   ~Slur_score_state ();
131
132   Bezier get_best_curve ();
133   void fill (Grob *);
134   void set_next_direction ();
135
136   Drul_array<Bound_info> get_bound_info () const;
137   void generate_curves () const;
138   Link_array<Slur_configuration> enumerate_attachments (Drul_array<Real> end_ys) const;
139   Drul_array<Offset> get_base_attachments () const;
140   Drul_array<Real> get_y_attachment_range () const;
141   Encompass_info get_encompass_info (Grob *col) const;
142   Array<Extra_collision_info> get_extra_encompass_infos () const;
143   Real move_away_from_staffline (Real y, Grob *on_staff) const;
144   int get_closest_index (SCM inspect_quants) const;
145 };
146
147 void set_slur_control_points (Grob *me);
148
149 #endif /* SLUR_SCORING_HH */