]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-turn-page-breaking.hh
1706437908be0a93a7adda746911dbea2a80f578
[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 Joe Neeman <joeneeman@gmail.com>
9 */
10
11 #ifndef PAGE_TURN_PAGE_BREAKING_HH
12 #define PAGE_TURN_PAGE_BREAKING_HH
13
14 #include "constrained-breaking.hh"
15 #include "page-breaking.hh"
16 #include "lily-guile.hh"
17
18 /*
19   A dynamic programming solution to breaking pages
20  */
21 class Page_turn_page_breaking: public Page_breaking
22 {
23 public:
24   virtual SCM solve ();
25
26   Page_turn_page_breaking (Paper_book *pb);
27   virtual ~Page_turn_page_breaking ();
28
29 protected:
30   struct Break_node
31   {
32     vsize prev_;
33     int first_page_number_;
34     vsize page_count_;
35
36     Real force_;
37     Real penalty_;
38
39     Real line_force_;
40     Real line_penalty_;
41
42     /* true if every score here is too widely spaced */
43     bool too_many_lines_;
44
45     Real demerits_;
46     vsize break_pos_; /* index into breaks_ */
47
48     Line_division div_;
49     vector<vsize> system_count_; /* systems per page */
50
51     Break_node ()
52     {
53       prev_ = break_pos_ = VPOS;
54       penalty_ = force_ = 0;
55       line_penalty_ = line_force_ = 0;
56       demerits_ = infinity_f;
57       first_page_number_ = 0;
58       page_count_ = 0;
59       too_many_lines_ = false;
60     }
61   };
62
63   vector<Break_node> state_;
64
65   vsize final_page_num (Break_node const &b);
66   Break_node put_systems_on_pages (vsize start,
67                                    vsize end,
68                                    vector<Line_details> const &lines,
69                                    Line_division const &div,
70                                    int page_number);
71
72   SCM make_lines (vector<Break_node> *breaks);
73   SCM make_pages (vector<Break_node> const &breaks, SCM systems);
74
75   Real calc_demerits (Break_node const &me);
76   void calc_subproblem (vsize i);
77 };
78 #endif /* PAGE_TURN_PAGE_BREAKING_HH */