-// utility functions for PScore
+#include "idealspacing.hh"
#include "debug.hh"
#include "lookup.hh"
#include "spanner.hh"
#include "scoreline.hh"
#include "pscore.hh"
#include "tstream.hh"
+#include "item.hh"
+
+
+Idealspacing*
+PScore::get_spacing(PCol*l, PCol*r)
+{
+ assert(l!=r);
+ for (iter_top(suz,ic); ic.ok(); ic++) {
+ if (ic->left == l && ic->right == r){
+ return ic;
+ }
+ }
+
+ Idealspacing*ip =new Idealspacing(l,r);
+ suz.bottom().add(ip);
+
+ return ip;
+}
void
PScore::clean_cols()
{
- for (PCursor<PCol *> c(cols); c.ok(); )
+ for (iter_top(cols,c); c.ok(); )
if (!c->used()) {
c.del();
} else
c->add(i);
/* first do this, because i->width() may follow the 0-pointer */
- i->preprocess();
-
-
- if (0 && c->daddy && c == c->daddy->prebreak) { // makeshift.
-
- Interval iv (i->width());
- if (!iv.empty()) {
- svec<Item*> col_its (select_items(s, c));
- for (int j =0; j < col_its.sz(); j++)
- col_its[j]->translate(Offset(-iv.length(),0));
- i->translate (Offset(-iv.max, 0));
- }
- }
-
-}
-
-void
-PScore::typeset_spanner(Spanner*sp, PStaff*ps)
-{
- sp->preprocess();
- sp->pstaff_ = ps;
- spanners.bottom().add(sp);
- ps->spans.bottom().add(sp);
- // do not init start/stop fields. These are for broken spans only.
+ i->add_processing();
}
-
void
-PScore::add_line(svec< PCol *> curline, svec<Real> config)
-{
- Line_of_score *p = new Line_of_score(curline,this);
- lines.bottom().add(p);
- for (int i=0; i < curline.sz(); i++){
- PCol *c=(PCol *)curline[i]; // so, this isn't really const.
- c->hpos = config[i];
- }
-}
-
-Idealspacing*
-PScore::get_spacing(PCol*l, PCol*r)
+PScore::typeset_spanner(Spanner*span_p, PStaff*ps)
{
- assert(l!=r);
- for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
- if (ic->left == l && ic->right == r){
- return ic;
- }
- }
-
- Idealspacing*ip =new Idealspacing(l,r);
- suz.bottom().add(ip);
+ span_p->pstaff_ = ps;
+ spanners.bottom().add(span_p);
+ ps->spans.bottom().add(span_p);
- return ip;
+ // do not init start/stop fields. These are for broken spans only.
+ span_p->add_processing();
}
return ac - bc;
}
-/*
- return all breakable columns
- */
-svec< PCol *>
-PScore::find_breaks() const
-{
- svec< PCol *> retval;
- for (PCursor<PCol *> c(cols); c.ok(); c++)
- if (c->breakable())
- retval.add(c);
-
- return retval;
-}
-
void
PScore::add(PCol *p)
{
int l=1;
ts << "\n "<< paper_->lookup_->texsetting << "%(Tex id)\n";
- for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
+ for (iter_top(lines,lic); lic.ok(); lic++) {
ts << "% line of score no. " << l++ <<"\n";
ts << lic->TeXstring();
if ((lic+1).ok())
{
svec<Item*> ret;
assert(ps && pc);
- for (PCursor<const Item*> ic(pc->its); ic.ok(); ic++){
- if (ic->pstaff_ == ps)
- ret.add((Item*)(const Item*)ic);
+ for (iter_top(pc->its,i); i.ok(); i++){
+ if (i->pstaff_ == ps)
+ ret.add((Item*)(const Item*)i);
}
return ret;
}
PScore::OK()const
{
#ifdef NDEBUG
- for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
+ for (iter_top(cols,cc); cc.ok(); cc++)
cc->OK();
- for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
- ic->OK();
+ for (iter_top(suz,i); i.ok(); i++)
+ i->OK();
#endif
}
mtor << "PScore { ";
paper_->print();
mtor << "\ncolumns: ";
- for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
+ for (iter_top(cols,cc); cc.ok(); cc++)
cc->print();
mtor << "\nideals: ";
- for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
- ic->print();
+ for (iter_top(suz,i); i.ok(); i++)
+ i->print();
mtor << "}\n";
#endif
}
void
PScore::preprocess()
{
+ for (iter_top(spanners,i); i.ok(); i++) {
+ i->pre_processing();
+ }
+ for (iter_top(its,i); i.ok(); i++){
+ i->pre_processing();
+ }
}
void
PScore::postprocess()
{
- for (PCursor<Spanner*> ic(broken_spans); ic.ok(); ic++) {
- ic->process();
+ for (iter_top(broken_spans,i); i.ok(); i++) { // could chase spans as well.
+ i->post_processing();
}
- for (PCursor<Item*> ic(its); ic.ok(); ic++){
- ic->postprocess();
+ for (iter_top(its,i); i.ok(); i++){
+ i->post_processing();
}
- for (PCursor<Line_of_score*> i(lines); i.ok(); i++)
+
+ for (iter_top(broken_spans,i); i.ok(); i++) {
+ i->molecule_processing();
+ }
+ for (iter_top(its,i); i.ok(); i++){
+ i->molecule_processing();
+ }
+
+ for (iter_top(lines,i); i.ok(); i++)
i->process();
+
}
PCursor<PCol *>
void
PScore::add_broken(Spanner*s)
{
+ assert(s->left->line == s->right->line);
broken_spans.bottom().add(s);
s->left->starters.bottom().add (s);
s->right->stoppers.bottom().add (s);
}
+
+void
+PScore::set_breaking(svec<Col_configuration> breaking)
+{
+ for (int j=0; j < breaking.sz(); j++) {
+ svec<PCol*> &curline(breaking[j].cols);
+ svec<Real> &config(breaking[j].config);
+
+ Line_of_score *p = new Line_of_score(curline,this);
+ lines.bottom().add(p);
+ for (int i=0; i < curline.sz(); i++){
+ curline[i]->hpos = config[i];
+ }
+ }
+}
+
+void
+PScore::calc_breaking()
+{
+ Word_wrap w(*this);
+ set_breaking(w.solve());
+}