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 elem_p->set_elt_property (ly_symbol ("full-name"),
54 gh_str02scm((char*)elem_p->name()));
56 scm_unprotect_object (elem_p->self_scm_);
60 Paper_score::add_column (Paper_column *p)
62 p->set_rank (col_l_arr_.size ());
68 Paper_score::print () const
74 DEBUG_OUT << "Paper_score { ";
75 DEBUG_OUT << "\n elements: ";
77 for (SCM p = SCM_CDR (element_smob_list_);
80 gh_display (SCM_CAR(p));
86 Paper_score::find_col_idx (Paper_column const *c) const
88 Paper_column const *what = c;
90 return col_l_arr_.find_i ((Paper_column*)what);
93 Array<Column_x_positions>
94 Paper_score::calc_breaking ()
96 Break_algorithm *algorithm_p=0;
97 Array<Column_x_positions> sol;
99 algorithm_p = new Gourlay_breaking ;
100 algorithm_p->set_pscore (this);
101 sol = algorithm_p->solve ();
110 Paper_score::process ()
112 Dictionary<int> type_stats;
113 type_stats["Item"] =0;
114 type_stats["Spanner"] =0;
115 type_stats["Total"]=0;
118 *mlog << _ ("Preprocessing elements...") << " " << flush;
119 line_l_->breakable_col_processing ();
120 line_l_->pre_processing ();
122 *mlog << '\n' << _ ("Calculating column positions...") << " " << flush;
123 line_l_->space_processing ();
125 Array<Column_x_positions> breaking = calc_breaking ();
128 Paper_stream* paper_stream_p = paper_l_->paper_stream_p ();
129 outputter_l_ = paper_l_->paper_outputter_p (paper_stream_p, header_l_, origin_str_);
131 Link_array<Line_of_score> lines;
132 for (int i=0; i < breaking.size (); i++)
134 Line_of_score *line_l = line_l_->set_breaking (breaking, i);
136 if (line_l != line_l_)
137 typeset_element (line_l);
142 *mlog << _ ("Line ... ");
143 line_l_->break_processing ();
144 for (int i=0; i < lines.size (); i++)
146 *mlog << '[' << flush;
148 Line_of_score *line_l = lines[i];
150 line_l->post_processing ();
152 line_l->output_all (i + 1 == lines.size());
153 *mlog << ']' << flush;
158 delete paper_stream_p;
165 if (experimental_features_global_b)
167 for (Dictionary_iter<int> i(type_stats); i.ok(); i++)
169 *mlog << i.key () << ": " << i.val () << " objects\n";
172 *mlog << '\n' << flush;
177 Paper_score::broken_col_range (Item const*l, Item const*r) const
179 Link_array<Item> ret;
185 ? find_col_idx (dynamic_cast<Paper_column*> ((Item*)l))+1
189 ? find_col_idx (dynamic_cast<Paper_column*>((Item*)r))
190 : col_l_arr_.size ();
194 Paper_column *c = col_l_arr_[start];
195 if (c->breakable_b () && !c->line_l_)