]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline-pair.cc
Run grand replace for 2015.
[lilypond.git] / lily / skyline-pair.cc
index 2f7ea73575a7e70347de237308d1c44a3e25a20c..92ae97a342e0961571b066c0ad4b30775ea050b0 100644 (file)
@@ -1,8 +1,8 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2008--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
-  
+  Copyright (C) 2008--2015 Han-Wen Nienhuys <hanwen@lilypond.org>
+
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
 #include "skyline-pair.hh"
 
-#include "ly-smobs.icc"
+#include "international.hh"
 
 Skyline_pair::Skyline_pair ()
   : skylines_ (Skyline (DOWN), Skyline (UP))
 {
 }
 
-Skyline_pair::Skyline_pair (vector<Box> const &boxes, Real padding, Axis a)
-  : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP))
+Skyline_pair::Skyline_pair (vector<Box> const &boxes, Axis a)
+  : skylines_ (Skyline (boxes, a, DOWN), Skyline (boxes, a, UP))
+{
+}
+
+Skyline_pair::Skyline_pair (vector<Drul_array<Offset> > const &buildings, Axis a)
+  : skylines_ (Skyline (buildings, a, DOWN), Skyline (buildings, a, UP))
+{
+}
+
+Skyline_pair::Skyline_pair (vector<Skyline_pair> const &skypairs)
+  : skylines_ (Skyline (skypairs, DOWN), Skyline (skypairs, UP))
 {
 }
 
-Skyline_pair::Skyline_pair (Box const &b, Real padding, Axis a)
-  : skylines_ (Skyline (b, padding, a, DOWN), Skyline (b, padding, a, UP))
+Skyline_pair::Skyline_pair (Box const &b, Axis a)
+  : skylines_ (Skyline (b, a, DOWN), Skyline (b, a, UP))
 {
 }
 
@@ -52,10 +62,10 @@ Skyline_pair::shift (Real r)
 }
 
 void
-Skyline_pair::insert (Box const &b, Real padding, Axis a)
+Skyline_pair::insert (Box const &b, Axis a)
 {
-  skylines_[UP].insert (b, padding, a);
-  skylines_[DOWN].insert (b, padding, a);
+  skylines_[UP].insert (b, a);
+  skylines_[DOWN].insert (b, a);
 }
 
 void
@@ -72,49 +82,59 @@ Skyline_pair::print () const
   skylines_[DOWN].print ();
 }
 
+Real
+Skyline_pair::left () const
+{
+  return min (skylines_[UP].left (), skylines_[DOWN].left ());
+}
+
+Real
+Skyline_pair::right () const
+{
+  return max (skylines_[UP].right (), skylines_[DOWN].right ());
+}
+
 void
 Skyline_pair::print_points () const
 {
-  skylines_[UP].print ();
-  skylines_[DOWN].print ();
+  skylines_[UP].print_points ();
+  skylines_[DOWN].print_points ();
 }
 
-
 bool
 Skyline_pair::is_empty () const
 {
   return skylines_[UP].is_empty ()
-    && skylines_[DOWN].is_empty ();
+         && skylines_[DOWN].is_empty ();
 }
 
-Skyline&
+Skyline &
 Skyline_pair::operator [] (Direction d)
 {
   return skylines_[d];
 }
 
-Skyline const&
+Skyline const &
 Skyline_pair::operator [] (Direction d) const
 {
   return skylines_[d];
 }
 
-IMPLEMENT_SIMPLE_SMOBS (Skyline_pair);
-IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?");
-IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair);
+const char Skyline_pair::type_p_name_[] = "ly:skyline-pair?";
+
 
+MAKE_SCHEME_CALLBACK (Skyline_pair, skyline, 2);
 SCM
-Skyline_pair::mark_smob (SCM)
+Skyline_pair::skyline (SCM smob, SCM dir_scm)
 {
-  return SCM_EOL;
-}
+  Skyline_pair *sp = Skyline_pair::unsmob (smob);
+  Direction dir = robust_scm2dir (dir_scm, UP);
 
-int
-Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *)
-{
-  Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s);
-  (void) r;
+  if (dir == CENTER)
+    {
+      warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline"));
+      dir = UP;
+    }
 
-  scm_puts ("#<Skyline-pair>", port);
-  return 1;
+  return (*sp)[dir].smobbed_copy ();
 }