]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/beam.hh
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / include / beam.hh
1 /*
2   beam.hh -- part of GNU LilyPond
3
4   source file of the LilyPond music typesetter
5
6   (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #ifndef BEAM_HH
11 #define BEAM_HH
12
13 #include "grob-interface.hh"
14 #include "std-vector.hh"
15 #include "lily-proto.hh"
16 #include "stem-info.hh"
17
18 /*
19   TODO: move quanting in separate file.
20 */
21 struct Beam_quant_parameters
22 {
23   Real INTER_QUANT_PENALTY;
24   Real SECONDARY_BEAM_DEMERIT;
25   Real STEM_LENGTH_DEMERIT_FACTOR;
26   Real REGION_SIZE;
27
28   /*
29     threshold to combat rounding errors.
30   */
31   Real BEAM_EPS;
32
33   // possibly ridiculous, but too short stems just won't do
34   Real STEM_LENGTH_LIMIT_PENALTY;
35   Real DAMPING_DIRECTION_PENALTY;
36   Real MUSICAL_DIRECTION_FACTOR;
37   Real IDEAL_SLOPE_FACTOR;
38   Real ROUND_TO_ZERO_SLOPE;
39
40   void fill (Grob *him);
41 };
42
43 struct Beam_segment
44 {
45   int vertical_count_;
46   Interval horizontal_; 
47   Beam_segment ();
48 };
49
50 struct Beam_stem_segment 
51 {
52   Beam_stem_segment ();
53
54   Grob *stem_;
55   Real width_;
56   Real stem_x_;
57   int rank_;
58   int stem_index_;
59   bool gapped_;
60   Direction dir_;
61   int max_connect_;
62   
63 };
64
65
66 bool operator <(Beam_stem_segment const &a, Beam_stem_segment const &b);
67
68 class Beam
69 {
70 public:
71   static int visible_stem_count (Grob *);
72   static Grob *first_visible_stem (Grob *);
73   static Grob *last_visible_stem (Grob *);
74   DECLARE_GROB_INTERFACE();
75   static void add_stem (Grob *, Grob *);
76   static bool is_knee (Grob *);
77   static void set_beaming (Grob *, Beaming_pattern const *);
78   static void set_stemlens (Grob *);
79   static int get_beam_count (Grob *me);
80   static Real get_beam_translation (Grob *me);
81   static Real get_thickness (Grob *me);
82   static void connect_beams (Grob *me);
83   static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common); 
84   
85   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
86   DECLARE_SCHEME_CALLBACK (print, (SCM));
87   DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
88   DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
89   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
90   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
91   DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
92   DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
93   DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
94
95   /* position callbacks */
96   DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM));
97   DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM));
98   DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM));
99   
100 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
101
102   static Real score_stem_lengths (vector<Grob*> const &stems,
103                                   vector<Stem_info> const &stem_infos,
104                                   vector<Real> const &base_stem_ys,
105                                   vector<Real> const &stem_xs,
106                                   Real xl, Real xr,
107                                   bool knee,
108                                   Real yl, Real yr, Beam_quant_parameters const *);
109   static Real score_forbidden_quants (Real, Real,
110                                       Real, Real, Real, Real,
111                                       Drul_array<int>, Direction, Direction,
112                                       Beam_quant_parameters const *);
113
114   static int get_direction_beam_count (Grob *me, Direction d);
115 private:
116   static Direction get_default_dir (Grob *);
117   static void set_stem_directions (Grob *, Direction);
118   static void consider_auto_knees (Grob *);
119   static void set_stem_shorten (Grob *);
120   static Real calc_stem_y (Grob *, Grob *s, Grob **c,
121                            Real, Real,
122                            Drul_array<Real> pos, bool french);
123   static int forced_stem_count (Grob *);
124 };
125
126
127 #endif /* BEAM_HH */
128