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 ()
28 set_elt_property ("stem", SCM_EOL);
33 Stem_tremolo::stem_l ()const
35 SCM s = get_elt_property ("stem");
37 return dynamic_cast<Stem*> ( unsmob_element (s));
41 Stem_tremolo::dim_callback (Dimension_cache const *c)
43 Stem_tremolo * s = dynamic_cast<Stem_tremolo*> (c->element_l ());
44 Real space = Staff_symbol_referencer_interface (s->stem_l ())
46 return Interval (-space, space);
51 Stem_tremolo::do_brew_molecule () const
53 Stem * stem = stem_l ();
54 Beam * beam = stem->beam_l ();
60 SCM s = beam->get_elt_property ("height");
62 dy = gh_scm2double (s);
63 Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
64 - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
65 dydx = dx ? dy/dx : 0;
71 Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
72 Real width = gh_scm2double (get_elt_property ("beam-width"));
73 Molecule a (lookup_l ()->beam (dydx, width, thick));
74 a.translate (Offset (-width/2, width / 2 * dydx));
77 SCM s = get_elt_property ("tremolo-flags");
79 tremolo_flags = gh_scm2int (s);
84 int mult = beam ? beam->get_multiplicity () : 0;
85 Real interbeam_f = paper_l ()->interbeam_f (mult);
87 for (int i = 0; i < tremolo_flags; i++)
90 b.translate_axis (interbeam_f * i, Y_AXIS);
94 mol.translate_axis (-mol.extent ()[Y_AXIS].center (), Y_AXIS);
96 Real half_space = Staff_symbol_referencer_interface (stem).staff_space ()
100 // ugh, rather calc from Stem_tremolo_req
101 int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
102 mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS),
103 stem->stem_end_position () * half_space -
104 directional_element (beam).get () * beams_i * interbeam_f));
109 Beams should intersect one beamthickness below stem end
111 Real dy = stem->stem_end_position () * half_space;
112 dy -= mol.extent ()[Y_AXIS].length () / 2 * stem->get_direction ();
115 uhg. Should use relative coords and placement
117 Real whole_note_correction;
118 if (stem->invisible_b ())
119 whole_note_correction = -stem->get_direction ()
120 * stem->support_head ()->extent (X_AXIS).length () / 2;
122 whole_note_correction = 0;
124 mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS) +
125 whole_note_correction, dy));
133 Stem_tremolo::set_stem (Stem *s)
135 set_elt_property ("stem", s->self_scm_);