]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/beam.cc (score_stem_lengths): Bugfix for knees: use correct
authorjan <jan>
Thu, 30 May 2002 20:43:57 +0000 (20:43 +0000)
committerjan <jan>
Thu, 30 May 2002 20:43:57 +0000 (20:43 +0000)
(but alas, not partly precomputed) value for current_y when
calculating stem length demerits.
(calc_stem_y): Temporary precomputed factors fix.

* lily/stem.cc (calc_stem_info): Take multiplicity into account
for shortest_y too.

ChangeLog
lily/beam.cc
lily/include/beam.hh
lily/stem.cc

index 6dee5cacb9d020e1a247c817a5beb54e38b37d99..8acd7fad82a04d2d36e57cd0be51b32903dab612 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * lily/beam.cc (score_stem_lengths): Bugfix for knees: use correct
        (but alas, not partly precomputed) value for current_y when
        calculating stem length demerits.
+       (calc_stem_y): Temporary precomputed factors fix.
 
        * lily/stem.cc (calc_stem_info): Take multiplicity into account
        for shortest_y too.
index 5c86fc16bbfaf963b98278a5014e4533840eab8b..59deeb40f48b6b3b45da5b36df4c64c49f24693e 100644 (file)
@@ -25,7 +25,8 @@
   */
 
 
-
+/* snapnie now also works */
+#define SNAPNIE
 
 #include <math.h> // tanh.
 
@@ -452,10 +453,10 @@ Beam::quanting (SCM smob)
       dirs_found[stem_infos.top ().dir_] = true;
 
 #ifdef SNAPNIE
-      Real b = calc_stem_y (me, s, Interval (1,0));
+      Real b = calc_stem_y (me, s, Interval (1,0), false);
       lbase_lengths.push (b);
 
-      Real a = calc_stem_y (me, s, Interval (0,1));
+      Real a = calc_stem_y (me, s, Interval (0,1), false);
       rbase_lengths.push (a);
 #endif      
     }
@@ -992,12 +993,19 @@ Beam::slope_damping (SCM smob)
 /*
   Calculate the Y position of the stem-end, given the Y-left, Y-right
   in POS, and for stem S.
+
+  If CORRECT, correct for multiplicity of beam in case of knees.
  */
 Real
-Beam::calc_stem_y (Grob *me, Grob* s, Interval pos)
+Beam::calc_stem_y (Grob *me, Grob* s, Interval pos, bool correct)
 {
   int beam_multiplicity = get_multiplicity (me);
   int stem_multiplicity = (Stem::duration_log (s) - 2) >? 0;
+  
+  int first_multiplicity = (Stem::duration_log (first_visible_stem (me))
+                           - 2) >? 0;
+  int last_multiplicity = (Stem::duration_log (last_visible_stem (me))
+                          - 2) >? 0;
 
   Real thick = gh_scm2double (me->get_grob_property ("thickness"));
   Real interbeam = get_interbeam (me);
@@ -1008,14 +1016,14 @@ Beam::calc_stem_y (Grob *me, Grob* s, Interval pos)
   Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
   Real dy = pos.delta ();
   Real stem_y = (dy && dx
-                ? r / dx //(s->relative_coordinate (0, X_AXIS) - x0) / dx
+                ? r / dx
                 * dy
                 : 0) + pos[LEFT];
 
   Direction first_dir = Directional_element_interface::get (first_visible_stem (me));
   Direction my_dir = Directional_element_interface::get (s);
 
-  if (my_dir != first_dir)
+  if (correct && my_dir != first_dir)
     {
       /*
        WTF is happening here ?
@@ -1039,6 +1047,8 @@ Beam::calc_stem_y (Grob *me, Grob* s, Interval pos)
        --hwn.
        
        */
+      
+      // FIXME, hairy stuff
       stem_y += my_dir * (thick / 2 + (beam_multiplicity - 1) * interbeam);
 
       // huh, why not for first visible?
@@ -1057,7 +1067,6 @@ Beam::calc_stem_y (Grob *me, Grob* s, Interval pos)
       else
        programming_error ("No last visible stem");
     }
-
   return stem_y;
 }
 
@@ -1097,7 +1106,7 @@ Beam::set_stem_lengths (Grob *me)
       if (Stem::invisible_b (s))
        continue;
 
-      Real stem_y = calc_stem_y (me, s, pos);
+      Real stem_y = calc_stem_y (me, s, pos, true);
 
 #if 0
       // doesn't play well with dvips
index 3aac48537442b7a1c72034ec7eeef265f43ba11b..3dca255c19d77fbdab61d146055c59099ed67596 100644 (file)
@@ -54,7 +54,7 @@ private:
   static void set_stem_directions (Grob*, Direction );
   static void consider_auto_knees (Grob*, Direction d);
   static void set_stem_shorten (Grob*);
-  static Real calc_stem_y (Grob*, Grob* s, Interval pos);
+  static Real calc_stem_y (Grob*, Grob* s, Interval pos, bool correct);
   static void set_stem_lengths (Grob*);
   static int forced_stem_count (Grob*);
 };
index b2ffe3e86eb27b2084cc14319d1dcafe41cc5f50..61f4688c280012d6b572bb588810075d618350dd 100644 (file)
@@ -774,9 +774,11 @@ Stem::calc_stem_info (Grob*me)
   Real thick = gh_scm2double (beam->get_grob_property ("thickness"));
   
   Real ideal_y = chord_start_y (me);
+  
+  /* from here on, calculate as if dir == UP */
   ideal_y *= mydir;
+  
   SCM grace_prop = me->get_grob_property ("grace");
-
   
   bool grace_b = to_boolean (grace_prop);
   
@@ -798,9 +800,14 @@ Stem::calc_stem_info (Grob*me)
 
   Real stem_length =  a[multiplicity <? (a.size () - 1)] * staff_space;
 
-  if (multiplicity)
-    ideal_y += thick + (multiplicity - 1) * interbeam_f;
+  Direction first_dir = Directional_element_interface::get
+    (Beam::first_visible_stem (beam));
 
+  // FIXME, hairy.  see beam::calc_stem_y, for knees it's not trival
+  // to calculate where secondary, ternary beams will go.
+  if (multiplicity && first_dir == mydir)
+    ideal_y += thick + (multiplicity - 1) * interbeam_f;
+  
   Real shortest_y = ideal_y; 
 
   ideal_y += stem_length;