]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
79332395180425084d9972b36b38ea833e73e1be
[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--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "line-of-score.hh"
10 #include "spanner.hh"
11 #include "atom.hh"
12 #include "paper-def.hh"
13 #include "p-col.hh"
14 #include "p-score.hh"
15
16
17 Line_of_score::Line_of_score()
18 {
19   error_mark_b_ = 0;
20 }
21
22
23 IMPLEMENT_IS_TYPE_B1(Line_of_score,Spanner);
24
25 void
26 Line_of_score::add_element (Score_element*e)
27 {
28   // avoid excess dependencies.
29   if (!(e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
30     add_dependency (e);
31 }
32
33 bool
34 Line_of_score::contains_b (Paper_column const* c) const
35 {
36   return cols.find_l ((Paper_column*)c);
37 }
38
39 Line_of_score*
40 Line_of_score::set_breaking (Array<Column_x_positions> const &breaking, int j) const
41 {
42   const Array<Paper_column*> &curline (breaking[j].cols);
43   const Array<Paper_column*> &errors (breaking[j].error_col_l_arr_);
44   const Array<Real> &config (breaking[j].config);
45         
46   for (int i=0; i < errors.size(); i++)
47     errors[i]->error_mark_b_ = true;
48
49   Line_of_score *line_l=0;
50         
51   if (breaking.size() >1) 
52     {
53       line_l = (Line_of_score*)clone()->access_Spanner ();
54     }
55   else 
56     line_l = (Line_of_score*) this;
57         
58   ((Array<Paper_column*> &)line_l->cols) = curline;
59   line_l->set_bounds(LEFT,curline[0]);
60       
61   line_l->set_bounds(RIGHT,curline.top());
62         
63   for (int i=0; i < curline.size(); i++)
64     {
65       curline[i]->translate_axis (config[i],X_AXIS);
66       curline[i]->line_l_ = (Line_of_score*)line_l;
67     }
68
69   return line_l;
70 }
71
72
73
74
75 void
76 Line_of_score::do_print() const
77 {
78   Spanner::do_print();
79 }
80
81 Interval
82 Line_of_score::do_width() const
83
84   return Spanner::do_width();
85 }
86
87 Link_array<Score_element>
88 Line_of_score::get_extra_dependencies () const
89 {
90   Link_array<Score_element> r;
91   for (int i=0; i < cols.size (); i++)
92     r.push (cols[i]);
93   return r;
94 }
95
96 void
97 Line_of_score::do_unlink () 
98 {
99   Spanner::do_unlink ();
100   for (int i=0; i < cols.size (); i++)
101     cols[i]->line_l_ =0;
102   cols.set_size (0);
103 }
104
105
106 void
107 Line_of_score::do_junk_links () 
108 {
109   cols.set_size (0);
110 }