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>
14 #include "align-element.hh"
16 #include "paper-def.hh"
18 #include "stem-info.hh"
20 #include "staff-symbol.hh"
22 Stem_info::Stem_info ()
26 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->beam_thickness_f ();
47 DOUT << "******" << i++ << "******\n"
48 << "begin_f: " << stem_l_->stem_begin_f () * dir_
49 << "\nchord_f/i: " << stem_l_->chord_start_f () * dir_ / internote_f << '\n';
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 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
62 Real min_stem_f = paper_l->get_var (String ("minimum_stem_length")
63 + to_str (mult_i_ <? stem_max));
64 Real stem_f = paper_l->get_var (String ("stem_length")
65 + to_str (mult_i_ <? stem_max));
67 if (!beam_dir_ || (beam_dir_ == dir_))
68 /* normal beamed stem */
73 idealy_f_ += (mult_i_ - 1) * interbeam_f;
79 miny_f_ += min_stem_f;
81 // lowest beam of (UP) beam must never be lower than second staffline
82 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
83 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
89 // idealy_f_ -= (mult_i_ - 1) * interbeam_f;
90 // idealy_f_ += (mult_i_ - stem_l_->flag_i_ >? 0) * interbeam_f;
95 maxy_f_ -= min_stem_f;
98 // set dim(y) == internote
99 idealy_f_ /= internote_f;
100 miny_f_ /= internote_f;
101 maxy_f_ /= internote_f;
103 DOUT << "dir_: " << dir_ << '\n';
104 DOUT << "mult_i_: " << mult_i_ << '\n';
105 DOUT << "idealy_f_: " << idealy_f_ << '\n';
106 DOUT << "miny_f_: " << miny_f_ << '\n';
107 DOUT << "maxy_f_: " << maxy_f_ << '\n';
109 idealy_f_ = maxy_f_ <? idealy_f_;
110 idealy_f_ = miny_f_ >? idealy_f_;
113 Beam* beam_l = stem_l_->beam_l_;
115 Dimension_cache *common = stem_l_->common_group (beam_l, Y_AXIS);
116 Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
117 if (align && align->axis() == Y_AXIS)
119 if (align->threshold_interval_[MIN] !=
120 align->threshold_interval_[MAX])
121 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
123 interstaff_f_ = align->threshold_interval_[MIN] / internote_f;
125 Dimension_cache * beam_refpoint = &beam_l->dim_cache_[Y_AXIS];
126 Dimension_cache * stem_refpoint = &stem_l_->dim_cache_[Y_AXIS];
128 while (beam_refpoint->parent_l_ != common)
129 beam_refpoint = beam_refpoint->parent_l_;
130 while (stem_refpoint->parent_l_ != common)
131 stem_refpoint = stem_refpoint->parent_l_;
135 align->get_priority (dynamic_cast<Score_element*> (beam_refpoint->element_l ()));
137 align->get_priority (dynamic_cast<Score_element*> (stem_refpoint->element_l ()));
140 our staff is lower -> interstaff_f_ *= -1
142 if (beam_prio < stem_prio)
145 idealy_f_ += interstaff_f_ * beam_dir_;
146 miny_f_ += interstaff_f_ * beam_dir_;
147 maxy_f_ += interstaff_f_ * beam_dir_;