]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
Fix 1519.
[lilypond.git] / lily / beam.cc
index 3197c7d29fb425572f2d2fac88ad4a7801238e46..58ac5d44d276d61fa98ec69eeada4a68feb71003 100644 (file)
 
 #include "beam.hh"
 
+#include "beam-scoring-problem.hh"
 #include "beaming-pattern.hh"
 #include "directional-element-interface.hh"
-#include "main.hh"
+#include "grob-array.hh"
 #include "international.hh"
 #include "interval-set.hh"
 #include "item.hh"
 #include "least-squares.hh"
 #include "lookup.hh"
+#include "main.hh"
 #include "misc.hh"
 #include "output-def.hh"
 #include "pointer-group-interface.hh"
@@ -52,7 +54,6 @@
 #include "staff-symbol-referencer.hh"
 #include "stem.hh"
 #include "warn.hh"
-#include "grob-array.hh"
 
 #if DEBUG_BEAM_SCORING
 #include "text-interface.hh" // debug output.
@@ -73,6 +74,12 @@ Beam_stem_segment::Beam_stem_segment ()
   dir_ = CENTER;
 }
 
+bool
+beam_segment_less (Beam_segment const& a, Beam_segment const& b)
+{
+  return a.horizontal_[LEFT] < b.horizontal_[LEFT];
+}
+
 Beam_segment::Beam_segment ()
 {
   vertical_count_ = 0;
@@ -329,6 +336,7 @@ operator <(Beam_stem_segment const &a,
 
 typedef map<int, vector<Beam_stem_segment> >  Position_stem_segments_map;
 
+// TODO - should store result in a property?
 vector<Beam_segment>
 Beam::get_beam_segments (Grob *me_grob, Grob **common)
 {
@@ -602,13 +610,6 @@ Beam::print (SCM grob)
 
 #if (DEBUG_BEAM_SCORING)
   SCM annotation = me->get_property ("annotation");
-  if (!scm_is_string (annotation))
-    {
-      SCM debug = me->layout ()->lookup_variable (ly_symbol2scm ("debug-beam-scoring"));
-      if (to_boolean (debug))
-       annotation = me->get_property ("quant-score");
-    }
-
   if (scm_is_string (annotation))
     {
       extract_grob_set (me, "stems", stems);
@@ -621,10 +622,13 @@ Beam::print (SCM grob)
       string str;
       SCM properties = Font_interface::text_font_alist_chain (me);
 
+      properties = scm_cons(scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-5), SCM_EOL),
+                            properties);
+      
       Direction stem_dir = stems.size () ? to_dir (stems[0]->get_property ("direction")) : UP;
 
       Stencil score = *unsmob_stencil (Text_interface::interpret_markup
-                                   (me->layout ()->self_scm (), properties, annotation));
+                                       (me->layout ()->self_scm (), properties, annotation));
 
       if (!score.is_empty ())
        {
@@ -1144,7 +1148,6 @@ Beam::slope_damping (SCM smob, SCM posns)
   if (normal_stem_count (me) <= 1)
     return posns;
 
-
   SCM s = me->get_property ("damping");
   Real damping = scm_to_double (s);
   Real concaveness = robust_scm2double (me->get_property ("concaveness"), 0.0);
@@ -1186,6 +1189,21 @@ Beam::slope_damping (SCM smob, SCM posns)
   return ly_interval2scm (pos);
 }
 
+
+MAKE_SCHEME_CALLBACK (Beam, quanting, 2);
+SCM
+Beam::quanting (SCM smob, SCM posns)
+{
+  Grob *me = unsmob_grob (smob);
+  Drul_array<Real> ys(0, 0);
+  ys = robust_scm2drul (posns, ys);
+  Beam_scoring_problem problem (me, ys);
+
+  ys = problem.solve ();
+  return ly_interval2scm (ys);
+}
+
+
 /*
   Report slice containing the numbers that are both in (car BEAMING)
   and (cdr BEAMING)
@@ -1607,6 +1625,7 @@ ADD_INTERFACE (Beam,
               "break-overshoot "
               "clip-edges "
               "concaveness "
+              "covered-grobs "
               "damping "
               "details "
               "direction "
@@ -1620,7 +1639,6 @@ ADD_INTERFACE (Beam,
               "neutral-direction "
               "normal-stems "
               "positions "
-              "quant-score "
               "quantized-positions "
               "shorten "
               "stems "