python parseable signature of a separate paper system.
+2006-05-27 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+ * scm/stencil.scm (write-system-signature): new routine: write
+ python parseable signature of a separate paper system.
+
2006-05-26 Han-Wen Nienhuys <hanwen@lilypond.org>
* lily/stanza-number-engraver.cc (process_music): use is_markup()
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=9
-PATCH_LEVEL=6
+PATCH_LEVEL=7
MY_PATCH_LEVEL=
<3+ 5- 7!>
<3 _! 5 _- 7>
<3 _ 5 _ 7>
+ <3 6/ >
<"V7" ["bla" 6] \markup{ \musicglyph #"rests.2"} >
\once \override BassFigureAlignment #'stacking-dir = #UP
{
if (to_boolean (get_property ("figuredBassCenterContinuations")))
center_repeated_continuations ();
+
alignment_ = 0;
for (vsize i = 0; i < groups_.size (); i++)
{
#include "grob.hh"
-#include "warn.hh"
+#include "warn.hh" // error()
#include "item.hh"
#include "output-def.hh"
#include "system.hh"
implemented separately from the class. */
LY_DEFINE (ly_input, "ly:input-location?", 1, 0, 0,
(SCM x),
- "Return #t if @var{x} is an input location.")
+ "Is @var{x} an @code{input-location}?")
{
return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F;
}
return SCM_UNSPECIFIED;
}
-LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-char-column", 1, 0, 0, (SCM sip),
+
+LY_DEFINE (ly_input_file_line_column,
+ "ly:input-file-line-char-column",
+ 1, 0, 0, (SCM sip),
"Return input location in @var{sip} as (file-name line char column).")
{
Input *ip = unsmob_input (sip);
SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
- int l, ch, col;
+ int l = 0;
+ int ch = 0;
+ int col = 0;
ip->get_counts (&l, &ch, &col);
return scm_list_4 (scm_makfrom0str (ip->file_string ().c_str ()),
scm_from_int (l),
scm_from_int (col));
}
-LY_DEFINE (ly_input_both_locations, "ly:input-both-locations", 1, 0, 0, (SCM sip),
- "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).")
+LY_DEFINE (ly_input_both_locations,
+ "ly:input-both-locations",
+ 1, 0, 0, (SCM sip),
+ "Return input location in @var{sip} as "
+ "(file-name first-line first-column last-line last-column).")
{
Input *ip = unsmob_input (sip);
SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
(postprocess-output book framework-eps-module
(format "~a.eps" basename) (ly:output-formats)))
+
+(define (write-system-signatures basename paper-systems count)
+ (if (pair? paper-systems)
+ (begin
+ (let*
+ ((outname (format "~a-~a.signature" basename count)) )
+
+ (ly:message "writing ~a" outname)
+ (write-system-signature outname (car paper-systems))
+ (write-system-signatures basename (cdr paper-systems) (1+ count))))))
+
+
(define-public (output-classic-framework basename book scopes fields)
(output-scopes scopes fields basename)
+
+ (write-system-signatures basename (ly:paper-book-systems book) 0)
(dump-stencils-as-EPSes
(map paper-system-stencil (ly:paper-book-systems book))
(cons force positions)))
- (define (walk-paths done-lines best-paths current-lines last? current-best)
+ (define (walk-paths done-lines best-paths current-lines last? current-best)
"Return the best optimal-page-break-node that contains
CURRENT-LINES. DONE-LINES.reversed ++ CURRENT-LINES is a consecutive
ascending range of lines, and BEST-PATHS contains the optimal breaks
last?)))
(height (page-printable-height this-page))
(vertical-spacing (space-systems height current-lines ragged?))
+
(satisfied-constraints (car vertical-spacing))
(force (if satisfied-constraints
(if (and last? ragged-last?)
(define-public (paper-system-stencil system)
(ly:prob-property system 'stencil))
+(define-public (paper-system-system-grob paper-system)
+ (ly:prob-property paper-system 'system-grob))
+
(define-public (paper-system-extent system axis)
(ly:stencil-extent (paper-system-stencil system) axis))
(ly:make-stencil "" '(0 . 0) '(0 . 0)))
))
+
+
+(define-public (write-system-signature filename paper-system)
+ (define (float? x)
+ (and (number? x) (inexact? x)))
+
+ (define system-grob
+ (paper-system-system-grob paper-system))
+ (define output (open-output-file filename))
+
+ (define (strip-floats expr)
+ (cond
+ ((float? expr) #f)
+ ((ly:font-metric? expr) (ly:font-name expr))
+ ((pair? expr) (cons (strip-floats (car expr))
+ (strip-floats (cdr expr))))
+ (else expr)))
+
+ (define (fold-false-pairs expr)
+ (if (pair? expr)
+ (let*
+ ((first (car expr))
+ (rest (fold-false-pairs (cdr expr))))
+
+ (if first
+ (cons (fold-false-pairs first) rest)
+ rest))
+ expr))
+
+ (define (music-cause grob)
+ (let*
+ ((cause (ly:grob-property grob 'cause)))
+
+ (cond
+ ((ly:music? cause) cause)
+ ((ly:grob? cause) (music-cause cause))
+ (else #f))))
+
+ (define (pythonic-string expr)
+ (string-regexp-substitute "'" "\\'" (format "~a" expr)))
+
+ (define (pythonic-pair expr)
+ (format "(~a,~a)"
+ (car expr) (cdr expr)))
+
+ (define (found-grob expr)
+ (let*
+ ((grob (car expr))
+ (rest (cdr expr))
+ (collected '())
+ (cause (music-cause grob))
+ (input (if (ly:music? cause) (ly:music-property cause 'origin) #f))
+ (location (if (ly:input-location? input) (ly:input-file-line-char-column input) '()))
+
+ (x-ext (ly:grob-extent grob system-grob X))
+ (y-ext (ly:grob-extent grob system-grob Y))
+ )
+
+ (interpret-for-signature #f (lambda (e)
+ (set! collected (cons e collected)))
+ rest)
+
+ (format output
+ "['~a', '~a', ~a, ~a, '~a'],\n"
+ (cdr (assq 'name (ly:grob-property grob 'meta) ))
+ (pythonic-string location)
+ (pythonic-pair (if (interval-empty? x-ext) '(0 . 0) x-ext))
+ (pythonic-pair (if (interval-empty? y-ext) '(0 . 0) y-ext))
+ (pythonic-string collected))
+ ))
+
+ (define (interpret-for-signature escape collect expr)
+ (define (interpret expr)
+ (let*
+ ((head (car expr)))
+
+ (cond
+ ((eq? head 'grob-cause) (escape (cdr expr)))
+ ((eq? head 'color) (interpret (caddr expr)))
+ ((eq? head 'rotate-stencil) (interpret (caddr expr)))
+ ((eq? head 'translate-stencil) (interpret (caddr expr)))
+ ((eq? head 'combine-stencil)
+ (for-each (lambda (e) (interpret e)) (cdr expr)))
+ (else
+ (collect (ffold-false-pairs (strip-floats expr))))
+
+ )))
+
+ (interpret expr))
+
+ (interpret-for-signature found-grob (lambda (x) #f)
+ (ly:stencil-expr
+ (paper-system-stencil paper-system))))
import string
import sys
-
################################################################
# Users of python modules should include this snippet.
#