lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dumb stacking page breaker


From: Nicolas Sceaux
Subject: Re: dumb stacking page breaker
Date: Sun, 15 Jul 2007 21:49:37 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

Joe Neeman <address@hidden> writes:

> On Sunday 15 July 2007 08:37, Nicolas Sceaux wrote:

>> Should Page_breaking::pack_systems_on_least_pages also compute the
>> Page_spacing_result force_, demerits_, etc, slots, even though they are
>> not used in the subclass? (to better conform to the protocol designed
>> for the other spacing methods).
>
> If it doesn't complicate things too much, I think you should put it in. If it 
> gets messy (eg. on the last page), then just put a comment noting the 
> difference and we can worry about it if we actually need it in the future. 
> The same remark applies to ragged-bottom/ragged-last-bottom support, which 
> doesn't seem to be there at the moment.

OK, in the following, the force_ and penalty_ slots are set, and
finalize_spacing_result is called.  Could you just check whether
penalty_ is computed as it should at the end of the function (for I
don't understand exactly what it should be by reading the other pieces
of code).

I'm abusing your services...

Thanks,
nicolas

diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc
index 9ad8336..d61e429 100644
--- a/lily/page-breaking.cc
+++ b/lily/page-breaking.cc
@@ -758,6 +759,61 @@ Page_breaking::space_systems_on_best_pag
   return finalize_spacing_result (configuration, best);
 }
 
+Page_spacing_result
+Page_breaking::pack_systems_on_least_pages (vsize configuration, vsize 
first_page_num)
+{
+  Page_spacing_result res;
+  vsize page = 0;
+  vsize page_first_line = 0;
+  Page_spacing space (page_height (first_page_num, false));
+
+  cache_line_details (configuration);
+  for (vsize line = 0; line < cached_line_details_.size (); line++)
+    {
+      Real prev_force = space.force_;
+      space.append_system (cached_line_details_[line]);
+      if ((line > page_first_line)
+         && (isinf (space.force_)
+             || (cached_line_details_[line].page_permission_ == ly_symbol2scm 
("force"))))
+       {
+         res.systems_per_page_.push_back (line - page_first_line);
+         res.force_.push_back (prev_force);
+         page++;
+         space.resize (page_height (first_page_num + page, false));
+         space.clear ();
+         page_first_line = line;
+       }
+
+      if (line == cached_line_details_.size () - 1)
+       {
+         /* This is the last line */
+         /* When the last page height was computed, we did not know yet that it
+          * was the last one. If the systems put on it don't fit anymore, the 
last
+          * system is moved to a new page */
+         space.resize (page_height (first_page_num + page, true));
+         if ((line > page_first_line) && (isinf (space.force_)))
+           {
+             res.systems_per_page_.push_back (line - page_first_line);
+             res.force_.push_back (prev_force);
+             /* the last page containing the last line */
+             space.resize (page_height (first_page_num + page + 1, true));
+             space.clear ();
+             space.append_system (cached_line_details_[line]);
+             res.systems_per_page_.push_back (1);
+             res.force_.push_back (space.force_);
+           }
+         else
+           {
+             res.systems_per_page_.push_back (line + 1 - page_first_line);
+             res.force_.push_back (space.force_);
+           }
+       }
+    }
+  res.penalty_ = cached_line_details_.back ().page_penalty_
+               + cached_line_details_.back ().turn_penalty_;
+  return finalize_spacing_result (configuration, res);
+}
+
 /* Calculate demerits and fix res.systems_per_page_ so that
    it refers to the original line numbers, not the ones given by 
compress_lines (). */
 Page_spacing_result





reply via email to

[Prev in Thread] Current Thread [Next in Thread]