From 445dd6237b59e0d1b5770223a85aa8eb75c34d6e Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:30:06 +0000 Subject: [PATCH] lilypond-0.0.26 --- configure | 16 +-- input/maartje.ly | 8 +- src/break.cc | 4 +- src/complexstaff.cc | 58 +++++++++++ src/complexwalker.cc | 241 +++++++++++++++++++++++++++++++++++++++++++ src/getcommands.cc | 22 ++-- src/grouping.cc | 45 ++++---- src/inputcommand.cc | 50 ++++----- src/inputscore.cc | 2 +- src/key.cc | 8 +- src/keyitem.cc | 6 +- src/lookup.cc | 12 +-- src/lyriccolumn.cc | 15 +-- src/molecule.cc | 6 +- src/pscore.cc | 2 +- src/qlp.cc | 10 +- src/sccol.cc | 2 +- src/scores.cc | 2 +- src/script.cc | 35 +++++-- src/simplestaff.cc | 25 ++--- src/simplewalker.cc | 89 ++++++++++------ src/slur.cc | 14 +-- src/spanner.cc | 24 ++--- src/staff.cc | 21 ++-- src/staffcommands.cc | 4 +- src/stcol.cc | 2 +- src/stem.cc | 17 ++- src/tex.cc | 2 +- src/textspanner.cc | 27 +++-- 29 files changed, 547 insertions(+), 222 deletions(-) create mode 100644 src/complexstaff.cc create mode 100644 src/complexwalker.cc diff --git a/configure b/configure index 1f7f7b5238..b10d461235 100755 --- a/configure +++ b/configure @@ -1,15 +1,18 @@ #!/bin/sh +PREFIX=${PREFIX:-.} +echo using PREFIX=$PREFIX -NEEDFLOWERVER=1.0.21 +NEEDFLOWERVER=1.0.22 flowertar=flower-$NEEDFLOWERVER here=`pwd` -if [ -x ../flower ] +cd .. +if [ -x flower ] then echo Found flowerdir else - cd ../ - if [ ! -f $flowertar ] + + if [ ! -d $flowertar ] then echo "can't find $flowertar" exit 1; @@ -19,11 +22,10 @@ else fi echo Compiling Library -cd flower; make +(cd flower;make) + cd $here -PREFIX="." echo '#define LIBDIR "'$PREFIX'/"'> hdr/config.hh -touch depend make -f Initial.make diff --git a/input/maartje.ly b/input/maartje.ly index 7755894eff..1a7925955f 100644 --- a/input/maartje.ly +++ b/input/maartje.ly @@ -4,9 +4,8 @@ % % - - -ritme = staff {rhythmic +ritme = staff { + rhythmic music {$ c8 |[a8() a8. a8 a16 a16 a16] c4. @@ -25,6 +24,7 @@ ritme = staff {rhythmic melody= staff { melodic +% complex music{$ c8 |r4 r4 r4 r4 @@ -56,7 +56,7 @@ staff { melodic skip 2:0 key skip 5:0 - clef "bass" + clef bass } } diff --git a/src/break.cc b/src/break.cc index 2a0586edff..f3832cf0f6 100644 --- a/src/break.cc +++ b/src/break.cc @@ -19,7 +19,7 @@ Break_algorithm::find_breaks() const Array retval; for (iter_top(pscore_.cols,c); c.ok(); c++) if (c->breakable()) - retval.add(c); + retval.push(c); return retval; } @@ -82,7 +82,7 @@ Col_configuration::Col_configuration() void Col_configuration::add( PCol*c) { - cols.add(c); + cols.push(c); } void diff --git a/src/complexstaff.cc b/src/complexstaff.cc new file mode 100644 index 0000000000..ffa667ea85 --- /dev/null +++ b/src/complexstaff.cc @@ -0,0 +1,58 @@ +#include "request.hh" +#include "voice.hh" +#include "staffwalker.hh" +#include "debug.hh" +#include "clef.hh" +#include "staff.hh" +#include "command.hh" +#include "complexstaff.hh" +#include "sccol.hh" +#include "complexwalker.hh" + + + +Complex_column::Complex_column(Score_column*s, Complex_staff *rs) + : Staff_column(s) +{ + staff_l_ = rs; +} + +Complex_staff::Complex_staff() +{ + theline_l_ = 0; +} + +void +Complex_column::setup_requests() +{ + for (int i = 0 ; i < v_elts.size(); i ++) + for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { + + if (j->barcheck()) { + if (tdescription_->whole_in_measure) { + error("Barcheck failed, " + tdescription_->str()); + } + continue; + } + if (j->mark()) + continue; + if (j->command()) + continue; + todo_l_arr_.push(j); + } +} + +Staff_column* +Complex_staff::create_col(Score_column*s) +{ + return new Complex_column(s,this); +} + +void +Complex_staff::walk() +{ + for (Complex_walker sc(this); sc.ok(); sc++) { + sc.col()->setup_requests();// TODO + sc.process(); + } +} diff --git a/src/complexwalker.cc b/src/complexwalker.cc new file mode 100644 index 0000000000..5cc1b5b6a5 --- /dev/null +++ b/src/complexwalker.cc @@ -0,0 +1,241 @@ +#include "associter.hh" +#include "script.hh" +#include "request.hh" +#include "voice.hh" +#include "clef.hh" +#include "pscore.hh" +#include "complexstaff.hh" +#include "complexwalker.hh" +#include "sccol.hh" +#include "debug.hh" +#include "keyitem.hh" +#include "clefitem.hh" +#include "voicegroup.hh" +#include "register.hh" + +Rhythmic_grouping +cparse_grouping(Array a, Moment one_beat) +{ + Array r; + for (int i= 0 ; i < a.size(); i++) + r.push(a[i]); + Moment here =0.0; + + Array children; + for (int i=0; i < r.size(); i++) { + + Moment last = here; + here += one_beat * r[i]; + children.push( + new Rhythmic_grouping(MInterval(last, here), r[i] ) + ); + } + return Rhythmic_grouping(children); +} + +void +Complex_walker::do_INTERPRET_command(Command*com) +{ + Array args(com->args); + args.del(0); + if (com->args[0] == "GROUPING") { + default_grouping = cparse_grouping(args, + col()->tdescription_->one_beat); + }else if (com->args[0] == "NEWMEASURE") { + local_key_.reset(key_); + + } else if (com->args[0] == "KEY") { + + if (col()->when() > Moment(0)) { + assert(!oldkey_undo); + oldkey_undo = new Array( key_.oldkey_undo(args)); + } + + typesetkey = key_.read(args); + local_key_.reset(key_); + } else if (com->args[0] == "CLEF") { + clef_.read(args); + } else { + WARN << " ignoring INTERPRET command: " << com->args[0]<< "\n"; + } +} + +void +Complex_walker::do_TYPESET_command(Command*com) +{ + /* ignore these commands if non-default versions have been + processed. */ + if (com->args[0] == "CURRENTKEY") + if (processed_key) + return; + else + com->args[0] = "KEY"; // urgh + + if (com->args[0] == "CURRENTCLEF") { + if (processed_clef) + return; + } + if (com->args[0] == "BAR") { + + if (processed_bar_priority > com->priority) + return; + else + processed_bar_priority = com->priority; + } + + Item* i = staff()->get_TYPESET_item(com); + if (!i) + return; + + if (com->args[0] == "KEY") { + ((Keyitem*) i)->read(clef_); + if (oldkey_undo) { + ((Keyitem*) i)->read(*oldkey_undo); + delete oldkey_undo; + oldkey_undo = 0; + } + processed_key = true; + + ((Keyitem*) i)->read(typesetkey); // ugh + } + + if (com->args[0] == "CLEF"||com->args[0] == "CURRENTCLEF") { + processed_clef =true; + Clef_item*c=(Clef_item*)i; + c->read(clef_); + c->change = (break_status != BREAK_POST - BREAK_PRE); + } + col()->typeset_item_directional(i, 1, break_status); +} + +void +Complex_walker::announce_element(Staff_elem_info info) +{ + announce_info_arr_.push(info); +} + +void +Complex_walker::do_announces() +{ + + for (int i = 0; i < announce_info_arr_.size(); i++){ + Staff_elem_info info = announce_info_arr_[i]; + for (iter_top(voice_reg_list_,j); j.ok(); j++) { + j->announce_element(info); + } + group_regs_.announce_element(info); + local_key_reg_.acknowledge_element(info); + } +} + +Voice_registers * +Complex_walker::find_voice_reg(Voice*v_l) +{ + for (iter_top(voice_reg_list_, i); i.ok(); i++) { + if (i->voice_l_ == v_l) + return i; + } + + Voice_registers *regs_p=new Voice_registers(this,v_l); + voice_reg_list_.bottom().add (regs_p); + //voice_reg_map_[v_l] = regs_p; + return regs_p; +} + +void +Complex_walker::try_request(Request*req) +{ + bool b; + if (req->note() || req->rest()|| req->slur()) { + Voice *v_l = req->elt_l_->voice_l_; + Voice_registers *vregs_l = find_voice_reg(v_l); + + b = vregs_l->try_request(req); + + } else { + b = group_regs_.try_request(req); + if (!b) + b = local_key_reg_.try_request(req); + } + if (!b) + WARN<< "junking request: " <name() <<"\n"; +} + +void +Complex_walker::process_requests() +{ + Complex_column*c = col(); +// Complex_staff *s = staff(); + + for (int i=0; i < c->todo_l_arr_.size(); i++) { + try_request(c->todo_l_arr_[i]); + } + + regs_process_requests(); + do_announces(); +} + +void +Complex_walker::regs_process_requests() +{ + for (iter_top(voice_reg_list_,j); j.ok(); j++) { + j->process_requests(); + } + group_regs_.process_requests(); + local_key_reg_.process_request(); +} + +void +Complex_walker::typeset_element(Staff_elem *elem_p) +{ + if (elem_p->spanner()) + pscore_l_->typeset_spanner(elem_p->spanner(), staff()->theline_l_); + else + col()->typeset_item(elem_p->item()); +} + +Complex_walker::Complex_walker(Complex_staff*s) + : Staff_walker(s, s->theline_l_->pscore_l_), + group_regs_(this), + local_key_reg_(this) +{ + oldkey_undo = 0; + do_post_move(); +} + +Complex_staff* +Complex_walker::staff() +{ + return (Complex_staff*) staff_l_; +} + +Complex_column* +Complex_walker::col() +{ + return (Complex_column*) *(*this); +} + +void +Complex_walker::do_pre_move() +{ + for (iter_top(voice_reg_list_,i); i.ok(); i++) { + i->pre_move_processing(); + } + group_regs_.pre_move_processing(); + local_key_reg_.pre_move_processing(); +} + +void +Complex_walker::do_post_move() +{ + processed_clef =false; + processed_key = false; + processed_bar_priority = 0; + + for (iter_top(voice_reg_list_,i); i.ok(); i++) { + i->post_move_processing(); + } + announce_info_arr_.set_size(0); + group_regs_.post_move_processing(); + local_key_reg_.post_move_processing(); +} diff --git a/src/getcommands.cc b/src/getcommands.cc index a11e2c0fe3..61a3f59f62 100644 --- a/src/getcommands.cc +++ b/src/getcommands.cc @@ -21,9 +21,9 @@ get_meter_command(int n, int m) Command*c = new Command; c->code = TYPESET; - c->args.add( "METER"); - c->args.add( n ); - c->args.add( m ); + c->args.push( "METER"); + c->args.push( n ); + c->args.push( m ); c->priority = 40; return c; } @@ -33,8 +33,8 @@ get_defaultbar_command() { Command c; c.code = TYPESET; - c.args.add("BAR"); - c.args.add("default"); + c.args.push("BAR"); + c.args.push("default"); return c; } @@ -45,21 +45,21 @@ split_bar_command(Command &pre_com, Command &no_break_com, Command &post_com, Command c; c.code = TYPESET; c.priority = (s=="default") ? 100: 110; - c.args.add("BAR"); + c.args.push("BAR"); if(s=="default") s = "|"; if (s == ":|:") { no_break_com=post_com=pre_com = c; - pre_com.args.add( ":|"); - no_break_com.args.add( s); - post_com.args.add( "|:"); + pre_com.args.push( ":|"); + no_break_com.args.push( s); + post_com.args.push( "|:"); }else if (s=="|:") { - c.args.add(s); + c.args.push(s); no_break_com=post_com=c; } else { - c.args.add(s); + c.args.push(s); pre_com= no_break_com= c; } } diff --git a/src/grouping.cc b/src/grouping.cc index 4f02b75378..06f906ff91 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -67,10 +67,10 @@ Rhythmic_grouping::intervals() MInterval i(interval()); MInterval r1(i), r2(i); r1.right = r2.left = i.center(); - r.add(r1); r.add(r2); + r.push(r1); r.push(r2); } else { for (int i=0; i < children.size(); i++) - r.add(children[i]->interval()); + r.push(children[i]->interval()); } return r; } @@ -124,12 +124,12 @@ Rhythmic_grouping::split(Array splitpoints) } else { if (i == starti) { - ch.add(children[i]); + ch.push(children[i]); } else { Rhythmic_grouping *newchild=new Rhythmic_grouping( children.subvec(starti, i+1)); - ch.add(newchild); + ch.push(newchild); } i ++; j++; @@ -154,7 +154,7 @@ Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n) Moment dt = t.length()/n; MInterval basic = MInterval(t.left, t.left+dt); for (int i= 0; i < n; i++) - children.add(new Rhythmic_grouping( dt*i + basic )); + children.push(new Rhythmic_grouping( dt*i + basic )); } @@ -174,7 +174,7 @@ Rhythmic_grouping::copy(Rhythmic_grouping const&s) { interval_ = (s.interval_)? new MInterval(*s.interval_) : 0; for (int i=0; i < s.children.size(); i++) - children.add(new Rhythmic_grouping(*s.children[i])); + children.push(new Rhythmic_grouping(*s.children[i])); } void @@ -213,21 +213,22 @@ Rhythmic_grouping::print()const #endif } +bool +Rhythmic_grouping::child_fit_query(Moment start) +{ + if (children.size()) + return ( children.last()->interval().right== start); + + return true; +} + void Rhythmic_grouping::add_child(Moment start, Moment len) { Moment stop = start+len; - for (int i=0; i < children.size(); i ++) { - MInterval j=children[i]->interval(); - if (j.left == start && j.right==stop) { - return; - } - } - - if (children.size()) - assert ( children.last()->interval().right== start); - children.add(new Rhythmic_grouping(MInterval(start, stop))); + assert(child_fit_query(start)); + children.push(new Rhythmic_grouping(MInterval(start, stop))); } Rhythmic_grouping::Rhythmic_grouping() @@ -255,12 +256,12 @@ Rhythmic_grouping::generate_beams(Array flags, int &flagidx) Array child_beams; if (children[i]->interval_) { int f = flags[flagidx++]; - child_beams.add(f); + child_beams.push(f); } else { child_beams = children[i]-> generate_beams(flags, flagidx); } - children_beams.add(child_beams); + children_beams.push(child_beams); } Array beams; int lastm, m, nextm; @@ -275,15 +276,15 @@ Rhythmic_grouping::generate_beams(Array flags, int &flagidx) if (children_beams[i].size() == 1) { if (add_right) - beams.add(m); + beams.push(m); if (add_left) - beams.add(m); + beams.push(m); } else { if (add_left) - beams.add(lastm args.add("PARTIAL"); - c->args.add(u); + c->args.push("PARTIAL"); + c->args.push(u); return c; } @@ -48,8 +48,8 @@ Input_command* get_goto_command(String s) { Input_command*c = new Input_command; - c->args.add("GOTO"); - c->args.add(s); + c->args.push("GOTO"); + c->args.push(s); return c; } @@ -58,17 +58,17 @@ get_cadenza_toggle(int i) { Input_command*c = new Input_command; - c->args.add("CADENZA"); - c->args.add(i); + c->args.push("CADENZA"); + c->args.push(i); return c; } Input_command* get_grouping_command(Arraya ) { Input_command*c = new Input_command; - c->args.add("GROUPING"); + c->args.push("GROUPING"); for (int i=0; i < a.size(); i ++) - c->args.add(a[i]); + c->args.push(a[i]); return c; } @@ -77,9 +77,9 @@ Input_command* get_key_interpret_command(Arraya ) { Input_command*c = new Input_command; - c->args.add("KEY"); + c->args.push("KEY"); for (int i=0; i < a.size(); i ++) { - c->args.add(a[i]); + c->args.push(a[i]); } return c; } @@ -88,7 +88,7 @@ Input_command* get_reset_command() { Input_command*c = new Input_command; - c->args.add("RESET"); + c->args.push("RESET"); return c; } @@ -97,9 +97,9 @@ get_meterchange_command(int n, int m) { Input_command*c = new Input_command; - c->args.add( "METER"); - c->args.add( n ); - c->args.add( m ); + c->args.push( "METER"); + c->args.push( n ); + c->args.push( m ); return c; } @@ -108,7 +108,7 @@ Input_command * get_newmeasure_command() { Input_command*c = new Input_command; - c->args.add( "NEWMEASURE"); + c->args.push( "NEWMEASURE"); return c; } @@ -117,9 +117,9 @@ get_skip_command(int n, Moment m) { Input_command*c = new Input_command; - c->args.add( "SKIP"); - c->args.add( n ); - c->args.add( m ); + c->args.push( "SKIP"); + c->args.push( n ); + c->args.push( m ); return c; } @@ -143,8 +143,8 @@ Input_command* get_clef_interpret_command(String w) { Input_command*c = new Input_command; - c->args.add("CLEF"); - c->args.add(w); + c->args.push("CLEF"); + c->args.push(w); return c; } @@ -152,8 +152,8 @@ Input_command* get_bar_command(String w) { Input_command*c = new Input_command; - c->args.add("BAR"); - c->args.add(w); + c->args.push("BAR"); + c->args.push(w); return c; } @@ -163,12 +163,12 @@ get_default_grouping(int count) Array s; if (!(count % 3 )) { for (int i=0; i < count/3; i++) - s.add(3); + s.push(3); } else if (!(count %2)) { for (int i=0; i < count/2; i++) - s.add(2); + s.push(2); }else { - s.add(2); + s.push(2); s.concat(get_default_grouping(count-2)); } return s; diff --git a/src/inputscore.cc b/src/inputscore.cc index 28e1f71599..6ea13d9b5d 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -40,7 +40,7 @@ Input_score::parse() Array parsed_staffs; for (iter_top(staffs_,i); i.ok(); i++) { Staff* staf_p=i->parse(s_p); - parsed_staffs.add(staf_p); + parsed_staffs.push(staf_p); s_p->add(staf_p); } int j = 0; diff --git a/src/key.cc b/src/key.cc index cd7f400737..232ce9a94f 100644 --- a/src/key.cc +++ b/src/key.cc @@ -48,8 +48,8 @@ Key::read(Array s) int small = s[i++]; accidentals[large]=small; - newkey.add(large); - newkey.add(small); + newkey.push(large); + newkey.push(small); } return newkey; } @@ -70,8 +70,8 @@ Key::oldkey_undo(Arrays) } for (int i=0; i < newkey.size(); i++) if (accidentals[i] && accidentals[i] != newkey[i]) { - oldkey.add(i); - oldkey.add(0); + oldkey.push(i); + oldkey.push(0); } diff --git a/src/keyitem.cc b/src/keyitem.cc index 9ae9c22289..017570d749 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -8,7 +8,7 @@ const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ - +NAME_METHOD(Keyitem); Keyitem::Keyitem(int c) { c_position = c; @@ -39,8 +39,8 @@ Keyitem::add(int p, int a) (a>0 && p>SHARP_TOP_PITCH)) { p=p-7; /* Typeset below c_position */ } - pitch.add(p); - acc.add(a); + pitch.push(p); + acc.push(a); } diff --git a/src/lookup.cc b/src/lookup.cc index befa542706..a9c5d18731 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -33,7 +33,7 @@ Lookup::text(String style, String text, int dir) { Array a; - a.add(text); + a.push(text); Symbol tsym = (*symtables_)("style")->lookup(style); a[0] = substitute_args(tsym.tex,a); @@ -132,7 +132,7 @@ Lookup::streepjes(int i) Symbol ret = (*symtables_)("streepjes")->lookup(idx); Array a; - a.add(arg); + a.push(arg); ret.tex = substitute_args(ret.tex, a); return ret; @@ -149,8 +149,8 @@ Lookup::linestaff(int lines, Real wid) s.dim.y = Interval(0,dy); Array a; - a.add(lines); - a.add(print_dimen(wid)); + a.push(lines); + a.push(print_dimen(wid)); s.tex = (*symtables_)("param")->lookup("linestaf").tex; s.tex = substitute_args(s.tex, a); @@ -182,8 +182,8 @@ Lookup::stem(Real y1,Real y2) s.dim.y = Interval(y1,y2); Array a; - a.add(print_dimen(y1)); - a.add(print_dimen(y2)); + a.push(print_dimen(y1)); + a.push(print_dimen(y2)); String src = (*symtables_)("param")->lookup("stem").tex; s.tex = substitute_args(src,a); diff --git a/src/lyriccolumn.cc b/src/lyriccolumn.cc index 6420c4b3d9..45f30836ed 100644 --- a/src/lyriccolumn.cc +++ b/src/lyriccolumn.cc @@ -3,14 +3,12 @@ #include "staffwalker.hh" #include "debug.hh" #include "staff.hh" -#include "command.hh" -//#include "simplestaff.hh" +//#include "command.hh" #include "lyricstaff.hh" #include "lyriccolumn.hh" #include "sccol.hh" -//#include "simplewalker.hh" #include "pscore.hh" -#include "paper.hh" +//#include "paper.hh" Lyric_column::Lyric_column(Score_column*s, Lyric_staff* lstaff_l) @@ -20,7 +18,7 @@ Lyric_column::Lyric_column(Score_column*s, Lyric_staff* lstaff_l) } void -Lyric_column::process_requests() +Lyric_column::setup_requests() { for (int i = 0 ; i < v_elts.size(); i ++) { for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { @@ -30,13 +28,8 @@ Lyric_column::process_requests() error("Barcheck failed, " + tdescription_->str()); } } -#if 0 - if (req_l->rhythmic()){ - notes.add(rq->rhythmic()); - } -#endif if (req_l->lreq_l()) { - winfo_array_.add(req_l->lreq_l()); + winfo_array_.push(req_l->lreq_l()); } } } diff --git a/src/molecule.cc b/src/molecule.cc index 682204880d..1e09658fee 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -33,9 +33,9 @@ Atom::TeXstring() const // whugh.. Hard coded... String s("\\placebox{%}{%}{%}"); Array a; - a.add(print_dimen(off.y)); - a.add(print_dimen(off.x)); - a.add(sym.tex); + a.push(print_dimen(off.y)); + a.push(print_dimen(off.x)); + a.push(sym.tex); return substitute_args(s, a); } diff --git a/src/pscore.cc b/src/pscore.cc index 8251135cde..83f71f440c 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -143,7 +143,7 @@ PScore::select_items(PStaff*ps, PCol*pc) assert(ps && pc); for (iter_top(pc->its,i); i.ok(); i++){ if (i->pstaff_l_ == ps) - ret.add((Item*)(const Item*)i); + ret.push((Item*)(const Item*)i); } return ret; } diff --git a/src/qlp.cc b/src/qlp.cc index 5aa8e9f45e..280f0db4cc 100644 --- a/src/qlp.cc +++ b/src/qlp.cc @@ -12,15 +12,15 @@ Mixed_qp::add_equality_cons(Vector , double ) void Mixed_qp::add_fixed_var(int i, Real r) { - eq_cons.add(i); - eq_consrhs.add(r); + eq_cons.push(i); + eq_consrhs.push(r); } void Ineq_constrained_qp::add_inequality_cons(Vector c, double r) { - cons.add(c); - consrhs.add(r); + cons.push(c); + consrhs.push(r); } Ineq_constrained_qp::Ineq_constrained_qp(int novars): @@ -96,7 +96,7 @@ Ineq_constrained_qp::assert_solution(Vector sol) const Real R=cons[i] * sol- consrhs[i]; assert(R> -EPS); if (R < EPS) - binding.add(i); + binding.push(i); } // KKT check... // todo diff --git a/src/sccol.cc b/src/sccol.cc index bbd0dba1ae..14c52796de 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -58,5 +58,5 @@ Score_column::add_duration(Moment d) if (d == durations[i]) return ; } - durations.add(d); + durations.push(d); } diff --git a/src/scores.cc b/src/scores.cc index bdd5371645..6ebbf18a17 100644 --- a/src/scores.cc +++ b/src/scores.cc @@ -25,7 +25,7 @@ do_scores() void add_score(Input_score * s) { - score_array_global.add(s); + score_array_global.push(s); } diff --git a/src/script.cc b/src/script.cc index eab30f9cbb..a6c3ee8039 100644 --- a/src/script.cc +++ b/src/script.cc @@ -5,15 +5,27 @@ #include "molecule.hh" #include "lookup.hh" -Script::Script(Script_req* rq, Item*i , int staflen, Stem*st_l) +NAME_METHOD(Script); + +void +Script::set_stem(Stem*st_l) { - dependencies.add(st_l); - dependencies.add(i); - + stem_l_ = st_l; + dependencies.push(st_l); +} + +void +Script::set_support(Item*i) +{ + support.push(i); + dependencies.push(i); +} + +Script::Script(Script_req* rq, int staflen) +{ staffsize =staflen; specs_l_ = rq->scriptdef; - support= i; - stem_l_ = st_l; + stem_l_ = 0; pos = 0; symdir=1; dir =rq->dir; @@ -37,6 +49,13 @@ Script::set_default_dir() } } +Interval +Script::support_height() const return r; +{ + for (int i=0; i < support.size(); i++) + r.unite(support[i]->height()); +} + void Script::set_default_pos() { @@ -46,12 +65,12 @@ Script::set_default_pos() int d = specs_l_->staffdir; Real y ; if (!d) { - Interval v= support->height(); + Interval v= support_height(); y = v[dir] -dy[-dir] + 2*dir*inter_f; } else { Real y = (d > 0) ? staffsize + 2: -2; // ug y *=inter_f; - Interval v= support->height(); + Interval v= support_height(); if (d > 0) { y = y >? v.max(); diff --git a/src/simplestaff.cc b/src/simplestaff.cc index e4e4986ef1..20f291fa8a 100644 --- a/src/simplestaff.cc +++ b/src/simplestaff.cc @@ -19,7 +19,7 @@ Simple_column::Simple_column(Score_column*s, Simple_staff *rs) staff_l_ = rs; beam_ = 0; text_=0; - lreq_p_ = 0; + } Simple_staff::Simple_staff() @@ -27,18 +27,10 @@ Simple_staff::Simple_staff() theline_l_ = 0; } -/** - accept: - - BREAK: all - TYPESET: bar, meter, -Scalar - */ - void -Simple_column::process_requests() +Simple_column::setup_requests() { for (int i = 0 ; i < v_elts.size(); i ++) for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { @@ -49,10 +41,10 @@ Simple_column::process_requests() } } if (rq->rhythmic()){ - notes.add(rq->rhythmic()); + notes.push(rq->rhythmic()); } if (rq->script()) { - notes.last().scripts.add(rq->script()); + notes.last().scripts.push(rq->script()); } if (rq->stem()) { stem_ = rq->stem(); @@ -61,16 +53,11 @@ Simple_column::process_requests() if (rq->text()) { text_ = rq->text(); } -#if 0 - if (rq->lreq_l()) { - lreq_p_ = rq->lreq_l(); - } -#endif if (rq->beam()) { beam_ = rq->beam(); } if (rq->slur()) { - slurs.add(rq->slur()); + slurs.push(rq->slur()); } } } @@ -85,7 +72,7 @@ void Simple_staff::walk() { for (Simple_walker sc(this); sc.ok(); sc++) { - sc.col()->process_requests();// TODO + sc.col()->setup_requests();// TODO sc.process(); } } diff --git a/src/simplewalker.cc b/src/simplewalker.cc index 8ac89bd2d0..05bc76c9b6 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -20,14 +20,14 @@ #include "slur.hh" #include "localkeyitem.hh" #include "textitem.hh" -#include "lyricitem.hh" + Rhythmic_grouping parse_grouping(Array a, Moment one_beat) { Array r; for (int i= 0 ; i < a.size(); i++) - r.add(a[i]); + r.push(a[i]); Moment here =0.0; Array children; @@ -35,7 +35,7 @@ parse_grouping(Array a, Moment one_beat) Moment last = here; here += one_beat * r[i]; - children.add( + children.push( new Rhythmic_grouping(MInterval(last, here), r[i] ) ); } @@ -120,14 +120,14 @@ Simple_walker::do_TYPESET_command(Command*com) void Simple_walker::do_local_key(Note_req*n,Notehead* head_p) { - if ( local_key_.oct(n->octave).acc(n->name) != n->accidental) { + if ( local_key_.oct(n->octave).acc(n->notename) != n->accidental) { if (!local_key_item_) { local_key_item_ = staff()->get_local_key_item(); local_key_item_->c0_position = clef_.c0_pos; } - - local_key_item_->add(n->octave, n->name, n->accidental, head_p); - local_key_.oct(n->octave).set(n->name, n->accidental); + local_key_item_->add(head_p); + local_key_item_->add(n->octave, n->notename, n->accidental); + local_key_.oct(n->octave).set(n->notename, n->accidental); } } @@ -136,10 +136,10 @@ Simple_walker::do_note(Note_info n) { Simple_column*c = col(); Simple_staff *s = staff(); - Item*rhythmic=0; + Item*rhythmic=0; if (n.rq->note()) { Note_req * req = n.rq->note() ; - const Voice *v = req->elt_l_->voice_; + const Voice *v = req->elt_l_->voice_l_; Notehead*n = s->get_notehead(req, clef_.c0_pos); rhythmic=n; @@ -150,7 +150,7 @@ Simple_walker::do_note(Note_info n) current_grouping->add_child( c->tdescription_->whole_in_measure, req->duration()); } - noteheads.add(n); + noteheads.push(n); int sidx =find_slur(v); if (sidx >= 0) { pending_slurs[sidx]->add(n); @@ -158,12 +158,16 @@ Simple_walker::do_note(Note_info n) if (wantkey) do_local_key(req,n); - }else if (n.rq->rest()) { + } else if (n.rq->rest()) { rhythmic = s->get_rest(n.rq->rest()); c->typeset_item(rhythmic); } - for (int i= 0; i < n.scripts.size(); i ++) - c->typeset_item(new Script(n.scripts[i], rhythmic, 10, stem_)); // UGR + for (int i= 0; i < n.scripts.size(); i ++) { + Script * s_p =new Script(n.scripts[i], 10); + s_p->set_support(rhythmic); + s_p->set_stem(stem_); + c->typeset_item(s_p); // UGR + } } void @@ -172,7 +176,7 @@ Simple_walker::process_requests() Simple_column*c = col(); Simple_staff *s = staff(); - if (c->beam_&& c->beam_->spantype == Span_req::START) { + if (c->beam_ && c->beam_->spantype == Span_req::START) { if (beam_) error("Too many beams (t = " +String(c->when())+")"); @@ -185,10 +189,10 @@ Simple_walker::process_requests() Slur_req*sl = c->slurs[i]; if (sl->spantype == Span_req::START) { - if (find_slur(sl->elt_l_->voice_ )>=0) + if (find_slur(sl->elt_l_->voice_l_)>=0) error_t("Too many slurs in voice", *col()->tdescription_); - pending_slur_reqs.add(sl); - pending_slurs.add(new Slur); + pending_slur_reqs.push(sl); + pending_slurs.push(new Slur); } } @@ -196,12 +200,8 @@ Simple_walker::process_requests() c->typeset_item(new Text_item(c->text_, 10)); // UGR } -// if (c->lreq_p_) { -// c->typeset_item(new Lyric_item(c->lreq_p_, 10)); // UGR -// } - if (c->stem_) { - stem_ = s->get_stem(c->stem_->stem(), c->stem_requester_len); + stem_ = s->get_stem(c->stem_->stem()); } for (int i = 0; i < c->notes.size(); i ++) { @@ -224,15 +224,19 @@ Simple_walker::process_requests() } if (c->beam_&& c->beam_->spantype == Span_req::STOP) { + if (!beam_) { + error_t("No beam to end", *col()->tdescription_); + } default_grouping.extend(current_grouping->interval()); beam_->set_grouping(default_grouping, *current_grouping); - pscore_->typeset_spanner(beam_, s->theline_l_); + pscore_l_->typeset_spanner(beam_, s->theline_l_); if (c->beam_->nplet) { - Text_spanner* t = new Text_spanner(beam_); + Text_spanner* t = new Text_spanner; + t->set_support(beam_); t->spec.align_i_ = 0; t->spec.text_str_ = c->beam_->nplet; - pscore_->typeset_spanner(t, s->theline_l_); + pscore_l_->typeset_spanner(t, s->theline_l_); } beam_ = 0; @@ -245,7 +249,7 @@ Simple_walker::process_requests() noteheads.set_size(0); if (local_key_item_) { - c->typeset_item_directional(local_key_item_, -1); + c->typeset_item(local_key_item_); local_key_item_ = 0; } if (stem_) { @@ -255,11 +259,11 @@ Simple_walker::process_requests() Slur_req *sl = c->slurs[i]; if (sl->spantype == Span_req::STOP) { - int idx = find_slur(sl->elt_l_->voice_); + int idx = find_slur(sl->elt_l_->voice_l_); if (idx < 0) error_t("can't find slur to end; ", *c->tdescription_); - pscore_->typeset_spanner(pending_slurs[idx], + pscore_l_->typeset_spanner(pending_slurs[idx], s->theline_l_); pending_slurs.del(idx); pending_slur_reqs.del(idx); @@ -267,7 +271,28 @@ Simple_walker::process_requests() } } +Simple_walker::Simple_walker(Simple_walker const&) + : Staff_walker(0, 0) +{ + assert(false); +} +Simple_walker::~Simple_walker() +{ + if (pending_slurs.size()) + WARN << "destructing " << pending_slurs.size() << " Pending slurs "; + if (beam_) + WARN << "destructing Beam\n"; + if (local_key_item_) + WARN<<"destructing Local_key_item\n"; + if (stem_) + WARN<< "destructing Stem\n"; + delete local_key_item_; + delete stem_; + delete beam_; + +} + Simple_walker::Simple_walker(Simple_staff*s) : Staff_walker(s, s->theline_l_->pscore_l_) { @@ -279,7 +304,7 @@ Simple_walker::Simple_walker(Simple_staff*s) wantkey =i; delete i; local_key_item_ = 0; - reset(); + do_post_move(); } @@ -287,7 +312,7 @@ Simple_walker::Simple_walker(Simple_staff*s) Simple_staff* Simple_walker::staff() { - return (Simple_staff*) staff_; + return (Simple_staff*) staff_l_; } Simple_column* @@ -297,7 +322,7 @@ Simple_walker::col() } void -Simple_walker::reset() +Simple_walker::do_post_move() { processed_clef =false; processed_key = false; @@ -308,7 +333,7 @@ int Simple_walker::find_slur(const Voice *v) { for (int i=0; i < pending_slur_reqs.size(); i++) { - if (pending_slur_reqs[i]->elt_l_->voice_ == v) + if (pending_slur_reqs[i]->elt_l_->voice_l_== v) return i; } return -1; diff --git a/src/slur.cc b/src/slur.cc index d4a3d0d96d..2cdddfec47 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -7,7 +7,7 @@ #include "molecule.hh" #include "debug.hh" #include "boxes.hh" - +NAME_METHOD(Slur); Slur::Slur() { dir = 0; @@ -30,8 +30,8 @@ Slur::center() const void Slur::add(Notehead*n) { - encompass.add(n); - dependencies.add(n); + encompass.push(n); + dependencies.push(n); } void @@ -50,12 +50,6 @@ Slur::set_default_dir() dir = 1; } -void -Slur::print()const -{ - mtor << "Slur.\n"; -} - void Slur::do_pre_processing() { @@ -72,7 +66,7 @@ Slur::do_break_at(PCol*l, PCol*r) const ret->encompass.set_size(0); for (int i =0; i < encompass.size(); i++) { if (encompass[i]->pcol_l_->line_l_==l->line_l_) - ret->encompass.add(encompass[i]); + ret->encompass.push(encompass[i]); } if (right != r) ret->open_right = true; diff --git a/src/spanner.cc b/src/spanner.cc index f6b4f92e80..ce3cb49162 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -2,6 +2,12 @@ #include "spanner.hh" #include "pcol.hh" +NAME_METHOD(Spanner); +void +Spanner::do_print()const +{ + mtor << " (unknown) "; +} Spanner* Spanner::broken_at(PCol*c1, PCol *c2)const { @@ -9,7 +15,7 @@ Spanner::broken_at(PCol*c1, PCol *c2)const Spanner *span_p = do_break_at(c1,c2); me_p->calc_children = true; - me_p->dependencies.add(span_p); + me_p->dependencies.push(span_p); span_p->calc_children = false; // should handle in ctor @@ -28,20 +34,10 @@ Spanner::Spanner() Interval Spanner::width()const { - Real r =right->hpos, - l= left->hpos; + Real r = right->hpos; + Real l = left->hpos; + assert(*left < *right); assert(r>=l); return Interval(0, r-l); } - -void -Spanner::print() const -{ -#ifndef NPRINT - mtor << "Spanner { "; - Staff_elem::print(); - mtor << "}\n"; -#endif -} - diff --git a/src/staff.cc b/src/staff.cc index 69fc3123b8..df46046c14 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -77,19 +77,19 @@ Staff::clean_cols() Staff_column * Staff::get_col(Moment w, bool mus) { - Score_column* sc = score_l_->find_col(w,mus); + Score_column* sccol_l = score_l_->find_col(w,mus); iter_top(cols,i); for (; i.ok(); i++) { - if (*i->score_column_l_ > *sc) // too far + if (*i->score_column_l_ > *sccol_l) // too far break; - if (sc == i->score_column_l_) + if (sccol_l == i->score_column_l_) return i; } /* post: *sc > *->score_column_l_ || !i.ok() */ - Staff_column* newst = create_col(sc); + Staff_column* newst = create_col(sccol_l); if (!i.ok()) { cols.bottom().add(newst); @@ -121,8 +121,8 @@ Staff::get_marks(Array&s_arr, Array&m_arr) for (iter_top(i->elts,j); j.ok(); j++) { for (iter_top(j->reqs, k); k.ok(); k++) { if (k->mark()) { // ugh. 4 levels - s_arr.add(k->mark()->mark_str_); - m_arr.add(now); + s_arr.push(k->mark()->mark_str_); + m_arr.push(now); } } now += j->duration; @@ -176,6 +176,15 @@ Staff::OK() const #ifndef NDEBUG cols.OK(); voices.OK(); + iter_top(cols, i); + iter_top(cols, j); + i++; + for (; i.ok(); j++,i++) { + if ( j->when() == i->when()) + assert(!j->mus() && i->mus()); + else + assert(j->when () < i->when() ); + } assert(score_l_); #endif } diff --git a/src/staffcommands.cc b/src/staffcommands.cc index 82286bd7d6..d1bbc45c42 100644 --- a/src/staffcommands.cc +++ b/src/staffcommands.cc @@ -156,14 +156,14 @@ Staff_commands_at::add(Command c) { /* every line a currentkey. */ Command kc; kc.code =TYPESET; - kc.args.add( "CURRENTKEY"); + kc.args.push( "CURRENTKEY"); kc.priority = 60; add(kc); } { /* every line a currentclef. */ Command kc; kc.code =TYPESET; - kc.args.add( "CURRENTCLEF"); + kc.args.push( "CURRENTCLEF"); kc.priority = 80; add(kc); } diff --git a/src/stcol.cc b/src/stcol.cc index 9d070aa4cc..89a572408a 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -35,7 +35,7 @@ Staff_column::add(Voice_element*ve) score_column_l_->add_duration(d); } - v_elts.add(ve); + v_elts.push(ve); } Staff_column::Staff_column(Score_column *s_l) diff --git a/src/stem.cc b/src/stem.cc index 85c4c15e2b..2e602c1cae 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -9,10 +9,10 @@ #include "misc.hh" const int STEMLEN=7; - -Stem::Stem(int c, Moment len) +NAME_METHOD(Stem); +Stem::Stem(int c) //, Moment len) { - note_length = len; +// note_length = len; beams_left = 0; beams_right = 0; minnote = 1000; // invalid values @@ -27,16 +27,11 @@ Stem::Stem(int c, Moment len) } void -Stem::print() const +Stem::do_print() const { #ifndef NPRINT - mtor << "{\n"; mtor << "flag "<< flag << " print_flag " << print_flag << "min,max [" << minnote << ", " << maxnote << "]"; - - - Item::print(); - mtor << "}\n"; #endif } void @@ -63,8 +58,8 @@ Stem::add(Notehead *n) minnote = p; if ( p> maxnote) maxnote = p; - heads.add(n); - n->dependencies.add(this); + heads.push(n); + n->dependencies.push(this); } diff --git a/src/tex.cc b/src/tex.cc index 9a10c993ea..1a5c4a08c5 100644 --- a/src/tex.cc +++ b/src/tex.cc @@ -36,7 +36,7 @@ substitute_args(String source, Array args) { Array sv; for (int i = 0 ; i < args.size(); i++) - sv.add(args[i]); + sv.push(args[i]); return substitute_args(source, sv); } diff --git a/src/textspanner.cc b/src/textspanner.cc index 86eac612cb..d4de8fb824 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -4,10 +4,23 @@ #include "textdef.hh" #include "debug.hh" -Text_spanner::Text_spanner(Directional_spanner*d) +NAME_METHOD(Text_spanner); + +void +Text_spanner::set_support(Directional_spanner*d) { support = d; - dependencies.add(d); + dependencies.push(d); +} +Text_spanner::Text_spanner() +{ + support = 0; +} + +void +Text_spanner::do_print() const +{ + spec.print(); } void @@ -35,14 +48,6 @@ Text_spanner::brew_molecule_p() const return output; } -void -Text_spanner::print() const // todo -{ -#ifndef NDEBUG - mtor << "Text_spanner\n"; -#endif -} - void Text_spanner::do_pre_processing() { @@ -60,5 +65,5 @@ Text_spanner::height()const Spanner* Text_spanner::do_break_at(PCol*c1, PCol*c2)const { - return new Text_spanner(*this); + return new Text_spanner(*this); // todo } -- 2.39.5