]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.4
authorfred <fred>
Tue, 22 Oct 1996 20:17:15 +0000 (20:17 +0000)
committerfred <fred>
Tue, 22 Oct 1996 20:17:15 +0000 (20:17 +0000)
sccol.cc [new file with mode: 0644]
sccol.hh [new file with mode: 0644]
score.cc
score.hh

diff --git a/sccol.cc b/sccol.cc
new file mode 100644 (file)
index 0000000..2895533
--- /dev/null
+++ b/sccol.cc
@@ -0,0 +1,28 @@
+#include "sccol.hh"
+#include "debug.hh"
+
+Score_column::Score_column(Mtime w)
+{
+    when = w;
+    pcol = new PCol(0);
+    musical = false;
+}
+
+bool
+Score_column::used() {
+    return pcol->used;
+}
+
+void
+Score_column::print() const
+{
+#ifndef NPRINT
+    mtor << "Score_column { mus "<< musical <<" at " <<  when<<'\n';
+    mtor << "durations: [";
+    for (int i=0; i < durations.sz(); i++)
+       mtor << durations[i] << " ";
+    mtor << "]\n";
+    pcol->print();
+    mtor << "}\n";
+#endif
+}
diff --git a/sccol.hh b/sccol.hh
new file mode 100644 (file)
index 0000000..9c22c27
--- /dev/null
+++ b/sccol.hh
@@ -0,0 +1,46 @@
+/*
+  sccol.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef SCCOL_HH
+#define SCCOL_HH
+#include "pcol.hh"
+#include "mtime.hh"
+
+
+struct Score_column {
+    PCol * pcol;
+    svec<Mtime> durations;
+    Mtime when;
+
+    /// 
+    bool musical;
+    
+
+    Score_column(Mtime when);
+
+    static int compare(Score_column & c1, Score_column &c2) {
+       return sgn(c1.when - c2.when);
+    }
+    void set_breakable() {
+        pcol->set_breakable();
+    }
+    bool used();
+    void print() const;
+};
+/**
+
+    When typesetting hasn't started on PScore yet, the columns which
+    contain data have a rhythmical position. Score_column is the type
+    with a rhythmical time attached to it. The calculation of
+    idealspacing is done with data in these columns. (notably: the
+    #durations# field)
+
+    */
+
+instantiate_compare(Score_column&, Score_column::compare);
+
+#endif // SCCOL_HH
+
index f5e357ecdbab7bfa3b13794d3154a6691d96870d..0f8bbf70de0b6b763add44afceac9c8e1d20e1d7 100644 (file)
--- a/score.cc
+++ b/score.cc
-
 #include "tstream.hh"
 #include "score.hh"
+#include "sccol.hh"
 #include "pscore.hh"
 #include "staff.hh"
-#include "misc.hh"
 #include "debug.hh"
+#include "paper.hh"
 
 void
-Score::add_command_seq(svec<Command *> com)
-{
-    if (!com.sz())
-       return;
-    Real when = com[0]->when;
-
-    PCursor<Command*> pc(commands_);    
-    while (pc.ok()&&pc->when <= when)
-       pc++;
-    
-    for (int i = 0; i < com.sz(); i++) {
-       assert(com[i]->when == when);
-       if (!pc.ok())
-           pc.add(com[i]);
-       else
-           pc.insert(com[i]);
-    }
-    
-}
-
-void
-Score::add(Command *c)
+Score::output(String s)
 {
-    svec<Command*> seq;    
-    if (c->code == TYPESET && c->args[0] == "BAR") {
-       /* should be encapsulated in BREAKs
-
-          THIS SUX.
-
-        */
-
-       Command k;
-       
-       k.when = c->when;
-       k.code = BREAK_PRE;
-       
-       seq.add(new Command(k));
-       seq.add(new Command(*c));
-       k.code = BREAK_MIDDLE;
-       seq.add(new Command(k));
-       seq.add(new Command(*c));
-       k.code = BREAK_POST;
-       seq.add(new Command(k));
-       k.code = BREAK_END;
-       seq.add(new Command(k));
-    }
-    else
-       seq.add(new Command(*c));
+    OK();
+    if (paper->outfile=="")
+       paper->outfile = s;
     
-    add_command_seq(seq);
-}
-
-void
-Score::add(Staff*s)
-{
-    s->score_ = this;
-    staffs_.bottom().add(s);    
+    *mlog << "output to " << paper->outfile << "...\n";
+    Tex_stream the_output(paper->outfile);    
+    pscore_->output(the_output);
 }
 
 
-void
-Score::do_pcols()
-{
-    PCursor<Score_column*> sc(cols_);
-    for (;sc.ok(); sc++) {
-       pscore_->add(sc->pcol);
-    }
-}
-/*
-    this sux. Really makeshift.
-
-    first and last column should be breakable.
-    Remove any command past the last musical column.
-    */
-void
-Score::do_miscs()
-{
-    Command c;
-
-    {
-       Command c;
-       c.when = 0.0;
-       c.code = TYPESET;
-       c.args.add("BAR");
-       c.args.add("empty");
-       add(&c);
-    }
-    
-    PCursor<Command*> bot(commands_.bottom());
-    Real l = last();    
-    while (bot.ok() && bot->when > l) {
-
-       mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n';
-       bot.del();
-       bot = commands_.bottom();
-    }
-
-    if (bot->when != l || bot->code != BREAK_END) {
-       Command c;
-       c.code = TYPESET;
-       c.when = l;
-       c.args.add("BAR");
-       c.args.add("||");
-       add(&c);
-    }
-   commands_.OK();
-}
-
-Mtime
-Score::last() const
-{    
-    Mtime l = 0;
-    for (PCursor<Staff*> stc(staffs_); stc.ok(); stc++) {
-       l = MAX(l, stc->last());
-    }
-    return l;
-}
-void
-Score::clean_commands() 
-{
-    Mtime l= last();
-    for (PCursor<Command*> cc(commands_); cc.ok(); ) {
-       if (cc->when > l){
-           mtor << "remming \n";
-           cc.del();
-       } else
-           cc++;
-    }
-}
 void
 Score::process()
 {
-     do_miscs();
+    if (!paper)
+       paper = new Paperdef;
+
+    commands_.clean(last());
     
     /// distribute commands to disciples
     distribute_commands();
@@ -238,18 +124,30 @@ Score::distribute_commands(void)
        sc->add_commands(commands_);
     }
 }
+void
+Score::add(Staff*s)
+{
+    s->score_ = this;
+    staffs_.bottom().add(s);    
+}
 
 
 void
-Score::output(String s)
+Score::do_pcols()
 {
-    OK();
-    if (outfile=="")
-       outfile = s;
-    
-    *mlog << "output to " << outfile << "...\n";
-    Tex_stream the_output(outfile);    
-    pscore_->output(the_output);
+    PCursor<Score_column*> sc(cols_);
+    for (; sc.ok(); sc++) {
+       pscore_->add(sc->pcol);
+    }
+}
+Mtime
+Score::last() const
+{    
+    Mtime l = 0;
+    for (PCursor<Staff*> stc(staffs_); stc.ok(); stc++) {
+       l = MAX(l, stc->last());
+    }
+    return l;
 }
 
 void
@@ -265,12 +163,11 @@ Score::OK() const
     for (PCursor<Score_column*> cc(cols_); cc.ok() && (cc+1).ok(); cc++) {
        assert(cc->when <= (cc+1)->when);
     }
-    for (PCursor<Command*> cc(commands_); cc.ok() && (cc+1).ok(); cc++) {
-       assert(cc->when <= (cc+1)->when);
-    }
+    commands_.OK();
 #endif    
 }
 
+
 void
 Score::print() const
 {
@@ -282,38 +179,18 @@ Score::print() const
     for (PCursor<Score_column*> sc(cols_); sc.ok(); sc++) {
        sc->print();
     }
+    commands_.print();
     mtor << "}\n";
 #endif
 }
+
 Score::Score()
 {
     pscore_=0;
+    paper = 0;
 }
-/****************************************************************/
-
-Score_column::Score_column(Mtime w)
-{
-    when = w;
-    pcol = new PCol(0);
-    musical = false;
-}
-
-bool
-Score_column::used() {
-    return pcol->used;
-}
-
 void
-Score_column::print() const
+Score::add(Command*c)
 {
-    #ifndef NPRINT
-    mtor << "Score_column { mus "<< musical <<" at " <<  when<<'\n';
-    mtor << " # symbols: " << pcol->its.size() << "\n";
-    mtor << "durations: [" ;
-    for (int i=0; i < durations.sz(); i++)
-       mtor << durations[i] << " ";
-    mtor << "]\n}\n";
-    #endif
+    commands_.add(*c);
 }
-
-    
index 5ec7f33b5a413ba5c1ac68dbb57e7022d0f86542..c6af97c7a10d77fb395fe086961ca9f2fd07292e 100644 (file)
--- a/score.hh
+++ b/score.hh
@@ -2,49 +2,15 @@
 #define SCORE_HH
 
 #include "vray.hh"
-#include "cols.hh"
 #include "mtime.hh"
-#include "command.hh"
-
-struct Score_column {
-    PCol * pcol;
-    svec<Mtime> durations;
-    Mtime when;
-
-    /// 
-    bool musical;
-    
-
-    Score_column(Mtime when);
-
-    static int compare(Score_column & c1, Score_column &c2) {
-       return sgn(c1.when - c2.when);
-    }
-    void set_breakable() {
-        pcol->set_breakable();
-    }
-    bool used();
-    void print() const;
-};
-/**
-
-    When typesetting hasn't started on PScore yet, the columns which
-    contain data have a rhythmical position. Score_column is the type
-    with a rhythmical time attached to it. The calculation of
-    idealspacing is done with data in these columns. (notably: the
-    #durations# field)
-
-    */
-
-instantiate_compare(Score_column&, Score_column::compare);
-
+#include "scommands.hh"
 
 /// the total music def of one movement
 struct Score {
-    String outfile;
+    Paperdef *paper;
     /// staffs_ and commands_ form the problem definition.
     PointerList<Staff *> staffs_;
-    PointerList<Command*> commands_;
+    Score_commands commands_;
     
     /// "runtime" fields for setting up spacing    
     PointerList<Score_column*> cols_;
@@ -52,34 +18,35 @@ struct Score {
 
     /****************************************************************/
 
-    Score();
-    
-    /// add #Idealspacings# to #pscore_#
-    void calc_idealspacing();
+    Score();    
     void process();
 
     /// construction
     void add_staff(Staff *st);
 
-    void distribute_commands();
-    /** add the score wide commands (bars, breaks) to each staff so
-    they can process (typeset) them if needed */
     void OK() const;
     Score_column *find_col(Mtime,bool);
     void do_pcols();
-    void add(Command *);
+
     void add(Staff*);
-    void add_command_seq(svec<Command*> );
     void output(String fn);
     PCursor<Score_column*> create_cols(Mtime);
     void print() const;
-    void do_miscs() ;
+
     Mtime last() const;
+    
+    void add(Command*);
+    
+private:
+    
     void clean_cols();
-    void clean_commands();
-
+    void distribute_commands();
     void do_connect(PCol *c1, PCol *c2, Real d);
     void connect_nonmus(PCol* c1, PCol *c2, Real d);
+    /// add #Idealspacings# to #pscore_#
+    void calc_idealspacing();
+    /** add the score wide commands (bars, breaks) to each staff so
+    they can process (typeset) them if needed */
 };
 /**