]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-spanner.cc
patch::: 1.3.54.hwn2
[lilypond.git] / lily / spacing-spanner.cc
index 712ff4dd4dfd3be922ec3b4b0a845a76f5904e66..4b413ec6a8cc61d06498e992ef88e0ff93e1dad3 100644 (file)
@@ -24,10 +24,6 @@ Spacing_spanner::Spacing_spanner ()
 }
 
 /*
-  cut 'n paste from spring-spacer.cc
-
-  generate springs between columns.
-
 
   The algorithm is partly taken from :
 
@@ -36,6 +32,8 @@ Spacing_spanner::Spacing_spanner ()
   Science, The Ohio State University, 1987.
 
   TOO HAIRY.
+
+  TODO: write comments 
   
  */
 Array<Spring>
@@ -69,8 +67,8 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
     {
       Item * l = cols[i];
       Item * r = cols[i+1];
-      Item * lb = l->find_broken_piece (RIGHT);
-      Item * rb = r->find_broken_piece (LEFT);      
+      Item * lb = l->find_prebroken_piece (RIGHT);
+      Item * rb = r->find_prebroken_piece (LEFT);      
 
       Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
 
@@ -158,8 +156,10 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
            stretch_dist += right_dist;
 
          if (s.distance_f_ <0)
-           programming_error("negative dist");
-         
+           {
+             programming_error("Negative dist, setting to 1.0 PT");
+             s.distance_f_ = 1.0;
+           }
          if (stretch_dist == 0.0)
            {
              /*
@@ -258,13 +258,13 @@ Spacing_spanner::note_spacing (Paper_column *lc, Paper_column *rc, Moment shorte
    This should be more advanced, since relative heights of the note
    heads also influence required correction.
 
-   Also might not work correctly ico. multi voices or staff changing voices
+   Also might not work correctly in case of multi voices or staff
+   changing voices
 
    TODO: lookup correction distances?  More advanced correction?
    Possibly turn this off?
 
-   This routine reads the DIR_LIST property of both its L and R arguments.
-*/
+   This routine reads the DIR-LIST property of both its L and R arguments.  */
 Real
 Spacing_spanner::stem_dir_correction (Paper_column*l, Paper_column*r) const
 {
@@ -315,22 +315,27 @@ Array<Spring>
 Spacing_spanner::get_springs () const
 {
   Array<Spring> springs;
-  
-  SCM last_col = pscore_l_->line_l_->get_elt_property ("columns");
-  Link_array<Paper_column> measure;
-  for (SCM s = last_col; gh_pair_p (s); s = gh_cdr (s))
+
+  Link_array<Paper_column> all (pscore_l_->line_l_->column_l_arr ()) ;
+
+  int j = 0;
+
+  for (int i = 1; i < all.size (); i++)
     {
-      Score_element * elt = unsmob_element (gh_car (s));
-      Paper_column* sc = dynamic_cast<Paper_column*> (elt);
-      measure.push (sc);
+      Paper_column* sc = dynamic_cast<Paper_column*> (all[i]);
       if (sc->breakable_b ())
         {
-         measure.reverse ();
+         Link_array<Paper_column> measure (all.slice (j, i+1));          
           springs.concat (do_measure (measure));
-         measure.clear ();
-         measure.push (sc);
+         j = i;
         }
     }
+
+  /*
+    farewell, cruel world
+   */
+  ((Spacing_spanner*)this)->suicide ();
+  
   return springs;
 }