]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/slur.cc: add 'positions to interface
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 8 Nov 2004 22:39:10 +0000 (22:39 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 8 Nov 2004 22:39:10 +0000 (22:39 +0000)
* lily/main.cc: reinstate PS as standard output format.

* scm/framework-tex.scm (output-preview-framework): print systems
up to first non title system.

ChangeLog
input/regression/slur-manual.ly [new file with mode: 0644]
lily/include/slur-scoring.hh
lily/main.cc
lily/slur-scoring.cc
lily/slur.cc
scm/framework-tex.scm

index 452f8d5f0bac4e87e03b10055629635d3f1573bb..6c27b4f10de97382e3203caa587654c1e22d99cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-11-08  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/slur.cc: add 'positions to interface
+
+       * lily/main.cc: reinstate PS as standard output format. 
+
+       * scm/framework-tex.scm (output-preview-framework): print systems
+       up to first non title system.
+
        * lily/grace-engraver.cc (start_translation_timestep): split
        scm_cadddr
        
diff --git a/input/regression/slur-manual.ly b/input/regression/slur-manual.ly
new file mode 100644 (file)
index 0000000..cd3acfe
--- /dev/null
@@ -0,0 +1,16 @@
+
+\header {
+
+  texidoc = "Setting @code{positions} overrides the automatic
+positioning of the slur. It selects the slur configuration closest to
+the given pair. "
+  
+  }
+\version "2.5.0"
+
+\paper { raggedright = ##T }
+\relative {
+  \override Slur #'positions = #'(-4 . -5)
+  e( f g)
+}
+
index 196387abd96f32c381968d3580f6f047bdb376e6..3d9049b217bbf7717cc40eebe6f6ea7296c4555c 100644 (file)
@@ -13,6 +13,7 @@
 #include "box.hh"
 #include "lily-proto.hh"
 #include "parray.hh"
+#include "lily-guile.hh"
 
 struct Slur_score_parameters
 {
@@ -144,6 +145,7 @@ struct Slur_score_state
   Encompass_info get_encompass_info (Grob *col) const;
   Array<Extra_collision_info> get_extra_encompass_infos () const;
   Real move_away_from_staffline (Real y, Grob *on_staff) const;
+  int get_closest_index (SCM inspect_quants) const;
 };
 
 
index 30f2c6c13b3c1525298707970a39c8697db18834..25e7e68e9bd8868934bff5c8e29cc580914f7f23 100644 (file)
@@ -47,7 +47,7 @@ bool no_layout_global_b = false;
 
 /* Selected output format.
    One of tex, ps, scm, as. */
-String output_format_global = "tex";
+String output_format_global = "ps";
 
 /* Current output name. */
 String output_name_global;
index 48799e2e0f775d329e344b4e230584270f919e81..6e9f05dff22ab58ebf3af8f797494e4e96b94bc2 100644 (file)
@@ -368,8 +368,18 @@ set_slur_control_points (Grob *me)
     return;
   
   state.generate_curves ();
-  Bezier best (state.get_best_curve());
 
+  SCM end_ys = me->get_property ("positions");
+  Bezier best;
+
+  if (is_number_pair (end_ys))
+    {
+      best = state.configurations_[state.get_closest_index (end_ys)]->curve_;
+    }
+  else
+    {
+      best = state.get_best_curve();
+    }
 
   SCM controls = SCM_EOL;
   for (int i = 4; i--;)
@@ -407,35 +417,42 @@ Slur_score_state::get_best_curve ()
   if (to_boolean (slur_->get_layout ()
                  ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")))
       && scm_is_pair (inspect_quants))
-    {
-      Drul_array<Real> ins = ly_scm2interval (inspect_quants);
-      Real mindist = 1e6;
-      for (int i = 0; i < configurations_.size (); i ++)
-       {
-         Real d =fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT])
-           + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
-         if (d < mindist)
-           {
-             opt_idx = i;
-             mindist= d;
-           }
-       }
-      if (mindist > 1e5)
-       programming_error ("Could not find quant.");
-    }
+    opt_idx = get_closest_index (inspect_quants);
 
   configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);  
   configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx);
 
   // debug quanting
   slur_->set_property ("quant-score",
-                   scm_makfrom0str (configurations_[opt_idx]->score_card_.to_str0 ()));
+                      scm_makfrom0str (configurations_[opt_idx]->score_card_.to_str0 ()));
 
 #endif
 
   return configurations_[opt_idx]->curve_;
 }
 
+int
+Slur_score_state::get_closest_index (SCM inspect_quants) const
+{
+  Drul_array<Real> ins = ly_scm2interval (inspect_quants);
+
+  int opt_idx = -1;
+  Real mindist = 1e6;
+  for (int i = 0; i < configurations_.size (); i ++)
+    {
+      Real d =fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT])
+       + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
+      if (d < mindist)
+       {
+         opt_idx = i;
+         mindist= d;
+       }
+    }
+  if (mindist > 1e5)
+    programming_error ("Could not find quant.");
+  return opt_idx;
+}
+
 /*
   TODO: should analyse encompasses to determine sensible region, and
   should limit slopes available.
index cde26695784ce002592e4a4630ece622ab41c044..fcf02f39ce8bb248e575bb745a47ee2c9c261380 100644 (file)
@@ -241,6 +241,6 @@ Slur::after_line_breaking (SCM smob)
 
 ADD_INTERFACE (Slur, "slur-interface",
               "A slur",
-              "quant-score excentricity encompass-objects control-points dashed slur-details direction height-limit note-columns ratio thickness");
+              "positions quant-score excentricity encompass-objects control-points dashed slur-details direction height-limit note-columns ratio thickness");
 
 
index e48209d3b2240b9bc86fa879928b47aab2acb697..ade6b100993286a24b81611b7ab7870c1b5c44b1 100644 (file)
         (ly:get-option 'resolution))
      (string-append (basename name ".tex") ".ps"))))
 
-
-;;
-;; ugh  -   double check this. We are leaking
-;; untrusted (user-settable) info to a command-line 
-;;
-
-
 (define-public (convert-to-ps book name)
   (let* ((paper (ly:paper-book-paper book))
         (preview? (string-contains name ".preview"))
+
         (papersizename (ly:output-def-lookup paper 'papersizename))
         (landscape? (eq? #t (ly:output-def-lookup paper 'landscape)))
         (base (basename name ".tex"))
                                 " -E "
                                 (string-append
                                  " -t "
+                                 
+                                 ;; careful: papersizename is user-set.
                                  (sanitize-command-option papersizename)))
                                 
                             (if landscape?