]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
The grand \paper -> \layout, \bookpaper -> \paper renaming.
[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 "all-font-metrics.hh"
10 #include "font-metric.hh"
11 #include "gourlay-breaking.hh"
12 #include "ly-module.hh"
13 #include "main.hh"
14 #include "misc.hh"
15 #include "output-def.hh"
16 #include "paper-book.hh"
17 #include "paper-column.hh"
18 #include "paper-score.hh"
19 #include "scm-hash.hh"
20 #include "score.hh"
21 #include "spanner.hh"
22 #include "stencil.hh"
23 #include "system.hh"
24 #include "warn.hh"
25
26 Paper_score::Paper_score ()
27 {
28   layout_ = 0;
29   system_ = 0;
30 }
31
32 Paper_score::Paper_score (Paper_score const &s)
33   : Music_output (s)
34 {
35   assert (false);
36 }
37
38 void
39 Paper_score::typeset_line (System *system)
40 {
41   if (!system_)
42     system_ = system;
43
44   systems_ = scm_cons (system->self_scm (), systems_);
45   system->pscore_ = this;
46
47   scm_gc_unprotect_object (system->self_scm ());
48 }
49
50 Array<Column_x_positions>
51 Paper_score::calc_breaking ()
52 {
53   Break_algorithm *algorithm = 0;
54   Array<Column_x_positions> sol;
55
56   algorithm = new Gourlay_breaking ;
57   algorithm->set_pscore (this);
58   sol = algorithm->solve ();
59   delete algorithm;
60
61   return sol;
62 }
63
64 SCM
65 Paper_score::process (String)
66 {
67   if (verbose_global_b)
68     progress_indication (_f ("Element count %d (spanners %d) ",
69                              system_->element_count (),
70                              system_->spanner_count ()));
71
72   progress_indication (_ ("Preprocessing graphical objects...") + " ");
73
74   /* FIXME: Check out why we need this - removing gives assertion failures
75      down the road.
76      
77      doubly, also done in Score_engraver */
78   Link_array<Grob> pc (system_->columns ());
79   pc[0]->set_property ("breakable", SCM_BOOL_T);
80   pc.top ()->set_property ("breakable", SCM_BOOL_T);
81     
82   system_->pre_processing ();
83  
84   Array<Column_x_positions> breaking = calc_breaking ();
85   system_->break_into_pieces (breaking);
86   SCM lines = system_->get_lines ();
87 #if 0
88   /* gourlay:do_solve also prints newline.  */
89   progress_indication ("\n");
90 #endif
91   
92   /* Only keep result stencils in lines_, *title_; delete all grobs.  */
93   systems_ = SCM_EOL;
94   
95   return lines;
96 }