]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/slur-scoring.hh
* lily/include/slur-scoring.hh (struct Slur_score_state): new file
[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 edge_slope_exponent_;
35   Real head_slur_distance_max_ratio_;
36   Real head_slur_distance_factor_;
37 };
38
39
40
41 struct Extra_collision_info
42 {
43   Real idx_;
44   Box extents_;
45   Real penalty_;
46   Grob * grob_;
47
48   Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p)
49   {
50     idx_ = idx;
51     extents_[X_AXIS] = x;
52     extents_[Y_AXIS] = y;
53     penalty_ = p;
54     grob_ = g;
55   }
56   Extra_collision_info ()
57   {
58     idx_ = 0.0;
59     penalty_ = 0.;
60     grob_ = 0;
61   }
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   Array<Slur_configuration> *scores_;
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   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 };
144
145
146 void set_slur_control_points (Grob *me);
147
148 #endif /* SLUR_SCORING_HH */