From e3fa24f095381f36fdc5fa17494ec16b5cd18fe8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 1 Jan 2007 16:54:19 +0100 Subject: [PATCH] Fix #122. Add Stem::is_normal_stem(), which disregards stemlet-length. Use it for concaveness/slope calculations. --- input/regression/beam-slope-stemlet.ly | 22 ++++++++++++++++++++++ lily/beam-concave.cc | 6 +++--- lily/beam.cc | 7 ++++--- lily/include/stem.hh | 1 + lily/stem.cc | 8 ++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 input/regression/beam-slope-stemlet.ly diff --git a/input/regression/beam-slope-stemlet.ly b/input/regression/beam-slope-stemlet.ly new file mode 100644 index 0000000000..a0657e81c4 --- /dev/null +++ b/input/regression/beam-slope-stemlet.ly @@ -0,0 +1,22 @@ + +\header { + + texidoc = "For slope calculations, stemlets are treated +as invisible stems." + +} + +\version "2.10.7" + +\layout { + ragged-right = ##t + indent = #0 +} + +\relative c' { + \times 2/3 {r8[ c' g']} + \override Stem #'stemlet-length = #0.5 + \times 2/3 {r8[ c, g']} +} + + diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index ee351d0a26..a37005c17c 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -96,13 +96,13 @@ Beam::calc_concaveness (SCM smob) Direction beam_dir = CENTER; for (vsize i = stems.size (); i--;) { - if (Stem::is_invisible (stems[i])) - stems.erase (stems.begin () + i); - else + if (Stem::is_normal_stem (stems[i])) { if (Direction dir = get_grob_direction (stems[i])) beam_dir = dir; } + else + stems.erase (stems.begin () + i); } if (stems.size () <= 2) diff --git a/lily/beam.cc b/lily/beam.cc index 58fd432493..a2e7a3cb92 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -894,8 +894,9 @@ Beam::calc_least_squares_positions (SCM smob, SCM posns) for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; - if (Stem::is_invisible (s)) + if (!Stem::is_normal_stem (s)) continue; + ideals.push_back (Offset (x_posns[i], Stem::get_stem_info (s).ideal_y_ + s->relative_coordinate (commony, Y_AXIS) @@ -1287,7 +1288,7 @@ Beam::first_visible_stem (Grob *me) for (vsize i = 0; i < stems.size (); i++) { - if (!Stem::is_invisible (stems[i])) + if (Stem::is_normal_stem (stems[i])) return stems[i]; } return 0; @@ -1300,7 +1301,7 @@ Beam::last_visible_stem (Grob *me) for (vsize i = stems.size (); i--;) { - if (!Stem::is_invisible (stems[i])) + if (Stem::is_normal_stem (stems[i])) return stems[i]; } return 0; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 8808d16665..b3663b6eee 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -33,6 +33,7 @@ public: static Real thickness (Grob *); static int head_count (Grob *); static bool is_invisible (Grob *); + static bool is_normal_stem (Grob *); static Interval head_positions (Grob *); static Real stem_end_position (Grob *); static Stencil flag (Grob *); diff --git a/lily/stem.cc b/lily/stem.cc index d333690491..6757582869 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -222,6 +222,14 @@ Stem::is_invisible (Grob *me) && scm_to_int (me->get_property ("duration-log")) >= 1); } + +bool +Stem::is_normal_stem (Grob *me) +{ + return head_count (me) && scm_to_int (me->get_property ("duration-log")) >= 1; +} + + MAKE_SCHEME_CALLBACK (Stem, pure_height, 3) SCM Stem::pure_height (SCM smob, SCM start, SCM end) -- 2.39.5