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