[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Allows for degree of feathering to be tweaked (issue4289052)
From: |
mtsolo |
Subject: |
Allows for degree of feathering to be tweaked (issue4289052) |
Date: |
Thu, 17 Mar 2011 11:34:47 +0000 |
Reviewers: ,
Message:
Makes degree of feathering tweakable.
Will need a convert-ly rule and several changes in various
regtests/docs, but it works.
Cheers,
Mike
Description:
Allows for degree of feathering to be tweaked
Please review this at http://codereview.appspot.com/4289052/
Affected files:
M lily/beam.cc
M lily/include/spanner.hh
M lily/spanner.cc
M scm/define-grob-properties.scm
M scm/define-grobs.scm
M scm/output-lib.scm
Index: lily/beam.cc
diff --git a/lily/beam.cc b/lily/beam.cc
index
e3135dadfa92609362dccfd467e5f164dde1bde7..795b322c194730dc67f3d51effc72705797b73f3
100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -588,7 +588,9 @@ Beam::print (SCM grob)
Real beam_thickness = get_beam_thickness (me);
Real beam_dy = get_beam_translation (me);
- Direction feather_dir = to_dir (me->get_property ("grow-direction"));
+ Interval feather_interval = robust_scm2interval (me->get_property
("feather-direction"), Interval (0.0, 0.0));
+ Real feather_dif = feather_interval[RIGHT] - feather_interval[LEFT];
+ int feather_dir = feather_dif == 0.0 ? 0 : int (feather_dif / fabs
(feather_dif));
Interval placements = robust_scm2interval (me->get_property
("normalized-endpoints"), Interval (0.0, 0.0));
@@ -1502,7 +1504,10 @@ Beam::set_stem_lengths (SCM smob)
Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
- Direction feather_dir = to_dir (me->get_property ("grow-direction"));
+
+ Interval feather_interval = robust_scm2interval (me->get_property
("feather-direction"), Interval (0.0, 0.0));
+ Real feather_dif = feather_interval[RIGHT] - feather_interval[LEFT];
+ int feather_dir = feather_dif == 0.0 ? 0 : int (feather_dif / fabs
(feather_dif));
for (vsize i = 0; i < stems.size (); i++)
{
@@ -1510,7 +1515,7 @@ Beam::set_stem_lengths (SCM smob)
bool french = to_boolean (s->get_property ("french-beaming"));
Real stem_y = calc_stem_y (me, s, common,
- xl, xr, feather_dir,
+ xl, xr, Direction (feather_dir),
pos, french && s != lvs && s!= fvs);
/*
@@ -1824,7 +1829,7 @@ ADD_INTERFACE (Beam,
"direction "
"gap "
"gap-count "
- "grow-direction "
+ "feather-direction "
"inspect-quants "
"knee "
"length-fraction "
Index: lily/include/spanner.hh
diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh
index
7bda060c864d20d3920837b0ce861fac92d2ee25..9122d46c7b80f30a43079e519511eb46e666fa99
100644
--- a/lily/include/spanner.hh
+++ b/lily/include/spanner.hh
@@ -49,6 +49,7 @@ class Spanner : public Grob
public:
DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
DECLARE_SCHEME_CALLBACK (calc_normalized_endpoints, (SCM));
+ DECLARE_SCHEME_CALLBACK (robust_calc_normalized_endpoints, (SCM, SCM,
SCM));
DECLARE_SCHEME_CALLBACK (bounds_width, (SCM));
DECLARE_SCHEME_CALLBACK (kill_zero_spanned_time, (SCM));
Index: lily/spanner.cc
diff --git a/lily/spanner.cc b/lily/spanner.cc
index
d3fd5a0955dd00df7cf78215f0452623748447c8..cc7642a5f840a633f5cd71cb66647998d192a918
100644
--- a/lily/spanner.cc
+++ b/lily/spanner.cc
@@ -402,7 +402,17 @@ MAKE_SCHEME_CALLBACK (Spanner,
calc_normalized_endpoints, 1);
SCM
Spanner::calc_normalized_endpoints (SCM smob)
{
+ return robust_calc_normalized_endpoints (smob, scm_from_double (0.0),
scm_from_double (1.0));
+}
+
+MAKE_SCHEME_CALLBACK (Spanner, robust_calc_normalized_endpoints, 3);
+SCM
+Spanner::robust_calc_normalized_endpoints (SCM smob, SCM l, SCM h)
+{
Spanner *me = unsmob_spanner (smob);
+ Real low = robust_scm2double (l, 0.0);
+ Real high = robust_scm2double (h, 1.0);
+
SCM result = SCM_EOL;
Spanner *orig = dynamic_cast<Spanner *> (me->original ());
@@ -430,7 +440,7 @@ Spanner::calc_normalized_endpoints (SCM smob)
for (vsize i = 0; i < unnormalized_endpoints.size (); i++)
{
- SCM t = ly_interval2scm (1 / total_width *
unnormalized_endpoints[i]);
+ SCM t = ly_interval2scm ((high - low) / total_width *
unnormalized_endpoints[i] + low);
orig->broken_intos_[i]->set_property ("normalized-endpoints", t);
if (me->get_break_index () == i)
result = t;
@@ -438,7 +448,7 @@ Spanner::calc_normalized_endpoints (SCM smob)
}
else
{
- result = scm_cons (scm_from_double (0.0), scm_from_double (1.0));
+ result = scm_cons (scm_from_double (low), scm_from_double (high));
orig->set_property ("normalized-endpoints", result);
}
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
83b327413dc1cb2eca4b3ea79283b1a79e21ab31..5ffcf33c1a14d4d052bac7c0e1bf443e2a055755
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -265,6 +265,7 @@ address@hidden by this much.")
;;
;; f
;;
+ (feather-direction ,pair? "Degree of feathering in or out?")
(flag ,ly:stencil? "A function returning the full flag stencil
for the @code{Stem}, which is passed to the function as the only
argument. The default ly:stem::calc-stencil function uses the
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index
8b9564f41e1776e00814887a7d4516b95dba4465..1e77fe47fb0cd2854743050e17ebde0e79da50f7
100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -366,7 +366,7 @@
(round-to-zero-slope . 0.02)))
(direction . ,ly:beam::calc-direction)
- (normalized-endpoints . ,ly:spanner::calc-normalized-endpoints)
+ (normalized-endpoints . ,beam::calc-normalized-endpoints)
;; only for debugging.
(font-family . roman)
Index: scm/output-lib.scm
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index
27c69fdfbe82eba10f1d3dcc20fe8156863c0926..c21c7a8d30d091019374e825d5c4837aa802363a
100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -57,6 +57,18 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; beams
+
+(define-public (beam::calc-normalized-endpoints grob)
+ (let* ((feather-dir (ly:grob-property grob 'feather-direction))
+ (feather-dir (if (> 0 (- (cdr feather-dir) (car feather-dir)))
+ (coord-translate (coord-scale feather-dir -1) 1)
+ feather-dir)))
+ (ly:spanner::robust-calc-normalized-endpoints grob
+ (car feather-dir)
+ (cdr feather-dir))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; note heads
(define-public (stem::calc-duration-log grob)
- Allows for degree of feathering to be tweaked (issue4289052),
mtsolo <=