lilypond-0.0.3
[lilypond.git] / pscore.cc
blobdd8ae697bc84d94859dddfedf271a0ade405c91c
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(); c++)
11 if (!c->used) {
12 c.remove();
13 //mtor << "removing pcol\n";
18 void
19 PScore::add(PStaff *s)
21 staffs.bottom().add(s);
24 void
25 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
27 assert(c && i && s);
28 if (breakstat == 1 ) {
29 typeset_item(i, c->prebreak, s, 0);
30 } if (breakstat == 3)
31 typeset_item(i, c->prebreak, s, 0 );
32 else{
33 its.bottom().add(i);
34 s->add(i);
35 c->add(i);
39 void
40 PScore::add_line(svec<const PCol *> curline, svec<Real> config)
42 Line_of_score *p = new Line_of_score(curline,this);
43 lines.bottom().add(p);
44 for (int i=0; i < curline.sz(); i++){
45 PCol *c=(PCol *)curline[i]; // so, this isn't really const.
46 c->hpos= config[i];
50 Idealspacing*
51 PScore::get_spacing(PCol*l, PCol*r)
53 assert(l!=r);
54 for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
55 if (ic->left == l && ic->right == r){
56 return ic;
60 Idealspacing*ip =new Idealspacing(l,r);
61 suz.bottom().add(ip);
62 // l->used = r->used = true;
63 return ip;
66 svec<const PCol *>
67 PScore::find_breaks() const
69 svec<const PCol *> retval;
70 for (PCursor<PCol *> c(cols); c.ok(); c++)
71 if (c->breakable)
72 retval.add(c);
74 return retval;
77 void
78 PScore::add(PCol *p)
80 cols.bottom().add(p);
83 todo: config of width
85 PScore::PScore()
87 linewidth = 15; // in cm for now
90 void
91 PScore::output(Tex_stream &ts)
93 int l=1;
94 ts << "% linewidth " << linewidth * HOR_TO_PT << " pt\n";
95 for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
96 ts << "% line of score no. " << l++ <<"\n";
97 ts << lic->TeXstring();