1 #include "idealspacing.hh"
5 #include "paper-def.hh"
8 #include "scoreline.hh"
10 #include "tex-stream.hh"
15 PScore::get_spacing(PCol
*l
, PCol
*r
)
19 Idealspacing
*i_p
=new Idealspacing(l
,r
);
20 suz
.bottom().add(i_p
);
30 for (iter_top(cols
,c
); c
.ok(); )
34 c
->set_rank(rank_i
++);
42 PScore::add(PStaff
*s
)
44 assert(s
->pscore_l_
== this);
45 staffs
.bottom().add(s
);
50 PScore::do_connect(PCol
*c1
, PCol
*c2
, Real d
, Real h
)
54 Idealspacing
*s_l
=get_spacing(c1
,c2
);
62 PScore::connect(PCol
* c1
, PCol
*c2
, Real d
, Real h
)
64 do_connect(c1
,c2
,d
,h
);
65 do_connect(c1
->postbreak_p_
, c2
,d
,h
);
66 do_connect(c1
, c2
->prebreak_p_
,d
,h
);
67 do_connect(c1
->postbreak_p_
, c2
->prebreak_p_
,d
,h
);
71 PScore::typeset_item(Item
*i
, PCol
*c
, PStaff
*s
, int breakstat
)
76 typeset_item(i
, c
->prebreak_p_
, s
);
81 typeset_item(i
, c
->postbreak_p_
, s
);
90 /* first do this, because i->width() may follow the 0-pointer */
95 PScore::typeset_spanner(Spanner
*span_p
, PStaff
*ps
)
97 span_p
->pstaff_l_
= ps
;
98 spanners
.bottom().add(span_p
);
99 ps
->spans
.bottom().add(span_p
);
101 // do not init start/stop fields. These are for broken spans only.
102 span_p
->add_processing();
110 if (p
->breakable_b()){
111 p
->prebreak_p_
->pscore_l_
= this;
112 p
->postbreak_p_
->pscore_l_
= this;
114 cols
.bottom().add(p
);
117 PScore::PScore( Paper_def
*p
)
123 PScore::output(Tex_stream
&ts
)
127 ts
<< "\n "<< paper_l_
->lookup_l()->texsetting
<< "%(Tex id)\n";
128 for (iter_top(lines
,lic
); lic
.ok(); lic
++) {
129 ts
<< "% line of score no. " << l
++ <<"\n";
130 ts
<< lic
->TeXstring();
132 ts
<< "\\interscoreline\n";
134 ts
<< "\n\\EndLilyPondOutput";
139 PScore::select_items(PStaff
*ps
, PCol
*pc
)
143 for (iter_top(pc
->its
,i
); i
.ok(); i
++){
144 if (i
->pstaff_l_
== ps
)
145 ret
.push((Item
*)(Item
const *)i
);
154 for (iter_top(cols
,cc
); cc
.ok(); cc
++)
156 for (iter_top(suz
,i
); i
.ok(); i
++)
162 PScore::print() const
167 mtor
<< "\ncolumns: ";
168 for (iter_top(cols
,cc
); cc
.ok(); cc
++)
171 mtor
<< "\nideals: ";
172 for (iter_top(suz
,i
); i
.ok(); i
++)
181 for (iter_top(spanners
,i
); i
.ok(); i
++) {
184 for (iter_top(its
,i
); i
.ok(); i
++){
190 PScore::postprocess()
192 for (iter_top(broken_spans
,i
); i
.ok(); i
++) { // could chase spans as well.
193 i
->post_processing();
195 for (iter_top(its
,i
); i
.ok(); i
++){
196 i
->post_processing();
199 for (iter_top(broken_spans
,i
); i
.ok(); i
++) {
200 i
->molecule_processing();
202 for (iter_top(its
,i
); i
.ok(); i
++){
203 i
->molecule_processing();
206 for (iter_top(lines
,i
); i
.ok(); i
++)
212 PScore::find_col(PCol
const *c
)const
214 PCol
const *what
= c
;
216 what
= what
->daddy_l_
;
218 return cols
.find((PCol
*)what
);
222 PScore::add_broken(Spanner
*s
)
224 assert(s
->left_col_l_
->line_l_
== s
->right_col_l_
->line_l_
);
225 broken_spans
.bottom().add(s
);
226 s
->left_col_l_
->starters
.bottom().add (s
);
227 s
->right_col_l_
->stoppers
.bottom().add (s
);
231 PScore::set_breaking(Array
<Col_hpositions
> const &breaking
)
233 for (int j
=0; j
< breaking
.size(); j
++) {
234 const Array
<PCol
*> &curline(breaking
[j
].cols
);
235 const Array
<PCol
*> &errors(breaking
[j
].error_col_l_arr_
);
236 const Array
<Real
> &config(breaking
[j
].config
);
238 Line_of_score
*s_p
= new Line_of_score(curline
,this);
239 s_p
->error_mark_b_
= breaking
[j
].ugh_b_
;
240 lines
.bottom().add(s_p
);
241 for (int i
=0; i
< curline
.size(); i
++){
242 curline
[i
]->hpos
= config
[i
];
244 for (int i
=0; i
< errors
.size(); i
++)
245 errors
[i
]->error_mark_b_
= true;
250 PScore::calc_breaking()
253 set_breaking(w
.solve());
261 *mlog
<< "Preprocessing elements... " <<flush
;
263 *mlog
<< "\nCalculating column positions ... " <<flush
;
265 *mlog
<< "\nPostprocessing elements..." << endl
;