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 ();
34 set_direction (stem_l_->get_direction ());
35 SCM bd = stem_l_->remove_elt_property ("beam-dir");
37 beam_dir_ = gh_scm2int (bd);
39 Paper_def* paper_l = stem_l_->paper_l ();
40 Real internote_f = stem_l_->staff_line_leading_f ()/2;
41 Real interbeam_f = paper_l->interbeam_f (mult_i_);
42 Real beam_f = paper_l->get_var ("beam_thickness");;
45 // strangely enough, dim(chord_start_f) == pt (and not internote!)
46 idealy_f_ = stem_l_->chord_start_f () / internote_f;
48 // calculate using dim(y) == pt
49 idealy_f_ *= internote_f;
51 // for simplicity, we calculate as if dir == UP
52 idealy_f_ *= beam_dir_;
54 bool grace_b = stem_l_->get_elt_property ("grace") != SCM_UNDEFINED;
55 bool no_extend_b = stem_l_->get_elt_property ("no-stem-extend")
58 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
59 String type_str = grace_b ? "grace_" : "";
60 Real min_stem_f = paper_l->get_var (type_str + "minimum_stem_length"
61 + to_str (mult_i_ <? stem_max)) * internote_f;
62 Real stem_f = paper_l->get_var (type_str + "stem_length"
63 + to_str (mult_i_ <? stem_max))* internote_f;
65 if (!beam_dir_ || (beam_dir_ == get_direction ()))
66 /* normal beamed stem */
71 idealy_f_ += (mult_i_ - 1) * interbeam_f;
77 miny_f_ += min_stem_f;
80 lowest beam of (UP) beam must never be lower than second staffline
82 Hmm, reference (Wanske?)
84 Although this (additional) rule is probably correct,
85 I expect that highest beam (UP) should also never be lower
86 than middle staffline, just as normal stems.
89 if (!grace_b && !no_extend_b)
91 //highest beam of (UP) beam must never be lower than middle staffline
92 miny_f_ = miny_f_ >? 0;
93 //lowest beam of (UP) beam must never be lower than second staffline
94 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
95 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
106 maxy_f_ -= min_stem_f;
109 // set dim(y) == internote
110 idealy_f_ /= internote_f;
111 miny_f_ /= internote_f;
112 maxy_f_ /= internote_f;
114 idealy_f_ = maxy_f_ <? idealy_f_;
115 idealy_f_ = miny_f_ >? idealy_f_;
118 Beam* beam_l = stem_l_->beam_l_;
120 interstaff_f_ = calc_interstaff_dist (stem_l_, beam_l) / internote_f;
121 idealy_f_ += interstaff_f_* beam_dir_;
122 miny_f_ += interstaff_f_ * beam_dir_;
123 maxy_f_ += interstaff_f_ * beam_dir_;