]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group.cc
release: 0.1.7
[lilypond.git] / lily / axis-group.cc
1 /*
2   axis-group.cc -- implement Axis_group_administration
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "interval.hh"
9 #include "axis-group.hh"
10 #include "score-elem.hh"
11 #include "debug.hh"
12
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(
16     Axis_group_administration const&)
17 {
18 }
19
20 bool 
21 Axis_group_administration::contains_b(Score_elem const *e)const
22 {
23     return elem_l_arr_.find_l(e);
24 }
25
26 Interval
27 Axis_group_administration::extent(Axis axis)const
28 {
29     Interval r;
30     for (int i=0; i < elem_l_arr_.size(); i++) 
31         r.unite(elem_l_arr_[i]->extent(axis));
32     return r;
33 }
34
35 void
36 Axis_group_administration::add_element(Score_elem*e,
37                                        Axis_group_element*g, Axis a1, Axis a2)
38 {
39     assert( ! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2] );
40     e->axis_group_l_a_[a1] = g;
41     e->axis_group_l_a_[a2] = g;    
42     elem_l_arr_.push ( e);
43 }
44
45
46
47 void
48 Axis_group_administration::remove_element(Score_elem*e, Axis a1, Axis a2)
49 {
50     assert( contains_b( e));
51     elem_l_arr_.unordered_substitute(e,0);
52     
53     e->axis_group_l_a_[a1] = 0;
54     e->axis_group_l_a_[a2] = 0;    
55 }
56
57 void
58 Axis_group_administration::remove_all(Axis a1, Axis a2)
59 {
60     for (int i=0; i < elem_l_arr_.size(); i++) { 
61         Score_elem*e=elem_l_arr_[i];
62         e->axis_group_l_a_[a1] = 0;
63         e->axis_group_l_a_[a2] = 0;  
64     }
65     elem_l_arr_.clear();
66 }
67
68
69 void    
70 Axis_group_administration::print() const
71 {
72 #ifndef NPRINT
73     for (int i=0; i < elem_l_arr_.size(); i++) 
74         mtor << elem_l_arr_[i]->name() << ' ';
75 #endif
76 }