lilypond-0.0.4
[lilypond.git] / pscore.cc
blob16156d1321eb9f8c30f4bd2a67907bd4c332bbae
1 // utility functions for PScore
2 #include "debug.hh"
3 #include "line.hh"
4 #include "pscore.hh"
5 #include "tstream.hh"
7 void
8 PScore::clean_cols()
10 for (PCursor<PCol *> c(cols); c.ok(); )
11 if (!c->used) {
12 c.del();
13 mtor << "removing pcol\n";
14 } else
15 c++;
19 void
20 PScore::add(PStaff *s)
22 staffs.bottom().add(s);
25 void
26 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
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);
40 void
41 PScore::add_line(svec<const PCol *> curline, svec<Real> config)
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];
51 Idealspacing*
52 PScore::get_spacing(PCol*l, PCol*r)
54 assert(l!=r);
55 for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
56 if (ic->left == l && ic->right == r){
57 return ic;
61 Idealspacing*ip =new Idealspacing(l,r);
62 suz.bottom().add(ip);
63 // l->used = r->used = true;
64 return ip;
67 svec<const PCol *>
68 PScore::find_breaks() const
70 svec<const PCol *> retval;
71 for (PCursor<PCol *> c(cols); c.ok(); c++)
72 if (c->breakable)
73 retval.add(c);
75 return retval;
78 void
79 PScore::add(PCol *p)
81 cols.bottom().add(p);
84 todo: config of width
86 PScore::PScore()
88 linewidth = 15; // in cm for now
91 void
92 PScore::output(Tex_stream &ts)
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";