]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
* Documentation/user/lilypond.tely: Add dir entries for
[lilypond.git] / lily / paper-score.cc
1 /*
2   paper-score.cc -- implement Paper_score
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "main.hh"
10 #include "warn.hh"
11 #include "font-metric.hh"
12 #include "spanner.hh"
13 #include "paper-def.hh"
14 #include "system.hh"
15 #include "paper-column.hh"
16 #include "paper-score.hh"
17 #include "paper-column.hh"
18 #include "scm-hash.hh"
19 #include "gourlay-breaking.hh"
20 #include "paper-outputter.hh"
21 #include "file-results.hh"
22 #include "misc.hh"
23 #include "all-font-metrics.hh"
24
25 Paper_score::Paper_score ()
26 {
27   paper_ =0;
28   outputter_ =0;
29   system_ = 0;
30   main_smob_ = SCM_EOL;
31 }
32
33 void
34 Paper_score::typeset_line (System *l)
35 {
36   if (!system_)
37     {
38       system_ = l;              // ugh.
39     }
40   main_smob_ = gh_cons (l->self_scm (), main_smob_);
41   l->pscore_ = this;
42
43   /*
44     We don't unprotect l->self_scm (), we haven't got any place else to
45     protect it from collection.  */
46
47 }
48
49 Paper_score::Paper_score (Paper_score const &s)
50   : Music_output (s)
51 {
52   assert (false);
53 }
54
55 Array<Column_x_positions>
56 Paper_score::calc_breaking ()
57 {
58   Break_algorithm *algorithm=0;
59   Array<Column_x_positions> sol;
60
61   algorithm = new Gourlay_breaking ;
62   algorithm->set_pscore (this);
63   sol = algorithm->solve ();
64   delete algorithm;
65
66   return sol;
67 }
68
69 /*
70   urg. clean me
71  */
72 void
73 Paper_score::process ()
74 {
75   if (verbose_global_b)
76     progress_indication (_f ("Element count %d ",  system_->element_count ()));
77
78   
79   progress_indication (_ ("Preprocessing elements...") + " ");
80
81   /*
82     Be sure to set breakability on first & last column.
83    */
84   Link_array<Grob> pc (system_->columns ());
85   
86   pc[0]->set_grob_property ("breakable", SCM_BOOL_T);
87   pc.top ()->set_grob_property ("breakable", SCM_BOOL_T);
88
89   system_->pre_processing ();
90  
91   Array<Column_x_positions> breaking = calc_breaking ();
92   system_->break_into_pieces (breaking);
93   
94   outputter_ = paper_->get_paper_outputter ();
95 ;
96   outputter_->output_header ();
97   outputter_->output_version ();
98
99   progress_indication ("\n");
100
101   if (global_header)
102     {
103
104       outputter_->output_scope (global_header, "lilypond");
105       outputter_->write_header_fields_to_file (global_header);
106     }
107   if (header_)
108     {
109       outputter_->output_scope (header_, "lilypond");
110       outputter_->write_header_fields_to_file (header_);
111     }
112   
113   outputter_->output_comment (_ ("Outputting Score, defined at: "));
114   outputter_->output_comment (origin_string_);
115
116   if (paper_->variable_tab_)
117     outputter_->output_scope (paper_->variable_tab_, "lilypondpaper");
118
119   SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
120   outputter_->output_scheme (scm);
121
122   system_->output_lines ();
123
124   scm = scm_list_n (ly_symbol2scm ("end-output"), SCM_UNDEFINED);
125   outputter_->output_scheme (scm);
126
127   progress_indication ("\n");
128
129   // huh?
130   delete outputter_;
131   outputter_ = 0;
132   
133   if (verbose_global_b)
134     {
135       scm_write (scm_gc_stats (), scm_current_error_port ());
136       scm_flush (scm_current_error_port ());
137     }
138 }