lilypond-1.1.21
[lilypond.git] / lily / axis-group.cc
blobb0161fa2a45df6194182e44f8de7c76e29e64d60
1 /*
2 axis-group.cc -- implement Axis_group_administration
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "interval.hh"
9 #include "axis-group-administration.hh"
10 #include "score-elem.hh"
11 #include "debug.hh"
13 /** don't copy anything: an element can only be in one
14 Axis_group_element at one time. */
15 Axis_group_administration::Axis_group_administration (Axis_group_administration const&)
19 bool
20 Axis_group_administration::contains_b (Score_elem const *e) const
22 return elem_l_arr_.find_l (e);
25 Interval
26 Axis_group_administration::extent (Axis axis) const
28 Interval r;
29 for (int i=0; i < elem_l_arr_.size(); i++)
30 r.unite (elem_l_arr_[i]->extent (axis));
31 return r;
34 void
35 Axis_group_administration::add_element (Score_elem*e,
36 Axis_group_element*g, Axis a1, Axis a2)
38 Axis_group_element *& g1=e->axis_group_l_a_[a1];
39 Axis_group_element *& g2 = e->axis_group_l_a_[a2];
41 assert (!g1 || g1 == g);
42 assert (!g2 || g2 == g);
43 g1 = g;
44 g2 = g;
45 elem_l_arr_.push (e);
50 void
51 Axis_group_administration::remove_element (Score_elem*e, Axis a1, Axis a2)
53 assert (contains_b (e));
54 elem_l_arr_.unordered_substitute (e,0);
56 e->axis_group_l_a_[a1] = 0;
57 e->axis_group_l_a_[a2] = 0;
60 void
61 Axis_group_administration::remove_all (Axis a1, Axis a2)
63 for (int i=0; i < elem_l_arr_.size(); i++)
65 Score_elem*e=elem_l_arr_[i];
66 e->axis_group_l_a_[a1] = 0;
67 e->axis_group_l_a_[a2] = 0;
69 elem_l_arr_.clear();
73 void
74 Axis_group_administration::print() const
76 #ifndef NPRINT
77 for (int i=0; i < elem_l_arr_.size(); i++)
78 DOUT << elem_l_arr_[i]->name() << ' ';
79 #endif