]> git.donarmstrong.com Git - lilypond.git/commitdiff
release: 0.0.18 release/0.0.18
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 Dec 1996 10:20:48 +0000 (11:20 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 Dec 1996 10:20:48 +0000 (11:20 +0100)
60 files changed:
.dstreamrc
Makefile
NEWS
README
Variables.make
flower/Sources.make
flower/Variables.make
flower/cursor.cc [deleted file]
flower/cursor.hh
flower/cursor.tcc [new file with mode: 0644]
flower/interval.cc [deleted file]
flower/interval.hh
flower/interval.tcc [new file with mode: 0644]
flower/iterate.hh [new file with mode: 0644]
flower/list.cc [deleted file]
flower/list.hh
flower/list.inl
flower/list.tcc [new file with mode: 0644]
flower/plist.cc [deleted file]
flower/plist.hh
flower/plist.tcc [new file with mode: 0644]
flower/smat.cc
flower/tsmat.cc [deleted file]
flower/tsmat.tcc [new file with mode: 0644]
hdr/Makefile
hdr/beam.hh
hdr/command.hh
hdr/getcommand.hh
hdr/grouping.hh
hdr/pscore.hh
hdr/scoreline.hh
hdr/simplewalker.hh
hdr/slur.hh
hdr/spanner.hh
hdr/staffcommands.hh
make_patch
src/Makefile
src/beam.cc
src/break.cc
src/calcideal.cc
src/command.cc
src/getcommands.cc
src/grouping.cc
src/inputcommands.cc
src/item.cc
src/keyitem.cc
src/linespace.cc
src/parser.y
src/pcol.cc
src/pscore.cc
src/qlp.cc
src/score.cc
src/scoreline.cc
src/simplewalker.cc
src/slur.cc
src/staff.cc
src/staffcommands.cc
src/staffline.cc
src/template3.cc
symbol.ini

index b14fb6c79ae1a11dff02a3ba04c0d2be16a85562..be1953b0ded35a48d2918bf3463b53cd8cd75162 100644 (file)
@@ -1,7 +1,7 @@
 # class name           silence?
 
-My_flex_lexer          0
-yyFlexLexer            0
+My_flex_lexer          1
+yyFlexLexer            1
 PCol                   1
 Score_column           1
 Ineq_constrained_qp    1
@@ -12,7 +12,7 @@ PScore                        1
 Idealspacing           1
 
 # yydebug
-Parser                 0
+Parser                 1
 
 # FlexLexer debug
 Lexer                  1
@@ -25,8 +25,8 @@ Note_req              1
 Rhythmic_req           1
 Rest_req               1
 delete_identifiers     1
-Command                        1
-Staff_commands         1
+Command                        0
+Staff_commands         0
 Stem                   0
 Staff                  0
 Score                  0
index ac9d7254ea4bb40b24ffb2d66ece0134e034005a..d0bdffd022c59dbb3af398ca6be2fe2d5f45246a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,16 @@
 include Variables.make 
 
+.SUFFIXES:
+.SUFFIXES: .cc .o .hh .y .l
+
 $(exe): $(obs)
        $(CXX) -o $@ $^ $(LOADLIBES)
 
 clean:
 #      $(MAKE) -C objects clean
        rm -f $(exe) objects/*.o $(DOCDIR)/* core  
+       $(MAKE) -C $(CCDIR) clean
+       $(MAKE) -C $(HEADERDIR) clean
 
 distclean: clean
        rm -f  depend version.hh $(gencc) .GENERATE *~
diff --git a/NEWS b/NEWS
index 455012a74f3a035e05f8888ed0de6f46aab17452..34a2deafd20a5dd12f32fd340dde8c2822fdf9d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+pl 18:
+       - robust Staff_commands
+
 pl 17:
        - robust Input_commands
        - merged Vertical_/Horizontal music
diff --git a/README b/README
index b849b7f2ee00b88f98c29c455095213aed612cc0..c936c13e294415127fa531c0335f0f7ee0222d18 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,10 @@
 -*-text-*-
 
-last update: 96/12/12, 0.0.16
+last update: 96/17/12, 0.0.17
+
+LICENSE
+
+See file COPYING
 
 INTRODUCTION
 
@@ -50,6 +54,7 @@ why G++ >= 2.7? LilyPond & flower lib uses:
        builtin bool
        typeof
        operator <?, operator >?
+       new for-scope
 
 USING
 
@@ -63,30 +68,40 @@ what I type in my xterm:
 
 This is what the output looks like over here:
 
-hw:~/musix/spacer$ lilypond maartje.ly
-LilyPond version 0.0.16 compiled on Dec 11 1996 at 13:54:27
-Parsing ... [symbol.ini][maartje.ly]
-Processing ... Calculating ... Postprocessing ... 
-output to lelie.uit...
+       hw:~/musix/spacer$ lilypond maartje.ly
+       LilyPond 0.0.17/FlowerLib 1.0.14. Compile: Dec 17 1996, 11:33:54 (g++ 2.7.2)
+       Parsing ... [symbol.ini][maartje.ly]
+       Processing ... Calculating ... Postprocessing ... 
+       output to lelie.uit...
 
-hw:~/musix/spacer$ tex test
-This is TeX, Version 3.14159 (C version 6.1)
-(test.tex
-Hyphenation patterns for english, dutch, loaded.
-(lilyponddefs.tex) (lelie.uit) [1] [2] )
-Output written on test.dvi (2 pages, 8072 bytes).
-Transcript written on test.log.
+       hw:~/musix/spacer$ tex test
+       This is TeX, Version 3.14159 (C version 6.1)
+       (test.tex
+       Hyphenation patterns for english, dutch, loaded.
+       (lilyponddefs.tex) (lelie.uit) [1] [2] )
+       Output written on test.dvi (2 pages, 8072 bytes).
+       Transcript written on test.log.
 
-hw:~/musix/spacer$ xdvi test&
-[1] 1468
+       hw:~/musix/spacer$ xdvi test&
+       [1] 1468
 
 Check out kortjakje.ly, it has some comments
 
+
 PROBLEMS
 
 If LilyPond bombs out, then please recompile using -g, and send a gdb
-stacktrace of the crash.
+stacktrace of the crash. It also helps if you can print the values of the objects. So if you trace is
+
+(gdb) backtrace 12
+#0  Interval::operator+= (this=0x11fffec60, r=-1.7976931348623157e+308)
+    at ../flower/interval.hh:50
+#1  0x12005195c in Item::width (this=0x14008a680) at src/item.cc:39
+#2  0x12008fdbc in itemlist_width (its=0x11fffed58) at src/simpleprint.cc:40
+  :
+  :
 
+Than it would help if you send a dump of the Interval and the Item (use: 'print *this' or use LilyPond print() methods)
 
 HOW DOES IT WORK
 
index f386e5546d9df322edf24e0c7aab435f3f4115f8..6e67b107d308f205bccb6d380b968f062e909d09 100644 (file)
@@ -37,7 +37,7 @@ endif
 # version info
 MAJVER=0
 MINVER=0
-PATCHLEVEL=17
+PATCHLEVEL=18
 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
 CXXVER=`$(CXX) --version`
 
index 84e27c4681c83fa789e62032a33da76482763737..2a618814c3fd9db08bcfa5a23af1b78b511f4ce8 100644 (file)
@@ -3,12 +3,14 @@ cc=lgetopt.cc          string.cc dataf.cc textdb.cc unionfind.cc  \
        smat.cc matrix.cc choleski.cc vector.cc dstream.cc\
        matdebug.cc  scalar.cc
 
-templatecc=cursor.cc list.cc tsmat.cc plist.cc interval.cc
+templatecc=cursor.tcc list.tcc tsmat.tcc plist.tcc interval.tcc
+
 inl=findcurs.inl link.inl list.inl  cursor.inl plist.inl
 hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \
        string.hh stringutil.hh vray.hh textdb.hh textstr.hh  assoc.hh\
        findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\
        smat.hh vsmat.hh  vector.hh  real.hh choleski.hh\
        tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\
-       interval.hh scalar.hh sstack.hh rational.hh
+       interval.hh scalar.hh sstack.hh rational.hh iterate.hh\
+       
 
index 9d58ba9063122b08594da3d29f654556e210c24f..7d6f0479a5a57aac95f4bcf32fc63959deff7e76 100644 (file)
@@ -1,10 +1,10 @@
 MAJVER=1
 MINVER=0
-PATCHLEVEL=17
+PATCHLEVEL=18
 PACKAGENAME=flower
 
 #PROFILEFLAG=-pg
-DEBUGFLAG=-g -O2
+DEBUGFLAG=-g -O2 -DNDEBUG
 OPTIFLAG=-DNDEBUG -DNPRINT -O2
 
 #########################################
diff --git a/flower/cursor.cc b/flower/cursor.cc
deleted file mode 100644 (file)
index 3d2116c..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef CURSOR_CC
-#define CURSOR_CC
-
-#include "cursor.hh"
-#include <assert.h>
-
-template<class T>
- void
-Cursor<T>::backspace()
-{
-    Cursor<T> c(*this);
-    c--;        
-    list_.remove( *this );
-}
-
-template<class T>
- void
-Cursor<T>::del()
-{
-    Cursor<T> c(*this);
-    c++;
-    list_.remove( *this );    
-    *this = c;
-}
-
-
-template<class T>
-Cursor<T> 
-Cursor<T>::operator -=( int j )    
-{
-    while (j--)
-       (*this)--;
-    return *this;
-}
-template<class T>
-Cursor<T> 
-Cursor<T>::operator +=( int j )    
-{
-    while (j++)
-       (*this)++;
-    return *this;
-}
-
-template<class T>
-Cursor<T> 
-Cursor<T>::operator +( int i ) const    
-{
-    Cursor<T> r = *this;
-
-    if (i<0)
-       return r -(-i);
-
-    while (i--)
-       r++;
-
-    return r;
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator -( int i ) const
-{
-    Cursor<T> r = *this;
-    if (i<0)
-       return r +(-i);
-
-    while (i--)
-       r--;
-    
-    return r;
-}
-/*
-  warning:  can't use Cursor::operator == (Cursor),
-  since it uses Cursor::operator-(Cursor)
- */
-template<class T>
-int
-Cursor<T>::operator-(Cursor<T> rhs) const
-{
-    assert(rhs.list == list);
-    int dif = 0;
-
-    // search from *this on further up (positive difference)
-    Cursor<T> c(*this);
-    while (c.ok() && c.pointer_ != rhs.pointer_) {
-       c--;
-       dif++;
-    }
-    
-    if (c.ok())
-       goto gotcha;            // so, sue me.
-
-    // search in direction of bottom. (negative diff)
-    dif =0;
-    c=*this;    
-    while (c.ok() && c.pointer_ !=rhs.pointer_) {
-       dif --;
-       c++;
-    }
-    assert(c.ok());
-
-gotcha:
-    assert((*this - dif).pointer_ == c.pointer_);
-    return dif;
-}
-
-#endif
index 428a52748fb0b7ff196238adc2685ed59cc03fe4..c6a8584335b113ed858fe9222d73daf6f7b959ab 100644 (file)
@@ -110,5 +110,6 @@ template_instantiate_compare(Cursor<T>, Cursor<T>::compare, template<class T>);
 #include "pcursor.hh"
 #include "list.hh"
 #include "cursor.inl"
+#include "iterate.hh"
 
 #endif // CURSOR_HH 
diff --git a/flower/cursor.tcc b/flower/cursor.tcc
new file mode 100644 (file)
index 0000000..3d2116c
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef CURSOR_CC
+#define CURSOR_CC
+
+#include "cursor.hh"
+#include <assert.h>
+
+template<class T>
+ void
+Cursor<T>::backspace()
+{
+    Cursor<T> c(*this);
+    c--;        
+    list_.remove( *this );
+}
+
+template<class T>
+ void
+Cursor<T>::del()
+{
+    Cursor<T> c(*this);
+    c++;
+    list_.remove( *this );    
+    *this = c;
+}
+
+
+template<class T>
+Cursor<T> 
+Cursor<T>::operator -=( int j )    
+{
+    while (j--)
+       (*this)--;
+    return *this;
+}
+template<class T>
+Cursor<T> 
+Cursor<T>::operator +=( int j )    
+{
+    while (j++)
+       (*this)++;
+    return *this;
+}
+
+template<class T>
+Cursor<T> 
+Cursor<T>::operator +( int i ) const    
+{
+    Cursor<T> r = *this;
+
+    if (i<0)
+       return r -(-i);
+
+    while (i--)
+       r++;
+
+    return r;
+}
+
+template<class T>
+Cursor<T>
+Cursor<T>::operator -( int i ) const
+{
+    Cursor<T> r = *this;
+    if (i<0)
+       return r +(-i);
+
+    while (i--)
+       r--;
+    
+    return r;
+}
+/*
+  warning:  can't use Cursor::operator == (Cursor),
+  since it uses Cursor::operator-(Cursor)
+ */
+template<class T>
+int
+Cursor<T>::operator-(Cursor<T> rhs) const
+{
+    assert(rhs.list == list);
+    int dif = 0;
+
+    // search from *this on further up (positive difference)
+    Cursor<T> c(*this);
+    while (c.ok() && c.pointer_ != rhs.pointer_) {
+       c--;
+       dif++;
+    }
+    
+    if (c.ok())
+       goto gotcha;            // so, sue me.
+
+    // search in direction of bottom. (negative diff)
+    dif =0;
+    c=*this;    
+    while (c.ok() && c.pointer_ !=rhs.pointer_) {
+       dif --;
+       c++;
+    }
+    assert(c.ok());
+
+gotcha:
+    assert((*this - dif).pointer_ == c.pointer_);
+    return dif;
+}
+
+#endif
diff --git a/flower/interval.cc b/flower/interval.cc
deleted file mode 100644 (file)
index 46b4fc7..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#include <assert.h> 
-#include <math.h>
-#include "interval.hh"
-#include "string.hh"
-
-
-
-template<class T>
-int
-Interval__compare(const Interval_t<T>&a,Interval_t<T> const&b)
-{
-    if (a.left == b.left && a.right == b.right)
-       return 0;
-    
-    if (a.left <= b.left && a.right >= b.right)
-       return 1;
-
-    if (a.left >= b.left && a.right <= b.right)
-       return -1;
-
-    assert(false);             // not comparable
-
-    return 0;
-}
-
-const Real INFTY = HUGE;
-
-template<class T>
-void
-Interval_t<T>::set_empty() {
-    left = INFTY;
-    right = -INFTY;
-}
-
-template<class T>
-T
-Interval_t<T>::length() const {
-    assert(right >= left);
-    return right-left;
-}
-
-template<class T>
-void
-Interval_t<T>::unite(Interval_t<T> h)
-{
-    if (h.left<left)
-       left = h.left;
-    if (h.right>right)
-       right = h.right;
-}
-
-/**
-  smallest Interval which includes *this and #h#
- */
-
-template<class T>
-void
-Interval_t<T>::intersect(Interval_t<T> h)
-{
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-    left = h.left >? left;
-    right = h.right <?right;
-#else
-    left = max(h.left, left);
-    right = min(h.right, right);
-#endif
-}
-
-template<class T>
-Interval_t<T>
-intersect(Interval_t<T> x, Interval_t<T> const &y)
-{
-    x.intersect(y);
-    return x;
-}
-
-template<class T>
-String
-Interval_t<T>::str() const
-{
-    if (empty())
-       return "[empty]";
-    String s("[");
-    return s + left + "," + right +"]";
-}
-
-template<class T>
-bool
-Interval_t<T>::elt_q(T r)
-{
-    return r >= left && r <= right;
-}
index 4184451701e72aa11ccf8a6ea015d7b64317ae76..294457db0f87af829f3afca887304602d8b469bf 100644 (file)
@@ -24,15 +24,25 @@ struct Interval_t {
        left += t;
        right += t;
     }
-    T operator[](int j) {
+    T& idx(int j) {
        if (j==-1)
            return left;
        else if (j==1)
            return right;
        else
            assert(false);
-       return 0;               
+       return left;            
     }
+    T& operator[](int j) {
+       return idx(j);
+    }
+    T operator[](int j) const {
+       return ((Interval_t<T> *)this)->idx(j);
+    }
+    T &max() { return right;}
+    T max()const { return right;}
+    T min()const{ return left; }
+    T &min(){ return left; }
     void unite(Interval_t<T> h);
     /**
       PRE
diff --git a/flower/interval.tcc b/flower/interval.tcc
new file mode 100644 (file)
index 0000000..46b4fc7
--- /dev/null
@@ -0,0 +1,93 @@
+#include <assert.h> 
+#include <math.h>
+#include "interval.hh"
+#include "string.hh"
+
+
+
+template<class T>
+int
+Interval__compare(const Interval_t<T>&a,Interval_t<T> const&b)
+{
+    if (a.left == b.left && a.right == b.right)
+       return 0;
+    
+    if (a.left <= b.left && a.right >= b.right)
+       return 1;
+
+    if (a.left >= b.left && a.right <= b.right)
+       return -1;
+
+    assert(false);             // not comparable
+
+    return 0;
+}
+
+const Real INFTY = HUGE;
+
+template<class T>
+void
+Interval_t<T>::set_empty() {
+    left = INFTY;
+    right = -INFTY;
+}
+
+template<class T>
+T
+Interval_t<T>::length() const {
+    assert(right >= left);
+    return right-left;
+}
+
+template<class T>
+void
+Interval_t<T>::unite(Interval_t<T> h)
+{
+    if (h.left<left)
+       left = h.left;
+    if (h.right>right)
+       right = h.right;
+}
+
+/**
+  smallest Interval which includes *this and #h#
+ */
+
+template<class T>
+void
+Interval_t<T>::intersect(Interval_t<T> h)
+{
+#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
+    left = h.left >? left;
+    right = h.right <?right;
+#else
+    left = max(h.left, left);
+    right = min(h.right, right);
+#endif
+}
+
+template<class T>
+Interval_t<T>
+intersect(Interval_t<T> x, Interval_t<T> const &y)
+{
+    x.intersect(y);
+    return x;
+}
+
+template<class T>
+String
+Interval_t<T>::str() const
+{
+    if (empty())
+       return "[empty]";
+    String s("[");
+    return s + left + "," + right +"]";
+}
+
+template<class T>
+bool
+Interval_t<T>::elt_q(T r)
+{
+    return r >= left && r <= right;
+}
diff --git a/flower/iterate.hh b/flower/iterate.hh
new file mode 100644 (file)
index 0000000..adff779
--- /dev/null
@@ -0,0 +1,6 @@
+
+#define iterator(set)          typeof((set).top())
+
+// should use top()
+#define iter_top(set,var)      iterator(set) var(set)
+
diff --git a/flower/list.cc b/flower/list.cc
deleted file mode 100644 (file)
index 55e1e20..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef LIST_CC
-#define LIST_CC
-
-#include "list.hh"
-
-template<class T>
-List<T>::List(List const&src)
-{
-    set_empty();
-    // probably el stupido
-    for (Cursor<T> c(src); c.ok(); c++)
-       bottom().add(c);
-}
-
-template<class T>
-void
-List<T>::OK() const
-{
-    int i = size_;
-    Link<T> *lp = top_;
-    while (i--) {
-       assert(lp);
-       lp->OK();
-       lp = lp->next();
-    }
-    assert(!lp);
-     i = size_;
-    lp = bottom_;
-    while (i--) {
-       assert(lp);
-       lp->OK();
-       lp = lp->previous();
-    }
-    assert(!lp);
-}
-
-
-template<class T>
-List<T>::~List()
-{
-    Cursor<T> next(*this);
-    for ( Cursor<T> c( *this ); c.ok(); c = next ) {
-       next = c;
-       next++;
-       remove( c );
-    }
-}
-
-template<class T>
-void
-List<T>::add( const T& thing, Cursor<T> &after_me )
-{
-    if (!size_) {              // not much choice if list is empty
-        bottom_ = top_ = new Link<T>( thing );
-       if (!after_me.ok())
-           after_me = bottom();
-    } else {                   // add at aprioprate place
-       if (!after_me.ok())
-           after_me = bottom();
-       Link<T> *p =after_me.pointer();
-       p->add(thing);
-       if (p == bottom_)       // adjust bottom_ if necessary.
-           bottom_ = p->next();
-    }
-
-    size_++;
-}
-/** 
-
-  Procedure:
-  \begin{itemize}
-  \item if #after_me# is #ok()#, add after #after_me#, else
-  \item if list !empty simply add to bottom, else
-  \item list is empty: create first \Ref{Link} and initialize 
-  #bottom_# and #top_#.
-  \end{itemize}
-*/
-
-template<class T>
-void
-List<T>::insert( const T& thing, Cursor<T> &before_me )
-{
-    if (!size_) {
-       bottom_ = top_ = new Link<T>( thing );
-       if (!before_me.ok())
-           before_me = top();
-       
-    } else {
-       if (!before_me.ok())
-           before_me = top();
-       
-       Link<T> *p = before_me.pointer() ;
-
-       p->insert(thing);
-       if (p == top_)
-           top_ = p->previous();
-    }
-
-    size_++;
-}
-
-
-template<class T>
-void
-List<T>::concatenate(List<T> const&s)
-{
-    Cursor<T> b(bottom());
-    for (Cursor<T> c(s); c.ok(); c++) {
-       b.add(c);
-       b++;
-    }
-}
-#endif
index 117e1862e4416720cf5ff5d810d08cc29d718f2a..f49b5d78500d1185a992d54135fe3afbab4633a1 100644 (file)
@@ -16,11 +16,13 @@ class List
     List();    
     virtual ~List();
        
-    Cursor<T> bottom();
-
     int size() const;
-    Cursor<T> top();
-    void OK() const; 
+
+    Cursor<T> bottom() const;  // const sucks..
+    Cursor<T> top() const;
+
+    void OK() const;           // check list
+    
  protected:
     friend class Cursor<T>;
     friend class Link<T>;
index c3ee7e2948263a62bdaeaf81f3e2654b0de39006..df0687b7c8b5b28e71cfd47ad96fbbd64b7caf8e 100644 (file)
@@ -39,7 +39,7 @@ List<T>::size() const
 
 template<class T>
 inline Cursor<T>
-List<T>::top()
+List<T>::top()const
 {
     return Cursor<T>( *this, top_ );
 }
@@ -47,7 +47,7 @@ List<T>::top()
 
 template<class T>
 inline Cursor<T>
-List<T>::bottom()
+List<T>::bottom()const
 {
     return Cursor<T>( *this, bottom_ );
 }
diff --git a/flower/list.tcc b/flower/list.tcc
new file mode 100644 (file)
index 0000000..55e1e20
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef LIST_CC
+#define LIST_CC
+
+#include "list.hh"
+
+template<class T>
+List<T>::List(List const&src)
+{
+    set_empty();
+    // probably el stupido
+    for (Cursor<T> c(src); c.ok(); c++)
+       bottom().add(c);
+}
+
+template<class T>
+void
+List<T>::OK() const
+{
+    int i = size_;
+    Link<T> *lp = top_;
+    while (i--) {
+       assert(lp);
+       lp->OK();
+       lp = lp->next();
+    }
+    assert(!lp);
+     i = size_;
+    lp = bottom_;
+    while (i--) {
+       assert(lp);
+       lp->OK();
+       lp = lp->previous();
+    }
+    assert(!lp);
+}
+
+
+template<class T>
+List<T>::~List()
+{
+    Cursor<T> next(*this);
+    for ( Cursor<T> c( *this ); c.ok(); c = next ) {
+       next = c;
+       next++;
+       remove( c );
+    }
+}
+
+template<class T>
+void
+List<T>::add( const T& thing, Cursor<T> &after_me )
+{
+    if (!size_) {              // not much choice if list is empty
+        bottom_ = top_ = new Link<T>( thing );
+       if (!after_me.ok())
+           after_me = bottom();
+    } else {                   // add at aprioprate place
+       if (!after_me.ok())
+           after_me = bottom();
+       Link<T> *p =after_me.pointer();
+       p->add(thing);
+       if (p == bottom_)       // adjust bottom_ if necessary.
+           bottom_ = p->next();
+    }
+
+    size_++;
+}
+/** 
+
+  Procedure:
+  \begin{itemize}
+  \item if #after_me# is #ok()#, add after #after_me#, else
+  \item if list !empty simply add to bottom, else
+  \item list is empty: create first \Ref{Link} and initialize 
+  #bottom_# and #top_#.
+  \end{itemize}
+*/
+
+template<class T>
+void
+List<T>::insert( const T& thing, Cursor<T> &before_me )
+{
+    if (!size_) {
+       bottom_ = top_ = new Link<T>( thing );
+       if (!before_me.ok())
+           before_me = top();
+       
+    } else {
+       if (!before_me.ok())
+           before_me = top();
+       
+       Link<T> *p = before_me.pointer() ;
+
+       p->insert(thing);
+       if (p == top_)
+           top_ = p->previous();
+    }
+
+    size_++;
+}
+
+
+template<class T>
+void
+List<T>::concatenate(List<T> const&s)
+{
+    Cursor<T> b(bottom());
+    for (Cursor<T> c(s); c.ok(); c++) {
+       b.add(c);
+       b++;
+    }
+}
+#endif
diff --git a/flower/plist.cc b/flower/plist.cc
deleted file mode 100644 (file)
index 2581d24..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "plist.hh"
-
-// not inlined since it assumes knowledge of destructor.
-template<class T>
-void
-IPointerList<T>::remove(PCursor<T> me )
-{
-    if ( me.ok() ) {
-       delete me.ptr();
-        List<void*>::remove(me); 
-    }
-}
-template<class T>
-PCursor<T> 
-PointerList<T>::find(T what ) const
-{
-    PCursor<T> i(*this);
-    for (; i.ok(); i++)
-       if (i.ptr() == what)
-          break;
-    return i;    
-}
index 99be3ff811a7d673f8c31b2be656261b1aeb1d51..bac9f7bf0227874df00147b76850ab97db1f5d43 100644 (file)
@@ -14,8 +14,12 @@ template<class T>
 class PointerList : public List<void *>
 {
  public:
-    PCursor<T> top() {  return PCursor<T> (List<void*>::top()); }
-    PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
+    PCursor<T> top() const{
+       return PCursor<T> (List<void*>::top());
+    }
+    PCursor<T> bottom() const {
+       return PCursor<T> (List<void*>::bottom());
+    }
     PCursor<T> find(T) const;
     void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
     PointerList() {}
diff --git a/flower/plist.tcc b/flower/plist.tcc
new file mode 100644 (file)
index 0000000..2581d24
--- /dev/null
@@ -0,0 +1,22 @@
+#include "plist.hh"
+
+// not inlined since it assumes knowledge of destructor.
+template<class T>
+void
+IPointerList<T>::remove(PCursor<T> me )
+{
+    if ( me.ok() ) {
+       delete me.ptr();
+        List<void*>::remove(me); 
+    }
+}
+template<class T>
+PCursor<T> 
+PointerList<T>::find(T what ) const
+{
+    PCursor<T> i(*this);
+    for (; i.ok(); i++)
+       if (i.ptr() == what)
+          break;
+    return i;    
+}
index 3830fd6825b4aab553cadf5b91f25ff5be457b6f..93726ec08aab055b1c59cac0c1bd97d564c97aad 100644 (file)
@@ -22,7 +22,7 @@ Full_storage::OK() const
        Real *r = els[maxh -1];
        if (maxw>0) {
            assert(r);
-           Real s = r[maxw -1];
+           Real s = r[maxw -1]; // accessing unitialised memory.
            s = sin(s);
        }
     }
diff --git a/flower/tsmat.cc b/flower/tsmat.cc
deleted file mode 100644 (file)
index 0e5407a..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#include "smat.hh"
-
-template<class T>
-void
-Full_storage<T>::operator=(Full_storage const &fs)
-{
-    resize(fs.h, fs.w);
-    for (int i=0; i<h; i++)
-       for (int j=0; i<w; j++)
-           els[i][j]= fs.els[i][j];
-}
-
-template<class T>
-void
-Full_storage<T>::OK() const
-{
-    assert(maxh >= h && maxw >= w);
-    assert(h >= 0 && w >= 0);
-}
-template<class T>
-void
-Full_storage<T>::resize_cols(int newh)
-{
-    if (newh <= maxh) {
-       h=newh;
-       return;
-    }
-   
-    T** newa=new T*[newh];
-    int j=0;
-    for (; j < h; j++)
-       newa[j] = els[j];
-    for (; j < newh; j++)
-       newa[j] = new T[w];
-    delete[] els;
-    els=newa;
-    maxh = newh;
-}
-
-template<class T>
-void
-Full_storage<T>::resize_rows(int neww)
-{
-    if (neww <= maxw) {
-       w=neww;
-       return;
-    }
-    for (int i=0; i < h ; i++) {
-       T* newa=new T[neww];
-       for (int k=0; k < w; k++)
-           newa[k] = els[i][k];
-
-       delete[] els[i];
-       els[i] = newa;
-       maxw = neww;
-    }
-}
-
-template<class T>
-Full_storage<T>::~Full_storage() {
-    for (int i=0; i < maxh; i++)
-       delete [] els[i];
-    delete[] els;
-}
-
-template<class T>
-void
-Full_storage<T>::resize(int i, int j)
-{
-    resize_cols(i);
-    resize_rows(j);
-}
-
-template<class T>
-void
-Full_storage<T>::set_size(int i, int j)
-{    
-    resize(i,j)
-}
-
-template<class T>
-bool
-Full_storage<T>::mult_ok(int i, int j) const
-{
-    return valid(i,j);
-}
-
-template<class T>
-bool
-Full_storage<T>::trans_ok(int i, int j) const
-{
-       return valid(i,j);
-} 
-
-
-template<class T>
-void
-Full_storage<T>::trans_next(int &i, int &j) const
-{
-    assert(trans_ok(i,j));
-    i++;
-    if (i >= h) {
-       i=0;
-       j ++;
-    }
-}
-
-template<class T>
-void
-Full_storage<T>::mult_next(int &i, int &j) const
-{
-    assert(mult_ok(i,j));
-    j++;
-    if (j >= w) {
-       j=0;
-       i++;
-    }
-}
-
-template<class T>
-void
-Full_storage<T>::delete_row(int k)
-{
-    assert(0 <= k <h);
-    for (int i=h-1; i > k ; i++)
-       for (int j=0; j < w; j++)
-           els[i-1][j]=els[i][j];
-}
-
-template<class T>
-void
-Full_storage<T>::insert_row(int k)
-{
-    assert(0 <= k <=h);
-    resize_cols(h+1);
-    for (int i=h-1; i > k ; i++)
-       for (int j=0; j <w; j++)
-           els[i][j]=els[i-1][j];
-}
-
-/****************************************************************/
-
-template<class T>
-virtual_smat<T> *
-virtual_smat<T>::get_full(int n, int m)
-{
-    return new Full_storage<T>(n,m);
-}
-#include "real.hh"
-
-template Full_storage<Real>;
diff --git a/flower/tsmat.tcc b/flower/tsmat.tcc
new file mode 100644 (file)
index 0000000..0e5407a
--- /dev/null
@@ -0,0 +1,151 @@
+#include "smat.hh"
+
+template<class T>
+void
+Full_storage<T>::operator=(Full_storage const &fs)
+{
+    resize(fs.h, fs.w);
+    for (int i=0; i<h; i++)
+       for (int j=0; i<w; j++)
+           els[i][j]= fs.els[i][j];
+}
+
+template<class T>
+void
+Full_storage<T>::OK() const
+{
+    assert(maxh >= h && maxw >= w);
+    assert(h >= 0 && w >= 0);
+}
+template<class T>
+void
+Full_storage<T>::resize_cols(int newh)
+{
+    if (newh <= maxh) {
+       h=newh;
+       return;
+    }
+   
+    T** newa=new T*[newh];
+    int j=0;
+    for (; j < h; j++)
+       newa[j] = els[j];
+    for (; j < newh; j++)
+       newa[j] = new T[w];
+    delete[] els;
+    els=newa;
+    maxh = newh;
+}
+
+template<class T>
+void
+Full_storage<T>::resize_rows(int neww)
+{
+    if (neww <= maxw) {
+       w=neww;
+       return;
+    }
+    for (int i=0; i < h ; i++) {
+       T* newa=new T[neww];
+       for (int k=0; k < w; k++)
+           newa[k] = els[i][k];
+
+       delete[] els[i];
+       els[i] = newa;
+       maxw = neww;
+    }
+}
+
+template<class T>
+Full_storage<T>::~Full_storage() {
+    for (int i=0; i < maxh; i++)
+       delete [] els[i];
+    delete[] els;
+}
+
+template<class T>
+void
+Full_storage<T>::resize(int i, int j)
+{
+    resize_cols(i);
+    resize_rows(j);
+}
+
+template<class T>
+void
+Full_storage<T>::set_size(int i, int j)
+{    
+    resize(i,j)
+}
+
+template<class T>
+bool
+Full_storage<T>::mult_ok(int i, int j) const
+{
+    return valid(i,j);
+}
+
+template<class T>
+bool
+Full_storage<T>::trans_ok(int i, int j) const
+{
+       return valid(i,j);
+} 
+
+
+template<class T>
+void
+Full_storage<T>::trans_next(int &i, int &j) const
+{
+    assert(trans_ok(i,j));
+    i++;
+    if (i >= h) {
+       i=0;
+       j ++;
+    }
+}
+
+template<class T>
+void
+Full_storage<T>::mult_next(int &i, int &j) const
+{
+    assert(mult_ok(i,j));
+    j++;
+    if (j >= w) {
+       j=0;
+       i++;
+    }
+}
+
+template<class T>
+void
+Full_storage<T>::delete_row(int k)
+{
+    assert(0 <= k <h);
+    for (int i=h-1; i > k ; i++)
+       for (int j=0; j < w; j++)
+           els[i-1][j]=els[i][j];
+}
+
+template<class T>
+void
+Full_storage<T>::insert_row(int k)
+{
+    assert(0 <= k <=h);
+    resize_cols(h+1);
+    for (int i=h-1; i > k ; i++)
+       for (int j=0; j <w; j++)
+           els[i][j]=els[i-1][j];
+}
+
+/****************************************************************/
+
+template<class T>
+virtual_smat<T> *
+virtual_smat<T>::get_full(int n, int m)
+{
+    return new Full_storage<T>(n,m);
+}
+#include "real.hh"
+
+template Full_storage<Real>;
index 81a8f4595c0004a0444842e0426c2dd120858418..29358a5d9d857b374f5d97c60595bffa72263241 100644 (file)
@@ -6,3 +6,6 @@ dist:
 
 TAGS: $(hdr) 
        etags -CT $(hdr) 
+
+clean:
+       rm -f parser.hh
\ No newline at end of file
index be2cb8f94c01e1d6e79a6a5f683b963258ce7e3a..60b5dedd710d6ad412a499f05706fb8136d63203 100644 (file)
@@ -22,7 +22,7 @@ struct Beam: public Spanner {
     
     virtual Interval width()const;    
 
-    Spanner *broken_at(const PCol *, const PCol *) const;
+    Spanner *broken_at(PCol *,  PCol *) const;
     Beam();
     void add(Stem*);
     void process();
index e2ece4a6fa6352fb2c173c626bb2cde2a4aaa944..26e47ffa1f244eb0b44ec0c987589be15a67632a 100644 (file)
@@ -16,7 +16,7 @@ enum Commandcode {
 struct Command {
     Commandcode code;
 
-    Real when;
+//    Real when;
     /// analogous to argv[]
     svec<Scalar> args;
 
@@ -28,7 +28,7 @@ struct Command {
     /****************/
     
     Command();
-    Command(Real w);
+//    Command(Real w);
     bool isbreak()const;
     void print() const;
 };
index eb6f624966fa117bb15f9febdbfe3d71aee06239..79e6bd407a2b9f5c85fc0e02743a305ae15f6aaa 100644 (file)
@@ -9,7 +9,7 @@
 #include "proto.hh"
 
 
-Command* get_meter_command( Real,int,int);
+Command* get_meter_command(int,int);
 
 
 
index a6e93bf840504c9c53f5692402727aeecff59411..21a4b4b70faabdd9311112ddb40f97ae503a83fa 100644 (file)
 #include "interval.hh"
 #include "vray.hh"
 
-struct Rhythmic_grouping {
-    Interval t;
 
+
+struct Rhythmic_grouping {    
+    svec<Real> divisions;
     svec<Rhythmic_grouping*> children;
+
     /****************/
-    
-    void split_half();
-    Real last();
-    Rhythmic_grouping* sub_grouping(Interval v);
-    void split_grouping(Rhythmic_grouping &initial_grouping);
-    void split_grouping(svec<Real> initial_grouping);
-    svec<Real> get_bounds();
-    Rhythmic_grouping(Interval);
-    Rhythmic_grouping(svec<Interval> notes,
-                     svec<Real> initial_grouping);
 
+    svec<Real> interior();
+    Rhythmic_grouping partial_grouping(Interval t);
+    Real length() const;
+    Interval time() const;
+    Rhythmic_grouping(Interval);
+    Rhythmic_grouping();
+    Rhythmic_grouping(svec<Real>);
+    Rhythmic_grouping(Rhythmic_grouping const&);
+    
+    void split(Rhythmic_grouping r);
+    void split(svec<Real>);
+    void intersect(Interval);
+    void split(int n);
     void print() const;
+    void OK() const;
     ~Rhythmic_grouping();
 };
-
-#endif // GROUPING_HH
+#endif
index 00fb79bccc1bf737f6036e4b05b83c28bd44fdaf..33741e926328feeb9f93abc4fb8c85584342585c 100644 (file)
@@ -55,13 +55,13 @@ struct PScore {
     void postprocess();
     
     /// search all pcols which are breakable.
-    svec<const PCol *> find_breaks() const;
+    svec< PCol *> find_breaks() const;
 
     /// add a line to the broken stuff. Positions given in #config#
-    void add_line(svec<const PCol *> curline, svec<Real> config);
+    void add_line(svec< PCol *> curline, svec<Real> config);
 
     /// helper: solve for the columns in #curline#.
-    svec<Real> solve_line(svec<const PCol *> curline) const;
+    svec<Real> solve_line(svec<PCol *> curline) const;
 
     void add(PStaff *);
     /// add item
@@ -83,7 +83,7 @@ struct PScore {
     */
 
     /// return argument as a cursor.
-    PCursor<PCol *> find_col(const PCol *)const;
+    PCursor<PCol *> find_col(PCol *)const;
 
     /// delete unused columns
     void clean_cols();
@@ -98,10 +98,10 @@ struct PScore {
     void print() const;
 
     /// does curline fit on the paper?
-    bool feasible(svec<const PCol *> curline) const;
+    bool feasible(svec<PCol *> curline) const;
 
     /// which is first (left, higher)
-    int compare_pcols(const PCol*, const PCol*)const;
+    int compare_pcols( PCol*, PCol*)const;
 };
 /** notes, signs, symbols in a score can be grouped in two ways:
     horizontally (staffwise), and vertically (columns). #PScore#
index e3997b5a3633d803d99225f54bd3871653d85e27..5734a7b4b458b4c396f242c661eac7f708686103 100644 (file)
@@ -13,7 +13,7 @@
 /// the columns of a score that form one line.
 struct
 Line_of_score {
-    PointerList<const PCol *> cols;
+    PointerList<PCol *> cols;
 
     // need to store height of each staff.
     IPointerList<Line_of_staff*> staffs;
@@ -21,7 +21,7 @@ Line_of_score {
 
     /****************/
     void process() ;
-    Line_of_score(svec<const PCol *> sv,  PScore *);
+    Line_of_score(svec<PCol *> sv,  PScore *);
 
     String TeXstring() const;
 
index a8db0337aa627497d3a43fd1e240159a2421035b..2631f8b983753f31bb36857403f326907398f51f 100644 (file)
@@ -8,6 +8,7 @@
 #define SIMPLEWALKER_HH
 
 #include "proto.hh"
+#include "grouping.hh"
 
 struct Simple_walker: Staff_walker {
     Stem *stem_;
@@ -22,8 +23,14 @@ struct Simple_walker: Staff_walker {
     bool processed_key;
     bool processed_clef;
     Clef clef_;
+    Rhythmic_grouping default_grouping;
+    Rhythmic_grouping current_grouping;
+    
     svec<Slur_req*> pending_slur_reqs;
     svec<Slur*>  pending_slurs;
+
+
+
     /****************/
 
     virtual void do_TYPESET_command(Command*);
index 43359399e80a458b4f1210312f974104ff825ead..10b588457174d17beb4bf0acfd68ecb94d641ac7 100644 (file)
@@ -25,7 +25,7 @@ struct Slur : Spanner {
     void add(Notehead*);
     void set_default_dir();
     Interval height() const;
-    Spanner* broken_at(const PCol*, const PCol*) const;
+    Spanner* broken_at( PCol*, PCol*) const;
     void process();
 private:
     void brew_molecule();
index 3940cebf603efef754a3996dd96348139625fb02..8a22985819440508ac983b84b6330274e00a60b6 100644 (file)
@@ -31,7 +31,7 @@ struct Spanner {
 
 
     /// clone a piece of  this spanner.
-    virtual Spanner *broken_at(const PCol *c1, const PCol *c2) const=0; 
+    virtual Spanner *broken_at( PCol *c1,  PCol *c2) const=0; 
     /**
  
     PRE
index b7cdef0f9b72585531874e56329f2b87c33b0230..7573595a373f468cad253c18b7d44c336535724e 100644 (file)
@@ -9,28 +9,38 @@
 #include "vray.hh"
 #include "plist.hh"
 
+
+struct Staff_commands_at : public IPointerList<Command*> {
+    Real when;
+
+    /****************/
+    
+    bool is_breakable();
+
+    Staff_commands_at(Real);
+    void set_breakable();
+    void add_command_to_break(Command pre, Command mid,Command post);
+    void print() const;
+    void OK() const;
+    void insert_between(Command victim, PCursor<Command*> firstc,
+                       PCursor<Command*> last);
+    void add(Command c);
+
+};
+
 /// the list of commands in Score
-struct Staff_commands : public IPointerList<Command*> {
-    void process_add(Command);
-    void add_seq(svec<Command>,bool);
+struct Staff_commands : public IPointerList<Staff_commands_at*>
+{
+    Staff_commands_at*find(Real);
+    void add(Command,Real);
     void clean(Real last);
-    void set_breakable(Real when);
-    bool is_breakable(Real w);
-    PCursor<Command*> last_insertion(Real w);
-    PCursor<Command*> first(Real w);
-    void add_command_to_break(Command pre, Command mid,Command post);
     void OK() const;
     void print() const;
     Real last() const;
-    void insert_between(Command victim, PCursor<Command*> firstc,
-                       PCursor<Command*> last);
 };
 /** the list of commands in Score. Put in a separate class, since it
   otherwise clutters the methods of Score.
 
-  This class serves two purposes: it stores the commands (via
-  parser_add()) in the yacc parser. at a later stage, some 'high
-  level' commands are converted (method: parse())  
   */
 
 #endif
index 8f8a688cd785d61dc3c726ee2c62f69e0b18004f..290e2e33da2163e9d97c744d80a8f9ad0b98c880 100755 (executable)
@@ -1,4 +1,10 @@
 #!/bin/sh
+
+case $# in
+0) echo make_patch old new name
+       exit 1;;
+esac
+
 old=$1
 new=$2
 nm=$3-
@@ -31,5 +37,5 @@ fi
 
 #(cd $nm$old; touch depend; make clean)
 #(cd $nm$new; touch depend; make clean)
-(cd $nm$new; diff -rP -c  ../$nm$old . > ../patch-$new)
+(cd $nm$new; diff -urP  ../$nm$old . > ../patch-$new)
 rm -rf $nm$old $nm$new
index 65374e807e6b34131451f80694187fcf71d946ae..a3cc55c1e4147f15ec00f7d3291c9752c5c7b075 100644 (file)
@@ -6,3 +6,6 @@ dist:
 
 TAGS: $(mycc)
        etags -CT $(mycc) 
+
+clean:
+       rm -f $(gencc)
\ No newline at end of file
index 3d43b4ed1dc6a1d42c09e9907d6174263914ee86..a2d58254af6bc57b13811bef0def138f814e35d5 100644 (file)
@@ -1,3 +1,4 @@
+#include "dimen.hh"
 #include "beam.hh"
 #include "misc.hh"
 #include "debug.hh"
@@ -141,7 +142,7 @@ Beam::process()
 
 // todo.
 Spanner *
-Beam::broken_at(const PCol *, const PCol *) const
+Beam::broken_at( PCol *, PCol *) const
 {
     return new Beam(*this);
 }
@@ -166,6 +167,7 @@ Beam::width() const
     return Interval( (*me->stems.top()) ->hpos(),
                     (*me->stems.bottom()) ->hpos() );
 }
+
 /*
   beams to go with one stem.
   */
@@ -177,6 +179,8 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)
     Real dy=paper()->internote()*2;
     Real stemdx = paper()->rule_thickness();
     Real sl = slope*paper()->internote();
+    paper()->lookup_->beam(sl, convert_dimen(20,"pt"));
+    slope = sl /paper()->internote();
     Molecule leftbeams;
     Molecule rightbeams;
 
@@ -227,10 +231,7 @@ Beam::brew_molecule()
 {
     assert(left->line == right->line);
     Real inter=paper()->internote();
-    Real sl = slope*inter;
-
     output = new Molecule;
-    slope = sl / inter;
     Real x0 = stems.top()->hpos();
     
     for (PCursor<Stem*> i(stems); i.ok(); i++) {
index 6cb1d3303b4a4d823aa4bb1c5278f8496b212080..ff86e848af358ce838b06121a02178b3a1bb664f 100644 (file)
@@ -10,7 +10,7 @@
 
 // construct an appropriate Spacing_problem and solve it. 
 svec<Real>
-PScore::solve_line(svec<const PCol *> curline) const
+PScore::solve_line(svec< PCol *> curline) const
 {
    Spacing_problem sp;
 
@@ -28,7 +28,7 @@ PScore::solve_line(svec<const PCol *> curline) const
 }
 
 bool
-PScore::feasible(svec<const PCol *> curline) const
+PScore::feasible(svec< PCol *> curline) const
 {
     Real l =0;
     for (int i=0; i < curline.sz(); i++)
@@ -49,14 +49,14 @@ PScore::problem_OK() const
 }
 
 struct Col_configuration {
-    svec<const PCol*> line;
+    svec< PCol*> line;
     svec<Real> config;
     Real energy;
 
     Col_configuration() {
        energy = INFTY;
     }
-    void add(const PCol*c) { line.add(c);}
+    void add( PCol*c) { line.add(c);}
     void setsol(svec<Real> sol) {
        config = sol;
        energy = config.last();
@@ -85,7 +85,7 @@ PScore::calc_breaking()
     problem_OK();
     PCursor<PCol *> curcol(cols);
            
-    svec<const PCol *> breakpoints(find_breaks());
+    svec<PCol *> breakpoints(find_breaks());
     assert(breakpoints.sz()>=2);
     for (int i=0 ; i < breakpoints.sz() -1; ) {
        Col_configuration minimum;
index 47ca885adecf9cd2fd64be3370bea884e1c1d371..9db9472113b986bdcfd5eea28135ff45eb381734 100644 (file)
@@ -37,20 +37,20 @@ Score::connect(PCol* c1, PCol *c2, Real d, Real h)
 void
 Score::calc_idealspacing()
 {
-#if 1
     PCursor<Score_column*> i(cols_);
 
     for (; i.ok(); i++) {
        assert(i->used());
        PCursor<Score_column*> j (i+1);
        if (i->musical) {
+           assert(j.ok());
            for (int n=0; n < i->durations.sz(); n++) {
                Real d = i->durations[n];
                Real dist = paper_->duration_to_dist(d);
                while (j->when < d + i->when)
                    j++;
                
-               assert(j->when == d+i->when);
+               assert( distance(j->when, d+i->when) < 1e-8);
 
                connect(i->pcol_, j->pcol_, dist);
                if (!j->musical && (j+1).ok() 
@@ -67,31 +67,13 @@ Score::calc_idealspacing()
            
            Real d = j->when - i->when;
            Real dist = (d) ? paper_->duration_to_dist(d) :
-               convert_dimen(2,"pt");
+               convert_dimen(2,"pt"); // todo
            
            connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
        }
            // !j.ok() might hold if we're at the last col.
        
     }
-#else
-    PCursor<Score_column*> sc(cols_);
-
-    for (; sc.ok(); sc++) {
-       if (sc->musical)
-           for (int i=0; i < sc->durations.sz(); i++) {
-               Real d = sc->durations[i];
-               Real dist = paper_->duration_to_dist(d);
-               PCol * c2 = find_col(sc->when + d,true)->pcol_;
-               connect(sc->pcol_, c2, dist);
-               c2 = find_col(sc->when + d,false)->pcol_;
-               connect(sc->pcol_, c2,  dist);
-           }
-       else if (sc->used()) {  // ignore empty columns
-           PCol * c2 = find_col(sc->when,true)->pcol_;
-           connect(sc->pcol_, c2, 0.0);
-       }
-#endif
 }
 
 
index 94d3bb94d2d59c42e3ff196a3dac9a19aa834875..98be691cd30a259db5ead74c515f1125ecb8b5c4 100644 (file)
@@ -11,14 +11,6 @@ Command::isbreak()const
 Command::Command()
 {
     code = NOP;
-    when = -1;
-    priority=0;
-}
-
-Command::Command(Real w)
-{
-    code = NOP;
-    when = w;
     priority=0;
 }
 
@@ -26,7 +18,7 @@ void
 Command::print() const
 {
 #ifndef NPRINT
-    mtor << "command at " << when << ", code " << code << " prio " << priority;
+    mtor << "Command " << "code " << code << " prio " << priority;
     if ( isbreak())
        mtor << "(break separator)";
     if (args.sz()) {
index 1ac2cc0bcb9af7deb4ddd34e0785692d3e8fc4df..b415e0b1cfb5d0a1cef5376a4bdeca5bb6acbb9b 100644 (file)
@@ -16,11 +16,11 @@ get_key_typeset_command(svec<Scalar>which)
 }
 
 Command *
-get_meter_command(Real w, int n, int m)
+get_meter_command(int n, int m)
 {
     Command*c = new Command;
     
-    c->when = w;
+//    c->when = w;
     c->code = TYPESET;
     c->args.add( "METER");
     c->args.add( n );
index e07de1254acf1e555c59d36ea469b5546521baf3..1d70808fc75fb67f097df923b16d2f83d12148d9 100644 (file)
-#include "grouping.hh"
 #include "debug.hh"
+#include "grouping.hh"
+#include "interval.hh"
 
-Interval
-vec_union(svec<Interval> notes)
+void
+Rhythmic_grouping::OK()const
 {
-    Interval u;
-    u.set_empty();
-    for (int i =0 ; i < notes.sz() ; i++) {
-       u.unite(notes[i]);
-    }
-    return u;
+     for (int i= 1; i < divisions.sz(); i++) {
+        Real dt = divisions[i] - divisions[i-1];
+        assert(dt>0);   
+     }
+     Interval u;
+     for (int i= 1; i < children.sz(); i++) {
+        children[i]->OK();
+        u.unite(children[i]->time());
+     }
+     
 }
 
-svec<Real>
-default_bounds(Interval t)
+Real
+Rhythmic_grouping::length() const
 {
-    svec<Real> bounds;
-    Real dt = t.length();
-    bounds.add(t.min);
-    bounds.add(t.min + dt/2);    
-    return bounds;
+    return divisions.last() - divisions[0];
 }
 
-svec<Real>
-Rhythmic_grouping::get_bounds()
+void
+Rhythmic_grouping::split(Rhythmic_grouping r)
 {
-    svec<Real> bounds;
-    if (children.sz()) {
-       for (int i=0; i < children.sz(); i++) {
-           bounds.add(children[i]->t.min);
-       }
-    } else {
-       default_bounds(t);
+    svec<Real> ir = r.interior();
+    split(ir);
+    
+    for (int i= 0; i < children.sz(); i++) {
+       Rhythmic_grouping here(r.partial_grouping(children[i]->time()));
+       if (here.divisions.sz() == 2)
+           here.split(2);
+       children[i]->split(here);
     }
-//     bounds.add(t.max );
-    return bounds;
 }
 
-Real
-Rhythmic_grouping::last()
+svec<Real>
+Rhythmic_grouping::interior()
 {
-    return t.max;
+    svec<Real> r(divisions);
+    r.del(0);
+    r.pop();
+    return r;
 }
 
 void
-Rhythmic_grouping::split_grouping(svec<Real> bounds)
+Rhythmic_grouping::split(int n)
 {
-    int lasti =0;
-    svec<Rhythmic_grouping*> newgrp;
-    for (int i=0, j = 1; i < children.sz() && j < bounds.sz(); ) {
-       if ( children[i]->t.max < bounds[j]) {
-           i ++;
-           continue;
-       } else if (children[i]->t.max > bounds[j]) {
-           j ++;
-           continue;
-       }
-
-        assert( children[lasti]->t.min == bounds[j-1] );
-       assert( children[i]->t.max == bounds[j] );
-
-       Rhythmic_grouping * n = new Rhythmic_grouping(Interval(
-           bounds[j-1], bounds[j]));
-       for (int k = lasti ; k < i; k++)
-           n->children.add(children[k]);
-       newgrp.add(n);
-
-       i = lasti = i+1;
-    }
-    if (newgrp.sz() <= 1) {
-       newgrp[0]->children.set_size(0);
-       delete newgrp[0];
-       return;
-    }
-    children = newgrp;    
+    assert(divisions.sz() == 2 && children.sz() == 0);
+    Real dt =(divisions.last()-divisions[0] )/n;
+    svec<Real> r;
+    for (int i= 0; i <= n; i++)
+       r.add(divisions[0] +dt *i);
+    divisions = r;
 }
 
 void
-Rhythmic_grouping::split_half()
+Rhythmic_grouping::intersect(Interval t)
 {
-    svec<Real> bounds = default_bounds(t);
-    bounds.add(t.max);
-    split_grouping(bounds);
+    svec<Real> r;
+    for  (int i=0; i < divisions.sz(); i++)
+       if (t.elt_q(divisions[i]))
+           r.add(divisions[i]);
+    if (r[0] > t.min )         // todo
+       r.insert( t.min,0);
+    if (r.last() < t.max)
+       r.add(t.max);
     
+    divisions = r;
+    svec<Rhythmic_grouping*> nc;
     for (int i=0; i < children.sz(); i++) {
-       if (children[i]->children.sz())
-           children[i]->split_half();
+       Interval inter = intersection(t, children[i]->time());
+       if (!inter.empty()) {
+           Rhythmic_grouping*p =new Rhythmic_grouping(*children[i]);
+           nc.add(p);
+           p->intersect(inter);
+       }
+       delete children[i];
     }
+    children = nc;
 }
 
-Rhythmic_grouping*
-Rhythmic_grouping::sub_grouping(Interval v)
+Rhythmic_grouping
+Rhythmic_grouping::partial_grouping(Interval t)
 {
-    return 0;                  // todo!
+    Rhythmic_grouping r(*this);
+    r.intersect(t);
+    return r;
 }
+
 void
-Rhythmic_grouping::split_grouping(Rhythmic_grouping &initial_grouping)
+Rhythmic_grouping::split(svec<Real> splitpoints)
 {
-    svec<Rhythmic_grouping*> newgrp;
-    svec<Real> bounds = initial_grouping.get_bounds();
-    bounds.add(initial_grouping.last());
-    split_grouping(bounds);
-    for (int i=0; i < children.sz(); i++) {
-       Interval h = children[i]->t;
-       Rhythmic_grouping*r = initial_grouping.sub_grouping(h);
-       if (children[i]->children.sz()) {
-           if (r)
-               children[i]->split_grouping(*r);
-           else
-               children[i]->split_half();
+    assert(!children.sz());
+    svec<Real> child;
+    int j = 0, i=0;
+    while (1) {
+       if  ( i >= divisions.sz() || j >= splitpoints.sz())
+           break;
+       
+       child.add(divisions[i]);
+       if (divisions[i] < splitpoints[j]) {
+           i++;
+       } else if (divisions[i] > splitpoints[j]) {
+           j ++;       
+       } else {
+           children.add(new Rhythmic_grouping(child));
+           child.set_size(1);
+           child[0] = divisions[i];
        }
     }
 }
 
-Rhythmic_grouping::Rhythmic_grouping(Interval i)
+Rhythmic_grouping::Rhythmic_grouping(svec<Real> d)
+    :divisions(d)
 {
-    t=i;
 }
-
-Rhythmic_grouping::Rhythmic_grouping(svec<Interval> notes,
-                               svec<Real> initial_grouping)
+Rhythmic_grouping::Rhythmic_grouping()
 {
-    t = vec_union(notes);
-    for (int i=0; i < notes.sz(); i++) {
-       children.add(new Rhythmic_grouping(notes[i]));
-    }
-    split_grouping(initial_grouping);
+}
+Interval
+Rhythmic_grouping::time()const
+{
+    return  Interval(divisions[0], divisions.last());
+}
+Rhythmic_grouping::Rhythmic_grouping(Interval h)
+{
+    divisions.add(h.min);
+    divisions.add(h.max);
 }
 
 Rhythmic_grouping::~Rhythmic_grouping()
 {
-    for (int i=0; i < children.sz(); i++) {
+    for (int i=0; i < children.sz(); i++)
        delete children[i];
-    }
 }
 
+
+Rhythmic_grouping::Rhythmic_grouping(Rhythmic_grouping const&s)
+{
+    divisions = s.divisions;    
+    for (int i=0; i < s.children.sz(); i++)
+       children.add(new Rhythmic_grouping(*s.children[i]));
+}
+    
 void
 Rhythmic_grouping::print()const    
 {
-    mtor << "{ " << t << "\n";
+#ifndef NPRINT
+    mtor << "{ ";
+    for (int i=0; i < divisions.sz(); i++) {
+       mtor << divisions[i] << ',';
+    }
     for (int i=0; i < children.sz(); i++) {
        children[i]->print();
     }
     mtor << "}";
+#endif
 }
 
 
index c7f7aaff5632c5c1e58e880c1a165ba0fd9d8685..3a27b3801f93c337e04d5e1bd47348e50d73c83d 100644 (file)
@@ -13,7 +13,7 @@ void
 Commands_at::print() const
 {
 #ifndef NPRINT
-    mtor << "{ at "<<when<<'\n'; 
+    mtor << "Commands_at { at "<<when<<'\n'; 
     mtor << "meter " << whole_per_measure
         << " pos "<< bars << ":" << whole_in_measure <<'\n';
     for (PCursor<Input_command *> cc(*this); cc.ok(); cc++) 
@@ -47,7 +47,7 @@ Commands_at::Commands_at(Real dt, Commands_at* prev)
 }
 
 void
-Commands_at::add(Input_command *i )
+Commands_at::add(Input_command *i)
 {
     bottom().add(i);           
     if (i->args[0] == "METER") { // should check for other meterchanges here.
@@ -81,7 +81,6 @@ Commands_at::setpartial(Real p)
 }
 Real
 Commands_at::barleft()
 {
     return  whole_per_measure-whole_in_measure;
 }
@@ -180,19 +179,19 @@ Input_commands::parse() const
     Staff_commands*nc = new Staff_commands;
 
     {   /* all pieces should start with a breakable. */
-       Command c(0.0);
+       Command c;//(0.0);
        c.code = INTERPRET;
        c.args.add("BAR");
        c.args.add("empty");
-       nc->process_add(c);
+       nc->add(c,0.0);
     }
 
     for (PCursor<Commands_at*> i(*this); i.ok(); i++)
        for (PCursor<Input_command *> cc(**i); cc.ok(); cc++) {
            if (cc->args.sz() &&  cc->args[0] !="") {
                Command c = **cc;
-               c.when = i->when;
-               nc->process_add(c);
+//             c.when = i->when;
+               nc->add(c, i->when);
            }
        }
     
index 4a8ea949d6c9a3c392e267f25639221f9b220886..ba71539d301f35b5861fe00c9afa63ccddc959a2 100644 (file)
@@ -36,7 +36,9 @@ Interval
 Item::width() const
 {
     Interval i =output->extent().x ;
-    return i+=offset_.x;
+    if (!i.empty())            // float exception on DEC Alpha
+        i+=offset_.x;
+    return i;
 }
 
 Interval
index 71f1654f19fad49ea16ca5c0c27d76459018db7a..26ad1745e3ada7a5b2842c9a44184584b311a8d3 100644 (file)
@@ -11,7 +11,6 @@ Keyitem::Keyitem(int c)
     c_position = c;
 }
 
-
 void
 Keyitem::read(svec<int> s)
 {
@@ -30,7 +29,8 @@ Keyitem::add(int p, int a)
 }
 
 void
-Keyitem::preprocess() {
+Keyitem::preprocess()
+{
     brew_molecole();
 }
 
index fbab62449bba2758d41c90f238c3bf062eb49350..e403c2dcc034e96764eadfa85b93724d88d359c0 100644 (file)
@@ -130,6 +130,7 @@ Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const
 {
     quad.fill(0);
     lin.fill(0);
+    c = 0;
     for (int j=0; j < ideals.sz(); j++){
        Idealspacing const*i=ideals[j];
        int l = col_id(i->left);
@@ -176,7 +177,6 @@ Spacing_problem::solve() const
     OK();
     assert(check_feasible());
 
-    
     /* optimalisatiefunctie */        
     Mixed_qp lp(cols.sz());
     make_matrices(lp.quad,lp.lin, lp.const_term);
index a0b9ed9b2f2440dc803e2858f04670f773d86faa..bc38c27e1489538a63b9d5db495dd315dbe5b31d 100644 (file)
@@ -447,8 +447,8 @@ int_list:
        /* */           {
                $$ = new svec<int>;
        }
-       | int           {
-               $$->add($1);
+       | int_list int          {
+               $$->add($2);
        }
        ;
 
index 2fab154829017478e75252ca6ec77aa70b43d979..951be6fa5f612e38f109962f1f066674bf015b03 100644 (file)
@@ -19,7 +19,7 @@ PCol::rank() const
 {
     if(!pscore_)
        return -1;
-    PCursor<PCol*> me=pscore_->find_col(this);
+    PCursor<PCol*> me=pscore_->find_col( (PCol*)this);
     if (!me.ok())
        return -1;
     PCursor<PCol*> bot(pscore_->cols.top());
@@ -51,7 +51,7 @@ PCol::print() const
 int
 PCol::compare(const PCol &c1, const PCol &c2)
 {
-    return c1.pscore_->compare_pcols(&c1,&c2);
+    return c1.pscore_->compare_pcols((PCol*)&c1,(PCol*)&c2);
 }
 
 void
index fcd03ca55a18a0163f19e58f00b3e2f190bd6623..a34d86b0ba6ebe6118f00a8dd2f67fee3c398838 100644 (file)
@@ -77,7 +77,7 @@ PScore::typeset_spanner(Spanner*sp, PStaff*ps)
 
 
 void
-PScore::add_line(svec<const PCol *> curline, svec<Real> config)
+PScore::add_line(svec< PCol *> curline, svec<Real> config)
 {    
     Line_of_score *p = new Line_of_score(curline,this);
     lines.bottom().add(p);     
@@ -105,7 +105,7 @@ PScore::get_spacing(PCol*l, PCol*r)
 
 
 int
-PScore::compare_pcols(const PCol*a, const PCol*b)const
+PScore::compare_pcols(PCol*a,  PCol*b)const
 {
     PCursor<PCol*> ac(find_col(a));
     PCursor<PCol*> bc(find_col(b));
@@ -116,10 +116,10 @@ PScore::compare_pcols(const PCol*a, const PCol*b)const
 /*
   return all breakable columns
  */
-svec<const PCol *>
+svec< PCol *>
 PScore::find_breaks() const
 {
-    svec<const PCol *> retval;
+    svec< PCol *> retval;
     for (PCursor<PCol *> c(cols); c.ok(); c++)
        if (c->breakable())
            retval.add(c);
@@ -217,7 +217,7 @@ PScore::postprocess()
 }
 
 PCursor<PCol *>
-PScore::find_col(const PCol *c)const
+PScore::find_col(PCol *c)const
 {
     PCol*what = (PCol*)c;
     if (what->daddy )
index 3dd8e4227e036810b539c717d699c3a83ce3fa1d..460bd864231b27646bbab9d76cb29ef1ae857f92 100644 (file)
@@ -25,7 +25,8 @@ Ineq_constrained_qp::add_inequality_cons(Vector c, double r)
 
 Ineq_constrained_qp::Ineq_constrained_qp(int novars):
     quad(novars),
-    lin(novars)
+    lin(novars),
+    const_term (0.0)
 {
 }
 
@@ -45,13 +46,6 @@ Ineq_constrained_qp::eval (Vector v)
 {
     return v * quad * v + lin * v + const_term;
 }
-/*
-    eliminate appropriate variables, until we have a Ineq_constrained_qp
-    then solve that.
-
-    PRE
-    cons should be ascending
-    */
 Vector
 Mixed_qp::solve(Vector start) const 
 {
@@ -94,32 +88,59 @@ Ineq_constrained_qp::eliminate_var(int idx, Real value)
 
 
 
-
-Mixed_qp::Mixed_qp(int n)
-    : Ineq_constrained_qp(n)
-{
-}
-
 void
-Mixed_qp::OK() const
+Ineq_constrained_qp::assert_solution(Vector sol) const
 {
-#ifndef NDEBUG
-    Ineq_constrained_qp::OK();
-    assert(eq_consrhs.sz() == eq_cons.sz());
-#endif    
+    svec<int> binding;
+    for (int i=0; i < cons.sz(); i++) {
+       Real R=cons[i] * sol- consrhs[i];
+       assert(R> -EPS);
+       if (R < EPS)
+           binding.add(i);
+    }
+    // KKT check...
+    // todo
 }
+
 void
 Ineq_constrained_qp::print() const
 {
 #ifndef NPRINT
     mtor << "Quad " << quad;
-    mtor << "lin " << lin <<"\n";
+    mtor << "lin " << lin <<"\n"
+       << "const " << const_term<<"\n";
     for (int i=0; i < cons.sz(); i++) {
        mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
        mtor << "\n";
     }
 #endif
 }
+
+/****************/
+
+/*
+    eliminate appropriate variables, until we have a Ineq_constrained_qp
+    then solve that.
+
+    PRE
+    cons should be ascending
+    */
+
+
+Mixed_qp::Mixed_qp(int n)
+    : Ineq_constrained_qp(n)
+{
+}
+
+void
+Mixed_qp::OK() const
+{
+#ifndef NDEBUG
+    Ineq_constrained_qp::OK();
+    assert(eq_consrhs.sz() == eq_cons.sz());
+#endif    
+}
+
 void
 Mixed_qp::print() const
 {
@@ -131,17 +152,3 @@ Mixed_qp::print() const
 #endif
 }
 
-
-void
-Ineq_constrained_qp::assert_solution(Vector sol) const
-{
-    svec<int> binding;
-    for (int i=0; i < cons.sz(); i++) {
-       Real R=cons[i] * sol- consrhs[i];
-       assert(R> -EPS);
-       if (R < EPS)
-           binding.add(i);
-    }
-    // KKT check...
-    // todo
-}
index 4c584c4ea727b3e6cc2bb4100a94e61737463992..5a65809c5ac73255bd00c89119f647ce760728f0 100644 (file)
@@ -24,8 +24,9 @@ Score::process()
 
     // do this after processing, staffs first have to generate PCols.
     do_pcols();
-    // ugh. Would want to clean the columns before anything else.
-    clean_cols();
+
+    clean_cols();    // can't move this farther up.
+
     calc_idealspacing();
 
     // debugging
index bd21c32bbabdb3819b6ec393780a61d29e6cbd89..788efd5dabc97bcc0d56fae8800bd87cc6de8517 100644 (file)
@@ -22,7 +22,7 @@ Line_of_score::TeXstring() const
 }
 
 
-Line_of_score::Line_of_score(svec<const PCol *> sv,
+Line_of_score::Line_of_score(svec<PCol *> sv,
                             PScore *ps)
 {
     pscore_ = ps;
index f275cd272e9b275f39964f10b02f95f25b18dc1e..fcf2558aac4cccf06b098655d319576b0ea75c09 100644 (file)
 #include "slur.hh"
 #include "localkeyitem.hh"
 
+Rhythmic_grouping
+parse_grouping(svec<Scalar> a)
+{
+    Rhythmic_grouping ret;
+    Real one_beat =a[0];
+    a.del(0);
+    svec<int> r;
+    for (int i= 0 ; i < a.sz(); i++)
+       r.add(a[i]);
+    Real here =0.0;
+    for (int i=0; i < r.sz(); i++) {
+       ret.divisions.add(here);
+       Real last = here;
+       here += one_beat * r[i];
+       Rhythmic_grouping *child =new Rhythmic_grouping(Interval(last, here));
+       child->split(r[i]);
+       ret.children.add(child);        
+    }
+    ret.divisions.add(here);
+}
+
 void
 Simple_walker::do_INTERPRET_command(Command*com)
 {
-    if (com->args[0] == "BAR") {
+    svec<Scalar> args(com->args);
+    args.del(0);
+    if (com->args[0] == "GROUPING") {  
+       default_grouping = parse_grouping(args);
+    }else if (com->args[0] == "BAR") {
        local_key_.reset(key_);
+       current_grouping = default_grouping;
     } else if (com->args[0] == "KEY") {
-       svec<Scalar>s(com->args);
-       s.del(0);
-       if (com->when) {
+       
+       if (col()->when()) {
            assert(!oldkey_undo);
-           oldkey_undo = new svec<int>( key_.oldkey_undo(s));
+           oldkey_undo = new svec<int>( key_.oldkey_undo(args));
        }
        
-       typesetkey = key_.read(s);
+       typesetkey = key_.read(args);
        local_key_.reset(key_); 
     } else if (com->args[0] == "CLEF") {
-       svec<Scalar>s(com->args);
-       s.del(0);
-       clef_.read(s);
+       clef_.read(args);
     } else {
        WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n';
     }
index 5d9eb0de44ba6fc95718b54aab88f76d76fa0026..f795dc82847a037200f1e30ddbea44528f1a89f7 100644 (file)
@@ -52,7 +52,7 @@ Slur::preprocess()
 }
 
 Spanner*
-Slur::broken_at(const PCol*l, const PCol*r) const
+Slur::broken_at(PCol*l, PCol*r) const
 {
     assert(l->line == r->line);
     Slur*ret = new Slur(*this);
index cbe0e59bbb77130da3d916c76c82ce6776488d78..f3d6a063bea159b868c0473dd2535582cff20aa2 100644 (file)
@@ -98,9 +98,10 @@ Staff::setup_staffcols()
        }       
     }
 
-    for (PCursor<Command*> cc(*staff_commands_); cc.ok(); cc++) {
+    for (PCursor<Staff_commands_at*> cc(*staff_commands_); cc.ok(); cc++) {
        Staff_column *sc=get_col(cc->when,false);
-       sc->s_commands.add(cc);
+       for (PCursor<Command*> i(**cc); i.ok(); i++)
+           sc->s_commands.add(i);
     }
 }
 
index 96647b1de62bef0076e1c087fc33e1781f016269..2837de161cbc28b00a279cfd3c3791d9307657af 100644 (file)
 #include "debug.hh"
 #include "parseconstruct.hh"
 
-/*
-  ARG!
-  */
-
-/*
-  maybe it's time for a "narrowing" cursor?
-  */
-PCursor<Command*>
-Staff_commands::first(Real w)
+void
+Staff_commands_at::print() const
 {
-    PCursor<Command*> pc(*this);    
-    while (pc.ok() && pc->when < w)
-       pc++;
-    if (!pc.ok() || pc->when != w) {
-       Command *c = new Command(w);
-       c->priority = 10000;
-       if (!pc.ok())
-           pc.add(c);
-       else
-           pc.insert(c);
-    }
-
-    return pc;
+#ifndef NPRINT
+    PCursor<Command*> i (*this);
+    mtor << "Commands at: " << when<<"\n";
+    
+    for (; i.ok(); i++)
+       i->print();
+#endif
 }
-/*
-  RETURN: pc->when == w && pc.ok
- */
-
-PCursor<Command*>
-Staff_commands::last_insertion(Real w)
-{    
-    PCursor<Command*> pc(first(w)), next(pc);    
-    while (next.ok() && next->when == w) {
-       pc=next;
-       next++;
-    }
-    if (pc->priority != -10000) {
-       Command*c = new Command(w);
-       c->priority = -10000;
-       pc.add(c);
-       pc++;
-    }
-        
-    return pc;
+void
+Staff_commands_at::OK()const
+{
+    PCursor<Command*> i (*this);
+    for (; i.ok() && (i+1).ok(); i++)
+       if (!i->isbreak() && !(i+1)->isbreak())
+           assert(i->priority >= (i+1)->priority);
 }
 
-/*
- */
-void
-Staff_commands::add_seq(svec<Command> com, bool checkbreak)
+Staff_commands_at::Staff_commands_at(Real r)
 {
-    if (!com.sz())
-       return;
-    
-    Real when = com[0].when;
+    when = r;
+}
 
-    PCursor<Command*> begin(first(when));
-    PCursor<Command*> end(last_insertion(when));
-    if (checkbreak && is_breakable(when)) {
-       if (com[0].priority < 0)
-           while (begin->code != BREAK_END)
-               begin++;
-       else
-           while (end->code != BREAK_PRE)
-               end--;
-    }
-    for (int i = 0; i < com.sz(); i++) {
-       insert_between(com[i], begin, end);
+bool
+Staff_commands_at::is_breakable()
+{
+    PCursor<Command*> i(*this);
+    for (; i.ok(); i++) {
+       if (i->isbreak())
+           return true;
     }
+    return false;
 }
 
 void
-Staff_commands::set_breakable(Real when)
+Staff_commands_at::set_breakable()
 {
-    bool found_typeset(false);
-    PCursor<Command*> cc = first(when);
-    for (; cc.ok() && cc->when == when; cc++) {
-       if (cc->isbreak())
-           return;
-       if (cc->code == TYPESET)
-           found_typeset=true;
-    }
-
-    assert(!found_typeset);
+    assert(!is_breakable());
     
-    svec<Command> seq;
-    Command k(when);
-    k.priority = 5;
+    Command k;
     k.code = BREAK_PRE;
-    seq.add(k);
-    k.priority = 4;
+    bottom().add(new Command(k));
     k.code = BREAK_MIDDLE;
-    seq.add(k);
-    k.priority = 3;
+    bottom().add(new Command(k));
     k.code = BREAK_POST;
-    seq.add(k);
-    k.priority = 2;
+    bottom().add(new Command(k));
     k.code = BREAK_END;
-    seq.add(k);
-
-    add_seq(seq,false);
-}
-
-bool
-Staff_commands::is_breakable(Real w)
-{
-    PCursor<Command*> cc = first(w);
-    for (; cc.ok() && cc->when == w; cc++) {
-       if (cc->isbreak())
-           return true;
-    }
-    return false;
+    bottom().add(new Command(k));        
 }
 
 void
-Staff_commands::insert_between(Command victim, PCursor<Command*> firstc,
-                              PCursor<Command*> last)
+Staff_commands_at::insert_between(Command victim, PCursor<Command*> firstc,
+                                 PCursor<Command*> last)
 {
     PCursor<Command*> c(firstc+1);
-    assert(last->when==firstc->when&&firstc < last&&last.ok());
+    assert(firstc < last&&last.ok());
     
     while (c < last) { 
        if (c->priority <= victim.priority) {
@@ -134,11 +72,10 @@ Staff_commands::insert_between(Command victim, PCursor<Command*> firstc,
 }
 
 void
-Staff_commands::add_command_to_break(Command pre, Command mid, Command post)
+Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post)
 {
-    Real w = pre.when;
-    assert(w >= 0);
-    PCursor<Command*> c ( first(w)), f(c), l(c);
+    assert(is_breakable());
+    PCursor<Command*> c ( *this), f(c), l(c);
 
     while (!c->isbreak())
        c++;
@@ -157,96 +94,91 @@ Staff_commands::add_command_to_break(Command pre, Command mid, Command post)
     while (!c->isbreak())
        c++;
     l = c++;
-    assert(l.ok() && l->when ==w && l->code == BREAK_END);
+    assert(l.ok() && l->code == BREAK_END);
     
     insert_between(post, f, l);
 }
-
+  
 void
-Staff_commands::process_add(Command c)
+Staff_commands_at::add(Command c)
 {
     bool encapsulate =false;
-    Real w = c.when;
-    assert(w >= 0);
-
-    Command pre(w);
-    Command mid(w);
-    Command post(w);
+    Command pre;
+    Command mid;
+    Command post;
 
     if (c.code == INTERPRET)
     {                          // UGH
        if (c.args[0] == "BAR") {
-           Command typeset(w); // kut met peren
+           Command typeset;    // kut met peren
            typeset.code = TYPESET;
            typeset.args = c.args;
            typeset.priority = 100;
-           process_add(typeset);
+           add(typeset);
        } else if (c.args[0] == "KEY") {
-           Command typeset(w);
+           Command typeset;
            typeset.code = TYPESET;
            typeset.args.add("KEY");
            typeset.priority = 70;
-           process_add(typeset);
+           add(typeset);
        } else if (c.args[0] == "CLEF") {
-           Command typeset(w);
+           Command typeset;
            typeset.code = TYPESET;
            typeset.args=c.args;
            typeset.priority = 90;
-           process_add(typeset);
+           add(typeset);
        } else if (c.args[0] == "METER") {
-           Command typeset(w);
+           Command typeset;
            typeset.code = TYPESET;
            typeset.args=c.args;
            typeset.priority = 40;
-           process_add(typeset);
+           add(typeset);
            return;
        }
     }
 
     // kut en peer
     if (c.code == TYPESET) {
+       encapsulate  = is_breakable();
        if (c.args[0] == "BAR") {
-           set_breakable(w);
-           encapsulate  = true;
+           set_breakable();
+           encapsulate = true;
            mid = c;
            pre = c;
            { /* every line a currentkey. */
-               Command kc(w);
+               Command kc;
                kc.code =TYPESET;
                kc.args.add( "CURRENTKEY");
                kc.priority = 60;
-               process_add(kc);
+               add(kc);
            }
            { /* every line a currentclef. */
-               Command kc(w);
+               Command kc;
                kc.code =TYPESET;
                kc.args.add( "CURRENTCLEF");
                kc.priority = 80;
-               process_add(kc);
+               add(kc);
            }
-       }else
-       if (c.args[0] == "METER" && is_breakable(w)) {
-           encapsulate = true;
+       }else if (c.args[0] == "METER" && is_breakable()) {
            mid = c;
            pre = c;
            post =c;
        }else
-       if( c.args[0] == "KEY" && is_breakable(c.when)) {
-           encapsulate = true;
+       if( c.args[0] == "KEY" && is_breakable()) {
+
            mid = c;
            pre = c;
            post = c;
-       }else
-       if (c.args[0] == "CURRENTKEY" && is_breakable(w)) {
+       }else if (c.args[0] == "CURRENTKEY" && is_breakable() ){
            post = c;
-           encapsulate = true;
+
        }else
-       if (c.args[0] == "CURRENTCLEF" && is_breakable(w)) {
+       if (c.args[0] == "CURRENTCLEF" && is_breakable() ){
            post = c;
-           encapsulate = true;
+
        }else
-       if (c.args[0] == "CLEF" && is_breakable(w)) {
-           encapsulate = true;
+       if (c.args[0] == "CLEF" && is_breakable()) {
+
            post = c;
            pre = c;
            mid = c;                   
@@ -254,65 +186,77 @@ Staff_commands::process_add(Command c)
     }
     
     if (encapsulate)
-       add_command_to_break(pre, mid, post);    
+       add_command_to_break(pre, mid, post);
     else {
-       svec<Command> seq;
-       seq.add(c);    
-       add_seq(seq,true);
+       bottom().add(new Command(c));
     }
 }
 
-/*
-    first and last column should be breakable.
-    Remove any command past the last musical column.
-    */
+
+/****************************************************************/
+
 void
-Staff_commands::clean(Real l)
+Staff_commands::OK() const
 {
-    assert(l>0);
-    if (!is_breakable(0.0)) {
-       Command c(0.0);
-       c.code = TYPESET;
-       c.args.add("BAR");
-       c.args.add("empty");
-       process_add(c);
+#ifndef NDEBUG
+    for (PCursor<Staff_commands_at*> i(*this); i.ok() && (i+1).ok(); i++) {
+       assert(i->when <= (i+1)->when);
+       i->OK();
+
     }
-    
-    PCursor<Command*> bot(bottom());
+#endif
+}
 
-    while (bot.ok() && bot->when > l) {
-       mtor <<"removing ";
-       bot->print();
-       bot.del();
-       bot = bottom();
+void
+Staff_commands::print() const
+{
+#ifndef NPRINT
+    for (PCursor<Staff_commands_at*> i(*this); i.ok() ; i++) {
+       i->print();
     }
+#endif
+}
 
-    if (!is_breakable(l)) {
-       Command c(l);
-       c.code = TYPESET;
-       c.args.add("BAR");
-       c.args.add("||");
-       process_add(c);
+Staff_commands_at*
+Staff_commands::find(Real w)
+{
+    PCursor<Staff_commands_at*> i(bottom());
+    for (; i.ok() ; i--) {
+       if (i->when == w)
+           return i;
+       if (i->when < w)
+           break;
+    }
+    Staff_commands_at*p =new Staff_commands_at(w);
+    if (!i.ok()) 
+       i.insert(p);
+    else {
+       i.add(p);
+       i++;
     }
-    OK();
+    return i;
 }
 
 void
-Staff_commands::OK() const
+Staff_commands::add(Command c, Real when)
 {
-    for (PCursor<Command*> cc(*this); cc.ok() && (cc+1).ok(); cc++) {
-       assert(cc->when <= (cc+1)->when);
-       if (cc->when == (cc+1)->when && !cc->isbreak() && !(cc+1)->isbreak())
-           assert(cc->priority >= (cc+1)->priority);
-    }
+    Staff_commands_at* p = find(when);
+    p->add(c);
 }
 
 void
-Staff_commands::print() const
+Staff_commands::clean(Real l)
 {
-#ifndef NPRINT
-    for (PCursor<Command*> cc(*this); cc.ok() ; cc++) {
-       cc->print();
+    PCursor<Staff_commands_at*> i(bottom());
+    for (; i->when > l ; i=bottom()) {
+       remove(i);
+    }
+    Staff_commands_at*p = find(l);
+    
+    if (!p->is_breakable()) {
+       p->set_breakable();
+/*     Command b;
+       b.code = INTERPRET;
+       b.args.add("BAR");*/
     }
-#endif
 }
index a51c669e1f515cb15180383664a47ec161d440cb..9fd5b1d5bf518c3af953039a2f9f229d8a8f4b16 100644 (file)
@@ -64,13 +64,13 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
     pstaff_=st;
 
     
-    const PCol *linestart = sc->cols.top();
-    const PCol *linestop = sc->cols.bottom();
+    PCol *linestart = sc->cols.top();
+    PCol *linestop = sc->cols.bottom();
 
     
     for (PCursor<const Spanner*> sp(pstaff_->spans); sp.ok(); sp++) {
-       const PCol *brokenstart = &MAX(*linestart, *sp->left);
-       const PCol *brokenstop = &MIN(*linestop, *sp->right);
+       PCol *brokenstart = &MAX(*linestart, *sp->left);
+       PCol *brokenstop = &MIN(*linestop, *sp->right);
        if ( *brokenstart < *brokenstop) {
            line_of_score_->pscore_-> // higghl
                add_broken(sp->broken_at(brokenstart,brokenstop));
index be32eeceff2bcba66f393bf9b47efe1304b8956b..3e06cfdb231171b5faa3b9285d84d3174fb3fe44 100644 (file)
@@ -16,3 +16,4 @@ IPL_instantiate(Command);
 IPL_instantiate(Input_command);
 IPL_instantiate(Commands_at);
 IPL_instantiate(Input_staff);
+IPL_instantiate(Input_music);
index 21226c079dcdb0d3499d60038bba26d606aa7da0..d0dd12453dbd3375d7ba98821ddca56e0f3a247b 100644 (file)
@@ -213,4 +213,4 @@ english_names = notenames {
 }
 
 default_table = symboltables { table_sixteen }
-notenames { dutch_names }
\ No newline at end of file
+notenames { dutch_names }