QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsellipse.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsellipse.h
3 --------------
4 begin : March 2017
5 copyright : (C) 2017 by Loîc Bartoletti
6 email : lbartoletti at tuxfamily dot org
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 QGSELLIPSE_H
19#define QGSELLIPSE_H
20
21#include <QString>
22
23#include "qgis_core.h"
24#include "qgspoint.h"
25#include "qgspolygon.h"
26#include "qgslinestring.h"
27#include "qgsrectangle.h"
28
39class CORE_EXPORT QgsEllipse
40{
41
42 public:
43
48
49 virtual ~QgsEllipse() = default;
50
58 QgsEllipse( const QgsPoint &center, double semiMajorAxis, double semiMinorAxis, double azimuth = 90 ) SIP_HOLDGIL;
59
71 static QgsEllipse fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 ) SIP_HOLDGIL;
72
83 static QgsEllipse fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
84
95 static QgsEllipse fromCenterPoint( const QgsPoint &ptc, const QgsPoint &pt1 ) SIP_HOLDGIL;
96
108 static QgsEllipse fromCenter2Points( const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
109
110 virtual bool operator ==( const QgsEllipse &elp ) const;
111 virtual bool operator !=( const QgsEllipse &elp ) const;
112
114 virtual bool isEmpty() const SIP_HOLDGIL;
115
121 QgsPoint center() const SIP_HOLDGIL {return mCenter; }
122
127 double semiMajorAxis() const SIP_HOLDGIL {return mSemiMajorAxis; }
128
133 double semiMinorAxis() const SIP_HOLDGIL {return mSemiMinorAxis; }
134
139 double azimuth() const SIP_HOLDGIL {return mAzimuth; }
140
148 QgsPoint &rcenter() SIP_SKIP { return mCenter; }
149
155 void setCenter( const QgsPoint &center ) SIP_HOLDGIL {mCenter = center; }
156
161 virtual void setSemiMajorAxis( double semiMajorAxis ) SIP_HOLDGIL;
162
167 virtual void setSemiMinorAxis( double semiMinorAxis ) SIP_HOLDGIL;
168
173 void setAzimuth( double azimuth ) SIP_HOLDGIL;
174
181 virtual double focusDistance() const SIP_HOLDGIL;
182
189 virtual QVector<QgsPoint> foci() const;
190
195 virtual double eccentricity() const SIP_HOLDGIL;
197 virtual double area() const SIP_HOLDGIL;
199 virtual double perimeter() const SIP_HOLDGIL;
200
206 virtual QVector<QgsPoint> quadrant() const;
207
212 virtual QgsPointSequence points( unsigned int segments = 36 ) const;
213
218 virtual QgsPolygon *toPolygon( unsigned int segments = 36 ) const SIP_FACTORY;
219
224 virtual QgsLineString *toLineString( unsigned int segments = 36 ) const SIP_FACTORY;
225 //virtual QgsCurvePolygon toCurvePolygon() const;
226
230 virtual QgsPolygon *orientedBoundingBox() const SIP_FACTORY;
231
235 virtual QgsRectangle boundingBox() const;
236
241 virtual QString toString( int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2 ) const;
242
243#ifdef SIP_RUN
244 SIP_PYOBJECT __repr__();
245 % MethodCode
246 QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() );
247 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
248 % End
249#endif
250
251 protected:
253 double mSemiMajorAxis = 0.0;
254 double mSemiMinorAxis = 0.0;
255 double mAzimuth = 90.0;
256
257 private:
259 void normalizeAxis();
260};
261
262#endif // QGSELLIPSE_H
Ellipse geometry type.
Definition qgsellipse.h:40
QgsPoint mCenter
Definition qgsellipse.h:252
QgsPoint & rcenter()
Returns a reference to the center point of this ellipse.
Definition qgsellipse.h:148
double semiMajorAxis() const
Returns the semi-major axis.
Definition qgsellipse.h:127
void setCenter(const QgsPoint &center)
Sets the center point.
Definition qgsellipse.h:155
double azimuth() const
Returns the azimuth.
Definition qgsellipse.h:139
QgsEllipse()=default
Constructor for QgsEllipse.
double semiMinorAxis() const
Returns the semi-minor axis.
Definition qgsellipse.h:133
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Polygon geometry type.
Definition qgspolygon.h:34
A rectangle specified with double values.
#define str(x)
Definition qgis.cpp:38
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_HOLDGIL
Definition qgis_sip.h:166
#define SIP_FACTORY
Definition qgis_sip.h:76
QVector< QgsPoint > QgsPointSequence