From: Han-Wen Nienhuys Date: Sun, 28 Nov 2004 12:12:07 +0000 (+0000) Subject: * lily/simple-spacer.cc (add_columns): use binary search for X-Git-Tag: release/2.5.14~485 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=2ec5f924eb75dfc6b584a8df25a03bdfde31fc6c;p=lilypond.git * lily/simple-spacer.cc (add_columns): use binary search for setting column rods. Changes O(n^2) to O(n log(n)) for constructing spacing problem from columns. (add_columns): read allow-outside-line to make sure no texts stick out. (solve): Simple_spacer::is_active() only determines satisfies_constraints_ for non-ragged typesetting. * lily/simultaneous-music.cc (to_relative_octave): only set old_relative_used if return pitch actually changed. * scm/define-context-properties.scm (all-user-translation-properties): change to match implementation. * python/lilylib.py: Replace re.match by re.search and adds "-c showpage" to the gs command line (Johannes Schindelin) --- diff --git a/ChangeLog b/ChangeLog index 7ab7307e70..24489e3e89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ 2004-11-28 Han-Wen Nienhuys + * input/regression/spacing-stick-out.ly: new file. + + * lily/simple-spacer.cc (add_columns): use binary search for + setting column rods. Changes O(n^2) to O(n log(n)) for + constructing spacing problem from columns. + (add_columns): read allow-outside-line to make sure no texts stick + out. + (solve): Simple_spacer::is_active() only determines + satisfies_constraints_ for non-ragged typesetting. + + * lily/simultaneous-music.cc (to_relative_octave): only set + old_relative_used if return pitch actually changed. + + * scm/define-context-properties.scm + (all-user-translation-properties): change to match implementation. + + * python/lilylib.py: Replace re.match by re.search and adds "-c + showpage" to the gs command line (Johannes Schindelin) + + * scm/framework-ps.scm (output-preview-framework): sanitize bbox + before processing. Prevents crash when inf is in the extent. + * scm/define-markup-commands.scm (note-by-number): add "s" to "noteheads-" glyphname. diff --git a/THANKS b/THANKS index 54320d25a0..c421f10db8 100644 --- a/THANKS +++ b/THANKS @@ -23,6 +23,7 @@ Jonathan Walther BUG HUNTERS/SUGGESTIONS +Johannes Schindelin Andreas Scherer Arjan Bos Fernando Pablo Lopez-Lezcano diff --git a/flower/include/parray.hh b/flower/include/parray.hh index f70d2197b2..67ce868a70 100644 --- a/flower/include/parray.hh +++ b/flower/include/parray.hh @@ -235,7 +235,7 @@ junk_pointers (Link_array &a) */ template int -binsearchs (Array const &arr, T t, int (*compare) (T const&,T const&)) +binsearch (Array const &arr, T t, int (*compare) (T const&,T const&)) { int lo; int hi; diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index b88e6f94ca..8845454aa1 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -7,10 +7,10 @@ */ -#include "accidental-placement.hh" - #include + +#include "accidental-placement.hh" #include "libc-extension.hh" // isinf #include "skyline.hh" #include "music.hh" diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index c4967edfd3..76f1fda1b2 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -44,9 +44,7 @@ Axis_group_engraver::process_music () if (!staffline_) { staffline_ = get_spanner (); - Grob * it = unsmob_grob (get_property ("currentCommandColumn")); - staffline_->set_bound (LEFT,it); } } @@ -106,9 +104,7 @@ Axis_group_engraver::process_acknowledged_grobs () for (int i=0; i < elts_.size (); i++) { - Grob *par = elts_[i]->get_parent (Y_AXIS); - - if (!par || !Axis_group_interface::has_interface (par)) + if (!unsmob_grob (elts_[i]->get_property ("axis-group-parent-Y"))) { if (staffline_->get_parent (Y_AXIS) && staffline_->get_parent (Y_AXIS) == elts_[i]) diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index fbac83ee5b..6a336f1efe 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -8,7 +8,6 @@ */ #include "axis-group-interface.hh" - #include "hara-kiri-group-spanner.hh" void @@ -20,8 +19,14 @@ Axis_group_interface::add_element (Grob*me,Grob *e) if (!e->get_parent (a)) e->set_parent (me, a); - } + e->internal_set_property ((a == X_AXIS) + ? ly_symbol2scm ("axis-group-parent-X") + : ly_symbol2scm ("axis-group-parent-Y"), + me->self_scm () + ); + } + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e); me->add_dependency (e); } diff --git a/lily/bar-line.cc b/lily/bar-line.cc index 54c1321ac3..3489aff6be 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -6,10 +6,10 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "bar-line.hh" #include +#include "bar-line.hh" #include "lookup.hh" #include "paper-column.hh" #include "output-def.hh" diff --git a/lily/beam.cc b/lily/beam.cc index d5ee204fd0..92d9f4979e 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -26,10 +26,10 @@ Notes: */ -#include "beam.hh" #include // tanh. +#include "beam.hh" #include "interval-set.hh" #include "directional-element-interface.hh" #include "beaming.hh" diff --git a/lily/bezier.cc b/lily/bezier.cc index 40fd5f7ac0..806d385531 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -6,10 +6,10 @@ (c) 1998--2004 Jan Nieuwenhuizen */ -#include "bezier.hh" #include +#include "bezier.hh" #include "warn.hh" #include "libc-extension.hh" diff --git a/lily/binary-source-file.cc b/lily/binary-source-file.cc index 2e45fb557c..4035472227 100644 --- a/lily/binary-source-file.cc +++ b/lily/binary-source-file.cc @@ -6,11 +6,9 @@ (c) 1997--2004 Jan Nieuwenhuizen */ - -#include "binary-source-file.hh" - #include // INT_MAX +#include "binary-source-file.hh" #include "string-convert.hh" Binary_source_file::Binary_source_file (String& file_name_string) diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc index c8ed412989..b3f5a786a9 100644 --- a/lily/break-align-interface.cc +++ b/lily/break-align-interface.cc @@ -6,10 +6,10 @@ (c) 1997--2004 Han-Wen Nienhuys */ -#include "break-align-interface.hh" #include +#include "break-align-interface.hh" #include // isinf #include "self-alignment-interface.hh" diff --git a/lily/custos.cc b/lily/custos.cc index 8ea02b4b1c..758890fdf1 100644 --- a/lily/custos.cc +++ b/lily/custos.cc @@ -14,11 +14,10 @@ */ -#include "custos.hh" - #include #include // rint +#include "custos.hh" #include "direction.hh" #include "staff-symbol-referencer.hh" #include "warn.hh" diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 8a1140c290..0527642325 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -6,10 +6,10 @@ (c) 1998--2004 Han-Wen Nienhuys */ -#include "dimension-cache.hh" #include +#include "dimension-cache.hh" #include "warn.hh" #include "grob.hh" diff --git a/lily/grob.cc b/lily/grob.cc index c2d6a2d049..030ce6ce6b 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -660,6 +660,13 @@ Grob::internal_has_interface (SCM k) return scm_c_memq (k, ifs) != SCM_BOOL_F; } +Grob* +Grob::get_parent (Axis a) const +{ + return dim_cache_[a].parent_; +} + + /** Return Array of Grobs in SCM list LST */ Link_array ly_scm2grobs (SCM lst) @@ -731,8 +738,11 @@ ADD_INTERFACE (Grob, "grob-interface", "Y-extent-callback print-function extra-offset spacing-procedure " "context staff-symbol interfaces dependencies X-extent Y-extent extra-X-extent " "meta layer before-line-breaking-callback " + "axis-group-parent-X " + "axis-group-parent-Y " "after-line-breaking-callback extra-Y-extent minimum-X-extent " "minimum-Y-extent transparent tweak-count tweak-rank" ); + diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 503f5c307b..f77bd09480 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -125,11 +125,7 @@ public: void set_parent (Grob* e, Axis); // URG - Grob *get_parent (Axis a) const - { - return dim_cache_[a].parent_; - } - + Grob *get_parent (Axis a) const; DECLARE_SCHEME_CALLBACK (fixup_refpoint, (SCM)); }; diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 221a32ec07..bfd7c065c6 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -177,7 +177,9 @@ Score_engraver::typeset_all () if (dynamic_cast (elem)) { - if (!elem->get_parent (X_AXIS) + if ( + (!elem->get_parent (X_AXIS) + || !unsmob_grob (elem->get_property ("axis-group-parent-X"))) && elem != command_column_ && elem != musical_column_ ) diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 5a03cbb483..cada127e14 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -408,12 +408,11 @@ Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged) positions->satisfies_constraints_ = positions->config_.top () < spacer_->line_len_ ; } - + else + positions->satisfies_constraints_ = spacer_->is_active (); positions->cols_ = spaced_cols_; positions->loose_cols_ = loose_cols_; - positions->satisfies_constraints_ = - positions->satisfies_constraints_ && spacer_->is_active (); /* Check if breaking constraints are met. @@ -468,6 +467,13 @@ Simple_spacer::add_spring (Real ideal, Real hooke) springs_.push (desc); } +static int +compare_paper_column_rank (Grob *const &a, + Grob *const &b) +{ + return Paper_column::get_rank (a) - Paper_column::get_rank (b); +} + void Simple_spacer_wrapper::add_columns (Link_array const &icols) { @@ -513,12 +519,20 @@ Simple_spacer_wrapper::add_columns (Link_array const &icols) scm_is_pair (s); s = scm_cdr (s)) { Grob * other = unsmob_grob (scm_caar (s)); - int oi = cols.find_index (other); + int oi = binsearch_links (cols, other, &compare_paper_column_rank); if (oi >= 0) { spacer_->add_rod (i, oi, scm_to_double (scm_cdar (s))); } } + + if (i + && !to_boolean (cols[i]->get_property ("allow-outside-line"))) + { + Interval e = cols[i]->extent (cols[i], X_AXIS); + spacer_->add_rod (i, cols.size()-1, e[RIGHT]); + spacer_->add_rod (0, i, e[LEFT]); + } } } diff --git a/lily/simultaneous-music.cc b/lily/simultaneous-music.cc index 7e2a480e54..ccf3287ab5 100644 --- a/lily/simultaneous-music.cc +++ b/lily/simultaneous-music.cc @@ -32,10 +32,17 @@ Simultaneous_music::Simultaneous_music () Pitch Simultaneous_music::to_relative_octave (Pitch p) { + Pitch retval = music_list_to_relative (music_list (), p, false); if (lily_1_8_relative) - lily_1_8_compatibility_used = true; - - return music_list_to_relative (music_list (), p, lily_1_8_relative); + { + Pitch retval_1_8 = music_list_to_relative (music_list (), p, true); + if (retval_1_8 != retval) + lily_1_8_compatibility_used = true; + + retval = retval_1_8; + } + + return retval; } ADD_MUSIC (Simultaneous_music); diff --git a/mf/feta-test-generic.mf b/mf/feta-test-generic.mf index e14b4e6cc3..ae432902d8 100644 --- a/mf/feta-test-generic.mf +++ b/mf/feta-test-generic.mf @@ -3,44 +3,64 @@ % in a separate file to avoid tainting non-test font files for testing. % % - - -fet_beginchar("espr", "espr", "espressivo") +fet_beginchar("> accent", "sforzato", "sforzatoaccent") set_char_box(.9 staff_space#, .9 staff_space#, .5 staff_space#, .5 staff_space#); save thickness, diminish; + thickness = 0.05 staff_space + linethickness; pickup pencircle scaled thickness; - t = thickness; - diminish = .75; - top z1 =(0.2 staff_space,h); - rt z3 =(w*2,0); - bot y5 =-h; - x5 = x1; - x2 = .5[x1,x3]; - x4 = .5[x5,x3]; - z2 = whatever[z1,z3]; - z4 = whatever[z5,z3]; - penpos1(t,90); - penpos2(t,90); - penpos5(t,90); - penpos4(t,90); - penpos3(diminish*t,90); - draw z1 .. z2; - draw z5 .. z4; - penstroke z4e .. z3e; - penstroke z2e .. z3e; - draw (z1 .. z2) xscaled -1; - draw (z5 .. z4) xscaled -1; - penstroke (z4e .. z3e) xscaled -1; - penstroke (z2e .. z3e) xscaled -1; - penlabels(1,2,3,4,5); - pickup pencircle scaled (diminish* thickness); - draw z3; - draw z3 xscaled -1; + % prevent blobs at crossing lines + diminish = 1.0; + + top y1 = h; + lft x1 = -b; + rt x2 = w; + y2 = .25 thickness* diminish; + + rt z4 = (w,0); + x3 = - linethickness + 0.1 staff_space; + z3 = whatever [z1, z4]; + + penpos2(thickness*(2 - diminish)/2 , 90); + penpos1(thickness, 90); + penpos3(thickness, 90); + + draw z1 .. z3; + draw (z1 .. z3) yscaled -1; + draw z4; + penstroke z3e .. z2e; + penstroke (z3e .. z2e) yscaled -1; + + penlabels(1,2,3); + labels(4); fet_endchar; +fet_beginchar("espr", "espr", "espressivo") + set_char_box(1.9 staff_space#, 1.9 staff_space#, .5 staff_space#, .5 staff_space#); + save thickness, diminish; + thickness = 0.05 staff_space + linethickness; + pickup pencircle scaled thickness; + t = thickness; + diminish = .1; + top z1 =(0.2 staff_space,h); + rt z3 =(w,0); + x2 = .5[x1,x3]; + z2 = whatever[z1,z3]; + penpos1(t,90); + penpos2(t,90); + penpos3(diminish*t,90); + draw z1 .. z2; + penstroke z2e .. z3e; + penlabels(1,2,3); + pickup pencircle scaled (diminish* thickness); + draw z3; + addto currentpicture also currentpicture xscaled -1; + addto currentpicture also currentpicture yscaled -1; + +fet_endchar; + input feta-bolletjes; %input feta-banier; %input feta-slag; diff --git a/python/lilylib.py b/python/lilylib.py index 0718cb64db..04efae76b1 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -447,7 +447,7 @@ BOUNDING_BOX_RE = '^%%BoundingBox: (-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)' def get_bbox (filename): bbox = filename + '.bbox' ## -sOutputFile does not work with bbox? - cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c quit 2>%s' % \ + cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c showpage -c quit 2>%s' % \ (filename, bbox) system (cmd, progress_p = 1) box = open (bbox).read () @@ -467,7 +467,7 @@ def make_ps_images (ps_name, resolution = 90): header = open (ps_name).read (1024) - match = re.match (BOUNDING_BOX_RE, header) + match = re.search (BOUNDING_BOX_RE, header, re.MULTILINE) bbox = [] if match: bbox = map (string.atoi, match.groups ()) @@ -501,7 +501,7 @@ def make_ps_images (ps_name, resolution = 90): if y == 0: y = 1 - cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c quit ''' % \ + cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c showpage -c quit ''' % \ (x, y, output_file, resolution, trans_ps, ps_name) rms = glob.glob (base + '-page*.png') @@ -513,7 +513,7 @@ def make_ps_images (ps_name, resolution = 90): if os.path.isfile (rmfile): os.unlink (rmfile) - cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c quit''' % (output_file, + cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c showpage -c quit''' % (output_file, resolution, ps_name) status = system (cmd) diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 04334c50e5..3d13d2fe1f 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -300,8 +300,8 @@ context.") (rehearsalMark ,integer? "The last rehearsal mark printed.") (repeatCommands ,list? "This property is read to find any command of the form @code{(volta . @var{x})}, where @var{x} is a string or @code{#f}") (restNumberThreshold ,number? - "If a multimeasure rest takes less -than this number of measures, no number is printed. ") + "If a multimeasure rest has more measures +than this, a number is printed. ") (shapeNoteStyles ,vector? "Vector of symbols, listing style for each note head relative to the tonic (qv.) of the scale.") (skipBars ,boolean? "If set to true, then diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 757d91279f..fca647c368 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -268,7 +268,9 @@ slur. If set to false, the script places itself around the slur. If unset, script and slur ignore each other ") (inspect-quants ,number-pair? "If debugging is set, set beam quant to this position, and print the respective scores.") - + + (allow-outside-line ,boolean? "If set, allow this column to +things sticking into the margin.") (kern ,ly:dimension? "Amount of extra white space to add. For bar line, this is the amount of space after a thick line.") (knee ,boolean? "Is this beam kneed?") @@ -516,7 +518,8 @@ sizes (like the dynamic @b{p} and @b{f}) on their baselines.") (apply define-internal-grob-property x)) `( - + (axis-group-parent-X ,ly:grob? "Containing X axis group") + (axis-group-parent-Y ,ly:grob? "Containing Y axis group") (accidental-grobs ,list? "Alist with (NOTENAME . GROBLIST) entries") (adjacent-hairpins ,grob-list? "List of directly neighboring hairpins") (after-line-breaking-callback ,procedure? "This procedure is called after line breaking. Its return value is ignored.")