From: fred Date: Sun, 24 Mar 2002 19:45:50 +0000 (+0000) Subject: lilypond-0.0.70pre X-Git-Tag: release/1.5.59~4584 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b39833f36e24a8ae20537a3cf134104385968a49;p=lilypond.git lilypond-0.0.70pre --- diff --git a/lily/collision.cc b/lily/collision.cc index 554d54ac60..7ba6c4c601 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -13,6 +13,7 @@ Collision::Collision() { + empty_b_ = transparent_b_ =true; } void diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index 8482d66882..a2a39754be 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -17,11 +17,15 @@ class Rest_collision : public Item { Link_array rest_l_arr_; Link_array ncol_l_arr_; public: + void add(Note_column*); void add(Rest_column*); void add(Collision*); NAME_MEMBERS(); + Rest_collision(); protected: virtual void do_post_processing(); + virtual void do_pre_processing(); + virtual void do_print() const; virtual void do_substitute_dependency(Score_elem*,Score_elem*); }; #endif // REST_COLLISION_HH diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 368d47d574..e3b7807f6d 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -6,16 +6,32 @@ (c) 1997 Han-Wen Nienhuys */ +#include "debug.hh" #include "rest-collision.hh" #include "rest-column.hh" +#include "note-column.hh" +#include "stem.hh" +#include "note-head.hh" #include "collision.hh" +#include "paper-def.hh" + +IMPLEMENT_STATIC_NAME(Rest_collision); +IMPLEMENT_IS_TYPE_B1(Rest_collision,Item); + +void +Rest_collision::add(Note_column *nc_l) +{ + add_dependency(nc_l); + ncol_l_arr_.push(nc_l); +} void Rest_collision::add(Rest_column *rc_l) { - rest_l_arr_.push(rc_l); add_dependency(rc_l); + rest_l_arr_.push(rc_l); } + void Rest_collision::add(Collision * c_l) { @@ -24,40 +40,108 @@ Rest_collision::add(Collision * c_l) ncol_l_arr_.push(c_l->clash_l_arr_[i]); } - void Rest_collision::do_post_processing() { -#if 0 - bool rest_b_a[4]; - rest_b_a[j] = (col_l_a[j]) ? col_l_a[j]->rest_b_ : false; - do { - int i1 = idx(d, false); - int i2 = idx(d,true); - if (!intersection(y_extent[i1] , - y_extent[i2]).empty_b()) { - if (rest_b_a[i1]) { - y_off[i1] = -y_extent[i1][-d] + y_extent[1][d] + d*4; // ugh - y_extent[i1] += y_off[i1]; - } - } - } while ((d *= -1) != 1); - - do { - int i1 = idx(d, false); - int i2 = idx(-d,false); - - if (d*(y_extent[i1][-d] - y_extent[i2][d] )< 0&& rest_b_a[i1]) { - y_off[i1] = -y_extent[i1][-d] + y_extent[i2][d] +d* 4; // ugh - y_extent[i1] += y_off[i1]; + /* + handle rest under beam (do_post: beams are calculated now) + + [todo] + i-d like to have access to the beam itself, + iso only the (half-initialised?) stem + + what about combination of collisions and rest under beam + */ + + // no rests to collide + if (!rest_l_arr_.size()) + return; + // can this happen? + Stem* stem_l = rest_l_arr_[0]->stem_l_; + if (!stem_l) + return; + // no beam + if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_)) + return; + + Real inter_f = paper()->internote_f(); + int dir_i = rest_l_arr_[0]->dir_i_; + int midpos = 4; +#if 1 + // ugh + int stem_length_i = 7 - 2; + // ugh, Stem::stem_start vs Stem::stem_end + int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i; +#else // nogo: stem_start not set for rests? + int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2; +#endif + Real dy = pos * inter_f; + rest_l_arr_[0]->translate_y(dy); +} + +void +Rest_collision::do_pre_processing() +{ + /* + handle rest-rest and rest-note collisions + + [todo] + decide not to print rest if too crowded? + */ + + // no rests to collide + if (!rest_l_arr_.size()) + return; + + // no partners to collide with + if (rest_l_arr_.size() + ncol_l_arr_.size() < 2 ) + return; + + Real inter_f = paper()->internote_f(); + + // meisjes met meisjes + if (!ncol_l_arr_.size()) { + Real dy = rest_l_arr_.size() > 2 ? 6 * inter_f : 4 * inter_f; + rest_l_arr_[0]->translate_y(dy); + // top is last element... + rest_l_arr_.top()->translate_y(-dy); + } + // meisjes met jongetjes + else { +#if 0 // breendet: rests go always under + // geen gemug, trug op je rug + int dir_i = -1; + rest_l_arr_[0]->translate_y(dir_i * 3 * inter_f); +#else + // int dir_i = - ncol_l_arr_[0]->dir_i_; + int dir_i = rest_l_arr_[0]->dir_i_; + // hope it's 4: if it works->doco + int midpos = 4; + // minimum move + int minpos = 4; + // quart rest height + int size_i = 6; + int sep_i = 3 + size_i / 2; + for (int i = 0; i < ncol_l_arr_.size(); i++) { + // how to know whether to sort? + ncol_l_arr_[i]->sort(); + for ( int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++ ) + minpos = minpos >? dir_i * ( ncol_l_arr_[i]->head_l_arr_[j]->position_i_ - midpos ) + sep_i; } - } while ((d *= -1) != 1); - + Real dy = dir_i * minpos * inter_f; + rest_l_arr_[0]->translate_y(dy); #endif + } } -IMPLEMENT_STATIC_NAME(Rest_collision); -IMPLEMENT_IS_TYPE_B1(Rest_collision,Item); +void +Rest_collision::do_print() const +{ +#ifndef NPRINT + mtor << "rests: " << rest_l_arr_.size() << ", "; + mtor << "cols: " << ncol_l_arr_.size(); +#endif +} void Rest_collision::do_substitute_dependency(Score_elem*o,Score_elem*n) @@ -68,3 +152,9 @@ Rest_collision::do_substitute_dependency(Score_elem*o,Score_elem*n) rest_l_arr_.substitute((Rest_column*)o_l,(Rest_column*)n_l); ncol_l_arr_.substitute((Note_column*)o_l,(Note_column*)n_l); } + +Rest_collision::Rest_collision() +{ + transparent_b_ = true; + empty_b_ = true; +} diff --git a/lily/vertical-align-elem.cc b/lily/vertical-align-elem.cc index 4ff58eef6f..2aecf5d3fc 100644 --- a/lily/vertical-align-elem.cc +++ b/lily/vertical-align-elem.cc @@ -31,7 +31,7 @@ void Vertical_align_elem::do_post_processing() { Array dims; - for (int i=elem_l_arr_.size(); i--; ) { + for (int i=0; i < elem_l_arr_.size(); i++ ) { Interval y = elem_l_arr_[i]->height() ; if (y.empty_b()) y = Interval(0,0);