]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
release: 1.3.105
[lilypond.git] / lily / beam.cc
index 10bf8d82e8f3e3878f0eeb3822a54c4b45ff9421..f94c018083f6e3c8617c5649e13a09bca4c45f08 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <math.h> // tanh.
 
-
+#include "molecule.hh" 
 #include "directional-element-interface.hh"
 #include "beaming.hh"
 #include "beam.hh"
@@ -39,8 +39,7 @@
 void
 Beam::add_stem (Score_element*me, Score_element*s)
 {
-  Pointer_group_interface gi (me, "stems");
-  gi.add_element (s);
+  Pointer_group_interface:: add_element(me, "stems", s);
   
   s->add_dependency (me);
 
@@ -72,7 +71,7 @@ Beam::get_multiplicity (Score_element*me)
   [Alternatively, stems could set its own directions, according to
    their beam, during 'final-pre-processing'.]
  */
-MAKE_SCHEME_CALLBACK(Beam,before_line_breaking);
+MAKE_SCHEME_CALLBACK(Beam,before_line_breaking,1);
 SCM
 Beam::before_line_breaking (SCM smob)
 {
@@ -271,7 +270,7 @@ Beam::set_stem_shorten (Score_element*m)
   Set elt properties height and y-position if not set.
   Adjust stem lengths to reach beam.
  */
-MAKE_SCHEME_CALLBACK(Beam,after_line_breaking);
+MAKE_SCHEME_CALLBACK(Beam,after_line_breaking,1);
 SCM
 Beam::after_line_breaking (SCM smob)
 {
@@ -397,10 +396,9 @@ Beam::suspect_slope_b (Score_element*me, Real y, Real dy)
   /*
     steep slope running against lengthened stem is suspect
   */
-  Real ss = me->paper_l ()->get_var ("staffspace");
   Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
   Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_;
-  Real lengthened = gh_scm2double (me->get_elt_property ("outer-stem-length-limit")) * ss;
+  Real lengthened = gh_scm2double (me->get_elt_property ("outer-stem-length-limit"));
   Real steep = gh_scm2double (me->get_elt_property ("slope-limit"));
 
   // ugh -> use commonx
@@ -444,13 +442,11 @@ Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy)
   int beam_multiplicity = get_multiplicity (me);
   int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0;
 
-  Real staffspace = me->paper_l ()->get_var ("staffspace");
-  
   SCM space_proc = me->get_elt_property ("space-function");
   SCM space = gh_call1 (space_proc, gh_int2scm (beam_multiplicity));
 
-  Real thick = gh_scm2double (me->get_elt_property ("thickness")) *staffspace;
-  Real interbeam_f = gh_scm2double (space) * staffspace;
+  Real thick = gh_scm2double (me->get_elt_property ("thickness")) ;
+  Real interbeam_f = gh_scm2double (space) ;
 
   // ugh -> use commonx
   Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
@@ -554,7 +550,7 @@ Beam::quantise_dy_f (Score_element*me,Real dy)
   SCM proc = me->get_elt_property ("height-quants");
   SCM quants = gh_call2 (proc, me->self_scm (),
                         gh_double2scm (me->paper_l ()->get_var ("stafflinethickness")
-                                       / me->paper_l ()->get_var ("staffspace")));
+                                       / 1.0));
   
   
   for (SCM s = quants; gh_pair_p (s); s = gh_cdr (s))
@@ -652,13 +648,12 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
 
   Real staffline_f = me->paper_l ()->get_var ("stafflinethickness");
   int multiplicity = get_multiplicity (me);
-  Real staffspace =me->paper_l ()->get_var ("staffspace");
 
   SCM space_proc = me->get_elt_property ("space-function");
   SCM space = gh_call1 (space_proc, gh_int2scm (multiplicity));
 
-  Real thick = gh_scm2double (me->get_elt_property ("thickness")) *staffspace;
-  Real interbeam_f = gh_scm2double (space) * staffspace;
+  Real thick = gh_scm2double (me->get_elt_property ("thickness")) ;
+  Real interbeam_f = gh_scm2double (space) ;
     
   Real bdy = interbeam_f;
   Real stemdx = staffline_f;
@@ -681,7 +676,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
 
     SCM proc = me->get_elt_property ("flag-width-function");
     SCM result = gh_call1 (proc, gh_int2scm (t));
-    nw_f = gh_scm2double (result) * staffspace;
+    nw_f = gh_scm2double (result);
   }
 
 
@@ -700,7 +695,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
       w = w/2 <? nw_f;
       Molecule a;
       if (lhalfs)              // generates warnings if not
-       a =  me->lookup_l ()->beam (dydx, w, thick);
+       a =  Lookup::beam (dydx, w, thick);
       a.translate (Offset (-w, -w * dydx));
       for (int j = 0; j  < lhalfs; j++)
        {
@@ -716,7 +711,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
       int rwholebeams= Stem::beam_count (here,RIGHT) <? Stem::beam_count (next,LEFT) ;
 
       Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
-      Molecule a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
+      Molecule a = Lookup::beam (dydx, w + stemdx, thick);
       a.translate_axis( - stemdx/2, X_AXIS);
       int j = 0;
       Real gap_f = 0;
@@ -736,7 +731,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
          // TODO: notehead widths differ for different types
          gap_f = nw_f / 2;
          w -= 2 * gap_f;
-         a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
+         a = Lookup::beam (dydx, w + stemdx, thick);
        }
 
       for (; j  < rwholebeams; j++)
@@ -748,7 +743,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
 
       w = w/2 <? nw_f;
       if (rhalfs)
-       a = me->lookup_l ()->beam (dydx, w, thick);
+       a = Lookup::beam (dydx, w, thick);
 
       for (; j  < rwholebeams + rhalfs; j++)
        {
@@ -767,7 +762,7 @@ Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
   return leftbeams;
 }
 
-MAKE_SCHEME_CALLBACK(Beam,brew_molecule);
+MAKE_SCHEME_CALLBACK(Beam,brew_molecule,1);
 SCM
 Beam::brew_molecule (SCM smob)
 {
@@ -811,7 +806,7 @@ Beam::brew_molecule (SCM smob)
   mol.translate_axis (x0 
     - dynamic_cast<Spanner*> (me)->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
 
-  return mol.create_scheme ();
+  return mol.smobbed_copy ();
 }
 
 int
@@ -891,18 +886,22 @@ Beam::last_visible_stem(Score_element*me)
     
     rest -> stem -> beam -> interpolate_y_position ()
 */
-Real
-Beam::rest_collision_callback (Score_element *rest, Axis a )
+MAKE_SCHEME_CALLBACK(Beam,rest_collision_callback,2);
+SCM
+Beam::rest_collision_callback (SCM element_smob, SCM axis)
 {
+  Score_element *rest = unsmob_element (element_smob);
+  Axis a = (Axis) gh_scm2int (axis);
+  
   assert (a == Y_AXIS);
 
   Score_element * st = unsmob_element (rest->get_elt_property ("stem"));
   Score_element * stem = st;
   if (!stem)
-    return 0.0;
+    return gh_double2scm (0.0);
   Score_element * beam = unsmob_element (stem->get_elt_property ("beam"));
   if (!beam || !Beam::has_interface (beam) || !Beam::visible_stem_count (beam))
-    return 0.0;
+    return gh_double2scm (0.0);
 
   // make callback for rest from this.
   Real beam_dy = 0;
@@ -927,7 +926,9 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   Real beamy = (stem->relative_coordinate (0, X_AXIS) - x0) * dydx + beam_y;
 
   Real staff_space =   Staff_symbol_referencer::staff_space (rest);
-  Real rest_dim = rest->extent (Y_AXIS)[d]*2.0 / staff_space ;
+
+  
+  Real rest_dim = rest->extent (rest, Y_AXIS)[d]*2.0 / staff_space ; // refp??
 
   Real minimum_dist
     = gh_scm2double (rest->get_elt_property ("minimum-beam-collision-distance"));
@@ -943,7 +944,7 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   if (discrete_dist < stafflines+1)
     discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
 
-  return  (-d *  discrete_dist);
+  return gh_double2scm  (-d *  discrete_dist);
 }
 
 
@@ -956,9 +957,6 @@ Beam::has_interface (Score_element*me)
 void
 Beam::set_interface (Score_element*me)
 {
-  Pointer_group_interface g (me, "stems");
-  g.set_interface ();
-
   /*
     why the init? No way to tell difference between default and user
     override.  */