2 axis-group-element.cc -- implement Axis_group_element
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "axis-group-element.hh"
10 #include "dimension-cache.hh"
11 #include "group-interface.hh"
13 Link_array
<Score_element
>
14 Axis_group_element::elem_l_arr () const
17 Group_interface__extract_elements (this, (Score_element
*)0, "elements");
20 Link_array
<Score_element
>
21 Axis_group_element::get_children ()
23 Link_array
<Score_element
> childs
;
24 Link_array
<Score_element
> elems
= elem_l_arr ();
26 for (int i
=0; i
< elems
.size (); i
++)
28 Score_element
* e
= elems
[i
];
30 Axis_group_element
* axis_group
= dynamic_cast <Axis_group_element
*> (e
);
32 childs
.concat (axis_group
->get_children ());
38 Axis_group_element::Axis_group_element()
40 set_elt_property ("elements", SCM_EOL
);
41 set_elt_property ("transparent", SCM_BOOL_T
);
45 Axis_group_element::set_axes (Axis a1
, Axis a2
)
47 SCM ax
= gh_cons (gh_int2scm (a1
), SCM_EOL
);
49 ax
= gh_cons (gh_int2scm (a2
), ax
);
52 set_elt_property ("axes", ax
);
54 if (a1
!= X_AXIS
&& a2
!= X_AXIS
)
56 if (a1
!= Y_AXIS
&& a2
!= Y_AXIS
)
59 dim_cache_
[a1
]->set_callback(extent_callback
);
60 dim_cache_
[a2
]->set_callback (extent_callback
);
64 Axis_group_element::extent_callback (Dimension_cache
const *c
)
67 Axis_group_element
* me
68 = dynamic_cast<Axis_group_element
*> (c
->element_l ());
71 for (SCM s
= me
->get_elt_property ("elements"); gh_pair_p (s
); s
= gh_cdr (s
))
74 Score_element
* se
= SMOB_TO_TYPE (Score_element
, e
);
76 Interval dims
= se
->extent (a
);
78 r
.unite (dims
+ se
->relative_coordinate (me
, a
));
86 Axis_group_element::axis_b (Axis a
)const
88 return dim_cache_
[a
]->extent_callback_l_
== extent_callback
;
93 Axis_group_element::add_element (Score_element
*e
)
98 for (SCM ax
= get_elt_property ("axes"); ax
!= SCM_EOL
; ax
= gh_cdr (ax
))
100 Axis a
= (Axis
) gh_scm2int (gh_car (ax
));
102 if (!e
->parent_l (a
))
103 e
->set_parent (this, a
);
105 Group_interface
gi (this);