]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/page-turn-page-breaking.hh
Run grand-replace (issue 3765)
[lilypond.git] / lily / include / page-turn-page-breaking.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2006--2014 Joe Neeman <joeneeman@gmail.com>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef PAGE_TURN_PAGE_BREAKING_HH
21 #define PAGE_TURN_PAGE_BREAKING_HH
22
23 #include "page-breaking.hh"
24
25 /*
26   A dynamic programming solution to breaking pages
27  */
28 class Page_turn_page_breaking: public Page_breaking
29 {
30 public:
31   virtual SCM solve ();
32
33   Page_turn_page_breaking (Paper_book *pb);
34   virtual ~Page_turn_page_breaking ();
35
36 protected:
37   struct Break_node
38   {
39     vsize prev_;
40     int first_page_number_;
41     vsize page_count_;
42
43     /* true if every score here is too widely spaced */
44     bool too_many_lines_;
45
46     Real demerits_;
47     vsize break_pos_; /* index into breaks_ */
48
49     Line_division div_;
50     vector<vsize> system_count_; /* systems per page */
51
52     Break_node ()
53     {
54       prev_ = break_pos_ = VPOS;
55       demerits_ = infinity_f;
56       first_page_number_ = 0;
57       page_count_ = 0;
58       too_many_lines_ = false;
59     }
60   };
61
62   vector<Break_node> state_;
63
64   vsize total_page_count (Break_node const &b);
65   Break_node put_systems_on_pages (vsize start,
66                                    vsize end,
67                                    vsize configuration,
68                                    vsize page_number);
69
70   SCM make_lines (vector<Break_node> *breaks);
71   SCM make_pages (vector<Break_node> const &breaks, SCM systems);
72
73   void calc_subproblem (vsize i);
74   void print_break_node (Break_node const &b);
75 };
76 #endif /* PAGE_TURN_PAGE_BREAKING_HH */