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"
13 #include "paper-def.hh"
14 #include "scoreline.hh"
16 #include "tex-stream.hh"
17 #include "word-wrap.hh"
20 PScore::PScore(Paper_def*p)
23 super_elem_l_ = new Super_elem;
24 typeset_element(super_elem_l_);
29 super_elem_l_->unlink_all();
33 PScore::typeset_element(Score_elem * elem_p)
35 elem_p_list_.bottom().add(elem_p);
36 elem_p->pscore_l_ = this;
38 elem_p->add_processing();
42 PScore::typeset_item(Item *i, PCol *c, int breakstat)
46 if (breakstat == -1) {
47 typeset_item(i, c->prebreak_p_);
52 typeset_item(i, c->postbreak_p_);
61 PScore::typeset_broken_spanner(Spanner*span_p)
63 span_p->left_col_l_->starters.bottom().add (span_p);
64 span_p->right_col_l_->stoppers.bottom().add(span_p);
65 assert(span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_);
67 typeset_element(span_p);
72 PScore::typeset_unbroken_spanner(Spanner*span_p)
74 span_p_list_.bottom().add(span_p);
75 span_p->pscore_l_=this;
77 if (span_p->left_col_l_)
78 span_p->left_col_l_->used_b_ = true;
79 if ( span_p->right_col_l_)
80 span_p->right_col_l_->used_b_ = true;
82 // do not init start/stop fields. These are for broken spans only.
83 span_p->add_processing();
91 for (iter_top(col_p_list_,c); c.ok(); )
95 c->set_rank(rank_i++);
104 if (p->breakable_b()){
105 p->prebreak_p_->pscore_l_ = this;
106 p->postbreak_p_->pscore_l_ = this;
108 col_p_list_.bottom().add(p);
112 PScore::output(Tex_stream &ts)
114 ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n";
115 ts<< super_elem_l_->TeX_string();
116 ts << "\n\\EndLilyPondOutput";
124 for (iter_top(col_p_list_,cc); cc.ok(); cc++)
130 PScore::print() const
135 mtor << "\n elements: ";
136 for (iter_top(elem_p_list_,cc); cc.ok(); cc++)
138 mtor << "\n unbroken spanners: ";
139 for (iter(span_p_list_.top(), i); i.ok(); i++)
141 mtor << "\ncolumns: ";
142 for (iter_top(col_p_list_,cc); cc.ok(); cc++)
152 super_elem_l_->breakable_col_processing();
153 super_elem_l_->pre_processing();
157 PScore::postprocess()
159 super_elem_l_->post_processing();
160 super_elem_l_->molecule_processing();
164 PScore::find_col(PCol const *c)const
166 PCol const *what = c;
168 what = what->daddy_l_;
170 return col_p_list_.find((PCol*)what);
175 PScore::set_breaking(Array<Col_hpositions> const &breaking)
177 super_elem_l_->line_of_score_l_->set_breaking( breaking);
178 super_elem_l_->break_processing();
181 for (iter(span_p_list_.top(),i); i.ok(); ) {
182 Spanner *span_p = i.remove_p();
183 if (span_p->broken_b()) {
187 typeset_broken_spanner(span_p);
190 for (iter(elem_p_list_.top(),i ); i.ok() ;) {
191 Item *i_l =i->item();
192 if ( i_l && !i_l->pcol_l_->line_l_) {
199 for (iter_top(col_p_list_, i); i.ok(); i++)
200 i->clean_breakable_items();
204 PScore::calc_breaking()
208 set_breaking(w.solve());
216 *mlog << "Preprocessing elements... " <<flush;
218 *mlog << "\nCalculating column positions ... " <<flush;
220 *mlog << "\nPostprocessing elements..." << endl;
224 /** Get all breakable columns between l and r, (not counting l and r). */
226 PScore::breakable_col_range(PCol*l,PCol*r)const
228 Link_array<PCol> ret;
230 PCursor<PCol*> start(l ? find_col(l)+1 : col_p_list_.top() );
231 PCursor<PCol*> stop(r ? find_col(r) : col_p_list_.bottom());
234 ugh! windows-suck-suck-suck.
236 while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
237 if (start->breakable_b())
245 PScore::col_range(PCol*l,PCol*r)const
247 Link_array<PCol> ret;
249 PCursor<PCol*> start(l ? find_col(l)+1 : col_p_list_.top() );
250 PCursor<PCol*> stop(r ? find_col(r) : col_p_list_.bottom());
254 ugh! windows-suck-suck-suck.
256 while ( PCursor<PCol*>::compare(start,stop) < 0 )
263 PScore::broken_col_range(PCol*l,PCol*r)const
265 Link_array<PCol> ret;
267 PCursor<PCol*> start(l ? find_col(l)+1 : col_p_list_.top() );
268 PCursor<PCol*> stop(r ? find_col(r) : col_p_list_.bottom());
271 ugh! windows-suck-suck-suck.
273 while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
274 if (start->breakable_b() && !start->line_l_ )