SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
mapextent.h
Go to the documentation of this file.
1
10#ifndef MAPEXTENT_H
11#define MAPEXTENT_H
12
13#include <QRectF>
14#include <QString>
15
17
26{
27public:
28
32 MapExtent() = default;
33
41 MapExtent(double xMin, double yMin, double xMax, double yMax);
42
46 explicit MapExtent(const QRectF &rect);
47
48 // ----- Accessors -------------------------------------------------------
49
50 [[nodiscard]] double xMin() const { return m_xMin; }
51 [[nodiscard]] double yMin() const { return m_yMin; }
52 [[nodiscard]] double xMax() const { return m_xMax; }
53 [[nodiscard]] double yMax() const { return m_yMax; }
54
55 [[nodiscard]] double width() const { return m_xMax - m_xMin; }
56 [[nodiscard]] double height() const { return m_yMax - m_yMin; }
57 [[nodiscard]] double centerX() const { return (m_xMin + m_xMax) * 0.5; }
58 [[nodiscard]] double centerY() const { return (m_yMin + m_yMax) * 0.5; }
59
63 [[nodiscard]] bool isValid() const;
64
68 [[nodiscard]] bool isNull() const;
69
70 // ----- Conversion ------------------------------------------------------
71
75 [[nodiscard]] QRectF toRectF() const;
76
80 [[nodiscard]] QString toString() const;
81
82 // ----- Mutators --------------------------------------------------------
83
84 void setXMin(double v) { m_xMin = v; }
85 void setYMin(double v) { m_yMin = v; }
86 void setXMax(double v) { m_xMax = v; }
87 void setYMax(double v) { m_yMax = v; }
88
92 void expandToInclude(double x, double y);
93
97 void expandToInclude(const MapExtent &other);
98
103 void growByFactor(double factor);
104
108 [[nodiscard]] MapExtent scaled(double factor) const;
109
113 [[nodiscard]] MapExtent panned(double dx, double dy) const;
114
119 [[nodiscard]] MapExtent intersected(const MapExtent &other) const;
120
124 [[nodiscard]] MapExtent united(const MapExtent &other) const;
125
129 [[nodiscard]] bool contains(double x, double y) const;
130
134 [[nodiscard]] bool contains(const MapExtent &other) const;
135
139 [[nodiscard]] bool intersects(const MapExtent &other) const;
140
141 // ----- Operators -------------------------------------------------------
142
143 bool operator==(const MapExtent &other) const;
144 bool operator!=(const MapExtent &other) const;
145
146private:
147 double m_xMin = 0.0;
148 double m_yMin = 0.0;
149 double m_xMax = 0.0;
150 double m_yMax = 0.0;
151};
152
153#endif // MAPEXTENT_H
An axis-aligned bounding box in the coordinate space of a given CRS.
Definition mapextent.h:26
MapExtent intersected(const MapExtent &other) const
Returns the intersection of this extent and other. Returns a null extent if they do not overlap.
Definition mapextent.cpp:97
double xMin() const
Definition mapextent.h:50
double centerX() const
Definition mapextent.h:57
bool intersects(const MapExtent &other) const
Returns true when this extent intersects (overlaps) other.
Definition mapextent.cpp:127
double yMax() const
Definition mapextent.h:53
void setXMin(double v)
Definition mapextent.h:84
bool contains(double x, double y) const
Returns true when this extent contains the given point.
Definition mapextent.cpp:116
void setYMin(double v)
Definition mapextent.h:85
double width() const
Definition mapextent.h:55
double xMax() const
Definition mapextent.h:52
void growByFactor(double factor)
Grows the extent by factor on all sides (relative to centre).
Definition mapextent.cpp:75
bool isNull() const
Returns true when this extent is equal to a default-constructed one.
Definition mapextent.cpp:38
void setYMax(double v)
Definition mapextent.h:87
double centerY() const
Definition mapextent.h:58
MapExtent panned(double dx, double dy) const
Returns a new extent panned by the given delta values.
Definition mapextent.cpp:92
MapExtent united(const MapExtent &other) const
Returns an extent that exactly contains both this and other.
Definition mapextent.cpp:107
MapExtent scaled(double factor) const
Returns a new extent scaled by factor around the centre point.
Definition mapextent.cpp:85
double height() const
Definition mapextent.h:56
bool operator==(const MapExtent &other) const
Definition mapextent.cpp:133
void setXMax(double v)
Definition mapextent.h:86
bool operator!=(const MapExtent &other) const
Definition mapextent.cpp:139
bool isValid() const
Returns true when all coordinates are finite and xMin < xMax and yMin < yMax.
Definition mapextent.cpp:31
QRectF toRectF() const
Returns a QRectF(xMin, yMin, width, height) representation.
Definition mapextent.cpp:43
MapExtent()=default
Constructs a default (null) extent.
QString toString() const
Returns a human-readable "[xMin, yMin] — [xMax, yMax]" string.
Definition mapextent.cpp:48
void expandToInclude(double x, double y)
Expands this extent to include the point (x, y).
Definition mapextent.cpp:54
double yMin() const
Definition mapextent.h:51
Represents a coordinate reference system backed by a GDAL OGRSpatialReference.
Definition spatialreferencesystem.h:28
std::vector< float > dx
Definition mesh2dresultsexport.cpp:611
std::vector< float > dy
Green–Gauss only, parallel to cell
Definition mesh2dresultsexport.cpp:611
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159