]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-turn-page-breaking.hh
Run `make grand-replace'.
[lilypond.git] / lily / include / page-turn-page-breaking.hh
1 /*
2   page-turn-page-breaking.hh -- break lines and pages optimally
3   for a whole Paper_book such that page turns can only occur
4   at specific places.
5
6   source file of the GNU LilyPond music typesetter
7
8   (c) 2006--2008 Joe Neeman <joeneeman@gmail.com>
9 */
10
11 #ifndef PAGE_TURN_PAGE_BREAKING_HH
12 #define PAGE_TURN_PAGE_BREAKING_HH
13
14 #include "page-breaking.hh"
15
16 /*
17   A dynamic programming solution to breaking pages
18  */
19 class Page_turn_page_breaking: public Page_breaking
20 {
21 public:
22   virtual SCM solve ();
23
24   Page_turn_page_breaking (Paper_book *pb);
25   virtual ~Page_turn_page_breaking ();
26
27 protected:
28   struct Break_node
29   {
30     vsize prev_;
31     int first_page_number_;
32     vsize page_count_;
33
34     /* true if every score here is too widely spaced */
35     bool too_many_lines_;
36
37     Real demerits_;
38     vsize break_pos_; /* index into breaks_ */
39
40     Line_division div_;
41     vector<vsize> system_count_; /* systems per page */
42
43     Break_node ()
44     {
45       prev_ = break_pos_ = VPOS;
46       demerits_ = infinity_f;
47       first_page_number_ = 0;
48       page_count_ = 0;
49       too_many_lines_ = false;
50     }
51   };
52
53   vector<Break_node> state_;
54
55   vsize total_page_count (Break_node const &b);
56   Break_node put_systems_on_pages (vsize start,
57                                    vsize end,
58                                    vsize configuration,
59                                    vsize page_number);
60
61   SCM make_lines (vector<Break_node> *breaks);
62   SCM make_pages (vector<Break_node> const &breaks, SCM systems);
63
64   void calc_subproblem (vsize i);
65   void print_break_node (Break_node const &b);
66 };
67 #endif /* PAGE_TURN_PAGE_BREAKING_HH */