]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
* lily/accidental-placement.cc (position_accidentals): bugfix in
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
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"
25
26 Paper_score::Paper_score ()
27 {
28   paper_ =0;
29   outputter_ =0;
30   system_ = 0;
31   main_smob_ = SCM_EOL;
32 }
33
34 void
35 Paper_score::typeset_line (System *l)
36 {
37   if (!system_)
38     {
39       system_ = l;              // ugh.
40     }
41
42   main_smob_ = gh_cons (l->self_scm (), main_smob_);
43   l->pscore_ = this;
44
45   scm_gc_unprotect_object (l->self_scm ());
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 (String outname)
74 {
75   if (verbose_global_b)
76     progress_indication (_f ("Element count %d (spanners %d) ",
77                              system_->element_count (),
78                              system_->spanner_count ()));
79
80   
81   progress_indication (_ ("Preprocessing graphical objects...") + " ");
82
83   /*
84     Check out why we need this - removing gives assertion failures
85     down the road.
86    */
87   { /* doubly, also done in Score_engraver */
88     Link_array<Grob> pc (system_->columns ());
89   
90     pc[0]->set_property ("breakable", SCM_BOOL_T);
91     pc.top ()->set_property ("breakable", SCM_BOOL_T);
92   }
93
94   system_->pre_processing ();
95  
96   Array<Column_x_positions> breaking = calc_breaking ();
97   system_->break_into_pieces (breaking);
98   
99   outputter_ = paper_->get_paper_outputter (outname);
100
101   progress_indication ("\n");
102
103   SCM scopes = SCM_EOL;
104
105   if (header_)
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);
109   
110   outputter_->output_metadata (scopes, paper_);
111   outputter_->output_music_output_def (paper_);
112   outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("header-end")));
113
114   outputter_
115     ->output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
116                                  ly_quote_scm (paper_->font_descriptions ())));
117
118   outputter_->output_scheme (scm_list_2 (ly_symbol2scm ("make-title"),
119                                          ly_quote_scm (outputter_->file_)));
120   system_->output_lines ();
121   outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
122
123   progress_indication ("\n");
124
125   // huh?
126   delete outputter_;
127   outputter_ = 0;
128 }