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);
51 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Stem_tremolo)
53 Stem_tremolo::do_brew_molecule () const
55 Stem * stem = stem_l ();
56 Beam * beam = stem->beam_l ();
62 SCM s = beam->get_elt_property ("height");
64 dy = gh_scm2double (s);
65 Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
66 - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
67 dydx = dx ? dy/dx : 0;
73 Real ss = Staff_symbol_referencer_interface (stem).staff_space ();
74 Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
75 Real width = gh_scm2double (get_elt_property ("beam-width"));
79 Molecule a (lookup_l ()->beam (dydx, width, thick));
80 a.translate (Offset (-width/2, width / 2 * dydx));
83 SCM s = get_elt_property ("tremolo-flags");
85 tremolo_flags = gh_scm2int (s);
90 int mult = beam ? beam->get_multiplicity () : 0;
91 Real interbeam_f = paper_l ()->interbeam_f (mult);
93 for (int i = 0; i < tremolo_flags; i++)
96 b.translate_axis (interbeam_f * i, Y_AXIS);
100 mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS);
103 // ugh, rather calc from Stem_tremolo_req
104 int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
105 mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS),
106 stem->stem_end_position () * ss / 2 -
107 directional_element (beam).get () * beams_i * interbeam_f));
112 Beams should intersect one beamthickness below stem end
114 Real dy = stem->stem_end_position () * ss / 2;
115 dy -= mol.extent (Y_AXIS).length () / 2 * stem->get_direction ();
118 uhg. Should use relative coords and placement
120 Real whole_note_correction;
121 if (stem->invisible_b ())
122 whole_note_correction = -stem->get_direction ()
123 * stem->support_head ()->extent (X_AXIS).length () / 2;
125 whole_note_correction = 0;
127 mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS) +
128 whole_note_correction, dy));
136 Stem_tremolo::set_stem (Stem *s)
138 set_elt_pointer ("stem", s->self_scm_);