]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.14
authorfred <fred>
Tue, 3 Dec 1996 23:35:24 +0000 (23:35 +0000)
committerfred <fred>
Tue, 3 Dec 1996 23:35:24 +0000 (23:35 +0000)
src/calcideal.cc
src/score.cc

index 3f9a7dca2354d7f41ff98c0f72fa53a46045e504..47ca885adecf9cd2fd64be3370bea884e1c1d371 100644 (file)
@@ -24,12 +24,10 @@ Score::do_connect(PCol *c1, PCol *c2, Real d, Real h)
 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.
@@ -39,43 +37,61 @@ Score::connect(PCol* c1, PCol *c2, Real d, Real h)
 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
 }
 
 
index 60ab3931f9f35a4d204203a72d5abb095654a105..57336936b5c2f0ec40c2308e020ad42cd9be531c 100644 (file)
@@ -1,7 +1,4 @@
-#include "staffcommands.hh"
 #include "tstream.hh"
-#include "getcommand.hh"
-#include "inputcommands.hh"
 #include "score.hh"
 #include "sccol.hh"
 #include "pscore.hh"
@@ -9,6 +6,7 @@
 #include "debug.hh"
 #include "paper.hh"
 
+
 void
 Score::process()
 {
@@ -18,20 +16,21 @@ 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();
@@ -49,16 +48,16 @@ Score::process()
 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();
@@ -114,27 +113,12 @@ Score::find_col(Real w,bool mus)
     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
@@ -151,9 +135,9 @@ void
 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();
@@ -169,34 +153,28 @@ Score::print() const
 {
 #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
@@ -212,10 +190,11 @@ Score::output(String s)
 }
 
 
+
 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);
 }