2 stem-info.cc -- implement Stem_info
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "cross-staff.hh"
15 #include "paper-def.hh"
17 #include "stem-info.hh"
21 Stem_info::Stem_info ()
27 FIXME: y dims should not be in internote.
29 Stem_info::Stem_info (Stem*s, int mult)
33 x_ = stem_l_->hpos_f ();
35 SCM bd = stem_l_->remove_elt_property (beam_dir_scm_sym);
37 beam_dir_ = gh_scm2int (SCM_CDR(bd));
40 Paper_def* paper_l = stem_l_->paper_l ();
41 Real internote_f = stem_l_->staff_line_leading_f ()/2;
42 Real interbeam_f = paper_l->interbeam_f (mult_i_);
43 Real beam_f = paper_l->get_realvar (beam_thickness_scm_sym);;
46 // strangely enough, dim(chord_start_f) == pt (and not internote!)
47 idealy_f_ = stem_l_->chord_start_f () / internote_f;
49 // calculate using dim(y) == pt
50 idealy_f_ *= internote_f;
52 // for simplicity, we calculate as if dir == UP
53 idealy_f_ *= beam_dir_;
55 bool grace_b = stem_l_->get_elt_property (grace_scm_sym) != SCM_BOOL_F;
57 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
58 String type_str = grace_b ? "grace_" : "";
59 Real min_stem_f = paper_l->get_var (type_str + "minimum_stem_length"
60 + to_str (mult_i_ <? stem_max)) * internote_f;
61 Real stem_f = paper_l->get_var (type_str + "stem_length"
62 + to_str (mult_i_ <? stem_max))* internote_f;
64 if (!beam_dir_ || (beam_dir_ == dir_))
65 /* normal beamed stem */
70 idealy_f_ += (mult_i_ - 1) * interbeam_f;
76 miny_f_ += min_stem_f;
79 lowest beam of (UP) beam must never be lower than second staffline
81 Hmm, reference (Wanske?)
83 Although this (additional) rule is probably correct,
84 I expect that highest beam (UP) should also never be lower
85 than middle staffline, just as normal stems.
90 //highest beam of (UP) beam must never be lower than middle staffline
91 miny_f_ = miny_f_ >? 0;
92 //lowest beam of (UP) beam must never be lower than second staffline
93 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
94 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
105 maxy_f_ -= min_stem_f;
108 // set dim(y) == internote
109 idealy_f_ /= internote_f;
110 miny_f_ /= internote_f;
111 maxy_f_ /= internote_f;
113 idealy_f_ = maxy_f_ <? idealy_f_;
114 idealy_f_ = miny_f_ >? idealy_f_;
117 Beam* beam_l = stem_l_->beam_l_;
119 Real is = calc_interstaff_dist (stem_l_, beam_l);
120 idealy_f_ += is* beam_dir_;
121 miny_f_ += is * beam_dir_;
122 maxy_f_ += is * beam_dir_;