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
, Axis a1
, Axis a2
)
51 (a1
== NO_AXES
) ? axes_
[0] : a1
,
52 (a2
== NO_AXES
) ? axes_
[1] : a2
,
57 for (int i
= 0; i
< 2; i
++)
59 if (e
->parent_l (as
[i
]))
62 e
->set_parent (this, as
[i
]);
64 // e->dim_cache_[as[i]]->dependencies_l_arr_.push (dim_cache_[as[i]]);
66 assert (e
->parent_l(Y_AXIS
) == this || e
->parent_l (X_AXIS
) == this);
72 ugr. duplication of functionality with remove_all ()
75 Graphical_axis_group::remove_element (Graphical_element
*e
)
77 assert (contains_b (e
));
79 elem_l_arr_
.substitute (e
,0);
81 elem_l_arr_
.unordered_substitute (e
,0);
87 Graphical_axis_group::do_remove (Graphical_element
*e
)
89 for (int i
=0; i
< 2; i
++)
92 if (e
->parent_l (a
) != this)
95 // e->dim_cache_[a]->dependencies_l_arr_.clear ();
100 Graphical_axis_group::remove_all ()
102 for (int i
=0; i
< elem_l_arr_
.size(); i
++)
103 do_remove (elem_l_arr_
[i
]);
105 elem_l_arr_
.clear ();
110 Graphical_axis_group::do_print() const
113 for (int i
=0; i
< elem_l_arr_
.size(); i
++)
114 DEBUG_OUT
<< classname(elem_l_arr_
[i
]) << " ";
118 Graphical_axis_group::Graphical_axis_group ()
121 axes_
[0] = (Axis
)-1 ;
122 axes_
[1] = (Axis
)-1 ;
126 Graphical_axis_group::set_axes (Axis a1
, Axis a2
)