]> git.donarmstrong.com Git - lilypond.git/commitdiff
(write-system-signature): new routine: write
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 May 2006 01:07:55 +0000 (01:07 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 May 2006 01:07:55 +0000 (01:07 +0000)
python parseable signature of a separate paper system.

ChangeLog
VERSION
input/regression/figured-bass.ly
lily/figured-bass-engraver.cc
lily/grob-scheme.cc
lily/input-scheme.cc
scm/framework-eps.scm
scm/layout-page-layout.scm
scm/paper-system.scm
scm/stencil.scm
scripts/midi2ly.py

index 25f254c581124f9e4b5682274d9ab6102d20b93d..2aaa733ddf5b11cd2d4c1173bf33511815e6b37f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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()
diff --git a/VERSION b/VERSION
index eeddea6bb58b544ceaf5325834df7653050e5cc9..404fb35970dc01d8d6e6af43d0efada7ef663f42 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=9
-PATCH_LEVEL=6
+PATCH_LEVEL=7
 MY_PATCH_LEVEL=
 
index 9ff2e5224e2c3aade6dbbd5ddcc404e016066092..6b45751850d79561fb44db25035b43c9dad72c35 100644 (file)
@@ -31,6 +31,7 @@ You can also enter markup strings. The vertical alignment may also be tuned.
     <3+ 5- 7!>
     <3 _! 5 _- 7>
     <3 _ 5 _ 7>
+    <3 6/ >
     <"V7" ["bla" 6] \markup{ \musicglyph #"rests.2"} >
 
     \once \override BassFigureAlignment #'stacking-dir = #UP
index d6c5f78c26ec7d6fc6c3b1e1955c355ec2f1789b..158959eda8b20644a6710c4a101017473e1fc271 100644 (file)
@@ -278,6 +278,7 @@ Figured_bass_engraver::process_music ()
     {
       if (to_boolean (get_property ("figuredBassCenterContinuations")))
        center_repeated_continuations ();
+      
       alignment_ = 0;
       for (vsize i = 0; i < groups_.size (); i++)
        {
index d510a11bcb9a327f47db2fa0ad3c94fb70497080..c8bdc2c828d9d36a864e91c32504ea60fb5f0c6e 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "grob.hh"
 
-#include "warn.hh"
+#include "warn.hh"             // error()
 #include "item.hh"
 #include "output-def.hh"
 #include "system.hh"
index a13ca876e7998431653c8e4f6b16eac62292e8c6..6e954ef162fbd307be8b7fe2f5e5a60556622bd5 100644 (file)
@@ -13,7 +13,7 @@
    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;
 }
@@ -34,13 +34,18 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM
   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),
@@ -48,8 +53,11 @@ LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-char-column", 1, 0, 0,
                     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");
index 9a7036df3682fb08d5bdc68ce544774ffee3fd95..18464278dd8ea6b7f673a4c9cf363b8ef580d483 100644 (file)
@@ -95,8 +95,22 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
     (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))
index a0a35027a35ca50c3a6e36679927b161189e7184..8a7628af857519d7c1dc0ec0bb8c718db029ab27 100644 (file)
@@ -318,7 +318,7 @@ is what have collected so far, and has ascending page numbers."
 
       (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
@@ -343,6 +343,7 @@ CURRENT-BEST is the best result sofar, or #f."
                             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?)
index 70985aae6669d012d8ee6a54d7b8e2f76c4ef70a..d414285d9df3d75a5dde138f8905343f5f7164a7 100644 (file)
@@ -17,6 +17,9 @@
 (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))
 
index cdac70fcc861d79bf2a81e6cc75fa6f9317e09c7..539b9c849b32bfad8461e881edfa6c5554e14962 100644 (file)
@@ -268,3 +268,96 @@ grestore
        
        (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))))
index 364e37f375711720919f2a91d6b063e3f5bf7d76..256063d6795fdb60a0d6fabd1982c58bcc6686db 100644 (file)
@@ -25,7 +25,6 @@ import os
 import string
 import sys
 
-
 ################################################################
 # Users of python modules should include this snippet.
 #