4 #include "paper-def.hh"
5 #include "note-head.hh"
14 Stem::min_head_i()const
17 for (int i =0; i < head_l_arr_.size(); i++)
18 m = m <? head_l_arr_[i]->position_i_;
23 Stem::max_head_i() const
26 for (int i =0; i < head_l_arr_.size(); i++)
27 m = m >? head_l_arr_[i]->position_i_;
37 stem_bottom_f_ = stem_top_f_ = 0;
47 IMPLEMENT_STATIC_NAME(Stem);
50 Stem::do_print() const
53 mtor << "flag "<< flag_i_ << " print_flag_b_ " << print_flag_b_;
59 Stem::stem_length_f()const
61 return stem_top_f_-stem_bottom_f_ ;
65 Stem::stem_start_f()const
67 return (dir_i_ < 0)? stem_top_f_ : stem_bottom_f_;
71 Stem::stem_end_f() const
73 return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_;
78 Stem::set_stemend(Real se)
81 if (! ((dir_i_ > 0 && se >= max_head_i()) ||
82 (se <= min_head_i() && dir_i_ <0)) )
83 warning("Weird stem size; check for narrow beams");
85 stem_top_f_ = (dir_i_ < 0) ? max_head_i() : se;
86 stem_bottom_f_ = (dir_i_ < 0) ? se : min_head_i();
90 Stem::add(Note_head *n)
92 n->add_dependency(this);
95 } else if (n->balltype_i_ == 1) {
104 Stem::invisible_b()const
106 return !head_l_arr_.size();
109 Stem::chord_b() const
111 return head_l_arr_.size() > 1;
114 // if dir_i_ is set we return a fake value.
116 Stem::get_center_distance()
121 int staff_center = staff_size_i_ / 2;
122 int min = min_head_i() - staff_center;
123 int max = max_head_i() - staff_center;
124 return (abs(max) > abs(min)) ? max : min;
128 Stem::get_default_dir()
132 return -sign(get_center_distance());
137 Stem::set_default_dir()
139 dir_i_ = get_default_dir();
143 Stem::set_default_stemlen()
149 // ugh... how about non 5-line staffs?
150 if ((max_head_i() < -2 && dir_i_ == 1 )
151 ||(min_head_i() > staff_size_i_ && dir_i_ == -1) ){
152 set_stemend( staff_size_i_ /2 -1 );
154 set_stemend( (dir_i_ > 0) ? max_head_i() + STEMLEN :
155 min_head_i() - STEMLEN);
162 Stem::set_default_extents()
164 if (!stem_length_f())
165 set_default_stemlen();
167 set_stemend((dir_i_< 0) ?
168 max_head_i()-stem_length_f(): min_head_i() +stem_length_f());
170 stem_xoffset_f_ = paper()->note_width()-paper()->rule_thickness();
178 move into note_column.cc
182 Stem::set_noteheads()
184 if(!head_l_arr_.size())
186 head_l_arr_.sort(Note_head::compare);
188 head_l_arr_.reverse();
190 head_l_arr_[0]->extremal_i_ = -1;
191 head_l_arr_.top()->extremal_i_ = 1;
193 int lastpos = head_l_arr_[0]->position_i_;
194 for (int i=1; i < head_l_arr_.size(); i ++) {
195 int dy =abs(lastpos- head_l_arr_[i]->position_i_);
199 head_l_arr_[i]->x_dir_i_ = (stem_xoffset_f_>0) ? 1:-1;
203 lastpos = head_l_arr_[i]->position_i_;
208 Stem::do_pre_processing()
210 if (stem_bottom_f_== stem_top_f_)
211 set_default_extents();
213 flag_i_ = dir_i_*abs(flag_i_);
218 Stem::do_width()const
220 if (!print_flag_b_ || abs(flag_i_) <= 4)
221 return Interval(0,0); // TODO!
222 Paper_def*p= paper();
223 Interval r(p->lookup_l()->flag(flag_i_).dim.x);
229 Stem::brew_molecule_p()const
233 return Score_elem::brew_molecule_p();
235 Real bot = stem_bottom_f_;
236 Real top = stem_top_f_;
240 Paper_def *p =paper();
242 Real dy = p->internote_f();
243 Symbol ss =p->lookup_l()->stem(bot*dy,top*dy);
245 out = new Molecule(Atom(ss));
247 if (print_flag_b_&&abs(flag_i_) > 4){
248 Symbol fl = p->lookup_l()->flag(flag_i_);
252 } else if (flag_i_ > 4) {
258 out->translate(Offset(stem_xoffset_f_,0));
265 return Item::hpos_f() + stem_xoffset_f_;
270 Stem::do_substitute_dependency(Score_elem*o,Score_elem*n)
272 Item * o_l = o->item();
273 Item * n_l = n? n->item():0;
274 whole_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
275 head_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
276 rest_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);