lilypond-1.3.12
[lilypond.git] / lily / abbrev.cc
blobdd17851d1ee596e46ee3d7ef775ca901e4474a9c
1 /*
2 abbrev.cc -- implement Abbreviation
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "abbrev.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 Abbreviation::Abbreviation ()
20 stem_l_ = 0;
21 abbrev_flags_i_ = 1;
24 void
25 Abbreviation::do_print () const
27 DOUT << "abbrev_flags_i_ " << abbrev_flags_i_;
30 Molecule*
31 Abbreviation::do_brew_molecule_p () const
33 Beam * b = stem_l_->beam_l_;
34 int mult =0;
35 if (b)
37 Stem_info i = b->get_stem_info (stem_l_);
38 mult = i.mult_i_;
41 Real interbeam_f = paper_l ()->interbeam_f (mult);
42 Real w = 1.5 * lookup_l ()->notehead (2, "").dim_[X_AXIS].length ();
43 Real space = stem_l_->staff_line_leading_f ();
44 Real internote_f = space/2;
46 Real beam_f = paper_l ()->beam_thickness_f ();
48 int beams_i = 0;
49 Real slope_f = internote_f / 4 / internote_f; // HUH?
51 if (stem_l_ && stem_l_->beam_l_) {
52 slope_f = stem_l_->beam_l_->slope_f_;
53 // ugh, rather calc from Abbreviation_req
54 beams_i = stem_l_->beams_i_drul_[RIGHT] >? stem_l_->beams_i_drul_[LEFT];
56 Real sl = slope_f * internote_f;
58 Molecule a (lookup_l ()->beam (sl, w, beam_f));
59 a.translate (Offset (-w/2, w / 2 * slope_f));
61 Molecule *beams= new Molecule;
62 for (int i = 0; i < abbrev_flags_i_; i++)
64 Molecule b (a);
65 b.translate_axis (interbeam_f * i, Y_AXIS);
66 beams->add_molecule (b);
68 beams->translate_axis (-beams->extent ()[Y_AXIS].center (), Y_AXIS);
70 if (stem_l_)
72 if (stem_l_->beam_l_)
74 beams->translate (Offset(stem_l_->hpos_f () - hpos_f (),
75 stem_l_->stem_end_f () * internote_f -
76 stem_l_->beam_l_->dir_ * beams_i * interbeam_f));
78 else
81 Beams should intersect one beamthickness below staff end
83 Real dy = - beams->extent ()[Y_AXIS].length () / 2 * stem_l_->dir_;
84 dy /= internote_f;
85 dy += stem_l_->stem_end_f ();
86 dy *= internote_f;
87 // urg: can't: stem should be stetched first
88 // dy -= paper_l ()->beam_thickness_f () * stem_l_->dir_;
89 beams->translate (Offset(stem_l_->hpos_f () - hpos_f (), dy));
93 there used to be half a page of code that was long commented out.
94 Removed in 1.1.35
98 return beams;
101 void
102 Abbreviation::do_substitute_element_pointer (Score_element*o, Score_element*n)
104 if (stem_l_ == o)
105 stem_l_ = dynamic_cast<Stem*> (n);
109 void
110 Abbreviation::set_stem (Stem *s)
112 stem_l_ = s;
113 add_dependency (s);