summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Solomon <mike@apollinemike.com>2012-06-15 08:37:47 +0200
committerMike Solomon <mike@apollinemike.com>2012-06-15 08:37:47 +0200
commitad0e41c6cd25db2643d1a3e25242d284d6f65e69 (patch)
tree1d327a1af7dc74cd158ef8a1b07fb80c7ff1afa9
parent251895f1816cf77d9caf9f5e1b3b53ea7c5c8d3b (diff)
Forbids slur and tie extrema points from getting to close.
-rw-r--r--input/regression/slur-tie-control-points.ly11
-rw-r--r--lily/include/slur-score-parameters.hh2
-rw-r--r--lily/slur-configuration.cc34
-rw-r--r--lily/slur-score-parameters.cc4
-rw-r--r--scm/layout-slur.scm2
5 files changed, 53 insertions, 0 deletions
diff --git a/input/regression/slur-tie-control-points.ly b/input/regression/slur-tie-control-points.ly
new file mode 100644
index 0000000000..a682a98522
--- /dev/null
+++ b/input/regression/slur-tie-control-points.ly
@@ -0,0 +1,11 @@
+\version "2.15.41"
+
+\header {
+ texidoc = "Slurs and ties should never share extremal control points.
+"
+}
+\paper { ragged-right = ##f }
+
+\relative c'' {
+ c1~( c2 g)
+}
diff --git a/lily/include/slur-score-parameters.hh b/lily/include/slur-score-parameters.hh
index 4799388542..75b1ae8e46 100644
--- a/lily/include/slur-score-parameters.hh
+++ b/lily/include/slur-score-parameters.hh
@@ -46,6 +46,8 @@ struct Slur_score_parameters
Real head_slur_distance_max_ratio_;
Real head_slur_distance_factor_;
Real encompass_object_range_overshoot_;
+ Real slur_tie_extrema_min_distance_;
+ Real slur_tie_extrema_min_distance_penalty_;
void fill (Grob *him);
};
diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc
index c446ca1a12..6095cdf35b 100644
--- a/lily/slur-configuration.cc
+++ b/lily/slur-configuration.cc
@@ -28,6 +28,7 @@
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "stem.hh"
+#include "tie.hh"
#include "warn.hh"
Bezier
@@ -316,6 +317,39 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
void
Slur_configuration::score_extra_encompass (Slur_score_state const &state)
{
+ // we find forbidden attachments
+ vector<Offset> forbidden_attachments;
+ for (vsize i = 0; i < state.extra_encompass_infos_.size (); i++)
+ if (Tie::has_interface (state.extra_encompass_infos_[i].grob_))
+ {
+ Grob *t = state.extra_encompass_infos_[i].grob_;
+ Grob *common_x = Grob::get_vertical_axis_group (t);
+ Real rp = t->relative_coordinate (common_x, X_AXIS);
+ SCM cp = t->get_property ("control-points");
+
+ Bezier b;
+ int j = 0;
+ for (SCM s = cp; scm_is_pair (s); s = scm_cdr (s))
+ {
+ b.control_[j] = ly_scm2offset (scm_car (s));
+ j++;
+ }
+ forbidden_attachments.push_back (Offset (b.control_[0]) + Offset (rp, 0));
+ forbidden_attachments.push_back (Offset (b.control_[3]) + Offset (rp, 0));
+ }
+
+ bool too_close = false;
+ for (vsize k = 0; k < forbidden_attachments.size (); k++)
+ for (LEFT_and_RIGHT (side))
+ if ((forbidden_attachments[k] - attachment_[side]).length () < state.parameters_.slur_tie_extrema_min_distance_)
+ {
+ too_close = true;
+ break;
+ }
+
+ if (too_close)
+ add_score (state.parameters_.slur_tie_extrema_min_distance_penalty_, "extra");
+
for (vsize j = 0; j < state.extra_encompass_infos_.size (); j++)
{
Drul_array<Offset> attachment = attachment_;
diff --git a/lily/slur-score-parameters.cc b/lily/slur-score-parameters.cc
index 6a0768e730..a8cbe4b7f9 100644
--- a/lily/slur-score-parameters.cc
+++ b/lily/slur-score-parameters.cc
@@ -78,4 +78,8 @@ Slur_score_parameters::fill (Grob *me)
= get_detail (details, ly_symbol2scm ("close-to-edge-length"));
encompass_object_range_overshoot_
= get_detail (details, ly_symbol2scm ("encompass-object-range-overshoot"));
+ slur_tie_extrema_min_distance_
+ = get_detail (details, ly_symbol2scm ("slur-tie-extrema-min-distance"));
+ slur_tie_extrema_min_distance_penalty_
+ = get_detail (details, ly_symbol2scm ("slur-tie-extrema-min-distance-penalty"));
}
diff --git a/scm/layout-slur.scm b/scm/layout-slur.scm
index 59b4e2a078..ff47dbb938 100644
--- a/scm/layout-slur.scm
+++ b/scm/layout-slur.scm
@@ -38,4 +38,6 @@
(edge-slope-exponent . 1.7)
(close-to-edge-length . 2.5)
(encompass-object-range-overshoot . 0.5)
+ (slur-tie-extrema-min-distance . 0.2)
+ (slur-tie-extrema-min-distance-penalty . 2)
))