From: Joe Neeman Date: Sun, 9 Nov 2008 19:57:49 +0000 (-0800) Subject: Put systems_per_page_ in an object property instead of passing it around. X-Git-Tag: release/2.13.1-1~61^2~11 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6932257f068f0ea88c3191dff3ccc22765e0ab74;p=lilypond.git Put systems_per_page_ in an object property instead of passing it around. --- diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index 73a0f59ccc..8c3dc83fec 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -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 line_breaking_; bool ragged_; bool ragged_last_; + int systems_per_page_; + int max_systems_per_page_; Real page_top_space_; vsize system_count_; diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index f5e50ffa5b..47a2edafbe 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -39,7 +39,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); @@ -55,8 +54,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); @@ -75,7 +74,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; } @@ -99,9 +98,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_)) { @@ -143,7 +142,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_)) { diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index fe59f55356..96b9d3a0db 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -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 { @@ -687,19 +702,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; } @@ -745,19 +758,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; } @@ -826,8 +837,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_); @@ -843,7 +853,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];