]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
* The grand 2005-2006 replace.
[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--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "paper-score.hh"
10
11 #include "all-font-metrics.hh"
12 #include "gourlay-breaking.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 "scm-hash.hh"
19 #include "score.hh"
20 #include "stencil.hh"
21 #include "system.hh"
22 #include "warn.hh"
23
24 Paper_score::Paper_score (Output_def *layout)
25 {
26   layout_ = layout;
27   system_ = 0;
28   systems_ = SCM_EOL;
29   paper_systems_ = SCM_EOL;
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::derived_mark () const
40 {
41   if (layout_)
42     scm_gc_mark (layout_->self_scm ());
43   scm_gc_mark (systems_);
44   scm_gc_mark (paper_systems_);
45 }
46
47 void
48 Paper_score::typeset_system (System *system)
49 {
50   if (!system_)
51     system_ = system;
52
53   systems_ = scm_cons (system->self_scm (), systems_);
54   system->pscore_ = this;
55   system->layout_ = layout_;
56   system->unprotect ();
57 }
58
59 Array<Column_x_positions>
60 Paper_score::calc_breaking ()
61 {
62   Break_algorithm *algorithm = 0;
63   Array<Column_x_positions> sol;
64
65   algorithm = new Gourlay_breaking;
66   algorithm->set_pscore (this);
67   sol = algorithm->solve ();
68   delete algorithm;
69
70   return sol;
71 }
72
73 void
74 Paper_score::process ()
75 {
76   if (be_verbose_global)
77     message (_f ("Element count %d (spanners %d) ",
78                  system_->element_count (),
79                  system_->spanner_count ()));
80
81   message (_ ("Preprocessing graphical objects...") + " ");
82
83   /* FIXME: Check out why we need this - removing gives assertion failures
84      down the road.
85
86      doubly, also done in Score_engraver */
87   Link_array<Grob> pc (system_->columns ());
88   pc[0]->set_property ("breakable", SCM_BOOL_T);
89   pc.top ()->set_property ("breakable", SCM_BOOL_T);
90
91   system_->pre_processing ();
92
93   Array<Column_x_positions> breaking = calc_breaking ();
94   system_->break_into_pieces (breaking);
95
96   paper_systems_ = system_->get_paper_systems ();
97 }
98
99 System *
100 Paper_score::root_system () const
101 {
102   return system_;
103 }
104
105 Output_def *
106 Paper_score::layout () const
107 {
108   return layout_;
109 }
110
111 SCM
112 Paper_score::get_paper_systems () const
113 {
114   return paper_systems_;
115 }