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 "international.hh"
16 #include "output-def.hh"
17 #include "paper-book.hh"
18 #include "paper-column.hh"
19 #include "scm-hash.hh"
24 #include "constrained-breaking.hh"
26 Paper_score::Paper_score (Output_def *layout)
31 paper_systems_ = SCM_BOOL_F;
34 Paper_score::Paper_score (Paper_score const &s)
41 Paper_score::derived_mark () const
44 scm_gc_mark (layout_->self_scm ());
45 scm_gc_mark (systems_);
46 scm_gc_mark (paper_systems_);
50 Paper_score::typeset_system (System *system)
55 systems_ = scm_cons (system->self_scm (), systems_);
56 system->pscore_ = this;
57 system->layout_ = layout_;
63 Paper_score::find_break_indices () const
65 vector<Grob*> all = root_system ()->columns ();
68 for (vsize i = 0; i < all.size (); i++)
70 Item *it = dynamic_cast<Item*> (all[i]);
71 if (Paper_column::is_breakable (all[i])
72 && (i == 0 || it->find_prebroken_piece (LEFT))
73 && (i == all.size () - 1 || it->find_prebroken_piece (RIGHT)))
78 break_indices_ = retval;
84 Paper_score::get_break_indices () const
86 if (break_indices_.empty ())
87 find_break_indices ();
88 return break_indices_;
92 Paper_score::get_columns () const
95 find_break_indices ();
99 vector<Column_x_positions>
100 Paper_score::calc_breaking ()
102 Constrained_breaking algorithm (this);
103 vector<Column_x_positions> sol;
105 message (_ ("Calculating line breaks...") + " ");
107 int system_count = robust_scm2int (layout ()->c_variable ("system-count"), 0);
109 algorithm.resize (system_count);
111 return algorithm.solve ();
115 Paper_score::process ()
117 if (be_verbose_global)
118 message (_f ("Element count %d (spanners %d) ",
119 system_->element_count (),
120 system_->spanner_count ()));
122 message (_ ("Preprocessing graphical objects...") + " ");
124 /* FIXME: Check out why we need this - removing gives assertion failures
127 doubly, also done in Score_engraver */
128 vector<Grob*> pc (system_->columns ());
129 pc[0]->set_property ("line-break-permission", ly_symbol2scm ("allow"));
130 pc.back ()->set_property ("line-break-permission", ly_symbol2scm ("allow"));
132 system_->pre_processing ();
136 Paper_score::root_system () const
142 Paper_score::layout () const
148 Paper_score::get_paper_systems ()
150 if (paper_systems_ == SCM_BOOL_F)
152 vector<Column_x_positions> breaking = calc_breaking ();
153 system_->break_into_pieces (breaking);
154 message (_ ("Drawing systems...") + " ");
155 paper_systems_ = system_->get_paper_systems ();
157 return paper_systems_;