2 paper-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "paper-score.hh"
11 #include "all-font-metrics.hh"
13 #include "gourlay-breaking.hh"
14 #include "international.hh"
17 #include "output-def.hh"
18 #include "paper-book.hh"
19 #include "paper-column.hh"
20 #include "scm-hash.hh"
25 #include "constrained-breaking.hh"
27 Paper_score::Paper_score (Output_def *layout)
32 paper_systems_ = SCM_BOOL_F;
35 Paper_score::Paper_score (Paper_score const &s)
42 Paper_score::derived_mark () const
45 scm_gc_mark (layout_->self_scm ());
46 scm_gc_mark (systems_);
47 scm_gc_mark (paper_systems_);
51 Paper_score::typeset_system (System *system)
56 systems_ = scm_cons (system->self_scm (), systems_);
57 system->pscore_ = this;
58 system->layout_ = layout_;
64 Paper_score::find_break_indices () const
66 vector<Grob*> all = root_system ()->columns ();
69 for (vsize i = 0; i < all.size (); i++)
71 Item *it = dynamic_cast<Item*> (all[i]);
72 if (Paper_column::is_breakable (all[i])
73 && (i == 0 || it->find_prebroken_piece (LEFT))
74 && (i == all.size () - 1 || it->find_prebroken_piece (RIGHT)))
79 break_indices_ = retval;
85 Paper_score::get_break_indices () const
87 if (break_indices_.empty ())
88 find_break_indices ();
89 return break_indices_;
93 Paper_score::get_columns () const
96 find_break_indices ();
100 vector<Column_x_positions>
101 Paper_score::calc_breaking ()
103 Break_algorithm *algorithm = 0;
104 vector<Column_x_positions> sol;
106 message (_ ("Calculating line breaks...") + " ");
108 int system_count = robust_scm2int (layout ()->c_variable ("system-count"), 0);
111 Constrained_breaking *b = new Constrained_breaking;
112 b->resize (system_count);
116 algorithm = new Gourlay_breaking;
118 algorithm->set_pscore (this);
119 sol = algorithm->solve ();
126 Paper_score::process ()
128 if (be_verbose_global)
129 message (_f ("Element count %d (spanners %d) ",
130 system_->element_count (),
131 system_->spanner_count ()));
133 message (_ ("Preprocessing graphical objects...") + " ");
135 /* FIXME: Check out why we need this - removing gives assertion failures
138 doubly, also done in Score_engraver */
139 vector<Grob*> pc (system_->columns ());
140 pc[0]->set_property ("line-break-permission", ly_symbol2scm ("allow"));
141 pc.back ()->set_property ("line-break-permission", ly_symbol2scm ("allow"));
143 system_->pre_processing ();
147 Paper_score::root_system () const
153 Paper_score::layout () const
159 Paper_score::get_paper_systems ()
161 if (paper_systems_ == SCM_BOOL_F)
163 vector<Column_x_positions> breaking = calc_breaking ();
164 system_->break_into_pieces (breaking);
165 message (_ ("Drawing systems...") + " ");
166 paper_systems_ = system_->get_paper_systems ();
168 return paper_systems_;