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 Stem_info::Stem_info (Stem*s, int mult)
30 x_ = stem_l_->hpos_f ();
32 SCM bd = stem_l_->remove_elt_property (beam_dir_scm_sym);
33 beam_dir_ = gh_scm2int (SCM_CDR(bd));
36 Paper_def* paper_l = stem_l_->paper_l ();
37 Real internote_f = stem_l_->staff_line_leading_f ()/2;
38 Real interbeam_f = paper_l->interbeam_f (mult_i_);
39 Real beam_f = paper_l->beam_thickness_f ();
43 DOUT << "******" << i++ << "******\n"
44 << "begin_f: " << stem_l_->stem_begin_f () * dir_
45 << "\nchord_f/i: " << stem_l_->chord_start_f () * dir_ / internote_f << '\n';
48 // strangely enough, dim(chord_start_f) == pt (and not internote!)
49 idealy_f_ = stem_l_->chord_start_f () / internote_f;
51 // calculate using dim(y) == pt
52 idealy_f_ *= internote_f;
54 // for simplicity, we calculate as if dir == UP
55 idealy_f_ *= beam_dir_;
57 int stem_max = (int)rint(paper_l->get_var ("stem_max"));
58 Real min_stem_f = paper_l->get_var (String ("minimum_stem_length")
59 + to_str (mult_i_ <? stem_max));
60 Real stem_f = paper_l->get_var (String ("stem_length")
61 + to_str (mult_i_ <? stem_max));
63 if (!beam_dir_ || (beam_dir_ == dir_))
64 /* normal beamed stem */
69 idealy_f_ += (mult_i_ - 1) * interbeam_f;
75 miny_f_ += min_stem_f;
77 // lowest beam of (UP) beam must never be lower than second staffline
78 miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
79 + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
85 // idealy_f_ -= (mult_i_ - 1) * interbeam_f;
86 // idealy_f_ += (mult_i_ - stem_l_->flag_i_ >? 0) * interbeam_f;
91 maxy_f_ -= min_stem_f;
94 // set dim(y) == internote
95 idealy_f_ /= internote_f;
96 miny_f_ /= internote_f;
97 maxy_f_ /= internote_f;
99 DOUT << "dir_: " << dir_ << '\n';
100 DOUT << "mult_i_: " << mult_i_ << '\n';
101 DOUT << "idealy_f_: " << idealy_f_ << '\n';
102 DOUT << "miny_f_: " << miny_f_ << '\n';
103 DOUT << "maxy_f_: " << maxy_f_ << '\n';
105 idealy_f_ = maxy_f_ <? idealy_f_;
106 idealy_f_ = miny_f_ >? idealy_f_;
109 Beam* beam_l = stem_l_->beam_l_;
110 Dimension_cache *common = stem_l_->common_group (beam_l, Y_AXIS);
111 Align_element * align = dynamic_cast<Align_element*> (common->element_l ());
112 if (align && align->axis() == Y_AXIS)
114 if (align->threshold_interval_[MIN] !=
115 align->threshold_interval_[MAX])
116 warning (_ ("minVerticalAlign != maxVerticalAlign: interstaff beams/slurs may be broken"));
118 interstaff_f_ = align->threshold_interval_[MIN] / internote_f;
120 Dimension_cache * beam_refpoint = &beam_l->dim_cache_[Y_AXIS];
121 Dimension_cache * stem_refpoint = &stem_l_->dim_cache_[Y_AXIS];
123 while (beam_refpoint->parent_l_ != common)
124 beam_refpoint = beam_refpoint->parent_l_;
125 while (stem_refpoint->parent_l_ != common)
126 stem_refpoint = stem_refpoint->parent_l_;
130 align->get_priority (dynamic_cast<Score_element*> (beam_refpoint->element_l ()));
132 align->get_priority (dynamic_cast<Score_element*> (stem_refpoint->element_l ()));
135 our staff is lower -> interstaff_f_ *= -1
137 if (beam_prio < stem_prio)
140 idealy_f_ += interstaff_f_ * beam_dir_;
141 miny_f_ += interstaff_f_ * beam_dir_;
142 maxy_f_ += interstaff_f_ * beam_dir_;