]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
release: 1.3.36
[lilypond.git] / lily / line-of-score.cc
1 /*
2   scoreline.cc -- implement Line_of_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 "line-of-score.hh"
10 #include "paper-def.hh"
11 #include "paper-outputter.hh"
12 #include "paper-column.hh"
13 #include "paper-score.hh"
14 #include "warn.hh"
15 #include "main.hh"
16 #include "debug.hh"
17 #include "axis-group-interface.hh"
18
19
20 Line_of_score::Line_of_score()
21 {
22   set_elt_property ("columns", SCM_EOL);
23   axis_group (this).set_axes (Y_AXIS,X_AXIS);
24 }
25
26
27
28 void
29 Line_of_score::output_lines ()
30 {
31   for (int i=0; i < broken_into_l_arr_.size (); i++)
32     {
33       Line_of_score *line_l = dynamic_cast<Line_of_score*> (broken_into_l_arr_[i]);
34
35       progress_indication ("[");
36       line_l->post_processing ();
37       progress_indication (to_str (i));
38       line_l->output_line (i + 1 == broken_into_l_arr_.size ());
39       progress_indication ("]");
40     }
41 }
42
43 // const?
44 void
45 Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
46 {
47   for (int i=0; i < breaking.size (); i++)
48     {
49       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
50       line_l->rank_i_ = i;
51       Link_array<Paper_column> c (breaking[i].cols_);
52       pscore_l_->typeset_element (line_l);
53       line_l->set_bound(LEFT,c[0]);
54       line_l->set_bound(RIGHT,c.top ());
55       for (int j=0; j < c.size(); j++)
56         {
57           c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
58           c[j]->line_l_ = line_l;
59         }
60       
61       broken_into_l_arr_.push (line_l);
62     }
63 }
64
65 void
66 Line_of_score::add_column (Paper_column*p)
67 {
68   set_elt_property ("columns",
69                     gh_cons (p->self_scm_, get_elt_property ("columns")));
70   axis_group (this).add_element (p);
71 }
72
73 void
74 Line_of_score::do_print() const
75 {
76   Spanner::do_print();
77   Axis_group_spanner::do_print ();
78 }
79
80 void
81 Line_of_score::output_line (bool last_line)
82 {
83   Interval i(extent(Y_AXIS));
84   if (i.empty_b())
85     programming_error ("Huh?  Empty Line_of_score?");
86   else
87     translate_axis (- i[MAX], Y_AXIS);
88   
89   pscore_l_->outputter_l_->start_line (i.length ());
90   Super_element::output_all ();
91   if (last_line)
92     pscore_l_->outputter_l_->stop_last_line();
93   else
94     pscore_l_->outputter_l_->stop_line ();
95 }
96
97 int
98 Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
99 {
100   return p1->rank_i_ - p2->rank_i_;
101 }