]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam-quanting.cc
2003 -> 2004
[lilypond.git] / lily / beam-quanting.cc
index aff6e7bf8de8413fc9a16984a1131c3fb748d1d8..28af0c533611b622780ac4394615069a61c272cd 100644 (file)
@@ -3,9 +3,11 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
   
+
+  
 */
 
 
@@ -93,10 +95,15 @@ Beam::quanting (SCM smob)
   Real yl = gh_scm2double (gh_car (s));
   Real yr = gh_scm2double (gh_cdr (s));
 
-  Real ss = Staff_symbol_referencer::staff_space (me);
-  Real thickness = gh_scm2double (me->get_grob_property ("thickness")) / ss;
-  Real slt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")) / ss;
 
+  /*
+    Calculations are relative to a unit-scaled staff, i.e. the quants are
+    divided by the current staff_space.
+    
+   */
+  Real ss = Staff_symbol_referencer::staff_space (me);
+  Real thickness = Beam::get_thickness (me) / ss ;
+  Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
 
   SCM sdy = me->get_grob_property ("least-squares-dy");
   Real dy_mus = gh_number_p (sdy) ? gh_scm2double (sdy) : 0.0;
@@ -153,14 +160,17 @@ Beam::quanting (SCM smob)
   for (int i= 0; i < stems.size(); i++)
     {
       Grob*s = stems[i];
-      stem_infos.push (Stem::get_stem_info (s));
+
+      Stem_info si (Stem::get_stem_info (s));
+      si.scale (1 / ss);
+      stem_infos.push (si);
       dirs_found[stem_infos.top ().dir_] = true;
 
       bool f = to_boolean (s->get_grob_property ("french-beaming"))
         && s != lvs && s != fvs;
 
       base_lengths.push (calc_stem_y (me, s, common, xl, xr,
-                                     Interval (0,0), f));
+                                     Interval (0,0), f) / ss);
       stem_xposns.push (s->relative_coordinate (common[X_AXIS], X_AXIS));
     }
 
@@ -225,7 +235,7 @@ Beam::quanting (SCM smob)
 
   Real rad = Staff_symbol_referencer::staff_radius (me);
   int beam_count = get_beam_count (me);
-  Real beam_translation = get_beam_translation (me);
+  Real beam_translation = get_beam_translation (me) / ss;
 
   Real reasonable_score = (knee_b) ? 200000 : 100;
   for (int i = qscores.size (); i--;)
@@ -264,15 +274,14 @@ Beam::quanting (SCM smob)
   if (debug_beam_quanting_flag
       && gh_pair_p (inspect_quants))
     {
-      Real il = gh_scm2double (gh_car (inspect_quants));
-      Real ir = gh_scm2double (gh_cdr (inspect_quants));
+      Drul_array<Real> ins = ly_scm2interval (inspect_quants);
 
       int i = 0;
 
       Real mindist = 1e6;
       for (; i < qscores.size(); i ++)
        {
-         Real d =fabs (qscores[i].yl-il) + fabs (qscores[i].yr - ir);
+         Real d =fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]);
          if (d < mindist)
            {
              best_idx = i;
@@ -285,8 +294,8 @@ Beam::quanting (SCM smob)
 #endif
   
   me->set_grob_property ("positions",
-                        gh_cons (gh_double2scm (qscores[best_idx].yl),
-                                 gh_double2scm (qscores[best_idx].yr)));
+                        ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
+                                         qscores[best_idx].yr)));
 #if DEBUG_QUANTING
   if (debug_beam_quanting_flag)
     {