lilypond-0.0.1
[lilypond.git] / line.cc
blob9311aeb22d726cc819e1976b03c0f8990d27b18f
1 #include "line.hh"
2 #include "cols.hh"
3 #include "pscore.hh"
5 String
6 Line_of_staff::TeXstring() const
8 String s("%line_of_staff\n\\vbox to ");
9 s += String(height * VERT_TO_PT) +"pt{";
11 //make some room
12 s += vstrut(base* VERT_TO_PT);
14 // the staff itself: eg lines, accolades
15 s += "\\hbox{";
17 s+=(*pstaff_->stafsym)(scor->score->linewidth);
18 PCursor<const PCol *> cc(scor->cols);
19 Real lastpos=cc->hpos;
21 // all items in the current line & staff.
22 for (; cc.ok(); cc++) {
23 Real delta=cc->hpos - lastpos;
24 lastpos = cc->hpos;
26 // moveover
27 s +=String( "\\kern ") + HOR_TO_PT*delta + "pt ";
29 // now output the items.
31 for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
32 if (ic->pstaff_ == pstaff_)
33 s += ic->TeXstring();
35 // spanners.
36 for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
37 if (sc->pstaff_ == pstaff_)
38 s += sc->TeXstring();
41 s+="\\hss}}";
42 return s;
45 String
46 Line_of_score::TeXstring() const
48 String s("\\vbox{");
49 for (PCursor<Line_of_staff*> sc(staffs); sc.ok(); sc++)
50 s += sc->TeXstring();
51 s += "}";
52 return s;
55 /// testing this entry
56 Line_of_score::Line_of_score(svec<const PCol *> sv,
57 const PScore *ps)
59 score = ps;
60 for (int i=0; i< sv.sz(); i++) {
61 PCol *p=(PCol *) sv[i];
62 cols.bottom().add(p);
63 p->line=this;
66 for (PCursor<PStaff*> sc(score->staffs); sc.ok(); sc++)
67 staffs.bottom().add(new Line_of_staff(this, sc));
69 /** construct a line with the named columns. Make the line field
70 in each column point to this
72 #sv# isn't really const!!
75 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
77 // [don't know how to calc dimensions yet.]
78 height = 0.0;
79 base =0.0;
81 scor=sc;
82 pstaff_=st;
84 const PCol *linestart= sc->cols.top();
85 const PCol *linestop=sc->cols.bottom();
87 for (PCursor<const Spanner*> sp(pstaff_->spans); sp.ok(); sp++) {
88 const PCol *brokenstart = &MAX(*linestart, *sp->left);
89 const PCol *brokenstop = &MIN(*linestop, *sp->right);
91 if (*brokenstop < *brokenstart)
92 brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart));