]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of git+ssh://git.sv.gnu.org/srv/git/lilypond
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 17 Dec 2006 22:14:00 +0000 (23:14 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 17 Dec 2006 22:14:00 +0000 (23:14 +0100)
buildscripts/output-distance.py
input/regression/spacing-loose-grace-error.ly [new file with mode: 0644]
input/regression/system-separator.ly
lily/include/spacing-spanner.hh
lily/pointer-group-interface.cc
lily/spacing-determine-loose-columns.cc
lily/tie-column.cc

index 92768454dc4c80f5247137aa21386209f2aa46b0..8f1b68633c89e0959cccd24b1f7e6184770ce9b7 100644 (file)
@@ -268,6 +268,38 @@ def read_signature_file (name):
 
 ################################################################
 # different systems of a .ly file.
+def read_pipe (c):
+    print 'pipe' , c
+    return os.popen (c).read ()
+
+def system (c):
+    print 'system' , c
+    s = os.system (c)
+    if s :
+        raise Exception ("failed")
+    return
+
+def compare_png_images (old, new, dir):
+    def png_dims (f):
+        m = re.search ('([0-9]+) x ([0-9]+)', read_pipe ('file %s' % f))
+        
+        return tuple (map (int, m.groups ()))
+
+    dims1 = png_dims (old)
+    dims2 = png_dims (new)
+
+    dims = (min (dims1[0], dims2[0]),
+            min (dims1[1], dims2[1]))
+
+    system ('convert -crop %dx%d+0+0 %s crop1.png' % (dims + (old,)))
+    system ('convert -crop %dx%d+0+0 %s crop2.png' % (dims + (new,)))
+
+    system ('compare crop1.png crop2.png diff.png')
+
+    system ("convert diff.png -border 2 -blur 0x3 -negate -channel alpha,blue -type TrueColorMatte     -fx 'intensity'    matte.png")
+
+    dest = os.path.join (dir, new.replace ('.png', '.compare.png'))
+    system ("composite matte.png %(new)s %(dest)s" % locals ())
 
 class FileLink:
     def __init__ (self):
@@ -341,11 +373,19 @@ class FileLink:
         self.add_system_link (link, system_index[0])
 
     def link_files_for_html (self, old_dir, new_dir, dest_dir):
+        png_linked = [[], []]
         for ext in ('.png', '.ly', '-page*png'):
+            
             for oldnew in (0,1):
                 for f in glob.glob (self.base_names[oldnew] + ext):
-                    print f
-                    link_file (f, dest_dir + '/' + f)
+                    dst = dest_dir + '/' + f
+                    link_file (f, dst)
+
+                    if f.endswith ('.png'):
+                        png_linked[oldnew].append (f)
+
+        for (old,new) in zip (png_linked[0], png_linked[1]):
+            compare_png_images (old, new, dest_dir)
 
     def html_record_string (self,  old_dir, new_dir):
         def img_cell (ly, img, name):
@@ -387,8 +427,9 @@ class FileLink:
 
 
         def cell (base, name):
-            pages = glob.glob (base + '-page*.png')
-            
+            pat = base + '-page*.png'
+            pages = glob.glob (pat)
+
             if pages:
                 return multi_img_cell (base + '.ly', sorted (pages), name)
             else:
@@ -410,7 +451,7 @@ class FileLink:
 </tr>
 ''' % (self.distance (), html_2,
        cell (self.base_names[0], name),
-       cell (self.base_names[1], name))
+       cell (self.base_names[1], name).replace ('.png', '.compare.png'))
 
         return html_entry
 
@@ -598,6 +639,7 @@ class ComparisonData:
 
             link.link_files_for_html (dir1, dir2, dest_dir) 
             link.write_html_system_details (dir1, dir2, dest_dir)
+            
             html += link.html_record_string (dir1, dir2)
 
 
@@ -699,7 +741,10 @@ def test_compare_trees ():
 
     ## introduce differences
     system ('cp 19-1.signature dir2/20-1.signature')
+    system ('cp 19.png dir2/20.png')
+    system ('cp 19multipage-page1.png dir2/20multipage-page1.png')
     system ('cp 20-1.signature dir2/subdir/19-sub-1.signature')
+    system ('cp 20.png dir2/subdir/19-sub.png')
 
     ## radical diffs.
     system ('cp 19-1.signature dir2/20grob-1.signature')
@@ -811,7 +856,7 @@ def test_compare_signatures (names, timing=False):
 
 
 def run_tests ():
-    dir = 'output-distance-test'
+    dir = 'test-output-distance'
 
     do_clean = not os.path.exists (dir)
 
diff --git a/input/regression/spacing-loose-grace-error.ly b/input/regression/spacing-loose-grace-error.ly
new file mode 100644 (file)
index 0000000..94a3968
--- /dev/null
@@ -0,0 +1,19 @@
+\header
+{
+  
+texidoc = "Even in case of incorrect contexts (eg. shortlived
+  contexts) that break linking of columns through spacing wishes,
+  @code{strict-note-spacing} defaults to a robust solution."
+
+}
+
+\version "2.11.2"
+
+
+%% \new Staff cause shortlived, disconnected Voice contexts
+%% breaking spacing-wishes links.
+\new Staff {
+  \override Score.SpacingSpanner #'strict-note-spacing = ##t
+  \afterGrace c'4 {c'32 c'32 }
+  c'4
+}
index 88414a86f4e4d685b417eed5476ce90b0738a5c5..865ff4fc48b15f2c99d42c1ed5ee251cdb2836e8 100644 (file)
@@ -3,7 +3,7 @@
 \header {
 
   texidoc = "System separators maybe defined as markups in the
-@code{systemSeparator} field of the bookpaper block. They are centered
+@code{systemSeparator} field of the paper block. They are centered
 between the boundary staffs of each system. "
 
 }
index 3dace37510894ae0154fe1c0c2b908a78f0c762f..7d46f78e1ce2b93151378fb37e4febe6f9638bfa 100644 (file)
   TODO: prune to public interface.
 */
 class Spacing_spanner
+
 {
 public:
+  static void set_distances_for_loose_col (Grob *me, Grob *c, Drul_array<Item *> next_door, Spacing_options const *);
   static void generate_pair_spacing (Grob *me,
                                     Paper_column *l, Paper_column *r,
                                     Paper_column *nextr,
index 36eac12bca69bbd2f50b87310bd9e94b5e374adf..a04d4512c0fd3f06abc26978196b4602f68f0e1e 100644 (file)
@@ -72,7 +72,9 @@ ly_scm2link_array (SCM x)
 vector<Grob*> const &
 internal_extract_grob_array (Grob const *elt, SCM symbol)
 {
-  return ly_scm2link_array (elt->internal_get_object (symbol));
+  return elt
+    ? ly_scm2link_array (elt->internal_get_object (symbol))
+    : empty_array;
 }
 
 vector<Item*>
index fe5a89c80bc3f0193a42422eb14bbec43577c352..c0eecf93280e6bf9631e3daca7112e40b24dc135 100644 (file)
@@ -37,18 +37,19 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
   if (!to_boolean (col->get_property ("allow-loose-spacing")))
     return false;
   
+
   if ((options->float_nonmusical_columns_
        ||options->float_grace_columns_)
       && Paper_column::when_mom (col).grace_part_)
-    return true;
+    {
+      return true;
+    }
 
+  
   if (Paper_column::is_musical (col)
       || Paper_column::is_breakable (col))
     return false;
 
-  extract_grob_set (col, "right-neighbors", rns);
-  extract_grob_set (col, "left-neighbors", lns);
-
   /*
     If this column doesn't have a proper neighbor, we should really
     make it loose, but spacing it correctly is more than we can
@@ -70,9 +71,14 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
     such a borderline case.)
 
   */
+
+  extract_grob_set (col, "right-neighbors", rns);
+  extract_grob_set (col, "left-neighbors", lns);
+
   if (lns.empty () || rns.empty ())
     return false;
 
+  
   Item *l_neighbor = dynamic_cast<Item *> (lns[0]);
   Item *r_neighbor = dynamic_cast<Item *> (rns[0]);
 
@@ -126,6 +132,68 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
   return true;
 }
 
+void
+Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c,
+                                             Drul_array<Item *> next_door,
+                                             Spacing_options const *options)
+{
+  Direction d = LEFT;
+  Drul_array<Real> dists (0, 0);
+
+  do
+    {
+      Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
+      Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
+
+      extract_grob_set (lc, "spacing-wishes", wishes);
+      for (vsize k = wishes.size (); k--;)
+       {
+         Grob *sp = wishes[k];
+         if (Note_spacing::left_column (sp) != lc
+             || Note_spacing::right_column (sp) != rc)
+           continue;
+
+         if (Note_spacing::has_interface (sp))
+           {
+             /*
+               The note spacing should be taken from the musical
+               columns.
+             */
+             Real space = 0.0;
+             Real fixed = 0.0;
+             bool dummy = false;
+                 
+             Real base = note_spacing (me, lc, rc, options, &dummy);
+             Note_spacing::get_spacing (sp, rc, base, options->increment_,
+                                        &space, &fixed);
+
+             space -= options->increment_;
+
+             dists[d] = max (dists[d], space);
+           }
+         else if (Staff_spacing::has_interface (sp))
+           {
+             Real space = 0;
+             Real fixed_space = 0;
+             Staff_spacing::get_spacing_params (sp,
+                                                &space, &fixed_space);
+
+             dists[d] = max (dists[d], fixed_space);
+           }
+         else
+           programming_error ("Subversive spacing wish");
+       }
+    }
+  while (flip (&d) != LEFT);
+
+  Rod r;
+  r.distance_ = dists[LEFT] + dists[RIGHT];
+  r.item_drul_ = next_door;
+  r.add_to_cols (); 
+}
+
+
 /*
   Remove columns that are not tightly fitting from COLS. In the
   removed columns, set 'between-cols to the columns where it is in
@@ -158,71 +226,28 @@ Spacing_spanner::prune_loose_columns (Grob *me, vector<Grob*> *cols,
          */
 
          extract_grob_set (unsmob_grob (rns), "right-items", right_items);
-         c->set_object ("between-cols", scm_cons (lns,
-                                                  right_items[0]->self_scm ()));
-
-         /*
-           Set distance constraints for loose columns
-         */
-         Drul_array<Grob *> next_door (cols->at (i - 1),
-                                       cols->at (i + 1));
-         Direction d = LEFT;
-         Drul_array<Real> dists (0, 0);
-
-         do
+         if (right_items.size () == 0 || !unsmob_grob (lns))
            {
-             Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
-             Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
-
-             extract_grob_set (lc, "spacing-wishes", wishes);
-             for (vsize k = wishes.size (); k--;)
-               {
-                 Grob *sp = wishes[k];
-                 if (Note_spacing::left_column (sp) != lc
-                     || Note_spacing::right_column (sp) != rc)
-                   continue;
-
-                 if (Note_spacing::has_interface (sp))
-                   {
-                     /*
-                       The note spacing should be taken from the musical
-                       columns.
-                     */
-                     Real space = 0.0;
-                     Real fixed = 0.0;
-                     bool dummy = false;
-                 
-                     Real base = note_spacing (me, lc, rc, options, &dummy);
-                     Note_spacing::get_spacing (sp, rc, base, options->increment_,
-                                                &space, &fixed);
-
-                     space -= options->increment_;
-
-                     dists[d] = max (dists[d], space);
-                   }
-                 else if (Staff_spacing::has_interface (sp))
-                   {
-                     Real space = 0;
-                     Real fixed_space = 0;
-                     Staff_spacing::get_spacing_params (sp,
-                                                        &space, &fixed_space);
-
-                     dists[d] = max (dists[d], fixed_space);
-                   }
-                 else
-                   programming_error ("Subversive spacing wish");
-               }
+             c->programming_error ("Can't determine neighbors for floating column. ");
+             c->set_object ("between-cols", scm_cons (cols->at (i-1)->self_scm (),
+                                                      cols->at (i+1)->self_scm ()));
            }
-         while (flip (&d) != LEFT);
+         else
+           {
+             c->set_object ("between-cols", scm_cons (lns,
+                                                      right_items[0]->self_scm ()));
 
-         Rod r;
-         r.distance_ = dists[LEFT] + dists[RIGHT];
-         r.item_drul_[LEFT] = dynamic_cast<Item *> (cols->at (i - 1));
-         r.item_drul_[RIGHT] = dynamic_cast<Item *> (cols->at (i + 1));
+             /*
+               Set distance constraints for loose columns
+             */
+             Drul_array<Item *> next_door (dynamic_cast<Item*> (cols->at (i - 1)),
+                                           dynamic_cast<Item*> (cols->at (i + 1)));
 
-         r.add_to_cols ();
+             set_distances_for_loose_col (me, c, next_door, options);
+           }
        }
-      else
+
+      if (!loose)
        newcols.push_back (c);
     }
 
index 85529ef1d559585edac3d6e7bf4e5723f18fef6b..dd54530e812edd8e5afcc581573ea0f8a393d0be 100644 (file)
 using namespace std;
 
 void
-Tie_column::add_tie (Grob *me, Grob *tie)
+Tie_column::add_tie (Grob *tc, Grob *tie)
 {
+  Spanner *me = dynamic_cast<Spanner *> (tc);
+  
   if (tie->get_parent (Y_AXIS)
       && Tie_column::has_interface (tie->get_parent (Y_AXIS)))
     return;
 
-  if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties")))
+  if (!me->get_bound (LEFT)
+      || (Paper_column::get_rank (me->get_bound (LEFT)->get_column ())
+         > Paper_column::get_rank (dynamic_cast<Spanner*> (tie)->get_bound (LEFT)->get_column ())))
     {
-      dynamic_cast<Spanner *> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
-      dynamic_cast<Spanner *> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
+       me->set_bound (LEFT, Tie::head (tie, LEFT));
+       me->set_bound (RIGHT, Tie::head (tie, RIGHT));
     }
-
+      
   tie->set_parent (me, Y_AXIS);
   Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
 }