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>
13 #include "dimension-cache.hh"
15 #include "align-element.hh"
17 #include "paper-def.hh"
19 #include "stem-info.hh"
21 #include "staff-symbol.hh"
23 Stem_info::Stem_info ()
27 FIXME: y dims should not be in internote.
30 Stem_info::Stem_info (Stem*s, int mult)
34 x_ = stem_l_->hpos_f ();
36 SCM bd = stem_l_->remove_elt_property (beam_dir_scm_sym);
38 beam_dir_ = gh_scm2int (SCM_CDR(bd));
41 Paper_def* paper_l = stem_l_->paper_l ();
42 Real internote_f = stem_l_->staff_line_leading_f ()/2;
43 Real interbeam_f = paper_l->interbeam_f (mult_i_);
44 Real beam_f = paper_l->beam_thickness_f ();
48 DOUT << "******" << i++ << "******\n"
49 << "begin_f: " << stem_l_->stem_begin_f () * dir_
50 << "\nchord_f/i: " << stem_l_->chord_start_f () * dir_ / internote_f << '\n';
53 // strangely enough, dim(chord_start_f) == pt (and not internote!)
54 idealy_f_ = stem_l_->chord_start_f () / internote_f;
56 // calculate using dim(y) == pt
57 idealy_f_ *= internote_f;
59 // for simplicity, we calculate as if dir == UP
60 idealy_f_ *= beam_dir_;
62 bool grace_b = stem_l_->get_elt_property (grace_scm_sym) != SCM_BOOL_F;
64 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
65 String type_str = grace_b ? "grace_" : "";
66 Real min_stem_f = paper_l->get_var (type_str + "minimum_stem_length"
67 + to_str (mult_i_ <? stem_max)) * internote_f;
68 Real stem_f = paper_l->get_var (type_str + "stem_length"
69 + to_str (mult_i_ <? stem_max))* internote_f;
71 if (!beam_dir_ || (beam_dir_ == dir_))
72 /* normal beamed stem */
77 idealy_f_ += (mult_i_ - 1) * interbeam_f;
83 miny_f_ += min_stem_f;
86 lowest beam of (UP) beam must never be lower than second staffline
88 Hmm, reference (Wanske?)
90 Although this (additional) rule is probably correct,
91 I expect that highest beam (UP) should also never be lower
92 than middle staffline, just as normal stems.
97 //highest beam of (UP) beam must never be lower than middle staffline
98 miny_f_ = miny_f_ >? 0;
99 //lowest beam of (UP) beam must never be lower than second staffline
100 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
101 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
108 // idealy_f_ -= (mult_i_ - 1) * interbeam_f;
109 // idealy_f_ += (mult_i_ - stem_l_->flag_i_ >? 0) * interbeam_f;
114 maxy_f_ -= min_stem_f;
117 // set dim(y) == internote
118 idealy_f_ /= internote_f;
119 miny_f_ /= internote_f;
120 maxy_f_ /= internote_f;
122 DOUT << "dir_: " << dir_ << '\n';
123 DOUT << "mult_i_: " << mult_i_ << '\n';
124 DOUT << "idealy_f_: " << idealy_f_ << '\n';
125 DOUT << "miny_f_: " << miny_f_ << '\n';
126 DOUT << "maxy_f_: " << maxy_f_ << '\n';
128 idealy_f_ = maxy_f_ <? idealy_f_;
129 idealy_f_ = miny_f_ >? idealy_f_;
132 Beam* beam_l = stem_l_->beam_l_;
134 Graphical_element *common = stem_l_->common_refpoint (beam_l, Y_AXIS);
135 Align_element * align = dynamic_cast<Align_element*> (common);
136 if (align && align->axis() == Y_AXIS)
138 if (align->threshold_interval_[MIN] !=
139 align->threshold_interval_[MAX])
140 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
142 interstaff_f_ = align->threshold_interval_[MIN] / internote_f;
144 Graphical_element * beam_refpoint = beam_l;
145 Graphical_element * stem_refpoint = stem_l_;
147 while (beam_refpoint->parent_l (Y_AXIS) != common)
148 beam_refpoint = beam_refpoint->parent_l (Y_AXIS);
149 while (stem_refpoint->parent_l (Y_AXIS) != common)
150 stem_refpoint = stem_refpoint->parent_l (Y_AXIS);
154 align->get_priority (dynamic_cast<Score_element*> (beam_refpoint));
156 align->get_priority (dynamic_cast<Score_element*> (stem_refpoint));
159 our staff is lower -> interstaff_f_ *= -1
161 if (beam_prio < stem_prio)
164 idealy_f_ += interstaff_f_ * beam_dir_;
165 miny_f_ += interstaff_f_ * beam_dir_;
166 maxy_f_ += interstaff_f_ * beam_dir_;