]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.76
authorfred <fred>
Sun, 24 Mar 2002 19:48:22 +0000 (19:48 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:48:22 +0000 (19:48 +0000)
lily/include/line-spacer.hh [new file with mode: 0644]
lily/line-spacer.cc [new file with mode: 0644]
lily/wordwrap.cc

diff --git a/lily/include/line-spacer.hh b/lily/include/line-spacer.hh
new file mode 100644 (file)
index 0000000..c8bf02b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+  line-spacer.hh -- declare Line_spacer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef LINE_SPACER_HH
+#define LINE_SPACER_HH
+#include "lily-proto.hh"
+#include "varray.hh"
+#include "vector.hh"
+#include "interval.hh"
+
+/**
+  abstract interface to Line spacing.
+
+  TODO
+  add estimate of "force" or energy.
+ */
+
+class Line_spacer 
+{
+    
+public:
+    Paper_def * paper_l_;
+    Paper_def *paper_l()const;
+    Line_spacer();
+    
+    virtual Array<PCol*> error_pcol_l_arr() const=0;
+
+    /** solve the spacing problem
+      
+      @return the column positions, and the energy (last element)
+
+      */
+    virtual Array<Real> solve() const=0;
+
+    /** add a col to the problem. columns have to be added left to
+      right. The column contains info on it's minimum width.  */
+    virtual void add_column(PCol  *, bool fixed=false, Real fixpos=0.0)=0;
+
+    /**
+      can the posed problem be solved?
+      
+      @pre
+
+      prepare() was called
+      
+     */
+    virtual bool check_constraints(Vector v) const=0;
+
+    /**
+      generate a solution which can't fail
+     */
+    virtual Vector default_solution() const=0;
+    
+    virtual void OK() const{}
+    virtual void print() const{}
+    
+    /**
+      Call after construction before solving
+     */
+    virtual void prepare(){}
+};
+
+#endif
diff --git a/lily/line-spacer.cc b/lily/line-spacer.cc
new file mode 100644 (file)
index 0000000..bc5ef29
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+  line-spacer.cc -- implement 
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#include "line-spacer.hh"
+
+Line_spacer::Line_spacer()
+{
+    paper_l_ =0;
+}
+Paper_def*
+Line_spacer::paper_l()const
+{ 
+
+
+    return paper_l_ ;
+}
index 5aefed16f3fc0e55e19a69b2fc4162a5f911777b..8653c071e9dec7cdaa8b14d28488abdae514e246 100644 (file)
@@ -6,21 +6,24 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
-#include "break.hh"
+#include "word-wrap.hh"
 #include "p-score.hh"
 #include "debug.hh"
 #include "p-col.hh"
+#include "spring-spacer.hh"
+
+
 /** el stupido. This should be done more accurately:
 
    It would be nice to have a Dynamic Programming type of algorithm
    similar to TeX's
    
-    */
+   */
 Array<Col_hpositions>
 Word_wrap::do_solve()const
 {
     problem_OK();
-    iter_top(pscore_.cols,curcol);
+    iter_top(pscore_l_->col_p_list_,curcol);
     Array<Col_hpositions> breaking;
     Line_of_cols breakpoints(find_breaks());
     assert(breakpoints.size()>=2);
@@ -87,4 +90,5 @@ Word_wrap::do_solve()const
 Word_wrap::Word_wrap(PScore&ps)
     : Break_algorithm(ps)
 {
+    get_line_spacer = Spring_spacer::constructor;
 }