]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-turn-page-breaking.hh
Merge branch 'cvs-head' of ssh+git://hanwen@repo.or.cz/srv/git/lilypond into master...
[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     /* true if every score here is too widely spaced */
37     bool too_many_lines_;
38
39     Real demerits_;
40     vsize break_pos_; /* index into breaks_ */
41
42     Line_division div_;
43     vector<vsize> system_count_; /* systems per page */
44
45     Break_node ()
46     {
47       prev_ = break_pos_ = VPOS;
48       demerits_ = infinity_f;
49       first_page_number_ = 0;
50       page_count_ = 0;
51       too_many_lines_ = false;
52     }
53   };
54
55   vector<Break_node> state_;
56
57   vsize final_page_num (Break_node const &b);
58   Break_node put_systems_on_pages (vsize start,
59                                    vsize end,
60                                    vector<Line_details> const &lines,
61                                    Line_division const &div,
62                                    int page_number);
63
64   SCM make_lines (vector<Break_node> *breaks);
65   SCM make_pages (vector<Break_node> const &breaks, SCM systems);
66
67   void calc_subproblem (vsize i);
68 };
69 #endif /* PAGE_TURN_PAGE_BREAKING_HH */