libosmscout 1.1.1
Loading...
Searching...
No Matches
ScreenBox.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_UTIL_SCREENBOX_H
2#define OSMSCOUT_UTIL_SCREENBOX_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2022 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
24
25#include <osmscout/Pixel.h>
26
27namespace osmscout {
28
37 class OSMSCOUT_API ScreenBox CLASS_FINAL
38 {
39 private:
40 Vertex2D minCoord=Vertex2D(0.0,0.0);
41 Vertex2D maxCoord=Vertex2D(0.0,0.0);
42
43 public:
44 static const ScreenBox EMPTY;
48 ScreenBox() = default;
49
53 ScreenBox(const ScreenBox& other) = default;
54
58 ScreenBox(ScreenBox&& other) = default;
59
64 ScreenBox(const Vertex2D& coordA,
65 const Vertex2D& coordB);
66
70 ScreenBox& operator=(const ScreenBox& other) = default;
71
75 ScreenBox& operator=(ScreenBox&& other) = default;
76
80 bool operator==(const ScreenBox& other) const;
81
82 [[nodiscard]] double GetMinX() const
83 {
84 return minCoord.GetX();
85 }
86
87 [[nodiscard]] double GetMinY() const
88 {
89 return minCoord.GetY();
90 }
91
92 [[nodiscard]] double GetMaxX() const
93 {
94 return maxCoord.GetX();
95 }
96
97 [[nodiscard]] double GetMaxY() const
98 {
99 return maxCoord.GetY();
100 }
101
105 [[nodiscard]] double GetWidth() const
106 {
107 return maxCoord.GetX()-minCoord.GetX();
108 }
109
113 [[nodiscard]] double GetHeight() const
114 {
115 return maxCoord.GetY()-minCoord.GetY();
116 }
117
123 [[nodiscard]] double GetSize() const
124 {
125 return GetWidth()*GetHeight();
126 }
127
133 [[nodiscard]] bool IsEmpty() const
134 {
135 return GetSize()==0.0;
136 }
137
142 [[nodiscard]] Vertex2D GetCenter() const
143 {
144 return {(minCoord.GetX()+maxCoord.GetX())/2,
145 (minCoord.GetY()+maxCoord.GetY())/2};
146 }
147
148 [[nodiscard]] bool Intersects(const ScreenBox& other) const;
149 [[nodiscard]] bool Intersects(const ScreenBox& other,
150 bool openInterval) const;
151
164 [[nodiscard]] ScreenBox Resize(double offset) const;
165 [[nodiscard]] ScreenBox Merge(const ScreenBox& other) const;
166 };
167}
168
169#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
double GetWidth() const
Definition ScreenBox.h:105
double GetHeight() const
Definition ScreenBox.h:113
ScreenBox Merge(const ScreenBox &other) const
bool Intersects(const ScreenBox &other) const
Vertex2D GetCenter() const
Definition ScreenBox.h:142
ScreenBox(ScreenBox &&other)=default
double GetMaxY() const
Definition ScreenBox.h:97
ScreenBox(const ScreenBox &other)=default
bool operator==(const ScreenBox &other) const
ScreenBox Resize(double offset) const
ScreenBox & operator=(ScreenBox &&other)=default
static const ScreenBox EMPTY
Definition ScreenBox.h:44
bool IsEmpty() const
Definition ScreenBox.h:133
ScreenBox & operator=(const ScreenBox &other)=default
bool Intersects(const ScreenBox &other, bool openInterval) const
double GetMaxX() const
Definition ScreenBox.h:92
ScreenBox(const Vertex2D &coordA, const Vertex2D &coordB)
double GetMinX() const
Definition ScreenBox.h:82
double GetSize() const
Definition ScreenBox.h:123
double GetMinY() const
Definition ScreenBox.h:87
Definition Area.h:39