2 axis-group-interface.cc -- implement Axis_group_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "axis-group-interface.hh"
11 #include "score-element.hh"
12 #include "dimension-cache.hh"
14 Axis_group_interface::Axis_group_interface (Score_element*s)
21 axis_group (Score_element*s)
23 return Axis_group_interface (s);
27 Axis_group_interface::add_element (Score_element *e)
29 elt_l_->used_b_ = true;
32 for (SCM ax = elt_l_->get_elt_property ("axes"); ax != SCM_EOL ; ax = gh_cdr (ax))
34 Axis a = (Axis) gh_scm2int (gh_car (ax));
37 e->set_parent (elt_l_, a);
40 Group_interface::add_element (e);
42 elt_l_->add_dependency (e);
47 Axis_group_interface::axis_b (Axis a )const
49 return elt_l_->dim_cache_[a]->extent_callback_l_ == group_extent_callback;
53 Axis_group_interface::group_extent_callback (Dimension_cache const *c)
56 Score_element * me = c->element_l ();
59 for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
62 Score_element * se = SMOB_TO_TYPE (Score_element, e);
64 Interval dims = se->extent (a);
66 r.unite (dims + se->relative_coordinate (me, a));
74 Axis_group_interface::set_interface ()
76 if (!has_interface_b ())
78 elt_l_->set_elt_property ("elements", SCM_EOL);
79 elt_l_->set_elt_property ("transparent", SCM_BOOL_T);
80 elt_l_->set_elt_property ("axes" , SCM_EOL);
81 group (elt_l_, "interfaces").add_thing (ly_symbol2scm ("Axis_group"));
86 Axis_group_interface::set_axes (Axis a1, Axis a2)
90 SCM ax = gh_cons (gh_int2scm (a1), SCM_EOL);
92 ax= gh_cons (gh_int2scm (a2), ax);
95 elt_l_->set_elt_property ("axes", ax);
97 if (a1 != X_AXIS && a2 != X_AXIS)
98 elt_l_->set_empty (X_AXIS);
99 if (a1 != Y_AXIS && a2 != Y_AXIS)
100 elt_l_->set_empty (Y_AXIS);
102 elt_l_->dim_cache_[a1]->set_callback (Axis_group_interface::group_extent_callback);
103 elt_l_->dim_cache_[a2]->set_callback (Axis_group_interface::group_extent_callback);
106 Link_array<Score_element>
107 Axis_group_interface::get_children ()
109 Link_array<Score_element> childs;
110 childs.push (elt_l_) ;
112 if (!has_interface_b ())
115 for (SCM ep = elt_l_->get_elt_property ("elements"); gh_pair_p (ep); ep = gh_cdr (ep))
117 Score_element* e = unsmob_element (gh_car (ep));
119 childs.concat (axis_group (e).get_children ());
126 Axis_group_interface::has_interface_b ()
128 SCM memq = scm_memq (ly_symbol2scm ("Axis_group"),
129 elt_l_->get_elt_property ("interfaces"));
131 return (memq != SCM_BOOL_F);