]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/linespace.hh
release: 1.0.13
[lilypond.git] / lily / include / linespace.hh
index 28e2abc01c564f0dcdee61c04f80233fdfd94fa1..8b230ff5161035ef9c9c1518678e5380f814b0ea 100644 (file)
@@ -1,30 +1,21 @@
-#ifndef PROBLEM_HH
-#define PROBLEM_HH
+/*
+  linespace.hh -- declare  Spacing_problem
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#error
+
+#ifndef LINESPACE_HH
+#define LINESPACE_HH
 
-#include "glob.hh"
 #include "plist.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "vector.hh"
 #include "interval.hh"
-
-/// helper struct for #Spacing_problem#
-struct Colinfo {
-    PCol const *pcol_;
-    Real const * fixpos;
-    Interval width;
-    
-    /* *************** */
-    Colinfo();
-    void operator=(Colinfo const&);
-    Colinfo(Colinfo const&);
-    ~Colinfo();
-    Colinfo(PCol const *,Real const *);
-    void print() const;
-    bool fixed() const { return fixpos;}
-    Real fixed_position()const { return *fixpos; }
-    Real minright() const { return width.right; }
-    Real minleft() const { return -width.left; }
-};
+#include "pointer.hh"
 
 
 /** the problem, given by the columns (which include constraints) and
@@ -50,11 +41,14 @@ struct Colinfo {
 
 */
 class Spacing_problem {
-    Array<Idealspacing const *> ideals;
-    Array<Colinfo> cols;
-
+    PointerList<Idealspacing *> ideal_p_list_;
+    Array<Column_info> cols;
+    Array<Column_info> loose_col_arr_;
+    
+    /// mark column #i# as being loose.
+    void loosen_column (int i);
     /// the index of #c# in #cols#
-    int col_id(PCol const *c) const;
+    int col_id (Paper_column const *c) const;
 
     /// generate an (nonoptimal) solution
     Vector find_initial_solution() const;
@@ -63,47 +57,38 @@ class Spacing_problem {
     bool check_feasible() const;
 
     /// does #this# contain the column #w#? 
-    bool contains(PCol const *w);
+    bool contains (Paper_column const *w);
 
     /// make the energy function
-    void make_matrices(Matrix &quad, Vector &lin,Real&) const;
+    void make_matrices (Matrix &quad, Vector &lin,Real&) const;
 
     /// generate the LP constraints
-    void make_constraints(Mixed_qp& lp) const;
-
-public:
-    /** solve the spacing problem
-      
-      @return the column positions, and the energy (last element)
+    void make_constraints (Mixed_qp& lp) const;
 
-      */
-    Array<Real> solve() const;
 
-    
-    /**
-       add a idealspacing to the problem.
-      
-    One pair of columns can have no, one or more idealspacings,
-    since they can be "summed" if the columns to which #i# refers are
-    not in this problem, the spacing is ignored.
-    */
-    void add_ideal(Idealspacing const *i);
-    
-    
-    /** add a col to the problem. columns have to be added left to right. The column contains
-      info on it's minimum width.
-    */
-    void add_column(PCol const *, bool fixed=false, Real fixpos=0.0);
+    void handle_loose_cols();
+    void position_loose_cols (Vector &) const;
+    void print_ideal (Idealspacing const *) const; 
+    Vector try_initial_solution() const;
+    void calcideal();
 
+    Score_column* scol_l (int);
+    void connect (int i,int j, Real,Real);
+public:
+    static Line_spacer *constructor() {
+       return new Line_spacer;
+    }
+    Array<Paper_column*> error_pcol_l_arr() const;
 
-    bool check_constraints(Vector v) const;
+    virtual   Array<Real> solve() const;
+    virtual void add_column (Paper_column  *, bool fixed=false, Real fixpos=0.0);
 
-    Vector try_initial_solution() const;
-    void OK() const;
-    void print() const;
-    void print_ideal(Idealspacing const *)const;
+    virtual Vector default_solution() contains { 
+       return try_initial_solution() ; 
+    }
+    virtual   bool check_constraints (Vector v) const;
+    virtual    void OK() const;
+    virtual    void print() const;
+    virtual    void prepare();
 };
-
-
-#endif