]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-column.cc
patch::: 1.3.44.jcn2
[lilypond.git] / lily / note-column.cc
index 7ed9936d149ea28b56f03432600942683d5c0a03..909629921cf1781571166e685764e92c8d7543c0 100644 (file)
@@ -3,8 +3,11 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
+#include <math.h>              // ceil
+
+#include "axis-group-interface.hh"
 #include "dot-column.hh"
 #include "note-column.hh"
 #include "beam.hh"
@@ -30,8 +33,8 @@ Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
   SCM s1 = p1->get_elt_property ("horizontal-shift");
   SCM s2 = p2->get_elt_property ("horizontal-shift");
 
-  int h1 = (s1 == SCM_UNDEFINED) ? 0 : gh_scm2int (s1);
-  int h2 = (s2 == SCM_UNDEFINED) ? 0 : gh_scm2int (s2);
+  int h1 = (gh_number_p (s1))?  gh_scm2int (s1) :0;
+  int h2 = (gh_number_p (s2)) ? gh_scm2int (s2):0;
   return h1 - h2;
 }
 
@@ -39,7 +42,8 @@ Note_column::Note_column()
 {
   set_elt_property ("rests", SCM_EOL);
   set_elt_property ("note-heads", SCM_EOL);  
-  set_axes (X_AXIS, Y_AXIS);
+  Axis_group_interface (this).set_interface ();
+  Axis_group_interface (this).set_axes (X_AXIS, Y_AXIS);
 }
 
 Stem *
@@ -89,7 +93,7 @@ Note_column::set_stem (Stem * stem_l)
   set_elt_property ("stem", stem_l->self_scm_);
 
   add_dependency (stem_l);
-  add_element (stem_l);
+  Axis_group_interface (this).add_element (stem_l);
 }
 
 
@@ -107,7 +111,7 @@ Note_column::add_head (Rhythmic_head *h)
       Group_interface gi (this, "note-heads");
       gi.add_element (nh);
     }
-  add_element (h);
+  Axis_group_interface (this).add_element (h);
 }
 
 /**
@@ -116,15 +120,13 @@ Note_column::add_head (Rhythmic_head *h)
 void
 Note_column::translate_rests (int dy_i)
 {
-  //  invalidate_cache (Y_AXIS);
-
   SCM s = get_elt_property ("rests");
   for (; gh_pair_p (s); s = gh_cdr (s))
     {
       Score_element * se = unsmob_element (gh_car (s));
       Staff_symbol_referencer_interface si (se);
 
-      se->translate_axis (dy_i * si.staff_line_leading_f ()/2.0, Y_AXIS);
+      se->translate_axis (dy_i * si.staff_space ()/2.0, Y_AXIS);
     }
 }
 
@@ -132,7 +134,7 @@ Note_column::translate_rests (int dy_i)
 void
 Note_column::set_dotcol (Dot_column *d)
 {
-  add_element (d);
+  Axis_group_interface (this).add_element (d);
 }
 
 /*
@@ -143,43 +145,46 @@ Note_column::set_dotcol (Dot_column *d)
   Should lookup
     
     rest -> stem -> beam -> interpolate_y_position ()
-    
 */
 
 void
-Note_column::do_post_processing ()
+Note_column::after_line_breaking ()
 {
   if (!stem_l () || !rest_b ())
     return;
 
   Beam * b = stem_l ()->beam_l ();
-  if (!b || !b->stem_count ())
+  if (!b || !b->visible_stem_count ())
     return;
   
   /* ugh. Should be done by beam.
      (what? should be done --jcn)
     scary too?: height is calculated during post_processing
    */
-  Real dy = 0;
-  Real y = 0;
+  Real beam_dy = 0;
+  Real beam_y = 0;
+
   SCM s = b->get_elt_property ("height");
-  if (s != SCM_UNDEFINED)
-    dy = gh_scm2double (s);
-    s = b->get_elt_property ("y-position");
-  if (s != SCM_UNDEFINED)
-    y = gh_scm2double (s);
+  if (gh_number_p (s))
+    beam_dy = gh_scm2double (s);
+  
+  s = b->get_elt_property ("y-position");
+  if (gh_number_p (s))
+    beam_y = gh_scm2double (s);
 
-  Real x0 = b->first_visible_stem ()->hpos_f ();
-  Real dydx = b->last_visible_stem ()->hpos_f () - x0;
+  
+  Real x0 = b->first_visible_stem ()->relative_coordinate (0, X_AXIS);
+  Real dx = b->last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+  Real dydx = beam_dy && dx ? beam_dy/dx : 0;
 
   Direction d = stem_l ()->get_direction ();
-  Real beamy = (stem_l ()->hpos_f () - x0) * dydx + y;
+  Real beamy = (stem_l ()->relative_coordinate (0, X_AXIS) - x0) * dydx + beam_y;
 
   s = get_elt_property ("rests");
   Score_element * se = unsmob_element (gh_car (s));
   Staff_symbol_referencer_interface si (se);
 
-  Real staff_space = si.staff_line_leading_f ();      
+  Real staff_space = si.staff_space ();      
   Real rest_dim = extent (Y_AXIS)[d]*2.0  /staff_space ;
 
   Real minimum_dist
@@ -187,7 +192,7 @@ Note_column::do_post_processing ()
   Real dist =
     minimum_dist +  -d  * (beamy - rest_dim) >? 0;
 
-  int stafflines = si.lines_i ();
+  int stafflines = si.line_count ();
 
   // move discretely by half spaces.
   int discrete_dist = int (ceil (dist ));
@@ -219,5 +224,4 @@ Note_column::first_head () const
 {
   Stem * st = stem_l ();
   return st?  st->first_head (): 0; 
-
 }