]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/beam.hh
*** empty log message ***
[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 "std-vector.hh"
14 #include "lily-proto.hh"
15 #include "lily-guile.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
44 struct Beam_segment
45 {
46   int vertical_count_;
47   Interval horizontal_; 
48   Beam_segment ();
49 };
50
51 struct Beam_stem_segment 
52 {
53   Beam_stem_segment ();
54   Grob *stem_;
55   Real width_;
56   Real stem_x_;
57   int rank_;
58   int stem_index_;
59   Direction dir_;
60 };
61
62
63 bool operator <(Beam_stem_segment const &a, Beam_stem_segment const &b);
64
65 class Beam
66 {
67 public:
68   static int visible_stem_count (Grob *);
69   static Grob *first_visible_stem (Grob *);
70   static Grob *last_visible_stem (Grob *);
71   static bool has_interface (Grob *);
72   static void add_stem (Grob *, Grob *);
73   static bool is_knee (Grob *);
74   static void set_beaming (Grob *, Beaming_info_list const *);
75   static void set_stemlens (Grob *);
76   static int get_beam_count (Grob *me);
77   static Real get_beam_translation (Grob *me);
78   static Real get_thickness (Grob *me);
79   static void connect_beams (Grob *me);
80   static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common); 
81   
82   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
83   DECLARE_SCHEME_CALLBACK (print, (SCM));
84   DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
85   DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
86   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
87   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
88   DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
89   DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
90   DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
91
92   /* position callbacks */
93   DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM));
94   DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM));
95   DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM));
96   
97 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
98
99   static Real score_stem_lengths (vector<Grob*> const &stems,
100                                   vector<Stem_info> const &stem_infos,
101                                   vector<Real> const &base_stem_ys,
102                                   vector<Real> const &stem_xs,
103                                   Real xl, Real xr,
104                                   bool knee,
105                                   Real yl, Real yr, Beam_quant_parameters const *);
106   static Real score_forbidden_quants (Real, Real,
107                                       Real, Real, Real, Real,
108                                       Drul_array<int>, Direction, Direction,
109                                       Beam_quant_parameters const *);
110
111   static int get_direction_beam_count (Grob *me, Direction d);
112 private:
113   static Direction get_default_dir (Grob *);
114   static void set_stem_directions (Grob *, Direction);
115   static void consider_auto_knees (Grob *);
116   static void set_stem_shorten (Grob *);
117   static Real calc_stem_y (Grob *, Grob *s, Grob **c,
118                            Real, Real,
119                            Drul_array<Real> pos, bool french);
120   static int forced_stem_count (Grob *);
121 };
122
123
124 #endif /* BEAM_HH */
125