lilypond-1.4.4
[lilypond.git] / lily / paper-score.cc
blob6d659d7064cd0576c3f222eb9bb227c2d3e1d914
1 /*
2 paper-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "main.hh"
10 #include "debug.hh"
11 #include "font-metric.hh"
12 #include "spanner.hh"
13 #include "paper-def.hh"
14 #include "line-of-score.hh"
15 #include "paper-column.hh"
16 #include "paper-score.hh"
17 #include "paper-column.hh"
18 #include "scope.hh"
19 #include "gourlay-breaking.hh"
20 #include "paper-stream.hh"
21 #include "paper-outputter.hh"
22 #include "file-results.hh"
23 #include "misc.hh"
24 #include "all-font-metrics.hh"
26 Paper_score::Paper_score ()
28 paper_l_ =0;
29 outputter_l_ =0;
30 line_l_ = 0;
31 main_smob_ = SCM_EOL;
34 void
35 Paper_score::typeset_line (Line_of_score *l)
37 if (!line_l_)
39 line_l_ = l; // ugh.
41 main_smob_ = gh_cons (l->self_scm (), main_smob_);
42 l->pscore_l_ = this;
45 We don't unprotect l->self_scm (), we haven't got any place else to
46 protect it from collection. */
50 Paper_score::Paper_score (Paper_score const &s)
51 : Music_output (s)
53 assert (false);
56 Array<Column_x_positions>
57 Paper_score::calc_breaking ()
59 Break_algorithm *algorithm_p=0;
60 Array<Column_x_positions> sol;
62 algorithm_p = new Gourlay_breaking ;
63 algorithm_p->set_pscore (this);
64 sol = algorithm_p->solve ();
65 delete algorithm_p;
67 return sol;
71 urg. clean me
73 void
74 Paper_score::process ()
76 if (verbose_global_b)
77 progress_indication (_f ("Element count %d ", line_l_->element_count ()));
80 progress_indication (_ ("Preprocessing elements...") + " ");
83 Be sure to set breakability on first & last column.
85 Link_array<Grob> pc (line_l_->column_l_arr ());
87 pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
88 pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
90 line_l_->pre_processing ();
92 Array<Column_x_positions> breaking = calc_breaking ();
93 line_l_->break_into_pieces (breaking);
95 outputter_l_ = paper_l_->paper_outputter_p ();
97 outputter_l_->output_header ();
98 outputter_l_->output_version ();
100 progress_indication ("\n");
102 if (global_header_p)
104 Scope gh (global_header_p);
105 outputter_l_->output_scope (&gh, "lilypond");
106 outputter_l_->write_header_fields_to_file (&gh);
108 if (header_l_)
110 outputter_l_->output_scope (header_l_, "lilypond");
111 outputter_l_->write_header_fields_to_file (header_l_);
114 outputter_l_->output_comment (_ ("Outputting Score, defined at: "));
115 outputter_l_->output_comment (origin_str_);
117 if (paper_l_->scope_p_)
118 outputter_l_->output_scope (paper_l_->scope_p_, "lilypondpaper");
120 SCM scm = gh_list (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
121 outputter_l_->output_scheme (scm);
123 line_l_->output_lines ();
125 scm = gh_list (ly_symbol2scm ("end-output"), SCM_UNDEFINED);
126 outputter_l_->output_scheme (scm);
128 progress_indication ("\n");
130 // huh?
131 delete outputter_l_;
132 outputter_l_ = 0;
134 if (verbose_global_b)
135 ly_display_scm (scm_gc_stats ());