]> git.donarmstrong.com Git - lilypond.git/blob - lily/skyline-pair.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / skyline-pair.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2008--2014 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 #include "ly-smobs.icc"
25
26 Skyline_pair::Skyline_pair ()
27   : skylines_ (Skyline (DOWN), Skyline (UP))
28 {
29 }
30
31 Skyline_pair::Skyline_pair (vector<Box> const &boxes, Axis a)
32   : skylines_ (Skyline (boxes, a, DOWN), Skyline (boxes, a, UP))
33 {
34 }
35
36 Skyline_pair::Skyline_pair (vector<Drul_array<Offset> > const &buildings, Axis a)
37   : skylines_ (Skyline (buildings, a, DOWN), Skyline (buildings, a, UP))
38 {
39 }
40
41 Skyline_pair::Skyline_pair (vector<Skyline_pair> const &skypairs)
42   : skylines_ (Skyline (skypairs, DOWN), Skyline (skypairs, UP))
43 {
44 }
45
46 Skyline_pair::Skyline_pair (Box const &b, Axis a)
47   : skylines_ (Skyline (b, a, DOWN), Skyline (b, a, UP))
48 {
49 }
50
51 void
52 Skyline_pair::raise (Real r)
53 {
54   skylines_[UP].raise (r);
55   skylines_[DOWN].raise (r);
56 }
57
58 void
59 Skyline_pair::deholify ()
60 {
61   skylines_[UP].deholify ();
62   skylines_[DOWN].deholify ();
63 }
64
65 void
66 Skyline_pair::shift (Real r)
67 {
68   skylines_[UP].shift (r);
69   skylines_[DOWN].shift (r);
70 }
71
72 void
73 Skyline_pair::insert (Box const &b, Axis a)
74 {
75   skylines_[UP].insert (b, a);
76   skylines_[DOWN].insert (b, a);
77 }
78
79 void
80 Skyline_pair::merge (Skyline_pair const &other)
81 {
82   skylines_[UP].merge (other[UP]);
83   skylines_[DOWN].merge (other[DOWN]);
84 }
85
86 void
87 Skyline_pair::print () const
88 {
89   skylines_[UP].print ();
90   skylines_[DOWN].print ();
91 }
92
93 Real
94 Skyline_pair::left () const
95 {
96   return min (skylines_[UP].left (), skylines_[DOWN].left ());
97 }
98
99 Real
100 Skyline_pair::right () const
101 {
102   return max (skylines_[UP].right (), skylines_[DOWN].right ());
103 }
104
105 void
106 Skyline_pair::print_points () const
107 {
108   skylines_[UP].print_points ();
109   skylines_[DOWN].print_points ();
110 }
111
112 bool
113 Skyline_pair::is_empty () const
114 {
115   return skylines_[UP].is_empty ()
116          && skylines_[DOWN].is_empty ();
117 }
118
119 Skyline &
120 Skyline_pair::operator [] (Direction d)
121 {
122   return skylines_[d];
123 }
124
125 Skyline const &
126 Skyline_pair::operator [] (Direction d) const
127 {
128   return skylines_[d];
129 }
130
131 IMPLEMENT_SIMPLE_SMOBS (Skyline_pair);
132 IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?");
133 IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair);
134
135 SCM
136 Skyline_pair::mark_smob (SCM)
137 {
138   return SCM_EOL;
139 }
140
141 int
142 Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *)
143 {
144   Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s);
145   (void) r;
146
147   scm_puts ("#<Skyline-pair>", port);
148   return 1;
149 }
150
151 MAKE_SCHEME_CALLBACK (Skyline_pair, skyline, 2);
152 SCM
153 Skyline_pair::skyline (SCM smob, SCM dir_scm)
154 {
155   Skyline_pair *sp = Skyline_pair::unsmob (smob);
156   Direction dir = robust_scm2dir (dir_scm, UP);
157
158   if (dir == CENTER)
159     {
160       warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline"));
161       dir = UP;
162     }
163
164   return (*sp)[dir].smobbed_copy ();
165 }