]> git.donarmstrong.com Git - lilypond.git/blob - lily/axis-group-administration.cc
release: 0.1.61
[lilypond.git] / lily / axis-group-administration.cc
1 /*
2   axis-group.cc -- implement Axis_group_administration
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "interval.hh"
9 #include "axis-group-administration.hh"
10 #include "axis-group-element.hh"
11 #include "graphical-element.hh"
12 #include "debug.hh"
13
14 /** don't copy anything: an element can only be in one
15   Axis_group_element at one time.  */
16 Axis_group_administration::Axis_group_administration (Axis_group_administration const&)
17 {
18 }
19
20 bool 
21 Axis_group_administration::contains_b (Graphical_element 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 (Graphical_element*e,
37                                         Axis_group_element*g, Axis a1, Axis a2)
38 {
39   // don't add self to self.
40   assert (e != g);
41   Axis_group_element *& g1 = e->axis_group_l_a_[a1];
42   Axis_group_element *& g2 = e->axis_group_l_a_[a2];
43   
44   assert (!g1 || g1 == g);
45   assert (!g2 || g2 == g);
46   g1 = g;
47   g2 = g;
48   elem_l_arr_.push (e);
49 }
50
51
52
53 void
54 Axis_group_administration::remove_element (Graphical_element*e, Axis a1, Axis a2)
55 {
56   assert (contains_b (e));
57   elem_l_arr_.unordered_substitute (e,0);
58   
59   e->axis_group_l_a_[a1] = 0;
60   e->axis_group_l_a_[a2] = 0;    
61 }
62
63 void
64 Axis_group_administration::remove_all (Axis a1, Axis a2)
65 {
66   for (int i=0; i < elem_l_arr_.size(); i++) 
67     {
68       Graphical_element*e=elem_l_arr_[i];
69       e->axis_group_l_a_[a1] = 0;
70       e->axis_group_l_a_[a2] = 0;  
71     }
72   elem_l_arr_.clear ();
73 }
74
75
76 void    
77 Axis_group_administration::print() const
78 {
79 #ifndef NPRINT
80   for (int i=0; i < elem_l_arr_.size(); i++) 
81     DOUT << elem_l_arr_[i]->name () << ' ';
82 #endif
83 }