]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.1
authorfred <fred>
Sat, 5 Oct 1996 15:04:27 +0000 (15:04 +0000)
committerfred <fred>
Sat, 5 Oct 1996 15:04:27 +0000 (15:04 +0000)
cols.cc [new file with mode: 0644]
cols.hh [new file with mode: 0644]
pscore.hh [new file with mode: 0644]

diff --git a/cols.cc b/cols.cc
new file mode 100644 (file)
index 0000000..e2a13f3
--- /dev/null
+++ b/cols.cc
@@ -0,0 +1,77 @@
+#include "cols.hh"
+#include "pstaff.hh"
+
+Idealspacing::Idealspacing(const PCol * l,const PCol * r)
+{
+    space = 0.0;
+    hooke = 0.0;
+    left = l;
+    right = r;
+}
+void
+Idealspacing::OK() const
+{
+    assert(hooke >= 0 && left  && right);
+}
+
+Interval
+PCol::width() const
+{
+    Interval w;
+
+    for (PCursor<const Item *> ic(its); ic.ok(); ic++)
+       w.unite(ic->width());
+    if (w.empty())
+       w.unite(Interval(0,0));
+    return w;
+}
+/****************************************************************/
+
+int
+PCol::compare(const PCol &c1, const PCol &c2)
+{
+    assert(false);
+}
+
+void
+PCol::OK () const
+{
+    if (prebreak || postbreak ) {
+       assert(breakable);
+    }
+}
+
+void
+PCol::set_breakable()
+{
+    if (breakable)
+       return;
+
+    prebreak = new PCol(this);
+    postbreak = new PCol(this);
+    breakable = true;
+    used = true;
+}
+
+PCol::PCol(PCol *parent) {
+    daddy = parent;
+    prebreak=0;
+    postbreak=0;
+    breakable=false;
+    line=0;
+    used  = false;
+}
+
+PCol::~PCol()
+{
+    delete prebreak;
+    delete postbreak;  
+}
+
+void
+PCol::add(const Item *i)
+{
+    its.bottom().add(i);
+    used = true;
+}
+
diff --git a/cols.hh b/cols.hh
new file mode 100644 (file)
index 0000000..e51e2d5
--- /dev/null
+++ b/cols.hh
@@ -0,0 +1,96 @@
+#ifndef COLS_HH
+#define COLS_HH
+
+#include "glob.hh"
+#include "boxes.hh"
+#include "list.hh"
+#include "item.hh"
+
+/// stuff grouped vertically.
+struct PCol {
+    List<const Item*> its;
+    List<const Spanner*> stoppers, starters;
+    
+    /// Can this be broken? true eg. for bars. 
+    bool breakable;
+
+    /// does this column have items, does it have spacings attached?
+    bool used;
+
+    /// prebreak is put before end of line.
+    PCol *prebreak;
+    /**
+    if broken here, then (*this) column is discarded, and prebreak
+    is put at end of line, owned by Col
+    */
+
+    /// postbreak at beginning of the new line
+    PCol *postbreak;
+    /**  \See{prebreak}
+    */
+    PCol *daddy;
+    /*
+    if this column is pre or postbreak, then this field points to the parent.
+    */
+    /// if lines are broken then this column is in #line#
+    const Line_of_score *line;
+
+    /// if lines are broken then this column x-coord #hpos#
+    Real hpos;
+
+
+    /****************************************************************/
+
+    void add(const Item*i);
+
+    Interval width() const;
+    ~PCol();
+    PCol(PCol * parent);
+    /// initialize the prebreak and postbreak fields
+    setup_breaks();
+    
+    /// which col comes first?
+    static int compare(const PCol &c1, const PCol &c2);
+    /**
+    signed compare on columns.
+
+    return < 0 if c1 < c2.
+    */
+
+    void OK() const;
+    void set_breakable();
+
+};
+/**
+    This is a class to address items vertically. It contains the data for:
+    \begin{itemize}
+    \item
+    unbroken score
+    \item
+    broken score
+    \item
+    the linespacing problem
+    \end{itemize}
+  */
+
+#include "compare.hh"
+instantiate_compare(const PCol &, PCol::compare);
+     
+
+/// ideal spacing between two columns
+struct Idealspacing {
+
+    /// the ideal distance
+    Real space;
+
+    /// Hooke's constant: how strong are the "springs" attached to columns
+    Real hooke;
+
+    /// the two columns
+    const PCol *left, *right;
+
+    void OK() const ;
+    Idealspacing(const PCol *left,const PCol *right);
+};
+
+#endif
diff --git a/pscore.hh b/pscore.hh
new file mode 100644 (file)
index 0000000..75da46a
--- /dev/null
+++ b/pscore.hh
@@ -0,0 +1,80 @@
+// the breaking problem for a score.
+
+#ifndef PSCORE_HH
+#define PSCORE_HH
+
+
+#include "vray.hh"
+#include "cols.hh"
+#include "pstaff.hh"
+
+/// all stuff which goes onto paper
+struct PScore {
+    /// width of paper
+    Real linewidth;
+    
+    /// the columns, ordered left to right
+    PointerList<PCol *> cols;
+
+    /// the idealspacings, no particular order
+    PointerList<Idealspacing*> suz;
+
+    /// the staffs ordered top to bottom
+    PointerList<PStaff*> staffs;
+
+    /// all symbols in score. No particular order.
+    PointerList<Item*> its;
+
+    /// if broken, the different lines
+    PointerList<Line_of_score*> lines;
+
+    /// crescs etc; no particular order
+    PointerList<Spanner *> spanners;
+
+    /****************************************************************/
+    
+    void calc_breaking();
+    /**
+      calculate where the lines are to be broken.
+
+      POST
+    
+      lines contain the broken lines.
+     */
+
+    /// search all pcols which are breakable.
+    svec<const 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);
+
+    /// helper: solve for the columns in #curline#.
+    svec<Real> solve_line(svec<const PCol *> curline) const;
+
+    void add(PStaff *);
+    /// add item
+    void typeset_item(Item *,  PCol *,PStaff*,int);
+    ///    add to bottom of pcols
+    void add(PCol*);
+    /**
+
+    */
+    void output(Tex_stream &ts);
+
+    Idealspacing* get_spacing(PCol *, PCol *);
+    /*
+    get the spacing between c1 and c2, create one if necessary.
+    */
+
+
+    PCursor<PCol *> find_col(PCol *);
+    void clean_cols();
+    void problem_OK() ;
+
+    PScore();
+};
+/** notes, signs, symbols in a score can be grouped in two ways:
+    horizontally (staffwise), and vertically (columns). #PScore#
+    contains the items, the columns and the staffs.
+ */
+#endif