From 02110a551cd685e0324e52caaa75dc4e2f59e0f8 Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 30 May 2002 20:43:57 +0000 Subject: [PATCH] * 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. --- ChangeLog | 1 + lily/beam.cc | 25 +++++++++++++++++-------- lily/include/beam.hh | 2 +- lily/stem.cc | 13 ++++++++++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dee5cacb9..8acd7fad82 100644 --- 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. diff --git a/lily/beam.cc b/lily/beam.cc index 5c86fc16bb..59deeb40f4 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -25,7 +25,8 @@ */ - +/* snapnie now also works */ +#define SNAPNIE #include // 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 diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 3aac485374..3dca255c19 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -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*); }; diff --git a/lily/stem.cc b/lily/stem.cc index b2ffe3e86e..61f4688c28 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -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