]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/break.hh
release: 0.1.11
[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 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef BREAK_HH
11 #define BREAK_HH
12 #include "varray.hh"
13 #include "lily-proto.hh"
14 #include "colhpos.hh"
15
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     Line_of_cols all_cols() const;
46     Array<int> find_break_indices() const;
47     
48
49     /// helper: solve for the columns in #curline#.
50     void solve_line (Col_hpositions*) const;
51
52     /// helper: approximate the energyv
53     void approximate_solve_line (Col_hpositions*) const;
54
55     /// does curline fit on the paper?    
56     bool feasible (Line_of_cols) const;
57     
58
59     Line_spacer* generate_spacing_problem (Line_of_cols) const;
60
61     virtual Array<Col_hpositions> do_solve() const=0;
62     void print_stats() const;
63
64     virtual void do_set_pscore();
65 public:
66     Col_stats approx_stats_;
67     Col_stats exact_stats_;
68
69     Line_spacer* (*get_line_spacer)();
70     
71     Break_algorithm();
72     void set_pscore (Paper_score*);
73
74     /// check if the spacing/breaking problem is well-stated
75     void problem_OK() const;
76     void OK() const;
77     Array<Col_hpositions> solve() const;
78 };
79
80 #endif // BREAK_HH
81