From: fred Date: Sun, 24 Mar 2002 19:55:44 +0000 (+0000) Subject: lilypond-0.1.11 X-Git-Tag: release/1.5.59~4005 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=92632d0f37808d9b38c460cdbbe5b8f4b065bab1;p=lilypond.git lilypond-0.1.11 --- diff --git a/lily/audio-item.cc b/lily/audio-item.cc index eaa895049a..55367026fa 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -18,7 +18,7 @@ Audio_instrument::Audio_instrument (String instrument_str) Midi_item* Audio_instrument::midi_item_p() { - return str_.length_i() ? new Midi_instrument( 0, str_ ) : 0; + return str_.length_i() ? new Midi_instrument(0, str_) : 0; } Audio_item::Audio_item (Request* req_l) @@ -83,7 +83,7 @@ Audio_text::Audio_text (Audio_text::Type type, String text_str) Midi_item* Audio_text::midi_item_p() { - return text_str_.length_i() ? new Midi_text( this ) : 0; + return text_str_.length_i() ? new Midi_text(this) : 0; } diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index 21de1e0c9e..199657677c 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -23,7 +23,7 @@ Audio_staff::output (Midi_stream& midi_stream_r, int track_i) { Midi_track midi_track; midi_track.number_i_ = track_i; - for ( Midi_walker i (this, &midi_track); i.ok(); i++ ) + for (Midi_walker i (this, &midi_track); i.ok(); i++) i.process(); midi_stream_r << midi_track; } diff --git a/lily/axis-group-item.cc b/lily/axis-group-item.cc index 325c2a0297..d033d97571 100644 --- a/lily/axis-group-item.cc +++ b/lily/axis-group-item.cc @@ -16,19 +16,17 @@ Axis_group_item::OK() const Link_array elems = axis_admin_.elem_l_arr_; for (int i=0; i < elems.size(); i++) { - Item * it_l = elems[i]->item(); - assert (it_l); - - // somebody probably broke it in pieces - assert (it_l->pcol_l_ == pcol_l_); + Item * it_l = elems[i]->item(); + assert (it_l); } } void Axis_group_item::do_breakable_col_processing() { - if (!pcol_l_->breakable_b()) - return; + if (!breakable_b_) + return; + OK(); copy_breakable_items(); @@ -36,12 +34,15 @@ Axis_group_item::do_breakable_col_processing() Link_array elems = axis_admin_.elem_l_arr_; for (int i=0; i < elems.size(); i++) { - Item* it_l = elems[i]->item(); - for ( int j=0; j < 2; j++) - { - Item *new_l = it_l->find_prebroken_piece (broken_to_a_[j]->pcol_l_); - ((Axis_group_item*)broken_to_a_[j])->add_element (new_l); - } + Item* it_l = elems[i]->item(); + Direction j=LEFT; + do + { + Item *new_l = + it_l->find_prebroken_piece (broken_to_drul_[j]->break_status_i_); + ((Axis_group_item*)broken_to_drul_[j])->add_element (new_l); + } + while ((j*=-1)!=LEFT); } Item::do_breakable_col_processing(); } diff --git a/lily/axis-group-spanner.cc b/lily/axis-group-spanner.cc index 1d45de3ae0..033a55b33a 100644 --- a/lily/axis-group-spanner.cc +++ b/lily/axis-group-spanner.cc @@ -21,97 +21,95 @@ Axis_group_spanner::do_break_processing_if_unbroken() Line_of_score *my_line = line_l(); for (int i=0; i < elems.size(); i++) { - if (!elems[i]->line_l()) - { - Item * item_l = elems[i]->item(); - if (item_l - && item_l->breakable_b_ - && item_l->break_status_i() == 0) - { - // last two checks are paranoia - Item * broken_item_l = - item_l->find_prebroken_piece (my_line); - add_element (broken_item_l); - } - remove_element (elems[i]); - } + if (!elems[i]->line_l()) + { + Item * item_l = elems[i]->item(); + if (item_l + && item_l->breakable_b_ + && item_l->break_status_i() == 0) + { + // last two checks are paranoia + Item * broken_item_l = + item_l->find_prebroken_piece (my_line); + add_element (broken_item_l); + } + remove_element (elems[i]); + } } - } void Axis_group_spanner::do_break_processing() { - set_my_columns(); bool breaking_self_b = ! Spanner::line_l(); if (!breaking_self_b) { - do_break_processing_if_unbroken(); - Spanner::do_break_processing(); - return; + do_break_processing_if_unbroken(); + Spanner::do_break_processing(); + return; } - break_into_pieces (true); + break_into_pieces (); Link_array loose_elems = axis_admin_.elem_l_arr_; remove_all(); for (int i=0; i < loose_elems.size(); i++) { - Score_elem * elt = loose_elems[i]; - Line_of_score *elt_line = elt->line_l(); + Score_elem * elt = loose_elems[i]; + Line_of_score *elt_line = elt->line_l(); - if ( ! elt_line) - { - /* this piece doesn't know where it belongs. - Find out if it was broken, and use the broken remains - */ - if (elt->spanner()) - { - Spanner * sp = elt->spanner(); + if (! elt_line) + { + /* this piece doesn't know where it belongs. + Find out if it was broken, and use the broken remains + */ + if (elt->spanner()) + { + Spanner * sp = elt->spanner(); - for (int j =0; j < broken_into_l_arr_.size(); j++) - { - Axis_group_spanner * my_broken_l - = (Axis_group_spanner*)broken_into_l_arr_[j]; + for (int j =0; j < broken_into_l_arr_.size(); j++) + { + Axis_group_spanner * my_broken_l + = (Axis_group_spanner*)broken_into_l_arr_[j]; - Spanner * broken_span_l - = sp->find_broken_piece ( - ((Score_elem*)my_broken_l)->line_l()); + Spanner * broken_span_l + = sp->find_broken_piece ( + ((Score_elem*)my_broken_l)->line_l()); - if (broken_span_l) - my_broken_l->add_element (broken_span_l); - - } - } - else if (elt->item() - && elt->item()->breakable_b_ - && elt->item()->break_status_i () == 0) - { - - // broken items - for (int j =0; j < 2; j++) - { - Item * my_item = elt->item()->broken_to_a_[j]; - Line_of_score * item_line_l = my_item->line_l() ; - if ( ! item_line_l) - continue; + if (broken_span_l) + my_broken_l->add_element (broken_span_l); - Axis_group_spanner * v - = (Axis_group_spanner*)find_broken_piece (item_line_l); - if (v) - v->add_element (my_item); - } + } + } + else if (elt->item() + && elt->item()->breakable_b_ + && elt->item()->break_status_i () == 0) + { + // broken items + Direction j=LEFT; + do + { + Item * my_item = elt->item()->broken_to_drul_[j]; + Line_of_score * item_line_l = my_item->line_l() ; + if (! item_line_l) + continue; - } - } - else - { + Axis_group_spanner * v + = (Axis_group_spanner*)find_broken_piece (item_line_l); + if (v) + v->add_element (my_item); + } + while ((j*=-1) != LEFT); + } + } + else + { /* this piece *does* know where it belongs. Put it in appropriate piece of this spanner */ - Axis_group_spanner * my_broken_l - = (Axis_group_spanner*)find_broken_piece (elt->line_l()); - my_broken_l->add_element (elt); - } + Axis_group_spanner * my_broken_l + = (Axis_group_spanner*)find_broken_piece (elt->line_l()); + my_broken_l->add_element (elt); + } } Spanner::do_break_processing(); diff --git a/lily/bar-column-grav.cc b/lily/bar-column-grav.cc index 4c073ac57e..ac3e868a52 100644 --- a/lily/bar-column-grav.cc +++ b/lily/bar-column-grav.cc @@ -36,7 +36,7 @@ Bar_column_engraver::acknowledge_element (Score_elem_info info) bar_l_ = (Bar*)info.elem_l_->item(); } - if ( bar_l_ && !barcol_p_) + if (bar_l_ && !barcol_p_) { barcol_p_ = new Bar_column; barcol_p_->breakable_b_ =true; diff --git a/lily/bar-column.cc b/lily/bar-column.cc index f4c4d2f96b..c9a0025208 100644 --- a/lily/bar-column.cc +++ b/lily/bar-column.cc @@ -26,7 +26,7 @@ void Bar_column::do_substitute_dependency (Score_elem*o,Score_elem*n) { Script_column::do_substitute_dependency (o,n); - if ( o == bar_l_) + if (o == bar_l_) { bar_l_ = n ? (Bar*)n->item() : 0; } diff --git a/lily/bar.cc b/lily/bar.cc index 7dc97c7c59..cbf8438869 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -25,13 +25,13 @@ Bar::Bar() IMPLEMENT_IS_TYPE_B1(Bar,Item); void -Bar::do_print()const +Bar::do_print() const { DOUT << type_str_; } Molecule* -Bar::brew_molecule_p()const +Bar::brew_molecule_p() const { Paper_def *p = paper(); Symbol s = p->lookup_l()->bar (type_str_, diff --git a/lily/break.cc b/lily/break.cc index 3ebba2eb63..7f5139a831 100644 --- a/lily/break.cc +++ b/lily/break.cc @@ -20,7 +20,7 @@ Col_stats::str() const { String s (count_i_); s += " lines"; if (count_i_) - s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)"); + s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)"); return s; } @@ -42,14 +42,14 @@ Col_stats::Col_stats() /* **************************************************************** */ Line_of_cols -Break_algorithm::all_cols()const +Break_algorithm::all_cols() const { Line_of_cols retval; - for (PCursor c (pscore_l_->col_p_list_.top()); - c.ok(); c++) - { + for (PCursor c (pscore_l_->col_p_list_.top()); + c.ok(); c++) + { - retval.push (c); + retval.push (c); } return retval; } @@ -61,12 +61,12 @@ Break_algorithm::find_break_indices() const Array retval; for (int i=0; i < all.size(); i++) - if (all[i]->breakable_b()) - retval.push (i); + if (all[i]->breakable_b_) + retval.push (i); - if ( linelength <=0) - while ( retval.size() >2) - retval.del (1); + if (linelength <=0) + while (retval.size() >2) + retval.del (1); return retval; } @@ -79,13 +79,13 @@ Break_algorithm::find_breaks() const Line_of_cols retval; for (int i=0; i < all.size(); i++) - if (all[i]->breakable_b()) - retval.push (all[i]); + if (all[i]->breakable_b_) + retval.push (all[i]); - if ( linelength <=0) - while ( retval.size() >2) - retval.del (1); + if (linelength <=0) + while (retval.size() >2) + retval.del (1); return retval; } @@ -95,19 +95,19 @@ Break_algorithm::find_breaks() const Line_spacer* -Break_algorithm::generate_spacing_problem (Line_of_cols curline)const +Break_algorithm::generate_spacing_problem (Line_of_cols curline) const { Line_spacer * sp= (*get_line_spacer)(); sp->paper_l_ = pscore_l_->paper_l_; sp->add_column (curline[0], true, 0.0); for (int i=1; i< curline.size()-1; i++) - sp->add_column (curline[i]); + sp->add_column (curline[i]); - if ( linelength > 0) - sp->add_column (curline.top(), true, linelength); + if (linelength > 0) + sp->add_column (curline.top(), true, linelength); else - sp->add_column (curline.top()); + sp->add_column (curline.top()); sp->prepare(); return sp; @@ -132,11 +132,11 @@ bool Break_algorithm::feasible (Line_of_cols curline) const { if (linelength <= 0) - return true; + return true; Real l =0; for (int i=0; i < curline.size(); i++) - l +=curline[i]->width().length (); + l +=curline[i]->width().length (); return l < linelength; } @@ -144,24 +144,24 @@ void Break_algorithm::problem_OK() const { if (!pscore_l_->col_p_list_.size()) - error ("Score does not have any columns"); + error ("Score does not have any columns"); OK(); } void -Break_algorithm::OK()const +Break_algorithm::OK() const { #ifndef NDEBUG iter_top (pscore_l_->col_p_list_,start); - PCursor end (pscore_l_->col_p_list_.bottom()); + PCursor end (pscore_l_->col_p_list_.bottom()); - assert (start->breakable_b()); - assert (end->breakable_b()); + assert (start->breakable_b_); + assert (end->breakable_b_); #endif } Array -Break_algorithm::solve()const +Break_algorithm::solve() const { return do_solve(); } @@ -173,10 +173,10 @@ Break_algorithm::do_set_pscore() } void -Break_algorithm::print_stats()const +Break_algorithm::print_stats() const { if (approx_stats_.count_i_) - *mlog << "\nApproximated: " << approx_stats_.str() << "\n"; + *mlog << "\nApproximated: " << approx_stats_.str() << "\n"; if (exact_stats_.count_i_) - *mlog << "Calculated exactly: " << exact_stats_.str() << "\n"; + *mlog << "Calculated exactly: " << exact_stats_.str() << "\n"; } diff --git a/lily/chord-iterator.cc b/lily/chord-iterator.cc new file mode 100644 index 0000000000..2bca2b16ed --- /dev/null +++ b/lily/chord-iterator.cc @@ -0,0 +1,88 @@ +/* + chord-iter.cc -- implement Chord_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "translator.hh" +#include "debug.hh" +#include "chord-iterator.hh" + +#include "music-list.hh" + + +Chord_iterator::~Chord_iterator() +{ +} + +Chord_iterator::Chord_iterator (Chord const *chord_C) +{ + chord_C_ = chord_C; +} + +void +Chord_iterator::construct_children() +{ + int j = 0; + for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; + i.ok(); j++, i++) + { + Music_iterator * mi = get_iterator_p (i.ptr()); + if (mi->ok()) + { + set_translator (mi->report_to_l()->ancestor_l (chord_C_->multi_level_i_)); + children_p_list_.bottom().add (mi); + } + else + delete mi; + } +} +void +Chord_iterator::do_print() const +{ +#ifndef NPRINT + for (PCursor i (children_p_list_.top()); i.ok (); i++) + { + i->print(); + } +#endif +} + +void +Chord_iterator::process_and_next (Moment until) +{ + for (PCursor i (children_p_list_.top()); i.ok ();) + { + if (i->next_moment() == until) + { + i->process_and_next (until); + } + if (!i->ok()) + delete i.remove_p(); + else + i++; + } + Music_iterator::process_and_next (until); +} + + +IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator); + +Moment +Chord_iterator::next_moment() const +{ + Moment next_ = infinity_mom; + for (PCursor i (children_p_list_.top()); i.ok (); i++) + next_ = next_ next_moment() ; + return next_; +} + + + +bool +Chord_iterator::ok() const +{ + return children_p_list_.size(); +} diff --git a/lily/clef-grav.cc b/lily/clef-grav.cc index 1afaa3cc44..a9bea179f0 100644 --- a/lily/clef-grav.cc +++ b/lily/clef-grav.cc @@ -66,7 +66,7 @@ Clef_engraver::acknowledge_element (Score_elem_info info) if (info.elem_l_->name() == Bar::static_name ()) { create_clef(); - if ( !clef_req_l_) + if (!clef_req_l_) clef_p_->default_b_ = true; } } diff --git a/lily/col-info.cc b/lily/col-info.cc index e05498f0e1..086b7c7e3e 100644 --- a/lily/col-info.cc +++ b/lily/col-info.cc @@ -16,20 +16,22 @@ Colinfo::print() const #ifndef NPRINT DOUT << "column { "; if (fixed()) - DOUT << "fixed at " << fixed_position()<<", "; + DOUT << "fixed at " << fixed_position()<<", "; assert (pcol_l_); DOUT << "[" << minleft() << ", " << minright () << "]"; DOUT <<"}\n"; #endif } -Colinfo::Colinfo (PCol *col_l, Real const *fixed_C) +Colinfo::Colinfo (Paper_column *col_l, Real const *fixed_C) { if (fixed_C) - fixpos_p_.set_l (fixed_C); + fixpos_p_.set_l (fixed_C); ugh_b_ = false; pcol_l_ = col_l; width = pcol_l_->width(); + if (width.empty_b()) + width = Interval(0,0); } diff --git a/lily/colhpos.cc b/lily/colhpos.cc index d7850f5c27..62cc881bde 100644 --- a/lily/colhpos.cc +++ b/lily/colhpos.cc @@ -26,7 +26,7 @@ Col_hpositions::~Col_hpositions() } void -Col_hpositions::add (PCol*c) +Col_hpositions::add (Paper_column*c) { cols.push (c); } @@ -43,7 +43,7 @@ Col_hpositions::print() const } void -Col_hpositions::OK()const +Col_hpositions::OK() const { #ifndef NDEBUG assert (config.size() == cols.size ()); diff --git a/lily/elem-group-item.cc b/lily/elem-group-item.cc index ec744fee45..9209796cae 100644 --- a/lily/elem-group-item.cc +++ b/lily/elem-group-item.cc @@ -11,7 +11,7 @@ #include "p-col.hh" void -Horizontal_vertical_group_item::do_print()const +Horizontal_vertical_group_item::do_print() const { Horizontal_vertical_group_element::do_print(); } diff --git a/lily/elem-group.cc b/lily/elem-group.cc index 807573384f..8c4c573b26 100644 --- a/lily/elem-group.cc +++ b/lily/elem-group.cc @@ -17,25 +17,37 @@ Axis_group_element::do_unlink() remove_all(); } +void +Axis_group_element::do_junk_links() +{ + axis_admin_.elem_l_arr_.set_size (0); +} + bool -Axis_group_element::contains_b (Score_elem const*e)const +Axis_group_element::contains_b (Score_elem const*e) const { return axis_admin_.contains_b (e); } Link_array -Axis_group_element::get_extra_dependencies()const +Axis_group_element::get_extra_dependencies() const { return axis_admin_.elem_l_arr_; } void -Axis_group_element::do_print()const +Axis_group_element::do_print() const { axis_admin_.print(); } + +Axis_group_element::Axis_group_element() +{ + transparent_b_ = true; +} + // **************** @@ -62,6 +74,7 @@ Vertical_group_element::remove_all() { axis_admin_.remove_all (Y_AXIS,Y_AXIS); } + // **************** void @@ -84,7 +97,7 @@ Horizontal_group_element::remove_element (Score_elem*e) Interval -Horizontal_group_element::do_width()const +Horizontal_group_element::do_width() const { return axis_admin_.extent (X_AXIS); } diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 90d07e6851..740899418b 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -39,7 +39,7 @@ struct Break_node { */ Array -Gourlay_breaking::do_solve()const +Gourlay_breaking::do_solve() const { Array optimal_paths; @@ -78,8 +78,8 @@ Gourlay_breaking::do_solve()const Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1); - line[0] = line[0]->postbreak_p_; - line.top() = line.top ()->prebreak_p_; + line[0] = line[0]->postbreak_l(); + line.top() = line.top ()->prebreak_l(); if (!feasible (line)) break; @@ -110,22 +110,22 @@ Gourlay_breaking::do_solve()const for (int j=0; j < candidates.size(); j++) { int start = candidates[j]; - if ( optimal_paths[start].line_config_.energy_f_ + if (optimal_paths[start].line_config_.energy_f_ + candidate_lines[j].energy_f_ > minimal_energy) continue; - if ( !candidate_lines[j].satisfies_constraints_b_) + if (!candidate_lines[j].satisfies_constraints_b_) { candidate_lines[j].solve_line(); - ((Break_algorithm*)this)->exact_stats_.add ( candidate_lines[j].cols); + ((Break_algorithm*)this)->exact_stats_.add (candidate_lines[j].cols); } Real this_energy = optimal_paths[start].line_config_.energy_f_ + candidate_lines[j].energy_f_ ; - if ( this_energy < minimal_energy) + if (this_energy < minimal_energy) { minimal_j = j; minimal_energy = this_energy; @@ -143,24 +143,24 @@ Gourlay_breaking::do_solve()const optimal_paths[break_idx].line_config_ = candidate_lines[minimal_j]; } - if ( !(break_idx % HAPPY_DOTS_I)) + if (!(break_idx % HAPPY_DOTS_I)) *mlog << "[" << break_idx << "]"< final_breaks; Array lines; - Real min_energy_f_ = infinity_f; - Real max_energy_f_ = 0; + + Real max_energy_f = 0; /* skip 0-th element, since it is a "dummy" elt*/ for (int i = optimal_paths.size()-1; i> 0;) { - final_breaks.push ( i); - assert ( i > optimal_paths[i].prev_break_i_); + final_breaks.push (i); + assert (i > optimal_paths[i].prev_break_i_); // there was no "feasible path" if (!optimal_paths[i].line_config_.config.size()) { @@ -174,7 +174,7 @@ Gourlay_breaking::do_solve()const /* TODO print variation in energy */ - if (max_energy_f_ ) + if (max_energy_f) { ; } @@ -182,7 +182,7 @@ Gourlay_breaking::do_solve()const for (int i= final_breaks.size(); i--;) - lines.push ( optimal_paths[final_breaks[i]].line_config_); + lines.push (optimal_paths[final_breaks[i]].line_config_); return lines; diff --git a/lily/grouping.cc b/lily/grouping.cc index c106db0861..15401fced9 100644 --- a/lily/grouping.cc +++ b/lily/grouping.cc @@ -18,7 +18,7 @@ Rhythmic_grouping::init() } void -Rhythmic_grouping::OK()const +Rhythmic_grouping::OK() const { #ifndef NDEBUG assert (bool (children.size()) != bool (interval_)); @@ -40,7 +40,7 @@ Rhythmic_grouping::length() const } MInterval -Rhythmic_grouping::interval()const +Rhythmic_grouping::interval() const { if (interval_) return *interval_; @@ -138,7 +138,7 @@ Rhythmic_grouping::split (Array splitpoints) Array ch; while (1) { - if ( i >= children.size() || j >= splitpoints.size ()) + if (i >= children.size() || j >= splitpoints.size ()) break; assert ( @@ -235,7 +235,7 @@ Rhythmic_grouping::junk() } void -Rhythmic_grouping::print()const +Rhythmic_grouping::print() const { #ifndef NPRINT DOUT << "{ \n"; @@ -253,7 +253,7 @@ bool Rhythmic_grouping::child_fit_b (Moment start) { if (children.size()) - return ( children.top()->interval ().right== start); + return (children.top()->interval ().right== start); return true; } @@ -347,7 +347,7 @@ Rhythmic_grouping::translate (Moment m) } void -Rhythmic_grouping::extend (MInterval m)const +Rhythmic_grouping::extend (MInterval m) const { assert (m.left >= interval().left); while (m.right >interval().right) diff --git a/lily/horizontal-align-item.cc b/lily/horizontal-align-item.cc index 163a1bf61c..48701d148a 100644 --- a/lily/horizontal-align-item.cc +++ b/lily/horizontal-align-item.cc @@ -10,14 +10,9 @@ IMPLEMENT_IS_TYPE_B1(Horizontal_align_item,Item); -void -Horizontal_align_item::OK() const -{ - for (int i =0; i < item_l_arr_.size(); i++) - assert ( pcol_l_ == item_l_arr_[i]->pcol_l_); -} + bool -Horizontal_align_item::contains_b (Item *i)const +Horizontal_align_item::contains_b (Item *i) const { return item_l_arr_.find_l (i); } @@ -37,10 +32,10 @@ Horizontal_align_item::do_substitute_dependency (Score_elem*o,Score_elem*n) int i; while ((i = item_l_arr_.find_i (o->item())) >=0) { - if (n) - item_l_arr_[i] = n->item(); - else - item_l_arr_.del (i); + if (n) + item_l_arr_[i] = n->item(); + else + item_l_arr_.del (i); } } @@ -48,15 +43,15 @@ struct Horizontal_align_item_content { Item * item_l_; int priority_i_; static int compare (Horizontal_align_item_content const &h1, - Horizontal_align_item_content const &h2) - { - return h1.priority_i_ - h2.priority_i_; - } + Horizontal_align_item_content const &h2) + { + return h1.priority_i_ - h2.priority_i_; + } Horizontal_align_item_content (Item*i, int p) - { - priority_i_ = p; - item_l_ = i; - } + { + priority_i_ = p; + item_l_ = i; + } Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; } }; @@ -64,50 +59,49 @@ struct Horizontal_align_item_content { void Horizontal_align_item::do_pre_processing() { - OK(); { - Array content; - for (int i =0; i < item_l_arr_.size(); i++) - content.push ( - Horizontal_align_item_content ( - item_l_arr_[i], priority_i_arr_[i])); - content.sort (Horizontal_align_item_content::compare); - item_l_arr_.clear(); - priority_i_arr_.clear(); - for (int i =0; i < content.size(); i++) - { - item_l_arr_.push (content[i].item_l_); - priority_i_arr_.push (content[i].priority_i_); - } - } + Array content; + for (int i =0; i < item_l_arr_.size(); i++) + content.push ( + Horizontal_align_item_content ( + item_l_arr_[i], priority_i_arr_[i])); + content.sort (Horizontal_align_item_content::compare); + item_l_arr_.clear(); + priority_i_arr_.clear(); + for (int i =0; i < content.size(); i++) + { + item_l_arr_.push (content[i].item_l_); + priority_i_arr_.push (content[i].priority_i_); + } + } Array dims; Real total =0; for (int i =0; i < item_l_arr_.size(); i++) { - Interval item_width= item_l_arr_[i]->width(); - if (item_width.empty_b()) - { - item_width = Interval (0,0); - } - dims.push (item_width); - total += item_width.length(); + Interval item_width= item_l_arr_[i]->width(); + if (item_width.empty_b()) + { + item_width = Interval (0,0); + } + dims.push (item_width); + total += item_width.length(); } Real where_f= total * (align_i_-1.0)/2.0; Real center_dx_f = 0; - for ( int i=0 ; i < item_l_arr_.size(); i++) + for (int i=0 ; i < item_l_arr_.size(); i++) { - Real dx = where_f -dims[i][-1]; - item_l_arr_[i]->translate (dx , X_AXIS); - if (item_l_arr_[i] == center_l_) - center_dx_f = where_f; - where_f += dims[i].length(); + Real dx = where_f -dims[i][-1]; + item_l_arr_[i]->translate (dx , X_AXIS); + if (item_l_arr_[i] == center_l_) + center_dx_f = where_f; + where_f += dims[i].length(); } if (center_dx_f && !align_i_) - for ( int i=0 ; i < item_l_arr_.size(); i++) - item_l_arr_[i]->translate (- center_dx_f , X_AXIS); + for (int i=0 ; i < item_l_arr_.size(); i++) + item_l_arr_[i]->translate (- center_dx_f , X_AXIS); } @@ -118,7 +112,7 @@ Horizontal_align_item::do_width() const } void -Horizontal_align_item::do_print()const +Horizontal_align_item::do_print() const { } diff --git a/lily/identifier.cc b/lily/identifier.cc index ad7f5de1f4..035c93b244 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -35,7 +35,7 @@ Identifier::error (String expect) ::error (e); } -Identifier::Identifier ( int code) +Identifier::Identifier (int code) { token_code_i_ = code; accessed_b_ = 0; @@ -43,7 +43,7 @@ Identifier::Identifier ( int code) } void -Identifier::print()const +Identifier::print() const { DOUT << "identifier "; do_print(); @@ -70,7 +70,7 @@ DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef); void -Duration_id::do_print()const +Duration_id::do_print() const {} void diff --git a/lily/ineq-constrained-qp.cc b/lily/ineq-constrained-qp.cc index f7b204fcff..a8cbd0a9db 100644 --- a/lily/ineq-constrained-qp.cc +++ b/lily/ineq-constrained-qp.cc @@ -210,10 +210,10 @@ Ineq_constrained_qp::constraint_solve (Vector start) const Vector -Ineq_constrained_qp::solve (Vector start)const +Ineq_constrained_qp::solve (Vector start) const { /* no hassle if no constraints*/ - if ( ! cons.size()) + if (! cons.size()) { Choleski_decomposition chol (quad); return - chol.solve (lin); diff --git a/lily/input-translator.cc b/lily/input-translator.cc index 34a65b7f3e..ff277cc672 100644 --- a/lily/input-translator.cc +++ b/lily/input-translator.cc @@ -27,7 +27,7 @@ void Input_translator::print() const { #ifndef NPRINT - if ( ! check_debug) + if (! check_debug) return ; DOUT << base_str_ <<" " << type_str_<<" {\n"; DOUT << "Consists of "; @@ -46,7 +46,7 @@ Input_translator::print() const Input_translator * Input_translator::recursive_find (String nm) { - if ( is_name_b (nm)) + if (is_name_b (nm)) return this; Input_translator * r =0; @@ -119,7 +119,7 @@ Input_translator::add (Input_translator *ip) Input_translator* Input_translator::get_default_itrans_l() { - if ( contains_itrans_p_list_.size()) + if (contains_itrans_p_list_.size()) return contains_itrans_p_list_.top(); else return 0; diff --git a/lily/item.cc b/lily/item.cc index 6c4a7699c8..6d72b4c5b8 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -11,13 +11,13 @@ #include "item.hh" #include "p-col.hh" #include "elem-group.hh" +#include "spanner.hh" Item::Item() { breakable_b_ = false; break_status_i_ = 0; - pcol_l_ = 0; - broken_to_a_[0] = broken_to_a_[1]=0; + broken_to_drul_[LEFT] = broken_to_drul_[RIGHT]=0; } IMPLEMENT_IS_TYPE_B1(Item, Score_elem); @@ -26,21 +26,22 @@ void Item::do_print() const { #ifndef NPRINT - DOUT << "(unknown)"; + DOUT << "breakable_b_: " << breakable_b_; + DOUT << "break_status_i_: " <hpos_f_ + absolute_coordinate (X_AXIS); + return absolute_coordinate (X_AXIS); } Line_of_score * -Item::line_l()const +Item::line_l() const { - return pcol_l_->line_l_; + return (axis_group_l_a_[X_AXIS])? axis_group_l_a_[X_AXIS]->line_l() : 0; } int @@ -52,36 +53,37 @@ Item::break_status_i() const void Item::copy_breakable_items() { - if ( broken_to_a_[0] || broken_to_a_[1]) - return; - Item *new_copies[2]; - for (int i=0; i < 2; i++) + if (broken_to_drul_[LEFT] || broken_to_drul_[RIGHT]) + return; + Drul_array new_copies; + Direction i=LEFT; + do { - Item * item_p = clone()->item (); - item_p->copy_dependencies (*this); - - item_p->break_status_i_ = -1+ 2*i; - pscore_l_->typeset_item (item_p, pcol_l_); - item_p->handle_prebroken_dependencies(); - new_copies[i] =item_p; + Item * item_p = clone()->item (); + + item_p->break_status_i_ = i; + pscore_l_->typeset_element (item_p); + item_p->handle_prebroken_dependencies(); + new_copies[i] =item_p; } - broken_to_a_= new_copies; + while ((i *= -1) != LEFT); + broken_to_drul_= new_copies; } void Item::do_breakable_col_processing() { - if (!breakable_b_ || !pcol_l_->breakable_b()) - return; + if (!breakable_b_) + return; copy_breakable_items(); handle_prebroken_dependencies(); /* Otherwise the broken items won't be pre_process()'ed. - */ - add_dependency (broken_to_a_[0]); - add_dependency (broken_to_a_[1]); + */ + add_dependency (broken_to_drul_[LEFT]); + add_dependency (broken_to_drul_[RIGHT]); } @@ -89,32 +91,67 @@ Item* Item::find_prebroken_piece (Line_of_score*l) const { if (line_l() == l) - return (Item*)this; - else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l) - return broken_to_a_[0]; - else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l) - return broken_to_a_[1]; + return (Item*)this; + else if (broken_to_drul_[LEFT] && broken_to_drul_[LEFT]->line_l() == l) + return broken_to_drul_[LEFT]; + else if (broken_to_drul_[RIGHT] && broken_to_drul_[RIGHT]->line_l() == l) + return broken_to_drul_[RIGHT]; return 0; } Item* -Item::find_prebroken_piece (PCol*c)const +Item::find_prebroken_piece (int breakstatus) const { - if (c == pcol_l_) - return (Item *) this; // ugh + if (!breakstatus) + return (Item *) this; // ugh + else + return (Item*) broken_to_drul_[(Direction)breakstatus]; +} - if (c == pcol_l_->prebreak_p_) - return (Item *) broken_to_a_[0]; - else if (c==pcol_l_->postbreak_p_) - return (Item *)broken_to_a_[1]; +void +Item::handle_prebroken_dependencies() +{ + if (breakable_b_) + Score_elem::handle_prebroken_dependencies(); +} - assert (false); +int +Item::left_right_compare(Item const *l, Item const *r) +{ + while (!l->is_type_b (Paper_column::static_name ())) + l = l->axis_group_l_a_[X_AXIS]->item(); + while (!r->is_type_b (Paper_column::static_name ())) + r = r->axis_group_l_a_[X_AXIS]->item(); + + Paper_column *p1 = (Paper_column*)l; + Paper_column* p2 = (Paper_column*)r; + return p1->rank_i () - p2->rank_i (); +} + + +bool +Item::linked_b() const +{ + return Score_elem::linked_b() || attached_span_l_arr_.size(); } void -Item::handle_prebroken_dependencies() +Item::do_junk_links() +{ + attached_span_l_arr_.set_size(0); +} + +void +Item::do_unlink() { - if ( breakable_b_) - Score_elem::handle_prebroken_dependencies(); + for (int i=0; i < attached_span_l_arr_.size (); i++) { + Spanner *&s= attached_span_l_arr_[i]; + if (s->spanned_drul_[LEFT] == this) + s->set_bounds (LEFT, 0); + if (s->spanned_drul_[RIGHT] == this) + s->set_bounds (RIGHT,0); + s =0; + } + attached_span_l_arr_.set_size (0); } diff --git a/lily/key-grav.cc b/lily/key-grav.cc index 96d51998c4..f2d81ae907 100644 --- a/lily/key-grav.cc +++ b/lily/key-grav.cc @@ -65,7 +65,7 @@ Key_engraver::acknowledge_element (Score_elem_info info) } else if (info.elem_l_->name() == Bar::static_name ()) { - if ( !keyreq_l_) + if (!keyreq_l_) default_key_b_ = true; create_key(); } diff --git a/lily/key-item.cc b/lily/key-item.cc index 12276dcbbf..5fbfd29f39 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -63,7 +63,7 @@ Key_item::add (int p, int a) Molecule* -Key_item::brew_molecule_p()const +Key_item::brew_molecule_p() const { Molecule*output = new Molecule; Real inter = paper()->internote_f (); @@ -76,7 +76,7 @@ Key_item::brew_molecule_p()const Molecule m (a); output->add_right (m); } - if ( pitch.size()) + if (pitch.size()) { Molecule m (paper()->lookup_l ()->fill (Box ( Interval (0, paper()->note_width ()), diff --git a/lily/key-performer.cc b/lily/key-performer.cc index d4d0527aa0..160dee4a64 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -28,7 +28,7 @@ void Key_performer::do_print() const { #ifndef NPRINT - if ( key_req_l_) + if (key_req_l_) key_req_l_->print(); #endif } @@ -36,21 +36,21 @@ Key_performer::do_print() const void Key_performer::process_requests() { - if ( key_req_l_) - play (new Audio_key (key_req_l_) ); + if (key_req_l_) + play (new Audio_key (key_req_l_)); key_req_l_ = 0; } bool Key_performer::do_try_request (Request* req_l) { - if ( key_req_l_) + if (key_req_l_) return false; - if ( req_l->command()) + if (req_l->command()) key_req_l_ = req_l->command()->keychange (); - if ( key_req_l_) + if (key_req_l_) return true; return false; diff --git a/lily/keyword.cc b/lily/keyword.cc index f027ee86d9..0274d1653f 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -45,7 +45,7 @@ Keyword_table::Keyword_table (Keyword_ent *tab) lookup with binsearch, return tokencode. */ int -Keyword_table::lookup (char const *s)const +Keyword_table::lookup (char const *s) const { int lo, hi, diff --git a/lily/line-group-grav.cc b/lily/line-group-grav.cc index 9d544d061e..5915e78544 100644 --- a/lily/line-group-grav.cc +++ b/lily/line-group-grav.cc @@ -12,6 +12,7 @@ #include "bar.hh" #include "debug.hh" #include "line-group-grav.hh" +#include "p-col.hh" Line_group_engraver::Line_group_engraver() { @@ -21,7 +22,7 @@ Line_group_engraver::Line_group_engraver() void Line_group_engraver::acknowledge_element (Score_elem_info elem) { - if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS]) + if (!elem.elem_l_->axis_group_l_a_[Y_AXIS]) staffline_p_->add_element (elem.elem_l_); } @@ -29,7 +30,7 @@ Line_group_engraver::acknowledge_element (Score_elem_info elem) void Line_group_engraver::do_removal_processing() { - staffline_p_->right_col_l_ = get_staff_info().command_pcol_l (); + staffline_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ()); typeset_element (staffline_p_); staffline_p_ = 0; } @@ -38,7 +39,7 @@ void Line_group_engraver::do_creation_processing() { staffline_p_ = new Vertical_group_spanner ; - staffline_p_->left_col_l_ = get_staff_info().command_pcol_l (); + staffline_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ()); // don't broadcast to self. announce_element (Score_elem_info (staffline_p_,0)); diff --git a/lily/line-spacer.cc b/lily/line-spacer.cc index 5f51ad3ad4..c59589481a 100644 --- a/lily/line-spacer.cc +++ b/lily/line-spacer.cc @@ -14,7 +14,7 @@ Line_spacer::Line_spacer() paper_l_ =0; } Paper_def* -Line_spacer::paper_l()const +Line_spacer::paper_l() const { return paper_l_ ; } diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index b81adc5fcf..33037e26ea 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -56,7 +56,7 @@ Local_key_item::do_pre_processing() } Molecule* -Local_key_item::brew_molecule_p()const +Local_key_item::brew_molecule_p() const { Molecule* output = new Molecule; Molecule*octmol = 0; diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index b800f3d1ad..9a7fef130c 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -28,7 +28,7 @@ void Lyric_performer::do_print() const { #ifndef NPRINT - if ( lreq_arr_.size()) + if (lreq_arr_.size()) lreq_arr_[ 0 ]->print(); #endif } @@ -36,8 +36,8 @@ Lyric_performer::do_print() const void Lyric_performer::process_requests() { - if ( lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i() ) - play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_) ); + if (lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i()) + play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_)); lreq_arr_.clear(); } @@ -45,7 +45,7 @@ bool Lyric_performer::do_try_request (Request* req_l) { Musical_req* m_l = req_l->musical(); - if ( !m_l || ! m_l->lreq_l()) + if (!m_l || ! m_l->lreq_l()) return false; lreq_arr_.push (m_l->lreq_l()); diff --git a/lily/main.cc b/lily/main.cc index eb9f611543..8c68dd1bc0 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -106,14 +106,14 @@ static File_path path; void do_one_file (String init_str, String file_str) { - if ( init_str != "" && "" == path.find (init_str) ) + if (init_str != "" && "" == path.find (init_str)) { - error ( "Can not find `" + init_str +"\'"); + error ("Can not find `" + init_str +"\'"); return ; } - if ( file_str!= "" && path.find (file_str) == "" ) + if (file_str!= "" && path.find (file_str) == "") { - error ( "Can not find `" + file_str + "'"); + error ("Can not find `" + file_str + "'"); return ; } @@ -142,7 +142,7 @@ main (int argc, char **argv) path.add (env_l); } path.add (""); - path.add (String (DIR_DATADIR) + "/init/" ); + path.add (String (DIR_DATADIR) + "/init/"); path.push (DIR_DATADIR); @@ -152,7 +152,7 @@ main (int argc, char **argv) while (Long_option_init const * opt = oparser()) { - switch ( opt->shortname) + switch (opt->shortname) { case 'o': set_default_output (oparser.optional_argument_ch_C_); @@ -188,7 +188,7 @@ main (int argc, char **argv) int p=0; const char *arg ; - while ( (arg= oparser.get_next_arg())) + while ((arg= oparser.get_next_arg())) { String f (arg); destill_inname (f); @@ -207,7 +207,7 @@ main (int argc, char **argv) void destill_inname (String &name_str_r) { - if ( name_str_r.length_i()) + if (name_str_r.length_i()) { if (name_str_r[ 0 ] != '-') { diff --git a/lily/meter-performer.cc b/lily/meter-performer.cc index 0d23bb9a9b..63eb06946b 100644 --- a/lily/meter-performer.cc +++ b/lily/meter-performer.cc @@ -26,30 +26,30 @@ void Meter_performer::do_print() const { #ifndef NPRINT - if ( meter_req_l_) - meter_req_l_->print(); + if (meter_req_l_) + meter_req_l_->print(); #endif } void Meter_performer::process_requests() { - if ( meter_req_l_) - play (new Audio_meter (meter_req_l_) ); + if (meter_req_l_) + play (new Audio_meter (meter_req_l_)); meter_req_l_ = 0; } bool Meter_performer::do_try_request (Request* req_l) { - if ( meter_req_l_) - return false; + if (meter_req_l_) + return false; - if ( req_l->command()) - meter_req_l_ = req_l->command()->meterchange (); + if (req_l->command()) + meter_req_l_ = req_l->command()->meterchange (); - if ( meter_req_l_) - return true; + if (meter_req_l_) + return true; return false; } diff --git a/lily/meter.cc b/lily/meter.cc index e8fcd8f9f0..aa41b7922b 100644 --- a/lily/meter.cc +++ b/lily/meter.cc @@ -11,7 +11,7 @@ Meter::Meter (Arraya) } Molecule* -Meter::brew_molecule_p()const +Meter::brew_molecule_p() const { Symbol s = paper()->lookup_l ()->meter (args); return new Molecule (Atom (s)); diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 47af53eb3b..e7e914782d 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -71,7 +71,7 @@ Midi_duration::Midi_duration (Real seconds_f) String Midi_duration::str() const { - return String (""; + return String (""; } Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i) @@ -270,14 +270,14 @@ String Midi_instrument::str() const { Byte program_byte = 0; - for ( int i = 0; instrument_name_sz_a_[i]; i++) - if ( instrument_str_ == String (instrument_name_sz_a_[ i ])) + for (int i = 0; instrument_name_sz_a_[i]; i++) + if (instrument_str_ == String (instrument_name_sz_a_[ i ])) { program_byte = (Byte)i; break; } - String str = String ((char)( 0xc0 + channel_i_) ); + String str = String ((char)(0xc0 + channel_i_)); str += String ((char)program_byte); return str; } @@ -298,7 +298,7 @@ String Midi_item::i2varint_str (int i) { int buffer_i = i & 0x7f; - while ( (i >>= 7) > 0) + while ((i >>= 7) > 0) { buffer_i <<= 8; buffer_i |= 0x80; @@ -306,10 +306,10 @@ Midi_item::i2varint_str (int i) } String str; - while ( 1) + while (1) { str += (char)buffer_i; - if ( buffer_i & 0x80) + if (buffer_i & 0x80) buffer_i >>= 8; else break; @@ -330,7 +330,7 @@ Midi_key::str() const int flats_i = k->flats_i(); // midi cannot handle non-conventional keys - if ( flats_i && sharps_i) + if (flats_i && sharps_i) return ""; int accidentals_i = sharps_i - flats_i; @@ -356,7 +356,7 @@ Midi_meter::str() const String str = "ff5804"; str += String_convert::i2hex_str (num_i, 2, '0'); - str += String_convert::i2hex_str (intlog2( den_i) , 2, '0' ); + str += String_convert::i2hex_str (intlog2(den_i) , 2, '0'); str += String_convert::i2hex_str (clocks_per_1_i_, 2, '0'); str += String_convert::i2hex_str (8, 2, '0'); return String_convert::hex2bin_str (str); @@ -383,16 +383,16 @@ Midi_note::pitch_i() const String Midi_note::str() const { - if ( pitch_i() == INT_MAX) + if (pitch_i() == INT_MAX) return String (""); - Byte status_byte = (char)( 0x90 + channel_i_); + Byte status_byte = (char)(0x90 + channel_i_); String str = String ((char)status_byte); - str += (char)( pitch_i() + c0_pitch_i_c_); + str += (char)(pitch_i() + c0_pitch_i_c_); // poor man's staff dynamics: - str += (char)( dynamic_byte_ - 0x10 * channel_i_); + str += (char)(dynamic_byte_ - 0x10 * channel_i_); return str; } @@ -414,13 +414,13 @@ Midi_note_off::pitch_i() const String Midi_note_off::str() const { - if ( pitch_i() == INT_MAX) + if (pitch_i() == INT_MAX) return String (""); - Byte status_byte = (char)( 0x80 + channel_i_); + Byte status_byte = (char)(0x80 + channel_i_); String str = String ((char)status_byte); - str += (char)( pitch_i() + Midi_note::c0_pitch_i_c_); + str += (char)(pitch_i() + Midi_note::c0_pitch_i_c_); str += (char)aftertouch_byte_; return str; } @@ -428,7 +428,7 @@ Midi_note_off::str() const Midi_tempo::Midi_tempo (Audio_item* audio_item_l) : Midi_item (audio_item_l) { - per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_)->per_minute_4_i_; + per_minute_4_i_ = ((Audio_tempo*)audio_item_l_)->per_minute_4_i_; } Midi_tempo::Midi_tempo (int per_minute_4_i) @@ -449,8 +449,8 @@ Midi_tempo::str() const Midi_text::Midi_text (Audio_item* audio_item_l) : Midi_item (audio_item_l) { - text_str_ = ( (Audio_text*)audio_item_l_)->text_str_; - type_ = (Type)( (Audio_text*)audio_item_l_)->type_; + text_str_ = ((Audio_text*)audio_item_l_)->text_str_; + type_ = (Type)((Audio_text*)audio_item_l_)->type_; } Midi_text::Midi_text (Midi_text::Type type, String text_str) @@ -512,14 +512,14 @@ Midi_track::Midi_track() void Midi_track::add (int delta_time_i, String event_str) { - if ( delta_time_i < 0) + if (delta_time_i < 0) { - cout << String_convert::bin2hex_str (i2varint_str (delta_time_i) ) << endl; + cout << String_convert::bin2hex_str (i2varint_str (delta_time_i)) << endl; cout << String_convert::bin2hex_str (event_str) << endl; } assert (delta_time_i >= 0); assert(event_str.length_i()); - Midi_chunk::add (i2varint_str (delta_time_i) + event_str ); + Midi_chunk::add (i2varint_str (delta_time_i) + event_str); } void @@ -527,8 +527,8 @@ Midi_track::add (Moment delta_time_moment, Midi_item* mitem_l) { // use convention of 384 clocks per 4 // use Duration_convert - int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4 ); - // ? int ( delta_time_moment * 4 * 384) + int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4); + // ? int (delta_time_moment * 4 * 384) add (delta_time_i, mitem_l->str()); } diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index 5f1b3ee501..0521e87c75 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -28,31 +28,31 @@ Midi_stream::~Midi_stream() } Midi_stream& -Midi_stream::operator <<( String str) +Midi_stream::operator <<(String str) { - if ( check_debug) + if (check_debug) str = String_convert::bin2hex_str (str); *os_p_ << str; - if ( check_debug) + if (check_debug) *os_p_ << "\n"; return *this; } Midi_stream& -Midi_stream::operator <<( Midi_item const& mitem_c_r) +Midi_stream::operator <<(Midi_item const& mitem_c_r) { // *this << mitem_c_r.str(); mitem_c_r.output (this); - if ( check_debug) + if (check_debug) *os_p_ << "\n"; return *this; } Midi_stream& -Midi_stream::operator <<( int i) +Midi_stream::operator <<(int i) { // output binary string ourselves *this << Midi_item::i2varint_str (i); @@ -63,6 +63,6 @@ void Midi_stream::open() { os_p_ = new ofstream (filename_str_); - if ( !*os_p_) + if (!*os_p_) error ("can't open `" + filename_str_ + "\'"); } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index aea8fcc0d7..36c8000024 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -27,7 +27,7 @@ compare (Midi_note_event const& left, Midi_note_event const& right) } Midi_walker::Midi_walker (Audio_staff* audio_staff_l, Midi_track* track_l) - : PCursor( audio_staff_l->audio_item_l_list_) + : PCursor(audio_staff_l->audio_item_l_list_) { track_l_ = track_l; last_mom_ = 0; @@ -36,7 +36,7 @@ Midi_walker::Midi_walker (Audio_staff* audio_staff_l, Midi_track* track_l) Midi_walker::~Midi_walker() { // ugh - do_stop_notes (last_mom_ + Moment (10, 1) ); + do_stop_notes (last_mom_ + Moment (10, 1)); } /** @@ -46,11 +46,11 @@ void Midi_walker::do_start_note (Midi_note* note_l) { Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom (); - for ( int i=0; i < stop_note_queue.size(); i++) + for (int i=0; i < stop_note_queue.size(); i++) { - if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) + if (stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) { - if ( stop_note_queue[ i ].key < stop_mom) + if (stop_note_queue[ i ].key < stop_mom) stop_note_queue[ i ].ignore_b_ = true; else // skip the stopnote return; @@ -71,10 +71,10 @@ Midi_walker::do_start_note (Midi_note* note_l) void Midi_walker::do_stop_notes (Moment max_mom) { - while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) + while (stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) { Midi_note_event e = stop_note_queue.get(); - if ( e.ignore_b_) + if (e.ignore_b_) continue; Moment stop_mom = e.key; @@ -101,11 +101,11 @@ Midi_walker::process() do_stop_notes (ptr()->audio_column_l_->at_mom ()); Midi_item* p = ptr()->midi_item_p (); - if ( !p ) + if (!p) return; p->channel_i_ = track_l_->number_i_; - if ( p->name() != Midi_note::static_name ()) + if (p->name() != Midi_note::static_name ()) output_event (ptr()->audio_column_l_->at_mom (), p); else do_start_note ((Midi_note*)p); diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 56a6476ff6..ef36b59d14 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -1,26 +1,24 @@ /* - music-iterator.cc -- implement {Music,Chord,Voice}_iterator + music-iterator.cc -- implement Music_iterator source file of the GNU LilyPond music typesetter (c) 1997 Han-Wen Nienhuys */ - +#include "debug.hh" #include "music-list.hh" #include "music-iterator.hh" +#include "voice-iterator.hh" +#include "chord-iterator.hh" +#include "request-iterator.hh" #include "translator.hh" -#include "request.hh" -#include "debug.hh" IMPLEMENT_IS_TYPE_B(Music_iterator); -Chord_iterator::~Chord_iterator() -{ -} void -Music_iterator::do_print()const +Music_iterator::do_print() const { } @@ -29,12 +27,15 @@ void Music_iterator::print() const { #ifndef NPRINT - if ( !check_debug) - return ; + if (!check_debug) + return ; DOUT << name() << "{"; DOUT << "report to " << - report_to_l() << " (" << report_to_l ()->name () << ")\n"; - DOUT << "next at " << next_moment() << " "; + report_to_l() << " (" << report_to_l ()->name () << ")\n"; + if (ok()) + DOUT << "next at " << next_moment() << " "; + else + DOUT << "not feeling well today.."; do_print(); DOUT << "}\n"; #endif @@ -45,7 +46,7 @@ Music_iterator::get_req_translator_l() { assert (report_to_l()); if (report_to_l()->is_bottom_engraver_b ()) - return report_to_l(); + return report_to_l(); set_translator (report_to_l()->get_default_interpreter ()); return report_to_l(); @@ -67,10 +68,10 @@ Music_iterator::pop_translator() } Translator* -Music_iterator::report_to_l()const +Music_iterator::report_to_l() const { if (! report_to_l_arr_.size()) - return 0; + return 0; return report_to_l_arr_.top(); } @@ -79,11 +80,11 @@ void Music_iterator::set_translator (Translator*trans) { if (report_to_l()==trans) - return; - if ( report_to_l()) - pop_translator(); + return; + if (report_to_l()) + pop_translator(); if (trans) - push_translator (trans); + push_translator (trans); } void @@ -98,7 +99,7 @@ Music_iterator::~Music_iterator() } Moment -Music_iterator::next_moment()const +Music_iterator::next_moment() const { return 0; } @@ -110,39 +111,39 @@ Music_iterator::process_and_next (Moment) } bool -Music_iterator::ok()const +Music_iterator::ok() const { return first_b_; } Music_iterator* Music_iterator::static_get_iterator_p (Music *m, - Translator *report_l) + Translator *report_l) { Music_iterator * p =0; if (m->is_type_b (Request_chord::static_name())) - p = new Request_chord_iterator ((Request_chord*) m); + p = new Request_chord_iterator ((Request_chord*) m); else if (m->is_type_b (Chord::static_name())) - p = new Chord_iterator ((Chord*) m); + p = new Chord_iterator ((Chord*) m); else if (m->is_type_b (Voice::static_name())) - p = new Voice_iterator ((Voice*) m); + p = new Voice_iterator ((Voice*) m); if (m -> type_str_ != "") { - Translator * a =report_l-> - find_get_translator_l (m-> type_str_, m->id_str_); - p->set_translator (a); + Translator * a =report_l-> + find_get_translator_l (m-> type_str_, m->id_str_); + p->set_translator (a); } if (! p->report_to_l()) - p ->set_translator (report_l); + p ->set_translator (report_l); return p; } Music_iterator* -Music_iterator::get_iterator_p (Music*m)const +Music_iterator::get_iterator_p (Music*m) const { Music_iterator*p = static_get_iterator_p (m,report_to_l()); p->daddy_iter_l_ = (Music_iterator*)this; @@ -156,252 +157,3 @@ Music_iterator::Music_iterator() first_b_ = true; } -/* ************** */ - -Chord_iterator::Chord_iterator (Chord const *chord_C) -{ - chord_C_ = chord_C; -} - -void -Chord_iterator::construct_children() -{ - int j = 0; - for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; - i.ok(); j++, i++) - { - Music_iterator * mi = get_iterator_p (i.ptr()); - if ( mi->ok()) - { - set_translator (mi->report_to_l()->ancestor_l ( - chord_C_->multi_level_i_) ); - children_p_list_.bottom().add (mi); - } - else - delete mi; - } -} -void -Chord_iterator::do_print() const -{ -#ifndef NPRINT - for (PCursor i (children_p_list_.top()); i.ok (); i++) - { - i->print(); - } -#endif -} - -void -Chord_iterator::process_and_next (Moment until) -{ - for (PCursor i (children_p_list_.top()); i.ok ();) - { - if (i->next_moment() == until) - { - i->process_and_next (until); - } - if (!i->ok()) - delete i.remove_p(); - else - i++; - } - Music_iterator::process_and_next (until); -} - - -IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator); - -Moment -Chord_iterator::next_moment()const -{ - Moment next_ = infinity_mom; - for (PCursor i (children_p_list_.top()); i.ok (); i++) - next_ = next_ next_moment() ; - return next_; -} - - - -bool -Chord_iterator::ok()const -{ - return children_p_list_.size(); -} - -/* ************** */ - -void -Voice_iterator::do_print()const -{ - if (iter_p_) - iter_p_->print(); -} - -Voice_iterator::Voice_iterator (Voice const*v) - : PCursor ( v->music_p_list_) -{ - here_mom_ = v->offset_mom_; - voice_C_ = v; - iter_p_ =0; -} - -void -Voice_iterator::construct_children() -{ - while (PCursor::ok()) - { - start_next_element(); - if ( !iter_p_->ok()) - { - leave_element(); - } - else - { - set_voice_translator(); - break; - } - } -} - -void -Voice_iterator::leave_element() -{ - delete iter_p_; - iter_p_ =0; - MInterval elt_time = ptr()->time_int (); - if (!elt_time.empty_b()) - here_mom_ += elt_time.length(); - PCursor::next(); -} - -void -Voice_iterator::start_next_element() -{ - assert (!iter_p_); - iter_p_ = get_iterator_p (ptr()); -} - -void -Voice_iterator::set_voice_translator() -{ - if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) - set_translator (iter_p_->report_to_l()); -} - -Voice_iterator::~Voice_iterator() -{ - assert (! iter_p_); -} - - -IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator); - -void -Voice_iterator::process_and_next (Moment until) -{ - while (1) - { - Moment local_until = until - here_mom_; - while ( iter_p_->ok()) - { - Moment here = iter_p_->next_moment(); - if (here != local_until) - goto loopexit; - - iter_p_->process_and_next (local_until); - } - - if (!iter_p_->ok()) - { - leave_element(); - if ( PCursor::ok()) - { - start_next_element(); - set_voice_translator(); - } - else - { - goto loopexit; - } - } - } - -loopexit: - - Music_iterator::process_and_next (until); -} - -Moment -Voice_iterator::next_moment()const -{ - return iter_p_->next_moment() + here_mom_; -} - -bool -Voice_iterator::ok()const -{ - return iter_p_; -} - - -IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator); - -void -Request_chord_iterator::construct_children() -{ - get_req_translator_l(); -} - -Request_chord_iterator::Request_chord_iterator (Request_chord*el_l) -{ - elt_l_ = el_l; - elt_duration_ = el_l->time_int().length (); - last_b_ = false; -} - - -bool -Request_chord_iterator::ok()const -{ - return (elt_duration_ && !last_b_) || first_b_; -} - - - -Moment -Request_chord_iterator::next_moment()const -{ - Moment m (0); - if (!first_b_) - m = elt_duration_; - return m; -} - -void -Request_chord_iterator::do_print() const -{ -#ifndef NPRINT - DOUT << "duration: " << elt_duration_; -#endif -} -void -Request_chord_iterator::process_and_next (Moment mom) -{ - if ( first_b_) - { - for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) - { - assert (i->is_type_b (Request::static_name())); - Request * req_l = (Request*)i.ptr(); - bool gotcha = report_to_l()->try_request (req_l); - if (!gotcha) - req_l->warning ("Junking request: " + String (req_l->name())); - - } - first_b_ = false; - } - - if ( mom >= elt_duration_) - last_b_ = true; -} diff --git a/lily/music-list.cc b/lily/music-list.cc index ad10bce46e..93a64e6a01 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -25,7 +25,7 @@ IMPLEMENT_IS_TYPE_B1(Voice,Music_list); IMPLEMENT_IS_TYPE_B1(Chord,Music_list); MInterval -Chord::time_int()const +Chord::time_int() const { MInterval m; for (iter (music_p_list_.top(), i); i.ok (); i++) @@ -62,7 +62,7 @@ Voice::time_int() const /* c4 <> c4 */ - if ( !interval.empty_b()) + if (!interval.empty_b()) last += interval.length(); } return offset_mom_ + MInterval (0,last); @@ -98,7 +98,7 @@ Music_list::transpose (Melodic_req const*rq) } void -Music_list::do_print()const +Music_list::do_print() const { #ifndef NPRINT for (iter (music_p_list_.top(),i); i.ok (); i++) diff --git a/lily/music.cc b/lily/music.cc index 6cd34fc2a0..7de77d1fc9 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -18,10 +18,10 @@ Music::time_int() const } void -Music::print()const +Music::print() const { #ifndef NPRINT - if ( ! check_debug) + if (! check_debug) return ; DOUT << name() << "{"; if (type_str_!="" || id_str_!="") @@ -43,7 +43,7 @@ Music::translate (Moment) } void -Music::do_print()const +Music::do_print() const { } diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 857d364ede..f09f0dd6c8 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -101,7 +101,7 @@ My_lily_lexer::set_identifier (String name_str, Identifier*i) Identifier *old = lookup_identifier (name_str); if (old) { - old->warning( "redeclaration of \\" + name_str); + old->warning("redeclaration of \\" + name_str); delete old; } (*identifier_assoc_p_)[name_str] = i; @@ -121,7 +121,7 @@ My_lily_lexer::~My_lily_lexer() delete identifier_assoc_p_; } void -My_lily_lexer::print_declarations (bool init_b)const +My_lily_lexer::print_declarations (bool init_b) const { for (Assoc_iter ai (*identifier_assoc_p_); ai.ok(); ai++) diff --git a/lily/note-performer.cc b/lily/note-performer.cc index dd2ac9da14..9ae829f7ff 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -26,7 +26,7 @@ void Note_performer::do_print() const { #ifndef NPRINT - if ( note_req_l_) + if (note_req_l_) { note_req_l_->print(); } @@ -37,20 +37,20 @@ void Note_performer::process_requests() { // this is _really_ braindead, but it generates some output - if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) + if (!note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) return; - play (new Audio_note (note_req_l_) ); + play (new Audio_note (note_req_l_)); note_req_l_ = 0; } bool Note_performer::do_try_request (Request* req_l) { - if ( note_req_l_) + if (note_req_l_) return false; - if ( !req_l->musical() || !req_l->musical ()->note ()) + if (!req_l->musical() || !req_l->musical ()->note ()) return false; note_req_l_ = req_l->musical()->melodic (); diff --git a/lily/p-col.cc b/lily/p-col.cc index 9e5be11664..715adecd83 100644 --- a/lily/p-col.cc +++ b/lily/p-col.cc @@ -1,5 +1,5 @@ /* - p-col.cc -- implement PCol + p-col.cc -- implement Paper_column source file of the GNU LilyPond music typesetter @@ -8,157 +8,91 @@ #include "p-col.hh" #include "p-score.hh" - #include "debug.hh" -Interval -PCol::width() const -{ - Interval w; - - for (iter_top (its,i); i.ok(); i++) - w.unite (i->width()); - if (w.empty_b()) - w.unite (Interval (0,0)); - return w; -} - -void -PCol::clean_breakable_items() -{ - if (!line_l_) - { - its.junk_links(); - } - if (prebreak_p_) - prebreak_p_->clean_breakable_items(); - if (postbreak_p_) - postbreak_p_->clean_breakable_items(); -} int -PCol::rank_i() const +Paper_column::rank_i() const { return rank_i_; } void -PCol::set_rank (int i) +Paper_column::set_rank (int i) { rank_i_ = i; - if (prebreak_p_) - prebreak_p_->rank_i_ = i; - if (postbreak_p_) - postbreak_p_->rank_i_ = i; + if (prebreak_l()) + prebreak_l()->rank_i_ = i; + if (postbreak_l()) + postbreak_l()->rank_i_ = i; } void -PCol::print() const +Paper_column::do_print() const { #ifndef NPRINT - DOUT << "PCol {"; - DOUT << "rank: " << rank_i_ << '\n'; - - DOUT << "# symbols: " << its.size() ; - if (prebreak_p_){ - DOUT << "\npre: "; - prebreak_p_->print(); + if (prebreak_l()) + { + DOUT << "\npre: "; + prebreak_l()->print(); } - if (postbreak_p_) { + if (postbreak_l()) + { DOUT << "post: "; - postbreak_p_->print(); + postbreak_l()->print(); } - else if (daddy_l_) + if (break_status_i_) { - DOUT <<'\n' << ((this == daddy_l_->prebreak_p_) ? - "prebreak" : "postbreak"); - DOUT << '\n'; + DOUT <<'\n' << ((break_status_i_ == -1)? "prebreak" : "postbreak"); + DOUT << '\n'; } DOUT << "extent: " << width().str () << "\n"; - DOUT << "}\n"; #endif } int -PCol::compare (PCol const &c1, PCol const &c2) +Paper_column::compare (Paper_column const &c1, Paper_column const &c2) { return c1.rank_i() - c2.rank_i (); } -void -PCol::OK() const +Paper_column* +Paper_column::prebreak_l() const { -#ifndef NDEBUG - if (prebreak_p_ || postbreak_p_) - { - assert (prebreak_p_&&postbreak_p_); - assert (prebreak_p_->daddy_l_ == this); - assert (postbreak_p_->daddy_l_ == this); - } -#endif + return (Paper_column*)broken_to_drul_[LEFT]; } -void -PCol::set_breakable() +Paper_column* +Paper_column::postbreak_l() const { - if (breakable_b()) - return; - - do_set_breakable(); - prebreak_p_->pscore_l_ = pscore_l_; - postbreak_p_->pscore_l_ = pscore_l_; - - prebreak_p_->daddy_l_ = postbreak_p_->daddy_l_ = this; + return(Paper_column*) broken_to_drul_[RIGHT]; } -void -PCol::do_set_breakable() -{ - prebreak_p_ = new PCol; - postbreak_p_ = new PCol; -} - - bool -PCol::breakpoint_b() const +Paper_column::breakpoint_b() const { return !line_l_; } -bool -PCol::breakable_b() const -{ - return prebreak_p_||postbreak_p_||daddy_l_; -} - -PCol::PCol() +Paper_column::Paper_column() { used_b_ = false; error_mark_b_ = false; - daddy_l_ = 0; - prebreak_p_=0; - postbreak_p_=0; line_l_=0; - hpos_f_ = -1.0; - pscore_l_ = 0; rank_i_ = -1; } -PCol::~PCol() -{ - delete prebreak_p_; - delete postbreak_p_; -} - -void -PCol::add (Item *i) +Line_of_score* +Paper_column::line_l() const { - its.bottom().add (i); - i->pcol_l_ = this; + return line_l_; } bool -PCol::used_b()const +Paper_column::used_b() const { - return daddy_l_ || breakable_b() || its.size ()|| used_b_; + return linked_b(); } + +IMPLEMENT_IS_TYPE_B1(Paper_column, Horizontal_group_item); + diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index ea11129e25..ae1e93dd6f 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -53,17 +53,17 @@ Performer_group_performer::depth_i() const void Performer_group_performer::do_creation_processing() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for (PCursor i (perf_p_list_.top()); i.ok (); i++) i->creation_processing(); } void -Performer_group_performer::do_print()const +Performer_group_performer::do_print() const { #ifndef NPRINT - if ( !check_debug) + if (!check_debug) return ; - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for (PCursor i (perf_p_list_.top()); i.ok (); i++) i->print(); #endif } @@ -71,7 +71,7 @@ Performer_group_performer::do_print()const void Performer_group_performer::do_removal_processing() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for (PCursor i (perf_p_list_.top()); i.ok (); i++) i->do_removal_processing(); } @@ -81,7 +81,7 @@ Performer_group_performer::do_try_request (Request* req_l) bool hebbes_b =false; for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) hebbes_b =nongroup_l_arr_[i]->try_request (req_l); - if ( !hebbes_b && daddy_perf_l_) + if (!hebbes_b && daddy_perf_l_) hebbes_b = daddy_perf_l_->try_request (req_l); return hebbes_b ; } @@ -90,7 +90,7 @@ Translator* Performer_group_performer::find_get_translator_l (String n,String id) { Translator * ret=0; - Input_translator* itrans_l= itrans_l_-> recursive_find ( n); + Input_translator* itrans_l= itrans_l_-> recursive_find (n); if (itrans_l) { ret = find_performer_l (n,id); @@ -102,7 +102,7 @@ Performer_group_performer::find_get_translator_l (String n,String id) add (group); ret = group; - if (group->itrans_l_->is_name_b (n) ) + if (group->itrans_l_->is_name_b (n)) ret ->id_str_ = id; else return ret->find_get_translator_l (n,id); @@ -137,7 +137,7 @@ Translator* Performer_group_performer::get_default_interpreter() { // ? - if ( is_bottom_performer_b()) + if (is_bottom_performer_b()) return daddy_perf_l_->get_default_interpreter(); Performer_group_performer *perf_p= itrans_l_-> @@ -164,7 +164,7 @@ Performer_group_performer::print() const void Performer_group_performer::process_requests() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for (PCursor i (perf_p_list_.top()); i.ok (); i++) i->process_requests(); } diff --git a/lily/performer.cc b/lily/performer.cc index ad2f9805ed..ed72f2a2ce 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -36,7 +36,7 @@ Performer::play (Audio_element* p) } int -Performer::get_tempo_i()const +Performer::get_tempo_i() const { return daddy_perf_l_->get_tempo_i(); } diff --git a/lily/request-iterator.cc b/lily/request-iterator.cc new file mode 100644 index 0000000000..82093173e8 --- /dev/null +++ b/lily/request-iterator.cc @@ -0,0 +1,75 @@ +/* + request-iterator.cc -- implement Request_chord_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "translator.hh" +#include "debug.hh" +#include "request-iterator.hh" +#include "music-list.hh" +#include "request.hh" + +IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator); + +void +Request_chord_iterator::construct_children() +{ + get_req_translator_l(); +} + +Request_chord_iterator::Request_chord_iterator (Request_chord*el_l) +{ + elt_l_ = el_l; + MInterval elt_dur =el_l->time_int(); + elt_duration_ = elt_dur.length (); + last_b_ = false; +} + + +bool +Request_chord_iterator::ok() const +{ + return (elt_duration_ && !last_b_) || first_b_; +} + + + +Moment +Request_chord_iterator::next_moment() const +{ + Moment m (0); + if (!first_b_) + m = elt_duration_; + return m; +} + +void +Request_chord_iterator::do_print() const +{ +#ifndef NPRINT + DOUT << "duration: " << elt_duration_; +#endif +} +void +Request_chord_iterator::process_and_next (Moment mom) +{ + if (first_b_) + { + for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) + { + assert (i->is_type_b (Request::static_name())); + Request * req_l = (Request*)i.ptr(); + bool gotcha = report_to_l()->try_request (req_l); + if (!gotcha) + req_l->warning ("Junking request: " + String (req_l->name())); + + } + first_b_ = false; + } + + if (mom >= elt_duration_) + last_b_ = true; +} diff --git a/lily/request.cc b/lily/request.cc index 1b431d2f2d..488b2cad95 100644 --- a/lily/request.cc +++ b/lily/request.cc @@ -25,18 +25,18 @@ Request::time_int() const bool -Request::equal_b (Request *r)const +Request::equal_b (Request *r) const { - if ( is_type_b ( r->name()) ) + if (is_type_b (r->name())) return r->do_equal_b ((Request*)this); - if ( r->is_type_b (name())) + if (r->is_type_b (name())) return do_equal_b (r); return false; } bool -Request::do_equal_b (Request*)const +Request::do_equal_b (Request*) const { return false; } diff --git a/lily/rest-collision-grav.cc b/lily/rest-collision-grav.cc index 86a4030bdf..fbd6d0ba5e 100644 --- a/lily/rest-collision-grav.cc +++ b/lily/rest-collision-grav.cc @@ -62,7 +62,7 @@ void Rest_collision_engraver::do_print() const { #ifndef NPRINT - if ( rest_collision_p_) + if (rest_collision_p_) rest_collision_p_->print(); #endif } diff --git a/lily/score-align-grav.cc b/lily/score-align-grav.cc index d86903eb7b..7f8ee615e1 100644 --- a/lily/score-align-grav.cc +++ b/lily/score-align-grav.cc @@ -41,7 +41,7 @@ Score_align_engraver::acknowledge_element (Score_elem_info inf) announce_element (Score_elem_info (align_p_,0)); } Score_elem * unbound_elem = inf.elem_l_; - while ( unbound_elem->axis_group_l_a_[X_AXIS]) + while (unbound_elem->axis_group_l_a_[X_AXIS]) unbound_elem = unbound_elem->axis_group_l_a_[X_AXIS]; align_p_->add_element (unbound_elem); } diff --git a/lily/score-column.cc b/lily/score-column.cc index d6f4e739a5..1827c04639 100644 --- a/lily/score-column.cc +++ b/lily/score-column.cc @@ -17,16 +17,15 @@ Score_column::Score_column (Moment w) } void -Score_column::print() const +Score_column::do_print() const { #ifndef NPRINT - DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n'; + DOUT << "mus "<< musical_b_ <<" at " << when_<<'\n'; DOUT << "durations: ["; for (int i=0; i < durations.size(); i++) - DOUT << durations[i] << " "; + DOUT << durations[i] << " "; DOUT << "]\n"; - PCol::print(); - DOUT << "}\n"; + Paper_column::do_print(); #endif } @@ -48,21 +47,10 @@ Score_column::add_duration (Moment d) assert (d); for (int i = 0; i< durations.size(); i++) { - if (d == durations[i]) - return ; + if (d == durations[i]) + return ; } durations.push (d); } -void -Score_column::do_set_breakable() -{ - Score_column *c1 = new Score_column (when_); - Score_column *c2 = new Score_column (when_); - prebreak_p_ =c1; - postbreak_p_ = c2; - c1->durations = durations; - c2->durations = durations; - c1->musical_b_ - = c2->musical_b_ = musical_b_; -} +IMPLEMENT_IS_TYPE_B1(Score_column, Paper_column); diff --git a/lily/score-elem.cc b/lily/score-elem.cc index 5569e5bf83..9d7b090daf 100644 --- a/lily/score-elem.cc +++ b/lily/score-elem.cc @@ -22,15 +22,15 @@ #include "p-col.hh" Score_elem* -Score_elem::dependency (int i)const +Score_elem::dependency (int i) const { - return (Score_elem*) get_out_edge_arr()[i]; + return (Score_elem*) get_out_edge_arr ()[i]; } int -Score_elem::dependency_size() const +Score_elem::dependency_size () const { - return get_out_edge_arr().size (); + return get_out_edge_arr ().size (); } Score_elem* @@ -45,48 +45,37 @@ Score_elem::dependent_size() const return get_in_edge_arr().size (); } - - String -Score_elem::TeX_string_without_offset (Offset o)const +Score_elem::make_TeX_string (Offset o)const { - if (transparent_b_) - return ""; String s ("\\placebox{%}{%}{%}"); Array a; a.push (print_dimen (o.y())); a.push (print_dimen (o.x())); String t = output->TeX_string(); if (t == "") - return t; + return t; a.push (t); String r; if (check_debug) - r = String ("\n%start: ") + name() + "\n"; - r += substitute_args (s, a);; + r = String ("\n%start: ") + name() + "\n"; + r += substitute_args (s, a); return r; } - String -Score_elem::TeX_string() const +Score_elem::do_TeX_output_str () const { - assert (status_ > POSTCALCED); - return TeX_string_without_offset (offset_); + return make_TeX_string(absolute_offset()); } -void -Score_elem::copy_dependencies (Score_elem const &s) +Score_elem::Score_elem (Score_elem const&s) { /* called from derived ctor, so most info points to the same deps - as (Directed_graph_node&)s. Nobody points to us, so don't copy - dependents. + as (Directed_graph_node&)s. Nobody points to us, so don't copy + dependents. */ copy_edges_out (s); -} - -Score_elem::Score_elem (Score_elem const&s) -{ transparent_b_ = s.transparent_b_; empty_b_ = s.empty_b_; axis_group_l_a_[0] = axis_group_l_a_[1] =0; @@ -104,20 +93,19 @@ Score_elem::~Score_elem() delete output; status_ = DELETED; output = 0; - } /* GEOMETRY */ Real -Score_elem::absolute_coordinate (Axis a)const +Score_elem::absolute_coordinate (Axis a) const { Real r = offset_[a]; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; - axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a]) + for (Axis_group_element * axis_group_l = axis_group_l_a_[a]; + axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a]) - r += axis_group_l->offset_[a]; + r += axis_group_l->offset_[a]; return r; } @@ -128,38 +116,38 @@ Score_elem::absolute_offset() const return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS)); } - void +void Score_elem::translate (Real y, Axis a) { offset_[a] += y; } Real -Score_elem::relative_coordinate (Axis_group_element*e, Axis a)const +Score_elem::relative_coordinate (Axis_group_element*e, Axis a) const { Real r =0.0; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; - axis_group_l != e; - axis_group_l = axis_group_l->axis_group_l_a_[a]) - r += axis_group_l->offset_[a]; + for (Axis_group_element * axis_group_l = axis_group_l_a_[a]; + axis_group_l != e; + axis_group_l = axis_group_l->axis_group_l_a_[a]) + r += axis_group_l->offset_[a]; return r; } Axis_group_element* -Score_elem::common_group (Score_elem const* s, Axis a)const +Score_elem::common_group (Score_elem const* s, Axis a) const { Link_array my_groups; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; - axis_group_l; - axis_group_l = axis_group_l->axis_group_l_a_[a]) - my_groups.push (axis_group_l); + for (Axis_group_element * axis_group_l = axis_group_l_a_[a]; + axis_group_l; + axis_group_l = axis_group_l->axis_group_l_a_[a]) + my_groups.push (axis_group_l); Axis_group_element* common_l=0; - for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a]; - !common_l && axis_group_l; - axis_group_l = axis_group_l->axis_group_l_a_[a]) - common_l = my_groups.find_l (axis_group_l); + for (Axis_group_element * axis_group_l = s->axis_group_l_a_[a]; + !common_l && axis_group_l; + axis_group_l = axis_group_l->axis_group_l_a_[a]) + common_l = my_groups.find_l (axis_group_l); return common_l; } @@ -179,12 +167,12 @@ Score_elem::do_width() const if (!output) { - Molecule*m = brew_molecule_p(); - r = m->extent().x (); - delete m; + Molecule*m = brew_molecule_p(); + r = m->extent().x (); + delete m; } else - r = output->extent().x (); + r = output->extent().x (); return r; } @@ -195,17 +183,17 @@ Score_elem::width() const } Interval -Score_elem::extent (Axis a)const +Score_elem::extent (Axis a) const { Interval r; - if ( !empty_b_) + if (!empty_b_) { - r = (a == X_AXIS)? do_width(): do_height (); + r = (a == X_AXIS)? do_width(): do_height (); } if (!r.empty_b()) // float exception on DEC Alpha - r+=offset_[a]; + r+=offset_[a]; return r; } @@ -216,12 +204,12 @@ Score_elem::do_height() const Interval r; if (!output) { - Molecule*m = brew_molecule_p(); - r = m->extent().y (); - delete m; + Molecule*m = brew_molecule_p(); + r = m->extent().y (); + delete m; } else - r = output->extent().y (); + r = output->extent().y (); return r; } @@ -235,19 +223,19 @@ Score_elem::height() const STANDARD METHS */ void -Score_elem::print()const +Score_elem::print() const { #ifndef NPRINT DOUT << name() << "{\n"; DOUT << "dets: " << dependent_size() << "dependencies: " << - dependency_size(); + dependency_size(); if (offset_.x() || offset_.y ()) - DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")"; + DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")"; DOUT << "\n"; do_print(); if (output) - output->print(); + output->print(); DOUT << "}\n"; #endif @@ -275,7 +263,7 @@ void Score_elem::add_processing() { if (status_ >= VIRGIN) - return; + return; status_ = VIRGIN; do_add_processing(); } @@ -284,17 +272,17 @@ void Score_elem::pre_processing() { if (status_ >= PRECALCED) - return; + return; assert (status_ != PRECALCING); // cyclic dependency status_ = PRECALCING; for (int i=0; i < dependency_size(); i++) - dependency (i)->pre_processing(); + dependency (i)->pre_processing(); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->pre_processing(); + extra[i]->pre_processing(); do_pre_processing(); status_ = PRECALCED; @@ -304,21 +292,21 @@ void Score_elem::breakable_col_processing() { if (status_ >= PREBROKEN) - return; + return; if (status_== PREBREAKING) { - status_ = PREBROKEN; - return ; + status_ = PREBROKEN; + return ; } status_ = PREBREAKING; for (int i=0; i < dependency_size(); i++) - dependency (i)->breakable_col_processing(); + dependency (i)->breakable_col_processing(); - Link_array extra (get_extra_dependencies()); + Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->breakable_col_processing(); + extra[i]->breakable_col_processing(); do_breakable_col_processing(); @@ -329,21 +317,21 @@ void Score_elem::break_processing() { if (status_ >= BROKEN) - return; + return; if (status_ == BREAKING) { - status_ = BROKEN; - return; + status_ = BROKEN; + return; } status_ = BREAKING; for (int i=0; i < dependency_size(); i++) - dependency (i)->break_processing(); + dependency (i)->break_processing(); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->break_processing(); + extra[i]->break_processing(); @@ -363,17 +351,17 @@ void Score_elem::post_processing() { if (status_ >= POSTCALCED) - return; + return; assert (status_ != POSTCALCING);// cyclic dependency status_=POSTCALCING; for (int i=0; i < dependency_size(); i++) - dependency (i)->post_processing(); + dependency (i)->post_processing(); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->post_processing(); + extra[i]->post_processing(); do_post_processing(); @@ -381,7 +369,7 @@ Score_elem::post_processing() } Score_elem::Status -Score_elem::status()const +Score_elem::status() const { return status_; } @@ -389,23 +377,45 @@ Score_elem::status()const void Score_elem::molecule_processing() { - if (status_ >= OUTPUT) - return; - status_ = OUTPUT; // do it only once. + if (status_ >= BREWED) + return; + status_ = BREWED; // do it only once. for (int i=0; i < dependency_size(); i++) - dependency (i)->molecule_processing(); + dependency (i)->molecule_processing(); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->molecule_processing(); + extra[i]->molecule_processing(); if (transparent_b_) - return ; + return ; output= brew_molecule_p(); } +String +Score_elem::TeX_output_str() const +{ + String s; + if (status_ >= TEXOUTPUT) + return ""; + + ((Score_elem*)this)->status_ = TEXOUTPUT; + + for (int i=0; i < dependency_size(); i++) + s += dependency (i)->TeX_output_str(); + + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) + s += extra[i]->TeX_output_str (); + + if (!transparent_b_) + s+= do_TeX_output_str(); + + return s; +} + /* VIRTUAL STUBS @@ -443,12 +453,18 @@ Score_elem::do_substitute_dependent (Score_elem*,Score_elem*) void Score_elem::do_unlink() -{} +{ +} + +void +Score_elem::do_junk_links() +{ +} IMPLEMENT_IS_TYPE_B(Score_elem); Molecule* -Score_elem::brew_molecule_p()const +Score_elem::brew_molecule_p() const { Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0)))); return new Molecule (a); @@ -456,7 +472,7 @@ Score_elem::brew_molecule_p()const Line_of_score * -Score_elem::line_l()const +Score_elem::line_l() const { return 0; } @@ -486,52 +502,43 @@ Score_elem::substitute_dependency (Score_elem* old, Score_elem* new_l) old->do_substitute_dependent (this, 0); } -void -Score_elem::junk_dependencies() -{ - while ( dependency_size()) - { - remove_edge_out (dependency (0)); - } -} - void Score_elem::handle_broken_dependencies() { Line_of_score *line = line_l(); if (!line) - return; + return; Link_array remove_us_arr; for (int i=0; i < dependency_size(); i++) { - Score_elem * elt = dependency (i); - if (elt->line_l() != line) - { - if (elt->spanner()) - { - Spanner * sp = elt->spanner(); - Spanner * broken = sp->find_broken_piece (line); - substitute_dependency (sp, broken); - - add_dependency (broken); - } - else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b () - && elt->item()->break_status_i () == 0) - { - Item * my_item = elt->item()->find_prebroken_piece (line); - substitute_dependency (elt, my_item); - if (my_item) - add_dependency (my_item); - } - remove_us_arr.push (elt); - } + Score_elem * elt = dependency (i); + if (elt->line_l() != line) + { + if (elt->spanner()) + { + Spanner * sp = elt->spanner(); + Spanner * broken = sp->find_broken_piece (line); + substitute_dependency (sp, broken); + + add_dependency (broken); + } + else if (elt->item()) + { + Item * my_item = elt->item()->find_prebroken_piece (line); + + substitute_dependency (elt, my_item); + if (my_item) + add_dependency (my_item); + } + remove_us_arr.push (elt); + } } remove_us_arr.default_sort(); remove_us_arr.uniq(); for (int i=0; i item(); - if (it_l && it_l->breakable_b_) - if (item()) - { - Score_elem *new_l = it_l->find_prebroken_piece (item()->pcol_l_); - if (new_l != elt) - { - new_arr.push (new_l); - old_arr.push (elt); - } - }else + Score_elem * elt = dependency (i); + Item *it_l = elt->item(); + if (it_l && it_l->breakable_b_) + if (item()) + { + Score_elem *new_l = it_l->find_prebroken_piece (item()->break_status_i_); + if (new_l != elt) { - new_arr.push (it_l->broken_to_a_[0]); - old_arr.push (0); - old_arr.push (0); - new_arr.push (it_l->broken_to_a_[1]); + new_arr.push (new_l); + old_arr.push (elt); } + } + else + { + new_arr.push (it_l->broken_to_drul_[LEFT]); + old_arr.push (0); + old_arr.push (0); + new_arr.push (it_l->broken_to_drul_[RIGHT]); + } } for (int i=0; i < old_arr.size(); i++) - if (old_arr[i]) - substitute_dependency (old_arr[i], new_arr[i]); + if (old_arr[i]) + substitute_dependency (old_arr[i], new_arr[i]); status_ = PREBROKEN; @@ -590,48 +598,56 @@ void Score_elem::unlink_all() { for (int i=0; i < dependency_size(); i++) - dependency (i)->unlink_all(); + dependency (i)->unlink_all(); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) - extra[i]->unlink_all(); + extra[i]->unlink_all(); junk_links(); - axis_group_l_a_[0] = axis_group_l_a_[1] =0; + axis_group_l_a_[X_AXIS] = axis_group_l_a_[Y_AXIS] =0; + do_unlink(); } void Score_elem::unlink() { do_unlink(); - while ( dependency_size()) + while (dependency_size()) { - do_substitute_dependency (dependency (0),0); - remove_edge_out_idx (0); + do_substitute_dependency (dependency (0),0); + remove_edge_out_idx (0); } - while ( dependent_size()) + while (dependent_size()) { - dependent (0)->remove_dependency (this); + dependent (0)->remove_dependency (this); } for (int j=0; j < 2; j++) - if ( axis_group_l_a_[j]) - axis_group_l_a_[j]->remove_element (this); + if (axis_group_l_a_[j]) + axis_group_l_a_[j]->remove_element (this); } void -Score_elem::OK()const +Score_elem::OK() const { #ifndef NDEBUG for (int i=0; i < dependency_size(); i++) { - dependency (i)->OK(); + dependency (i)->OK(); } #endif } Link_array -Score_elem::get_extra_dependencies()const +Score_elem::get_extra_dependencies() const { Link_array empty; return empty; } + +bool +Score_elem::linked_b() const +{ + return get_extra_dependencies().size() || + dependency_size(); +} diff --git a/lily/scoreline.cc b/lily/scoreline.cc index 7bb391211a..f332409152 100644 --- a/lily/scoreline.cc +++ b/lily/scoreline.cc @@ -20,50 +20,15 @@ take out hard coded TeX stuff. */ String -Line_of_score::TeX_string() const +Line_of_score::TeX_output_str () const { - String s ("\\hbox{%<- line of score\n"); - if (error_mark_b_) - s+= "\\scorelineerrormark"; - - - Real lastpos = cols[0]->hpos_f_; - for (int i=0; i < cols.size(); i++) - { - PCol* col_l= cols[i]; - // all items in the current line & staff. - String chunk_str; - - - Link_array elems; - - if (col_l->error_mark_b_) - { - chunk_str += String ("\\columnerrormark"); - } - - // now output the items. - for (iter_top (col_l->its,j); j.ok(); j++) - { - elems.push (j); - } - - // spanners. - for (iter_top (col_l->starters,j); j.ok(); j++) - { - if (j->name() != name ()) - elems.push (j); - } - - for (int j =0; j< elems.size(); j++) - { - Offset o = elems[j]->absolute_offset(); - o[X_AXIS] += cols[i]->hpos_f_; - s += elems[j]->TeX_string_without_offset (o); - } - } - s += "}"; - return s; + String s ("\\hbox{%<- line of score\n"); + if (error_mark_b_) + s+= "\\scorelineerrormark"; + + s+= Score_elem::TeX_output_str(); + s += "}"; + return s; } @@ -73,23 +38,20 @@ Line_of_score::Line_of_score() } - - - IMPLEMENT_IS_TYPE_B1(Line_of_score,Spanner); void Line_of_score::add (Score_elem*e) { // avoid excess dependencies. - if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1])) - add_dependency (e); + if (!(e->axis_group_l_a_[0] || e->axis_group_l_a_[1])) + add_dependency (e); } bool -Line_of_score::contains_b (PCol const* c)const +Line_of_score::contains_b (Paper_column const* c) const { - return cols.find_l ((PCol*)c); + return cols.find_l ((Paper_column*)c); } void @@ -97,72 +59,82 @@ Line_of_score::set_breaking (Array const &breaking) { for (int j=0; j < breaking.size(); j++) { - const Array &curline (breaking[j].cols); - const Array &errors (breaking[j].error_col_l_arr_); - const Array &config (breaking[j].config); + const Array &curline (breaking[j].cols); + const Array &errors (breaking[j].error_col_l_arr_); + const Array &config (breaking[j].config); - for (int i=0; i < errors.size(); i++) - errors[i]->error_mark_b_ = true; + for (int i=0; i < errors.size(); i++) + errors[i]->error_mark_b_ = true; - Line_of_score *line_l=0; - Line_of_score *line_p =0; - - if (breaking.size() >1) - { - line_p = (Line_of_score*)clone()->spanner (); - line_p->copy_dependencies (*this); - line_l = line_p; - } - else - line_l = this; + Line_of_score *line_l=0; + Line_of_score *line_p =0; - ((Array &)line_l->cols) = curline; - line_l->left_col_l_ = curline[0]; - line_l->right_col_l_= curline.top(); + if (breaking.size() >1) + { + line_p = (Line_of_score*)clone()->spanner (); + line_l = line_p; + } + else + line_l = this; - if (line_p) - { - pscore_l_->typeset_broken_spanner (line_p); - broken_into_l_arr_.push (line_p); - } + ((Array &)line_l->cols) = curline; + line_l->set_bounds(LEFT,curline[0]); + + line_l->set_bounds(RIGHT,curline.top()); - for (int i=0; i < curline.size(); i++) - { - curline[i]->hpos_f_ = config[i]; - curline[i]->line_l_ = (Line_of_score*)line_l; - } + if (line_p) + { + pscore_l_->typeset_broken_spanner (line_p); + broken_into_l_arr_.push (line_p); + } + + for (int i=0; i < curline.size(); i++) + { + curline[i]->translate(config[i],X_AXIS); + curline[i]->line_l_ = (Line_of_score*)line_l; + } } } + void Line_of_score::break_into_pieces (bool) { + } Link_array -Line_of_score::get_lines()const +Line_of_score::get_lines() const { Link_array ret; if (broken_into_l_arr_.size()) - for (int i=0; i < broken_into_l_arr_.size(); i++) - { - ret.push ((Line_of_score*)broken_into_l_arr_[i]); - } + for (int i=0; i < broken_into_l_arr_.size(); i++) + { + ret.push ((Line_of_score*)broken_into_l_arr_[i]); + } else - ret.push ((Line_of_score*)this); // ugh + ret.push ((Line_of_score*)this); // ugh return ret; } void -Line_of_score::do_print()const +Line_of_score::do_print() const { Spanner::do_print(); } Interval -Line_of_score::do_width()const +Line_of_score::do_width() const { return Spanner::do_width(); } + +void +Line_of_score::do_breakable_col_processing() +{ + for (int i=0; i < cols.size (); i++) + cols[i]->breakable_col_processing(); + Spanner::do_breakable_col_processing(); +} diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 152e9a7cd8..5f19f84177 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -60,7 +60,7 @@ Span_bar::do_width() const void Span_bar::do_pre_processing() { - if ( spanning_l_arr_.size() < 1) + if (spanning_l_arr_.size() < 1) { transparent_b_ = true; empty_b_ =true; @@ -74,11 +74,11 @@ Span_bar::do_pre_processing() transparent_b_=true; empty_b_ = true; } - else if ( type_str_ == "|:") + else if (type_str_ == "|:") { type_str_ = ".|"; } - else if ( type_str_ == ":|") + else if (type_str_ == ":|") { type_str_ = "|."; } @@ -93,7 +93,7 @@ Span_bar::get_bar_sym (Real dy) const Molecule* -Span_bar::brew_molecule_p()const +Span_bar::brew_molecule_p() const { Interval y_int; for (int i=0; i < spanning_l_arr_.size(); i++) @@ -109,7 +109,7 @@ Span_bar::brew_molecule_p()const Symbol s = get_bar_sym (y_int.length()); Molecule*output = new Molecule (Atom (s)); - output->translate ( y_int[-1], Y_AXIS); + output->translate (y_int[-1], Y_AXIS); return output; } diff --git a/lily/span-score-bar.cc b/lily/span-score-bar.cc index a7592d5320..96c73a9d1d 100644 --- a/lily/span-score-bar.cc +++ b/lily/span-score-bar.cc @@ -21,7 +21,7 @@ Span_score_bar::do_pre_processing() { Span_bar::do_pre_processing(); - if ( break_status_i() != 1) + if (break_status_i() != 1) { empty_b_ = transparent_b_ = true; } @@ -29,12 +29,12 @@ Span_score_bar::do_pre_processing() Symbol -Piano_brace::get_bar_sym (Real dy)const +Piano_brace::get_bar_sym (Real dy) const { return paper()->lookup_l ()->vbrace (dy); } Interval -Piano_brace::do_width()const +Piano_brace::do_width() const { return Interval (0,0); } diff --git a/lily/spanner.cc b/lily/spanner.cc index eac107ba8d..397cfdb6c5 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -15,37 +15,26 @@ IMPLEMENT_IS_TYPE_B1(Spanner,Score_elem); void -Spanner::do_print()const +Spanner::do_print() const { #ifndef NPRINT DOUT << "Between col "; - if ( left_col_l_) - DOUT << left_col_l_->rank_i(); - else - DOUT << "nop"; - DOUT << ", "; - if ( right_col_l_) - DOUT << right_col_l_->rank_i(); - else - DOUT << "nop"; if (broken_into_l_arr_.size()) - DOUT << "with broken pieces\n"; + DOUT << "with broken pieces\n"; #endif } void -Spanner::break_into_pieces (bool copy_deps_b) +Spanner::break_into_pieces () { - if ( broken_into_l_arr_.size()) - return; + if (broken_into_l_arr_.size()) + return; - PCol * left = left_col_l_; - PCol * right = right_col_l_; - if (left->daddy_l_) left = left->daddy_l_; - if (right->daddy_l_) right = right->daddy_l_; + Item * left = spanned_drul_[LEFT]; + Item * right = spanned_drul_[RIGHT]; - Link_array break_cols = pscore_l_->broken_col_range (left,right); + Link_array break_cols = pscore_l_->broken_col_range (left,right); Link_array broken_into_l_arr; break_cols.insert (left,0); @@ -53,23 +42,21 @@ Spanner::break_into_pieces (bool copy_deps_b) for (int i=1; i < break_cols.size(); i++) { - Spanner* span_p = clone()->spanner (); - if (copy_deps_b) - span_p->copy_dependencies (*this); - left = break_cols[i-1]; - right = break_cols[i]; - if (!right->line_l_) - right = right->prebreak_p_; - if (!left->line_l_) - left = left->postbreak_p_; - - assert (left&&right && left->line_l_ == right->line_l_); - - span_p->left_col_l_ = left; - span_p->right_col_l_ = right; + Spanner* span_p = clone()->spanner (); + left = break_cols[i-1]; + right = break_cols[i]; + if (!right->line_l()) + right = right->find_prebroken_piece(-1); + if (!left->line_l()) + left = left->find_prebroken_piece(1); + + assert (left&&right && left->line_l() == right->line_l()); + + span_p->set_bounds(LEFT,left); + span_p->set_bounds(RIGHT,right); - pscore_l_->typeset_broken_spanner (span_p); - broken_into_l_arr.push (span_p); + pscore_l_->typeset_broken_spanner (span_p); + broken_into_l_arr.push (span_p); } broken_into_l_arr_ = broken_into_l_arr; @@ -78,68 +65,110 @@ Spanner::break_into_pieces (bool copy_deps_b) void Spanner::set_my_columns() { - if (!left_col_l_->line_l_) - left_col_l_ = left_col_l_->postbreak_p_; - if (!right_col_l_->line_l_) - right_col_l_ = right_col_l_->prebreak_p_; + Direction i = (Direction)1; + do + { + if (!spanned_drul_[i]->line_l()) + set_bounds(i,spanned_drul_[i]->find_prebroken_piece(-i)); + } + while ((i*=-1) != 1); } + void -Spanner::do_break_processing() +Spanner::set_bounds(Direction d, Item*i) { - set_my_columns(); + if (spanned_drul_[d]) + spanned_drul_[d]->attached_span_l_arr_.substitute(this,0); - if (!line_l()) + spanned_drul_[d] =i; + if (i) + i->attached_span_l_arr_.push(this); +} + +void +Spanner::do_break_processing() +{ + if (!line_l()) { - break_into_pieces (true); - for (int i=0; i < broken_into_l_arr_.size(); i++) - broken_into_l_arr_[i]->handle_broken_dependencies(); + break_into_pieces (); + for (int i=0; i < broken_into_l_arr_.size(); i++) + broken_into_l_arr_[i]->handle_broken_dependencies(); } else { - handle_broken_dependencies(); + handle_broken_dependencies(); } } Spanner::Spanner() { - left_col_l_ = right_col_l_ = 0; + spanned_drul_[LEFT]=0; + spanned_drul_[RIGHT]=0; } +String +Spanner::do_TeX_output_str () const +{ + Offset left_off (spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), 0); + return make_TeX_string (absolute_offset() + left_off); +} Interval -Spanner::do_width()const +Spanner::do_width() const { - Real r = right_col_l_->hpos_f_; - Real l = left_col_l_->hpos_f_; - assert (*left_col_l_ < *right_col_l_); + Real l = spanned_drul_[LEFT]->absolute_coordinate (X_AXIS); + Real r = spanned_drul_[RIGHT]->absolute_coordinate (X_AXIS); assert (r>=l); return Interval (0, r-l); } Line_of_score * -Spanner::line_l()const +Spanner::line_l() const { - if ( left_col_l_->line_l_ != right_col_l_->line_l_) - return 0; - return left_col_l_->line_l_; + if (!spanned_drul_[LEFT] || !spanned_drul_[RIGHT]) + return 0; + if (spanned_drul_[LEFT]->line_l() != spanned_drul_[RIGHT]->line_l()) + return 0; + return spanned_drul_[LEFT]->line_l(); } Spanner* -Spanner::find_broken_piece (Line_of_score*l)const +Spanner::find_broken_piece (Line_of_score*l) const { for (int i=0; i < broken_into_l_arr_.size(); i++) - if (broken_into_l_arr_[i]->line_l() == l) - return broken_into_l_arr_[i]; + if (broken_into_l_arr_[i]->line_l() == l) + return broken_into_l_arr_[i]; return 0; } bool -Spanner::broken_b()const +Spanner::broken_b() const { return broken_into_l_arr_.size(); } + +void +Spanner::do_unlink() +{ + if (spanned_drul_[LEFT]) + { + spanned_drul_[LEFT]->attached_span_l_arr_.substitute (this,0); + spanned_drul_[LEFT] =0; + } + if (spanned_drul_[RIGHT]) + { + spanned_drul_[RIGHT]->attached_span_l_arr_.substitute (this,0); + spanned_drul_[RIGHT] = 0; + } +} + +void +Spanner::do_junk_links() +{ + spanned_drul_[LEFT] = spanned_drul_[RIGHT] =0; +} diff --git a/lily/staff-info.cc b/lily/staff-info.cc index 0857fb9b55..75854b82a9 100644 --- a/lily/staff-info.cc +++ b/lily/staff-info.cc @@ -38,13 +38,13 @@ Staff_info::command_l() return command_l_; } -PCol* +Paper_column* Staff_info::command_pcol_l() { return command_l(); } -PCol* +Paper_column* Staff_info::musical_pcol_l() { return musical_l(); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 80bbf00a30..72b1ef6840 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -35,7 +35,7 @@ Staff_performer::do_creation_processing() if (instrument_str().length_i()) { // staff name - play (new Audio_text ( Audio_text::TRACK_NAME, instrument_str ())); + play (new Audio_text (Audio_text::TRACK_NAME, instrument_str ())); // instrument description play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str ())); } diff --git a/lily/staff-sym-grav.cc b/lily/staff-sym-grav.cc index 6adfae1826..f2dfad4d32 100644 --- a/lily/staff-sym-grav.cc +++ b/lily/staff-sym-grav.cc @@ -12,6 +12,7 @@ #include "p-col.hh" const NO_LINES = 5; + void Staff_sym_engraver::fill_staff_info (Staff_info&i) { @@ -32,14 +33,14 @@ void Staff_sym_engraver::do_creation_processing() { span_p_ = new Staff_symbol (NO_LINES); - span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh + span_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ()); announce_element (Score_elem_info (span_p_, 0)); } void Staff_sym_engraver::do_removal_processing() { - span_p_->right_col_l_ = get_staff_info().command_pcol_l (); + span_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ()); typeset_element (span_p_); span_p_ =0; } diff --git a/lily/staff-sym.cc b/lily/staff-sym.cc index 4542d2e3dc..6b9b288aba 100644 --- a/lily/staff-sym.cc +++ b/lily/staff-sym.cc @@ -22,7 +22,7 @@ Staff_symbol::Staff_symbol (int l) IMPLEMENT_IS_TYPE_B1(Staff_symbol,Spanner); void -Staff_symbol::do_print()const +Staff_symbol::do_print() const { #ifndef NPRINT Spanner::do_print(); @@ -37,16 +37,8 @@ Staff_symbol::brew_molecule_p() const return new Molecule (a); } -void -Staff_symbol::set_extent (PCol*p1, PCol*p2) -{ - assert (p1&&p2); - left_col_l_ = p1; - right_col_l_ = p2; -} - Real -Staff_symbol::inter_note_f()const +Staff_symbol::inter_note_f() const { return paper()->internote_f (); } diff --git a/lily/super-elem.cc b/lily/super-elem.cc index 7ee2db3b9a..ef162d0a0b 100644 --- a/lily/super-elem.cc +++ b/lily/super-elem.cc @@ -12,14 +12,14 @@ #include "string.hh" String -Super_elem::TeX_string()const +Super_elem::TeX_output_str() const { String s; for (int i=0; i < lines_arr_.size(); i++) { - s += lines_arr_[i]->TeX_string(); - if (i + 1TeX_output_str(); + if (i + 1get_lines(); for (int i =0; i < lines_arr_.size(); i++) - add_dependency (lines_arr_[i]); + add_dependency (lines_arr_[i]); } @@ -37,7 +37,7 @@ void Super_elem::do_substitute_dependency (Score_elem*o,Score_elem* n) { if (line_of_score_l_ == o->spanner()) - line_of_score_l_ = n?(Line_of_score*)n->spanner():0; + line_of_score_l_ = n? (Line_of_score*) n->spanner() : 0; } Super_elem::Super_elem() @@ -52,7 +52,4 @@ Super_elem::do_add_processing() add_dependency (line_of_score_l_); } - - - IMPLEMENT_IS_TYPE_B1(Super_elem,Score_elem); diff --git a/lily/symbol.cc b/lily/symbol.cc index 2f7834b89c..9ba3d45f58 100644 --- a/lily/symbol.cc +++ b/lily/symbol.cc @@ -15,7 +15,7 @@ Symbol::Symbol (String s, Box b) String -Symbol::str()const +Symbol::str() const { return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))"; } diff --git a/lily/translator.cc b/lily/translator.cc index b902387529..642c9b9401 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -24,7 +24,7 @@ Translator::try_request (Request*) void -Translator::print()const +Translator::print() const { } diff --git a/lily/vertical-align-elem.cc b/lily/vertical-align-elem.cc index 2ddc1a29c6..02d1823b25 100644 --- a/lily/vertical-align-elem.cc +++ b/lily/vertical-align-elem.cc @@ -48,7 +48,7 @@ Vertical_align_element::do_post_processing() } Real where_f=0; - for ( int i=0 ; i < elem_l_arr_.size(); i++) + for (int i=0 ; i < elem_l_arr_.size(); i++) { elem_l_arr_[i]->translate (- dims[i][1] - where_f, Y_AXIS); where_f += dims[i].length(); @@ -56,7 +56,7 @@ Vertical_align_element::do_post_processing() } bool -Vertical_align_element::contains_b (Score_elem const *e)const +Vertical_align_element::contains_b (Score_elem const *e) const { return elem_l_arr_.find_l (e); } diff --git a/lily/vertical-align-grav.cc b/lily/vertical-align-grav.cc index dcaaf028bd..65fcceec2d 100644 --- a/lily/vertical-align-grav.cc +++ b/lily/vertical-align-grav.cc @@ -6,7 +6,7 @@ (c) 1997 Han-Wen Nienhuys */ - +#include "p-col.hh" #include "vertical-align-grav.hh" #include "vertical-align-spanner.hh" @@ -19,14 +19,14 @@ void Vertical_align_engraver::do_creation_processing() { valign_p_ =new Vertical_align_spanner; - valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ; + valign_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ()); announce_element (Score_elem_info (valign_p_ , 0)); } void Vertical_align_engraver::do_removal_processing() { - valign_p_->right_col_l_ = get_staff_info().command_pcol_l (); + valign_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ()); typeset_element (valign_p_); valign_p_ =0; } @@ -34,13 +34,13 @@ Vertical_align_engraver::do_removal_processing() void Vertical_align_engraver::acknowledge_element (Score_elem_info i) { - if ( i.origin_grav_l_arr_.size() == 2 && - i.elem_l_->is_type_b (Vertical_group_element::static_name()) && - !i.elem_l_->axis_group_l_a_[Y_AXIS] ) - { - assert (!valign_p_->contains_b (i.elem_l_)); + if (i.origin_grav_l_arr_.size() == 2 && + i.elem_l_->is_type_b (Vertical_group_element::static_name()) && + !i.elem_l_->axis_group_l_a_[Y_AXIS]) + { + assert (!valign_p_->contains_b (i.elem_l_)); - valign_p_->add ( i.elem_l_); + valign_p_->add (i.elem_l_); } } diff --git a/lily/voice-iterator.cc b/lily/voice-iterator.cc new file mode 100644 index 0000000000..b8318e2c74 --- /dev/null +++ b/lily/voice-iterator.cc @@ -0,0 +1,129 @@ +/* + voice-iter.cc -- implement Voice_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "translator.hh" +#include "debug.hh" +#include "voice-iterator.hh" +#include "music-list.hh" + + +void +Voice_iterator::do_print() const +{ + if (iter_p_) + iter_p_->print(); +} + +Voice_iterator::Voice_iterator (Voice const*v) + : PCursor (v->music_p_list_) +{ + here_mom_ = v->offset_mom_; + voice_C_ = v; + iter_p_ =0; +} + +void +Voice_iterator::construct_children() +{ + while (PCursor::ok()) + { + start_next_element(); + if (!iter_p_->ok()) + { + leave_element(); + } + else + { + set_voice_translator(); + break; + } + } +} + +void +Voice_iterator::leave_element() +{ + delete iter_p_; + iter_p_ =0; + MInterval elt_time = ptr()->time_int (); + if (!elt_time.empty_b()) + here_mom_ += elt_time.length(); + PCursor::next(); +} + +void +Voice_iterator::start_next_element() +{ + assert (!iter_p_); + iter_p_ = get_iterator_p (ptr()); +} + +void +Voice_iterator::set_voice_translator() +{ + if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) + set_translator (iter_p_->report_to_l()); +} + +Voice_iterator::~Voice_iterator() +{ + assert (! iter_p_); +} + + +IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator); + +void +Voice_iterator::process_and_next (Moment until) +{ + while (1) + { + Moment local_until = until - here_mom_; + while (iter_p_->ok()) + { + Moment here = iter_p_->next_moment(); + if (here != local_until) + goto loopexit; + + iter_p_->process_and_next (local_until); + } + + if (!iter_p_->ok()) + { + leave_element(); + + if (PCursor::ok()) + { + start_next_element(); + set_voice_translator(); + } + else + { + goto loopexit; + } + } + } + +loopexit: + + Music_iterator::process_and_next (until); +} + +Moment +Voice_iterator::next_moment() const +{ + return iter_p_->next_moment() + here_mom_; +} + +bool +Voice_iterator::ok() const +{ + return iter_p_; +} + + diff --git a/lily/word-wrap.cc b/lily/word-wrap.cc index beddf0d753..5814012ca0 100644 --- a/lily/word-wrap.cc +++ b/lily/word-wrap.cc @@ -21,85 +21,85 @@ */ Array -Word_wrap::do_solve()const +Word_wrap::do_solve() const { problem_OK(); - PCursor curcol (pscore_l_->col_p_list_.top()); + PCursor curcol (pscore_l_->col_p_list_.top()); Array breaking; Line_of_cols breakpoints (find_breaks()); assert (breakpoints.size()>=2); int break_idx_i=0; - while ( break_idx_i < breakpoints.size() -1) + while (break_idx_i < breakpoints.size() -1) { - Col_hpositions minimum; - Col_hpositions current; + Col_hpositions minimum; + Col_hpositions current; // do another line - PCol *post = breakpoints[break_idx_i]->postbreak_p_; - current.add (post); - curcol++; // skip the breakable. - break_idx_i++; + Paper_column *post = breakpoints[break_idx_i]->postbreak_l(); + current.add (post); + curcol++; // skip the breakable. + break_idx_i++; - while (break_idx_i < breakpoints.size()) - { + while (break_idx_i < breakpoints.size()) + { - // add another measure. - while (breakpoints[break_idx_i] != curcol.ptr()) - { - current.add (curcol); - curcol++; - } - current.add (breakpoints[break_idx_i]->prebreak_p_); - - current.spacer_l_ = generate_spacing_problem (current.cols); - - // try to solve - if (!feasible (current.cols)) - { - if (!minimum.cols.size()) - { - warning ("Ugh, this measure is too long, breakpoint: " - + String (break_idx_i) + - " (generating stupido solution)"); - current.stupid_solution(); - current.energy_f_ = - 1; // make sure we break out. - } - else - current.energy_f_ = infinity_f; // make sure we go back - } - else - { + // add another measure. + while (breakpoints[break_idx_i] != curcol.ptr()) + { + current.add (curcol); + curcol++; + } + current.add (breakpoints[break_idx_i]->prebreak_l()); + + current.spacer_l_ = generate_spacing_problem (current.cols); + + // try to solve + if (!feasible (current.cols)) + { + if (!minimum.cols.size()) + { + warning ("Ugh, this measure is too long, breakpoint: " + + String (break_idx_i) + + " (generating stupido solution)"); + current.stupid_solution(); + current.energy_f_ = - 1; // make sure we break out. + } + else + current.energy_f_ = infinity_f; // make sure we go back + } + else + { - current.solve_line(); - current.print(); - } - - delete current.spacer_l_; - current.spacer_l_ =0; - - // update minimum, or backup. - if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0) - { - minimum = current; - } - else { // we're one col too far. - break_idx_i--; - while (curcol.ptr() != breakpoints[break_idx_i]) - curcol --; - break; // do the next line. - } - - - // add nobreak version of breakable column - current.cols.top()=breakpoints[break_idx_i]; - curcol ++; - break_idx_i++; + current.solve_line(); + current.print(); + } + + delete current.spacer_l_; + current.spacer_l_ =0; + + // update minimum, or backup. + if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0) + { + minimum = current; + } + else { // we're one col too far. + break_idx_i--; + while (curcol.ptr() != breakpoints[break_idx_i]) + curcol --; + break; // do the next line. } - *mlog << "[" <