Commit 00d7ea68 authored by Valentin Platzgummer's avatar Valentin Platzgummer

adding .qml files for WimaPolygons

parent 2ff5f135
...@@ -15,7 +15,5 @@ ...@@ -15,7 +15,5 @@
<file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file> <file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file>
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file> <file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
</qresource> </qresource>
<qresource prefix="/"> <qresource prefix="/"/>
<file>src/WimaView/FlyAreaMapVisual.qml</file>
</qresource>
</RCC> </RCC>
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Global Measurement Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object
property var _polygon: object.polygon
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.75
rect.height *= 0.75
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
Component.onDestruction: {
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
interactive: _missionItem.isCurrentItem
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
}
...@@ -413,7 +413,6 @@ HEADERS += \ ...@@ -413,7 +413,6 @@ HEADERS += \
src/MissionManager/WimaVehicleCorridor.h \ src/MissionManager/WimaVehicleCorridor.h \
src/MissionManager/WimaVehicleMeasurementPolygon.h \ src/MissionManager/WimaVehicleMeasurementPolygon.h \
src/MissionManager/WimaGlobalMeasurementPolygon.h \ src/MissionManager/WimaGlobalMeasurementPolygon.h \
src/MissionManager/WimaPolygonContainer.h \
src/MissionManager/WimaVehicle.h src/MissionManager/WimaVehicle.h
SOURCES += \ SOURCES += \
...@@ -423,13 +422,11 @@ SOURCES += \ ...@@ -423,13 +422,11 @@ SOURCES += \
src/api/QmlComponentInfo.cc \ src/api/QmlComponentInfo.cc \
src/comm/MavlinkMessagesTimer.cc \ src/comm/MavlinkMessagesTimer.cc \
src/MissionManager/WimaController.cc \ src/MissionManager/WimaController.cc \
src/MissionManager/WimaFlyArea.cc \
src/MissionManager/WimaPolygon.cc \ src/MissionManager/WimaPolygon.cc \
src/MissionManager/WimaServicePolygon.cc \ src/MissionManager/WimaServicePolygon.cc \
src/MissionManager/WimaVehicleCorridor.cc \ src/MissionManager/WimaVehicleCorridor.cc \
src/MissionManager/WimaVehicleMeasurementPolygon.cc \ src/MissionManager/WimaVehicleMeasurementPolygon.cc \
src/MissionManager/WimaGlobalMeasurementPolygon.cc \ src/MissionManager/WimaGlobalMeasurementPolygon.cc \
src/MissionManager/WimaPolygonContainer.cc \
src/MissionManager/WimaVehicle.cc src/MissionManager/WimaVehicle.cc
# #
......
...@@ -210,9 +210,10 @@ ...@@ -210,9 +210,10 @@
<file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file> <file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file>
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file> <file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file>
<file alias="WimaView.qml">src/WimaView/WimaView.qml</file> <file alias="WimaView.qml">src/WimaView/WimaView.qml</file>
<file alias="QGroundControl/Controls/FlyAreaPolygonMapVisual.qml">src/WimaView/FlyAreaPolygonMapVisual.qml</file> <file alias="QGroundControl/Controls/WimaMapVisual.qml">src/WimaView/WimaMapVisual.qml</file>
<file alias="QGroundControl/Controls/FlyAreaEditor.qml">src/WimaView/FlyAreaEditor.qml</file> <file alias="QGroundControl/Controls/WimaGlobalMeasurementPolygonMapVisual.qml">src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml</file>
<file alias="QGroundControl/Controls/FlyAreaItemEditor.qml">src/WimaView/FlyAreaItemEditor.qml</file> <file alias="QGroundControl/Controls/WimaServicePolygonMapVisual.qml">src/WimaView/WimaServicePolygonMapVisual.qml</file>
<file alias="WimaItemEditor.qml">src/WimaView/WimaItemEditor.qml</file>
</qresource> </qresource>
<qresource prefix="/json"> <qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file> <file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
#include "MissionController.h" #include "MissionController.h"
WimaController::WimaController(QObject *parent) : WimaController::WimaController(QObject *parent) :
QObject(parent) QObject (parent)
,_planView(true) ,_planView (true)
,_visualItems (new QmlObjectListModel(parent))
{ {
connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity);
} }
void WimaController::setMasterController(PlanMasterController *masterC) void WimaController::setMasterController(PlanMasterController *masterC)
...@@ -21,18 +21,30 @@ void WimaController::setMissionController(MissionController *missionC) ...@@ -21,18 +21,30 @@ void WimaController::setMissionController(MissionController *missionC)
emit missionControllerChanged(); emit missionControllerChanged();
} }
void WimaController::setCurrentPolygonIndex(int index)
{
if(index > 0 && index < _visualItems->count() && index != _currentPolygonIndex){
_currentPolygonIndex = index;
emit currentPolygonIndexChanged(index);
}
}
void WimaController::addGlobalMeasurementArea() void WimaController::addGlobalMeasurementArea()
{ {
WimaGlobalMeasurementPolygon* poly = new WimaGlobalMeasurementPolygon(this); WimaGlobalMeasurementPolygon* newPoly = new WimaGlobalMeasurementPolygon(this);
_visualItems.append(poly); _visualItems->append(newPoly);
int newIndex = _visualItems->count()-1;
_currentPolygonIndex = newIndex;
emit currentPolygonIndexChanged(newIndex);
emit visualItemsChanged(); emit visualItemsChanged();
} }
void WimaController::removeArea(int index) void WimaController::removeArea(int index)
{ {
if(index > 0 && index < _visualItems.size()){ if(index > 0 && index < _visualItems->count()){
_visualItems.removeAt(index); _visualItems->removeAt(index);
emit visualItemsChanged(); emit visualItemsChanged();
}else{ }else{
...@@ -43,16 +55,74 @@ void WimaController::removeArea(int index) ...@@ -43,16 +55,74 @@ void WimaController::removeArea(int index)
void WimaController::addServiceArea() void WimaController::addServiceArea()
{ {
WimaServicePolygon* poly = new WimaServicePolygon(this); resetAllIsCurrentPolygon();
_visualItems.append(poly); WimaServicePolygon* newPoly = new WimaServicePolygon(this);
newPoly->setIsCurrentPolygon(true);
_visualItems->append(newPoly);
emit visualItemsChanged(); emit visualItemsChanged();
} }
void WimaController::startMission()
{
}
void WimaController::abortMission()
{
}
void WimaController::pauseMission()
{
}
void WimaController::resumeMission()
{
}
void WimaController::saveMission()
{
}
void WimaController::loadMission()
{
}
void WimaController::recalcVehicleCorridor() void WimaController::recalcVehicleCorridor()
{ {
} }
void WimaController::recalcVehicleMeasurementAreas()
{
}
void WimaController::recalcAll()
{
}
void WimaController::recalcPolygonInteractivity(int index)
{
resetAllIsCurrentPolygon();
WimaPolygon* interactivePoly = qobject_cast<WimaPolygon*>(_visualItems->get(index));
interactivePoly->setIsCurrentPolygon(true);
}
void WimaController::resetAllIsCurrentPolygon()
{
int itemCount = _visualItems->count();
for (int i = 0; i < itemCount; i++) {
WimaPolygon* iteratorPoly = qobject_cast<WimaPolygon*>(_visualItems->get(i));
iteratorPoly->setIsCurrentPolygon(false);
}
}
#ifndef WIMACONTROLLER_H #pragma once
#define WIMACONTROLLER_H
#include <QObject> #include <QObject>
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "WimaPolygon.h" #include "WimaPolygon.h"
#include "WimaGlobalMeasurementPolygon.h" #include "WimaGlobalMeasurementPolygon.h"
#include "WimaServicePolygon.h" #include "WimaServicePolygon.h"
#include "WimaPolygonContainer.h"
#include "PlanMasterController.h" #include "PlanMasterController.h"
#include "MissionController.h" #include "MissionController.h"
...@@ -21,13 +21,15 @@ public: ...@@ -21,13 +21,15 @@ public:
Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged) Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged)
Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged) Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged)
Q_PROPERTY(QList<WimaPolygon*>& visualItems READ visualItems NOTIFY visualItemsChanged) Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
Q_PROPERTY(QList<WimaPolygon*>& editorItems READ editorItems NOTIFY visualItemsChanged) Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex WRITE setCurrentPolygonIndex NOTIFY currentPolygonIndexChanged)
// Property accessors // Property accessors
PlanMasterController* masterController (void) const { return _masterController;} PlanMasterController* masterController (void) const { return _masterController;}
MissionController* missionController (void) const { return _missionController;} MissionController* missionController (void) const { return _missionController;}
QList<WimaPolygon*>& visualItems (void) { return _visualItemsContainer.returnFlatList(); } QmlObjectListModel* visualItems (void) { return _visualItems; }
int currentPolygonIndex (void) const { return _currentPolygonIndex; }
...@@ -35,6 +37,7 @@ public: ...@@ -35,6 +37,7 @@ public:
// Property setters // Property setters
void setMasterController (PlanMasterController* masterController); void setMasterController (PlanMasterController* masterController);
void setMissionController (MissionController* missionController); void setMissionController (MissionController* missionController);
void setCurrentPolygonIndex (int index);
Q_INVOKABLE void addGlobalMeasurementArea(); Q_INVOKABLE void addGlobalMeasurementArea();
Q_INVOKABLE void removeArea(int index); Q_INVOKABLE void removeArea(int index);
...@@ -48,25 +51,28 @@ public: ...@@ -48,25 +51,28 @@ public:
Q_INVOKABLE void saveMission(); Q_INVOKABLE void saveMission();
Q_INVOKABLE void loadMission(); Q_INVOKABLE void loadMission();
Q_INVOKABLE void resetAllIsCurrentPolygon(void);
signals: signals:
void masterControllerChanged (void); void masterControllerChanged (void);
void missionControllerChanged (void); void missionControllerChanged (void);
void visualItemsChanged (void); void visualItemsChanged (void);
void currentPolygonIndexChanged (int index);
private slots: private slots:
void recalcVehicleCorridor(); void recalcVehicleCorridor();
void recalcVehicleMeasurementAreas(); void recalcVehicleMeasurementAreas();
void recalcAll(); void recalcAll();
void recalcPolygonInteractivity(int index);
private: private:
bool _planView; bool _planView;
QList<WimaPolygon*> _visualItems; QmlObjectListModel* _visualItems;
PlanMasterController* _masterController; PlanMasterController* _masterController;
MissionController* _missionController; MissionController* _missionController;
int _currentPolygonIndex;
}; };
#endif // WIMACONTROLLER_H
#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;
selectCurrentPolygon(index);
emit polygonsChanged();
}
void WimaFlyArea::removeFlyAreaPolygon(int index)
{
if(index >= 0 && index < _polygons->count()) {
_polygons->removeAt(index);
emit polygonsChanged();
}
}
void WimaFlyArea::selectCurrentPolygon(int index)
{
if(index >= 0 && index < _polygons->count()) {
disselectAllPolygons();
_currentPolygonIndex = index;
_currentPolygonItem = qobject_cast<QGCMapPolygon*>(_polygons->get(index));
_currentPolygonItem->setInteractive(true);
if(index != _currentPolygonIndex){
emit currentPolygonItemChanged(_currentPolygonItem);
emit currentPolygonIndexChanged(index);
}
}
}
void WimaFlyArea::disselectAllPolygons()
{
for (int i = 0; i < _polygons->count(); i++) {
QGCMapPolygon* polygon = qobject_cast<QGCMapPolygon*>(_polygons->get(i));
polygon->setInteractive(false);
}
}
/*void WimaFlyArea::setBottomLayerAltitude(double alt)
{
if(_bottomLayerAltitude != alt){
_bottomLayerAltitude = alt;
emit bottomLayerAltitudeChanged(_bottomLayerAltitude);
}
}*/
#ifndef WIMAFLYAREA_H
#define WIMAFLYAREA_H
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
class WimaFlyArea : public QObject
{
Q_OBJECT
public:
WimaFlyArea(QObject *parent = nullptr);
WimaFlyArea(const WimaFlyArea& other, QObject *parent = nullptr);
const WimaFlyArea& operator=(const WimaFlyArea& other);
Q_PROPERTY(QmlObjectListModel* polygons READ polygons NOTIFY polygonsChanged)
Q_PROPERTY(QGCMapPolygon* currentPolygonItem READ currentPolygonItem NOTIFY currentPolygonItemChanged)
Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex NOTIFY currentPolygonIndexChanged)
//Q_PROPERTY(QList<double>* bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged)
//Q_PROPERTY(QList<int>* layerNumber READ layerNumber WRITE setLayerNumber NOTIFY layerNumberChanged)
//Q_PROPERTY(QList<double>* layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged)
Q_INVOKABLE void appendFlyAreaPolygon();
Q_INVOKABLE void removeFlyAreaPolygon(int index);
Q_INVOKABLE void selectCurrentPolygon(int index);
Q_INVOKABLE void disselectAllPolygons();
// Property Accessors
QmlObjectListModel * polygons (void) { return _polygons;}
QGCMapPolygon * currentPolygonItem (void) { return _currentPolygonItem;}
int currentPolygonIndex (void) { return _currentPolygonIndex;}
//QList<double>* bottomLayerAltitude (void) { return _bottomLayerAltitude;}
//QList<int>* layerNumber (void) { return _layerNumber;}
//QList<double>* layerDistance (void) { return _layerDistance;}
// Property Writers
//void setBottomLayerAltitude(double alt);
//void setLayerNumber(int layerNumber);
//void setLayerDistance(double dist);
// Methodes
void _init(void);
signals:
void polygonsChanged(void);
void currentPolygonItemChanged(QGCMapPolygon * polygon);
void currentPolygonIndexChanged(int index);
void bottomLayerAltitudeChanged(double alt);
void layerNumberChanged(int alt);
void layerDistanceChanged(double dist);
public slots:
private:
QmlObjectListModel* _polygons;
QGCMapPolygon* _currentPolygonItem;
int _currentPolygonIndex;
bool _visible;
//QList<double>* _bottomLayerAltitude;
//QList<int>* _layerNumber;
//QList<double>* _layerDistance;
};
#endif // WIMAFLYAREA_H
...@@ -17,25 +17,30 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, ...@@ -17,25 +17,30 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other,
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle) void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
{ {
if(vehicle != nullptr){ if(vehicle != nullptr){
_vehicleList.append(vehicle); _vehicleList->append(vehicle);
emit vehicleListChanged(_vehicleList); emit vehicleListChanged();
} }
} }
void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex) void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex)
{ {
if(vehicleIndex >= 0 && vehicleIndex < _vehicleList.count()){ if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){
_vehicleList.removeAt(vehicleIndex); _vehicleList->removeAt(vehicleIndex);
emit vehicleListChanged(_vehicleList); emit vehicleListChanged();
} }
} }
void WimaGlobalMeasurementPolygon::recalculatesubPolygons() void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
{ {
int vehicleCount = _vehicleList->count(); int vehicleCount = _vehicleList->count();
WimaVehicleMeasurementPolygon* newPolygon = new WimaVehicleMeasurementPolygon(this); QScopedPointer<QList<QGCMapPolygon*>> listQGCPoly(this->splitPolygonArea(vehicleCount));
_subPolygons = this->splitPolygonArea(vehicleCount); int polyCount = listQGCPoly->size();
_subPolygons->clear();
for(int i = 0; i < polyCount; i++){
WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
_subPolygons->append(subPoly);
}
} }
void WimaGlobalMeasurementPolygon::removeAllVehicles() void WimaGlobalMeasurementPolygon::removeAllVehicles()
...@@ -47,14 +52,14 @@ void WimaGlobalMeasurementPolygon::removeAllVehicles() ...@@ -47,14 +52,14 @@ void WimaGlobalMeasurementPolygon::removeAllVehicles()
counter--; counter--;
} }
emit vehicleListChanged(_vehicleList); emit vehicleListChanged();
} }
void WimaGlobalMeasurementPolygon::setBottomLayerAltitude(double altitude) void WimaGlobalMeasurementPolygon::setBottomLayerAltitude(double altitude)
{ {
if(altitude > 0 && altitude != _bottomLayerAltitude){ if(altitude > 0 && altitude != _bottomLayerAltitude){
_bottomLayerAltitude = altitude; _bottomLayerAltitude = altitude;
emit bottomLayerAltitudeChanged(altitude); emit bottomLayerAltitudeChanged();
} }
} }
...@@ -62,7 +67,7 @@ void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers) ...@@ -62,7 +67,7 @@ void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers)
{ {
if(numberOfLayers > 0 && _numberOfLayers != numberOfLayers){ if(numberOfLayers > 0 && _numberOfLayers != numberOfLayers){
_numberOfLayers = numberOfLayers; _numberOfLayers = numberOfLayers;
emit numberOfLayersChanged(numberOfLayers); emit numberOfLayersChanged();
} }
} }
...@@ -70,6 +75,6 @@ void WimaGlobalMeasurementPolygon::setLayerDistance(double distance) ...@@ -70,6 +75,6 @@ void WimaGlobalMeasurementPolygon::setLayerDistance(double distance)
{ {
if(distance > 0 && distance != _layerDistance){ if(distance > 0 && distance != _layerDistance){
_layerDistance = distance; _layerDistance = distance;
emit layerDistanceChanged(distance); emit layerDistanceChanged();
} }
} }
#ifndef WIMAGLOBALMEASUREMENTPOLYGON_H #pragma once
#define WIMAGLOBALMEASUREMENTPOLYGON_H
#include <QObject> #include <QObject>
#include "WimaPolygon.h" #include "WimaPolygon.h"
...@@ -7,6 +6,8 @@ ...@@ -7,6 +6,8 @@
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h" #include "WimaVehicleMeasurementPolygon.h"
#include "QScopedPointer"
class WimaGlobalMeasurementPolygon : public WimaPolygon class WimaGlobalMeasurementPolygon : public WimaPolygon
{ {
Q_OBJECT Q_OBJECT
...@@ -17,9 +18,8 @@ public: ...@@ -17,9 +18,8 @@ public:
Q_PROPERTY(double bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged) Q_PROPERTY(double bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged)
Q_PROPERTY(int numberOfLayers READ numberOfLayers WRITE setNumberOfLayers NOTIFY numberOfLayersChanged) Q_PROPERTY(int numberOfLayers READ numberOfLayers WRITE setNumberOfLayers NOTIFY numberOfLayersChanged)
Q_PROPERTY(double layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged) Q_PROPERTY(double layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged)
Q_PROPERTY(QList<Vehicle*> vehicleList READ vehicleList NOTIFY vehicleListChanged) Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged) Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged)
Q_PROPERTY( QList<WimaPolygon*> subPolygons READ subPolygons NOTIFY subPolygonsChanged)
Q_INVOKABLE void addVehicle(Vehicle *vehicle); Q_INVOKABLE void addVehicle(Vehicle *vehicle);
Q_INVOKABLE void removeVehicle(int vehicleIndex); Q_INVOKABLE void removeVehicle(int vehicleIndex);
...@@ -28,14 +28,14 @@ public: ...@@ -28,14 +28,14 @@ public:
// Overrides from WimaPolygon // Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaGlobalMeasurementPolygonMapVisal.qml";} QString mapVisualQML (void) const { return "WimaGlobalMeasurementPolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";} QString editorQML (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";}
// Property accessors // Property accessors
double bottomLayerAltitude (void) const { return _bottomLayerAltitude;} double bottomLayerAltitude (void) const { return _bottomLayerAltitude;}
int numberOfLayers (void) const { return _numberOfLayers;} int numberOfLayers (void) const { return _numberOfLayers;}
double layerDistance (void) const { return _layerDistance;} double layerDistance (void) const { return _layerDistance;}
QList<Vehicle*> vehicleList (void) const { return _vehicleList;} QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;} QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;}
// Property setters // Property setters
...@@ -45,21 +45,20 @@ public: ...@@ -45,21 +45,20 @@ public:
void setLayerDistance (double distance); void setLayerDistance (double distance);
signals: signals:
void bottomLayerAltitudeChanged (double altitude); void bottomLayerAltitudeChanged (void);
void numberOfLayersChanged (int numberOfLayers); void numberOfLayersChanged (void);
void layerDistanceChanged (double distance); void layerDistanceChanged (void);
void vehicleListChanged (QList<Vehicle*> vehicleList); void vehicleListChanged (void);
void entryPolylineChanged (QGCMapPolyline* polyline); void entryPolylineChanged (void);
void subPolygonsChanged (QList<WimaPolygon*> subPolygons); void subPolygonsChanged (void);
private: private:
double _bottomLayerAltitude; double _bottomLayerAltitude;
int _numberOfLayers; int _numberOfLayers;
double _layerDistance; double _layerDistance;
QList<Vehicle*> _vehicleList; QmlObjectListModel* _vehicleList;
QGCMapPolyline* _entryPolyline; QGCMapPolyline* _entryPolyline;
}; };
#endif // WIMAGLOBALMEASUREMENTPOLYGON_H
...@@ -3,15 +3,16 @@ ...@@ -3,15 +3,16 @@
WimaPolygon::WimaPolygon(QObject *parent) : WimaPolygon::WimaPolygon(QObject *parent) :
QObject (parent) QObject (parent)
,_maxAltitude (30) ,_maxAltitude (30)
,_vehicle (nullptr) ,_vehicle (parent)
,_polygon (new QGCMapPolygon(this)) ,_polygon (new QGCMapPolygon(this))
,_subPolygons (new QmlObjectListModel(this))
,_subPolylines (new QmlObjectListModel(this))
{ {
} }
WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent): WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon(parent) WimaPolygon(parent)
{ {
delete _polygon;
*_polygon = *other; *_polygon = *other;
} }
...@@ -27,17 +28,25 @@ void WimaPolygon::setMaxAltitude(double alt) ...@@ -27,17 +28,25 @@ void WimaPolygon::setMaxAltitude(double alt)
void WimaPolygon::setVehicle(Vehicle *vehicle) void WimaPolygon::setVehicle(Vehicle *vehicle)
{ {
if(_vehicle != vehicle){ if(_vehicle.vehicle() != vehicle){
_vehicle = vehicle; _vehicle.setVehicle(vehicle);
emit vehicleChanged(); emit vehicleChanged();
} }
} }
QGCMapPolygon* WimaPolygon::splitPolygonArea(int numberOfFractions) void WimaPolygon::setIsCurrentPolygon(bool isCurrentPolygon)
{
_isCurrentPolygon = isCurrentPolygon;
emit isCurrentPolygonChanged();
}
QList<QGCMapPolygon*>* WimaPolygon::splitPolygonArea(int numberOfFractions)
{ {
if(numberOfFractions > 0){ if(numberOfFractions > 0){
QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this); QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this);
return poly; QList<QGCMapPolygon*>* list = new QList<QGCMapPolygon*>();
list->append(poly);
return list;
} }
return nullptr; return nullptr;
} }
......
#ifndef WIMAPOLYGON_H #pragma once
#define WIMAPOLYGON_H
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "QGCMapPolyline.h" #include "QGCMapPolyline.h"
#include "Vehicle.h" #include "Vehicle.h"
#include "qobject.h" #include "qobject.h"
#include "WimaVehicle.h"
...@@ -22,15 +25,17 @@ public: ...@@ -22,15 +25,17 @@ public:
Q_PROPERTY(QString editorQML READ editorQML CONSTANT) Q_PROPERTY(QString editorQML READ editorQML CONSTANT)
Q_PROPERTY(Vehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged) Q_PROPERTY(Vehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged)
Q_PROPERTY(QGCMapPolygon* polygon READ polygon NOTIFY polygonChanged) Q_PROPERTY(QGCMapPolygon* polygon READ polygon NOTIFY polygonChanged)
Q_PROPERTY(QList<WimaPolygon*> subPolygons READ subPolygons NOTIFY subPolygonsChanged) Q_PROPERTY(QmlObjectListModel* subPolygons READ subPolygons NOTIFY subPolygonsChanged)
Q_PROPERTY(QList<QGCMapPolyline*> subPolylines READ subPolylines NOTIFY subPolylinesChanged) Q_PROPERTY(QmlObjectListModel* subPolylines READ subPolylines NOTIFY subPolylinesChanged)
Q_PROPERTY(bool isCurrentPolygon READ isCurrentPolygon WRITE setIsCurrentPolygon NOTIFY isCurrentPolygonChanged)
//Property accessors //Property accessors
double maxAltitude (void) const { return _maxAltitude;} double maxAltitude (void) const { return _maxAltitude;}
Vehicle* vehicle (void) const { return _vehicle;} Vehicle* vehicle (void) const { return _vehicle.vehicle();}
QGCMapPolygon* polygon (void) const { return _polygon;} QGCMapPolygon* polygon (void) const { return _polygon;}
QList<WimaPolygon*> subPolygons (void) const { return _subPolygons;} QmlObjectListModel* subPolygons (void) const { return _subPolygons;}
QList<QGCMapPolyline*> subPolylines (void) const { return _subPolylines;} QmlObjectListModel* subPolylines (void) const { return _subPolylines;}
bool isCurrentPolygon (void) const { return _isCurrentPolygon;}
virtual QString mapVisualQML (void) const = 0; virtual QString mapVisualQML (void) const = 0;
virtual QString editorQML (void) const = 0; virtual QString editorQML (void) const = 0;
...@@ -39,25 +44,28 @@ public: ...@@ -39,25 +44,28 @@ public:
void setMaxAltitude (double alt); void setMaxAltitude (double alt);
void setName (QString name); void setName (QString name);
void setVehicle (Vehicle* vehicle); void setVehicle (Vehicle* vehicle);
void setIsCurrentPolygon(bool isCurrentPolygon);
QGCMapPolygon* splitPolygonArea(int numberOfFractions); QList<QGCMapPolygon*>* splitPolygonArea(int numberOfFractions); // use QScopedPointer to store return value
signals: signals:
void maxAltitudeChanged (void); void maxAltitudeChanged (void);
void vehicleChanged (void); void vehicleChanged (void);
void subPolygons (void); void polygonChanged (void);
void subPolygonsChanged (void);
void subPolylinesChanged (void);
private: void isCurrentPolygonChanged (void);
protected:
double _maxAltitude; double _maxAltitude;
Vehicle* _vehicle; WimaVehicle _vehicle;
QGCMapPolygon* _polygon; QGCMapPolygon* _polygon;
QList<WimaPolygon*> _subPolygons; QmlObjectListModel* _subPolygons;
QList<QGCMapPolyline*> _subPolylines; QmlObjectListModel* _subPolylines;
bool _isCurrentPolygon;
}; };
#endif // WIMAPOLYGON_H
...@@ -12,26 +12,19 @@ WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent): ...@@ -12,26 +12,19 @@ WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent):
} }
void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate coordinate) void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate* coordinate)
{ {
if(_takeOffPosition != coordinate){ if(_takeOffPosition != *coordinate){
_takeOffPosition = coordinate; _takeOffPosition = *coordinate;
emit takeOffPositionChanged(coordinate); emit takeOffPositionChanged();
} }
} }
void WimaServicePolygon::setLandPosition(QGeoCoordinate coordinate) void WimaServicePolygon::setLandPosition(QGeoCoordinate* coordinate)
{ {
if(_landPosition != coordinate){ if(_landPosition != *coordinate){
_landPosition = coordinate; _landPosition = *coordinate;
emit landPositionChanged(coordinate); emit landPositionChanged();
} }
} }
void WimaServicePolygon::setVehicle(Vehicle *vehicle)
{
if(_vehicle != vehicle){
_vehicle = vehicle;
emit vehicleChanged(vehicle);
}
}
#ifndef WIMASERVICEPOLYGON_H #pragma once
#define WIMASERVICEPOLYGON_H
#include "QObject" #include <QObject>
#include "WimaPolygon.h" #include "WimaPolygon.h"
class WimaServicePolygon : public WimaPolygon class WimaServicePolygon : public WimaPolygon
...@@ -11,33 +10,26 @@ public: ...@@ -11,33 +10,26 @@ public:
WimaServicePolygon(QObject* parent = nullptr); WimaServicePolygon(QObject* parent = nullptr);
WimaServicePolygon(QGCMapPolygon* other, QObject* parent = nullptr); WimaServicePolygon(QGCMapPolygon* other, QObject* parent = nullptr);
Q_PROPERTY(QGeoCoordiante takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged) Q_PROPERTY(QGeoCoordinate* takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged)
Q_PROPERTY(QGeoCoordinate landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged) Q_PROPERTY(QGeoCoordinate* landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged)
Q_PROPERTY(Vehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged)
// Overrides from WimaPolygon // Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaServicePolygonMapVisal.qml";} QString mapVisualQML (void) const { return "WimaServicePolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaServicePolygonEditor.qml";} QString editorQML (void) const { return "WimaServicePolygonEditor.qml";}
// Property acessors // Property acessors
QGeoCoordinate takeOffPosition (void) const { return _takeOffPosition;} QGeoCoordinate* takeOffPosition (void) { return &_takeOffPosition;}
QGeoCoordinate landPosition (void) const { return _landPosition;} QGeoCoordinate* landPosition (void) { return &_landPosition;}
Vehicle* vehicle (void) const { return _vehicle;}
// Property setters // Property setters
void setTakeOffPosition (QGeoCoordinate coordinate); void setTakeOffPosition (QGeoCoordinate* coordinate);
void setLandPosition (QGeoCoordinate coordinate); void setLandPosition (QGeoCoordinate* coordinate);
void setVehicle (Vehicle* vehicle);
signals: signals:
void takeOffPositionChanged (QGeoCoordinate takeOffPos); void takeOffPositionChanged (void);
void landPositionChanged (QGeoCoordinate landPos); void landPositionChanged (void);
void vehicleChanged (Vehicle* vehicle);
private: private:
QGeoCoordinate _takeOffPosition; QGeoCoordinate _takeOffPosition;
QGeoCoordinate _landPosition; QGeoCoordinate _landPosition;
Vehicle* _vehicle;
}; };
#endif // WIMASERVICEPOLYGON_H
...@@ -3,7 +3,47 @@ ...@@ -3,7 +3,47 @@
WimaVehicle::WimaVehicle(QObject *parent): WimaVehicle::WimaVehicle(QObject *parent):
Vehicle (parent) QObject (parent)
,_vehicle (nullptr)
,_servicePolygon (nullptr)
,_vehicleCorridor (nullptr)
,_measurementPolygon (nullptr)
{ {
} }
void WimaVehicle::setVehicle(Vehicle *vehicle)
{
if(vehicle != nullptr){
_vehicle = vehicle;
}else {
qWarning("Not a valid vehicle!");
}
}
void WimaVehicle::setServicePolygon(WimaServicePolygon *servicePolygon)
{
if(servicePolygon != nullptr){
_servicePolygon = servicePolygon;
}else{
qWarning("Not a valid service Polygon!");
}
}
void WimaVehicle::setVehicleCorridor(WimaVehicleCorridor *vehicleCorridor)
{
if(vehicleCorridor != nullptr){
_vehicleCorridor = vehicleCorridor;
}else{
qWarning("Not a valid vehicle Corridor!");
}
}
void WimaVehicle::setMeasurementPolygon(WimaVehicleMeasurementPolygon *measurementPolygon)
{
if(measurementPolygon != nullptr){
_measurementPolygon = measurementPolygon;
}else{
qWarning("Not a valid measurementPolygon!");
}
}
#ifndef WIMAVEHICLE_H #pragma once
#define WIMAVEHICLE_H
#include <QObject> #include <QObject>
#include "Vehicle.h" #include "Vehicle.h"
class WimaVehicle : public Vehicle class WimaServicePolygon;
class WimaVehicleCorridor;
class WimaVehicleMeasurementPolygon;
class WimaVehicle : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
WimaVehicle(QObject* parent); WimaVehicle(QObject* parent);
Vehicle* vehicle (void) const { return _vehicle;}
WimaServicePolygon* servicePolygon (void) const { return _servicePolygon;}
WimaVehicleCorridor* vehicleCorridor (void) const { return _vehicleCorridor;}
WimaVehicleMeasurementPolygon* measurementPolygon (void) const { return _measurementPolygon;}
void setVehicle (Vehicle* vehicle);
void setServicePolygon (WimaServicePolygon* servicePolygon);
void setVehicleCorridor (WimaVehicleCorridor* vehicleCorridor);
void setMeasurementPolygon (WimaVehicleMeasurementPolygon* measurementPolygon);
private:
Vehicle* _vehicle;
WimaServicePolygon* _servicePolygon;
WimaVehicleCorridor* _vehicleCorridor;
WimaVehicleMeasurementPolygon* _measurementPolygon;
}; };
#endif // WIMAVEHICLE_H
#ifndef WIMAVEHICLECORRIDOR_H #pragma once
#define WIMAVEHICLECORRIDOR_H
#include <QObject> #include <QObject>
#include "WimaPolygon.h" #include "WimaPolygon.h"
...@@ -12,8 +11,7 @@ public: ...@@ -12,8 +11,7 @@ public:
WimaVehicleCorridor(QGCMapPolygon* other, QObject* parent); WimaVehicleCorridor(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon // Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVehicleCorridorMapVisal.qml";} QString mapVisualQML (void) const { return "WimaVehicleCorridorMapVisual.qml";}
QString editorQML (void) const { return "WimaVehicleCorridorEditor.qml";} QString editorQML (void) const { return "WimaVehicleCorridorEditor.qml";}
}; };
#endif // WIMAVEHICLECORRIDOR_H
#ifndef WIMAVEHICLEMEASUREMENTPOLYGON_H #pragma once
#define WIMAVEHICLEMEASUREMENTPOLYGON_H
#include <QObject> #include <QObject>
#include "WimaPolygon.h" #include "WimaPolygon.h"
...@@ -12,8 +11,8 @@ public: ...@@ -12,8 +11,8 @@ public:
WimaVehicleMeasurementPolygon(QGCMapPolygon* other, QObject* parent); WimaVehicleMeasurementPolygon(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon // Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVehicleMeasurementPolygonMapVisal.qml";} QString mapVisualQML (void) const { return "WimaVehicleMeasurementPolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaVehicleMeasurementPolygonEditor.qml";} QString editorQML (void) const { return "WimaVehicleMeasurementPolygonEditor.qml";}
}; };
#endif // WIMAVEHICLEMEASUREMENTPOLYGON_H
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
#include "CoordinateVector.h" #include "CoordinateVector.h"
#include "PlanMasterController.h" #include "PlanMasterController.h"
#include "WimaController.h" //custom #include "WimaController.h" //custom
#include "WimaFlyArea.h" //custom
#include "VideoManager.h" #include "VideoManager.h"
#include "VideoSurface.h" #include "VideoSurface.h"
#include "VideoReceiver.h" #include "VideoReceiver.h"
...@@ -466,7 +465,6 @@ void QGCApplication::_initCommon(void) ...@@ -466,7 +465,6 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController"); qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController");
#endif #endif
// Wima // Wima
qmlRegisterUncreatableType<WimaFlyArea> ("Wima", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterType<WimaController> ("Wima", 1, 0, "WimaController"); //custom qmlRegisterType<WimaController> ("Wima", 1, 0, "WimaController"); //custom
......
...@@ -83,5 +83,9 @@ ToolStrip 1.0 ToolStrip.qml ...@@ -83,5 +83,9 @@ ToolStrip 1.0 ToolStrip.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml ViewWidget 1.0 ViewWidget.qml
FlyAreaPolygonMapVisual 1.0 FlyAreaPolygonMapVisual.qml
FlyAreaItemEditor 1.0 FlyAreaItemEditor.qml FlyAreaItemEditor 1.0 FlyAreaItemEditor.qml
WimaMapVisual 1.0 WimaMapVisual.qml
WimaGlobalMeasurementPolygonMapVisual 1.0 WimaGlobalMeasurementPolygonMapVisual.qml
WimaServicePolygonMapVisual 1.0 WimaServicePolygonMapVisual.qml
WimaItemEditor 1.0 WimaItemEditor.qml
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0
// Editor for Survery mission items
Rectangle {
id: _root
height: visible ? (editorColumn.height + (_margin * 2)) : 0
width: availableWidth
color: qgcPal.windowShadeDark
radius: _radius
// The following properties must be available up the hierarchy chain
//property real availableWidth ///< Width for control
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
QGCPalette { id: qgcPal; colorGroupEnabled: true }
Column {
id: editorColumn
anchors.margins: _margin
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
} // Column
} // Rectangle
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Global Measurement Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object
property var _polygon: object.polygon
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.75
rect.height *= 0.75
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
Component.onDestruction: {
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
interactive: _missionItem.isCurrentPolygon
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
}
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQml 2.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
/// Fly Area Item edit control
Rectangle {
id: _root
height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (descriptionLabel.y + descriptionLabel.height + _margin / 2)
color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
radius: _radius
property var map ///< Map control
property var flyArea
property var masterController
property var polygon ///< MissionItem associated with this editor
property bool readOnly ///< true: read only view, false: full editing view
property var rootQgcView
property int _index
signal clicked
signal remove
property var _masterController: masterController
property var _missionController: _masterController.missionController
property bool _currentItem: polygon.interactive
property color _outerTextColor: _currentItem ? qgcPal.primaryButtonText : qgcPal.text
property bool _noMissionItemsAdded: ListView.view.model.count === 1
property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings
readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12)
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
readonly property real _hamburgerSize: descriptionLabel.height * 0.75
readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
FocusScope {
id: currentItemScope
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: {
currentItemScope.focus = true
_root.clicked()
}
}
}
QGCLabel {
id: label
anchors.verticalCenter: descriptionLabel.verticalCenter
anchors.leftMargin: _margin
anchors.left: parent.left
text: index
color: _outerTextColor
}
QGCColoredImage {
id: hamburger
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.verticalCenter: descriptionLabel.verticalCenter
width: _hamburgerSize
height: _hamburgerSize
sourceSize.height: _hamburgerSize
source: "qrc:/qmlimages/Hamburger.svg"
visible: _currentItem
color: qgcPal.text
}
QGCMouseArea {
fillItem: hamburger
visible: hamburger.visible
onClicked: {
currentItemScope.focus = true
hamburgerMenu.popup()
}
Menu {
id: hamburgerMenu
MenuItem {
text: qsTr("Insert Fly Area")
onTriggered: flyArea.appendFlyAreaPolygon()
}
MenuItem {
text: qsTr("Delete")
onTriggered: remove()
}
MenuItem {
text: qsTr("Copy Fly Area")
//onTriggered: //To Do
}
}
}
QGCLabel {
id: descriptionLabel
anchors.topMargin: _margin / 2
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: label.right
anchors.top: parent.top
text: "Fly Area"
verticalAlignment: Text.AlignVCenter
color: _outerTextColor
}
Loader {
id: editorLoader
anchors.leftMargin: _margin
anchors.topMargin: _margin
anchors.left: parent.left
anchors.top: descriptionLabel.bottom
source: "FlyAreaEditor.qml"
visible: _currentItem
property var masterController: _masterController
property real availableWidth: _root.width - (_margin * 2) ///< How wide the editor should be
property var editorRoot: _root
}
} // Rectangle
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
/// Wima map visual
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
signal clicked(int sequenceNumber)
property var _visualItem
Component.onCompleted: {
if (object.mapVisualQML) {
var component = Qt.createComponent(object.mapVisualQML)
if (component.status === Component.Error) {
console.log("Error loading Qml: ", object.mapVisualQML, component.errorString())
}
_visualItem = component.createObject(map, { "map": _root.map, "qgcView": _root.qgcView })
_visualItem.clicked.connect(_root.clicked)
}
}
Component.onDestruction: {
if (_visualItem) {
_visualItem.destroy()
}
}
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Global Measurement Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object
property var _polygon: object.polygon
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.25
rect.height *= 0.25
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
Component.onDestruction: {
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
interactive: _missionItem.isCurrentPolygon
borderWidth: 1
borderColor: "black"
interiorColor: "yellow"
interiorOpacity: 0.25
}
}
...@@ -68,7 +68,7 @@ QGCView { ...@@ -68,7 +68,7 @@ QGCView {
property var _appSettings: QGroundControl.settingsManager.appSettings property var _appSettings: QGroundControl.settingsManager.appSettings
readonly property int _layerMission: 1 readonly property int _layerMission: 1
readonly property int _layerFlyArea: 2 readonly property int _layerWima: 2
readonly property string _armedVehicleUploadPrompt: qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?") readonly property string _armedVehicleUploadPrompt: qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
Component.onCompleted: { Component.onCompleted: {
...@@ -155,7 +155,7 @@ QGCView { ...@@ -155,7 +155,7 @@ QGCView {
} }
} }
} }
} }_layerWimaPlan
Connections { Connections {
target: QGroundControl.airspaceManager target: QGroundControl.airspaceManager
...@@ -174,7 +174,8 @@ QGCView { ...@@ -174,7 +174,8 @@ QGCView {
id:wimaController id:wimaController
Component.onCompleted: { Component.onCompleted: {
wimaController.start() wimaController.masterController = Qt.binding(function () { return masterController})
wimaController.missionController = Qt.binding(function () { return masterController.missionController})
} }
} }
...@@ -256,7 +257,7 @@ QGCView { ...@@ -256,7 +257,7 @@ QGCView {
} }
Connections { Connections {
target: _missionController target: _missionController_layerWimaPlan
onNewItemsFromVehicle: { onNewItemsFromVehicle: {
if (_visualItems && _visualItems.count != 1) { if (_visualItems && _visualItems.count != 1) {
...@@ -375,7 +376,7 @@ QGCView { ...@@ -375,7 +376,7 @@ QGCView {
toIndex = 1 toIndex = 1
} }
_missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex) _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
hideDialog() hideDialog()_layerWimaPlan
} }
Column { Column {
...@@ -433,7 +434,7 @@ QGCView { ...@@ -433,7 +434,7 @@ QGCView {
QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap } QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }
onZoomLevelChanged: updateAirspace(false) onZoomLevelChanged: updateAirspace(false)
onCenterChanged: updateAirspace(false) onCenterChanged: updateAirspace(false)_layerWimaPlan
MouseArea { MouseArea {
//-- It's a whole lot faster to just fill parent and deal with top offset below //-- It's a whole lot faster to just fill parent and deal with top offset below
...@@ -484,13 +485,13 @@ QGCView { ...@@ -484,13 +485,13 @@ QGCView {
model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
} }
//Add fly area //Add Wima Visuals
Repeater { Repeater {
model: _flyArea.polygons model: wimaController.visualItems
delegate: FlyAreaPolygonMapVisual { delegate: WimaMapVisual {
map: editorMap ///< Map control to place item in map: editorMap ///< Map control to place item in
qgcView: _qgcView ///< QGCView to use for popping dialogs qgcView: _qgcView ///< QGCView to use for popping dialogs
_flyAreaPolygon: object visible: true
} }
onItemAdded: { onItemAdded: {
...@@ -575,11 +576,11 @@ QGCView { ...@@ -575,11 +576,11 @@ QGCView {
dropPanelComponent: syncDropPanel dropPanelComponent: syncDropPanel
}, },
{ {
name: qsTr("Fly Area"), name: qsTr("Global Area"),
iconSource: "/qmlimages/Target.svg" iconSource: "/qmlimages/Target.svg"
}, },
{ {
name: qsTr("No Fly"), name: qsTr("Service Area"),
iconSource: "/qmlimages/noFlyArea.svg" iconSource: "/qmlimages/noFlyArea.svg"
}, },
{ {
...@@ -609,15 +610,13 @@ QGCView { ...@@ -609,15 +610,13 @@ QGCView {
onClicked: { onClicked: {
switch (index) { switch (index) {
case 1: case 1:
_flyArea.appendFlyAreaPolygon(); wimaController.addGlobalMeasurementArea();
console.log("polygon count: ", _flyArea.polygons.count)
//addComplexItem(_missionController.complexMissionItemNames[2]) //addComplexItem(_missionController.complexMissionItemNames[2])
/*_addWaypointOnClick = checked /*_addWaypointOnClick = checked
_addROIOnClick = false*/ _addROIOnClick = false*/
break break
case 2: case 2:
wimaController.addServiceArea(); /*
/*
_addROIOnClick = checked _addROIOnClick = checked
_addWaypointOnClick = false*/ _addWaypointOnClick = false*/
break break
...@@ -625,7 +624,7 @@ QGCView { ...@@ -625,7 +624,7 @@ QGCView {
/*if (_singleComplexItem) { /*if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0]) addComplexItem(_missionController.complexMissionItemNames[0])
}*/ }*/FlyArea
break break
case 5: case 5:
editorMap.zoomLevel += 0.5 editorMap.zoomLevel += 0.5
...@@ -757,16 +756,16 @@ QGCView { ...@@ -757,16 +756,16 @@ QGCView {
case planElementMission: case planElementMission:
_editingLayer = _layerMission _editingLayer = _layerMission
break break
case planElementFlyArea: case planElementWima:
_editingLayer = _layerFlyArea _editingLayer = _layerWima
break break
} }
} }
} }
QGCRadioButton { QGCRadioButton {
id: planElementFlyArea id: planElementWima
exclusiveGroup: planElementSelectorGroup exclusiveGroup: planElementSelectorGroup
text: qsTr("Fly Area") text: qsTr("Wima")
checked: true checked: true
visible: QGroundControl.corePlugin.options.enablePlanViewSelector visible: QGroundControl.corePlugin.options.enablePlanViewSelector
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -784,7 +783,7 @@ QGCView { ...@@ -784,7 +783,7 @@ QGCView {
} }
} }
//------------------------------------------------------- //-------------------------------------------------------
// Fly Area Item Editor // Wima Item Editor
Item { Item {
id: flyAreaItemEditor id: flyAreaItemEditor
anchors.left: parent.left anchors.left: parent.left
...@@ -793,20 +792,20 @@ QGCView { ...@@ -793,20 +792,20 @@ QGCView {
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25 anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
visible: _editingLayer == _layerFlyArea && !planControlColapsed visible: _editingLayer == _layerWima && !planControlColapsed
QGCListView { QGCListView {
id: flyAreaItemEditorListView id: flyAreaItemEditorListView
anchors.fill: parent anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight / 4 spacing: ScreenTools.defaultFontPixelHeight / 4
orientation: ListView.Vertical orientation: ListView.Vertical
model: _flyArea.polygons model: wimaController.visualItems
cacheBuffer: Math.max(height * 2, 0) cacheBuffer: Math.max(height * 2, 0)
clip: true clip: true
currentIndex: _flyArea.currentPolygonIndex currentIndex: wimaController.currentPolygonIndex
highlightMoveDuration: 250 highlightMoveDuration: 250
visible: _editingLayer == _layerFlyArea && !planControlColapsed visible: _editingLayer == _layerWima && !planControlColapsed
//-- List Elements //-- List Elements
delegate: FlyAreaItemEditor { delegate: WimaItemEditor {
map: editorMap map: editorMap
masterController: _planMasterController masterController: _planMasterController
flyArea: _flyArea flyArea: _flyArea
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment