]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 3 Sep 2004 23:21:18 +0000 (23:21 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 3 Sep 2004 23:21:18 +0000 (23:21 +0000)
14 files changed:
ChangeLog
Documentation/user/changing-defaults.itely
lily/align-interface.cc
lily/include/paper-system.hh
lily/paper-system.cc
lily/simple-spacer.cc
lily/slur-engraver.cc
lily/system.cc
ly/book-paper-defaults.ly
ly/engraver-init.ly
scm/define-grobs.scm
scm/framework-tex.scm
scm/page-layout.scm
scm/paper.scm

index 007620b4f7fe66e4bc0f1b96c0e0cb93e4940b25..3743579acf641ad496258fa9c4210fcf4ae442dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
+2004-09-03  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/simple-spacer.cc (LY_DEFINE): return something sensible for
+       0 springs
+
+       * lily/system.cc (post_processing): 
+
+       * scm/page-layout.scm (ly:optimal-page-breaks): implement uniform
+       density for vertical spacing by means of force penalty.
+       
+       * scm/paper.scm (paper-set-staff-size): add betweensystemspace as
+       dimension-variables
+
+       * Documentation/user/changing-defaults.itely (Page layout): add
+       betweensystemspace variable.
+
+       * ly/book-paper-defaults.ly: set betweensystemspace: 20 mm
+
+       * scm/page-layout.scm (space-systems): new function. Use spring
+       and rod approach for vertically spacing systems.
+
+       * ly/engraver-init.ly: tune down minimumVerticalExtent.
+
+       * scm/define-grobs.scm (all-grob-descriptions): set threshold for
+       vertical alignment.
+
+       * lily/slur-engraver.cc (process_music): add warning for slur.
+
 2004-09-02  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/include/lily-guile.hh (scm_is_number): add scm_is_number
+
        * lily/simple-spacer.cc (LY_DEFINE): ly_solve_spring_rod_problem:
        export spacing routine to SCM.
 
index e9a73b8d007c700582706c685921ae7b8ffb2d69..bd25872d9de4edd012b64535cd7a09bd15fc3c01 100644 (file)
@@ -2222,6 +2222,11 @@ The default layout responds to the following settings in the
  If set to true, systems will not be spread across the page.  
 @item raggedlastbottom
  If set to true, systems will not be spread to fill the last page.
+
+@item betweensystemspace
+  This dimensions determines the distance between systems. It is the
+ideal distance between the center of the bottom staff of one system, and
+the center of the top staff of the next system.
 @end table
 
 @example
index b3bbf6a07c4f74ee25ec5fbaebadbb6477a0751c..f510304b6667e462f461eb83831ac91d9e5205fa 100644 (file)
@@ -128,7 +128,8 @@ Align_interface::align_elements_to_extents (Grob * me, Axis a)
   if (!stacking_dir)
     stacking_dir = DOWN;
   
-  Interval threshold = robust_scm2interval (me->get_property ("threshold"), Interval (0, Interval::infinity ()));
+  Interval threshold = robust_scm2interval (me->get_property ("threshold"),
+                                           Interval (0, Interval::infinity ()));
   
   Array<Interval> dims;
 
index 63cffb3fb1a22405ec5c9f74216d778ae14a208f..b94a3be35ec1f13a4f6bae695d5ff3269e40149f 100644 (file)
@@ -32,8 +32,7 @@ public:
   int number_;
 
   Paper_system (Stencil, bool);
-
-  Offset dim () const;
+  
   Stencil to_stencil () const;
   SCM stencils () const;
   bool is_title () const;
index 885b865cab169c9ded49f77ff95a8b775297276e..ab2fc13f3db6e9ee33ac3f3b0cc6e84bc352bfd3 100644 (file)
@@ -26,6 +26,7 @@ Paper_system::Paper_system (Stencil s, bool is_title)
   penalty_ = 0;
   smobify_self ();
   stencil_ = s;
+  staff_refpoints_ = Interval(0,0);
 }
 
 Paper_system::~Paper_system ()
@@ -67,13 +68,6 @@ Paper_system::penalty () const
   return penalty_;
 }
 
-Offset
-Paper_system::dim () const
-{
-  return Offset (stencil_.extent (X_AXIS).length (),
-                stencil_.extent (Y_AXIS).length ());
-}
-
 Stencil
 Paper_system::to_stencil () const
 {
@@ -88,9 +82,11 @@ LY_DEFINE (ly_paper_system_height, "ly:paper-system-extent",
   SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
   SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
   Axis ax = (Axis)ly_scm2int (axis);
-  return scm_make_real (ps->dim ()[ax]);
+  return ly_interval2scm (ps->to_stencil().extent (ax));
 }
 
+
+
 LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
           1, 0, 0, (SCM system),
           "Is  @var{system} a title system?")
index 08fd455e15cf69ce899602bd522e1b2474598ec2..a7fd8a7680a141835c51ad8a10167a4e12f19112 100644 (file)
@@ -143,7 +143,28 @@ Simple_spacer::active_blocking_force () const
 Real
 Simple_spacer::active_springs_stiffness () const
 {
-  return range_stiffness (0, springs_.size ());
+  Real  stiff =  range_stiffness (0, springs_.size ());
+  if (isinf (stiff))
+    {
+      /*
+       all springs are inactive. Take the stiffness of the
+       latest spring to block.
+       */
+
+      Real max_block_force = -infinity_f;
+      int max_i = -1;
+      for (int i=0; i < springs_.size (); i++)
+       {
+         if (springs_[i].block_force_ > max_block_force)
+           {
+             max_i = i;
+             max_block_force = springs_[i].block_force_;
+           }
+       }
+
+      stiff = springs_[max_i].hooke_;   
+    }
+  return stiff;
 }
 
 void
@@ -185,7 +206,7 @@ Simple_spacer::my_solve_linelen ()
 
       if (conf < line_len_)
        {
-         force_ += (line_len_  - conf) * active_springs_stiffness ();
+         force_ += (line_len_ - conf) * active_springs_stiffness ();
          break;
        }
       else
@@ -214,15 +235,20 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
          "are connected by @var{count-1} springs, and an arbitrary number of rods "
          "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) "
          "@var{length} is a number, @var{ragged} a boolean "
-         "Return: a list containing the force (#f for non-satisfied constraints)"
-         "followed by positions of the objects."
+         "Return: a list containing the force (#f for non-satisfied constraints) "
+         "followed by the @var{spring-count}+1 positions of the objects. "
          )
 {
-  SCM_ASSERT_TYPE (scm_ilength (springs) >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs");
+  int len = scm_ilength (springs);
+  if (len == 0)
+    return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0));
+  
+  SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs");
   SCM_ASSERT_TYPE (scm_ilength (rods) >= 0, rods, SCM_ARG2, __FUNCTION__, "list of rods");
   SCM_ASSERT_TYPE (scm_is_number (length) || length == SCM_BOOL_F,
                   length, SCM_ARG3, __FUNCTION__, "number or #f");
 
+
   bool is_ragged   = ragged == SCM_BOOL_T; 
   Simple_spacer spacer; 
   for (SCM s = springs; ly_c_pair_p (s); s = ly_cdr (s))
@@ -236,22 +262,20 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
   for (SCM s = rods; ly_c_pair_p (s); s = ly_cdr (s))
     {
       SCM entry = ly_car (s);
-      int l = scm_to_int (ly_car (s));
-      int r = scm_to_int (ly_cadr (s));
-      entry = ly_cddr (s);
+      int l = scm_to_int (ly_car (entry));
+      int r = scm_to_int (ly_cadr (entry));
+      entry = ly_cddr (entry);
       
-      Real distance = scm_to_double (ly_car (s));
+      Real distance = scm_to_double (ly_car (entry));
       spacer.add_rod (l, r, distance);
     }
 
+  spacer.line_len_ = scm_to_double (length);
+      
   if (is_ragged)
     spacer.my_solve_natural_len ();
   else
-    {
-      spacer.line_len_ = scm_to_double (length);
-      
-      spacer.my_solve_linelen ();
-    }
+    spacer.my_solve_linelen ();
 
   Array<Real> posns;
   posns.push (0.0);
@@ -261,17 +285,20 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
       posns.push (posns.top() + l);
     }
 
-  SCM force_return = scm_from_double (spacer.force_);
+  SCM force_return = SCM_BOOL_F;
   if (is_ragged)
     {
       Real len = posns.top ();
       if (spacer.line_len_ - len  >= 0)
        force_return  = scm_from_double ((spacer.line_len_ - len)
                                         * spacer.active_springs_stiffness ());
-      else
-       force_return = SCM_BOOL_F;
     }
-
+  else if (not isinf (spacer.force_)
+          && spacer.is_active ())
+    {
+      force_return = scm_from_double (spacer.force_);
+    }
+  
   SCM retval= SCM_EOL;
   for (int i = posns.size(); i--;)
     {
@@ -297,7 +324,9 @@ Spring_description::Spring_description ()
 bool
 Spring_description::is_sane () const
 {
-  return (hooke_ > 0) &&  !isinf (ideal_) && !isnan (ideal_);
+  return (hooke_ > 0)
+    && ideal_ > 0
+    && !isinf (ideal_) && !isnan (ideal_);
 }
 
 Real
index 96c83dde182f693aa2895e6d10287290314b4a10..e963ad68b176d22443ca941876073305ec607556 100644 (file)
@@ -12,7 +12,7 @@
 #include "engraver.hh"
 #include "spanner.hh"
 #include "tie.hh"
-
+#include "input.hh"
 /*
   It is possible that a slur starts and ends on the same note.  At
   least, it is for phrasing slurs: a note can be both beginning and
@@ -119,6 +119,11 @@ Slur_engraver::process_music ()
 {
   if (events_[STOP])
     {
+      if (slurs_.size() == 0)
+       {
+         events_[STOP]->origin()->warning (_ ("No slur to end"));
+       }
+      
       end_slurs_ = slurs_;
       slurs_.clear ();
     }
index 6f57b2db616251cadcf8045dba8c812b8a462438..75c7a9555100f276ea2939b4fba9d9ba93f70465 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <math.h>
 
+#include "align-interface.hh"
 #include "axis-group-interface.hh"
 #include "warn.hh"
 #include "system.hh"
@@ -308,7 +309,7 @@ System::post_processing ()
     programming_error ("System with zero extent.");
   else
     translate_axis (-iv[MAX], Y_AXIS);
-
+  
   /* Generate all stencils to trigger font loads.
      This might seem inefficient, but Stencils are cached per grob
      anyway. */
@@ -336,6 +337,8 @@ System::get_line ()
      Start with layer 3, since scm_cons prepends to list.  */
   SCM all = get_property ("all-elements");
   Interval staff_refpoints;
+  staff_refpoints.set_empty();
+  
   for (int i = LAYER_COUNT; i--;)
     for (SCM s = all; ly_c_pair_p (s); s = ly_cdr (s))
       {
@@ -344,6 +347,7 @@ System::get_line ()
 
        if (i == 0
            && Axis_group_interface::has_interface (g)
+           && !Align_interface::has_interface (g)
            && dynamic_cast<Spanner*> (g))
          {
            staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
@@ -368,8 +372,6 @@ System::get_line ()
        st.translate (o + extra);
        *tail = scm_cons (st.expr (), SCM_EOL);
        tail = SCM_CDRLOC(*tail);
-
-       
       }
 
   if (Stencil *me = get_stencil ())
index a3d1ced8bd7fdc87dcdec225d738d04874a54da1..99251ea38c2169f3df29c37bb37f4b744d2cf03e 100644 (file)
@@ -1,6 +1,14 @@
 \version "2.3.8"
 
 \bookpaper {
+
+    %%%%%%%%%%%%%%
+    %%%%
+    %%%% WARNING
+
+    %%% if you  add any new dimensions, don't forget to update
+    %%% the dimension-variables variable. see paper.scm
+    
     unit = #(ly:unit)
     mm = 1.0
     in = 25.4
     %% input encoding in EMACS? -- jcn
     %%%%inputencoding = #"TeX"
     inputencoding = #"latin1"
-
     printpagenumber = ##t
 
     %%
     %% 20pt staff, 5 pt = 1.75 mm
     %%
 
-   outputscale = #1.7573
+    outputscale = #1.7573
     
     #(define-public score-title default-score-title)
     #(define-public user-title default-user-title)
     
     #(paper-set-staff-size (* 20.0 pt))
 
+    %
+    % this dimension includes the extent of the
+    % staves themselves.
+    %
+    betweensystemspace = #(* 20 mm)
+
+    %
+    % fixed space between systems.
+    %
+    betweensystempadding = #(* 4 mm)
+
+
+    raggedbottom = ##f
+    raggedlastbottom= ##f
 
-  papersize = "a4"
+    papersize = "a4"
 
     #(define font-defaults
       '((font-encoding . fetaMusic)))
index c2b3a8c2bc968d7de051e9c9370a4b7b0327a937..fac290591ac990ae4d373d23821c2591766741f5 100644 (file)
@@ -40,7 +40,7 @@
        \consists "String_number_engraver"
        \consists "Axis_group_engraver"
 
-       minimumVerticalExtent = #'(-5 . 5)
+       minimumVerticalExtent = #'(-3 . 3)
        extraVerticalExtent = ##f
        verticalExtent = ##f 
        localKeySignature = #'()
index da6c1b98876e06ac8a8564c46bc9a52ac073c8a0..8c6e8d1a12cc281787a05ce64e42cd60b4de6202 100644 (file)
        (Y-extent-callback . ,Axis_group_interface::group_extent_callback)
        (X-extent-callback . ,Axis_group_interface::group_extent_callback)
        (stacking-dir . -1)
+       (threshold .  (12 . 1000))
        (meta . ((interfaces . (align-interface axis-group-interface spanner-interface))))
        ))
 
index 7c535f49ded94b45eb2b3a1ed8b7a5712dec4b7c..eeee26df6dd20737fce1d8032e4fffba1484e166 100644 (file)
   (ly:outputter-dump-string
    putter
    (string-append "\\leavevmode\n\\lybox{0}{0}{0}{"
-                 (ly:number->string (ly:paper-system-extent line Y))
+                 (ly:number->string (interval-length (ly:paper-system-extent line Y)))
                  "}{"))
 
   (ly:outputter-dump-stencil putter (ly:paper-system-stencil line))
index 1b2f7db5f08cfa8b6d30eea438996934b03c1fab..65f15c78e4b1396b867d4b4bc8051c984d5e10f4 100644 (file)
@@ -14,7 +14,9 @@
 (define-class <optimally-broken-page-node> ()
   (prev #:init-value '() #:accessor node-prev #:init-keyword #:prev)
   (page #:init-value 0 #:accessor node-page-number #:init-keyword #:pageno)
+  (force #:init-value 0 #:accessor node-force #:init-keyword #:force) 
   (penalty #:init-value 0 #:accessor node-penalty #:init-keyword #:penalty)
+  (configuration #:init-value '() #:accessor node-configuration #:init-keyword #:configuration)
   (lines #:init-value 0 #:accessor node-lines #:init-keyword #:lines))
 
 (define-method (display (node <optimally-broken-page-node>) port)
     ))
 
 
-(define-public (default-page-make-stencil lines paper scopes number last? )
+(define-public (default-page-make-stencil
+                lines offsets paper scopes number last? )
   "Construct a stencil representing the page from LINES.  "
   (let*
      ((topmargin  (ly:output-def-lookup paper 'topmargin))
       
       ;; TODO: naming vsize/hsize not analogous to TeX.
-
       
       (vsize (ly:output-def-lookup paper 'vsize))
       (hsize (ly:output-def-lookup paper 'hsize))
       (foot (page-headfoot paper scopes number 'make-footer 'footsep DOWN last?))
       (line-stencils (map ly:paper-system-stencil lines))
       (height-proc (ly:output-def-lookup paper 'page-music-height))
-      (music-height (height-proc paper scopes number last?))
-      (ragged (ly:output-def-lookup paper 'raggedbottom))
-      (ragged-last   (ly:output-def-lookup paper 'raggedlastbottom))
-      (ragged-bottom (or (eq? #t ragged)
-                        (and last? (eq? #t ragged-last))))
-
-      (spc-left (-  music-height
-                  (apply + (map (lambda (x)
-                                  (interval-length (ly:stencil-extent x Y)))
-                       line-stencils))))
-      (stretchable-lines (remove ly:paper-system-title? (cdr lines)))
-      (stretch (if (or (null? stretchable-lines)
-                      (> spc-left (/ music-height 2))
-                      ragged-bottom)
-                  0.0
-                  (/ spc-left (length stretchable-lines))))
 
       (page-stencil (ly:make-stencil '()
-                   (cons leftmargin hsize)
-                   (cons (- topmargin) 0)))
-      (was-title #t))
-
-    (set! page-stencil (ly:stencil-combine-at-edge
-         page-stencil Y DOWN head 0. 0.))
-
-    (for-each
-     (lambda (l)
-       (set! page-stencil
-            (ly:stencil-combine-at-edge
-             page-stencil Y DOWN (ly:paper-system-stencil l)
-             (if was-title
-                 0.0
-                 stretch)
-             ))
-
-       (set! was-title (ly:paper-system-title? l)))
-     lines)
-
+                                    (cons leftmargin hsize)
+                                    (cons (- topmargin) 0)))
+      (was-title #t)
+      (add-system (lambda (stencil-position)
+                   (set! page-stencil
+                         (ly:stencil-add
+                          (ly:stencil-translate-axis
+                           (car stencil-position)
+                           (- 0
+                              (cadr stencil-position)
+                              topmargin)
+                              Y)
+                          page-stencil))))
+      )
+
+
+    (map add-system (zip line-stencils offsets))
     (if (ly:stencil? foot)
        (set! page-stencil
              (ly:stencil-add
               (ly:stencil-translate
                foot
                (cons 0
-                     (+ (- bottom-edge) (- (car (ly:stencil-extent foot Y)))))
+                     (+ (- bottom-edge)
+                        (- (car (ly:stencil-extent foot Y)))))
                ))))
 
     (ly:stencil-translate page-stencil (cons leftmargin 0))
   "Return pages as a list starting with 1st page. Each page is a list
 of lines. "
 
-  (define (make-node prev lines page-num penalty)
-    (make <optimally-broken-page-node>
-      #:prev prev
-      #:lines lines
-      #:pageno page-num
-      #:penalty penalty))
 
   (define MAXPENALTY 1e9)
   (define bookpaper (ly:paper-book-book-paper paper-book))
   (define scopes (ly:paper-book-scopes paper-book))
-  (define (line-height line)
-    (ly:paper-system-extent line Y))
-
-  ;; FIXME: may need some tweaking: square, cubic
-  (define (height-penalty available used)
-    ;; FIXME, simplistic
-    (let* ((left (- available used))
-          ;; scale-independent
-          (relative (abs (/ left available))))
-      (if (negative? left)
-
-         ;; too full, penalise more
-         (* 10 (1+ relative) relative)
-         
-         ;; Convexity: two half-empty pages is better than 1 completely
-         ;; empty page
-         (* (1+ relative) relative))))
 
   (define (page-height page-number last?)
     (let
@@ -248,11 +209,7 @@ of lines. "
       (if (procedure? p)
          (p bookpaper scopes page-number last?)
          10000)))
-
   
-  (define (cumulative-height lines)
-    (apply + (map line-height lines)))
-
   (define (get-path node done)
     "Follow NODE.PREV, and return as an ascending list of pages. DONE
 is what have collected so far, and has ascending page numbers."
@@ -260,9 +217,114 @@ is what have collected so far, and has ascending page numbers."
        (get-path (node-prev node) (cons node done))
        done))
 
-  (define (combine-penalties user page prev)
-    (+ prev page user))
-
+  (define (combine-penalties force user best-paths)
+    (let*
+       ((prev-force  (if (null? best-paths)
+                         0.0
+                         (node-force  (car best-paths))))
+        (prev-penalty (if (null? best-paths)
+                          0.0
+                          (node-penalty (car best-paths))))
+        (inter-system-space (ly:output-def-lookup bookpaper 'betweensystemspace))
+        (force-equalization-factor 0.3)
+        (relative-force (/ force inter-system-space))
+        (abs-relative-force (abs relative-force))
+        )
+        
+        
+    (+ (* abs-relative-force (+ abs-relative-force 1))
+       prev-penalty
+       (* force-equalization-factor (/ (abs (- prev-force force)) inter-system-space))
+       user)))
+
+  (define (space-systems page-height lines ragged?)
+    (let*
+       ((inter-system-space
+         (ly:output-def-lookup bookpaper 'betweensystemspace))
+
+        (staff-extents
+         (list->vector
+          (append  (map
+                    ly:paper-system-staff-extents
+                    lines)
+                   (if (= (length lines) 1)
+                       '((0 .  0))
+                       '())) 
+          ))
+        (real-extents
+         (list->vector
+          (append
+           (map
+            (lambda (sys) (ly:paper-system-extent sys Y)) lines)
+                   (if (= (length lines) 1)
+                       '((0 .  0))
+                       '()) 
+                   )))
+        (no-systems (vector-length real-extents))
+        (topskip (cdr (vector-ref real-extents 0)))
+        (space-left (- page-height
+                       (apply + (map interval-length (vector->list real-extents)))
+
+                       ))
+                    
+        (space (- page-height
+                  topskip
+                  (-  (car (vector-ref real-extents (1- no-systems))))
+                  ))
+
+        (calc-spring
+         (lambda (idx)
+           (let*
+               ((this-system-ext (vector-ref staff-extents idx))
+                (next-system-ext (vector-ref staff-extents (1+ idx)))
+                (fixed (- (cdr next-system-ext)
+                          (car this-system-ext)))
+                (ideal (+ inter-system-space fixed))
+                (hooke (/ 1 (- ideal fixed)))
+                )
+             (list ideal hooke))
+           ))
+
+        (springs (map calc-spring (iota (1- no-systems))))
+        (fixed-dist (ly:output-def-lookup bookpaper 'betweensystempadding))
+        (calc-rod
+         (lambda (idx)
+           (let*
+               ((this-system-ext (vector-ref real-extents idx))
+                (next-system-ext (vector-ref real-extents (1+ idx)))
+                (distance (- (+ (car this-system-ext)
+                                fixed-dist)
+                             (cdr next-system-ext)
+                             ))
+                (entry (list idx (1+ idx) distance)))
+             entry)))
+        (rods (map calc-rod (iota (1- no-systems))))
+        (page-very-empty (> space-left (/ page-height 3)))
+        (result (ly:solve-spring-rod-problem
+                 springs rods space
+                 ragged?))
+        (force (car result))
+        (positions
+         (map (lambda (y) (+ y topskip) y) 
+              (cdr  result)))
+        )
+
+     (if #f ;; debug.
+        (begin
+          (display (list "\n# systems: " no-systems
+                         "\nreal-ext" real-extents "\nstaff-ext" staff-extents
+                         "\ninterscore" inter-system-space
+                         "\nspace-letf" space-left
+                         "\npage empty" page-very-empty
+                         "\nspring,rod" springs rods
+                         "\ntopskip etc" topskip space
+                         "\npage-height" page-height
+                         "\nragged" ragged?
+                         "\nforce" force 
+                         "\npositions" positions "\n"))))
+     
+     (cons force positions)))
+  
   (define (walk-paths done-lines best-paths current-lines  last? current-best)
     "Return the best optimal-page-break-node that contains
 CURRENT-LINES.  DONE-LINES.reversed ++ CURRENT-LINES is a consecutive
@@ -270,46 +332,68 @@ ascending range of lines, and BEST-PATHS contains the optimal breaks
 corresponding to DONE-LINES.
 
 CURRENT-BEST is the best result sofar, or #f."
-
+    
     (let* ((this-page-num (if (null? best-paths)
                               (ly:output-def-lookup bookpaper 'firstpagenumber)
                               (1+ (node-page-number (car best-paths)))))
-           (prev-penalty (if (null? best-paths)
-                             0.0
-                             (node-penalty (car best-paths))))
+
+          
+          (ragged? (or (eq? #t (ly:output-def-lookup bookpaper 'raggedbottom))
+                      (and (eq? #t (ly:output-def-lookup bookpaper 'raggedlastbottom))
+                           last?)))
            (page-height (page-height this-page-num last?))
-           (space-used (cumulative-height current-lines))
-           (this-page-penalty (height-penalty page-height space-used))
+          
+          (vertical-spacing (space-systems page-height current-lines ragged?))
+          (satisfied-constraints (car vertical-spacing))
+           (force (if satisfied-constraints satisfied-constraints 10000))
+          (positions (cdr vertical-spacing))
            (user-penalty (ly:paper-system-break-penalty (car current-lines)))
            (total-penalty (combine-penalties
-                           user-penalty this-page-penalty prev-penalty))
+                           force user-penalty
+                          best-paths))
+
+          
            (better? (or
                      (not current-best)
                      (< total-penalty (node-penalty current-best))))
            (new-best (if better?
-                         (make-node (if (null? best-paths)
+                        (make <optimally-broken-page-node>
+                          #:prev  (if (null? best-paths)
                                         #f
                                         (car best-paths))
-                                    current-lines
-                                    this-page-num total-penalty)
+                          #:lines current-lines
+                          #:pageno this-page-num
+                          #:force force
+                          #:configuration positions
+                          #:penalty total-penalty)
                          current-best)))
       
-      (if #f ;; debug
+      (if #t ;; debug
           (display
            (list
-            "user pen " user-penalty " prev-penalty "
-            prev-penalty "\n"
-            "better? " better? " total-penalty " total-penalty "\n"
-            "height " page-height " spc used: " space-used "\n"
-            "pen " this-page-penalty " lines: " current-lines "\n")))
+            "\nuser pen " user-penalty
+           "\nsatisfied-constraints" satisfied-constraints
+           "\nlast? " last? "ragged?" ragged?
+            "\nbetter? " better? " total-penalty " total-penalty "\n"
+           "\nconfig " positions
+            "\nforce " force
+           "\nlines: " current-lines "\n")))
+
+      (if #f ; debug
+         (display (list "\nnew-best is " (node-lines new-best)
+                        "\ncontinuation of "
+                        (if (null? best-paths)
+                            "start"
+                            (node-lines (car best-paths))))))
       
       (if (and (pair? done-lines)
                ;; if this page is too full, adding another line won't help
-               (< this-page-penalty MAXPENALTY))
+               satisfied-constraints)
           (walk-paths (cdr done-lines) (cdr best-paths)
                       (cons (car done-lines) current-lines)
                       last? new-best)
-          new-best)))
+         
+         new-best)))
 
   (define (walk-lines done best-paths todo)
     "Return the best page breaking as a single
@@ -321,7 +405,8 @@ DONE."
        (let* ((this-line (car todo))
               (last? (null? (cdr todo)))
               (next (walk-paths done best-paths (list this-line) last? #f)))
-       
+
+;        (display "\n***************")
          (walk-lines (cons this-line done)
                      (cons next best-paths)
                      (cdr todo)))))
@@ -332,10 +417,13 @@ DONE."
   (let* ((best-break-node (walk-lines '() '() lines))
         (break-nodes (get-path best-break-node '())))
 
-    (if (ly:get-option 'verbose)
+    (if #f; (ly:get-option 'verbose)
        (begin
-         (format (current-error-port) "breaks: ~S\n" (map line-number break-nodes))
-         (force-output (current-error-port))))
+         (display (list
+                   "\nbreaks: " (map line-number break-nodes))
+                   "\nsystems " (map node-lines break-nodes)
+                   "\npenalties " (map node-penalty break-nodes)
+                   "\nconfigs " (map node-configuration break-nodes))))
 
     
     ; create stencils.
@@ -343,6 +431,7 @@ DONE."
     (map (lambda (node)
           ((ly:output-def-lookup bookpaper 'page-make-stencil)
            (node-lines node)
+           (node-configuration node)
            bookpaper
            scopes
            (node-page-number node)
index d430c36a32e9a4b062a0d4e8b70923e92b350a14..599eb51a95da7ebc61a9a11984c8939329fc8e54 100644 (file)
@@ -39,6 +39,7 @@
 
     (module-define! m 'dimension-variables
                    '(pt mm cm in staffheight staff-space
+                        betweensystemspace betweensystempadding
                         linewidth indent hsize vsize
                         staffspace linethickness ledgerlinethickness
                         blotdiameter interscoreline leftmargin rightmargin))