]> git.donarmstrong.com Git - lilypond.git/blob - line.cc
release: 0.0.1
[lilypond.git] / line.cc
1 #include "line.hh"
2 #include "cols.hh"
3 #include "pscore.hh"
4
5 String
6 Line_of_staff::TeXstring() const
7 {
8     String s("%line_of_staff\n\\vbox to ");
9     s += String(height * VERT_TO_PT) +"pt{";
10
11     //make some room
12     s += vstrut(base* VERT_TO_PT);
13
14     // the staff itself: eg lines, accolades
15     s += "\\hbox{";
16     {
17         s+=(*pstaff_->stafsym)(scor->score->linewidth);
18         PCursor<const PCol *> cc(scor->cols);
19         Real lastpos=cc->hpos;
20
21         // all items in the current line & staff.
22         for (; cc.ok(); cc++) {
23             Real delta=cc->hpos - lastpos;
24             lastpos = cc->hpos;
25
26             // moveover
27             s +=String( "\\kern ") + HOR_TO_PT*delta + "pt ";
28
29             // now output the items.
30
31             for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
32                 if (ic->pstaff_ == pstaff_)
33                     s += ic->TeXstring();
34             }
35             // spanners.
36             for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
37                 if (sc->pstaff_ == pstaff_)
38                     s += sc->TeXstring();
39         }
40     }
41     s+="\\hss}}";
42     return s;
43 }
44
45 String
46 Line_of_score::TeXstring() const
47 {
48      String s("\\vbox{");
49      for (PCursor<Line_of_staff*> sc(staffs); sc.ok(); sc++)
50          s += sc->TeXstring();
51      s += "}";
52      return s;
53 }
54
55 /// testing this entry
56 Line_of_score::Line_of_score(svec<const PCol *> sv,
57                              const PScore *ps)
58 {
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;
64     }
65
66     for (PCursor<PStaff*> sc(score->staffs); sc.ok(); sc++)
67         staffs.bottom().add(new Line_of_staff(this, sc));    
68 }
69 /** construct a line with the named columns. Make the line field
70     in each column point to this
71     
72     #sv# isn't really const!!
73     */
74
75 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
76 {
77     // [don't know how to calc dimensions yet.]
78    height = 0.0;
79    base =0.0;
80  
81     scor=sc;
82     pstaff_=st;
83
84     const    PCol *linestart= sc->cols.top();
85     const PCol *linestop=sc->cols.bottom();
86     
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);
90
91         if (*brokenstop  < *brokenstart)
92             brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart));
93     }
94 }