-
+#include "scommands.hh"
#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)
+Score::set(Paperdef*p)
{
- 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]);
- }
-
+ delete paper_;
+ paper_ = p;
}
-
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();
+ *mlog << "Processing ...";
+ set(commands_->parse(last()));
+ commands_->print();
+
+ if (!paper_)
+ paper_ = new Paperdef;
+
+ commands_->clean(last());
/// distribute commands to disciples
distribute_commands();
- pscore_ = new PScore;
+ pscore_ = new PScore(paper_);
for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
sc->set_output(pscore_);
sc->process();
clean_cols();
OK();
// print();
+ *mlog << "Calculating ... ";
pscore_->calc_breaking();
// TODO: calculate vertical structs
// TODO: calculate mixed structs.
+ *mlog << "\n";
}
// remove empty cols with no spacing attached.
*/
// todo
PCursor<Score_column*>
-Score::create_cols(Mtime w)
+Score::create_cols(Real w)
{
Score_column* c1 = new Score_column(w);
Score_column* c2 = new Score_column(w);
}
Score_column*
-Score::find_col(Mtime w,bool mus)
+Score::find_col(Real w,bool mus)
{
PCursor<Score_column*> scc(cols_);
for (; scc.ok(); scc++) {
Score::distribute_commands(void)
{
for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->add_commands(commands_);
+ 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);
+ }
+}
+Real
+Score::last() const
+{
+ Real l = 0;
+ for (PCursor<Staff*> stc(staffs_); stc.ok(); stc++) {
+ l = MAX(l, stc->last());
+ }
+ return l;
}
void
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
{
for (PCursor<Score_column*> sc(cols_); sc.ok(); sc++) {
sc->print();
}
+ commands_->print();
mtor << "}\n";
#endif
}
+
Score::Score()
{
pscore_=0;
+ paper_ = 0;
+ commands_ = new Score_commands;
}
-/****************************************************************/
-Score_column::Score_column(Mtime w)
+Score::~Score()
{
- when = w;
- pcol = new PCol(0);
- musical = false;
-}
-
-bool
-Score_column::used() {
- return pcol->used;
+ delete pscore_;
+ delete commands_;
+ delete paper_;
}
void
-Score_column::print() const
+Score::set(Score_commands*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
+ delete commands_;
+ commands_ = c;
}
-
-