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