From 0664383554c9918aafd1e56139c17aab307ee63b Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 8 Oct 1996 09:43:05 +0000 Subject: [PATCH] lilypond-0.0.1 --- line.cc | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 line.cc diff --git a/line.cc b/line.cc new file mode 100644 index 0000000000..9311aeb22d --- /dev/null +++ b/line.cc @@ -0,0 +1,94 @@ +#include "line.hh" +#include "cols.hh" +#include "pscore.hh" + +String +Line_of_staff::TeXstring() const +{ + String s("%line_of_staff\n\\vbox to "); + s += String(height * VERT_TO_PT) +"pt{"; + + //make some room + s += vstrut(base* VERT_TO_PT); + + // the staff itself: eg lines, accolades + s += "\\hbox{"; + { + s+=(*pstaff_->stafsym)(scor->score->linewidth); + PCursor cc(scor->cols); + Real lastpos=cc->hpos; + + // all items in the current line & staff. + for (; cc.ok(); cc++) { + Real delta=cc->hpos - lastpos; + lastpos = cc->hpos; + + // moveover + s +=String( "\\kern ") + HOR_TO_PT*delta + "pt "; + + // now output the items. + + for (PCursor ic(cc->its); ic.ok(); ic++) { + if (ic->pstaff_ == pstaff_) + s += ic->TeXstring(); + } + // spanners. + for (PCursor sc(cc->starters); sc.ok(); sc++) + if (sc->pstaff_ == pstaff_) + s += sc->TeXstring(); + } + } + s+="\\hss}}"; + return s; +} + +String +Line_of_score::TeXstring() const +{ + String s("\\vbox{"); + for (PCursor sc(staffs); sc.ok(); sc++) + s += sc->TeXstring(); + s += "}"; + return s; +} + +/// testing this entry +Line_of_score::Line_of_score(svec sv, + const PScore *ps) +{ + score = ps; + for (int i=0; i< sv.sz(); i++) { + PCol *p=(PCol *) sv[i]; + cols.bottom().add(p); + p->line=this; + } + + for (PCursor sc(score->staffs); sc.ok(); sc++) + staffs.bottom().add(new Line_of_staff(this, sc)); +} +/** construct a line with the named columns. Make the line field + in each column point to this + + #sv# isn't really const!! + */ + +Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) +{ + // [don't know how to calc dimensions yet.] + height = 0.0; + base =0.0; + + scor=sc; + pstaff_=st; + + const PCol *linestart= sc->cols.top(); + const PCol *linestop=sc->cols.bottom(); + + for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { + const PCol *brokenstart = &MAX(*linestart, *sp->left); + const PCol *brokenstop = &MIN(*linestop, *sp->right); + + if (*brokenstop < *brokenstart) + brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart)); + } +} -- 2.39.5