]> git.donarmstrong.com Git - lilypond.git/commitdiff
Put systems_per_page_ in an object property instead of passing it around.
authorJoe Neeman <joeneeman@gmail.com>
Sun, 9 Nov 2008 19:57:49 +0000 (11:57 -0800)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 9 Nov 2008 19:57:49 +0000 (11:57 -0800)
lily/include/page-breaking.hh
lily/optimal-page-breaking.cc
lily/page-breaking.cc

index 205d9348e7ea024b1b0052fae38caa84f821ee09..5768e4b1098af965a87f67d5efc22c44dc8f65e6 100644 (file)
@@ -101,6 +101,8 @@ public:
   bool ragged_last () const;
   bool is_last () const;
   bool ends_score () const;
+  int systems_per_page () const;
+  int max_systems_per_page () const;
   Real page_height (int page_number, bool last) const;
   Real page_top_space () const;
   vsize system_count () const;
@@ -129,16 +131,13 @@ protected:
   vsize current_configuration_count () const;
   Line_division current_configuration (vsize configuration_index) const;
   Page_spacing_result space_systems_on_n_pages (vsize configuration_index,
-                                               vsize n, vsize first_page_num,
-                                               int systems_per_page=0);
+                                               vsize n, vsize first_page_num);
   Page_spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n,
-                                                           vsize first_page_num,
-                                                           int systems_per_page=0);
+                                                           vsize first_page_num);
   Page_spacing_result space_systems_on_best_pages (vsize configuration_index,
                                                   vsize first_page_num);
   Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index,
-                                                               vsize first_page_num,
-                                                               int systems_per_page);
+                                                               vsize first_page_num);
   Page_spacing_result pack_systems_on_least_pages (vsize configuration_index,
                                                   vsize first_page_num);
   vsize min_page_count (vsize configuration_index, vsize first_page_num);
@@ -155,6 +154,8 @@ private:
   vector<Constrained_breaking> line_breaking_;
   bool ragged_;
   bool ragged_last_;
+  int systems_per_page_;
+  int max_systems_per_page_;
   Real page_top_space_;
   vsize system_count_;
 
index 7eb04ce24d9fc48cab1b7fdf6e1b1920c7e01f9e..1946af4d40765ba78954cce73388606c6581a465 100644 (file)
@@ -40,7 +40,6 @@ Optimal_page_breaking::solve ()
   vsize max_sys_count = max_system_count (0, end);
   vsize first_page_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
   SCM forced_page_count = book_->paper_->c_variable ("page-count");
-  int systems_per_page = robust_scm2int (book_->paper_->c_variable ("systems-per-page"), 0);
 
   set_to_ideal_line_configuration (0, end);
 
@@ -56,8 +55,8 @@ Optimal_page_breaking::solve ()
       /* find out the ideal number of pages */
       message (_ ("Finding the ideal number of pages..."));
   
-      if (systems_per_page > 0)
-       best = space_systems_with_fixed_number_per_page (0, first_page_num, systems_per_page);
+      if (systems_per_page () > 0)
+       best = space_systems_with_fixed_number_per_page (0, first_page_num);
       else
        best = space_systems_on_best_pages (0, first_page_num);
 
@@ -74,7 +73,7 @@ Optimal_page_breaking::solve ()
         ideal line spacing doesn't fit on PAGE_COUNT pages */
       /* TODO: the interaction between systems_per_page and page_count needs to
         be considered. */
-      best = space_systems_on_n_pages (0, page_count, first_page_num, systems_per_page);
+      best = space_systems_on_n_pages (0, page_count, first_page_num);
       min_sys_count = page_count;
     }
 
@@ -98,9 +97,9 @@ Optimal_page_breaking::solve ()
          Page_spacing_result cur;
 
          if (min_p_count == page_count || scm_is_integer (forced_page_count))
-           cur = space_systems_on_n_pages (i, page_count, first_page_num, systems_per_page);
+           cur = space_systems_on_n_pages (i, page_count, first_page_num);
          else
-           cur = space_systems_on_n_or_one_more_pages (i, page_count-1, first_page_num, systems_per_page);
+           cur = space_systems_on_n_or_one_more_pages (i, page_count-1, first_page_num);
 
          if (cur.demerits_ < best_for_this_sys_count.demerits_ || isinf (best_for_this_sys_count.demerits_))
            {
@@ -142,7 +141,7 @@ Optimal_page_breaking::solve ()
          if (min_p_count > page_count)
            continue;
          else
-           cur = space_systems_on_n_pages (i, page_count, first_page_num, systems_per_page);
+           cur = space_systems_on_n_pages (i, page_count, first_page_num);
 
          if (cur.demerits_ < best.demerits_ || isinf (best.demerits_))
            {
index 7b0bb8cffb9444b2603e6f8f444d4127bd0e081a..1aedcb9d270c948f0f2f12461456ea381aae1649 100644 (file)
@@ -101,6 +101,9 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break)
   ragged_ = to_boolean (pb->paper_->c_variable ("ragged-bottom"));
   ragged_last_ = to_boolean (pb->paper_->c_variable ("ragged-last-bottom"));
   page_top_space_ = robust_scm2double (pb->paper_->c_variable ("page-top-space"), 0);
+  systems_per_page_ = robust_scm2int (pb->paper_->c_variable ("systems-per-page"), 0);
+  max_systems_per_page_ = robust_scm2int (pb->paper_->c_variable ("max-systems-per-page"), 0);
+
   create_system_list ();
   find_chunks_and_breaks (is_break);
 }
@@ -121,6 +124,18 @@ Page_breaking::ragged_last () const
   return ragged_last_;
 }
 
+int
+Page_breaking::systems_per_page () const
+{
+  return systems_per_page_;
+}
+
+int
+Page_breaking::max_systems_per_page () const
+{
+  return max_systems_per_page_;
+}
+
 Real
 Page_breaking::page_top_space () const
 {
@@ -682,19 +697,17 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
   return ret;
 }
 
-// If systems_per_page is positive, we don't really try to space on N pages;
+// If systems_per_page_ is positive, we don't really try to space on N pages;
 // we just put the requested number of systems on each page and penalize
 // if the result doesn't have N pages.
 Page_spacing_result
-Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize first_page_num,
-                                        int systems_per_page)
+Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize first_page_num)
 {
   Page_spacing_result ret;
 
-  if (systems_per_page > 0)
+  if (systems_per_page_ > 0)
     {
-      Page_spacing_result ret = space_systems_with_fixed_number_per_page (configuration, first_page_num,
-                                                                         systems_per_page);
+      Page_spacing_result ret = space_systems_with_fixed_number_per_page (configuration, first_page_num);
       ret.demerits_ += (ret.force_.size () == n) ? 0 : BAD_SPACING_PENALTY;
       return ret;
     }
@@ -740,19 +753,17 @@ Page_breaking::blank_page_penalty () const
   return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0);
 }
 
-// If systems_per_page is positive, we don't really try to space on N
+// If systems_per_page_ is positive, we don't really try to space on N
 // or N+1 pages; see the comment to space_systems_on_n_pages.
 Page_spacing_result
-Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize n, vsize first_page_num,
-                                                    int systems_per_page)
+Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize n, vsize first_page_num)
 {
   Page_spacing_result n_res;
   Page_spacing_result m_res;
 
-  if (systems_per_page > 0)
+  if (systems_per_page_ > 0)
     {
-      Page_spacing_result ret = space_systems_with_fixed_number_per_page (configuration, first_page_num,
-                                                                         systems_per_page);
+      Page_spacing_result ret = space_systems_with_fixed_number_per_page (configuration, first_page_num);
       ret.demerits_ += (ret.force_.size () == n || ret.force_.size () == (n-1)) ? 0 : BAD_SPACING_PENALTY;
       return ret;
     }
@@ -821,8 +832,7 @@ Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_pag
 
 Page_spacing_result
 Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration,
-                                                        vsize first_page_num,
-                                                        int systems_per_page)
+                                                        vsize first_page_num)
 {
   Page_spacing_result res;
   Page_spacing space (page_height (first_page_num, false), page_top_space_);
@@ -838,7 +848,7 @@ Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration,
       space.resize (page_height (first_page_num + page, false));
 
       int system_count_on_this_page = 0;
-      while (system_count_on_this_page < systems_per_page
+      while (system_count_on_this_page < systems_per_page_
             && line < cached_line_details_.size ())
        {
          Line_details const &cur_line = cached_line_details_[line];