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