QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCMapPolygon Class Reference

The QGCMapPolygon class provides a polygon which can be displayed on a map using a map visuals control. More...

#include <QGCMapPolygon.h>

Inheritance diagram for QGCMapPolygon:
Collaboration diagram for QGCMapPolygon:

Signals

void countChanged (int count)
void pathChanged (void)
void dragPathChanged (void)
void dirtyChanged (bool dirty)
void cleared (void)
void centerChanged (QGeoCoordinate center)
void dragCenterChanged (QGeoCoordinate center)
void centerDragChanged (bool centerDrag)
void vertexDragChanged (bool vertexDrag)
void interactiveChanged (bool interactive)
bool isValidChanged (void)
bool isEmptyChanged (void)
void traceModeChanged (bool traceMode)
void showAltColorChanged (bool showAltColor)
void selectedVertexChanged (int index)

Public Member Functions

 QGCMapPolygon (QObject *parent=nullptr)
 QGCMapPolygon (const QGCMapPolygon &other, QObject *parent=nullptr)
 ~QGCMapPolygon () override
const QGCMapPolygon & operator= (const QGCMapPolygon &other)
Q_INVOKABLE void clear (void)
Q_INVOKABLE void appendVertex (const QGeoCoordinate &coordinate)
Q_INVOKABLE void removeVertex (int vertexIndex)
Q_INVOKABLE void appendVertices (const QVariantList &varCoords)
void appendVertices (const QList< QGeoCoordinate > &coordinates)
Q_INVOKABLE void adjustVertex (int vertexIndex, const QGeoCoordinate coordinate)
Q_INVOKABLE void splitPolygonSegment (int vertexIndex)
 Splits the segment comprised of vertextIndex -> vertexIndex + 1.
Q_INVOKABLE bool containsCoordinate (const QGeoCoordinate &coordinate) const
 Returns true if the specified coordinate is within the polygon.
Q_INVOKABLE bool offset (double distance)
Q_INVOKABLE bool loadKMLOrSHPFile (const QString &file)
QList< QGeoCoordinate > coordinateList (void) const
 Returns the path in a list of QGeoCoordinate's format.
Q_INVOKABLE QGeoCoordinate vertexCoordinate (int vertex) const
 Returns the QGeoCoordinate for the vertex specified.
Q_INVOKABLE void verifyClockwiseWinding (void)
 Adjust polygon winding order to be clockwise (if needed).
bool isClockwise () const
Q_INVOKABLE void beginReset (void)
Q_INVOKABLE void endReset (void)
void saveToJson (QJsonObject &json)
bool loadFromJson (const QJsonObject &json, bool required, QString &errorString)
QList< QPointF > nedPolygon (void) const
 Convert polygon to NED and return (D is ignored).
double area (void) const
 Returns the area of the polygon in meters squared.
QDomElement kmlPolygonElement (KMLDomDocument &domDocument)
int count (void) const
bool dirty (void) const
void setDirty (bool dirty)
QGeoCoordinate center (void) const
bool centerDrag (void) const
bool vertexDrag (void) const
bool interactive (void) const
bool isValid (void) const
bool empty (void) const
bool traceMode (void) const
bool showAltColor (void) const
int selectedVertex () const
QVariantList path (void) const
QmlObjectListModel * qmlPathModel (void)
QmlObjectListModel & pathModel (void)
void setPath (const QList< QGeoCoordinate > &path)
void setPath (const QVariantList &path)
void setCenter (QGeoCoordinate newCenter)
void setCenterDrag (bool centerDrag)
void setVertexDrag (bool vertexDrag)
void setInteractive (bool interactive)
void setTraceMode (bool traceMode)
void setShowAltColor (bool showAltColor)
void selectVertex (int index)

Static Public Attributes

static constexpr const char * jsonPolygonKey = "polygon"

Detailed Description

The QGCMapPolygon class provides a polygon which can be displayed on a map using a map visuals control.

It maintains a representation of the polygon on QVariantList and QmlObjectListModel format.

Definition at line 17 of file QGCMapPolygon.h.

Constructor & Destructor Documentation

◆ QGCMapPolygon() [1/2]

QGCMapPolygon::QGCMapPolygon ( QObject * parent = nullptr)

◆ QGCMapPolygon() [2/2]

QGCMapPolygon::QGCMapPolygon ( const QGCMapPolygon & other,
QObject * parent = nullptr )

Definition at line 28 of file QGCMapPolygon.cc.

References QGCMapPolygon().

◆ ~QGCMapPolygon()

QGCMapPolygon::~QGCMapPolygon ( )
override

Definition at line 40 of file QGCMapPolygon.cc.

References pathChanged(), and qgcApp.

Member Function Documentation

◆ adjustVertex()

void QGCMapPolygon::adjustVertex ( int vertexIndex,
const QGeoCoordinate coordinate )

Adjust the value for the specified coordinate

Parameters
vertexIndexPolygon point index to modify (0-based)
coordinateNew coordinate for point

Definition at line 101 of file QGCMapPolygon.cc.

References dragPathChanged(), pathChanged(), and setDirty().

Referenced by setCenter().

◆ appendVertex()

void QGCMapPolygon::appendVertex ( const QGeoCoordinate & coordinate)

◆ appendVertices() [1/2]

void QGCMapPolygon::appendVertices ( const QList< QGeoCoordinate > & coordinates)

Definition at line 300 of file QGCMapPolygon.cc.

References beginReset(), dragPathChanged(), endReset(), and pathChanged().

◆ appendVertices() [2/2]

void QGCMapPolygon::appendVertices ( const QVariantList & varCoords)

◆ area()

double QGCMapPolygon::area ( void ) const

Returns the area of the polygon in meters squared.

Definition at line 571 of file QGCMapPolygon.cc.

References nedPolygon().

◆ beginReset()

void QGCMapPolygon::beginReset ( void )

Definition at line 624 of file QGCMapPolygon.cc.

Referenced by appendVertices(), loadKMLOrSHPFile(), offset(), and verifyClockwiseWinding().

◆ center()

QGeoCoordinate QGCMapPolygon::center ( void ) const
inline

Definition at line 111 of file QGCMapPolygon.h.

Referenced by centerChanged(), and dragCenterChanged().

◆ centerChanged

void QGCMapPolygon::centerChanged ( QGeoCoordinate center)
signal

References center().

Referenced by setCenter(), and setCenterDrag().

◆ centerDrag()

bool QGCMapPolygon::centerDrag ( void ) const
inline

Definition at line 112 of file QGCMapPolygon.h.

Referenced by centerDragChanged(), and setCenterDrag().

◆ centerDragChanged

void QGCMapPolygon::centerDragChanged ( bool centerDrag)
signal

References centerDrag().

Referenced by setCenterDrag().

◆ clear()

void QGCMapPolygon::clear ( void )

◆ cleared

void QGCMapPolygon::cleared ( void )
signal

Referenced by clear().

◆ containsCoordinate()

bool QGCMapPolygon::containsCoordinate ( const QGeoCoordinate & coordinate) const

Returns true if the specified coordinate is within the polygon.

Definition at line 174 of file QGCMapPolygon.cc.

◆ coordinateList()

QList< QGeoCoordinate > QGCMapPolygon::coordinateList ( void ) const

Returns the path in a list of QGeoCoordinate's format.

Definition at line 245 of file QGCMapPolygon.cc.

◆ count()

int QGCMapPolygon::count ( void ) const
inline

◆ countChanged

void QGCMapPolygon::countChanged ( int count)
signal

◆ dirty()

bool QGCMapPolygon::dirty ( void ) const
inline

Definition at line 109 of file QGCMapPolygon.h.

Referenced by dirtyChanged(), selectedVertexChanged(), and setDirty().

◆ dirtyChanged

void QGCMapPolygon::dirtyChanged ( bool dirty)
signal

◆ dragCenterChanged

void QGCMapPolygon::dragCenterChanged ( QGeoCoordinate center)
signal

References center().

Referenced by setCenter().

◆ dragPathChanged

void QGCMapPolygon::dragPathChanged ( void )
signal

◆ empty()

bool QGCMapPolygon::empty ( void ) const
inline

Definition at line 116 of file QGCMapPolygon.h.

◆ endReset()

void QGCMapPolygon::endReset ( void )

Definition at line 629 of file QGCMapPolygon.cc.

Referenced by appendVertices(), loadKMLOrSHPFile(), offset(), and verifyClockwiseWinding().

◆ interactive()

bool QGCMapPolygon::interactive ( void ) const
inline

Definition at line 114 of file QGCMapPolygon.h.

Referenced by interactiveChanged(), and setInteractive().

◆ interactiveChanged

void QGCMapPolygon::interactiveChanged ( bool interactive)
signal

References interactive().

Referenced by setInteractive().

◆ isClockwise()

bool QGCMapPolygon::isClockwise ( ) const

Definition at line 591 of file QGCMapPolygon.cc.

Referenced by verifyClockwiseWinding().

◆ isEmptyChanged

bool QGCMapPolygon::isEmptyChanged ( void )
signal

◆ isValid()

bool QGCMapPolygon::isValid ( void ) const
inline

Definition at line 115 of file QGCMapPolygon.h.

◆ isValidChanged

◆ kmlPolygonElement()

QDomElement QGCMapPolygon::kmlPolygonElement ( KMLDomDocument & domDocument)

◆ loadFromJson()

bool QGCMapPolygon::loadFromJson ( const QJsonObject & json,
bool required,
QString & errorString )

Load a polygon from json

Parameters
jsonJson object to load from
requiredtrue: no polygon in object will generate error
errorStringError string if return is false
Returns
true: success, false: failure (errorString set)

Definition at line 218 of file QGCMapPolygon.cc.

References clear(), jsonPolygonKey, GeoJsonHelper::loadGeoCoordinateArray(), pathChanged(), setDirty(), and JsonParsing::validateRequiredKeys().

Referenced by QGCFencePolygon::loadFromJson().

◆ loadKMLOrSHPFile()

bool QGCMapPolygon::loadKMLOrSHPFile ( const QString & file)

Loads a polygon from a KML/SHP file

Returns
true: success

Definition at line 549 of file QGCMapPolygon.cc.

References appendVertices(), beginReset(), clear(), endReset(), ShapeFileHelper::loadPolygonsFromFile(), and QGC::showAppMessage().

◆ nedPolygon()

QList< QPointF > QGCMapPolygon::nedPolygon ( void ) const

Convert polygon to NED and return (D is ignored).

Definition at line 494 of file QGCMapPolygon.cc.

References QGCGeo::convertGeoToNed(), count(), nedPolygon(), and vertexCoordinate().

Referenced by area(), nedPolygon(), and offset().

◆ offset()

bool QGCMapPolygon::offset ( double distance)

Offsets the current polygon edges by the specified distance in meters. Positive distances expand the polygon.

Returns
false if no single offset polygon could be produced; the polygon is left unchanged

Definition at line 517 of file QGCMapPolygon.cc.

References appendVertices(), beginReset(), clear(), QGCGeo::convertNedToGeo(), count(), endReset(), nedPolygon(), QGCPlanarGeometry::offsetPolygon(), and vertexCoordinate().

◆ operator=()

const QGCMapPolygon & QGCMapPolygon::operator= ( const QGCMapPolygon & other)

Definition at line 60 of file QGCMapPolygon.cc.

References appendVertices(), clear(), path(), QGCMapPolygon(), and setDirty().

Referenced by QGCFencePolygon::operator=().

◆ path()

QVariantList QGCMapPolygon::path ( void ) const
inline

Definition at line 121 of file QGCMapPolygon.h.

Referenced by operator=(), GeoFenceManager::sendToVehicle(), setPath(), and setPath().

◆ pathChanged

◆ pathModel()

QmlObjectListModel & QGCMapPolygon::pathModel ( void )
inline

Definition at line 123 of file QGCMapPolygon.h.

◆ qmlPathModel()

QmlObjectListModel * QGCMapPolygon::qmlPathModel ( void )
inline

Definition at line 122 of file QGCMapPolygon.h.

◆ removeVertex()

void QGCMapPolygon::removeVertex ( int vertexIndex)

Definition at line 335 of file QGCMapPolygon.cc.

References pathChanged(), and selectVertex().

◆ saveToJson()

void QGCMapPolygon::saveToJson ( QJsonObject & json)

Saves the polygon to the json object.

Parameters
jsonJson object to save to

Definition at line 209 of file QGCMapPolygon.cc.

References jsonPolygonKey, GeoJsonHelper::saveGeoCoordinateArray(), and setDirty().

Referenced by QGCFencePolygon::saveToJson().

◆ selectedVertex()

int QGCMapPolygon::selectedVertex ( ) const
inline

Definition at line 119 of file QGCMapPolygon.h.

◆ selectedVertexChanged

void QGCMapPolygon::selectedVertexChanged ( int index)
signal

References count(), and dirty().

Referenced by selectVertex().

◆ selectVertex()

void QGCMapPolygon::selectVertex ( int index)

Definition at line 692 of file QGCMapPolygon.cc.

References count(), and selectedVertexChanged().

Referenced by removeVertex(), and splitPolygonSegment().

◆ setCenter()

void QGCMapPolygon::setCenter ( QGeoCoordinate newCenter)

◆ setCenterDrag()

void QGCMapPolygon::setCenterDrag ( bool centerDrag)

Definition at line 448 of file QGCMapPolygon.cc.

References centerChanged(), centerDrag(), centerDragChanged(), and pathChanged().

◆ setDirty()

void QGCMapPolygon::setDirty ( bool dirty)

Definition at line 125 of file QGCMapPolygon.cc.

References dirty(), and dirtyChanged().

Referenced by adjustVertex(), clear(), loadFromJson(), operator=(), saveToJson(), setPath(), and setPath().

◆ setInteractive()

void QGCMapPolygon::setInteractive ( bool interactive)

Definition at line 476 of file QGCMapPolygon.cc.

References interactive(), and interactiveChanged().

Referenced by GeoFenceController::addInclusionPolygon().

◆ setPath() [1/2]

void QGCMapPolygon::setPath ( const QList< QGeoCoordinate > & path)

Definition at line 183 of file QGCMapPolygon.cc.

References path(), pathChanged(), and setDirty().

◆ setPath() [2/2]

void QGCMapPolygon::setPath ( const QVariantList & path)

Definition at line 196 of file QGCMapPolygon.cc.

References path(), pathChanged(), and setDirty().

◆ setShowAltColor()

void QGCMapPolygon::setShowAltColor ( bool showAltColor)

Definition at line 685 of file QGCMapPolygon.cc.

References showAltColor(), and showAltColorChanged().

◆ setTraceMode()

void QGCMapPolygon::setTraceMode ( bool traceMode)

Definition at line 677 of file QGCMapPolygon.cc.

References traceMode(), and traceModeChanged().

◆ setVertexDrag()

void QGCMapPolygon::setVertexDrag ( bool vertexDrag)

Definition at line 464 of file QGCMapPolygon.cc.

References pathChanged(), vertexDrag(), and vertexDragChanged().

◆ showAltColor()

bool QGCMapPolygon::showAltColor ( void ) const
inline

Definition at line 118 of file QGCMapPolygon.h.

Referenced by setShowAltColor(), and showAltColorChanged().

◆ showAltColorChanged

void QGCMapPolygon::showAltColorChanged ( bool showAltColor)
signal

References showAltColor().

Referenced by setShowAltColor().

◆ splitPolygonSegment()

void QGCMapPolygon::splitPolygonSegment ( int vertexIndex)

Splits the segment comprised of vertextIndex -> vertexIndex + 1.

Definition at line 256 of file QGCMapPolygon.cc.

References appendVertex(), pathChanged(), and selectVertex().

◆ traceMode()

bool QGCMapPolygon::traceMode ( void ) const
inline

Definition at line 117 of file QGCMapPolygon.h.

Referenced by setTraceMode(), and traceModeChanged().

◆ traceModeChanged

void QGCMapPolygon::traceModeChanged ( bool traceMode)
signal

◆ verifyClockwiseWinding()

void QGCMapPolygon::verifyClockwiseWinding ( void )

Adjust polygon winding order to be clockwise (if needed).

Definition at line 603 of file QGCMapPolygon.cc.

References appendVertices(), beginReset(), clear(), endReset(), and isClockwise().

◆ vertexCoordinate()

QGeoCoordinate QGCMapPolygon::vertexCoordinate ( int vertex) const

Returns the QGeoCoordinate for the vertex specified.

Definition at line 484 of file QGCMapPolygon.cc.

Referenced by nedPolygon(), and offset().

◆ vertexDrag()

bool QGCMapPolygon::vertexDrag ( void ) const
inline

Definition at line 113 of file QGCMapPolygon.h.

Referenced by setVertexDrag(), and vertexDragChanged().

◆ vertexDragChanged

void QGCMapPolygon::vertexDragChanged ( bool vertexDrag)
signal

References vertexDrag().

Referenced by setVertexDrag().

Member Data Documentation

◆ jsonPolygonKey

const char* QGCMapPolygon::jsonPolygonKey = "polygon"
staticconstexpr

Definition at line 135 of file QGCMapPolygon.h.

Referenced by StructureScanComplexItem::load(), loadFromJson(), and saveToJson().


The documentation for this class was generated from the following files: