X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fsimple-spacer.cc;h=edf841a7737b9cc4e49d67ba582eecfeb10fde43;hb=50cb93642631297394c1d1e108ecc42cfbadd644;hp=e11b6c1dd6cb5f26abde9701a10eefa1762185d7;hpb=b6b49c3d93f8e002450f6543ce8028a86529ac88;p=lilypond.git diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index e11b6c1dd6..edf841a773 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2000 Han-Wen Nienhuys + (c) 1999--2001 Han-Wen Nienhuys TODO: - add support for different stretch/shrink constants? @@ -19,6 +19,7 @@ #include "rod.hh" #include "warn.hh" #include "column-x-positions.hh" +#include "spaceable-element.hh" #include "dimensions.hh" Simple_spacer::Simple_spacer () @@ -140,7 +141,7 @@ Simple_spacer::my_solve_linelen () if (conf < line_len_f_) { - force_f_ += (line_len_f_ - conf) * active_springs_stiffness (); + force_f_ += (line_len_f_ - conf) * active_springs_stiffness (); break; } else @@ -164,29 +165,31 @@ Simple_spacer::my_solve_natural_len () } void -Simple_spacer::add_columns (Link_array cols) +Simple_spacer::add_columns (Link_array cols) { for (int i=0; i < cols.size () - 1; i++) { - Paper_column * c = cols [i]; - Column_spring *to_next = 0; - for (int j =0; !to_next && j < c->springs_.size( ); j++) + SCM spring_params = SCM_UNDEFINED; + for (SCM s = Spaceable_grob::get_ideal_distances (cols[i]); + spring_params == SCM_UNDEFINED && gh_pair_p (s); + s = gh_cdr (s)) { - Column_spring &sp = c->springs_ [j]; - if (sp.other_l_ != cols[i+1]) + Grob *other = unsmob_grob (gh_caar (s)); + if (other != cols[i+1]) continue; - to_next = &sp; + spring_params = gh_cdar (s); } Spring_description desc; - if (to_next) + if (spring_params != SCM_UNDEFINED) { - desc.hooke_f_ = to_next->strength_f_; - desc.ideal_f_ = to_next->distance_f_; + desc.ideal_f_ = gh_scm2double (gh_car (spring_params)); + desc.hooke_f_ = gh_scm2double (gh_cdr (spring_params)); } else { + programming_error ("No spring between adjacent columns"); desc.hooke_f_ = 1.0; desc.ideal_f_ = default_space_f_; } @@ -199,18 +202,19 @@ Simple_spacer::add_columns (Link_array cols) } desc.block_force_f_ = - desc.hooke_f_ * desc.ideal_f_; // block at distance 0 - springs_.push (desc); + springs_.push (desc); } for (int i=0; i < cols.size () - 1; i++) { - Array * rods = &cols [i]->minimal_dists_; - for (int j =0; j < rods->size( ); j++) + for (SCM s = Spaceable_grob::get_minimum_distances (cols[i]); + gh_pair_p (s); s = gh_cdr (s)) { - int oi = cols.find_i (rods->elem (j).other_l_ ); + Grob * other = unsmob_grob (gh_caar (s)); + int oi = cols.find_i (other); if (oi >= 0) { - add_rod (i, oi, rods->elem (j).distance_f_); + add_rod (i, oi, gh_scm2double (gh_cdar (s))); } } } @@ -235,12 +239,12 @@ Simple_spacer::solve (Column_x_positions *positions) const positions->config_.push (positions->config_.top () + springs_[i].length (force_f_)); } - positions->satisfies_constraints_b_ = (line_len_f_ < 0) || active_b (); + positions->satisfies_constraints_b_ = (line_len_f_ < 0) || active_b (); } -Spring_description::Spring_description( ) +Spring_description::Spring_description () { ideal_f_ =0.0; hooke_f_ =0.0;