1 // utility functions for PScore
7 #include "scoreline.hh"
15 for (PCursor<PCol *> c(cols); c.ok(); )
24 PScore::add(PStaff *s)
26 assert(s->pscore_ == this);
27 staffs.bottom().add(s);
31 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
34 // assert(!breakstat != 4 || c->breakable() );
36 typeset_item(i, c->prebreak, s);
41 typeset_item(i, c->postbreak, s);
50 /* first do this, because i->width() may follow the 0-pointer */
54 if (0 && c->daddy && c == c->daddy->prebreak) { // makeshift.
56 Interval iv (i->width());
58 svec<Item*> col_its (select_items(s, c));
59 for (int j =0; j < col_its.sz(); j++)
60 col_its[j]->translate(Offset(-iv.length(),0));
61 i->translate (Offset(-iv.max, 0));
68 PScore::typeset_spanner(Spanner*sp, PStaff*ps)
72 spanners.bottom().add(sp);
73 ps->spans.bottom().add(sp);
74 // do not init start/stop fields. These are for broken spans only.
79 PScore::add_line(svec<const PCol *> curline, svec<Real> config)
81 Line_of_score *p = new Line_of_score(curline,this);
82 lines.bottom().add(p);
83 for (int i=0; i < curline.sz(); i++){
84 PCol *c=(PCol *)curline[i]; // so, this isn't really const.
90 PScore::get_spacing(PCol*l, PCol*r)
93 for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
94 if (ic->left == l && ic->right == r){
99 Idealspacing*ip =new Idealspacing(l,r);
100 suz.bottom().add(ip);
107 PScore::compare_pcols(const PCol*a, const PCol*b)const
109 PCursor<PCol*> ac(find_col(a));
110 PCursor<PCol*> bc(find_col(b));
111 assert(ac.ok() && bc.ok());
116 return all breakable columns
119 PScore::find_breaks() const
121 svec<const PCol *> retval;
122 for (PCursor<PCol *> c(cols); c.ok(); c++)
134 p->prebreak->pscore_ = this;
135 p->postbreak->pscore_ = this;
137 cols.bottom().add(p);
140 PScore::PScore( Paperdef*p)
146 PScore::output(Tex_stream &ts)
150 for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
151 ts << "% line of score no. " << l++ <<"\n";
152 ts << lic->TeXstring();
154 ts << "\\interscoreline\n";
160 PScore::select_items(PStaff*ps , PCol*pc)
164 for (PCursor<const Item*> ic(pc->its); ic.ok(); ic++){
165 if (ic->pstaff_ == ps)
166 ret.add((Item*)(const Item*)ic);
175 for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
177 for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
183 PScore::print() const
188 mtor << "\ncolumns: ";
189 for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
192 mtor << "\nideals: ";
193 for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
203 for (PCursor<Item*> ic(its); ic.ok(); ic++){
210 PScore::postprocess()
212 for (PCursor<Spanner*> ic(broken_spans); ic.ok(); ic++) {
215 for (PCursor<Item*> ic(its); ic.ok(); ic++){
221 PScore::find_col(const PCol *c)const
223 PCursor<PCol*> cc(cols);
224 for (; cc.ok(); cc++)
225 if (cc.ptr() == c || cc->prebreak == c || cc->postbreak == c)
231 PScore::add_broken(Spanner*s)
233 broken_spans.bottom().add(s);
234 s->left->starters.bottom().add (s);
235 s->right->stoppers.bottom().add (s);