From eee89fa03bc21f734f6312e1e40a3aff73a4b1b3 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:27:40 +0000 Subject: [PATCH] lilypond-0.0.22 --- hdr/break.hh | 16 ++++---- hdr/clef.hh | 4 +- hdr/command.hh | 4 +- hdr/grouping.hh | 12 +++--- hdr/inputscore.hh | 6 +-- hdr/inputstaff.hh | 7 ++-- hdr/key.hh | 10 ++--- hdr/keyitem.hh | 8 ++-- hdr/leastsquares.hh | 4 +- hdr/linespace.hh | 8 ++-- hdr/localkeyitem.hh | 6 +-- hdr/meter.hh | 6 +-- hdr/pscore.hh | 75 +++++++++++++++++---------------- hdr/qlpsolve.hh | 6 +-- hdr/sccol.hh | 15 +++---- hdr/score.hh | 34 +++++++++------ hdr/scoreline.hh | 6 +-- hdr/slur.hh | 4 +- hdr/staffcommands.hh | 17 +------- hdr/staffelem.hh | 10 ++--- hdr/staffline.hh | 6 +-- hdr/stcol.hh | 14 ++++--- hdr/stem.hh | 4 +- src/beam.cc | 38 ++++++++--------- src/boxes.cc | 2 +- src/break.cc | 24 +++++------ src/calcideal.cc | 56 ++++++++----------------- src/command.cc | 4 +- src/grouping.cc | 62 ++++++++++++++-------------- src/inputcommands.cc | 31 +++++++------- src/inputscore.cc | 17 ++++---- src/inputstaff.cc | 12 +++--- src/key.cc | 22 +++++----- src/keyitem.cc | 10 ++--- src/leastsquares.cc | 4 +- src/linespace.cc | 32 +++++++-------- src/localkeyitem.cc | 4 +- src/molecule.cc | 4 +- src/pscore.cc | 98 ++++++++++++++++++++++++++++---------------- src/qlp.cc | 18 ++++---- src/qlpsolve.cc | 29 +++++++------ src/sccol.cc | 24 ++++++----- src/scoreline.cc | 10 ++--- src/scores.cc | 20 ++++----- src/simpleprint.cc | 28 ++++++------- src/slur.cc | 45 ++++++++++++-------- src/staffelem.cc | 25 +++++++---- src/stem.cc | 13 +++--- src/symbol.cc | 2 +- src/tex.cc | 12 +++--- src/wordwrap.cc | 18 ++++---- 51 files changed, 488 insertions(+), 458 deletions(-) diff --git a/hdr/break.hh b/hdr/break.hh index 4c0f6b33b6..4475e7d173 100644 --- a/hdr/break.hh +++ b/hdr/break.hh @@ -6,18 +6,18 @@ #ifndef BREAK_HH #define BREAK_HH -#include "vray.hh" +#include "varray.hh" #include "proto.hh" -typedef svec Line_of_cols; +typedef Array Line_of_cols; struct Col_configuration { Line_of_cols cols; - svec config; + Array config; Real energy; /****************/ void OK()const; - void setsol(svec); + void setsol(Array); Col_configuration() ; void add( PCol*c); void print() const; @@ -33,21 +33,21 @@ struct Break_algorithm { /// check if the spacing/breaking problem is well-stated void problem_OK()const; /// search all pcols which are breakable. - svec find_breaks() const; + Array find_breaks() const; /// helper: solve for the columns in #curline#. - svec solve_line(Line_of_cols) const; + Array solve_line(Line_of_cols) const; /// does curline fit on the paper? bool feasible(Line_of_cols)const; - virtual svec solve()=0; + virtual Array solve()=0; }; /// wordwrap type algorithm: move to next line if current is optimal. struct Word_wrap : Break_algorithm { - virtual svec solve(); + virtual Array solve(); Word_wrap(PScore&); }; #endif // BREAK_HH diff --git a/hdr/clef.hh b/hdr/clef.hh index 243ea6ebdd..3b61ca3bc7 100644 --- a/hdr/clef.hh +++ b/hdr/clef.hh @@ -7,14 +7,14 @@ #ifndef CLEF_HH #define CLEF_HH #include "scalar.hh" -#include "vray.hh" +#include "varray.hh" struct Clef { int c0_pos; String clef_type; Clef(); - void read(svec args); + void read(Array args); }; #endif // CLEF_HH diff --git a/hdr/command.hh b/hdr/command.hh index 43d016bbee..d4dda9411c 100644 --- a/hdr/command.hh +++ b/hdr/command.hh @@ -2,7 +2,7 @@ #define COMMAND_HH #include "glob.hh" -#include "vray.hh" +#include "varray.hh" #include "scalar.hh" enum Commandcode { @@ -17,7 +17,7 @@ struct Command { Commandcode code; /// analogous to argv[] - svec args; + Array args; /// int priority; diff --git a/hdr/grouping.hh b/hdr/grouping.hh index 9541123b9e..6e13f3217e 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -9,19 +9,19 @@ #include "moment.hh" #include "interval.hh" -#include "vray.hh" +#include "varray.hh" typedef Interval_t MInterval; /// data structure which represents rhythmic units struct Rhythmic_grouping { - svec children; + Array children; MInterval *interval_; /****************/ - svec intervals(); + Array intervals(); MInterval interval()const; Moment length() const; void intersect(MInterval); @@ -30,19 +30,19 @@ struct Rhythmic_grouping { Rhythmic_grouping(Rhythmic_grouping const&); Rhythmic_grouping(MInterval, int n=1); Rhythmic_grouping(); - Rhythmic_grouping(svec); + Rhythmic_grouping(Array); ~Rhythmic_grouping(); void add_child(Moment start, Moment len); void split(Rhythmic_grouping r); - void split(svec); + void split(Array); void split(int n); void print() const; void OK() const; - svec generate_beams(svec, int&); + Array generate_beams(Array, int&); private: void init(); diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index a34e6d9579..39e6a367fd 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -1,6 +1,6 @@ #ifndef ISCORE_HH #define ISCORE_HH -#include "vray.hh" +#include "varray.hh" #include "proto.hh" #include "plist.hh" @@ -14,8 +14,8 @@ struct Input_score { /****************************************************************/ Input_score(); - Input_score(Input_score&); - void add(svec &s); + Input_score(Input_score const&); + void add(Array &s); void add(Input_staff*); ~Input_score(); /// construction diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh index e2caea7dc2..6fac204643 100644 --- a/hdr/inputstaff.hh +++ b/hdr/inputstaff.hh @@ -9,7 +9,7 @@ #include "string.hh" #include "plist.hh" -#include "vray.hh" +#include "varray.hh" #include "proto.hh" struct Input_staff { @@ -22,10 +22,9 @@ struct Input_staff { void add(Input_music*m); Input_staff(Input_staff&); Input_staff(String); - void add(svec &s); - Staff* parse(PointerList); + void add(Array &s); + Staff* parse(PointerList, Score*); void print() const; - }; diff --git a/hdr/key.hh b/hdr/key.hh index f0141d688f..791c0861cf 100644 --- a/hdr/key.hh +++ b/hdr/key.hh @@ -7,17 +7,17 @@ #ifndef KEY_HH #define KEY_HH -#include "vray.hh" +#include "varray.hh" #include "scalar.hh" class Key { - svec accidentals; + Array accidentals; /****************/ public: - svec read(svec ); - svec oldkey_undo(svec); + Array read(Array ); + Array oldkey_undo(Array); Key(); void set(int i, int acc); @@ -31,7 +31,7 @@ struct Local_key Local_key(); private: - svec octaves; + Array octaves; }; #endif // KEY_HH diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index ffd0abeb9d..43ce9ca0a7 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -8,12 +8,12 @@ #define KEYITEM_HH #include "item.hh" -#include "vray.hh" +#include "varray.hh" /// struct Keyitem : Item { - svec pitch; - svec acc; + Array pitch; + Array acc; int c_position; @@ -21,7 +21,7 @@ struct Keyitem : Item { Keyitem(int cposition); void add(int pitch, int acc); - void read(svec k); + void read(Array k); void preprocess(); diff --git a/hdr/leastsquares.hh b/hdr/leastsquares.hh index 105efd0aa7..e7368e398b 100644 --- a/hdr/leastsquares.hh +++ b/hdr/leastsquares.hh @@ -6,11 +6,11 @@ #ifndef LEASTSQUARE_HH #define LEASTSQUARE_HH -#include "vray.hh" +#include "varray.hh" #include "offset.hh" struct Least_squares { - svec input; + Array input; void minimise(Real &coef, Real &offset); }; diff --git a/hdr/linespace.hh b/hdr/linespace.hh index 75f4b9fb74..50f13bd35c 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -3,7 +3,7 @@ #include "glob.hh" #include "plist.hh" -#include "vray.hh" +#include "varray.hh" #include "vector.hh" #include "interval.hh" @@ -29,8 +29,8 @@ struct Colinfo { /// spacing for one line. class Spacing_problem { - svec ideals; - svec cols; + Array ideals; + Array cols; /// the index of #c# in #cols# int col_id(const PCol *c) const; @@ -51,7 +51,7 @@ class Spacing_problem { public: /// solve the spacing problem - svec solve() const; + Array solve() const; /** return the column positions, and the energy (last element) */ diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index 05a468b973..6276977b77 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -7,7 +7,7 @@ #ifndef LOCALKEYITEM_HH #define LOCALKEYITEM_HH #include "item.hh" -#include "vray.hh" +#include "varray.hh" struct Local_acc { int name , acc, octave; @@ -15,8 +15,8 @@ struct Local_acc { }; struct Local_key_item : Item { - svec accs; - svec group; + Array accs; + Array group; int c0_position; // move into walker /****************/ diff --git a/hdr/meter.hh b/hdr/meter.hh index 33838c1525..ca364cf59c 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -7,13 +7,13 @@ #ifndef METER_HH #define METER_HH #include "item.hh" -#include "vray.hh" +#include "varray.hh" struct Meter: Item { - svec args; + Array args; /****************/ - Meter(svec args) ; + Meter(Array args) ; Molecule*brew_molecule() const; }; #endif // METER_HH diff --git a/hdr/pscore.hh b/hdr/pscore.hh index 8ad259412e..f796247353 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -4,13 +4,13 @@ #define PSCORE_HH #include "break.hh" -#include "vray.hh" +#include "varray.hh" #include "pcol.hh" #include "pstaff.hh" /// all stuff which goes onto paper struct PScore { - Paperdef *paper_; // indirection. + Paperdef *paper_l_; /// the columns, ordered left to right IPointerList cols; @@ -34,63 +34,62 @@ struct PScore { IPointerList broken_spans; /****************/ - - void add_broken(Spanner*); - - svec select_items(PStaff*, PCol*); - - /// before calc_breaking - void preprocess(); - - void calc_breaking(); - /** - calculate where the lines are to be broken. - - POST - - lines contain the broken lines. - */ - - /// after calc_breaking - void postprocess(); + /* CONSTRUCTION */ + PScore(Paperdef*); /// add a line to the broken stuff. Positions given in #config# - void set_breaking(svec< Col_configuration> ); + void set_breaking(Array); void add(PStaff *); /// add item void typeset_item(Item *, PCol *,PStaff*,int=1); - /// add an Spanner + /// add a Spanner void typeset_spanner(Spanner*, PStaff*); /// add to bottom of pcols void add(PCol*); - /** + void add_broken(Spanner*); + + /* INSPECTION */ + Array select_items(PStaff*, PCol*); + + /// return argument as a cursor. + PCursor find_col(const PCol *)const; + + /* MAIN ROUTINES */ + void process(); - */ + /// last deed of this struct void output(Tex_stream &ts); - Idealspacing* get_spacing(PCol *, PCol *); - /* - get the spacing between c1 and c2, create one if necessary. - */ + /* UTILITY ROUTINES */ - /// return argument as a cursor. - PCursor find_col(PCol *)const; + /// get the spacing between c1 and c2, create one if necessary. + Idealspacing* get_spacing(PCol *c1, PCol *c2); - /// delete unused columns - void clean_cols(); + /// connect c1 and c2 + void do_connect(PCol *c1, PCol *c2, Real distance_f, Real strength_f); - /// invarinants + /// connect c1 and c2 and any children of c1 and c2 + void connect(PCol* c1, PCol *c2, Real distance_f,Real strength_f= 1.0); + + /* STANDARD ROUTINES */ void OK()const; - - PScore(Paperdef*); void print() const; +private: + /// before calc_breaking + void preprocess(); + + /// calculate where the lines are to be broken, and use results + void calc_breaking(); - /// which is first (left, higher) - int compare_pcols( PCol*, PCol*)const; + /// after calc_breaking + void postprocess(); + + /// delete unused columns + void clean_cols(); }; /** notes, signs, symbols in a score can be grouped in two ways: horizontally (staffwise), and vertically (columns). #PScore# diff --git a/hdr/qlpsolve.hh b/hdr/qlpsolve.hh index 4d29bcc4a0..b9789bfc4a 100644 --- a/hdr/qlpsolve.hh +++ b/hdr/qlpsolve.hh @@ -7,8 +7,8 @@ class Active_constraints { Matrix A,H; - svec active; - svec inactive; // actually this is a set, not an array. + Array active; + Array inactive; // actually this is a set, not an array. const Ineq_constrained_qp *opt; public: @@ -71,7 +71,7 @@ public: int constraint_id() const { return ac->inactive[j]; } Vector vec() const { return ac->vec(constraint_id()); } Real rhs() const { return ac->rhs(constraint_id()); } - bool ok() const { return j < ac->inactive.sz(); } + bool ok() const { return j < ac->inactive.size(); } }; /** loop through the inactive constraints. diff --git a/hdr/sccol.hh b/hdr/sccol.hh index 8c1d82b3ae..615376309c 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -7,25 +7,23 @@ #ifndef SCCOL_HH #define SCCOL_HH #include "proto.hh" -#include "vray.hh" +#include "varray.hh" #include "moment.hh" struct Score_column { /// indirection to column - PCol * pcol_; + PCol * pcol_l_; /// length of notes/rests in this column - svec durations; + Array durations; - Moment when; - /// - bool musical; + bool musical_; /****************/ - + Moment when() { return when_; } Score_column(Moment when); static int compare(Score_column & c1, Score_column &c2); void add_duration(Moment ); @@ -33,6 +31,9 @@ struct Score_column { void set_breakable(); bool used(); void print() const; + +private: + Moment when_; }; /** diff --git a/hdr/score.hh b/hdr/score.hh index 5363b475cb..f58367c30e 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -1,6 +1,6 @@ #ifndef SCORE_HH #define SCORE_HH -#include "vray.hh" +#include "varray.hh" #include "proto.hh" #include "plist.hh" #include "moment.hh" @@ -8,12 +8,12 @@ /// the total music def of one movement struct Score { /// paper_, staffs_ and commands_ form the problem definition. - Paperdef *paper_; + Paperdef *paper_p_; IPointerList staffs_; /// "runtime" fields for setting up spacing IPointerList cols_; - PScore *pscore_; + PScore *pscore_p_; /****************************************************************/ @@ -22,22 +22,32 @@ struct Score { ~Score(); void add(Staff*); - - - void OK() const; - PCursor find_col(Moment,bool); + /// do everything except outputting to file void process(); + + /// output to file void output(String fn); - PCursor create_cols(Moment); + + // standard + void OK() const; void print() const; + + // utils: + PCursor create_cols(Moment); + PCursor find_col(Moment,bool); + /// when does the last *musical* element finish? Moment last() const; private: - void do_pcols(); + Score(Score const&){} + void do_cols(); + /** + make the pcol_l_ fields of each Score_column point to the correct PCol, + remove any unnecessary Score_column's + */ + + /// remove unused cols void clean_cols(); - void distribute_commands(); - void do_connect(PCol *c1, PCol *c2, Real d,Real); - void connect(PCol* c1, PCol *c2, Real d,Real = 1.0); /// add #Idealspacings# to #pscore_# void calc_idealspacing(); diff --git a/hdr/scoreline.hh b/hdr/scoreline.hh index 5734a7b4b4..233496932a 100644 --- a/hdr/scoreline.hh +++ b/hdr/scoreline.hh @@ -8,7 +8,7 @@ #define SCORELINE_HH #include "plist.hh" #include "proto.hh" -#include "vray.hh" +#include "varray.hh" /// the columns of a score that form one line. struct @@ -17,11 +17,11 @@ Line_of_score { // need to store height of each staff. IPointerList staffs; - PScore * pscore_; // needed to generate staffs + PScore * pscore_l_; // needed to generate staffs /****************/ void process() ; - Line_of_score(svec sv, PScore *); + Line_of_score(Array sv, PScore *); String TeXstring() const; diff --git a/hdr/slur.hh b/hdr/slur.hh index cf8c2261ab..9a3333f063 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -9,11 +9,11 @@ #include "directionalspanner.hh" #include "fproto.hh" -#include "vray.hh" +#include "varray.hh" struct Slur : Directional_spanner { - svec encompass; + Array encompass; //int dir; bool open_left,open_right; diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh index 633b73285c..e0e27be4be 100644 --- a/hdr/staffcommands.hh +++ b/hdr/staffcommands.hh @@ -6,7 +6,7 @@ #include "proto.hh" #include "command.hh" -#include "vray.hh" +#include "varray.hh" #include "plist.hh" #include "timedescription.hh" @@ -28,20 +28,5 @@ struct Staff_commands_at : public IPointerList { void add(Command c); }; -/// the list of commands in Score -struct Staff_commands : public IPointerList -{ - Staff_commands_at*find(Moment); - void add(Staff_commands_at*); - void clean(Moment last); - void OK() const; - void print() const; - Moment last() const; -}; -/** the list of commands in Score. Put in a separate class, since it - otherwise clutters the methods of Score. - - */ - #endif diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh index a12addbfac..bd10f216a8 100644 --- a/hdr/staffelem.hh +++ b/hdr/staffelem.hh @@ -6,7 +6,7 @@ #ifndef STAFFELEM_HH #define STAFFELEM_HH -#include "vray.hh" +#include "varray.hh" #include "proto.hh" #include "offset.hh" #include "molecule.hh" @@ -20,13 +20,13 @@ struct Staff_elem { OUTPUT, // molecule has been output } status; bool calc_children; - svec dependencies; + Array dependencies; - /// indirection to the pstaff it is in - PStaff *pstaff_; + /// the pstaff it is in + PStaff *pstaff_l_; /****************/ - + Staff_elem(Staff_elem const&); String TeXstring () const ; virtual void print() const; virtual Interval width() const; diff --git a/hdr/staffline.hh b/hdr/staffline.hh index 12d30c3764..663c9584b2 100644 --- a/hdr/staffline.hh +++ b/hdr/staffline.hh @@ -9,15 +9,15 @@ #include "real.hh" #include "plist.hh" -#include "vray.hh" +#include "varray.hh" #include "glob.hh" #include "pstaff.hh" /// one broken line of staff. struct Line_of_staff { - Line_of_score * line_of_score_; - PStaff *pstaff_; + Line_of_score * line_of_score_l_; + PStaff *pstaff_l_; /****************/ diff --git a/hdr/stcol.hh b/hdr/stcol.hh index 9e7501edc7..2bdd3b8bb9 100644 --- a/hdr/stcol.hh +++ b/hdr/stcol.hh @@ -7,19 +7,19 @@ #ifndef STCOL_HH #define STCOL_HH #include "proto.hh" -#include "vray.hh" +#include "varray.hh" #include "moment.hh" /// store simultaneous requests struct Staff_column { - /// indirection - Score_column *score_column; + + Score_column *score_column_l_; /// fields to collect data vertically. - svec v_elts; + Array v_elts; /// idem - Staff_commands_at *s_commands; + Staff_commands_at *staff_commands_p_; Time_description *tdescription_; @@ -29,7 +29,7 @@ struct Staff_column { bool mus() const; Moment when() const; void add(Voice_element*ve); - + void OK() const; /**************************************************************** VIRTUAL ****************************************************************/ @@ -37,6 +37,8 @@ struct Staff_column { virtual void process_requests()=0; virtual ~Staff_column(); +private: + Staff_column(Staff_column const&){} }; diff --git a/hdr/stem.hh b/hdr/stem.hh index ad2856b0f2..b7d7e05e29 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -7,7 +7,7 @@ #ifndef STEM_HH #define STEM_HH #include "item.hh" -#include "vray.hh" +#include "varray.hh" #include "moment.hh" /// the rule attached to the ball @@ -46,7 +46,7 @@ struct Stem : public Item { Real stem_xoffset; - svec heads; + Array heads; /****************/ Stem(int center, Moment duration); diff --git a/src/beam.cc b/src/beam.cc index 5edf3ce7eb..1016320dea 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -50,7 +50,6 @@ Beam::center()const Beam::Beam() { - group = 0; slope = 0; left_pos = 0.0; dir =0; @@ -85,7 +84,7 @@ Beam::set_default_dir() void Beam::solve_slope() { - svec sinfo; + Array sinfo; for (iter_top(stems,i); i.ok(); i++) { i->set_default_extents(); Stem_info info(i); @@ -93,14 +92,14 @@ Beam::solve_slope() } Real leftx = sinfo[0].x; Least_squares l; - for (int i=0; i < sinfo.sz(); i++) { + for (int i=0; i < sinfo.size(); i++) { sinfo[i].x -= leftx; l.input.add(Offset(sinfo[i].x, sinfo[i].idealy)); } l.minimise(slope, left_pos); Real dy = 0.0; - for (int i=0; i < sinfo.sz(); i++) { + for (int i=0; i < sinfo.size(); i++) { Real y = sinfo[i].x * slope + left_pos; Real my = sinfo[i].miny; @@ -113,7 +112,7 @@ Beam::solve_slope() // URG Real sl = slope*paper()->internote(); - paper()->lookup_->beam(sl, convert_dimen(20,"pt")); + paper()->lookup_p_->beam(sl, convert_dimen(20,"pt")); slope = sl /paper()->internote(); } @@ -141,28 +140,28 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) { def.OK(); cur.OK(); - assert(cur.children.sz() == stems.size()); + assert(cur.children.size() == stems.size()); cur.split(def); - group = new Rhythmic_grouping(cur); - svec b; + + Array b; { iter_top(stems,s); - svec flags; + Array flags; for (; s.ok(); s++) { int f = intlog2(abs(s->flag))-2; assert(f>0); flags.add(f); } int fi =0; - b= group->generate_beams(flags, fi); + b= cur.generate_beams(flags, fi); b.insert(0,0); b.add(0); - assert(stems.size() == b.sz()/2); + assert(stems.size() == b.size()/2); } iter_top(stems,s); - for (int i=0; i < b.sz() && s.ok(); i+=2, s++) { + for (int i=0; i < b.size() && s.ok(); i+=2, s++) { s->beams_left = b[i]; s->beams_right = b[i+1]; } @@ -179,8 +178,8 @@ Beam::do_break_at( PCol *, PCol *) const void Beam::do_pre_processing() { - left = (*stems.top()) ->pcol_; - right = (*stems.bottom())->pcol_; + left = (*stems.top()) ->pcol_l_; + right = (*stems.bottom())->pcol_l_; assert(stems.size()>1); if (!dir) set_default_dir(); @@ -207,7 +206,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const Real dy=paper()->internote()*2; Real stemdx = paper()->rule_thickness(); Real sl = slope*paper()->internote(); - paper()->lookup_->beam(sl, convert_dimen(20,"pt")); + paper()->lookup_p_->beam(sl, convert_dimen(20,"pt")); Molecule leftbeams; Molecule rightbeams; @@ -217,7 +216,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const int lhalfs= lhalfs = here->beams_left - prev->beams_right ; int lwholebeams= here->beams_left beams_right ; Real w = (here->hpos() - prev->hpos())/4; - Atom a = paper()->lookup_->beam(sl, w); + Atom a = paper()->lookup_p_->beam(sl, w); a.translate(Offset (-w, -w * sl)); for (int j = 0; j < lhalfs; j++) { Atom b(a); @@ -231,7 +230,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const int rwholebeams = here->beams_right beams_left; Real w = next->hpos() - here->hpos(); - Atom a = paper()->lookup_->beam(sl, w + stemdx); + Atom a = paper()->lookup_p_->beam(sl, w + stemdx); int j = 0; for (; j < rwholebeams; j++) { @@ -240,7 +239,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const rightbeams.add( b ); } w /= 4; - a = paper()->lookup_->beam(sl, w); + a = paper()->lookup_p_->beam(sl, w); for (; j < rwholebeams + rhalfs; j++) { Atom b(a); @@ -257,7 +256,6 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const Molecule* Beam::brew_molecule() const return out; { - assert(left->line == right->line); Real inter=paper()->internote(); out = new Molecule; Real x0 = stems.top()->hpos(); @@ -288,5 +286,5 @@ Beam::print()const Beam::~Beam() { - delete group; + } diff --git a/src/boxes.cc b/src/boxes.cc index d6564663a1..f83f7659e9 100644 --- a/src/boxes.cc +++ b/src/boxes.cc @@ -1,6 +1,6 @@ #include "boxes.hh" #include "const.hh" -#include "vray.hh" +#include "varray.hh" Box::Box() diff --git a/src/break.cc b/src/break.cc index e27abd9b84..2a0586edff 100644 --- a/src/break.cc +++ b/src/break.cc @@ -13,27 +13,25 @@ /* return all breakable columns */ -svec +Array Break_algorithm::find_breaks() const { - svec retval; + Array retval; for (iter_top(pscore_.cols,c); c.ok(); c++) if (c->breakable()) - - retval.add(c); return retval; } // construct an appropriate Spacing_problem and solve it. -svec +Array Break_algorithm::solve_line(Line_of_cols curline) const { Spacing_problem sp; sp.add_column(curline[0], true, 0.0); - for (int i=1; i< curline.sz()-1; i++) + for (int i=1; i< curline.size()-1; i++) sp.add_column(curline[i]); sp.add_column(curline.last(), true, linelength); @@ -41,21 +39,21 @@ Break_algorithm::solve_line(Line_of_cols curline) const for (iter_top(pscore_.suz,i); i.ok(); i++) { sp.add_ideal(i); } - svec the_sol=sp.solve(); + Array the_sol=sp.solve(); return the_sol; } Break_algorithm::Break_algorithm(PScore&s) :pscore_(s) { - linelength = s.paper_->linewidth; + linelength = s.paper_l_->linewidth; } bool Break_algorithm::feasible(Line_of_cols curline) const { Real l =0; - for (int i=0; i < curline.sz(); i++) + for (int i=0; i < curline.size(); i++) l +=curline[i]->width().length(); return l < linelength; } @@ -88,7 +86,7 @@ Col_configuration::add( PCol*c) } void -Col_configuration::setsol(svec sol) +Col_configuration::setsol(Array sol) { config = sol; energy = config.last(); @@ -100,11 +98,13 @@ Col_configuration::print() const { #ifndef NPRINT mtor << "energy : " << energy << '\n'; - mtor << "line of " << config.sz() << " cols\n"; + mtor << "line of " << config.size() << " cols\n"; #endif } void Col_configuration::OK()const { - assert(config.sz() == cols.sz()); +#ifndef NDEBUG + assert(config.size() == cols.size()); +#endif } diff --git a/src/calcideal.cc b/src/calcideal.cc index 77cef180ef..b6d3411508 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -9,32 +9,12 @@ #include "dimen.hh" -void -Score::do_connect(PCol *c1, PCol *c2, Real d, Real h) -{ - if (!c1 || !c2 ) - return; - Idealspacing*sp=pscore_->get_spacing(c1,c2); - - if (!sp->hooke){ - sp->hooke = h; - sp->space =d; - } -} - -void -Score::connect(PCol* c1, PCol *c2, Real d, Real 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. -/* this needs A LOT of rethinking. + generate springs between columns. - generate springs between columns. - */ + */ void Score::calc_idealspacing() { @@ -43,21 +23,20 @@ Score::calc_idealspacing() for (; i.ok(); i++) { assert(i->used()); PCursor j(i+1); - if (i->musical) { + if (i->musical_) { assert(j.ok()); - for (int n=0; n < i->durations.sz(); n++) { + for (int n=0; n < i->durations.size(); n++) { Moment d = i->durations[n]; - Real dist = paper_->duration_to_dist(d); - while (j->when < d + i->when) + Real dist = paper_p_->duration_to_dist(d); + while (j->when() < d + i->when()) j++; - - assert( j->when== d+i->when); + assert( j->when()== d+i->when()); - connect(i->pcol_, j->pcol_, dist); - if (!j->musical && (j+1).ok() - && (j+1)->when == j->when) { + pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); + if (!j->musical_ && (j+1).ok() + && (j+1)->when() == j->when()) { j++; - connect(i->pcol_, j->pcol_, dist); + pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); } } } else if (j.ok()) { @@ -66,14 +45,13 @@ Score::calc_idealspacing() the last col is breakable, and therefore in use */ - Moment d = j->when - i->when; - Real dist = (d) ? paper_->duration_to_dist(d) : + Moment d = j->when() - i->when(); + Real dist = (d) ? paper_p_->duration_to_dist(d) : convert_dimen(2,"pt"); // todo - connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0); + pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0); } - // !j.ok() might hold if we're at the last col. - + // !j.ok() might hold if we're at the last col. } } diff --git a/src/command.cc b/src/command.cc index 98be691cd3..7ddebc6f82 100644 --- a/src/command.cc +++ b/src/command.cc @@ -21,9 +21,9 @@ Command::print() const mtor << "Command " << "code " << code << " prio " << priority; if ( isbreak()) mtor << "(break separator)"; - if (args.sz()) { + if (args.size()) { mtor<< " args: "; - for (int i = 0; iOK(); if (i>0) assert(children[i-1]->interval().right == children[i]->interval().left); } +#endif } Moment @@ -48,7 +50,7 @@ Rhythmic_grouping::split(Rhythmic_grouping r) r.intersect(interval()); split(r.intervals()); - for (int i= 0; i < children.sz(); i++) { + for (int i= 0; i < children.size(); i++) { if (!children[i]->interval_) { Rhythmic_grouping here(r); children[i]->split(here); @@ -57,17 +59,17 @@ Rhythmic_grouping::split(Rhythmic_grouping r) } -svec +Array Rhythmic_grouping::intervals() { - svec r; - if (interval_ || children.sz() == 1) { + Array r; + if (interval_ || children.size() == 1) { MInterval i(interval()); MInterval r1(i), r2(i); r1.right = r2.left = i.center(); r.add(r1); r.add(r2); } else { - for (int i=0; i < children.sz(); i++) + for (int i=0; i < children.size(); i++) r.add(children[i]->interval()); } return r; @@ -80,7 +82,7 @@ Rhythmic_grouping::intersect(MInterval t) return; } - for (int i=0; i < children.sz(); i++) { + for (int i=0; i < children.size(); i++) { MInterval inter = intersection(t, children[i]->interval()); if (inter.empty() || inter.length() <= 0) { delete children[i]; @@ -89,7 +91,7 @@ Rhythmic_grouping::intersect(MInterval t) children[i]->intersect(t); } } - for (int i=0; i < children.sz(); ) { + for (int i=0; i < children.size(); ) { if (!children[i]) children.del(i); else @@ -99,14 +101,14 @@ Rhythmic_grouping::intersect(MInterval t) } void -Rhythmic_grouping::split(svec splitpoints) +Rhythmic_grouping::split(Array splitpoints) { //check on splitpoints.. int j = 0, i=0, starti = 0, startj = 0; - svec ch; + Array ch; while (1) { - if ( i >= children.sz() || j >= splitpoints.sz()) + if ( i >= children.size() || j >= splitpoints.size()) break; assert( @@ -152,7 +154,7 @@ Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n) } -Rhythmic_grouping::Rhythmic_grouping(svec r) +Rhythmic_grouping::Rhythmic_grouping(Array r) :children(r) { interval_ =0; @@ -168,7 +170,7 @@ void Rhythmic_grouping::copy(Rhythmic_grouping const&s) { interval_ = (s.interval_)? new MInterval(*s.interval_) : 0; - for (int i=0; i < s.children.sz(); i++) + for (int i=0; i < s.children.size(); i++) children.add(new Rhythmic_grouping(*s.children[i])); } @@ -189,7 +191,7 @@ void Rhythmic_grouping::junk() { delete interval_; - for (int i=0; i < children.sz(); i++) + for (int i=0; i < children.size(); i++) delete children[i]; init(); } @@ -201,7 +203,7 @@ Rhythmic_grouping::print()const mtor << "{ \n"; if (interval_) mtor<<" Interval "<< interval_->str(); - for (int i=0; i < children.sz(); i++) { + for (int i=0; i < children.size(); i++) { children[i]->print(); } mtor << "}\n"; @@ -212,14 +214,14 @@ void Rhythmic_grouping::add_child(Moment start, Moment len) { Moment stop = start+len; - for (int i=0; i < children.sz(); i ++) { + for (int i=0; i < children.size(); i ++) { MInterval j=children[i]->interval(); if (j.left == start && j.right==stop) { return; } } - if (children.sz()) + if (children.size()) assert ( children.last()->interval().right== start); children.add(new Rhythmic_grouping(MInterval(start, stop))); @@ -231,23 +233,23 @@ Rhythmic_grouping::Rhythmic_grouping() } int -min_elt(svec v) +min_elt(Array v) { int i = 1000; // ugh - for (int j = 0 ; j < v.sz(); j++) + for (int j = 0 ; j < v.size(); j++) i = i -Rhythmic_grouping::generate_beams(svec flags, int &flagidx) +Array +Rhythmic_grouping::generate_beams(Array flags, int &flagidx) { assert (!interval_) ; - svec< svec > children_beams; - for (int i=0; i < children.sz(); i++) { - svec child_beams; + Array< Array > children_beams; + for (int i=0; i < children.size(); i++) { + Array child_beams; if (children[i]->interval_) { int f = flags[flagidx++]; child_beams.add(f); @@ -257,18 +259,18 @@ Rhythmic_grouping::generate_beams(svec flags, int &flagidx) } children_beams.add(child_beams); } - svec beams; + Array beams; int lastm, m, nextm; - for (int i=0; i < children_beams.sz(); i++) { + for (int i=0; i < children_beams.size(); i++) { bool add_left = (i >0); - bool add_right = (i < children_beams.sz() -1); + bool add_right = (i < children_beams.size() -1); if (!i) m = min_elt(children_beams[i]); if (add_right) nextm = min_elt(children_beams[i+1]); - if (children_beams[i].sz() == 1) { + if (children_beams[i].size() == 1) { if (add_right) beams.add(m); if (add_left) @@ -283,7 +285,7 @@ Rhythmic_grouping::generate_beams(svec flags, int &flagidx) lastm = m; m = nextm; } - assert(!(beams.sz()%2)); + assert(!(beams.size()%2)); return beams; } diff --git a/src/inputcommands.cc b/src/inputcommands.cc index 64e8fa9598..90d6eeffa6 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -4,6 +4,8 @@ #include "staffcommands.hh" #include "getcommand.hh" #include "command.hh" +#include "stcol.hh" +#include "staff.hh" void Commands_at::print() const @@ -25,7 +27,7 @@ Commands_at::Commands_at(Moment dt, Commands_at* prev) : tdescription_(dt, (prev)? &prev->tdescription_ : 0) { if (prev&& !tdescription_.whole_in_measure) { - bottom().add(get_bar_command()); + bottom().add(get_newmeasure_command()); } } @@ -70,7 +72,7 @@ Commands_at::parse(Staff_commands_at*s) { s->tdescription_ = tdescription_; for (iter_top(*this,cc); cc.ok(); cc++) { - if (cc->args.sz() && cc->args[0] !="") { + if (cc->args.size() && cc->args[0] !="") { Command c = **cc; s->add(c); @@ -169,30 +171,31 @@ Input_commands::add(Input_command c) } -Staff_commands* -Input_commands::parse() const +void +Input_commands::parse(Staff * staff_l) const { print(); - Staff_commands*nc = new Staff_commands; - for (iter_top(*this,i); i.ok(); i++) { - Staff_commands_at* s= nc->find(i->when()); - if (!s){ - s = new Staff_commands_at(i->tdescription_); - nc->add(s); - } + Staff_column* col_l = staff_l->get_col(i->when(), false); + if (!col_l->staff_commands_p_) + col_l->staff_commands_p_ = new Staff_commands_at(i->tdescription_); + + Staff_commands_at * com_l = col_l->staff_commands_p_; + if (!i->when()) { /* all pieces should start with a breakable. */ + com_l->set_breakable(); + #if 0 Command c;//(0.0); c.code = INTERPRET; c.args.add("BAR"); c.args.add("empty"); - s->add(c); + com_l->add(c); + #endif } - i->parse(s); + i->parse(com_l); } - return nc; } diff --git a/src/inputscore.cc b/src/inputscore.cc index 8bbe7e266e..cdc348c725 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -6,10 +6,10 @@ #include "paper.hh" void -Input_score::add(svec &s) +Input_score::add(Array &s) { commands_.bottom().add(get_reset_command()); - for (int i=0; i < s.sz(); i++) + for (int i=0; i < s.size(); i++) commands_.bottom().add(s[i]); } @@ -29,19 +29,20 @@ Input_score::set(Paperdef*p) Score* Input_score::parse() { - Paperdef* p=new Paperdef(*paper_); - Score *s = new Score(p); + Paperdef* paper_p=new Paperdef(*paper_); + Score *s_p = new Score(paper_p); for (iter_top(staffs_,i); i.ok(); i++) { - Staff* staf=i->parse(commands_); - s->add(staf); + Staff* staf_p=i->parse(commands_, s_p); + s_p->add(staf_p); } - return s; + return s_p; } Input_score::~Input_score() { - // should fix paper/symtabs to allow this deletion. + // TODO! +//should fix paper/symtabs to allow this deletion. // delete paper_; } diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 97622a9dab..1786f3e293 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -10,10 +10,10 @@ #include "staff.hh" void -Input_staff::add(svec &s) +Input_staff::add(Array &s) { commands_.bottom().add(get_reset_command()); - for (int i=0; i < s.sz(); i++) + for (int i=0; i < s.size(); i++) commands_.bottom().add(s[i]); s.set_size(0); } @@ -30,7 +30,7 @@ Input_staff::add(Input_music*m) } Staff* -Input_staff::parse(PointerList score_wide) +Input_staff::parse(PointerList score_wide, Score*score_l) { Staff *p=0; @@ -38,7 +38,7 @@ Input_staff::parse(PointerList score_wide) p = new Melodic_staff; else if (type == "rhythmic") p = new Rhythmic_staff; - + p->score_l_ = score_l; for (iter_top(music_,i); i.ok(); i++) { Voice_list vl = i->convert(); p->add(vl); @@ -50,7 +50,7 @@ Input_staff::parse(PointerList score_wide) for (iter_top(commands_,i); i.ok(); i++) commands.add(**i); - p->staff_commands_ = commands.parse(); + commands.parse(p); return p; } @@ -60,7 +60,7 @@ Input_staff::Input_staff(Input_staff&s) for (iter_top(s.commands_,i); i.ok(); i++) commands_.bottom().add(new Input_command(**i)); for (iter_top(s.music_,i); i.ok(); i++) - add(i); + add(i->clone()); type = s.type; } diff --git a/src/key.cc b/src/key.cc index dac8c266ec..cd7f400737 100644 --- a/src/key.cc +++ b/src/key.cc @@ -36,14 +36,14 @@ Local_key::reset(Key k) octaves[i] = k; } -svec -Key::read(svec s) +Array +Key::read(Array s) { - svec newkey; + Array newkey; for (int j = 0; j < 7; j++) accidentals[j] = 0; - for (int i=0; i < s.sz(); ) { + for (int i=0; i < s.size(); ) { int large = s[i++]; int small = s[i++]; accidentals[large]=small; @@ -54,21 +54,21 @@ Key::read(svec s) return newkey; } -svec -Key::oldkey_undo(svecs) +Array +Key::oldkey_undo(Arrays) { - svec oldkey; - svec newkey; + Array oldkey; + Array newkey; newkey.set_size(7); - for (int i=0; i < newkey.sz(); i++) + for (int i=0; i < newkey.size(); i++) newkey[i] = 0; - for (int i=0; i < s.sz(); ) { + for (int i=0; i < s.size(); ) { int large = s[i++]; int small = s[i++]; newkey[large] = small; } - for (int i=0; i < newkey.sz(); i++) + for (int i=0; i < newkey.size(); i++) if (accidentals[i] && accidentals[i] != newkey[i]) { oldkey.add(i); oldkey.add(0); diff --git a/src/keyitem.cc b/src/keyitem.cc index 3499149352..29b1f25e5c 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -12,9 +12,9 @@ Keyitem::Keyitem(int c) } void -Keyitem::read(svec s) +Keyitem::read(Array s) { - for (int i = 0 ; i< s.sz(); ) { + for (int i = 0 ; i< s.size(); ) { int note = s[i++]; int acc = s[i++]; @@ -36,14 +36,14 @@ Keyitem::brew_molecule()const Molecule*output = new Molecule; Real inter = paper()->interline()/2; - for (int i =0; i < pitch.sz(); i++) { - Symbol s= paper()->lookup_->accidental(acc[i]); + for (int i =0; i < pitch.size(); i++) { + Symbol s= paper()->lookup_p_->accidental(acc[i]); Atom a(s); a.translate(Offset(0,(c_position + pitch[i]) * inter)); Molecule m(a); output->add_right(m); } - Molecule m(paper()->lookup_->fill(Box( + Molecule m(paper()->lookup_p_->fill(Box( Interval(0, paper()->note_width()), Interval(0,0)))); output->add_right(m); diff --git a/src/leastsquares.cc b/src/leastsquares.cc index 1e1c91cee3..adbc098219 100644 --- a/src/leastsquares.cc +++ b/src/leastsquares.cc @@ -8,7 +8,7 @@ Least_squares::minimise(Real &coef, Real &offset) Real sqx =0.0; Real sxy = 0.0; - for (int i=0; i < input.sz();i++) { + for (int i=0; i < input.size();i++) { Real x=input[i].x; Real y = input[i].y; sx += x; @@ -16,7 +16,7 @@ Least_squares::minimise(Real &coef, Real &offset) sqx += sqr(x); sxy += x*y; } - int N = input.sz(); + int N = input.size(); coef = (N * sxy - sx*sy )/(N*sqx - sqr(sx)); diff --git a/src/linespace.cc b/src/linespace.cc index f35f64e2fa..920d3ba7ab 100644 --- a/src/linespace.cc +++ b/src/linespace.cc @@ -12,7 +12,7 @@ const Real COLFUDGE=1e-3; bool Spacing_problem::contains(const PCol *w) { - for (int i=0; i< cols.sz(); i++) + for (int i=0; i< cols.size(); i++) if (cols[i].pcol_ == w) return true; return false; @@ -21,7 +21,7 @@ Spacing_problem::contains(const PCol *w) int Spacing_problem::col_id(const PCol *w)const { - for (int i=0; i< cols.sz(); i++) + for (int i=0; i< cols.size(); i++) if (cols[i].pcol_ == w) return i; assert(false); @@ -32,20 +32,20 @@ void Spacing_problem::OK() const { #ifndef NDEBUG - Union_find connected(cols.sz()); - svec fixed; - for (int i=0; i < ideals.sz(); i++) { + Union_find connected(cols.size()); + Array fixed; + for (int i=0; i < ideals.size(); i++) { assert(ideals[i]->hooke > 0); int l = col_id(ideals[i]->left); int r = col_id(ideals[i]->right); connected.connect(l,r); } - for (int i = 0; i < cols.sz(); i++) + for (int i = 0; i < cols.size(); i++) if (cols[i].fixed()) fixed.add(i); - for (int i = 0; i < cols.sz(); i++) { + for (int i = 0; i < cols.size(); i++) { bool c=false; - for (int j =0; jleft); int r = col_id(i->right); @@ -156,7 +156,7 @@ Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const void Spacing_problem::make_constraints(Mixed_qp& lp) const { - int dim=cols.sz(); + int dim=cols.size(); for (int j=0; j < dim; j++) { Colinfo *c=&(cols[j]); if (c->fixed()) { @@ -173,7 +173,7 @@ Spacing_problem::make_constraints(Mixed_qp& lp) const } } -svec +Array Spacing_problem::solve() const { print(); @@ -181,7 +181,7 @@ Spacing_problem::solve() const assert(check_feasible()); /* optimalisatiefunctie */ - Mixed_qp lp(cols.sz()); + Mixed_qp lp(cols.size()); make_matrices(lp.quad,lp.lin, lp.const_term); make_constraints(lp); Vector start=find_initial_solution(); @@ -191,7 +191,7 @@ Spacing_problem::solve() const } - svec posns(sol); + Array posns(sol); posns.add(lp.eval(sol)); return posns; } @@ -234,11 +234,11 @@ void Spacing_problem::print() const { #ifndef NPRINT - for (int i=0; i < cols.sz(); i++) { + for (int i=0; i < cols.size(); i++) { mtor << "col " << i<<' '; cols[i].print(); } - for (int i=0; i < ideals.sz(); i++) { + for (int i=0; i < ideals.size(); i++) { print_ideal(ideals[i]); } #endif diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc index 42bb268df0..d23b26277f 100644 --- a/src/localkeyitem.cc +++ b/src/localkeyitem.cc @@ -33,7 +33,7 @@ Local_key_item::brew_molecule()const Molecule* output = new Molecule; Molecule*octmol = 0; int lastoct = -100; - for (int i = 0; i < accs.sz(); i++) { + for (int i = 0; i < accs.size(); i++) { if (accs[i].octave != lastoct) { if (octmol){ Real dy =lastoct*7*paper()->interline()/2; @@ -44,7 +44,7 @@ Local_key_item::brew_molecule()const octmol= new Molecule; } lastoct = accs[i].octave; - Symbol s =paper()->lookup_->accidental(accs[i].acc); + Symbol s =paper()->lookup_p_->accidental(accs[i].acc); Atom a(s); Real dy = (accs[i].name + c0_position) * paper()->interline()/2; a.translate(Offset(0,dy)); diff --git a/src/molecule.cc b/src/molecule.cc index 6b9db4cac3..682204880d 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -1,4 +1,4 @@ -#include "vray.hh" +#include "varray.hh" #include "interval.hh" #include "dimen.hh" #include "string.hh" @@ -32,7 +32,7 @@ Atom::TeXstring() const { // whugh.. Hard coded... String s("\\placebox{%}{%}{%}"); - svec a; + Array a; a.add(print_dimen(off.y)); a.add(print_dimen(off.x)); a.add(sym.tex); diff --git a/src/pscore.cc b/src/pscore.cc index bd9154647d..696c542838 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -42,22 +42,45 @@ PScore::clean_cols() void PScore::add(PStaff *s) { - assert(s->pscore_ == this); + assert(s->pscore_l_ == this); staffs.bottom().add(s); } + +void +PScore::do_connect(PCol *c1, PCol *c2, Real d, Real h) +{ + if (!c1 || !c2 ) + return; + Idealspacing*s_l=get_spacing(c1,c2); + + if (!s_l->hooke){ + s_l->hooke = h; + s_l->space =d; + } +} + +void +PScore::connect(PCol* c1, PCol *c2, Real d, Real h) +{ + do_connect(c1,c2,d,h); + do_connect(c1->postbreak_p_, c2,d,h); + do_connect(c1, c2->prebreak_p_,d,h); + do_connect(c1->postbreak_p_, c2->prebreak_p_,d,h); +} + void PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) { assert(c && i && s); // assert(!breakstat != 4 || c->breakable() ); if (breakstat == 0) { - typeset_item(i, c->prebreak, s); + typeset_item(i, c->prebreak_p_, s); return; } if (breakstat == 2) { - typeset_item(i, c->postbreak, s); + typeset_item(i, c->postbreak_p_, s); return; } @@ -73,7 +96,7 @@ PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) void PScore::typeset_spanner(Spanner*span_p, PStaff*ps) { - span_p->pstaff_ = ps; + span_p->pstaff_l_ = ps; spanners.bottom().add(span_p); ps->spans.bottom().add(span_p); @@ -82,29 +105,20 @@ PScore::typeset_spanner(Spanner*span_p, PStaff*ps) } -int -PScore::compare_pcols(PCol*a, PCol*b)const -{ - PCursor ac(find_col(a)); - PCursor bc(find_col(b)); - assert(ac.ok() && bc.ok()); - return ac - bc; -} - void PScore::add(PCol *p) { - p->pscore_ = this; + p->pscore_l_ = this; if (p->breakable()){ - p->prebreak->pscore_ = this; - p->postbreak->pscore_ = this; + p->prebreak_p_->pscore_l_ = this; + p->postbreak_p_->pscore_l_ = this; } cols.bottom().add(p); } PScore::PScore( Paperdef*p) { - paper_ = p; + paper_l_ = p; } void @@ -112,7 +126,7 @@ PScore::output(Tex_stream &ts) { int l=1; - ts << "\n "<< paper_->lookup_->texsetting << "%(Tex id)\n"; + ts << "\n "<< paper_l_->lookup_p_->texsetting << "%(Tex id)\n"; for (iter_top(lines,lic); lic.ok(); lic++) { ts << "% line of score no. " << l++ <<"\n"; ts << lic->TeXstring(); @@ -122,13 +136,13 @@ PScore::output(Tex_stream &ts) } -svec -PScore::select_items(PStaff*ps , PCol*pc) +Array +PScore::select_items(PStaff*ps, PCol*pc) { - svec ret; + Array ret; assert(ps && pc); for (iter_top(pc->its,i); i.ok(); i++){ - if (i->pstaff_ == ps) + if (i->pstaff_l_ == ps) ret.add((Item*)(const Item*)i); } return ret; @@ -150,7 +164,7 @@ PScore::print() const { #ifndef NPRINT mtor << "PScore { "; - paper_->print(); + paper_l_->print(); mtor << "\ncolumns: "; for (iter_top(cols,cc); cc.ok(); cc++) cc->print(); @@ -196,34 +210,34 @@ PScore::postprocess() } PCursor -PScore::find_col(PCol *c)const +PScore::find_col(const PCol *c)const { - PCol*what = (PCol*)c; - if (what->daddy ) - what = what -> daddy; + const PCol*what = c; + if (what->daddy_l_ ) + what = what->daddy_l_; - return cols.find(what); + return cols.find((PCol*)what); } void PScore::add_broken(Spanner*s) { - assert(s->left->line == s->right->line); + assert(s->left->line_l_ == s->right->line_l_); broken_spans.bottom().add(s); s->left->starters.bottom().add (s); s->right->stoppers.bottom().add (s); } void -PScore::set_breaking(svec breaking) +PScore::set_breaking(Array breaking) { - for (int j=0; j < breaking.sz(); j++) { - svec &curline(breaking[j].cols); - svec &config(breaking[j].config); + for (int j=0; j < breaking.size(); j++) { + Array &curline(breaking[j].cols); + Array &config(breaking[j].config); - Line_of_score *p = new Line_of_score(curline,this); - lines.bottom().add(p); - for (int i=0; i < curline.sz(); i++){ + Line_of_score *s_p = new Line_of_score(curline,this); + lines.bottom().add(s_p); + for (int i=0; i < curline.size(); i++){ curline[i]->hpos = config[i]; } } @@ -235,3 +249,15 @@ PScore::calc_breaking() Word_wrap w(*this); set_breaking(w.solve()); } + +void +PScore::process() +{ + clean_cols(); + *mlog << "Preprocessing ... "; + preprocess(); + *mlog << "Calculating ... "; + calc_breaking(); + *mlog << "Postprocessing ... "; + postprocess(); +} diff --git a/src/qlp.cc b/src/qlp.cc index 460bd86423..5aa8e9f45e 100644 --- a/src/qlp.cc +++ b/src/qlp.cc @@ -34,7 +34,7 @@ void Ineq_constrained_qp::OK() const { #ifndef NDEBUG - assert(cons.sz() == consrhs.sz()); + assert(cons.size() == consrhs.size()); Matrix Qdif= quad - quad.transposed(); assert(Qdif.norm()/quad.norm() < EPS); #endif @@ -52,12 +52,12 @@ Mixed_qp::solve(Vector start) const print(); Ineq_constrained_qp pure(*this); - for (int i= eq_cons.sz()-1; i>=0; i--) { + for (int i= eq_cons.size()-1; i>=0; i--) { pure.eliminate_var(eq_cons[i], eq_consrhs[i]); start.del(eq_cons[i]); } Vector sol = pure.solve(start); - for (int i= 0; i < eq_cons.sz(); i++) { + for (int i= 0; i < eq_cons.size(); i++) { sol.insert( eq_consrhs[i],eq_cons[i]); } return sol; @@ -80,7 +80,7 @@ Ineq_constrained_qp::eliminate_var(int idx, Real value) row.del(idx); lin +=row ; - for (int i=0; i < cons.sz(); i++) { + for (int i=0; i < cons.size(); i++) { consrhs[i] -= cons[i](idx) *value; cons[i].del(idx); } @@ -91,8 +91,8 @@ Ineq_constrained_qp::eliminate_var(int idx, Real value) void Ineq_constrained_qp::assert_solution(Vector sol) const { - svec binding; - for (int i=0; i < cons.sz(); i++) { + Array binding; + for (int i=0; i < cons.size(); i++) { Real R=cons[i] * sol- consrhs[i]; assert(R> -EPS); if (R < EPS) @@ -109,7 +109,7 @@ Ineq_constrained_qp::print() const mtor << "Quad " << quad; mtor << "lin " << lin <<"\n" << "const " << const_term<<"\n"; - for (int i=0; i < cons.sz(); i++) { + for (int i=0; i < cons.size(); i++) { mtor << "constraint["<= " << consrhs[i]; mtor << "\n"; } @@ -137,7 +137,7 @@ Mixed_qp::OK() const { #ifndef NDEBUG Ineq_constrained_qp::OK(); - assert(eq_consrhs.sz() == eq_cons.sz()); + assert(eq_consrhs.size() == eq_cons.size()); #endif } @@ -146,7 +146,7 @@ Mixed_qp::print() const { #ifndef NPRINT Ineq_constrained_qp::print(); - for (int i=0; i < eq_cons.sz(); i++) { + for (int i=0; i < eq_cons.size(); i++) { mtor << "eq cons "<cons.sz()); + assert(active.size() +inactive.size() == opt->cons.size()); assert(H.dim() == opt->dim()); - assert(active.sz() == A.rows()); - svec allcons; + assert(active.size() == A.rows()); + Array allcons; - for (int i=0; i < opt->cons.sz(); i++) + for (int i=0; i < opt->cons.size(); i++) allcons.add(0); - for (int i=0; i < active.sz(); i++) { + for (int i=0; i < active.size(); i++) { int j = active[i]; allcons[j]++; } - for (int i=0; i < inactive.sz(); i++) { + for (int i=0; i < inactive.size(); i++) { int j = inactive[i]; allcons[j]++; } - for (int i=0; i < allcons.sz(); i++) + for (int i=0; i < allcons.size(); i++) assert(allcons[i] == 1); +#endif } Vector @@ -60,7 +63,7 @@ Active_constraints::add(int k) int cidx=inactive[k]; active.add(cidx); - inactive.swap(k,inactive.sz()-1); + inactive.swap(k,inactive.size()-1); inactive.pop(); Vector a( opt->cons[cidx] ); @@ -92,7 +95,7 @@ Active_constraints::add(int k) void Active_constraints::drop(int k) { - int q=active.sz()-1; + int q=active.size()-1; // drop indices inactive.add(active[k]); @@ -124,7 +127,7 @@ Active_constraints::Active_constraints(Ineq_constrained_qp const *op) H(op->dim()), opt(op) { - for (int i=0; i < op->cons.sz(); i++) + for (int i=0; i < op->cons.size(); i++) inactive.add(i); Choleski_decomposition chol(op->quad); H=chol.inverse(); diff --git a/src/sccol.cc b/src/sccol.cc index ec8784a9bd..bbd0dba1ae 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -5,35 +5,37 @@ int Score_column::compare(Score_column & c1, Score_column &c2) { - return sign(c1.when - c2.when); + return sign(c1.when_ - c2.when_); } void -Score_column::set_breakable() { - pcol_->set_breakable(); +Score_column::set_breakable() +{ + pcol_l_->set_breakable(); } + Score_column::Score_column(Moment w) { - when = w; - pcol_ = new PCol(0); - musical = false; + when_ = w; + pcol_l_ = new PCol(0); + musical_ = false; } bool Score_column::used() { - return pcol_->used(); + return pcol_l_->used(); } void Score_column::print() const { #ifndef NPRINT - mtor << "Score_column { mus "<< musical <<" at " << when<<'\n'; + mtor << "Score_column { mus "<< musical_ <<" at " << when_<<'\n'; mtor << "durations: ["; - for (int i=0; i < durations.sz(); i++) + for (int i=0; i < durations.size(); i++) mtor << durations[i] << " "; mtor << "]\n"; - pcol_->print(); + pcol_l_->print(); mtor << "}\n"; #endif } @@ -52,7 +54,7 @@ Score_column::preprocess() void Score_column::add_duration(Moment d) { - for (int i = 0; i< durations.sz(); i++) { + for (int i = 0; i< durations.size(); i++) { if (d == durations[i]) return ; } diff --git a/src/scoreline.cc b/src/scoreline.cc index 39c13c48b8..ed28c5b543 100644 --- a/src/scoreline.cc +++ b/src/scoreline.cc @@ -22,17 +22,17 @@ Line_of_score::TeXstring() const } -Line_of_score::Line_of_score(svec sv, +Line_of_score::Line_of_score(Array sv, PScore *ps) { - pscore_ = ps; - for (int i=0; i< sv.sz(); i++) { + pscore_l_ = ps; + for (int i=0; i< sv.size(); i++) { PCol *p=(PCol *) sv[i]; cols.bottom().add(p); - p->line=this; + p->line_l_=this; } - for (iter_top(pscore_->staffs,sc); sc.ok(); sc++) + for (iter_top(pscore_l_->staffs,sc); sc.ok(); sc++) staffs.bottom().add(new Line_of_staff(this, sc)); } /* construct a line with the named columns. Make the line field diff --git a/src/scores.cc b/src/scores.cc index 1d0679c534..1b7b6558de 100644 --- a/src/scores.cc +++ b/src/scores.cc @@ -3,7 +3,7 @@ #include "score.hh" #include "string.hh" -static svec sv; +static Array score_array_global; static String outfn="lelie.uit"; @@ -11,21 +11,21 @@ static String outfn="lelie.uit"; void do_scores() { - for (int i=0; i < sv.sz(); i++) { - Score * s = sv[i]->parse(); - delete sv[i]; - - s->process(); - s->output(outfn); - delete s; + for (int i=0; i < score_array_global.size(); i++) { + Score * s_p = score_array_global[i]->parse(); + delete score_array_global[i]; + s_p->print (); + s_p->process(); + s_p->output(outfn); + delete s_p; } - sv.set_size(0); + score_array_global.set_size(0); } void add_score(Input_score * s) { - sv.add(s); + score_array_global.add(s); } diff --git a/src/simpleprint.cc b/src/simpleprint.cc index b3f2ac40c0..de3d6ec921 100644 --- a/src/simpleprint.cc +++ b/src/simpleprint.cc @@ -13,7 +13,7 @@ Item * Simple_staff::get_TYPESET_item(Command *com) { Item *s=0; - svec arg( com->args); + Array arg( com->args); String type =arg[0]; arg.del(0); if (type == "BAR" ) { @@ -32,12 +32,12 @@ Simple_staff::get_TYPESET_item(Command *com) Interval -itemlist_width(const svec &its) +itemlist_width(const Array &its) { Interval iv ; iv.set_empty(); - for (int j =0; j < its.sz(); j++){ + for (int j =0; j < its.size(); j++){ iv.unite (its[j]->width()); } @@ -49,18 +49,18 @@ Simple_column::typeset_item(Item *i, int breakst) { assert(i); - staff_->pscore_->typeset_item(i, score_column->pcol_, + staff_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, staff_->theline,breakst); if (breakst == BREAK_PRE - BREAK_PRE) { - svec to_move( - staff_->pscore_->select_items(staff_->theline, - score_column->pcol_->prebreak)); + Array to_move( + staff_->pscore_l_->select_items(staff_->theline, + score_column_l_->pcol_l_->prebreak_p_)); Interval column_wid = itemlist_width(to_move); assert(!column_wid.empty()); - for (int j=0; j < to_move.sz(); j++) { + for (int j=0; j < to_move.size(); j++) { to_move[j]->translate(Offset(-column_wid.right, 0)); } } @@ -70,13 +70,13 @@ void Simple_column::typeset_item_directional(Item *i, int dir, int breakst) { assert(i); - PCol * c=score_column->pcol_; + PCol * c=score_column_l_->pcol_l_; if (breakst == 0) - c = c->prebreak; + c = c->prebreak_p_; else if (breakst == 2) - c = c->postbreak; + c = c->postbreak_p_; - svec to_move(staff_->pscore_->select_items(staff_->theline, + Array to_move(staff_->pscore_l_->select_items(staff_->theline, c)); typeset_item(i, breakst); @@ -89,8 +89,8 @@ Simple_column::typeset_item_directional(Item *i, int dir, int breakst) void Simple_staff::set_output(PScore* ps ) { - pscore_ = ps; - pscore_->add(theline); + pscore_l_ = ps; + pscore_l_->add(theline); } diff --git a/src/slur.cc b/src/slur.cc index 15a94cf8c3..e5dbf385ac 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -38,12 +38,12 @@ void Slur::set_default_dir() { int sumpos=0; - for (int i=0; i < encompass.sz(); i ++) { + for (int i=0; i < encompass.size(); i ++) { sumpos += encompass[i]->position; } /* should consult stems */ - Real meanpos = sumpos/Real(encompass.sz()); + Real meanpos = sumpos/Real(encompass.size()); if (meanpos < 5) // todo dir = -1; else @@ -59,19 +59,19 @@ Slur::print()const void Slur::do_pre_processing() { - right = encompass.last()->pcol_; - left = encompass[0]->pcol_; + right = encompass.last()->pcol_l_; + left = encompass[0]->pcol_l_; } Spanner* Slur::do_break_at(PCol*l, PCol*r) const { - assert(l->line == r->line); + assert(l->line_l_ == r->line_l_); Slur*ret = new Slur(*this); ret->encompass.set_size(0); - for (int i =0; i < encompass.sz(); i++) { - if (encompass[i]->pcol_->line==l->line) + for (int i =0; i < encompass.size(); i++) { + if (encompass[i]->pcol_l_->line_l_==l->line_l_) ret->encompass.add(encompass[i]); } if (right != r) @@ -93,32 +93,41 @@ Molecule* Slur::brew_molecule() const { Molecule*output = new Molecule; - assert(left->line == right->line); + int minp=1000, maxp=-1000; // todo - for (int i=0; iposition position >? maxp; } - assert(encompass.sz()>0); // todo + assert(encompass.size()>0); // todo Notehead *lnote_p =encompass[0]; Notehead *rnote_p =encompass.last(); - int pos1 = lnote_p->position; - int pos2 = rnote_p->position; - - int dy = pos2-pos1; + int lpos_i = lnote_p->position; + int rpos_i = rnote_p->position; + Offset left_off(lnote_p->x_dir, lpos_i + 2*dir); + Offset right_off(lnote_p->x_dir, rpos_i + 2*dir); + if (!lnote_p->extremal) + left_off += Offset(0.5, -dir); + if (!rnote_p->extremal) + right_off+= Offset(-0.5, -dir); + + int dy = right_off.y - left_off.y; + Real nw_f = paper()->note_width(); + Real nh_f = paper()->internote(); Real w = width().length(); - w+= (-lnote_p->x_dir + rnote_p->x_dir)* nw_f ; + + w+= (right_off.x - left_off.x) * nw_f ; Real round_w = w; // slur lookup rounds the slurwidth . - Symbol sl = paper()->lookup_->slur(dy , round_w, dir); + Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir); Real error = w-round_w; Atom a(sl); - a.translate(Offset((lnote_p->x_dir + 0.5 )*nw_f + error/2, - (pos2+2*dir) * paper()->internote())); + a.translate(Offset((left_off.x + 0.5 )*nw_f + error/2, + left_off.y * nh_f)); output->add(a); return output; } diff --git a/src/staffelem.cc b/src/staffelem.cc index bf76a9eb70..d942732e7c 100644 --- a/src/staffelem.cc +++ b/src/staffelem.cc @@ -7,12 +7,23 @@ String Staff_elem::TeXstring() const { - assert(output && !calc_children); + assert(!calc_children); Molecule m(*output); m.translate(offset_); // ugh? return m.TeXstring(); } +Staff_elem::Staff_elem(Staff_elem const&s) + : dependencies(s.dependencies) +{ + status = s.status; + assert(!s.output); + output = 0; + pstaff_l_ = s.pstaff_l_; + calc_children = false; + offset_ = Offset(0,0); +} + Staff_elem::~Staff_elem() { delete output; @@ -60,7 +71,7 @@ Staff_elem::print()const Staff_elem::Staff_elem() { calc_children = false; - pstaff_=0; + pstaff_l_=0; offset_ = Offset(0,0); output = 0; status = ORPHAN; @@ -70,8 +81,8 @@ Staff_elem::Staff_elem() Paperdef* Staff_elem::paper() const { - assert(pstaff_); - return pstaff_->pscore_->paper_; + assert(pstaff_l_); + return pstaff_l_->pscore_l_->paper_l_; } void @@ -89,7 +100,7 @@ Staff_elem::pre_processing() { if (status >= PRECALCED ) return; - for (int i=0; i < dependencies.sz(); i++) + for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->pre_processing(); if (!calc_children) @@ -101,7 +112,7 @@ Staff_elem::post_processing() { if (status > POSTCALCED) return; - for (int i=0; i < dependencies.sz(); i++) + for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->post_processing(); if (!calc_children) @@ -114,7 +125,7 @@ Staff_elem::molecule_processing() { if (status >= OUTPUT) return; - for (int i=0; i < dependencies.sz(); i++) + for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->molecule_processing(); if (!calc_children) diff --git a/src/stem.cc b/src/stem.cc index df250aa8d3..66b1aadb33 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -116,9 +116,11 @@ void Stem::set_noteheads() { heads.sort(Notehead::compare); + heads[0]->extremal = -1; + heads.last()->extremal = 1; int parity=1; int lastpos = heads[0]->position; - for (int i=1; i < heads.sz(); i ++) { + for (int i=1; i < heads.size(); i ++) { int dy =abs(lastpos- heads[i]->position); if (dy <= 1) { @@ -146,7 +148,7 @@ Stem::width()const if (!print_flag || abs(flag) <= 4) return Interval(0,0); // TODO! Paperdef*p= paper(); - Interval r(p->lookup_->flag(flag).dim.x); + Interval r(p->lookup_p_->flag(flag).dim.x); r+= stem_xoffset; return r; } @@ -154,20 +156,19 @@ Stem::width()const Molecule* Stem::brew_molecule()const return out; { - assert(pstaff_); assert(bot!=top); Paperdef *p =paper(); Real dy = p->internote(); - Symbol ss =p->lookup_->stem(bot*dy,top*dy); + Symbol ss =p->lookup_p_->stem(bot*dy,top*dy); out = new Molecule(Atom(ss)); if (print_flag&&abs(flag) > 4){ - Symbol fl = p->lookup_->flag(flag); + Symbol fl = p->lookup_p_->flag(flag); Molecule m(fl); if (flag < -4){ out->add_bottom(m); @@ -183,7 +184,7 @@ Stem::brew_molecule()const return out; Real Stem::hpos()const { - return pcol_->hpos + stem_xoffset; + return pcol_l_->hpos + stem_xoffset; } diff --git a/src/symbol.cc b/src/symbol.cc index d9ffea7afb..01b235679b 100644 --- a/src/symbol.cc +++ b/src/symbol.cc @@ -1,5 +1,5 @@ #include "symbol.hh" -#include "vray.hh" +#include "varray.hh" Symbol::Symbol() diff --git a/src/tex.cc b/src/tex.cc index 372536c20a..9a10c993ea 100644 --- a/src/tex.cc +++ b/src/tex.cc @@ -2,7 +2,7 @@ #include "tex.hh" #include "symbol.hh" #include "const.hh" -#include "vray.hh" +#include "varray.hh" String vstrut(Real h) @@ -22,20 +22,20 @@ substitute_arg(String& r, String arg) String -substitute_args(String source, svec args) +substitute_args(String source, Array args) { String retval (source); - for (int i = 0 ; i < args.sz(); i++) + for (int i = 0 ; i < args.size(); i++) substitute_arg(retval, args[i]); while (retval.pos('%')) substitute_arg(retval, ""); return retval; } String -substitute_args(String source, svec args) +substitute_args(String source, Array args) { - svec sv; - for (int i = 0 ; i < args.sz(); i++) + Array sv; + for (int i = 0 ; i < args.size(); i++) sv.add(args[i]); return substitute_args(source, sv); diff --git a/src/wordwrap.cc b/src/wordwrap.cc index ec6ac16395..d0bfd5b74f 100644 --- a/src/wordwrap.cc +++ b/src/wordwrap.cc @@ -9,25 +9,25 @@ */ -svec +Array Word_wrap::solve() { problem_OK(); iter_top(pscore_.cols,curcol); - svec breaking; - svec breakpoints(find_breaks()); - assert(breakpoints.sz()>=2); - for (int i=0 ; i < breakpoints.sz() -1; ) { + Array breaking; + Array breakpoints(find_breaks()); + assert(breakpoints.size()>=2); + for (int i=0 ; i < breakpoints.size() -1; ) { Col_configuration minimum; Col_configuration current; // do another line - PCol *post = breakpoints[i]->postbreak; + PCol *post = breakpoints[i]->postbreak_p_; current.add( post); curcol++; // skip the breakable. i++; - while (i < breakpoints.sz()) { + while (i < breakpoints.size()) { // add another measure. while (breakpoints[i] != curcol.ptr()){ @@ -35,9 +35,9 @@ Word_wrap::solve() current.add(curcol); curcol++; } - current.add(breakpoints[i]->prebreak ); + current.add(breakpoints[i]->prebreak_p_ ); if (!feasible(current.cols)) { - if (!minimum.cols.sz()) + if (!minimum.cols.size()) error("sorry, this measure is too long"); break; } -- 2.39.5