2 axis-group.cc -- implement Graphical_axis_group
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
10 #include "interval.hh"
11 #include "graphical-axis-group.hh"
12 #include "axis-group-element.hh"
13 #include "graphical-element.hh"
16 /** don't copy anything: an element can only be in one
17 Graphical_axis_group at one time. */
18 Graphical_axis_group::Graphical_axis_group(Graphical_axis_group const&s)
20 axes_[0] = s.axes_[0];
21 axes_[1] = s.axes_[1];
22 ordered_b_ = s.ordered_b_;
26 Graphical_axis_group::contains_b (Graphical_element const *e) const
28 return elem_l_arr_.find_l (e);
32 Graphical_axis_group::extent (Axis axis) const
35 for (int i=0; i < elem_l_arr_.size(); i++)
37 r.unite (elem_l_arr_[i]->extent (axis)
38 + elem_l_arr_[i]->relative_coordinate (this, axis)
45 Graphical_axis_group::add_element (Graphical_element*e)
49 for (int i = 0; i < 2; i++)
53 assert (!e->parent_l (a) || this == e->parent_l (a));
54 e->set_parent (this, a);
56 e->dim_cache_[a]->dependencies_l_arr_.push (dim_cache_[a]);
65 Graphical_axis_group::remove_element (Graphical_element*e)
67 assert (contains_b (e));
69 elem_l_arr_.substitute (e,0);
71 elem_l_arr_.unordered_substitute (e,0);
73 for (int i=0; i< 2; i++)
76 Dimension_cache * d = e->dim_cache_[a];
78 d->dependencies_l_arr_.unordered_substitute (dim_cache_[a], 0);
83 Graphical_axis_group::remove_all ()
85 for (int i=0; i < elem_l_arr_.size(); i++)
87 Graphical_element*e=elem_l_arr_[i];
88 for (int i=0; i< 2; i++)
91 Dimension_cache * d = e->dim_cache_[a];
93 d->dependencies_l_arr_.clear ();
102 Graphical_axis_group::do_print() const
105 for (int i=0; i < elem_l_arr_.size(); i++)
106 DOUT << classname(elem_l_arr_[i]) << " ";
110 Graphical_axis_group::Graphical_axis_group ()
113 axes_[0] = (Axis)-1 ;
114 axes_[1] = (Axis)-1 ;
118 Graphical_axis_group::set_axes (Axis a1, Axis a2)