+++ /dev/null
-/*
- axis-group.cc -- implement Graphical_axis_group
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "dimension-cache.hh"
-#include "interval.hh"
-#include "graphical-axis-group.hh"
-#include "axis-group-element.hh"
-#include "graphical-element.hh"
-#include "debug.hh"
-
-/** don't copy anything: an element can only be in one
- Graphical_axis_group at one time. */
-Graphical_axis_group::Graphical_axis_group(Graphical_axis_group const&s)
-{
- axes_[0] = s.axes_[0];
- axes_[1] = s.axes_[1];
- ordered_b_ = s.ordered_b_;
-}
-
-bool
-Graphical_axis_group::contains_b (Graphical_element const *e) const
-{
- return elem_l_arr_.find_l (e);
-}
-
-Interval
-Graphical_axis_group::extent (Axis axis) const
-{
- Interval r;
- for (int i=0; i < elem_l_arr_.size(); i++)
- {
- r.unite (elem_l_arr_[i]->extent (axis)
- + elem_l_arr_[i]->relative_coordinate (this, axis)
- );
- }
- return r;
-}
-
-void
-Graphical_axis_group::add_element (Graphical_element*e, Axis a1 , Axis a2)
-{
- used_b_ =true;
- e->used_b_ = true;
-
- Axis as[2] = {
- (a1 == NO_AXES) ? axes_[0] : a1,
- (a2 == NO_AXES) ? axes_[1] : a2,
- };
-
-
-
- for (int i = 0; i < 2; i++)
- {
- if (e->parent_l (as[i]))
- continue;
-
- e->set_parent (this, as[i]);
-
- // e->dim_cache_[as[i]]->dependencies_l_arr_.push (dim_cache_[as[i]]);
- }
- assert (e->parent_l(Y_AXIS) == this || e->parent_l (X_AXIS) == this);
- elem_l_arr_.push (e);
-}
-
-
-/**
- ugr. duplication of functionality with remove_all ()
- */
-void
-Graphical_axis_group::remove_element (Graphical_element*e)
-{
- assert (contains_b (e));
- if (ordered_b_)
- elem_l_arr_.substitute (e,0);
- else
- elem_l_arr_.unordered_substitute (e,0);
-
- do_remove (e);
-}
-
-void
-Graphical_axis_group::do_remove (Graphical_element *e)
-{
- for (int i=0; i< 2; i++)
- {
- Axis a=axes_[i];
- if (e->parent_l (a) != this)
- continue;
- e->set_parent (0, a);
- // e->dim_cache_[a]->dependencies_l_arr_.clear ();
- }
-}
-
-void
-Graphical_axis_group::remove_all ()
-{
- for (int i=0; i < elem_l_arr_.size(); i++)
- do_remove (elem_l_arr_[i]);
-
- elem_l_arr_.clear ();
-}
-
-
-void
-Graphical_axis_group::do_print() const
-{
-#ifndef NPRINT
- for (int i=0; i < elem_l_arr_.size(); i++)
- DEBUG_OUT << classname(elem_l_arr_[i]) << " ";
-#endif
-}
-
-Graphical_axis_group::Graphical_axis_group ()
-{
- ordered_b_ = false;
- axes_[0] = (Axis)-1 ;
- axes_[1] = (Axis)-1 ;
-}
-
-void
-Graphical_axis_group::set_axes (Axis a1, Axis a2)
-{
- axes_[0] = a1 ;
- axes_[1] = a2 ;
-}
+++ /dev/null
-/*
- graphical-element.cc -- implement Graphical_element
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "dimension-cache.hh"
-#include "graphical-element.hh"
-#include "graphical-axis-group.hh"
-#include "debug.hh"
-
-Graphical_element::Graphical_element ()
-{
- dim_cache_[X_AXIS] = new Dimension_cache;
- dim_cache_[Y_AXIS] = new Dimension_cache;
- used_b_ = false;
- init ();
-}
-
-Graphical_element::Graphical_element (Graphical_element const &s)
-{
- dim_cache_[X_AXIS] = new Dimension_cache (*s.dim_cache_[X_AXIS]);
- dim_cache_[Y_AXIS] = new Dimension_cache (*s.dim_cache_[Y_AXIS]);
-
- used_b_ = true;
- init ();
-}
-
-void
-Graphical_element::init ()
-{
- dim_cache_[X_AXIS]->elt_l_ = dim_cache_[Y_AXIS]->elt_l_ = this;
-}
-
-
-void
-Graphical_element::translate_axis (Real y, Axis a)
-{
- dim_cache_[a]->translate (y);
-}
-
-Real
-Graphical_element::relative_coordinate (Graphical_element const*e, Axis a) const
-{
- return dim_cache_[a]->relative_coordinate (e ? e->dim_cache_[a] : 0);
-}
-
-Graphical_element *
-Graphical_element::common_refpoint (Graphical_element const* s, Axis a) const
-{
- Dimension_cache *dim = dim_cache_[a]->common_refpoint (s->dim_cache_[a]);
- if (!dim)
- programming_error ("No common reference point");
- return dim ? dim->element_l () : 0;
-}
-
-void
-Graphical_element::translate (Offset offset)
-{
- translate_axis (offset[Y_AXIS], Y_AXIS);
- translate_axis (offset[X_AXIS], X_AXIS);
-}
-
-
-void
-Graphical_element::set_empty (bool b, Axis a1, Axis a2)
-{
- if (a1 != NO_AXES)
- dim_cache_[a1]->set_empty (b);
- if (a2 != NO_AXES)
- dim_cache_[a2]->set_empty (b);
-}
-
-/**
- Return true if empty in both A1 direction and A2 dir.
- */
-bool
-Graphical_element::empty_b (Axis a)
-{
- return dim_cache_[a]->empty_b ();
-}
-
-Interval
-Graphical_element::extent (Axis a) const
-{
- Dimension_cache const * d = dim_cache_[a];
-
- if (d->empty_b ())
- return Interval ();
-
- return d->get_dim ();
-}
-
-
-void
-Graphical_element::do_print () const
-{
-#ifndef NPRINT
- DEBUG_OUT << '\n';
-#endif
-}
-
-void
-Graphical_element::invalidate_cache (Axis a)
-{
- dim_cache_[a]->invalidate ();
-}
-
-Graphical_element*
-Graphical_element::parent_l (Axis a) const
-{
- Dimension_cache*d= dim_cache_[a]->parent_l_;
- return d ? d->elt_l_ : 0;
-}
-
-Graphical_element::~Graphical_element ()
-{
- delete dim_cache_[X_AXIS];
- delete dim_cache_[Y_AXIS];
-}
-
-Graphical_element *
-Graphical_element::common_refpoint (Link_array<Graphical_element> gs, Axis a) const
-{
- Dimension_cache * common = dim_cache_[a];
- for (int i=0; i < gs.size (); i++)
- {
- common = common->common_refpoint (gs[i]->dim_cache_[a]);
- }
-
- return common->element_l ();
-}
-
-char const *
-Graphical_element::name () const
-{
- return classname (this);
-}
-
-void
-Graphical_element::print () const
-{
-#ifndef NPRINT
- DEBUG_OUT << classname (this) << "{\n";
- do_print ();
- DEBUG_OUT << "}\n";
-#endif
-}
-
-void
-Graphical_element::set_parent (Graphical_element *g, Axis a)
-{
- dim_cache_[a]->parent_l_ = g ? g->dim_cache_[a]: 0;
-}
+++ /dev/null
-/*
- axis-group-administration.hh -- declare Graphical_axis_group
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef GRAPHICAL_AXIS_GROUP_HH
-#define GRAPHICAL_AXIS_GROUP_HH
-
-
-#include "parray.hh"
-#include "axes.hh"
-#include "real.hh"
-#include "lily-proto.hh"
-#include "graphical-element.hh"
-
-/**
- Treat a group of graphical elements as an aggegrate.
- */
-class Graphical_axis_group : public virtual Graphical_element {
-private:
-
- /// modify fields of E for removal.
- void do_remove (Graphical_element*e);
-public:
- // keep array in order.
- bool ordered_b_;
- Link_array<Graphical_element> elem_l_arr_;
- Axis axes_[2];
-
- Interval extent (Axis) const;
- virtual void do_print() const;
- Graphical_axis_group(Graphical_axis_group const&s);
- Graphical_axis_group ();
- virtual void set_axes (Axis,Axis);
- void remove_all ();
-
- bool contains_b (Graphical_element const *) const;
- void add_element (Graphical_element*, Axis = NO_AXES, Axis = NO_AXES);
- void remove_element (Graphical_element*);
-};
-
-#endif // Graphical_axis_group_HH