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