From: fred Date: Sat, 5 Oct 1996 15:04:27 +0000 (+0000) Subject: lilypond-0.0.1 X-Git-Tag: release/1.5.59~7156 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2b62687781e3549146ace3e50cc27aa405385046;p=lilypond.git lilypond-0.0.1 --- diff --git a/cols.cc b/cols.cc new file mode 100644 index 0000000000..e2a13f35f3 --- /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 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 index 0000000000..e51e2d56c0 --- /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 its; + List 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 index 0000000000..75da46a4a5 --- /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 cols; + + /// the idealspacings, no particular order + PointerList suz; + + /// the staffs ordered top to bottom + PointerList staffs; + + /// all symbols in score. No particular order. + PointerList its; + + /// if broken, the different lines + PointerList lines; + + /// crescs etc; no particular order + PointerList 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 find_breaks() const; + + /// add a line to the broken stuff. Positions given in #config# + void add_line(svec curline, svec config); + + /// helper: solve for the columns in #curline#. + svec solve_line(svec 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 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