Correct left text alignment of DynamicTextSpanner.
[lilypond.git] / lily / include / beam.hh
blob3b61792aebfde302494e8d9df480313e69c0a59d
1 /*
2 beam.hh -- part of GNU LilyPond
4 source file of the LilyPond music typesetter
6 (c) 1996--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #ifndef BEAM_HH
11 #define BEAM_HH
13 #include "grob-interface.hh"
14 #include "std-vector.hh"
15 #include "lily-proto.hh"
16 #include "stem-info.hh"
19 TODO: move quanting in separate file.
21 struct Beam_quant_parameters
23 Real INTER_QUANT_PENALTY;
24 Real SECONDARY_BEAM_DEMERIT;
25 Real STEM_LENGTH_DEMERIT_FACTOR;
26 Real REGION_SIZE;
29 threshold to combat rounding errors.
31 Real BEAM_EPS;
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 HINT_DIRECTION_PENALTY;
38 Real IDEAL_SLOPE_FACTOR;
39 Real ROUND_TO_ZERO_SLOPE;
41 void fill (Grob *him);
44 struct Beam_segment
46 int vertical_count_;
47 Interval horizontal_;
48 Beam_segment ();
51 struct Beam_stem_segment
53 Beam_stem_segment ();
55 Grob *stem_;
56 Real width_;
57 Real stem_x_;
58 int rank_;
59 vsize stem_index_;
60 bool gapped_;
61 Direction dir_;
62 int max_connect_;
67 bool operator <(Beam_stem_segment const &a, Beam_stem_segment const &b);
69 class Beam
71 public:
72 static int normal_stem_count (Grob *);
73 static Grob *first_normal_stem (Grob *);
74 static Grob *last_normal_stem (Grob *);
75 DECLARE_GROB_INTERFACE();
76 static void add_stem (Grob *, Grob *);
77 static bool is_cross_staff (Grob *);
78 static bool is_knee (Grob *);
79 static void set_beaming (Grob *, Beaming_pattern const *);
80 static void set_stemlens (Grob *);
81 static int get_beam_count (Grob *me);
82 static Real get_beam_translation (Grob *me);
83 static Real get_thickness (Grob *me);
84 static void connect_beams (Grob *me);
85 static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common);
86 static Interval no_visible_stem_positions (Grob *me, Interval default_value);
88 DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
89 DECLARE_SCHEME_CALLBACK (print, (SCM));
90 DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
91 DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
92 DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
93 DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
94 DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
95 DECLARE_SCHEME_CALLBACK (calc_normal_stems, (SCM));
96 DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
97 DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
98 DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
100 /* position callbacks */
101 DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM));
102 DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM));
103 DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM));
105 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
107 static Real score_stem_lengths (vector<Grob*> const &stems,
108 vector<Stem_info> const &stem_infos,
109 vector<Real> const &base_stem_ys,
110 vector<Real> const &stem_xs,
111 Real xl, Real xr,
112 bool knee,
113 Real yl, Real yr, Beam_quant_parameters const *);
114 static Real score_forbidden_quants (Real, Real,
115 Real, Real, Real, Real,
116 Drul_array<int>, Direction, Direction,
117 Beam_quant_parameters const *);
119 static int get_direction_beam_count (Grob *me, Direction d);
120 private:
121 static Direction get_default_dir (Grob *);
122 static void set_stem_directions (Grob *, Direction);
123 static void consider_auto_knees (Grob *);
124 static void set_stem_shorten (Grob *);
125 static Real calc_stem_y (Grob *, Grob *s, Grob **c,
126 Real, Real, Direction,
127 Drul_array<Real> pos, bool french);
128 static int forced_stem_count (Grob *);
132 #endif /* BEAM_HH */