QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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
38class CORE_EXPORT QgsEllipse
39{
40
41 public:
42
47
48 virtual ~QgsEllipse() = default;
49
57 QgsEllipse( const QgsPoint &center, double semiMajorAxis, double semiMinorAxis, double azimuth = 90 ) SIP_HOLDGIL;
58
70 static QgsEllipse fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 ) SIP_HOLDGIL;
71
82 static QgsEllipse fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
83
94 static QgsEllipse fromCenterPoint( const QgsPoint &ptc, const QgsPoint &pt1 ) SIP_HOLDGIL;
95
107 static QgsEllipse fromCenter2Points( const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
108
109 virtual bool operator ==( const QgsEllipse &elp ) const;
110 virtual bool operator !=( const QgsEllipse &elp ) const;
111
113 virtual bool isEmpty() const SIP_HOLDGIL;
114
120 QgsPoint center() const SIP_HOLDGIL {return mCenter; }
121
126 double semiMajorAxis() const SIP_HOLDGIL {return mSemiMajorAxis; }
127
132 double semiMinorAxis() const SIP_HOLDGIL {return mSemiMinorAxis; }
133
138 double azimuth() const SIP_HOLDGIL {return mAzimuth; }
139
147 QgsPoint &rcenter() SIP_SKIP { return mCenter; }
148
154 void setCenter( const QgsPoint &center ) SIP_HOLDGIL {mCenter = center; }
155
160 virtual void setSemiMajorAxis( double semiMajorAxis ) SIP_HOLDGIL;
161
166 virtual void setSemiMinorAxis( double semiMinorAxis ) SIP_HOLDGIL;
167
172 void setAzimuth( double azimuth ) SIP_HOLDGIL;
173
180 virtual double focusDistance() const SIP_HOLDGIL;
181
188 virtual QVector<QgsPoint> foci() const;
189
194 virtual double eccentricity() const SIP_HOLDGIL;
196 virtual double area() const SIP_HOLDGIL;
198 virtual double perimeter() const SIP_HOLDGIL;
199
205 virtual QVector<QgsPoint> quadrant() const;
206
211 virtual QgsPointSequence points( unsigned int segments = 36 ) const;
212
217 virtual QgsPolygon *toPolygon( unsigned int segments = 36 ) const SIP_FACTORY;
218
223 virtual QgsLineString *toLineString( unsigned int segments = 36 ) const SIP_FACTORY;
224 //virtual QgsCurvePolygon toCurvePolygon() const;
225
229 virtual QgsPolygon *orientedBoundingBox() const SIP_FACTORY;
230
234 virtual QgsRectangle boundingBox() const;
235
240 virtual QString toString( int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2 ) const;
241
242#ifdef SIP_RUN
243 SIP_PYOBJECT __repr__();
244 % MethodCode
245 QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() );
246 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
247 % End
248#endif
249
250 protected:
252 double mSemiMajorAxis = 0.0;
253 double mSemiMinorAxis = 0.0;
254 double mAzimuth = 90.0;
255
256 private:
258 void normalizeAxis();
259
260 void pointsInternal( unsigned int segments, QVector< double> &x, QVector< double> &y, QVector<double> &z, QVector< double> &m ) const;
261};
262
263#endif // QGSELLIPSE_H
Ellipse geometry type.
Definition qgsellipse.h:39
QgsPoint mCenter
Definition qgsellipse.h:251
QgsPoint & rcenter()
Returns a reference to the center point of this ellipse.
Definition qgsellipse.h:147
double semiMajorAxis() const
Returns the semi-major axis.
Definition qgsellipse.h:126
void setCenter(const QgsPoint &center)
Sets the center point.
Definition qgsellipse.h:154
double azimuth() const
Returns the azimuth.
Definition qgsellipse.h:138
QgsEllipse()=default
Constructor for QgsEllipse.
double semiMinorAxis() const
Returns the semi-minor axis.
Definition qgsellipse.h:132
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:33
A rectangle specified with double values.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_HOLDGIL
Definition qgis_sip.h:171
#define SIP_FACTORY
Definition qgis_sip.h:76
QVector< QgsPoint > QgsPointSequence