void
Score::connect(PCol* c1, PCol *c2, Real d, Real h)
{
- if (c2->used() && c1->used()) {
- do_connect(c1,c2,d,h);
- do_connect(c1->postbreak, c2,d,h);
- do_connect(c1, c2->prebreak,d,h);
- do_connect(c1->postbreak, c2->prebreak,d,h);
- }
+ do_connect(c1,c2,d,h);
+ do_connect(c1->postbreak, c2,d,h);
+ do_connect(c1, c2->prebreak,d,h);
+ do_connect(c1->postbreak, c2->prebreak,d,h);
}
/* this needs A LOT of rethinking.
void
Score::calc_idealspacing()
{
+#if 1
PCursor<Score_column*> i(cols_);
for (; i.ok(); i++) {
-
+ assert(i->used());
PCursor<Score_column*> j (i+1);
if (i->musical) {
for (int n=0; n < i->durations.sz(); n++) {
Real d = i->durations[n];
Real dist = paper_->duration_to_dist(d);
- while (d + i->when > j->when)
+ while (j->when < d + i->when)
j++;
+
+ assert(j->when == d+i->when);
- if (j->used())
- connect(i->pcol_, j->pcol_, dist);
- if (!j->musical && (j+1)->used && (j+1)->when == j->when) {
+ connect(i->pcol_, j->pcol_, dist);
+ if (!j->musical && (j+1).ok()
+ && (j+1)->when == j->when) {
j++;
connect(i->pcol_, j->pcol_, dist);
}
}
- } else if (i->used()) {
-
+ } else if (j.ok()) {
+
/* attach i to the next column in use. This exists, since
the last col is breakable, and therefore in use
*/
- for (;j.ok(); j++) {
- if (j->used()) {
- Real d = j->when - i->when;
- Real dist = (d) ? paper_->duration_to_dist(d) :
- convert_dimen(2,"pt");
+
+ Real d = j->when - i->when;
+ Real dist = (d) ? paper_->duration_to_dist(d) :
+ convert_dimen(2,"pt");
+
+ connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
+ }
+ // !j.ok() might hold if we're at the last col.
+
+ }
+#else
+ PCursor<Score_column*> sc(cols_);
- connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
- break;
- }
+ for (; sc.ok(); sc++) {
+ if (sc->musical)
+ for (int i=0; i < sc->durations.sz(); i++) {
+ Real d = sc->durations[i];
+ Real dist = paper_->duration_to_dist(d);
+ PCol * c2 = find_col(sc->when + d,true)->pcol_;
+ connect(sc->pcol_, c2, dist);
+ c2 = find_col(sc->when + d,false)->pcol_;
+ connect(sc->pcol_, c2, dist);
}
- // !j.ok() might hold if we're at the last col.
+ else if (sc->used()) { // ignore empty columns
+ PCol * c2 = find_col(sc->when,true)->pcol_;
+ connect(sc->pcol_, c2, 0.0);
}
- }
+#endif
}
-#include "staffcommands.hh"
#include "tstream.hh"
-#include "getcommand.hh"
-#include "inputcommands.hh"
#include "score.hh"
#include "sccol.hh"
#include "pscore.hh"
#include "debug.hh"
#include "paper.hh"
+
void
Score::process()
{
paper_ = new Paperdef;
/// distribute commands to disciples
- distribute_commands();
-
pscore_ = new PScore(paper_);
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->set_output(pscore_);
- sc->process();
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->process_commands(last());
+ i->set_output(pscore_);
+ i->process();
}
// do this after processing, staffs first have to generate PCols.
do_pcols();
+ // ugh. Would want to clean the columns before anything else.
+ clean_cols();
calc_idealspacing();
- clean_cols(); // ugh. Would want to clean the columns before anything else.
-
+ // debugging
+ print ();
OK();
pscore_->preprocess();
void
Score::clean_cols()
{
- for (PCursor<Staff * > sc(staffs_); sc.ok(); sc++)
- sc->clean_cols();
+ for (PCursor<Staff * > i(staffs_); i.ok(); i++)
+ i->clean_cols();
for (PCursor<Score_column*> c(cols_); c.ok(); ) {
if (!c->pcol_->used()) {
- mtor << "removing : ";
- c->print();
c.del();
- } else
+ } else {
+ c->preprocess();
c++;
+ }
}
pscore_->clean_cols();
return scc;
}
-void
-Score::distribute_commands()
-{
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->process_input_commands(input_commands_, last());
- }
-}
-void
-Score::add(Staff*s)
-{
- s->score_ = this;
- staffs_.bottom().add(s);
-}
-
-
void
Score::do_pcols()
{
- PCursor<Score_column*> sc(cols_);
- for (; sc.ok(); sc++) {
- pscore_->add(sc->pcol_);
+ PCursor<Score_column*> i(cols_);
+ for (; i.ok(); i++) {
+ pscore_->add(i->pcol_);
}
}
Real
Score::OK() const
{
#ifndef NDEBUG
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->OK();
- assert(sc->score_ == this);
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->OK();
+ assert(i->score_ == this);
}
staffs_.OK();
cols_.OK();
{
#ifndef NPRINT
mtor << "score {\n";
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->print();
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->print();
}
- for (PCursor<Score_column*> sc(cols_); sc.ok(); sc++) {
- sc->print();
+ for (PCursor<Score_column*> i(cols_); i.ok(); i++) {
+ i->print();
}
+ if (pscore_)
+ pscore_->print();
+
mtor << "}\n";
#endif
}
-Score::Score()
+Score::Score(Paperdef*p)
{
pscore_=0;
- paper_ = 0;
+ paper_ = p;
}
Score::~Score()
{
delete pscore_;
- for (int i=0; i<input_commands_.sz(); i++)
- delete input_commands_[i];
- delete paper_;
-}
-void
-Score::set(Paperdef*p)
-{
- delete paper_;
- paper_ = p;
}
void
}
+
void
-Score::add(svec<Command*> &s)
+Score::add(Staff*s)
{
- input_commands_.add(get_reset_command());
- input_commands_.concat(s);
+ s->score_ = this;
+ staffs_.bottom().add(s);
}