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