2 paper-score.cc -- implement Paper_score
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "paper-score.hh"
11 #include "all-font-metrics.hh"
13 #include "international.hh"
16 #include "output-def.hh"
17 #include "paper-book.hh"
18 #include "paper-column.hh"
19 #include "scm-hash.hh"
24 #include "constrained-breaking.hh"
26 Paper_score::Paper_score (Output_def
*layout
)
31 paper_systems_
= SCM_BOOL_F
;
34 Paper_score::Paper_score (Paper_score
const &s
)
41 Paper_score::derived_mark () const
44 scm_gc_mark (layout_
->self_scm ());
45 scm_gc_mark (systems_
);
46 scm_gc_mark (paper_systems_
);
50 Paper_score::typeset_system (System
*system
)
55 systems_
= scm_cons (system
->self_scm (), systems_
);
56 system
->pscore_
= this;
57 system
->layout_
= layout_
;
63 Paper_score::find_break_indices () const
65 vector
<Grob
*> all
= root_system ()->used_columns ();
68 for (vsize i
= 0; i
< all
.size (); i
++)
70 Item
*it
= dynamic_cast<Item
*> (all
[i
]);
71 if (Paper_column::is_breakable (all
[i
])
72 && (i
== 0 || it
->find_prebroken_piece (LEFT
))
73 && (i
== all
.size () - 1 || it
->find_prebroken_piece (RIGHT
)))
78 break_indices_
= retval
;
84 Paper_score::get_break_indices () const
86 if (break_indices_
.empty ())
87 find_break_indices ();
88 return break_indices_
;
92 Paper_score::get_columns () const
95 find_break_indices ();
99 vector
<Column_x_positions
>
100 Paper_score::calc_breaking ()
102 Constrained_breaking
algorithm (this);
103 vector
<Column_x_positions
> sol
;
105 message (_ ("Calculating line breaks...") + " ");
107 int system_count
= robust_scm2int (layout ()->c_variable ("system-count"), 0);
109 return algorithm
.solve (0, VPOS
, system_count
);
111 return algorithm
.best_solution (0, VPOS
);
115 Paper_score::process ()
117 if (be_verbose_global
)
118 message (_f ("Element count %d (spanners %d) ",
119 system_
->element_count (),
120 system_
->spanner_count ()));
122 message (_ ("Preprocessing graphical objects..."));
124 system_
->pre_processing ();
128 Paper_score::root_system () const
134 Paper_score::layout () const
140 Paper_score::get_paper_systems ()
142 if (paper_systems_
== SCM_BOOL_F
)
144 vector
<Column_x_positions
> breaking
= calc_breaking ();
145 system_
->break_into_pieces (breaking
);
146 message (_ ("Drawing systems...") + " ");
147 system_
->do_break_substitution_and_fixup_refpoints ();
148 paper_systems_
= system_
->get_paper_systems ();
150 return paper_systems_
;
155 unsmob_paper_score (SCM x
)
157 return dynamic_cast<Paper_score
*> (unsmob_music_output (x
));