2 stem-tremolo.cc -- implement Stem_tremolo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "stem-tremolo.hh"
13 #include "paper-def.hh"
17 #include "dimension-cache.hh"
18 #include "staff-symbol-referencer.hh"
19 #include "directional-element-interface.hh"
23 lengthen stem if necessary
26 Stem_tremolo::Stem_tremolo (SCM s)
29 set_elt_pointer ("stem", SCM_EOL);
34 Stem_tremolo::stem_l ()const
36 SCM s = get_elt_pointer ("stem");
38 return dynamic_cast<Stem*> ( unsmob_element (s));
42 Stem_tremolo::dim_callback (Score_element * se, Axis )
44 Stem_tremolo * s = dynamic_cast<Stem_tremolo*> (se);
45 Real space = Staff_symbol_referencer_interface (s->stem_l ())
47 return Interval (-space, space);
52 GLUE_SCORE_ELEMENT(Stem_tremolo,brew_molecule);
54 Stem_tremolo::member_brew_molecule () const
56 Stem * stem = stem_l ();
57 Beam * beam = stem->beam_l ();
63 SCM s = beam->get_elt_property ("height");
65 dy = gh_scm2double (s);
66 Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
67 - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
68 dydx = dx ? dy/dx : 0;
74 Real ss = Staff_symbol_referencer_interface (stem).staff_space ();
75 Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
76 Real width = gh_scm2double (get_elt_property ("beam-width"));
80 Molecule a (lookup_l ()->beam (dydx, width, thick));
81 a.translate (Offset (-width/2, width / 2 * dydx));
84 SCM s = get_elt_property ("tremolo-flags");
86 tremolo_flags = gh_scm2int (s);
91 int mult = beam ? beam->get_multiplicity () : 0;
92 Real interbeam_f = paper_l ()->interbeam_f (mult);
94 for (int i = 0; i < tremolo_flags; i++)
97 b.translate_axis (interbeam_f * i, Y_AXIS);
101 mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS);
104 // ugh, rather calc from Stem_tremolo_req
105 int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
106 mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS),
107 stem->stem_end_position () * ss / 2 -
108 directional_element (beam).get () * beams_i * interbeam_f));
113 Beams should intersect one beamthickness below stem end
115 Real dy = stem->stem_end_position () * ss / 2;
116 dy -= mol.extent (Y_AXIS).length () / 2 * stem->get_direction ();
119 uhg. Should use relative coords and placement
121 Real whole_note_correction;
122 if (stem->invisible_b ())
123 whole_note_correction = -stem->get_direction ()
124 * stem->support_head ()->extent (X_AXIS).length () / 2;
126 whole_note_correction = 0;
128 mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS) +
129 whole_note_correction, dy));
132 return mol.create_scheme();
137 Stem_tremolo::set_stem (Stem *s)
139 set_elt_pointer ("stem", s->self_scm_);