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.
30 GURG UGRGINRG INA UG R
32 JUNKME -> This should be in Beam
34 Stem_info::Stem_info (Stem*s, int mult)
38 Beam* beam_l = stem_l_->beam_l_;
40 x_ = stem_l_->hpos_f ();
41 set_direction (stem_l_->get_direction ());
42 SCM bd = stem_l_->remove_elt_property ("beam-dir");
44 beam_dir_ = gh_scm2int (bd);
46 Paper_def* paper_l = stem_l_->paper_l ();
47 Real internote_f = stem_l_->staff_line_leading_f ()/2;
48 Real interbeam_f = paper_l->interbeam_f (mult_i_);
49 Real beam_f = gh_scm2double (beam_l->get_elt_property ("beam-thickness"));
52 // strangely enough, dim(chord_start_f) == pt (and not internote!)
53 idealy_f_ = stem_l_->chord_start_f () / internote_f;
55 // calculate using dim(y) == pt
56 idealy_f_ *= internote_f;
58 // for simplicity, we calculate as if dir == UP
59 idealy_f_ *= beam_dir_;
61 bool grace_b = stem_l_->get_elt_property ("grace") != SCM_UNDEFINED;
62 bool no_extend_b = stem_l_->get_elt_property ("no-stem-extend")
65 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
66 String type_str = grace_b ? "grace_" : "";
67 Real min_stem_f = paper_l->get_var (type_str + "minimum_stem_length"
68 + to_str (mult_i_ <? stem_max)) * internote_f;
69 Real stem_f = paper_l->get_var (type_str + "stem_length"
70 + to_str (mult_i_ <? stem_max))* internote_f;
72 if (!beam_dir_ || (beam_dir_ == get_direction ()))
73 /* normal beamed stem */
78 idealy_f_ += (mult_i_ - 1) * interbeam_f;
84 miny_f_ += min_stem_f;
87 lowest beam of (UP) beam must never be lower than second staffline
89 Hmm, reference (Wanske?)
91 Although this (additional) rule is probably correct,
92 I expect that highest beam (UP) should also never be lower
93 than middle staffline, just as normal stems.
96 if (!grace_b && !no_extend_b)
98 //highest beam of (UP) beam must never be lower than middle staffline
99 miny_f_ = miny_f_ >? 0;
100 //lowest beam of (UP) beam must never be lower than second staffline
101 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
102 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
113 maxy_f_ -= min_stem_f;
116 // set dim(y) == internote
117 idealy_f_ /= internote_f;
118 miny_f_ /= internote_f;
119 maxy_f_ /= internote_f;
121 idealy_f_ = maxy_f_ <? idealy_f_;
122 idealy_f_ = miny_f_ >? idealy_f_;
124 interstaff_f_ = calc_interstaff_dist (stem_l_, beam_l) / internote_f;
125 idealy_f_ += interstaff_f_* beam_dir_;
126 miny_f_ += interstaff_f_ * beam_dir_;
127 maxy_f_ += interstaff_f_ * beam_dir_;