/*
- abbrev.cc -- implement Stem_tremolo
+ stem-tremolo.cc -- implement Stem_tremolo
source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "offset.hh"
#include "dimension-cache.hh"
#include "staff-symbol-referencer.hh"
+#include "directional-element-interface.hh"
+/*
+ TODO:
+ lengthen stem if necessary
+ */
Stem_tremolo::Stem_tremolo ()
{
set_elt_property ("stem", SCM_EOL);
- abbrev_flags_i_ = 1;
}
-void
-Stem_tremolo::do_print () const
-{
- DEBUG_OUT << "abbrev_flags_i_ " << abbrev_flags_i_;
-}
Stem *
Stem_tremolo::stem_l ()const
{
Stem_tremolo * s = dynamic_cast<Stem_tremolo*> (c->element_l ());
Real space = Staff_symbol_referencer_interface (s->stem_l ())
- .staff_line_leading_f ();
+ .staff_space ();
return Interval (-space, space);
}
-Molecule*
-Stem_tremolo::do_brew_molecule_p () const
+Molecule
+Stem_tremolo::do_brew_molecule () const
{
- Stem * st = stem_l ();
- int mult =0;
- if (Beam * b = st->beam_l ())
+ Stem * stem = stem_l ();
+ Beam * beam = stem->beam_l ();
+
+ Real dydx;
+ if (beam)
{
- mult = b->multiplicity_i_;
+ Real dy = 0;
+ SCM s = beam->get_elt_property ("height");
+ if (gh_number_p (s))
+ dy = gh_scm2double (s);
+ Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
+ - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
+ dydx = dx ? dy/dx : 0;
}
+ else
+ // urg
+ dydx = 0.25;
+
+ Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
+ Real width = gh_scm2double (get_elt_property ("beam-width"));
+ Molecule a (lookup_l ()->beam (dydx, width, thick));
+ a.translate (Offset (-width/2, width / 2 * dydx));
+ int tremolo_flags;
+ SCM s = get_elt_property ("tremolo-flags");
+ if (gh_number_p (s))
+ tremolo_flags = gh_scm2int (s);
+ else
+ // huh?
+ tremolo_flags = 1;
+
+ int mult = beam ? beam->get_multiplicity () : 0;
Real interbeam_f = paper_l ()->interbeam_f (mult);
- Real w = gh_scm2double (get_elt_property ("beam-width"));
- Real space = Staff_symbol_referencer_interface (st).staff_line_leading_f ();
- Real internote_f = space / 2;
- Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));
-
- int beams_i = 0;
- Real slope_f = 0.25;
-
- if (st && st->beam_l ()) {
- slope_f = st->beam_l ()->slope_f_;
- // ugh, rather calc from Stem_tremolo_req
- beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT];
- }
-
- Molecule a (lookup_l ()->beam (slope_f, w, beam_f));
- a.translate (Offset (-w/2, w / 2 * slope_f));
-
- Molecule *beams= new Molecule;
- for (int i = 0; i < abbrev_flags_i_; i++)
+ Molecule mol;
+ for (int i = 0; i < tremolo_flags; i++)
{
Molecule b (a);
b.translate_axis (interbeam_f * i, Y_AXIS);
- beams->add_molecule (b);
+ mol.add_molecule (b);
}
- beams->translate_axis (-beams->extent ()[Y_AXIS].center (), Y_AXIS);
-
- if (st)
- {
- if (st->beam_l ())
- {
- beams->translate (Offset(st->hpos_f () - hpos_f (),
- st->stem_end_f () * internote_f -
- st->beam_l ()->get_direction () * beams_i * interbeam_f));
- }
- else
- {
- /*
- Beams should intersect one beamthickness below staff end
- */
- Real dy = - beams->extent ()[Y_AXIS].length () / 2 * st->get_direction ();
-
- /*
- uhg. Should use relative coords and placement
- */
- Real whole_note_correction = (st && st->invisible_b( ))
- ? -st->get_direction () * st->note_delta_f ()/2
- : 0.0;
-
- dy += st->stem_end_f ();
- beams->translate (Offset(st->hpos_f () - hpos_f ()+
- whole_note_correction, dy));
- }
+ if (tremolo_flags)
+ mol.translate_axis (-mol.extent ()[Y_AXIS].center (), Y_AXIS);
+ Real half_space = Staff_symbol_referencer_interface (stem).staff_space ()
+ / 2;
+ if (beam)
+ {
+ // ugh, rather calc from Stem_tremolo_req
+ int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT);
+ mol.translate (Offset(stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS),
+ stem->stem_end_position () * half_space -
+ directional_element (beam).get () * beams_i * interbeam_f));
+ }
+ else
+ {
/*
- there used to be half a page of code that was long commented out.
- Removed in 1.1.35
- */
+ Beams should intersect one beamthickness below stem end
+ */
+ Real dy = stem->stem_end_position () * half_space;
+ dy -= mol.extent ()[Y_AXIS].length () / 2 * stem->get_direction ();
+
+ /*
+ uhg. Should use relative coords and placement
+ */
+ Real whole_note_correction;
+ if (stem->invisible_b ())
+ whole_note_correction = -stem->get_direction ()
+ * stem->support_head ()->extent (X_AXIS).length () / 2;
+ else
+ whole_note_correction = 0;
+
+ mol.translate (Offset (stem->relative_coordinate (0, X_AXIS) - relative_coordinate (0, X_AXIS) +
+ whole_note_correction, dy));
}
- return beams;
+ return mol;
}