2 p-score.cc -- implement PScore
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "super-elem.hh"
10 #include "idealspacing.hh"
14 #include "paper-def.hh"
15 #include "scoreline.hh"
17 #include "tex-stream.hh"
21 PScore::PScore(Paper_def*p)
24 super_elem_l_ = new Super_elem;
25 typeset_element(super_elem_l_);
30 super_elem_l_->unlink_all();
34 PScore::typeset_element(Score_elem * elem_p)
36 elem_p_list_.bottom().add(elem_p);
37 elem_p->pscore_l_ = this;
39 elem_p->add_processing();
43 PScore::typeset_item(Item *i, PCol *c, int breakstat)
47 if (breakstat == -1) {
48 typeset_item(i, c->prebreak_p_);
53 typeset_item(i, c->postbreak_p_);
62 PScore::typeset_broken_spanner(Spanner*span_p)
64 span_p->left_col_l_->starters.bottom().add (span_p);
65 span_p->right_col_l_->stoppers.bottom().add(span_p);
66 assert(span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_);
68 typeset_element(span_p);
73 PScore::typeset_unbroken_spanner(Spanner*span_p)
75 spanners.bottom().add(span_p);
76 span_p->pscore_l_=this;
78 if ( span_p->left_col_l_)
79 span_p->left_col_l_->used_b_ = true;
80 if ( span_p->right_col_l_)
81 span_p->right_col_l_->used_b_ = true;
83 // do not init start/stop fields. These are for broken spans only.
84 span_p->add_processing();
88 PScore::get_spacing(PCol*l, PCol*r)
92 Idealspacing*i_p =new Idealspacing(l,r);
93 suz.bottom().add(i_p);
103 for (iter_top(cols,c); c.ok(); )
107 c->set_rank(rank_i++);
113 PScore::do_connect(PCol *c1, PCol *c2, Real d, Real h)
117 Idealspacing*s_l=get_spacing(c1,c2);
125 PScore::connect(PCol* c1, PCol *c2, Real d, Real h)
127 do_connect(c1,c2,d,h);
128 do_connect(c1->postbreak_p_, c2,d,h);
129 do_connect(c1, c2->prebreak_p_,d,h);
130 do_connect(c1->postbreak_p_, c2->prebreak_p_,d,h);
137 if (p->breakable_b()){
138 p->prebreak_p_->pscore_l_ = this;
139 p->postbreak_p_->pscore_l_ = this;
141 cols.bottom().add(p);
145 PScore::output(Tex_stream &ts)
147 ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n";
148 ts<< super_elem_l_->TeX_string();
149 ts << "\n\\EndLilyPondOutput";
157 for (iter_top(cols,cc); cc.ok(); cc++)
159 for (iter_top(suz,i); i.ok(); i++)
165 PScore::print() const
170 mtor << "\n elements: ";
171 for (iter_top(elem_p_list_,cc); cc.ok(); cc++)
173 mtor << "\n unbroken spanners: ";
174 for (iter(spanners.top(), i); i.ok(); i++)
176 mtor << "\ncolumns: ";
177 for (iter_top(cols,cc); cc.ok(); cc++)
180 mtor << "\nideals: ";
181 for (iter_top(suz,i); i.ok(); i++)
190 super_elem_l_->breakable_col_processing();
191 super_elem_l_->pre_processing();
195 PScore::postprocess()
197 super_elem_l_->post_processing();
198 super_elem_l_->molecule_processing();
202 PScore::find_col(PCol const *c)const
204 PCol const *what = c;
206 what = what->daddy_l_;
208 return cols.find((PCol*)what);
213 PScore::set_breaking(Array<Col_hpositions> const &breaking)
215 super_elem_l_->line_of_score_l_->set_breaking( breaking);
216 super_elem_l_->break_processing();
219 for (iter(spanners.top(),i); i.ok(); ) {
220 Spanner *span_p = i.remove_p();
221 if (span_p->broken_b()) {
225 typeset_broken_spanner(span_p);
228 for (iter(elem_p_list_.top(),i ); i.ok() ;) {
229 Item *i_l =i->item();
230 if ( i_l && !i_l->pcol_l_->line_l_) {
237 for (iter_top(cols, i); i.ok(); i++)
238 i->clean_breakable_items();
242 PScore::calc_breaking()
245 set_breaking(w.solve());
253 *mlog << "Preprocessing elements... " <<flush;
255 *mlog << "\nCalculating column positions ... " <<flush;
257 *mlog << "\nPostprocessing elements..." << endl;
261 /** Get all breakable columns between l and r, (not counting l and r). */
263 PScore::breakable_col_range(PCol*l,PCol*r)const
265 Link_array<PCol> ret;
267 PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
268 PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
271 ugh! windows-suck-suck-suck.
273 while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
274 if (start->breakable_b())
282 PScore::col_range(PCol*l,PCol*r)const
284 Link_array<PCol> ret;
286 PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
287 PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
291 ugh! windows-suck-suck-suck.
293 while ( PCursor<PCol*>::compare(start,stop) < 0 )
300 PScore::broken_col_range(PCol*l,PCol*r)const
302 Link_array<PCol> ret;
304 PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
305 PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
308 ugh! windows-suck-suck-suck.
310 while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
311 if (start->breakable_b() && !start->line_l_ )