]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/stencil.scm (annotate-y-interval): robustify: print nan/inf
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 19 Feb 2006 12:38:02 +0000 (12:38 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 19 Feb 2006 12:38:02 +0000 (12:38 +0000)
markers when necessary.

* lily/program-option.cc (internal_set_option): add
strict_infinity_checking option.

ChangeLog
lily/include/main.hh
lily/program-option.cc
lily/side-position-interface.cc
lily/stencil.cc
scm/framework-scm.scm
scm/lily.scm
scm/page.scm
scm/stencil.scm

index d04e7cd6eaee0c0749e478e1c6a5afb96730adaa..75233cb455cae4339b960ebd637dfb324ddb9dbd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2006-02-19  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * scm/stencil.scm (annotate-y-interval): robustify: print nan/inf
+       markers when necessary.
+
+       * lily/program-option.cc (internal_set_option): add
+       strict_infinity_checking option.
+
        * scm/output-lib.scm (cyan): swap yellow and cyan.
 
 2006-02-19  Graham Percival  <gpermus@gmail.com>
index bd396a16f771ad6e7c64b3784df00472dac07dd1..329be3f77b7db1f5face71b547ab37914a305fcf 100644 (file)
@@ -37,7 +37,7 @@ extern bool is_TeX_format_global;
 extern bool point_and_click_global;
 extern string prefix_directory;
 extern bool use_object_keys;
-
+extern bool strict_infinity_checking;
 /*
   todo: collect in Output_option struct?
 */
index 4ec7b2d3e411179a008124d848285c992d7d20a1..215bcfe0b9cee0abdde5c2e1e9df83090be36685 100644 (file)
@@ -32,6 +32,8 @@ bool profile_property_accesses = false;
   crash if internally the wrong type is used for a grob property.
 */
 bool do_internal_type_checking_global;
+bool strict_infinity_checking = false; 
+
 
 static SCM option_hash;
 
@@ -78,6 +80,11 @@ void internal_set_option (SCM var, SCM val)
       use_object_keys = to_boolean (val);
       val = scm_from_bool (to_boolean (val));
     }
+  else if (var == ly_symbol2scm ("strict-infinity-checking"))
+    {
+      strict_infinity_checking = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
 }
 
 ssize const HELP_INDENT = 30;
index 72dfbb838018b7da1918bd4dd233fa2138c2d700..f5f51bced2259832f7de93266bfa28a421780ae2 100644 (file)
@@ -14,8 +14,7 @@ using namespace std;
 
 #include "note-head.hh"
 #include "warn.hh"
-#include "warn.hh"
-#include "dimensions.hh"
+#include "main.hh"
 #include "staff-symbol-referencer.hh"
 #include "pointer-group-interface.hh"
 #include "directional-element-interface.hh"
@@ -107,11 +106,12 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten
   if (fabs (total_off) > 1000)
     {
       string msg
-       = String_convert::form_string ("Improbable offset for grob %s: %f%s",
-                                      me->name ().c_str (), total_off,
-                                      INTERNAL_UNIT);
+       = String_convert::form_string ("Improbable offset for grob %s: %f",
+                                      me->name ().c_str (), total_off);
 
       programming_error (msg);
+      if (strict_infinity_checking)
+       scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL);
     }
   return scm_from_double (total_off);
 }
index a9693e7a7ce71fb8c1dd0028d4310800c95c1a2a..2fad44274d43f0a99c685a143c5598be51dd2f34 100644 (file)
@@ -8,8 +8,7 @@
 
 #include "stencil.hh"
 
-
-#include "dimensions.hh"
+#include "main.hh"
 #include "font-metric.hh"
 #include "input-smob.hh"
 #include "string-convert.hh"
@@ -95,6 +94,8 @@ Stencil::translate (Offset o)
                             + "\n"
                             + "Setting to zero.");
          o[a] = 0.0;
+         if (strict_infinity_checking)
+           scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL);
        }
       incr (a);
     }
index d20e5dea35f0d4ca0a10a952453673fd944e1b8b..e4895ae2e0fd6cb2fe011edd673145bb8ca023a5 100644 (file)
@@ -10,6 +10,7 @@
             (srfi srfi-1)
             (ice-9 pretty-print)
             (srfi srfi-13)
+            (scm page)
             (lily))
 
 (define-public (output-framework basename book scopes fields )
index 43d1176ebbe438941f51827d1a5e553b959159d9..5f9e364b7f5ba554f2ca324868ffae1aebac6b53 100644 (file)
@@ -34,6 +34,7 @@ similar to chord syntax")
                                         "delete unusable PostScript files")
              (safe #f "Run safely")
              (verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
+             (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN")
              (ttf-verbosity 0
                           "how much verbosity for TTF font embedding?")
              (debug-gc #f
index 9274eef3fd0d67410e79c2bce959d2e0fd90a91e..616efe3469a290bc364829e1ecc4cd656c63bdff 100644 (file)
@@ -365,7 +365,7 @@ create offsets.
     page-stencil))
               
 
-(define (page-stencil page)
+(define-public (page-stencil page)
   (if (not (ly:stencil? (page-property page 'stencil)))
 
       ;; todo: make tweakable.
index 58b19346186c5654af29992d43c69d23b36a4254..541b4bf28e8677830344f111676aa18bcc225257 100644 (file)
@@ -178,47 +178,53 @@ encloses the contents.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (annotate-y-interval layout name extent is-length)
-  ;; do something sensible for 0,0 intervals. 
-  (set! extent (interval-widen extent 0.001))
   (let*
       ((text-props (cons
                    '((font-size . -3)
                      (font-family . typewriter))
                    (layout-extract-page-properties layout)))
-       (annotation (interpret-markup
-                   layout text-props
-                   (make-column-markup
-                    (list
-                     (make-whiteout-markup (make-simple-markup name))
-                     (make-whiteout-markup
-                      (make-simple-markup
-                       (begin
-                         (display extent)
-                       (cond
-                        ((interval-empty? extent) "empty")
-                        ((not (interval-sane? extent)) "insane")
-                        (is-length (format "~$" (interval-length extent)))
-                        (else
-                         (format "(~$,~$)" (car extent)
-                                   (cdr extent)))))))))))
-       (arrows
-       (ly:stencil-translate-axis 
-        (dimension-arrows (cons 0 (interval-length extent)))
-        (interval-start extent) Y)))
+       (annotation #f)
+       )
 
-    (set! annotation
-         (ly:stencil-aligned-to annotation Y CENTER))
-    
-    (set! annotation (ly:stencil-translate annotation
-                         (cons 0 (interval-center extent))))
+    ;; do something sensible for 0,0 intervals. 
+    (set! extent (interval-widen extent 0.001))
+    (if (not (interval-sane? extent))
+       (set! annotation (interpret-markup layout text-props
+                                          (make-simple-markup (format "~a: NaN/inf" name))))
+       (let*
+           ((text-stencil (interpret-markup
+                           layout text-props
+                           (make-column-markup
+                            (list
+                             (make-whiteout-markup (make-simple-markup name))
+                             (make-whiteout-markup
+                              (make-simple-markup
+                               (cond
+                                ((interval-empty? extent) "empty")
+                                (is-length (format "~$" (interval-length extent)))
+                                (else
+                                 (format "(~$,~$)" (car extent)
+                                         (cdr extent))))))))))
+            (arrows
+             (ly:stencil-translate-axis 
+              (dimension-arrows (cons 0 (interval-length extent)))
+              (interval-start extent) Y)))
+         
+         (set! annotation
+               (ly:stencil-aligned-to text-stencil Y CENTER))
+         
+         (set! annotation (ly:stencil-translate
+                           annotation
+                           (cons 0 (interval-center extent))))
+         
 
-    (set! annotation
-         (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5 0))
+         (set! annotation
+               (ly:stencil-combine-at-edge arrows X RIGHT annotation 0.5 0))
 
-    (set! annotation
-         (ly:make-stencil (ly:stencil-expr annotation)
-                          (ly:stencil-extent annotation X)
-                          (cons 10000 -10000)))
+         (set! annotation
+               (ly:make-stencil (ly:stencil-expr annotation)
+                                (ly:stencil-extent annotation X)
+                                (cons 10000 -10000)))))
     annotation))