]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
* lily/include/music-output.hh (process): Change signature to
[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 #include "stencil.hh"
27 #include "paper-book.hh"
28 #include "ly-module.hh"
29
30 Paper_score::Paper_score ()
31 {
32   paper_ = 0;
33   system_ = 0;
34   score_ = SCM_EOL;
35 }
36
37 Paper_score::Paper_score (Paper_score const &s)
38   : Music_output (s)
39 {
40   assert (false);
41 }
42
43 void
44 Paper_score::typeset_line (System *system)
45 {
46   if (!system_)
47     system_ = system;
48
49   score_ = gh_cons (system->self_scm (), score_);
50   system->pscore_ = this;
51
52   scm_gc_unprotect_object (system->self_scm ());
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 SCM
70 Paper_score::process (String)
71 {
72   if (verbose_global_b)
73     progress_indication (_f ("Element count %d (spanners %d) ",
74                              system_->element_count (),
75                              system_->spanner_count ()));
76
77   progress_indication (_ ("Preprocessing graphical objects...") + " ");
78
79   /* FIXME: Check out why we need this - removing gives assertion failures
80      down the road.
81      
82      doubly, also done in Score_engraver */
83   Link_array<Grob> pc (system_->columns ());
84   pc[0]->set_property ("breakable", SCM_BOOL_T);
85   pc.top ()->set_property ("breakable", SCM_BOOL_T);
86     
87   system_->pre_processing ();
88  
89   Array<Column_x_positions> breaking = calc_breaking ();
90   system_->break_into_pieces (breaking);
91   SCM lines = system_->get_lines ();
92   progress_indication ("\n");
93
94   /* Only keep result stencils in lines_, *title_; delete all grobs.  */
95   score_ = SCM_EOL;
96   
97   return lines;
98 }