QGIS API Documentation  3.0.2-Girona (307d082)
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 
39 class CORE_EXPORT QgsEllipse
40 {
41 
42  public:
43 
47  QgsEllipse() = default;
48 
49  virtual ~QgsEllipse() = default;
50 
58  QgsEllipse( const QgsPoint &center, const double semiMajorAxis, const double semiMinorAxis, const double azimuth = 90 );
59 
71  static QgsEllipse fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 );
72 
83  static QgsEllipse fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 );
84 
95  static QgsEllipse fromCenterPoint( const QgsPoint &ptc, const QgsPoint &pt1 );
96 
108  static QgsEllipse fromCenter2Points( const QgsPoint &ptc, const QgsPoint &pt1, const QgsPoint &pt2 );
109 
110  virtual bool operator ==( const QgsEllipse &elp ) const;
111  virtual bool operator !=( const QgsEllipse &elp ) const;
112 
114  virtual bool isEmpty() const;
115 
121  QgsPoint center() const {return mCenter; }
122 
127  double semiMajorAxis() const {return mSemiMajorAxis; }
128 
133  double semiMinorAxis() const {return mSemiMinorAxis; }
134 
139  double azimuth() const {return mAzimuth; }
140 
148  QgsPoint &rcenter() SIP_SKIP { return mCenter; }
149 
155  void setCenter( const QgsPoint &center ) {mCenter = center; }
156 
161  virtual void setSemiMajorAxis( const double semiMajorAxis );
162 
167  virtual void setSemiMinorAxis( const double semiMinorAxis );
168 
173  void setAzimuth( const double azimuth );
174 
181  virtual double focusDistance() const;
182 
189  virtual QVector<QgsPoint> foci() const;
190 
195  virtual double eccentricity() const;
197  virtual double area() const;
199  virtual double perimeter() const;
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  protected:
245  double mSemiMajorAxis = 0.0;
246  double mSemiMinorAxis = 0.0;
247  double mAzimuth = 90.0;
248 
249  private:
251  void normalizeAxis();
252 };
253 
254 #endif // QGSELLIPSE_H
A rectangle specified with double values.
Definition: qgsrectangle.h:39
double semiMinorAxis() const
Returns the semi-minor axis.
Definition: qgsellipse.h:133
QgsPoint & rcenter()
Returns a reference to the center point of this ellipse.
Definition: qgsellipse.h:148
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double semiMajorAxis() const
Returns the semi-major axis.
Definition: qgsellipse.h:127
QgsPoint center() const
Returns the center point.
Definition: qgsellipse.h:121
void setCenter(const QgsPoint &center)
Sets the center point.
Definition: qgsellipse.h:155
QgsPoint mCenter
Definition: qgsellipse.h:244
double azimuth() const
Returns the azimuth.
Definition: qgsellipse.h:139
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_FACTORY
Definition: qgis_sip.h:69
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QVector< QgsPoint > QgsPointSequence
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:41
Ellipse geometry type.
Definition: qgsellipse.h:39
Polygon geometry type.
Definition: qgspolygon.h:31