]> git.donarmstrong.com Git - lilypond.git/blob - lily/scoreline.cc
release: 0.1.61
[lilypond.git] / lily / scoreline.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@stack.nl>
7 */
8
9 #include "scoreline.hh"
10 #include "dimen.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 (Score_elem*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 void
41 Line_of_score::set_breaking (Array<Col_hpositions> const &breaking)
42 {
43   for (int j=0; j < breaking.size(); j++) 
44     {
45       const Array<Paper_column*> &curline (breaking[j].cols);
46       const Array<Paper_column*> &errors (breaking[j].error_col_l_arr_);
47       const Array<Real> &config (breaking[j].config);
48         
49       for (int i=0; i < errors.size(); i++)
50         errors[i]->error_mark_b_ = true;
51
52       Line_of_score *line_l=0;
53       Line_of_score *line_p =0;
54         
55       if (breaking.size() >1) 
56         {
57           line_p = (Line_of_score*)clone()->spanner ();
58           line_l = line_p;
59         }
60       else 
61         line_l =  this;
62         
63       ((Array<Paper_column*> &)line_l->cols) = curline;
64       line_l->set_bounds(LEFT,curline[0]);
65       
66       line_l->set_bounds(RIGHT,curline.top());
67         
68       if (line_p) 
69         {
70           pscore_l_->typeset_broken_spanner (line_p);
71           broken_into_l_arr_.push (line_p);
72         }
73
74       for (int i=0; i < curline.size(); i++)
75         {
76           curline[i]->translate_axis (config[i],X_AXIS);
77           curline[i]->line_l_ = (Line_of_score*)line_l;
78         }
79     }
80 }
81
82
83 void
84 Line_of_score::break_into_pieces (bool)
85 {
86   
87 }
88
89 Link_array<Line_of_score>
90 Line_of_score::get_lines() const
91 {
92   Link_array<Line_of_score> ret;
93
94   if (broken_into_l_arr_.size())
95     for (int i=0; i < broken_into_l_arr_.size(); i++) 
96       {
97         ret.push ((Line_of_score*)broken_into_l_arr_[i]);
98       }
99   else 
100     ret.push ((Line_of_score*)this);    // ugh
101   
102   return ret;
103 }
104
105 void
106 Line_of_score::do_print() const
107 {
108   Spanner::do_print();
109 }
110
111 Interval
112 Line_of_score::do_width() const
113
114   return Spanner::do_width();
115 }
116
117 Link_array<Score_elem>
118 Line_of_score::get_extra_dependencies () const
119 {
120   Link_array<Score_elem> r;
121   for (int i=0; i < cols.size (); i++)
122     r.push (cols[i]);
123   return r;
124 }
125
126 void
127 Line_of_score::do_unlink () 
128 {
129   Spanner::do_unlink ();
130   for (int i=0; i < cols.size (); i++)
131     cols[i]->line_l_ =0;
132   cols.set_size (0);
133 }
134
135
136 void
137 Line_of_score::do_junk_links () 
138 {
139   cols.set_size (0);
140 }