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