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_EOL;
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++)
70 if (Item::is_breakable (all[i]))
77 vector<Column_x_positions>
78 Paper_score::calc_breaking ()
80 Break_algorithm *algorithm = 0;
81 vector<Column_x_positions> sol;
83 int system_count = robust_scm2int (layout ()->c_variable ("system-count"), 0);
86 Constrained_breaking *b = new Constrained_breaking;
87 b->resize (system_count);
91 algorithm = new Gourlay_breaking;
93 algorithm->set_pscore (this);
94 sol = algorithm->solve ();
101 Paper_score::process ()
103 if (be_verbose_global)
104 message (_f ("Element count %d (spanners %d) ",
105 system_->element_count (),
106 system_->spanner_count ()));
108 message (_ ("Preprocessing graphical objects...") + " ");
110 /* FIXME: Check out why we need this - removing gives assertion failures
113 doubly, also done in Score_engraver */
114 vector<Grob*> pc (system_->columns ());
115 pc[0]->set_property ("breakable", SCM_BOOL_T);
116 pc.back ()->set_property ("breakable", SCM_BOOL_T);
118 system_->pre_processing ();
120 vector<Column_x_positions> breaking = calc_breaking ();
121 system_->break_into_pieces (breaking);
123 paper_systems_ = system_->get_paper_systems ();
127 Paper_score::root_system () const
133 Paper_score::layout () const
139 Paper_score::get_paper_systems () const
141 return paper_systems_;