From fc2be417b37ab7e5a59b783950292a903c566b16 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 23 Jul 2002 21:32:50 +0000 Subject: [PATCH] * input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Warn when not using 6 systems, like the original. * lily/spanner.cc (get_broken_into): * lily/grob.cc (original_scm, line_scm): New function. * lily/include/grob.hh (ly_scm2grob_array): Moved from group-interface.hh and renamed. (ly_grob_array2scm): New function. --- ChangeLog | 14 +++++++++ .../J.S.Bach/baerenreiter-sarabande.ly | 20 +++++++++++- lily/grob.cc | 22 +++++++++++++ lily/include/grob.hh | 31 +++++++++++++++++++ lily/include/group-interface.hh | 18 ----------- lily/include/spanner.hh | 3 +- lily/slur.cc | 2 +- lily/spanner.cc | 20 ++++++++++++ 8 files changed, 109 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65be160e05..04f5f0a3f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-07-23 Jan Nieuwenhuizen + + * input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Warn when not + using 6 systems, like the original. + + * input/test/count-systems.ly: New file. + + * lily/spanner.cc (get_broken_into): + * lily/grob.cc (original_scm, line_scm): New function. + + * lily/include/grob.hh (ly_scm2grob_array): Moved from + group-interface.hh and renamed. + (ly_grob_array2scm): New function. + 2002-07-23 Juergen Reuter * lily/ambitus-engraver.cc: bugfix: create ambitus grob during diff --git a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly index baf7ce50b5..7c1a780c08 100644 --- a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly +++ b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly @@ -1,6 +1,19 @@ %% #(set! point-and-click line-column-location) +%% We want this to perfectly match the Baerenreiter spacing. +%% If we're not using 6 systems, there's definately a problem. +#(define (assert-system-count smob n) + (let ((systems (length (Spanner::get_broken_into + (Grob::original_scm + (Grob::line_scm smob)))))) + (if (not (equal? n systems)) + ;; Can't use error yet, as we know that we're not using 6... + ;;(error + (warn + (string-append "Got " (number->string systems) + " systems (expecting " (number->string n)))))) + \header { title = "Solo Cello Suite II" piece ="Sarabande" @@ -101,7 +114,12 @@ sarabandeA = \context Voice \notes \relative c { [a,8 e'] \oneVoice [d' cis] | - d4 d,,2 | + %% d4 d,,2 | + d4 + \property Thread.NoteHead + \override #'after-line-breaking-callback + = #(lambda (smob) (assert-system-count smob 6)) + d,,2 | } diff --git a/lily/grob.cc b/lily/grob.cc index 9394dac321..f4cb9937b1 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -308,6 +308,28 @@ Grob::line_l () const return 0; } +MAKE_SCHEME_CALLBACK (Grob, line_scm, 1); +SCM +Grob::line_scm (SCM smob) +{ + Grob *me = unsmob_grob (smob); + if (Grob *g = me->line_l ()) + return g->self_scm (); + + return SCM_EOL; +} + +MAKE_SCHEME_CALLBACK (Grob, original_scm, 1); +SCM +Grob::original_scm (SCM smob) +{ + Grob *me = unsmob_grob (smob); + if (me->original_l_) + return me->original_l_->self_scm (); + + return SCM_EOL; +} + void Grob::add_dependency (Grob*e) { diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 71921452e3..bc62ac7e25 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -154,6 +154,8 @@ public: Grob *get_parent (Axis a) const { return dim_cache_[a].parent_l_; } DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM)); + DECLARE_SCHEME_CALLBACK (original_scm, (SCM smob)); + DECLARE_SCHEME_CALLBACK (line_scm, (SCM smob)); }; DECLARE_UNSMOB(Grob,grob); @@ -167,5 +169,34 @@ void set_break_subsititution (SCM criterion); SCM substitute_mutable_property_alist (SCM alist); +/** Return Array of Grobs in SCM list L */ +inline Link_array +ly_scm2grob_array (SCM l) +{ + Link_array arr; + + for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + arr.push (unsmob_grob (e)); + } + + arr.reverse (); + return arr; +} + +#if 0 +/** Return SCM list of Grob array A */ +inline SCM +ly_grob_array2scm (Link_array a) +{ + SCM s = SCM_EOL; + for (int i = a.size (); i; i--) + s = gh_cons (a[i-1]->self_scm (), s); + + return s; +} +#endif + #endif // STAFFELEM_HH diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index 5ee3a085e5..7d88d5674e 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -35,24 +35,6 @@ struct Pointer_group_interface : public Group_interface { public: static void add_grob (Grob*, SCM nm, Grob*e); }; -/** - Put all score elements of ELT's property called NAME into an array, - and return it. */ - -inline Link_array -list_to_grob_array (SCM l) -{ - Link_array arr; - - for (SCM s = l; gh_pair_p (s); s = gh_cdr (s)) - { - SCM e = gh_car (s); - arr.push (unsmob_grob (e)); - } - - arr.reverse (); - return arr; -} template Link_array diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 5457c66638..cc0bd57753 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -33,7 +33,8 @@ class Spanner : public Grob { Drul_array spanned_drul_; public: - DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); + DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); + DECLARE_SCHEME_CALLBACK (get_broken_into, (SCM)); Link_array broken_into_l_arr_; diff --git a/lily/slur.cc b/lily/slur.cc index 1861eb18c4..424aa55765 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -462,7 +462,7 @@ Slur::get_encompass_offset_arr (Grob *me) common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT), X_AXIS); common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT), X_AXIS); - Link_array encompass_arr = list_to_grob_array (eltlist); + Link_array encompass_arr = ly_scm2grob_array (eltlist); Array offset_arr; Offset origin (me->relative_coordinate (common[X_AXIS], X_AXIS), diff --git a/lily/spanner.cc b/lily/spanner.cc index 0c11f2833a..7cae376694 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -19,6 +19,26 @@ #include "system.hh" #include "group-interface.hh" + +MAKE_SCHEME_CALLBACK (Spanner, get_broken_into, 1); +SCM +Spanner::get_broken_into (SCM smob) +{ + if (Spanner *me = dynamic_cast (unsmob_grob (smob))) +#if 0 + return ly_grob_array2scm (me->broken_into_l_arr_); +#else + { + SCM s = SCM_EOL; + for (int i = me->broken_into_l_arr_.size (); i; i--) + s = gh_cons (me->broken_into_l_arr_[i-1]->self_scm (), s); + return s; + } +#endif + + return SCM_EOL; +} + void Spanner::do_break_processing () { -- 2.39.2