]> git.donarmstrong.com Git - lilypond.git/blob - pscore.cc
release: 0.0.3
[lilypond.git] / pscore.cc
1 // utility functions for PScore
2 #include "debug.hh"
3 #include "line.hh"
4 #include "pscore.hh"
5 #include "tstream.hh"
6
7 void
8 PScore::clean_cols()
9 {
10     for (PCursor<PCol *> c(cols); c.ok(); )
11         if (!c->used) {
12             c.del();
13             mtor << "removing pcol\n";
14         } else
15             c++;
16 }
17
18
19 void
20 PScore::add(PStaff *s)
21 {
22     staffs.bottom().add(s);    
23 }
24
25 void
26 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
27 {
28     assert(c && i && s);
29     if (breakstat == 1 ) {
30         typeset_item(i, c->prebreak, s, 0);
31     } if (breakstat == 3) 
32         typeset_item(i, c->prebreak, s, 0 );
33     else{
34         its.bottom().add(i);
35         s->add(i);
36         c->add(i);
37     }
38 }
39
40 void
41 PScore::add_line(svec<const PCol *> curline, svec<Real> config)
42 {    
43     Line_of_score *p = new Line_of_score(curline,this);
44     lines.bottom().add(p);      
45     for (int i=0; i < curline.sz(); i++){
46         PCol *c=(PCol *)curline[i]; // so, this isn't really const.
47         c->hpos= config[i];
48     }
49 }
50
51 Idealspacing*
52 PScore::get_spacing(PCol*l, PCol*r)
53 {
54     assert(l!=r);
55     for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
56         if (ic->left == l && ic->right == r){
57             return ic;
58         }
59     }
60     
61     Idealspacing*ip =new Idealspacing(l,r);
62     suz.bottom().add(ip);
63     //    l->used = r->used = true;
64     return ip;
65 }
66
67 svec<const PCol *>
68 PScore::find_breaks() const
69 {
70     svec<const PCol *> retval;
71     for (PCursor<PCol *> c(cols); c.ok(); c++)
72         if (c->breakable)
73             retval.add(c);
74             
75     return retval;
76 }
77
78 void
79 PScore::add(PCol *p)
80 {
81     cols.bottom().add(p);
82 }
83 /*
84     todo: config of width
85     */
86 PScore::PScore()
87 {
88     linewidth = 15;             // in cm for now
89 }
90
91 void
92 PScore::output(Tex_stream &ts)
93 {
94     int l=1;
95     ts << "% linewidth " << linewidth * HOR_TO_PT << " pt\n";
96     for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
97         ts << "% line of score no. " << l++ <<"\n";
98         ts << lic->TeXstring();
99         if ((lic+1).ok())
100             ts << "\\interscoreline\n";
101     }   
102 }