1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
// utility functions for PScore
#include "debug.hh"
#include "paper.hh"
#include "molecule.hh"
#include "dimen.hh"
#include "line.hh"
#include "pscore.hh"
#include "tstream.hh"
void
PScore::clean_cols()
{
for (PCursor<PCol *> c(cols); c.ok(); )
if (!c->used) {
c.del();
} else
c++;
}
void
PScore::add(PStaff *s)
{
staffs.bottom().add(s);
}
void
PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
{
assert(c && i && s);
// assert(!breakstat != 4 || c->breakable() );
if (breakstat == 0) {
typeset_item(i, c->prebreak, s);
return;
}
if (breakstat == 2) {
typeset_item(i, c->postbreak, s);
return;
}
if (c->daddy && c == c->daddy->prebreak) { // makeshift.
Interval iv (i->width());
if (!iv.empty()) {
svec<Item*> col_its (select_items(s, c));
for (int j =0; j < col_its.sz(); j++)
col_its[j]->output->translate(Offset(-iv.length(),0));
i->output->translate (Offset(-iv.max, 0));
}
}
its.bottom().add(i);
s->add(i);
c->add(i);
i->preprocess();
}
void
PScore::add_line(svec<const PCol *> curline, svec<Real> config)
{
Line_of_score *p = new Line_of_score(curline,this);
lines.bottom().add(p);
for (int i=0; i < curline.sz(); i++){
PCol *c=(PCol *)curline[i]; // so, this isn't really const.
c->hpos= config[i];
}
}
Idealspacing*
PScore::get_spacing(PCol*l, PCol*r)
{
assert(l!=r);
for (PCursor<Idealspacing*> ic (suz); ic.ok(); ic++) {
if (ic->left == l && ic->right == r){
return ic;
}
}
Idealspacing*ip =new Idealspacing(l,r);
suz.bottom().add(ip);
return ip;
}
svec<const PCol *>
PScore::find_breaks() const
{
svec<const PCol *> retval;
for (PCursor<PCol *> c(cols); c.ok(); c++)
if (c->breakable())
retval.add(c);
return retval;
}
void
PScore::add(PCol *p)
{
cols.bottom().add(p);
}
PScore::PScore( Paperdef*p)
{
paper_ = p;
}
void
PScore::output(Tex_stream &ts)
{
int l=1;
for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
ts << "% line of score no. " << l++ <<"\n";
ts << lic->TeXstring();
if ((lic+1).ok())
ts << "\\interscoreline\n";
}
}
svec<Item*>
PScore::select_items(PStaff*ps , PCol*pc)
{
svec<Item*> ret;
assert(ps && pc);
for (PCursor<const Item*> ic(pc->its); ic.ok(); ic++){
if (ic->pstaff_ == ps)
ret.add((Item*)(const Item*)ic);
}
return ret;
}
void
PScore::OK()const
{
#ifdef NDEBUG
for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
cc->OK();
for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
ic->OK();
#endif
}
void
PScore::print() const
{
#ifndef NPRINT
mtor << "PScore { paper ";
paper_->print();
mtor << "\ncolumns: ";
for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
cc->print();
mtor << "\nideals: ";
for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
ic->print();
mtor << "}\n";
#endif
}
void
PScore::preprocess()
{
#if 0
for (PCursor<Item*> ic(its); ic.ok(); ic++){
ic->preprocess();
}
#endif
}
void
PScore::postprocess()
{
for (PCursor<Item*> ic(its); ic.ok(); ic++){
ic->postprocess();
}
}
|