]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/slur-scoring.hh
2fc069b9023c06d9a6f7c1a3e5214ae0d45d184a
[lilypond.git] / lily / include / slur-scoring.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef SLUR_SCORING_HH
21 #define SLUR_SCORING_HH
22
23 #include "box.hh"
24 #include "std-vector.hh"
25 #include "lily-guile.hh"
26 #include "slur-score-parameters.hh"
27
28 struct Extra_collision_info
29 {
30   Real idx_;
31   Box extents_;
32   Real penalty_;
33   Grob *grob_;
34   SCM type_;
35
36   Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p);
37   Extra_collision_info ();
38 };
39
40 struct Encompass_info
41 {
42   Real x_;
43   Real stem_;
44   Real head_;
45   Encompass_info ()
46   {
47     x_ = 0.0;
48     stem_ = 0.0;
49     head_ = 0.0;
50   }
51   Real get_point (Direction dir) const
52   {
53     Interval y;
54     y.add_point (stem_);
55     y.add_point (head_);
56     return y[dir];
57   }
58 };
59
60 struct Bound_info
61 {
62   Box stem_extent_;
63   Direction stem_dir_;
64   Item *bound_;
65   Grob *note_column_;
66   Grob *slur_head_;
67   Grob *staff_;
68   Grob *stem_;
69   Grob *flag_;
70   Interval slur_head_x_extent_;
71   Real staff_space_;
72
73   Bound_info ()
74   {
75     stem_ = 0;
76     staff_ = 0;
77     slur_head_ = 0;
78     stem_dir_ = CENTER;
79     note_column_ = 0;
80   }
81 };
82
83 struct Slur_score_state
84 {
85   Spanner *slur_;
86   Grob *common_[NO_AXES];
87   bool valid_;
88   bool edge_has_beams_;
89   bool is_broken_;
90   bool has_same_beam_;
91
92   Real musical_dy_;
93   vector<Grob *> columns_;
94   vector<Encompass_info> encompass_infos_;
95   vector<Extra_collision_info> extra_encompass_infos_;
96
97   Direction dir_;
98   Slur_score_parameters parameters_;
99   Drul_array<Bound_info> extremes_;
100   Drul_array<Offset> base_attachments_;
101   vector<Slur_configuration *> configurations_;
102   Real staff_space_;
103   Real line_thickness_;
104   Real thickness_;
105
106   Slur_score_state ();
107   ~Slur_score_state ();
108
109   Slur_configuration *get_forced_configuration (Interval ys) const;
110   Slur_configuration *get_best_curve () const;
111   void fill (Grob *);
112   Direction slur_direction () const;
113
114   vector<Offset> generate_avoid_offsets () const;
115   Drul_array<Bound_info> get_bound_info () const;
116   void generate_curves () const;
117   vector<Slur_configuration *> enumerate_attachments (Drul_array<Real> end_ys) const;
118   Drul_array<Offset> get_base_attachments () const;
119   Drul_array<Real> get_y_attachment_range () const;
120   Encompass_info get_encompass_info (Grob *col) const;
121   vector<Extra_collision_info> get_extra_encompass_infos () const;
122   Real move_away_from_staffline (Real y, Grob *on_staff) const;
123
124   Interval breakable_bound_extent (Direction) const;
125 };
126
127 void set_slur_control_points (Grob *me);
128
129 #endif /* SLUR_SCORING_HH */