release commit
[lilypond.git] / lily / paper-score.cc
blob0cc8169ede947399a15ca164b3dcf5b0e7702f58
1 /*
2 paper-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "score.hh"
10 #include "main.hh"
11 #include "warn.hh"
12 #include "font-metric.hh"
13 #include "spanner.hh"
14 #include "paper-def.hh"
15 #include "system.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"
23 #include "misc.hh"
24 #include "all-font-metrics.hh"
26 Paper_score::Paper_score ()
28 paper_ =0;
29 outputter_ =0;
30 system_ = 0;
31 main_smob_ = SCM_EOL;
34 void
35 Paper_score::typeset_line (System *l)
37 if (!system_)
39 system_ = l; // ugh.
42 main_smob_ = gh_cons (l->self_scm (), main_smob_);
43 l->pscore_ = this;
46 We don't unprotect l->self_scm (), we haven't got any place else to
47 protect it from collection. */
51 Paper_score::Paper_score (Paper_score const &s)
52 : Music_output (s)
54 assert (false);
57 Array<Column_x_positions>
58 Paper_score::calc_breaking ()
60 Break_algorithm *algorithm=0;
61 Array<Column_x_positions> sol;
63 algorithm = new Gourlay_breaking ;
64 algorithm->set_pscore (this);
65 sol = algorithm->solve ();
66 delete algorithm;
68 return sol;
72 urg. clean me
74 void
75 Paper_score::process (String outname)
77 if (verbose_global_b)
78 progress_indication (_f ("Element count %d (spanners %d) ",
79 system_->element_count (),
80 system_->spanner_count ()));
83 progress_indication (_ ("Preprocessing graphical objects...") + " ");
86 Be sure to set breakability on first & last column.
88 Link_array<Grob> pc (system_->columns ());
90 pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
91 pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
93 system_->pre_processing ();
95 Array<Column_x_positions> breaking = calc_breaking ();
96 system_->break_into_pieces (breaking);
98 outputter_ = paper_->get_paper_outputter (outname);
99 outputter_->output_header ();
100 outputter_->output_version ();
102 progress_indication ("\n");
104 if (global_input_file->header_)
106 outputter_->output_scope (global_input_file->header_, "lilypond");
107 outputter_->write_header_fields_to_file (global_input_file->header_);
110 if (header_)
112 outputter_->output_scope (header_, "lilypond");
113 outputter_->write_header_fields_to_file (header_);
116 outputter_->output_scope (paper_->scope_, "lilypondpaper");
118 SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
119 outputter_->output_scheme (scm);
121 system_->output_lines ();
123 scm = scm_list_n (ly_symbol2scm ("end-output"), SCM_UNDEFINED);
124 outputter_->output_scheme (scm);
126 progress_indication ("\n");
128 // huh?
129 delete outputter_;
130 outputter_ = 0;
132 if (verbose_global_b)
134 scm_write (scm_gc_stats (), scm_current_error_port ());
135 scm_flush (scm_current_error_port ());