2 p-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "paper-def.hh"
14 #include "line-of-score.hh"
15 #include "paper-column.hh"
16 #include "paper-score.hh"
17 #include "paper-column.hh"
19 #include "gourlay-breaking.hh"
20 #include "paper-stream.hh"
21 #include "paper-outputter.hh"
22 #include "file-results.hh"
25 Paper_score::Paper_score ()
29 Line_of_score * line_p = new Line_of_score;
30 line_p->pscore_l_ = this;
31 element_smob_list_ = scm_protect_object (gh_cons (line_p->self_scm_, SCM_EOL));
35 Paper_score::Paper_score (Paper_score const &s)
41 Paper_score::~Paper_score ()
43 scm_unprotect_object (element_smob_list_);
47 Paper_score::typeset_element (Score_element * elem_p)
49 elem_p->pscore_l_ = this;
51 SCM_CDR(element_smob_list_) = gh_cons (elem_p->self_scm_,
52 SCM_CDR (element_smob_list_));
53 scm_unprotect_object (elem_p->self_scm_);
57 Paper_score::add_column (Paper_column *p)
59 p->set_rank (col_l_arr_.size ());
65 Paper_score::print () const
71 DEBUG_OUT << "Paper_score { ";
72 DEBUG_OUT << "\n elements: ";
74 for (SCM p = SCM_CDR (element_smob_list_);
77 gh_display (SCM_CAR(p));
83 Paper_score::find_col_idx (Paper_column const *c) const
85 Paper_column const *what = c;
87 return col_l_arr_.find_i ((Paper_column*)what);
90 Array<Column_x_positions>
91 Paper_score::calc_breaking ()
93 Break_algorithm *algorithm_p=0;
94 Array<Column_x_positions> sol;
96 algorithm_p = new Gourlay_breaking ;
97 algorithm_p->set_pscore (this);
98 sol = algorithm_p->solve ();
107 Paper_score::process ()
109 Dictionary<int> type_stats;
110 type_stats["Item"] =0;
111 type_stats["Spanner"] =0;
112 type_stats["Total"]=0;
115 *mlog << _ ("Preprocessing elements...") << " " << flush;
116 line_l_->breakable_col_processing ();
117 line_l_->pre_processing ();
119 *mlog << '\n' << _ ("Calculating column positions...") << " " << flush;
120 line_l_->space_processing ();
122 Array<Column_x_positions> breaking = calc_breaking ();
125 Paper_stream* paper_stream_p = paper_l_->paper_stream_p ();
126 outputter_l_ = paper_l_->paper_outputter_p (paper_stream_p, header_l_, origin_str_);
128 Link_array<Line_of_score> lines;
129 for (int i=0; i < breaking.size (); i++)
131 Line_of_score *line_l = line_l_->set_breaking (breaking, i);
133 if (line_l != line_l_)
134 typeset_element (line_l);
139 *mlog << _ ("Line ... ");
140 line_l_->break_processing ();
141 for (int i=0; i < lines.size (); i++)
143 *mlog << '[' << flush;
145 Line_of_score *line_l = lines[i];
147 line_l->post_processing ();
149 line_l->output_all (i + 1 == lines.size());
150 *mlog << ']' << flush;
155 delete paper_stream_p;
162 if (experimental_features_global_b)
164 for (Dictionary_iter<int> i(type_stats); i.ok(); i++)
166 *mlog << i.key () << ": " << i.val () << " objects\n";
169 *mlog << '\n' << flush;
174 Paper_score::broken_col_range (Item const*l, Item const*r) const
176 Link_array<Item> ret;
182 ? find_col_idx (dynamic_cast<Paper_column*> ((Item*)l))+1
186 ? find_col_idx (dynamic_cast<Paper_column*>((Item*)r))
187 : col_l_arr_.size ();
191 Paper_column *c = col_l_arr_[start];
192 if (c->breakable_b () && !c->line_l_)