QGIS API Documentation 3.99.0-Master (e9821da5c6b)
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 : lituus at free dot fr
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 "qgis_core.h"
22#include "qgslinestring.h"
23#include "qgspoint.h"
24#include "qgspolygon.h"
25#include "qgsrectangle.h"
26
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
40class CORE_EXPORT QgsEllipse
41{
42
43 public:
44
49
50 virtual ~QgsEllipse() = default;
51
59 QgsEllipse( const QgsPoint &center, double semiMajorAxis, double semiMinorAxis, double azimuth = 90 ) SIP_HOLDGIL;
60
72 static QgsEllipse fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 ) SIP_HOLDGIL;
73
84 static QgsEllipse fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
85
96 static QgsEllipse fromCenterPoint( const QgsPoint &ptc, const QgsPoint &pt1 ) SIP_HOLDGIL;
97
109 static QgsEllipse fromCenter2Points( const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
110
111 virtual bool operator ==( const QgsEllipse &elp ) const;
112 virtual bool operator !=( const QgsEllipse &elp ) const;
113
115 virtual bool isEmpty() const SIP_HOLDGIL;
116
123
128 double semiMajorAxis() const SIP_HOLDGIL {return mSemiMajorAxis; }
129
134 double semiMinorAxis() const SIP_HOLDGIL {return mSemiMinorAxis; }
135
140 double azimuth() const SIP_HOLDGIL {return mAzimuth; }
141
150
157
162 virtual void setSemiMajorAxis( double semiMajorAxis ) SIP_HOLDGIL;
163
168 virtual void setSemiMinorAxis( double semiMinorAxis ) SIP_HOLDGIL;
169
174 void setAzimuth( double azimuth ) SIP_HOLDGIL;
175
182 virtual double focusDistance() const SIP_HOLDGIL;
183
190 virtual QVector<QgsPoint> foci() const;
191
196 virtual double eccentricity() const SIP_HOLDGIL;
198 virtual double area() const SIP_HOLDGIL;
200 virtual double perimeter() const SIP_HOLDGIL;
201
207 virtual QVector<QgsPoint> quadrant() const;
208
213 virtual QgsPointSequence points( unsigned int segments = 36 ) const;
214
219 virtual QgsPolygon *toPolygon( unsigned int segments = 36 ) const SIP_FACTORY;
220
225 virtual QgsLineString *toLineString( unsigned int segments = 36 ) const SIP_FACTORY;
226 //virtual QgsCurvePolygon toCurvePolygon() const;
227
231 virtual QgsPolygon *orientedBoundingBox() const SIP_FACTORY;
232
236 virtual QgsRectangle boundingBox() const;
237
242 virtual QString toString( int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2 ) const;
243
244#ifdef SIP_RUN
245 SIP_PYOBJECT __repr__();
246 % MethodCode
247 QString str = u"<QgsEllipse: %1>"_s.arg( sipCpp->toString() );
248 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
249 % End
250#endif
251
252 protected:
254 double mSemiMajorAxis = 0.0;
255 double mSemiMinorAxis = 0.0;
256 double mAzimuth = 90.0;
257
258 private:
260 void normalizeAxis();
261
262 void pointsInternal( unsigned int segments, QVector< double> &x, QVector< double> &y, QVector<double> &z, QVector< double> &m ) const;
263};
264
265#endif // QGSELLIPSE_H
QgsPoint mCenter
Definition qgsellipse.h:253
QgsPoint & rcenter()
Returns a reference to the center point of this ellipse.
Definition qgsellipse.h:149
QgsPoint center() const
Returns the center point.
Definition qgsellipse.h:122
double semiMajorAxis() const
Returns the semi-major axis.
Definition qgsellipse.h:128
static QgsEllipse fromCenterPoint(const QgsPoint &ptc, const QgsPoint &pt1)
Constructs an ellipse by a center point and a another point.
void setCenter(const QgsPoint &center)
Sets the center point.
Definition qgsellipse.h:156
double mAzimuth
Definition qgsellipse.h:256
double mSemiMajorAxis
Definition qgsellipse.h:254
double azimuth() const
Returns the azimuth.
Definition qgsellipse.h:140
QgsEllipse()=default
Constructor for QgsEllipse.
static QgsEllipse fromExtent(const QgsPoint &pt1, const QgsPoint &pt2)
Constructs an ellipse by an extent (aka bounding box / QgsRectangle).
virtual bool isEmpty() const
An ellipse is empty if axes are equal to 0.
double mSemiMinorAxis
Definition qgsellipse.h:255
static QgsEllipse fromFoci(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3)
Constructs an ellipse by foci (pt1 and pt2) and a point pt3.
double semiMinorAxis() const
Returns the semi-minor axis.
Definition qgsellipse.h:134
static QgsEllipse fromCenter2Points(const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2)
Constructs an ellipse by a central point and two other points.
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:53
Polygon geometry type.
Definition qgspolygon.h:37
A rectangle specified with double values.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_FACTORY
Definition qgis_sip.h:84
QVector< QgsPoint > QgsPointSequence