From 3fc91138b05cfdd6b8446608eb1764cad85202f8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 16 Mar 2002 16:04:22 +0100 Subject: [PATCH] patch::: 1.5.41.jcn1 2002-03-16 Jan Nieuwenhuizen * lily/beam.cc (least_squares): Remember least-squares-dy for later use. (quantise_interval): Don't quant to dy steeper that least-squares-dy. Return empty interval if no sane quants found. (quantise_position): Try quantise_interval until we have acceptable solution. 2002-03-15 Jan Nieuwenhuizen * scm/interface-description.scm (beam-interface): Update. --- Generated by janneke@gnu.org, From = lilypond-1.5.41, To = lilypond-1.5.41.jcn1 usage cd lilypond-source-dir; patch -E -p1 < lilypond-1.5.41.jcn1.diff Patches do not contain automatically generated files or (urg) empty directories, i.e., you should rerun autoconf, configure --- ChangeLog | 20 +++++- VERSION | 2 +- lily/beam.cc | 117 +++++++++++++++++++++++----------- scm/beam.scm | 49 ++++++++++++++ scm/grob-description.scm | 5 +- scm/interface-description.scm | 16 ++--- 6 files changed, 159 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65cb32d322..46d1ad78bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,22 @@ -2002-03-15 Mats Bengtsson +--- ../lilypond-1.5.41/ChangeLog Fri Mar 15 15:44:50 2002 +++ b/ChangeLog Sat Mar 16 16:04:22 2002 +@@ -1,3 +1,16 @@ +2002-03-16 Jan Nieuwenhuizen + + * lily/beam.cc (least_squares): Remember least-squares-dy for + later use. + (quantise_interval): Don't quant to dy steeper that + least-squares-dy. Return empty interval if no sane quants found. + (quantise_position): Try quantise_interval until we have + acceptable solution. + +2002-03-15 Jan Nieuwenhuizen + + * scm/interface-description.scm (beam-interface): Update. + + 2002-03-15 Han-Wen Nienhuys + + * VERSION: 1.5.41 released2002-03-15 Mats Bengtsson * buildscripts/lilypond-profile.sh: diff --git a/VERSION b/VERSION index 8aa52a92e8..a8b541224c 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=41 -MY_PATCH_LEVEL=mb1 +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/beam.cc b/lily/beam.cc index 9f15cdc24e..67d9b664ce 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -368,6 +368,8 @@ Beam::least_squares (SCM smob) Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; Real dy = dydx * dx; + me->set_grob_property ("least-squares-dy", gh_double2scm (dy * dir)); + pos = Interval (y*dir, (y+dy) * dir); } @@ -428,6 +430,7 @@ Beam::check_concave (SCM smob) Interval pos = ly_scm2interval (me->get_grob_property ("positions")); Real r = pos.linear_combination (0); me->set_grob_property ("positions", ly_interval2scm (Interval (r, r))); + me->remove_grob_property ("least-squares-dy"); } return SCM_UNSPECIFIED; @@ -477,36 +480,38 @@ Beam::quantise_interval (Grob *me, Interval pos, Direction quant_dir) Real staff_space = Staff_symbol_referencer::staff_space (me); Real thick = me->paper_l ()->get_var ("stafflinethickness"); - - /* TODO: - - - left and right should be different, depending on direction and - multiplicity - - -use different left-position-quant-function, - right-position-quant-function for handier slope quanting? */ - SCM proc = me->get_grob_property ("vertical-position-quant-function"); - SCM quants = scm_apply (proc, - me->self_scm (), - scm_list_n (gh_int2scm (multiplicity), - gh_double2scm (1), /* junkme */ - gh_double2scm (thick / staff_space), - /* HUH? */ - SCM_EOL, - SCM_UNDEFINED)); - - Array a; - for (SCM i = quants; gh_pair_p (i); i = ly_cdr (i)) - a.push (gh_scm2double (ly_car (i))); - - if (a.size () <= 1) - return pos; - Direction dir = Directional_element_interface::get (me); - Interval left = quantise_iv (a, pos[LEFT]*dir/staff_space) * staff_space; - Interval right = quantise_iv (a, pos[RIGHT]*dir/staff_space) * staff_space; - Real dy = pos.delta (); + + Drul_array bounds; + Direction d = LEFT; + do + { + SCM proc = d == LEFT + ? me->get_grob_property ("left-position-quant-function") + : me->get_grob_property ("right-position-quant-function"); + + SCM quants = scm_apply (proc, + me->self_scm (), + scm_list_n (gh_int2scm (multiplicity), + gh_double2scm (dir), + gh_double2scm (dy), + gh_double2scm (thick / staff_space), + /* HUH? */ + SCM_EOL, + SCM_UNDEFINED)); + + Array a; + for (SCM i = quants; gh_pair_p (i); i = ly_cdr (i)) + a.push (gh_scm2double (ly_car (i))); + + if (a.size () <= 1) + return pos; + + bounds[d] = quantise_iv (a, pos[d]*dir/staff_space) * staff_space; + } + while (flip (&d) != LEFT); + Real ady = abs (dy); // quant direction hints disabled for now @@ -518,18 +523,28 @@ Beam::quantise_interval (Grob *me, Interval pos, Direction quant_dir) (save that value?) Slope should never be reduced to zero. */ - Interval qpos (0, 20.0 *sign (dy)); + SCM s = me->get_grob_property ("least-squares-dy"); + Real lsdy = gh_number_p (s) ? gh_scm2double (s) : 0; + + // Interval qpos (0, 1000 * sign (dy)); + Interval qpos; + Real epsilon = staff_space / 10; Direction ldir = LEFT; do { Direction rdir = LEFT; do { - Interval i (left[ldir]*dir, right[rdir]*dir); - if ((abs (abs (i.delta ()) - ady) <= abs (abs (qpos.delta ()) - ady) - && sign (i.delta ()) == sign (pos.delta ()) - && (!q - || (i[LEFT]*q >= pos[LEFT]*q && i[RIGHT]*q >= pos[RIGHT]*q)))) + Interval i (bounds[LEFT][ldir]*dir, bounds[RIGHT][rdir]*dir); + if ((!lsdy + || (abs (i.delta ()) <= abs (lsdy) + epsilon + && sign (i.delta ()) == sign (lsdy))) + && (abs (abs (i.delta ()) - ady) + <= abs (abs (qpos.delta ()) - ady)) + && sign (i.delta ()) == sign (pos.delta ()) + && (!q + || (i[LEFT]*q >= pos[LEFT]*q && i[RIGHT]*q + >= pos[RIGHT]*q))) qpos = i; } while (flip (&rdir) != LEFT); @@ -551,11 +566,30 @@ Beam::quantise_position (SCM smob) Interval pos = ly_scm2interval (me->get_grob_property ("positions")); Real y_shift = check_stem_length_f (me, pos); pos += y_shift; - pos = quantise_interval (me, pos, CENTER); + Real staff_space = Staff_symbol_referencer::staff_space (me); + + Direction dir = Directional_element_interface::get (me); + for (int i = 0; i < 10; i++) + { + Interval qpos = quantise_interval (me, pos, CENTER); + // how to check for uninitised interval, (inf, -inf)? + if (qpos[LEFT] < 1000) + { + y_shift = check_stem_length_f (me, qpos); + if (y_shift * dir < staff_space / 2) + { + pos = qpos; + break; + } + } + pos += ((i + 1) * ((i % 2) * -2 + 1)) * dir * staff_space / 4; + } + me->set_grob_property ("positions", ly_interval2scm (pos)); set_stem_lengths (me); +#if 0 pos = ly_scm2interval (me->get_grob_property ("positions")); y_shift = check_stem_length_f (me, pos); @@ -575,7 +609,8 @@ Beam::quantise_position (SCM smob) } me->set_grob_property ("positions", ly_interval2scm (pos)); - +#endif + return SCM_UNSPECIFIED; } @@ -668,13 +703,23 @@ Beam::check_stem_length_f (Grob *me, Interval pos) if (info.idealy_f_ - stem_y > 0) { +#if 0 ideal_lengthen += info.idealy_f_ - stem_y; ideal_lengthen_count++; +#else + ideal_lengthen = ideal_lengthen >? info.idealy_f_ - stem_y; + ideal_lengthen_count = 1; +#endif } else if (info.idealy_f_ - stem_y < 0) { +#if 0 ideal_shorten += info.idealy_f_ - stem_y; ideal_shorten_count++; +#else + ideal_shorten = ideal_shorten dy 0)))) + (set! quants (cons beam-hang quants))) + (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2))) + (set! quants (cons beam-straddle quants))) + ;; period: 1 (staff-space) + (append quants (list (+ 1 (car quants)))))) + +(define (default-right-beam-pos-quants beam multiplicity dir dy staff-line) + (default-beam-pos-quants beam multiplicity 1 staff-line)) + +(define (foo beam multiplicity dir dy staff-line) + (let* ((beam-straddle 0) + (thick (ly-get-grob-property beam 'thickness)) + (beam-sit (/ (- thick staff-line) 2)) + (beam-hang (- 1 (/ (- thick staff-line) 2))) + (quants '()) + ) + + + (if (or (<= multiplicity 1) + (and (not (equal? dir 1)) + (not (> dy 0)))) + (set! quants (cons beam-sit quants))) + (if (or (<= multiplicity 1) + (and (not (equal? dir -1)) + (not (< dy 0)))) + (set! quants (cons beam-hang quants))) + (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2))) + (set! quants (cons beam-straddle quants))) + ;; period: 1 (staff-space) + (append quants (list (+ 1 (car quants)))))) + (define (beam-traditional-pos-quants beam multiplicity dy staff-line) (let* ((beam-straddle 0) (thick (ly-get-grob-property beam 'thickness)) diff --git a/scm/grob-description.scm b/scm/grob-description.scm index fcb3f3b90f..c583c4c7cf 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -111,7 +111,8 @@ ,Beam::end_after_line_breaking)) (neutral-direction . -1) (dir-function . ,beam-dir-majority) - (vertical-position-quant-function . ,default-beam-pos-quants) + (left-position-quant-function . ,default-left-beam-pos-quants) + (right-position-quant-function . ,default-right-beam-pos-quants) (beamed-stem-shorten . (1.0 0.5)) (outer-stem-length-limit . 0.2) (slope-limit . 0.2) @@ -706,7 +707,7 @@ . ( (molecule-callback . ,Staff_symbol::brew_molecule) (staff-space . 1.0) - (line-count . 5) + (line-count . 15) (layer . 0) (meta . ,(grob-description staff-symbol-interface )) )) diff --git a/scm/interface-description.scm b/scm/interface-description.scm index dd05c80db0..38499a65b4 100644 --- a/scm/interface-description.scm +++ b/scm/interface-description.scm @@ -73,20 +73,16 @@ #'thickness= weight of beams, in staffspace " '(auto-knee-gap - staff-position - height - flag-width-function - damping - neutral-direction - thickness - space-function beamed-stem-shorten - height-quants - vertical-position-quant-function damping + flag-width-function + neutral-direction outer-stem-length-limit + positions slope-limit - auto-knee-gap + space-function + thickness + vertical-position-quant-function ) ) -- 2.39.5