2 paper-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "font-metric.hh"
14 #include "paper-def.hh"
16 #include "paper-column.hh"
17 #include "paper-score.hh"
18 #include "paper-column.hh"
19 #include "scm-hash.hh"
20 #include "gourlay-breaking.hh"
21 #include "paper-outputter.hh"
22 #include "input-file-results.hh"
24 #include "all-font-metrics.hh"
27 #include "paper-book.hh"
28 #include "ly-module.hh"
30 Paper_score::Paper_score ()
41 Paper_score::Paper_score (Paper_score const &s)
49 Paper_score::typeset_line (System *line)
55 main_smob_ = gh_cons (line->self_scm (), main_smob_);
58 scm_gc_unprotect_object (line->self_scm ());
61 Array<Column_x_positions>
62 Paper_score::calc_breaking ()
64 Break_algorithm *algorithm=0;
65 Array<Column_x_positions> sol;
67 algorithm = new Gourlay_breaking ;
68 algorithm->set_pscore (this);
69 sol = algorithm->solve ();
76 Paper_score::process (String outname)
79 progress_indication (_f ("Element count %d (spanners %d) ",
80 system_->element_count (),
81 system_->spanner_count ()));
83 progress_indication (_ ("Preprocessing graphical objects...") + " ");
85 /* FIXME: Check out why we need this - removing gives assertion failures
88 doubly, also done in Score_engraver */
89 Link_array<Grob> pc (system_->columns ());
90 pc[0]->set_property ("breakable", SCM_BOOL_T);
91 pc.top ()->set_property ("breakable", SCM_BOOL_T);
93 system_->pre_processing ();
95 Array<Column_x_positions> breaking = calc_breaking ();
96 system_->break_into_pieces (breaking);
97 lines_ = system_->get_lines ();
100 outputter_ = paper_->get_paper_outputter (outname);
102 progress_indication ("\n");
104 SCM scopes = SCM_EOL;
106 scopes = scm_cons (header_, scopes);
107 if (global_input_file->header_ && global_input_file->header_ != header_)
108 scopes = scm_cons (global_input_file->header_, scopes);
110 outputter_->output_metadata (scopes, paper_);
113 SCM make_title = scm_primitive_eval (ly_symbol2scm ("make-title"));
114 SCM b = ly_modules_lookup (scopes, ly_symbol2scm ("bookTitle"));
115 if (b != SCM_UNDEFINED && scm_variable_bound_p (b) == SCM_BOOL_T)
117 = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
118 scm_variable_ref (b)));
120 SCM s = ly_modules_lookup (scopes, ly_symbol2scm ("scoreTitle"));
121 if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
123 = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
124 scm_variable_ref (s)));
132 /* Ugh: caller (Score) should do this, but does not know our flavor
134 paper_book->paper_scores_.push (this);
141 Paper_score::output ()
143 outputter_->output_header (paper_);
145 int line_count = SCM_VECTOR_LENGTH ((SCM) lines_);
146 for (int i = 0; i < line_count; i++)
147 outputter_->output_line (scm_vector_ref (lines_, scm_int2num (i)),
148 i == line_count - 1);
150 outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
151 progress_indication ("\n");