X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fskyline-pair.cc;h=164117c35bdb62b59516eafe08a8d725e1456fe0;hb=refs%2Fheads%2Fdebian;hp=100061a19c01aeb1c59d1eb5e826c70fbafefa41;hpb=19e6facfeb5c2809ea8099bfaa81339cc44b04b3;p=lilypond.git diff --git a/lily/skyline-pair.cc b/lily/skyline-pair.cc index 100061a19c..164117c35b 100644 --- a/lily/skyline-pair.cc +++ b/lily/skyline-pair.cc @@ -1,14 +1,26 @@ -/* - skyline-pair.cc -- implement Skyline_pair - - source file of the GNU LilyPond music typesetter - - (c) 2008 Han-Wen Nienhuys - +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2008--2012 Han-Wen Nienhuys + + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "skyline-pair.hh" +#include "international.hh" #include "ly-smobs.icc" Skyline_pair::Skyline_pair () @@ -16,13 +28,23 @@ Skyline_pair::Skyline_pair () { } -Skyline_pair::Skyline_pair (vector const &boxes, Real padding, Axis a) - : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP)) +Skyline_pair::Skyline_pair (vector const &boxes, Axis a) + : skylines_ (Skyline (boxes, a, DOWN), Skyline (boxes, a, UP)) +{ +} + +Skyline_pair::Skyline_pair (vector > const &buildings, Axis a) + : skylines_ (Skyline (buildings, a, DOWN), Skyline (buildings, a, 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 (vector const &skypairs) + : skylines_ (Skyline (skypairs, DOWN), Skyline (skypairs, UP)) +{ +} + +Skyline_pair::Skyline_pair (Box const &b, Axis a) + : skylines_ (Skyline (b, a, DOWN), Skyline (b, a, UP)) { } @@ -33,6 +55,13 @@ Skyline_pair::raise (Real r) skylines_[DOWN].raise (r); } +void +Skyline_pair::deholify () +{ + skylines_[UP].deholify (); + skylines_[DOWN].deholify (); +} + void Skyline_pair::shift (Real r) { @@ -41,10 +70,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 @@ -61,28 +90,39 @@ 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]; @@ -107,3 +147,19 @@ Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *) scm_puts ("#", port); return 1; } + +MAKE_SCHEME_CALLBACK (Skyline_pair, skyline, 2); +SCM +Skyline_pair::skyline (SCM smob, SCM dir_scm) +{ + Skyline_pair *sp = Skyline_pair::unsmob (smob); + Direction dir = robust_scm2dir (dir_scm, UP); + + if (dir == CENTER) + { + warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline")); + dir = UP; + } + + return (*sp)[dir].smobbed_copy (); +}