2 page-spacing.hh -- routines for spacing systems
3 vertically across pages
5 source file of the GNU LilyPond music typesetter
7 (c) 2006--2009 Joe Neeman <joeneeman@gmail.com>
10 #ifndef PAGE_SPACING_HH
11 #define PAGE_SPACING_HH
13 #include "constrained-breaking.hh"
14 #include "page-spacing-result.hh"
16 /* This is a penalty that we add whenever a page breaking solution
17 is not bad enough to completely discard, but bad enough that
18 it is worse than any "proper" solution. For example, if we didn't
19 manage to fit systems on the desired number of pages or if there was
22 This constant is large enough that it dominates any reasonable penalty,
23 but small enough that nothing will overflow to infinity (so that we
24 can still distinguish bad spacings by the number of BAD_SPACING_PENALTYs
27 BAD_SPACING_PENALTY is for occasions where the spacing is bad.
28 TERRIBLE_SPACING_PENALTY is for when we are disregarding a user override
29 (for example, we are failing to satisfy min-systems-per-page). These user
30 overrides are more important than getting good spacing, so they get a
33 const Real BAD_SPACING_PENALTY = 1e6;
34 const Real TERRIBLE_SPACING_PENALTY = 1e8;
37 /* for page_count > 2, we use a dynamic algorithm similar to
38 constrained-breaking -- we have a class that stores the intermediate
39 calculations so they can be reused for querying different page counts.
44 Page_spacer (vector<Line_details> const &lines, vsize first_page_num, Page_breaking const*);
45 Page_spacing_result solve (vsize page_count);
48 struct Page_spacing_node
52 demerits_ = infinity_f;
54 penalty_ = infinity_f;
56 system_count_status_ = SYSTEM_COUNT_OK;
63 int system_count_status_;
66 Page_breaking const *breaker_;
67 vsize first_page_num_;
68 vector<Line_details> lines_;
69 Matrix<Page_spacing_node> state_;
70 vsize max_page_count_;
75 void resize (vsize page_count);
76 bool calc_subproblem (vsize page, vsize lines);
85 Real inverse_spring_k_;
87 Line_details last_line_;
88 Line_details first_line_;
89 Page_breaking const *breaker_;
91 Page_spacing (Real page_height, Page_breaking const *breaker)
93 page_height_ = page_height;
99 void resize (Real new_height);
100 void append_system (const Line_details &line);
101 void prepend_system (const Line_details &line);
105 #endif /* PAGE_SPACING_HH */