]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-score.cc
release: 1.3.74
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "main.hh"
10 #include "debug.hh"
11 #include "lookup.hh"
12 #include "spanner.hh"
13 #include "paper-def.hh"
14 #include "line-of-score.hh"
15 #include "paper-column.hh"
16 #include "paper-score.hh"
17 #include "paper-column.hh"
18 #include "scope.hh"
19 #include "gourlay-breaking.hh"
20 #include "paper-stream.hh"
21 #include "paper-outputter.hh"
22 #include "file-results.hh"
23 #include "misc.hh"
24 #include "all-font-metrics.hh"
25
26 Paper_score::Paper_score ()
27 {
28   paper_l_ =0;
29   outputter_l_ =0;
30   line_l_ = 0;
31   main_smob_ = SCM_EOL;
32 }
33
34 void
35 Paper_score::typeset_line (Line_of_score *l)
36 {
37   if (!line_l_)
38     {
39       line_l_ = l;              // ugh.
40     }
41   main_smob_ = gh_cons (l->self_scm (), main_smob_);
42   l->pscore_l_ = this;
43
44   /*
45     We don't unprotect l->self_scm (), we haven't got any place else to
46     protect it from collection.  */
47
48 }
49
50 Paper_score::Paper_score (Paper_score const &s)
51   : Music_output (s)
52 {
53   assert (false);
54 }
55
56 Array<Column_x_positions>
57 Paper_score::calc_breaking ()
58 {
59   Break_algorithm *algorithm_p=0;
60   Array<Column_x_positions> sol;
61
62   algorithm_p = new Gourlay_breaking ;
63   algorithm_p->set_pscore (this);
64   sol = algorithm_p->solve ();
65   delete algorithm_p;
66
67   return sol;
68 }
69
70
71
72 /*
73   urg. clean me
74  */
75 void
76 Paper_score::process ()
77 {
78   if (verbose_global_b)
79     progress_indication ( _f("Element count %d ",  line_l_->element_count ()));
80
81   
82   progress_indication (_ ("Preprocessing elements...") + " ");
83
84   /*
85     Be sure to set breakability on first & last column.
86    */
87   Link_array<Score_element> pc (line_l_->column_l_arr ());
88   
89   pc[0]->set_elt_property ("breakable", SCM_BOOL_T);
90   pc.top ()->set_elt_property ("breakable", SCM_BOOL_T);
91
92   line_l_->pre_processing ();
93  
94   Array<Column_x_positions> breaking = calc_breaking ();
95   line_l_->break_into_pieces (breaking);
96   
97   outputter_l_ = new Paper_outputter (paper_l_->paper_stream_p ());
98 ;
99   outputter_l_->output_header ();
100   outputter_l_->output_version();
101   
102   if (header_global_p)
103     outputter_l_->output_scope (header_global_p, "mudela");
104   if (header_l_)
105     outputter_l_->output_scope (header_l_, "mudela");
106
107   outputter_l_->output_comment (_ ("Outputting Score, defined at: "));
108   outputter_l_->output_comment (origin_str_);
109
110   if (paper_l_->scope_p_)
111     outputter_l_->output_scope (paper_l_->scope_p_, "mudelapaper");
112
113   SCM scm;
114   if(experimental_features_global_b)
115     {
116       SCM scm = gh_list (ly_symbol2scm ("experimental-on"), SCM_UNDEFINED);
117       outputter_l_->output_scheme (scm);
118     }
119   scm = gh_list (ly_symbol2scm ("header-end"), SCM_UNDEFINED);
120   outputter_l_->output_scheme (scm);
121   
122   line_l_->output_lines ();
123
124
125   scm = gh_list (ly_symbol2scm ("end-output"), SCM_UNDEFINED);
126   outputter_l_->output_scheme (scm);
127
128   // huh?
129   delete outputter_l_;
130   outputter_l_ = 0;
131 }