#include "WimaFlyArea.h" WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent) , _polygons (nullptr) { } WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent) { *this = other; } const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other) { this->_polygons = other._polygons; return *this; } void WimaFlyArea::_init() { _polygons = new QmlObjectListModel(this); } void WimaFlyArea::appendFlyAreaPolygon() { QGCMapPolygon *newPolygon = new QGCMapPolygon(); _polygons->append(newPolygon); int index = _polygons->count()-1; setCurrentPolygon(index); emit polygonsChanged(); } void WimaFlyArea::removeFlyAreaPolygon(int index) { if(index >= 0 && index < _polygons->count()) { _polygons->removeAt(index); emit polygonsChanged(); } } void WimaFlyArea::setCurrentPolygon(int index) { if(index >= 0 && index < _polygons->count()) { if(index == _currentPolygonIndex){ return; } for (int i = 0; i < _polygons->count(); i++) { QGCMapPolygon* polygon = qobject_cast(_polygons->get(i)); polygon->setInteractive(false); } _currentPolygonIndex = index; _currentPolygonItem = qobject_cast(_polygons->get(index)); _currentPolygonItem->setInteractive(true); emit currentPolygonItemChanged(_currentPolygonItem); emit currentPolygonIndexChanged(index); } }