Quantum GIS API Documentation
1.7.5-Wroclaw
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
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
/* $Id$ */
18
19
#ifndef QGSRECT_H
20
#define QGSRECT_H
21
22
#include <iosfwd>
23
24
class
QString;
25
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
(
QgsPoint
const
& p1,
QgsPoint
const
& p2 );
43
QgsRectangle
(
const
QgsRectangle
&other );
45
~
QgsRectangle
();
47
//normalised after construction.
48
void
set(
const
QgsPoint
& p1,
const
QgsPoint
& p2 );
50
// normalised after construction.
51
void
set(
double
xmin,
double
ymin,
double
xmax,
double
ymax );
53
void
setXMinimum(
double
x );
55
void
setXMaximum(
double
x );
57
void
setYMinimum(
double
y );
59
void
setYMaximum(
double
y );
61
// and max corner is at min. It is NOT normalized.
62
void
setMinimal();
64
double
xMaximum()
const
;
66
double
xMinimum()
const
;
68
double
yMaximum()
const
;
70
double
yMinimum()
const
;
72
void
normalize();
74
double
width()
const
;
76
double
height()
const
;
78
QgsPoint
center()
const
;
80
void
scale(
double
,
const
QgsPoint
*c = 0 );
82
void
expand(
double
,
const
QgsPoint
*c = 0 );
84
QgsRectangle
intersect(
const
QgsRectangle
*rect )
const
;
86
bool
intersects(
const
QgsRectangle
& rect )
const
;
89
bool
contains(
const
QgsRectangle
& rect )
const
;
92
bool
contains(
const
QgsPoint
&p )
const
;
94
void
combineExtentWith(
QgsRectangle
*rect );
96
void
combineExtentWith(
double
x,
double
y );
98
bool
isEmpty()
const
;
100
QString asWktCoordinates()
const
;
102
QString toString(
bool
automaticPrecision =
false
)
const
;
104
QString toString(
int
thePrecision )
const
;
106
QString asPolygon()
const
;
110
bool
operator==
(
const
QgsRectangle
&r1 )
const
;
114
bool
operator!=(
const
QgsRectangle
&r1 )
const
;
118
QgsRectangle
& operator=(
const
QgsRectangle
&r1 );
119
121
void
unionRect(
const
QgsRectangle
& rect );
122
125
bool
isFinite()
const
;
126
127
protected
:
128
129
// These are protected instead of private so that things like
130
// the QgsPostGisBox3d can get at them.
131
132
double
xmin
;
133
double
ymin
;
134
double
xmax
;
135
double
ymax
;
136
137
};
138
139
140
inline
QgsRectangle::~QgsRectangle
()
141
{
142
}
143
144
inline
void
QgsRectangle::setXMinimum
(
double
x )
145
{
146
xmin
= x;
147
}
148
149
inline
void
QgsRectangle::setXMaximum
(
double
x )
150
{
151
xmax
= x;
152
}
153
154
inline
void
QgsRectangle::setYMinimum
(
double
y )
155
{
156
ymin
= y;
157
}
158
159
inline
void
QgsRectangle::setYMaximum
(
double
y )
160
{
161
ymax
= y;
162
}
163
164
inline
double
QgsRectangle::xMaximum
()
const
165
{
166
return
xmax
;
167
}
168
169
inline
double
QgsRectangle::xMinimum
()
const
170
{
171
return
xmin
;
172
}
173
174
inline
double
QgsRectangle::yMaximum
()
const
175
{
176
return
ymax
;
177
}
178
179
inline
double
QgsRectangle::yMinimum
()
const
180
{
181
return
ymin
;
182
}
183
184
inline
double
QgsRectangle::width
()
const
185
{
186
return
xmax
-
xmin
;
187
}
188
189
inline
double
QgsRectangle::height
()
const
190
{
191
return
ymax
-
ymin
;
192
}
193
194
inline
QgsPoint
QgsRectangle::center
()
const
195
{
196
return
QgsPoint
(
xmin
+
width
() / 2,
ymin
+
height
() / 2 );
197
}
198
inline
std::ostream&
operator <<
( std::ostream& os,
const
QgsRectangle
&r )
199
{
200
return
os << r.
toString
().toLocal8Bit().data();
201
}
202
203
#endif // QGSRECT_H
Generated on Thu Sep 19 2013 17:30:54 for Quantum GIS API Documentation by
1.8.4