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