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