]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
release: 1.2.9
[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,  1997--1999 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
16 Line_of_score::Line_of_score()
17 {
18   set_axes (Y_AXIS,X_AXIS);
19 }
20
21 bool
22 Line_of_score::contains_b (Paper_column const* c) const
23 {
24   return cols_.find_l ((Paper_column*)(c));
25 }
26
27 // const?
28 Line_of_score*
29 Line_of_score::set_breaking (Array<Column_x_positions> const &breaking, int j) 
30 {
31   const Link_array<Paper_column> &curline (breaking[j].cols_);
32   const Array<Real> &config (breaking[j].config_);
33   Line_of_score *line_l=0;
34
35   line_l = dynamic_cast <Line_of_score*> (clone());
36   line_l->rank_i_ = j;
37   
38   line_l->cols_ = curline;
39   line_l->set_bounds(LEFT,curline[0]);
40   line_l->set_bounds(RIGHT,curline.top());
41         
42   for (int i=0; i < curline.size(); i++)
43     {
44       curline[i]->translate_axis (config[i],X_AXIS);
45       curline[i]->line_l_ = dynamic_cast<Line_of_score*> (line_l);
46     }
47
48   broken_into_l_arr_.push (line_l);
49   return line_l;
50 }
51
52 void
53 Line_of_score::add_column (Paper_column*p)
54 {
55   cols_.push (p);
56   add_element (p);
57 }
58
59 void
60 Line_of_score::do_print() const
61 {
62   Spanner::do_print();
63   Axis_group_spanner::do_print ();
64 }
65
66 Link_array<Score_element>
67 Line_of_score::get_extra_dependencies () const
68 {
69   Link_array<Score_element> r (Axis_group_spanner::get_extra_dependencies ());
70   for (int i=0; i < cols_.size (); i++)
71     r.push (cols_[i]);
72   return r;
73 }
74
75 void
76 Line_of_score::do_substitute_element_pointer (Score_element*o, Score_element*n)
77 {
78   if (Paper_column *p = dynamic_cast<Paper_column*>(o))
79     cols_.substitute (p, dynamic_cast<Paper_column*>(n));
80 }
81
82 void
83 Line_of_score::output_all (bool last_line)
84 {
85   Interval i(extent(Y_AXIS));
86   if (i.empty_b())
87     warning (_ ("Huh?  Empty Line_of_score?"));
88   else
89     translate_axis (- i[MAX], Y_AXIS);
90   
91   pscore_l_->outputter_l_->start_line (i.length ());
92   Super_element::output_all ();
93   if (last_line)
94     pscore_l_->outputter_l_->stop_last_line();
95   else
96     pscore_l_->outputter_l_->stop_line ();
97 }
98
99 int
100 Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
101 {
102   return p1->rank_i_ - p2->rank_i_;
103 }