4 #include "paper-def.hh"
14 Stem::Stem(int c) //, Moment len)
18 minnote = 1000; // invalid values
30 Stem::do_print() const
33 mtor << "flag "<< flag << " print_flag " << print_flag
34 << "min,max [" << minnote << ", " << maxnote << "]";
38 Stem::set_stemend(Real se)
42 if (! ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)) )
43 warning("Weird stem size; check for narrow beams",0);
45 top = (dir < 0) ? maxnote : se;
46 bot = (dir < 0) ? se : minnote;
51 Stem::add(Notehead *n)
53 assert(status < PRECALCED);
63 n->add_dependency(this);
68 Stem::get_default_dir()
72 Real mean = (minnote+maxnote)/2;
73 return (mean > staff_center) ? -1: 1;
77 Stem::set_default_dir()
79 dir = get_default_dir();
83 Stem::set_default_stemlen()
88 int stafftop = 2*staff_center;
89 stemlen = STEMLEN + (maxnote - minnote);
91 // uhh... how about non 5-line staffs?
92 if (maxnote < -2 && dir == 1){
93 int t = staff_center - staff_center/2;
94 stemlen = t - minnote +2;
95 } else if (minnote > stafftop + 2 && dir == -1) {
96 int t = staff_center + staff_center/2;
97 stemlen = maxnote -t +2;
105 Stem::set_default_extents()
107 if (minnote > maxnote) {
108 warning("Empty stem. Ugh!", 0);
114 set_default_stemlen();
116 set_stemend((dir< 0) ? maxnote-stemlen: minnote +stemlen);
118 stem_xoffset = paper()->note_width()-paper()->rule_thickness();
124 Stem::set_noteheads()
128 heads.sort(Notehead::compare);
129 heads[0]->extremal = -1;
130 heads.top()->extremal = 1;
132 int lastpos = heads[0]->position;
133 for (int i=1; i < heads.size(); i ++) {
134 int dy =abs(lastpos- heads[i]->position);
138 heads[i]->x_dir = (stem_xoffset>0) ? 1:-1;
142 lastpos = heads[i]->position;
147 Stem::do_pre_processing()
150 set_default_extents();
158 if (!print_flag || abs(flag) <= 4)
159 return Interval(0,0); // TODO!
160 Paper_def*p= paper();
161 Interval r(p->lookup_l()->flag(flag).dim.x);
167 Stem::brew_molecule_p()const return out;
172 Paper_def *p =paper();
174 Real dy = p->internote();
175 Symbol ss =p->lookup_l()->stem(bot*dy,top*dy);
178 out = new Molecule(Atom(ss));
180 if (print_flag&&abs(flag) > 4){
181 Symbol fl = p->lookup_l()->flag(flag);
185 } else if (flag > 4) {
191 out->translate(Offset(stem_xoffset,0));
197 return pcol_l_->hpos + stem_xoffset; // hmm. + offset_.x;