]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/break-algorithm.hh
release: 1.2.14
[lilypond.git] / lily / include / break-algorithm.hh
1 /*
2   break-algorithm.hh -- declare  Break_algorithm
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996,  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef BREAK_HH
11 #define BREAK_HH
12 #include "array.hh"
13 #include "interval.hh"
14 #include "lily-proto.hh"
15 #include "column-x-positions.hh"
16
17
18 /** Class representation of an algorithm which decides where to put
19   the column, and where to break lines.
20   
21   TODO:  A "parindent", caching of breakpoints
22   
23   */
24 class Break_algorithm {
25 protected:
26
27   Paper_score *pscore_l_;
28   Real linelength;
29
30   /// search all pcols which are breakable.
31   Line_of_cols find_breaks() const;
32
33   Array<int> find_break_indices() const;
34     
35
36   /// helper: solve for the columns in #curline#.
37   void solve_line (Column_x_positions*) const;
38
39   /// helper: approximate the energyv
40   void approximate_solve_line (Column_x_positions*) const;
41
42   /// does curline fit on the paper?    
43   bool feasible (Line_of_cols) const;
44     
45
46   Simple_spacer* generate_spacing_problem (Line_of_cols, Interval) const;
47
48   virtual Array<Column_x_positions> do_solve() const=0;
49   virtual void do_set_pscore();
50
51 public:
52   
53   Simple_spacer* (*get_line_spacer)();
54     
55   Break_algorithm();
56   void set_pscore (Paper_score*);
57
58   /// check if the spacing/breaking problem is well-stated
59   void problem_OK() const;
60   void OK() const;
61   Array<Column_x_positions> solve() const;
62 };
63
64 #endif // BREAK_HH
65