1 // utility functions for PScore
8 #include "scoreline.hh"
16 for (PCursor<PCol *> c(cols); c.ok(); )
25 PScore::add(PStaff *s)
27 assert(s->pscore_ == this);
28 staffs.bottom().add(s);
32 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
35 // assert(!breakstat != 4 || c->breakable() );
37 typeset_item(i, c->prebreak, s);
42 typeset_item(i, c->postbreak, s);
51 /* first do this, because i->width() may follow the 0-pointer */
55 if (0 && c->daddy && c == c->daddy->prebreak) { // makeshift.
57 Interval iv (i->width());
59 svec<Item*> col_its (select_items(s, c));
60 for (int j =0; j < col_its.sz(); j++)
61 col_its[j]->translate(Offset(-iv.length(),0));
62 i->translate (Offset(-iv.max, 0));
69 PScore::typeset_spanner(Spanner*sp, PStaff*ps)
73 spanners.bottom().add(sp);
74 ps->spans.bottom().add(sp);
75 // do not init start/stop fields. These are for broken spans only.
80 PScore::add_line(svec<const PCol *> curline, svec<Real> config)
82 Line_of_score *p = new Line_of_score(curline,this);
83 lines.bottom().add(p);
84 for (int i=0; i < curline.sz(); i++){
85 PCol *c=(PCol *)curline[i]; // so, this isn't really const.
91 PScore::get_spacing(PCol*l, PCol*r)
94 for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
95 if (ic->left == l && ic->right == r){
100 Idealspacing*ip =new Idealspacing(l,r);
101 suz.bottom().add(ip);
108 PScore::compare_pcols(const PCol*a, const PCol*b)const
110 PCursor<PCol*> ac(find_col(a));
111 PCursor<PCol*> bc(find_col(b));
112 assert(ac.ok() && bc.ok());
117 return all breakable columns
120 PScore::find_breaks() const
122 svec<const PCol *> retval;
123 for (PCursor<PCol *> c(cols); c.ok(); c++)
135 p->prebreak->pscore_ = this;
136 p->postbreak->pscore_ = this;
138 cols.bottom().add(p);
141 PScore::PScore( Paperdef*p)
147 PScore::output(Tex_stream &ts)
151 ts << "\n "<< paper_->lookup_->texsetting << "%(Tex id)\n";
152 for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
153 ts << "% line of score no. " << l++ <<"\n";
154 ts << lic->TeXstring();
156 ts << "\\interscoreline\n";
162 PScore::select_items(PStaff*ps , PCol*pc)
166 for (PCursor<const Item*> ic(pc->its); ic.ok(); ic++){
167 if (ic->pstaff_ == ps)
168 ret.add((Item*)(const Item*)ic);
177 for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
179 for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
185 PScore::print() const
190 mtor << "\ncolumns: ";
191 for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
194 mtor << "\nideals: ";
195 for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
207 PScore::postprocess()
209 for (PCursor<Spanner*> ic(broken_spans); ic.ok(); ic++) {
212 for (PCursor<Item*> ic(its); ic.ok(); ic++){
215 for (PCursor<Line_of_score*> i(lines); i.ok(); i++)
220 PScore::find_col(const PCol *c)const
222 PCol*what = (PCol*)c;
224 what = what -> daddy;
226 return cols.find(what);
230 PScore::add_broken(Spanner*s)
232 broken_spans.bottom().add(s);
233 s->left->starters.bottom().add (s);
234 s->right->stoppers.bottom().add (s);