]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
c53a33a9e8cc4f7f6647015f2dffa7db0e95ec03
[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,Y_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) const
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
37   line_l->cols_ = curline;
38   line_l->set_bounds(LEFT,curline[0]);
39   line_l->set_bounds(RIGHT,curline.top());
40         
41   for (int i=0; i < curline.size(); i++)
42     {
43       curline[i]->translate_axis (config[i],X_AXIS);
44       curline[i]->line_l_ = dynamic_cast<Line_of_score*>(line_l);
45     }
46
47   Breaking_information b;
48   b.bounds_ = line_l->spanned_drul_;
49   b.broken_spanner_l_ = line_l;
50   b.line_l_ = line_l;
51   
52   broken_info_.push (b);
53
54   return line_l;
55 }
56
57 void
58 Line_of_score::add_column (Paper_column*p)
59 {
60   cols_.push (p);
61 }
62
63 void
64 Line_of_score::do_print() const
65 {
66   Spanner::do_print();
67   Axis_group_spanner::do_print ();
68 }
69
70 Link_array<Score_element>
71 Line_of_score::get_extra_dependencies () const
72 {
73   Link_array<Score_element> r (Axis_group_spanner::get_extra_dependencies ());
74   for (int i=0; i < cols_.size (); i++)
75     r.push (cols_[i]);
76   return r;
77 }
78
79 void
80 Line_of_score::do_substitute_element_pointer (Score_element*o, Score_element*n)
81 {
82   if (Paper_column *p = dynamic_cast<Paper_column*>(o))
83     cols_.substitute (p, dynamic_cast<Paper_column*>(n));
84 }
85
86 void
87 Line_of_score::output_all (bool last_line)
88 {
89   Interval i(extent(Y_AXIS));
90   if (i.empty_b())
91     warning ("Huh? Empty Line_of_score?");
92   else
93     translate_axis (- i[MAX], Y_AXIS);
94   
95   pscore_l_->outputter_l_->start_line (i.length ());
96   Super_element::output_all ();
97   if (last_line)
98     pscore_l_->outputter_l_->stop_last_line();
99   else
100     pscore_l_->outputter_l_->stop_line ();
101 }