]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/break.hh
release: 1.0.1
[lilypond.git] / lily / include / break.hh
index 703f9bb8164ba1dd9401715a5cd6b96f842fc8b8..f3b3deb18b1b58de4aaa3481494d5e00809df993 100644 (file)
@@ -3,56 +3,78 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c) 1996,  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
 #ifndef BREAK_HH
 #define BREAK_HH
-#include "varray.hh"
+#include "array.hh"
+#include "interval.hh"
 #include "lily-proto.hh"
 #include "colhpos.hh"
 
+/**
+  Statistics for the number of columns calced.
+ */
+struct Col_stats
+{
+  int count_i_;
+  int cols_i_;
+
+  Col_stats(); 
+  void add (Line_of_cols const&l);
+  String str() const;
+};
+
 /** Class representation of an algorithm which decides where to put
   the column, and where to break lines.
   
-  TODO: a decent algorithm, based on dynamic programming or something
-  a like. A "parindent", caching of breakpoints
+  TODO:  A "parindent", caching of breakpoints
   
   */
 class Break_algorithm {
-    void generate_spacing_problem(Line_of_cols,Spacing_problem&)const;
 protected:
-    PScore &pscore_;
-    Real linelength;
 
-    /// search all pcols which are breakable.
-    Line_of_cols find_breaks() const;
+  Paper_score *pscore_l_;
+  Real linelength;
 
-     /// helper: solve for the columns in #curline#.
-    Col_hpositions solve_line(Line_of_cols) const;
+  /// search all pcols which are breakable.
+  Line_of_cols find_breaks() const;
 
-    /// does curline fit on the paper?    
-    bool feasible(Line_of_cols)const;
+  Line_of_cols all_cols() const;
+  Array<int> find_break_indices() const;
     
 
-    /** generate a solution with no regard to idealspacings or
-      constraints.  should always work */
-    Col_hpositions stupid_solution(Line_of_cols) const;
-    virtual Array<Col_hpositions> do_solve()const=0;
-public:
-    Break_algorithm(PScore&);
+  /// helper: solve for the columns in #curline#.
+  void solve_line (Column_x_positions*) const;
 
-    /// check if the spacing/breaking problem is well-stated
-    void problem_OK()const;
+  /// helper: approximate the energyv
+  void approximate_solve_line (Column_x_positions*) const;
 
-    Array<Col_hpositions> solve()const;
-};
+  /// does curline fit on the paper?    
+  bool feasible (Line_of_cols) const;
+    
+
+  Line_spacer* generate_spacing_problem (Line_of_cols, Interval) const;
 
-/// wordwrap type algorithm: move to next line if current is optimal.
-struct Word_wrap : Break_algorithm {
-    virtual Array<Col_hpositions> do_solve()const;
-    Word_wrap(PScore&);
+  virtual Array<Column_x_positions> do_solve() const=0;
+  virtual void do_set_pscore();
+
+public:
+  Col_stats approx_stats_;
+  Col_stats exact_stats_;
+  
+  Line_spacer* (*get_line_spacer)();
+    
+  Break_algorithm();
+  void set_pscore (Paper_score*);
+
+  /// check if the spacing/breaking problem is well-stated
+  void problem_OK() const;
+  void OK() const;
+  Array<Column_x_positions> solve() const;
 };
+
 #endif // BREAK_HH