QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
qgsrectangle.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrectangle.h - description
3
-------------------
4
begin : Sat Jun 22 2002
5
copyright : (C) 2002 by Gary E.Sherman
6
email : sherman at mrcc.com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSRECTANGLE_H
19
#define QGSRECTANGLE_H
20
21
#include <iosfwd>
22
#include <QDomDocument>
23
24
class
QString;
25
class
QRectF;
26
#include "
qgspoint.h
"
27
28
35
class
CORE_EXPORT
QgsRectangle
36
{
37
public
:
39
QgsRectangle
(
double
xmin = 0,
double
ymin = 0,
double
xmax = 0,
double
ymax = 0 );
41
QgsRectangle
(
const
QgsPoint
& p1,
const
QgsPoint
& p2 );
43
QgsRectangle
(
const
QRectF & qRectF );
45
QgsRectangle
(
const
QgsRectangle
&other );
47
~
QgsRectangle
();
50
void
set
(
const
QgsPoint
& p1,
const
QgsPoint
& p2 );
53
void
set
(
double
xmin,
double
ymin,
double
xmax,
double
ymax );
55
void
setXMinimum(
double
x );
57
void
setXMaximum(
double
x );
59
void
setYMinimum(
double
y );
61
void
setYMaximum(
double
y );
64
void
setMinimal();
66
double
xMaximum()
const
;
68
double
xMinimum()
const
;
70
double
yMaximum()
const
;
72
double
yMinimum()
const
;
74
void
normalize();
76
double
width()
const
;
78
double
height()
const
;
80
QgsPoint
center()
const
;
82
void
scale(
double
scaleFactor,
const
QgsPoint
*c = 0 );
83
void
scale(
double
scaleFactor,
double
centerX,
double
centerY );
86
QgsRectangle
buffer(
double
width );
88
QgsRectangle
intersect(
const
QgsRectangle
*rect )
const
;
90
bool
intersects(
const
QgsRectangle
& rect )
const
;
92
bool
contains(
const
QgsRectangle
& rect )
const
;
94
bool
contains(
const
QgsPoint
&p )
const
;
96
void
combineExtentWith(
QgsRectangle
*rect );
98
void
combineExtentWith(
double
x,
double
y );
101
bool
isEmpty()
const
;
105
bool
isNull
()
const
;
107
QString asWktCoordinates()
const
;
109
QString asWktPolygon()
const
;
111
QRectF toRectF()
const
;
113
QString toString(
bool
automaticPrecision =
false
)
const
;
115
QString toString(
int
thePrecision )
const
;
117
QString asPolygon()
const
;
121
bool
operator==
(
const
QgsRectangle
&r1 )
const
;
125
bool
operator!=
(
const
QgsRectangle
&r1 )
const
;
129
QgsRectangle
& operator=(
const
QgsRectangle
&r1 );
130
132
void
unionRect(
const
QgsRectangle
& rect );
133
136
bool
isFinite()
const
;
137
139
void
invert();
140
141
protected
:
142
143
// These are protected instead of private so that things like
144
// the QgsPostGisBox3d can get at them.
145
146
double
xmin
;
147
double
ymin
;
148
double
xmax
;
149
double
ymax
;
150
151
};
152
153
154
inline
QgsRectangle::~QgsRectangle
()
155
{
156
}
157
158
inline
void
QgsRectangle::setXMinimum
(
double
x )
159
{
160
xmin
= x;
161
}
162
163
inline
void
QgsRectangle::setXMaximum
(
double
x )
164
{
165
xmax
= x;
166
}
167
168
inline
void
QgsRectangle::setYMinimum
(
double
y )
169
{
170
ymin
= y;
171
}
172
173
inline
void
QgsRectangle::setYMaximum
(
double
y )
174
{
175
ymax
= y;
176
}
177
178
inline
double
QgsRectangle::xMaximum
()
const
179
{
180
return
xmax
;
181
}
182
183
inline
double
QgsRectangle::xMinimum
()
const
184
{
185
return
xmin
;
186
}
187
188
inline
double
QgsRectangle::yMaximum
()
const
189
{
190
return
ymax
;
191
}
192
193
inline
double
QgsRectangle::yMinimum
()
const
194
{
195
return
ymin
;
196
}
197
198
inline
double
QgsRectangle::width
()
const
199
{
200
return
xmax
-
xmin
;
201
}
202
203
inline
double
QgsRectangle::height
()
const
204
{
205
return
ymax
-
ymin
;
206
}
207
208
inline
QgsPoint
QgsRectangle::center
()
const
209
{
210
return
QgsPoint
(
xmin
+
width
() / 2,
ymin
+
height
() / 2 );
211
}
212
inline
std::ostream&
operator <<
( std::ostream& os,
const
QgsRectangle
&r )
213
{
214
return
os << r.
toString
().toLocal8Bit().data();
215
}
216
217
#endif // QGSRECTANGLE_H
Generated on Sun May 10 2015 16:33:24 for QGIS API Documentation by
1.8.1.2