4 #include "paper-def.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_;
77 Stem::set_stemend(Real se)
80 if (! ((dir_i_ > 0 && se >= max_head_i()) ||
81 (se <= min_head_i() && dir_i_ <0)) )
82 warning("Weird stem size; check for narrow beams");
84 stem_top_f_ = (dir_i_ < 0) ? max_head_i() : se;
85 stem_bottom_f_ = (dir_i_ < 0) ? se : min_head_i();
89 Stem::add(Notehead *n)
91 n->add_dependency(this);
94 } else if (n->balltype_i_ == 1) {
103 Stem::invisible_b()const
105 return !head_l_arr_.size();
109 Stem::get_default_dir()
111 int staff_center = staff_size_i_ /2;
114 Real mean = (min_head_i() + max_head_i())/2;
115 return (mean > staff_center) ? -1: 1;
119 Stem::set_default_dir()
121 dir_i_ = get_default_dir();
125 Stem::set_default_stemlen()
131 // ugh... how about non 5-line staffs?
132 if ((max_head_i() < -2 && dir_i_ == 1 )
133 ||(min_head_i() > staff_size_i_ && dir_i_ == -1) ){
134 set_stemend( staff_size_i_ /2 );
136 set_stemend( (dir_i_ > 0) ? max_head_i() + STEMLEN :
137 min_head_i() - STEMLEN);
144 Stem::set_default_extents()
146 if (!stem_length_f())
147 set_default_stemlen();
149 set_stemend((dir_i_< 0) ?
150 max_head_i()-stem_length_f(): min_head_i() +stem_length_f());
152 stem_xoffset_f_ = paper()->note_width()-paper()->rule_thickness();
158 Stem::set_noteheads()
160 if(!head_l_arr_.size())
162 head_l_arr_.sort(Notehead::compare);
163 head_l_arr_[0]->extremal_i_ = -1;
164 head_l_arr_.top()->extremal_i_ = 1;
166 int lastpos = head_l_arr_[0]->position_i_;
167 for (int i=1; i < head_l_arr_.size(); i ++) {
168 int dy =abs(lastpos- head_l_arr_[i]->position_i_);
172 head_l_arr_[i]->x_dir_i_ = (stem_xoffset_f_>0) ? 1:-1;
176 lastpos = head_l_arr_[i]->position_i_;
181 Stem::do_pre_processing()
183 if (stem_bottom_f_== stem_top_f_)
184 set_default_extents();
186 flag_i_ = dir_i_*abs(flag_i_);
191 Stem::do_width()const
193 if (!print_flag_b_ || abs(flag_i_) <= 4)
194 return Interval(0,0); // TODO!
195 Paper_def*p= paper();
196 Interval r(p->lookup_l()->flag(flag_i_).dim.x);
202 Stem::brew_molecule_p()const
205 if (invisible_b() && ! rest_l_arr_.size())
206 warning("Empty stem. Ugh!");
209 return Staff_elem::brew_molecule_p();
211 Real bot = stem_bottom_f_;
212 Real top = stem_top_f_;
216 Paper_def *p =paper();
218 Real dy = p->internote();
219 Symbol ss =p->lookup_l()->stem(bot*dy,top*dy);
221 out = new Molecule(Atom(ss));
223 if (print_flag_b_&&abs(flag_i_) > 4){
224 Symbol fl = p->lookup_l()->flag(flag_i_);
228 } else if (flag_i_ > 4) {
234 out->translate(Offset(stem_xoffset_f_,0));
241 return Item::hpos_f() + stem_xoffset_f_;