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