From 43b558b9aad166a9f3f9b530520a3409c4c48fb1 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 47ee57bbf5..9965b4fd9e 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 51ce0967ea..332e6b4055 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -890,8 +890,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) @@ -1283,7 +1284,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; @@ -1296,7 +1297,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 3d06bca6f6..02f9e69a13 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 352c5ca419..a7c864b8b2 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -221,6 +221,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