]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/graphical-axis-group.cc
release: 1.1.52
[lilypond.git] / lily / graphical-axis-group.cc
index 0912244897e55713a259c2135907a9ced1dbf571..484b25368d38973615f3549058e45176689a3246 100644 (file)
@@ -3,8 +3,9 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
+
 #include "interval.hh"
 #include "graphical-axis-group.hh"
 #include "axis-group-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)
+  Graphical_axis_group at one time. */
+Graphical_axis_group::Graphical_axis_group(Graphical_axis_group const&s)
 {
-  axis1_ = s.axis1_;
-  axis2_ = s.axis2_;
+  axes_ = s.axes_;
+  ordered_b_ = s.ordered_b_;
 }
 
 bool 
@@ -37,13 +38,18 @@ Graphical_axis_group::extent (Axis axis) const
 void
 Graphical_axis_group::add_element (Graphical_element*e)
 {
-  Graphical_axis_group *& g1 = e->axis_group_l_a_[axis1_];
-  Graphical_axis_group *& g2 = e->axis_group_l_a_[axis2_];
-  
-  assert (!g1 || g1 == this);
-  assert (!g2 || g2 == this);
-  g1 = this;
-  g2 = this;
+  used_b_ =true;
+  e->used_b_ = true;
+  for (int i = 0; i < 2; i++)
+    {
+      Axis a = axes_[i];
+      assert (a>=0);
+      Dimension_cache * &d = e->dim_cache_[a]->parent_l_;
+      assert (!d || d == dim_cache_[a]);
+      d = dim_cache_[a];
+      d->dependencies_l_arr_.push (dim_cache_[a]);
+    }
+
   elem_l_arr_.push (e);
 }
 
@@ -53,10 +59,18 @@ void
 Graphical_axis_group::remove_element (Graphical_element*e)
 {
   assert (contains_b (e));
-  elem_l_arr_.unordered_substitute (e,0);
+  if (ordered_b_)
+    elem_l_arr_.substitute (e,0);
+  else
+    elem_l_arr_.unordered_substitute (e,0);
   
-  e->axis_group_l_a_[axis1_] = 0;
-  e->axis_group_l_a_[axis2_] = 0;    
+  for (int i=0; i<  2; i++)
+    {
+      Axis a=axes_[i];
+      Dimension_cache * d = e->dim_cache_[a];
+      d->parent_l_ = 0;
+      d->dependencies_l_arr_.unordered_substitute (dim_cache_[a], 0);
+    }
 }
 
 void
@@ -65,8 +79,14 @@ Graphical_axis_group::remove_all ()
   for (int i=0; i < elem_l_arr_.size(); i++) 
     {
       Graphical_element*e=elem_l_arr_[i];
-      e->axis_group_l_a_[axis1_] = 0;
-      e->axis_group_l_a_[axis2_] = 0;  
+      for (int i=0; i<  2; i++)
+       {
+         Axis a=axes_[i];
+         Dimension_cache * d = e->dim_cache_[a];
+         d->parent_l_ = 0;
+         d->dependencies_l_arr_.clear ();
+       }
+      
     }
   elem_l_arr_.clear ();
 }
@@ -81,10 +101,16 @@ Graphical_axis_group::do_print() const
 #endif
 }
 
-Graphical_axis_group::Graphical_axis_group (Axis a1, Axis a2)
+Graphical_axis_group::Graphical_axis_group ()
 {
-  axis1_ =a1;
-  axis2_ = a2;
+  ordered_b_ = false;
+  axes_[0] = -1 ; 
+  axes_[1] = -1 ;
 }
 
-
+void
+Graphical_axis_group::set_axes (Axis a1, Axis a2)
+{
+  axes_[0] = a1 ; 
+  axes_[1] = a2 ;
+}