]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/break.hh
c6654fa8f04d2887aa719ad739d7d6d345466141
[lilypond.git] / lily / include / break.hh
1 /*
2   break.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   Statistics for the number of columns calced.
19  */
20 struct Col_stats
21 {
22   int count_i_;
23   int cols_i_;
24
25   Col_stats(); 
26   void add (Line_of_cols const&l);
27   String str() const;
28 };
29
30 /** Class representation of an algorithm which decides where to put
31   the column, and where to break lines.
32   
33   TODO:  A "parindent", caching of breakpoints
34   
35   */
36 class Break_algorithm {
37 protected:
38
39   Paper_score *pscore_l_;
40   Real linelength;
41
42   /// search all pcols which are breakable.
43   Line_of_cols find_breaks() const;
44
45   Array<int> find_break_indices() const;
46     
47
48   /// helper: solve for the columns in #curline#.
49   void solve_line (Column_x_positions*) const;
50
51   /// helper: approximate the energyv
52   void approximate_solve_line (Column_x_positions*) const;
53
54   /// does curline fit on the paper?    
55   bool feasible (Line_of_cols) const;
56     
57
58   Line_spacer* generate_spacing_problem (Line_of_cols, Interval) const;
59
60   virtual Array<Column_x_positions> do_solve() const=0;
61   virtual void do_set_pscore();
62
63 public:
64   Col_stats approx_stats_;
65   Col_stats exact_stats_;
66   
67   Line_spacer* (*get_line_spacer)();
68     
69   Break_algorithm();
70   void set_pscore (Paper_score*);
71
72   /// check if the spacing/breaking problem is well-stated
73   void problem_OK() const;
74   void OK() const;
75   Array<Column_x_positions> solve() const;
76 };
77
78 #endif // BREAK_HH
79