From 2690cfa8ef38d2f857e1e3c3cecbfe25dd3561ce Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:33:21 +0000 Subject: [PATCH] lilypond-0.0.35 --- hdr/complexstaff.hh | 1 - hdr/registergroup.hh | 38 +++++++++++++++++++++ hdr/scorecolumn.hh | 59 +++++++++++++++++++++++++++++++++ hdr/staffcolumn.hh | 47 ++++++++++++++++++++++++++ src/calcideal.cc | 2 +- src/complexstaff.cc | 2 +- src/lyricwalker.cc | 2 +- src/scorecolumn.cc | 77 +++++++++++++++++++++++++++++++++++++++++++ src/scorewalker.cc | 2 +- src/template2.cc | 12 +++++-- src/template4.cc | 8 +++++ src/template6.cc | 4 ++- src/voicegroupregs.cc | 70 +++++++++++++++++++++++++++++++++++++++ src/voiceregs.cc | 61 ++++++++-------------------------- 14 files changed, 329 insertions(+), 56 deletions(-) create mode 100644 hdr/registergroup.hh create mode 100644 hdr/scorecolumn.hh create mode 100644 hdr/staffcolumn.hh create mode 100644 src/scorecolumn.cc create mode 100644 src/voicegroupregs.cc diff --git a/hdr/complexstaff.hh b/hdr/complexstaff.hh index b7d0c714d9..74ecef4732 100644 --- a/hdr/complexstaff.hh +++ b/hdr/complexstaff.hh @@ -9,7 +9,6 @@ #include "key.hh" -#include "stcol.hh" #include "staff.hh" #include "staffwalker.hh" diff --git a/hdr/registergroup.hh b/hdr/registergroup.hh new file mode 100644 index 0000000000..c3a4df4a62 --- /dev/null +++ b/hdr/registergroup.hh @@ -0,0 +1,38 @@ +/* + registergroup.hh -- declare + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef REGISTERGROUP_HH +#define REGISTERGROUP_HH + + +#include "plist.hh" +#include "staffeleminfo.hh" +/** + Group a number of registers. Usually delegates everything to its contents. + */ +class Register_group { +public: + IPointerList reg_list_; + + void set_dir(int i); + bool acceptable_request_b(Request*); + void pre_move_processing(); + void post_move_processing(); + void acknowledge_element(Staff_elem_info info); + bool try_request(Request*); + void process_requests(); + virtual ~Register_group(); + void add(Request_register* reg_p); + bool contains_b(Request_register*); +// bool contains_b(Register_group*); +}; + +#endif // REGISTERGROUP_HH + + diff --git a/hdr/scorecolumn.hh b/hdr/scorecolumn.hh new file mode 100644 index 0000000000..e961d04920 --- /dev/null +++ b/hdr/scorecolumn.hh @@ -0,0 +1,59 @@ +/* + sccol.hh -- part of LilyPond + + (c) 1996,97 Han-Wen Nienhuys +*/ + +#ifndef SCCOL_HH +#define SCCOL_HH +#include "proto.hh" +#include "varray.hh" +#include "moment.hh" + + +/** + + When typesetting hasn't started on PScore yet, the columns which + contain data have a rhythmical position. Score_column is the type + with a rhythmical time attached to it. The calculation of + idealspacing is done with data in these columns. (notably: the + #durations# field) + + */ + +class Score_column { + friend class Score; + friend class Score_walker; + + bool musical_b_; + Moment when_; + void set_breakable(); +public: + /// indirection to column + PCol * pcol_l_; + + /// length of notes/rests in this column + Array durations; + + /* *************** */ + + Moment when() { return when_; } + Score_column(Moment when); + static int compare(Score_column & c1, Score_column &c2); + void add_duration(Moment ); + void preprocess(); + bool breakable_b(); + bool musical_b() { return musical_b_; } + bool used_b(); + void print() const; + + +}; + +instantiate_compare(Score_column&, Score_column::compare); + +#endif // SCCOL_HH + + + + diff --git a/hdr/staffcolumn.hh b/hdr/staffcolumn.hh new file mode 100644 index 0000000000..d80b6fa7b3 --- /dev/null +++ b/hdr/staffcolumn.hh @@ -0,0 +1,47 @@ +/* + staffcolumn.hh -- declare Staff_column + + (c) 1996,97 Han-Wen Nienhuys +*/ + +#ifndef STAFFCOLUMN_HH +#define STAFFCOLUMN_HH +#include "proto.hh" +#include "varray.hh" +#include "moment.hh" + +/// store simultaneous requests +class Staff_column { + + Staff_column(Staff_column const&); + +public: + Array musicalreq_l_arr_; + Array commandreq_l_arr_; + Staff * staff_l_; + + /// fields to collect timing data vertically. + Array timing_req_l_arr_; + Score_column *musical_column_l_, *command_column_l_; + + /* *************** */ + + Staff_column(); + + Moment when() const; + void set_cols(Score_column *c1, Score_column *c2); + void add(Voice_element*ve); + void OK() const; + ~Staff_column(); + void typeset_breakable_items(Array &pre_p_arr, + Array &nobreak_p_arr, + Array &post_p_arr); + void typeset_musical_item(Item *i); +protected: + void setup_one_request(Request*); +}; + + + +#endif // STAFFCOLUMN_HH + diff --git a/src/calcideal.cc b/src/calcideal.cc index 08180c64fb..1a96243426 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -2,7 +2,7 @@ #include "score.hh" #include "pscore.hh" #include "paperdef.hh" -#include "sccol.hh" +#include "scorecolumn.hh" #include "dimen.hh" diff --git a/src/complexstaff.cc b/src/complexstaff.cc index 9eb84cb59a..627b5745e2 100644 --- a/src/complexstaff.cc +++ b/src/complexstaff.cc @@ -7,7 +7,7 @@ #include "pscore.hh" #include "bar.hh" #include "meter.hh" -#include "sccol.hh" +#include "scorecolumn.hh" #include "commandrequest.hh" const NO_LINES = 5; diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index fbff9a8cd5..c77b716ec2 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -13,7 +13,7 @@ #include "lyricwalker.hh" #include "debug.hh" #include "lyricitem.hh" -#include "stcol.hh" +#include "staffcolumn.hh" void Lyric_walker::process_requests() diff --git a/src/scorecolumn.cc b/src/scorecolumn.cc new file mode 100644 index 0000000000..80fc804f0c --- /dev/null +++ b/src/scorecolumn.cc @@ -0,0 +1,77 @@ +/* + scorecolumn.cc -- implement Score_column + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "debug.hh" +#include "pcol.hh" +#include "scorecolumn.hh" + +int +Score_column::compare(Score_column & c1, Score_column &c2) +{ + return sign(c1.when_ - c2.when_); +} + +void +Score_column::set_breakable() +{ + pcol_l_->set_breakable(); +} + +Score_column::Score_column(Moment w) +{ + when_ = w; + pcol_l_ = new PCol(0); + musical_b_ = false; +} + +bool +Score_column::used_b() { + return pcol_l_->used_b(); +} + +void +Score_column::print() const +{ +#ifndef NPRINT + mtor << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n'; + mtor << "durations: ["; + for (int i=0; i < durations.size(); i++) + mtor << durations[i] << " "; + mtor << "]\n"; + pcol_l_->print(); + mtor << "}\n"; +#endif +} + +int +Moment_compare(Moment &a , Moment& b) +{ + return sign(a-b); +} + +void +Score_column::preprocess() +{ + durations.sort(Moment_compare); +} +void +Score_column::add_duration(Moment d) +{ + assert(d); + for (int i = 0; i< durations.size(); i++) { + if (d == durations[i]) + return ; + } + durations.push(d); +} + +bool +Score_column::breakable_b() +{ + return pcol_l_->breakable_b(); +} diff --git a/src/scorewalker.cc b/src/scorewalker.cc index 1cd9339ce9..c79031ab9a 100644 --- a/src/scorewalker.cc +++ b/src/scorewalker.cc @@ -11,7 +11,7 @@ #include "score.hh" #include "staffwalker.hh" #include "staff.hh" -#include "sccol.hh" +#include "scorecolumn.hh" Score_walker::Score_walker(Score *s) :PCursor (s->cols_) diff --git a/src/template2.cc b/src/template2.cc index 29d4b1eaf3..b3b8624ef0 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -1,9 +1,17 @@ +/* + template2.cc -- instantiate some list templates. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "symbol.hh" #include "voice.hh" #include "musicalrequest.hh" #include "staff.hh" -#include "sccol.hh" -#include "stcol.hh" +#include "scorecolumn.hh" +#include "staffcolumn.hh" #include "spanner.hh" #include "plist.tcc" #include "pcursor.tcc" diff --git a/src/template4.cc b/src/template4.cc index 69f7513390..d26e748e6f 100644 --- a/src/template4.cc +++ b/src/template4.cc @@ -1,3 +1,11 @@ +/* + template4.cc -- instantiate PointerList baseclass. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "proto.hh" #include "list.tcc" #include "cursor.tcc" diff --git a/src/template6.cc b/src/template6.cc index 1f94149abf..e85062003e 100644 --- a/src/template6.cc +++ b/src/template6.cc @@ -1,8 +1,10 @@ #include "proto.hh" #include "plist.tcc" #include "register.hh" -#include "voicegroup.hh" +#include "voicegroupregs.hh" +#include "voiceregs.hh" IPL_instantiate(Voice_registers); IPL_instantiate(Voice_group_registers); +IPL_instantiate(Request_register); diff --git a/src/voicegroupregs.cc b/src/voicegroupregs.cc new file mode 100644 index 0000000000..d23b58ac70 --- /dev/null +++ b/src/voicegroupregs.cc @@ -0,0 +1,70 @@ +/* + voicegroup.cc -- implement Voice_group_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "plist.hh" +#include "musicalrequest.hh" +#include "voiceregs.hh" +#include "voicegroupregs.hh" +#include "register.hh" +#include "textreg.hh" +#include "stembeamreg.hh" +#include "scriptreg.hh" +#include "complexwalker.hh" +#include "commandrequest.hh" + +static int temp_id_count; + +Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id) +{ + walk_l_ = w_l; + add(new Text_register(w_l)); + add(new Stem_beam_register(w_l)); + add(new Script_register(w_l)); + + if (id=="") // UGH + id = __FUNCTION__ + String(temp_id_count++); + group_id_str_ = id; +} + +bool +Voice_group_registers::try_request(Request*r_l) +{ + if (r_l->groupfeature()) { + set_dir(r_l->groupfeature()->stemdir_i_); + return true; + } + return Register_group::try_request(r_l); +} + +void +Voice_group_registers::acknowledge_element(Staff_elem_info i) +{ + if (i.group_regs_l_!= this) + return; + Register_group::acknowledge_element(i); +} +#if 1 +void +Voice_group_registers::set_dir(int i) +{ + Register_group::set_dir(i); + + // ughh + Array vr_arr (walk_l_->get_voice_regs(this)); + for (int j=0; jset_dir(i); + } +} +#endif +bool +Voice_group_registers::acceptable_request_b(Request*r) +{ + return (r->stem() || r->beam() || r->text() || r->script() || + r->groupfeature()); +} diff --git a/src/voiceregs.cc b/src/voiceregs.cc index d6c24cd674..ea56a5da46 100644 --- a/src/voiceregs.cc +++ b/src/voiceregs.cc @@ -1,5 +1,13 @@ +/* + voiceregs.cc -- implement Voice_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "musicalrequest.hh" -#include "voicegroup.hh" +#include "voiceregs.hh" #include "register.hh" #include "slurreg.hh" #include "headreg.hh" @@ -7,21 +15,8 @@ Voice_registers::Voice_registers(Complex_walker*c_l, Voice *v_p) { voice_l_ = v_p; - head_reg_ = new Notehead_register(c_l); - slur_reg_ = new Slur_register(c_l); -} -Voice_registers::~Voice_registers() -{ - delete head_reg_; - delete slur_reg_; -} -bool -Voice_registers::try_request(Request * r_l) -{ - bool b = head_reg_->try_request(r_l); - if (!b) - b = slur_reg_->try_request(r_l); - return b; + add(new Notehead_register(c_l)); + add(new Slur_register(c_l)); } void @@ -29,41 +24,11 @@ Voice_registers::acknowledge_element(Staff_elem_info i) { if (i.voice_l_ != voice_l_) return; - if (i.origin_reg_l_ != slur_reg_) - slur_reg_->acknowledge_element(i); -} - -void -Voice_registers::pre_move_processing() -{ - head_reg_->pre_move_processing(); - slur_reg_->pre_move_processing(); -} -void -Voice_registers::post_move_processing() -{ - head_reg_->post_move_processing(); - slur_reg_->post_move_processing(); -} - -void -Voice_registers::process_requests() -{ - head_reg_->process_request(); - slur_reg_->process_request(); + Register_group::acknowledge_element(i); } bool -Voice_registers::acceptable_request(Request*r) +Voice_registers::acceptable_request_b(Request*r) { return (r->rest() || r->note() || r->slur()); - -} - -void -Voice_registers::set_dir(int i) -{ - head_reg_->set_dir(i); - slur_reg_->set_dir(i); } - -- 2.39.5