2 note-column.cc -- implement Note_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "dot-column.hh"
9 #include "note-column.hh"
11 #include "note-head.hh"
15 #include "paper-def.hh"
18 Note_column::rest_b () const
20 return rest_l_arr_.size ();
23 Note_column::Note_column()
25 set_axes (X_AXIS,X_AXIS);
32 head_l_arr_.sort (Note_head::compare);
36 Note_column::head_positions_interval() const
38 ((Note_column*)this)->sort();
43 if (head_l_arr_.size ())
44 iv = Interval_t<int>(head_l_arr_[0]->position_i_,
45 head_l_arr_.top()->position_i_);
51 Note_column::dir () const
55 else if (head_l_arr_.size ())
56 return sign (head_positions_interval().center ());
64 Note_column::set_stem (Stem * stem_l)
67 add_dependency (stem_l);
73 Note_column::do_substitute_element_pointer (Score_element*o, Score_element*n)
77 stem_l_ = n ? dynamic_cast<Stem *> (n):0;
79 if (dynamic_cast<Note_head *> (o))
81 head_l_arr_.substitute (dynamic_cast<Note_head *> (o),
82 (n)? dynamic_cast<Note_head *> (n) : 0);
85 if (dynamic_cast<Rest *> (o))
87 rest_l_arr_.substitute (dynamic_cast<Rest *> (o),
88 (n)? dynamic_cast<Rest *> (n) : 0);
93 Note_column::add_head (Rhythmic_head *h)
95 if (Rest*r=dynamic_cast<Rest *> (h))
99 if (Note_head *nh=dynamic_cast<Note_head *> (h))
101 head_l_arr_.push (nh);
107 translate the rest symbols
110 Note_column::translate_rests (int dy_i)
112 invalidate_cache (Y_AXIS);
113 for (int i=0; i < rest_l_arr_.size(); i++)
114 rest_l_arr_[i]->position_i_ += dy_i;
118 Note_column::do_print() const
121 DOUT << "rests: " << rest_l_arr_.size() << ", ";
122 DOUT << "heads: " << head_l_arr_.size();
127 Note_column::set_dotcol (Dot_column *d)
134 handle rest under beam (do_post: beams are calculated now)
135 what about combination of collisions and rest under beam.
139 rest -> stem -> beam -> interpolate_y_position ()
144 Note_column::do_post_processing ()
146 if (!stem_l_ || !rest_b ())
149 Beam * b = stem_l_->beam_l_;
153 /* ugh. Should be done by beam. */
154 Real x = stem_l_->hpos_f ();
155 Direction d = stem_l_->get_dir ();
156 Real beamy = x * b->slope_f_ + b->left_y_;
157 Interval restdim = extent (Y_AXIS);
159 Real staff_space = rest_l_arr_[0]->staff_line_leading_f ();
160 Real internote_f = staff_space/2;
162 = paper_l ()->get_var ("restcollision_minimum_beamdist") * internote_f;
164 minimum_dist + -d * (beamy - restdim[d]) >? 0;
166 int stafflines = rest_l_arr_[0]->lines_i ();
168 // move discretely by half spaces.
169 int discrete_dist = int (ceil (dist / (0.5 *staff_space)));
171 // move by whole spaces inside the staff.
172 if (discrete_dist < stafflines+1)
173 discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
175 translate_rests (-d * discrete_dist);