lilypond-1.1.67
[lilypond.git] / lily / stem-tremolo.cc
blob6a0e947362c6d330c74d798a427d063e3c638150
1 /*
2 abbrev.cc -- implement Stem_tremolo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "stem-tremolo.hh"
11 #include "debug.hh"
12 #include "beam.hh"
13 #include "paper-def.hh"
14 #include "lookup.hh"
15 #include "stem.hh"
16 #include "offset.hh"
18 Stem_tremolo::Stem_tremolo ()
20 stem_l_ = 0;
21 abbrev_flags_i_ = 1;
24 void
25 Stem_tremolo::do_print () const
27 DOUT << "abbrev_flags_i_ " << abbrev_flags_i_;
30 Interval
31 Stem_tremolo::do_width () const
33 Real space = stem_l_->staff_line_leading_f ();
34 return Interval (-space, space);
37 void
38 Stem_tremolo::do_pre_processing ()
42 Molecule*
43 Stem_tremolo::do_brew_molecule_p () const
45 int mult =0;
46 if (Beam * b = stem_l_->beam_l_)
48 Stem_info i = b->get_stem_info (stem_l_);
49 mult = i.mult_i_;
52 Real interbeam_f = paper_l ()->interbeam_f (mult);
53 Real w = 1.5 * lookup_l ()->notehead (2, "").dim_[X_AXIS].length ();
54 Real space = stem_l_->staff_line_leading_f ();
55 Real internote_f = space/2;
57 Real beam_f = paper_l ()->beam_thickness_f ();
59 int beams_i = 0;
60 Real slope_f = internote_f / 4 / internote_f; // HUH?
62 if (stem_l_ && stem_l_->beam_l_) {
63 slope_f = stem_l_->beam_l_->slope_f_;
64 // ugh, rather calc from Stem_tremolo_req
65 beams_i = stem_l_->beams_i_drul_[RIGHT] >? stem_l_->beams_i_drul_[LEFT];
67 Real sl = slope_f * internote_f;
69 Molecule a (lookup_l ()->beam (sl, w, beam_f));
70 a.translate (Offset (-w/2, w / 2 * slope_f));
72 Molecule *beams= new Molecule;
73 for (int i = 0; i < abbrev_flags_i_; i++)
75 Molecule b (a);
76 b.translate_axis (interbeam_f * i, Y_AXIS);
77 beams->add_molecule (b);
79 beams->translate_axis (-beams->extent ()[Y_AXIS].center (), Y_AXIS);
81 if (stem_l_)
83 if (stem_l_->beam_l_)
85 beams->translate (Offset(stem_l_->hpos_f () - hpos_f (),
86 stem_l_->stem_end_f () * internote_f -
87 stem_l_->beam_l_->dir_ * beams_i * interbeam_f));
89 else
92 Beams should intersect one beamthickness below staff end
94 Real dy = - beams->extent ()[Y_AXIS].length () / 2 * stem_l_->dir_;
97 uhg. Should use relative coords and placement
99 Real whole_note_correction = (stem_l_ && stem_l_->invisible_b( ))
100 ? -stem_l_->get_dir () * stem_l_->note_delta_f ()/2
101 : 0.0;
104 UGH. Internote fudging.
106 dy /= internote_f;
107 dy += stem_l_->stem_end_f ();
108 dy *= internote_f;
109 beams->translate (Offset(stem_l_->hpos_f () - hpos_f ()+
110 whole_note_correction, dy));
114 there used to be half a page of code that was long commented out.
115 Removed in 1.1.35
119 return beams;
122 void
123 Stem_tremolo::do_substitute_element_pointer (Score_element*o, Score_element*n)
125 if (stem_l_ == o)
126 stem_l_ = dynamic_cast<Stem*> (n);
130 void
131 Stem_tremolo::set_stem (Stem *s)
133 stem_l_ = s;
134 add_dependency (s);