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
27 Stem_tremolo::set_interface (Score_element *me)
29 me->set_elt_pointer ("stem", SCM_EOL);
34 Stem_tremolo::dim_callback (Score_element * se, Axis )
36 Real space = Staff_symbol_referencer_interface (se).staff_space ();
37 return Interval (-space, space);
42 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Stem_tremolo,brew_molecule);
44 Stem_tremolo::brew_molecule (SCM smob)
46 Score_element *me= unsmob_element (smob);
47 Stem * stem = dynamic_cast<Stem*> (unsmob_element (me->get_elt_pointer ("stem")));
48 Beam * beam = stem->beam_l ();
54 SCM s = beam->get_elt_property ("height");
56 dy = gh_scm2double (s);
57 Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
58 - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
59 dydx = dx ? dy/dx : 0;
65 Real ss = Staff_symbol_referencer_interface (stem).staff_space ();
66 Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
67 Real width = gh_scm2double (me->get_elt_property ("beam-width"));
71 Molecule a (me->lookup_l ()->beam (dydx, width, thick));
72 a.translate (Offset (-width/2, width / 2 * dydx));
75 SCM s = me->get_elt_property ("tremolo-flags");
77 tremolo_flags = gh_scm2int (s);
82 int mult = beam ? beam->get_multiplicity () : 0;
83 Real interbeam_f = me->paper_l ()->interbeam_f (mult);
85 for (int i = 0; i < tremolo_flags; i++)
88 b.translate_axis (interbeam_f * i, Y_AXIS);
92 mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS);
95 // ugh, rather calc from Stem_tremolo_req
96 int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
97 mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - me->relative_coordinate (0, X_AXIS),
98 stem->stem_end_position () * ss / 2 -
99 Directional_element_interface (beam).get () * beams_i * interbeam_f));
104 Beams should intersect one beamthickness below stem end
106 Real dy = stem->stem_end_position () * ss / 2;
107 dy -= mol.extent (Y_AXIS).length () / 2 * stem->get_direction ();
110 uhg. Should use relative coords and placement
112 Real whole_note_correction;
113 if (stem->invisible_b ())
114 whole_note_correction = -stem->get_direction ()
115 * stem->support_head ()->extent (X_AXIS).length () / 2;
117 whole_note_correction = 0;
119 mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - me->relative_coordinate (0, X_AXIS) +
120 whole_note_correction, dy));
123 return mol.create_scheme();
128 Stem_tremolo::set_stem (Score_element*me,Score_element *s)
130 me->set_elt_pointer ("stem", s->self_scm_);