From 5be2624595a1c43b6cba4b717a6dd99745678d36 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 22 Oct 1996 19:45:35 +0000 Subject: [PATCH] lilypond-0.0.4 --- item.cc | 5 ++- line.cc | 17 ++++++--- linespace.hh | 9 ++--- pcol.cc | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ pscore.hh | 9 +++-- template1.cc | 18 ++++----- 6 files changed, 138 insertions(+), 26 deletions(-) create mode 100644 pcol.cc diff --git a/item.cc b/item.cc index 72f447be94..453200627b 100644 --- a/item.cc +++ b/item.cc @@ -1,13 +1,14 @@ #include "line.hh" #include "symbol.hh" -#include "cols.hh" +#include "molecule.hh" +#include "pcol.hh" String Spanner::TeXstring() const { assert(right->line); Real w = left->hpos - right->hpos; - return (*strets)(w); + return strets->eval(w).tex; } Spanner * diff --git a/line.cc b/line.cc index d0a5d794bb..ebe9595d3b 100644 --- a/line.cc +++ b/line.cc @@ -1,21 +1,23 @@ #include "line.hh" +#include "dimen.hh" #include "symbol.hh" -#include "cols.hh" +#include "pcol.hh" #include "pscore.hh" String Line_of_staff::TeXstring() const { String s("%line_of_staff\n\\vbox to "); - s += String(maxheight() * VERT_TO_PT) +"pt{"; + s += print_dimen(maxheight() ) +"{"; //make some room - s += vstrut(base* VERT_TO_PT); + s += vstrut(base); // the staff itself: eg lines, accolades s += "\\hbox{"; { - s+=(*pstaff_->stafsym)(scor->score->linewidth); + Symbol sym = pstaff_->get_stafsym(scor->score->linewidth); + s+=sym.tex; PCursor cc(scor->cols); Real lastpos=cc->hpos; @@ -25,7 +27,7 @@ Line_of_staff::TeXstring() const lastpos = cc->hpos; // moveover - s +=String( "\\kern ") + HOR_TO_PT*delta + "pt "; + s +=String( "\\kern ") + print_dimen(delta); // now output the items. @@ -102,7 +104,10 @@ Real Line_of_staff::maxheight() const { Interval y; - y = pstaff_->stafsym->height(scor->score->linewidth); + { + Symbol s = pstaff_->stafsym->eval(scor->score->linewidth); + y = s.dim.y; + } PCursor cc(scor->cols); // all items in the current line & staff. diff --git a/linespace.hh b/linespace.hh index 5a3c4edeb8..e5b23ca7f0 100644 --- a/linespace.hh +++ b/linespace.hh @@ -4,7 +4,7 @@ #include "glob.hh" #include "list.hh" #include "vray.hh" -#include "cols.hh" +#include "pcol.hh" #include "matrix.hh" /// helper struct for #Spacing_problem# @@ -12,10 +12,7 @@ struct Colinfo { const PCol *col; bool fixed; Real fixpos; - Colinfo() { - fixed=false; - col=0; - } + Colinfo(); void print() const; Real minright()const { return col->width().max; } Real minleft()const { return -col->width().min; } @@ -42,7 +39,7 @@ class Spacing_problem { void make_matrices(Matrix &quad, Vector &lin,Real&) const; /// generate the LP constraints - void make_constraints(Optimisation_problem& lp) const; + void make_constraints(Mixed_qp& lp) const; public: /// solve the spacing problem diff --git a/pcol.cc b/pcol.cc new file mode 100644 index 0000000000..44c82a938d --- /dev/null +++ b/pcol.cc @@ -0,0 +1,106 @@ +#include "pcol.hh" +#include "pstaff.hh" +#include "debug.hh" + +void +Idealspacing::print() const +{ + #ifndef NPRINT + mtor << "idealspacing {" ; + mtor << "distance "<= 0 && left && right); +#endif +} + +/****************************************************************/ + +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; +} + +void +PCol::print() const +{ + #ifndef NPRINT + mtor << "PCol {"; + mtor << "# symbols: " << its.size() ; + mtor << "breakable: " << breakable<<"\n"; + mtor << "extent: " << width().min << ", " << width().max << "\n"; + mtor << "}\n"; + #endif +} + +int +PCol::compare(const PCol &, const PCol &) +{ + assert(false); + return 0 ; +} + +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() +{ + if (prebreak) + delete prebreak; // no recursion! + if (postbreak) + delete postbreak; +} + +void +PCol::add(const Item *i) +{ + its.bottom().add(i); + used = true; +} + diff --git a/pscore.hh b/pscore.hh index 75da46a4a5..5ae4c37951 100644 --- a/pscore.hh +++ b/pscore.hh @@ -5,7 +5,7 @@ #include "vray.hh" -#include "cols.hh" +#include "pcol.hh" #include "pstaff.hh" /// all stuff which goes onto paper @@ -32,6 +32,8 @@ struct PScore { PointerList spanners; /****************************************************************/ + + svec select_items(PStaff*, PCol*); void calc_breaking(); /** @@ -69,9 +71,10 @@ struct PScore { PCursor find_col(PCol *); void clean_cols(); - void problem_OK() ; - + void problem_OK()const ; + void OK()const ; PScore(); + void print() const; }; /** notes, signs, symbols in a score can be grouped in two ways: horizontally (staffwise), and vertically (columns). #PScore# diff --git a/template1.cc b/template1.cc index 908de8d4e1..b7c453b6e0 100644 --- a/template1.cc +++ b/template1.cc @@ -1,20 +1,20 @@ #include "line.hh" #include "list.hh" -#include "cols.hh" +#include "pcol.hh" #include "item.hh" #include "request.hh" #include "command.hh" #include "list.cc" #include "cursor.cc" +#define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a) - -PL_instantiate(Line_of_score); -PL_instantiate(Line_of_staff); -PL_instantiate(Item); -PL_instantiate(Spanner); -PL_instantiate(PStaff); -PL_instantiate(Idealspacing); -PL_instantiate(PCol); +PLC_instantiate(Line_of_score); +PLC_instantiate(Line_of_staff); +PLC_instantiate(Item); +PLC_instantiate(Spanner); +PLC_instantiate(PStaff); +PLC_instantiate(Idealspacing); +PLC_instantiate(PCol); -- 2.39.5