]> git.donarmstrong.com Git - lilypond.git/blob - lily/skyline-pair.cc
Web-ja: update introduction
[lilypond.git] / lily / skyline-pair.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2008--2015 Han-Wen Nienhuys <hanwen@lilypond.org>
5
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "skyline-pair.hh"
22
23 #include "international.hh"
24
25 Skyline_pair::Skyline_pair ()
26   : skylines_ (Skyline (DOWN), Skyline (UP))
27 {
28 }
29
30 Skyline_pair::Skyline_pair (vector<Box> const &boxes, Axis a)
31   : skylines_ (Skyline (boxes, a, DOWN), Skyline (boxes, a, UP))
32 {
33 }
34
35 Skyline_pair::Skyline_pair (vector<Drul_array<Offset> > const &buildings, Axis a)
36   : skylines_ (Skyline (buildings, a, DOWN), Skyline (buildings, a, UP))
37 {
38 }
39
40 Skyline_pair::Skyline_pair (vector<Skyline_pair> const &skypairs)
41   : skylines_ (Skyline (skypairs, DOWN), Skyline (skypairs, UP))
42 {
43 }
44
45 Skyline_pair::Skyline_pair (Box const &b, Axis a)
46   : skylines_ (Skyline (b, a, DOWN), Skyline (b, a, UP))
47 {
48 }
49
50 void
51 Skyline_pair::raise (Real r)
52 {
53   skylines_[UP].raise (r);
54   skylines_[DOWN].raise (r);
55 }
56
57 void
58 Skyline_pair::shift (Real r)
59 {
60   skylines_[UP].shift (r);
61   skylines_[DOWN].shift (r);
62 }
63
64 void
65 Skyline_pair::insert (Box const &b, Axis a)
66 {
67   skylines_[UP].insert (b, a);
68   skylines_[DOWN].insert (b, a);
69 }
70
71 void
72 Skyline_pair::merge (Skyline_pair const &other)
73 {
74   skylines_[UP].merge (other[UP]);
75   skylines_[DOWN].merge (other[DOWN]);
76 }
77
78 void
79 Skyline_pair::print () const
80 {
81   skylines_[UP].print ();
82   skylines_[DOWN].print ();
83 }
84
85 Real
86 Skyline_pair::left () const
87 {
88   return min (skylines_[UP].left (), skylines_[DOWN].left ());
89 }
90
91 Real
92 Skyline_pair::right () const
93 {
94   return max (skylines_[UP].right (), skylines_[DOWN].right ());
95 }
96
97 void
98 Skyline_pair::print_points () const
99 {
100   skylines_[UP].print_points ();
101   skylines_[DOWN].print_points ();
102 }
103
104 bool
105 Skyline_pair::is_empty () const
106 {
107   return skylines_[UP].is_empty ()
108          && skylines_[DOWN].is_empty ();
109 }
110
111 Skyline &
112 Skyline_pair::operator [] (Direction d)
113 {
114   return skylines_[d];
115 }
116
117 Skyline const &
118 Skyline_pair::operator [] (Direction d) const
119 {
120   return skylines_[d];
121 }
122
123 const char * const Skyline_pair::type_p_name_ = "ly:skyline-pair?";
124
125
126 MAKE_SCHEME_CALLBACK (Skyline_pair, skyline, 2);
127 SCM
128 Skyline_pair::skyline (SCM smob, SCM dir_scm)
129 {
130   Skyline_pair *sp = unsmob<Skyline_pair> (smob);
131   Direction dir = robust_scm2dir (dir_scm, UP);
132
133   if (dir == CENTER)
134     {
135       warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline"));
136       dir = UP;
137     }
138
139   return (*sp)[dir].smobbed_copy ();
140 }