From d60a13184f382cd71df1462e1224a3c881530010 Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Fri, 17 May 2019 17:20:01 +0200 Subject: [PATCH] changing class structure --- WimaGlobalMeasurementPolygonEditor.qml | 128 +---------------- src/MissionManager/WimaController.cc | 134 ------------------ .../WimaGlobalMeasurementPolygon.cc | 113 --------------- src/MissionManager/WimaVehicle.h | 34 ----- src/Wima/WimaArea.cc | 6 + src/Wima/WimaArea.h | 11 ++ src/Wima/WimaController.cc | 6 + src/Wima/WimaController.h | 17 +++ .../WimaGOperationArea.SettingsGroup.json | 0 src/Wima/WimaGOperationArea.cc | 6 + src/Wima/WimaGOperationArea.h | 11 ++ src/Wima/WimaServiceArea.cc | 6 + src/Wima/WimaServiceArea.h | 11 ++ src/Wima/WimaTrackerPolyline.cc | 6 + src/Wima/WimaTrackerPolyline.h | 11 ++ src/Wima/WimaVCorridor.cc | 6 + src/Wima/WimaVCorridor.h | 11 ++ src/Wima/WimaVehicle.cc | 6 + src/Wima/WimaVehicle.h | 11 ++ src/WimaView/WimaGOperationAreaEditor.qml | 5 + src/WimaView/WimaGOperationAreaMapVisual.qml | 5 + .../WimaGlobalMeasurementPolygonEditor.cc | 46 ++++++ .../WimaGlobalMeasurementPolygonEditor.h | 29 ++++ .../WimaGlobalMeasurementPolygonMapVisual.qml | 112 --------------- src/WimaView/WimaMapPolygonVisuals.qml | 5 + src/WimaView/WimaMapPolylineVisuals.qml | 5 + src/WimaView/WimaServiceAreaMapVisual.qml | 5 + src/WimaView/WimaServicePolygonMapVisual.qml | 86 ----------- 28 files changed, 228 insertions(+), 604 deletions(-) delete mode 100644 src/MissionManager/WimaController.cc delete mode 100644 src/MissionManager/WimaGlobalMeasurementPolygon.cc delete mode 100644 src/MissionManager/WimaVehicle.h create mode 100644 src/Wima/WimaArea.cc create mode 100644 src/Wima/WimaArea.h create mode 100644 src/Wima/WimaController.cc create mode 100644 src/Wima/WimaController.h create mode 100644 src/Wima/WimaGOperationArea.SettingsGroup.json create mode 100644 src/Wima/WimaGOperationArea.cc create mode 100644 src/Wima/WimaGOperationArea.h create mode 100644 src/Wima/WimaServiceArea.cc create mode 100644 src/Wima/WimaServiceArea.h create mode 100644 src/Wima/WimaTrackerPolyline.cc create mode 100644 src/Wima/WimaTrackerPolyline.h create mode 100644 src/Wima/WimaVCorridor.cc create mode 100644 src/Wima/WimaVCorridor.h create mode 100644 src/Wima/WimaVehicle.cc create mode 100644 src/Wima/WimaVehicle.h create mode 100644 src/WimaView/WimaGOperationAreaEditor.qml create mode 100644 src/WimaView/WimaGOperationAreaMapVisual.qml create mode 100644 src/WimaView/WimaGlobalMeasurementPolygonEditor.cc create mode 100644 src/WimaView/WimaGlobalMeasurementPolygonEditor.h delete mode 100644 src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml create mode 100644 src/WimaView/WimaMapPolygonVisuals.qml create mode 100644 src/WimaView/WimaMapPolylineVisuals.qml create mode 100644 src/WimaView/WimaServiceAreaMapVisual.qml delete mode 100644 src/WimaView/WimaServicePolygonMapVisual.qml diff --git a/WimaGlobalMeasurementPolygonEditor.qml b/WimaGlobalMeasurementPolygonEditor.qml index a49b24251..9c36e13c5 100644 --- a/WimaGlobalMeasurementPolygonEditor.qml +++ b/WimaGlobalMeasurementPolygonEditor.qml @@ -1,127 +1,5 @@ -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 QtQuick 2.0 -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 +Item { -// Editor for Operating Area 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 var areaItem ///< Mission Item for editor - - property real _margin: ScreenTools.defaultFontPixelWidth / 2 - property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5 - property var polyline: areaItem.polyline - property var operatingPolygon: areaItem.polygon - property bool initNecesarry: true - - function editPolyline(){ - polyline.setInteractive(true); - } - - - - - 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 - - SectionHeader { - id: scanHeader - text: qsTr("Settings") - } - - Column { - anchors.left: parent.left - anchors.right: parent.right - spacing: _margin - visible: scanHeader.checked - - GridLayout { - anchors.left: parent.left - anchors.right: parent.right - columnSpacing: _margin - rowSpacing: _margin - columns: 2 - - QGCLabel { - text: qsTr("Bottom Layer Altitude") - } - FactTextField { - fact: areaItem.bottomLayerAltitude - Layout.fillWidth: true - } - - QGCLabel { text: qsTr("Number of Layers") } - FactTextField { - fact: areaItem.numberOfLayers - Layout.fillWidth: true - } - - QGCLabel { text: qsTr("Layer Distance") } - FactTextField { - fact: areaItem.layerDistance - Layout.fillWidth: true - } - - - } - - Item { - height: ScreenTools.defaultFontPixelHeight / 2 - width: 1 - } - } // Column - Scan - SectionHeader { - id: polylineHeader - text: qsTr("Gateway Poly Line") - } - - QGCButton { - id: polylineEditor - anchors.topMargin: _margin / 2 - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - anchors.rightMargin: ScreenTools.defaultFontPixelWidth - text: "Edit Polyline" - - onClicked: editPolyline() - } - - SectionHeader { - id: statsHeader - text: qsTr("Statistics") - } - - Grid { - columns: 2 - columnSpacing: ScreenTools.defaultFontPixelWidth - visible: statsHeader.checked - - /*QGCLabel { text: qsTr("Layers") } - QGCLabel { text: areaItem.layers.valueString }*/ - - } - } // Column -} // Rectangle +} diff --git a/src/MissionManager/WimaController.cc b/src/MissionManager/WimaController.cc deleted file mode 100644 index 60e782af5..000000000 --- a/src/MissionManager/WimaController.cc +++ /dev/null @@ -1,134 +0,0 @@ -#include "WimaController.h" -#include "MissionController.h" - -WimaController::WimaController(QObject *parent) : - QObject (parent) - ,_planView (true) - ,_visualItems (new QmlObjectListModel(parent)) -{ - connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity); -} - -void WimaController::setMasterController(PlanMasterController *masterC) -{ - _masterController = masterC; - emit masterControllerChanged(); -} - -void WimaController::setMissionController(MissionController *missionC) -{ - _missionController = missionC; - emit missionControllerChanged(); -} - -void WimaController::setCurrentPolygonIndex(int index) -{ - if(index >= 0 && index < _visualItems->count() && index != _currentPolygonIndex){ - _currentPolygonIndex = index; - - emit currentPolygonIndexChanged(index); - } -} - -void WimaController::addGlobalMeasurementArea() -{ - WimaGlobalMeasurementPolygon* newPoly = new WimaGlobalMeasurementPolygon(this); - _visualItems->append(newPoly); - int newIndex = _visualItems->count()-1; - _currentPolygonIndex = newIndex; - - emit currentPolygonIndexChanged(newIndex); - emit visualItemsChanged(); -} - -void WimaController::removeArea(int index) -{ - if(index >= 0 && index < _visualItems->count()){ - _visualItems->removeAt(index); - - emit visualItemsChanged(); - - if(_currentPolygonIndex >= _visualItems->count()){ - setCurrentPolygonIndex(_visualItems->count() - 1); - }else{ - recalcPolygonInteractivity(_currentPolygonIndex); - } - }else{ - qWarning("Index out of bounds!"); - } - -} - -void WimaController::addServiceArea() -{ - resetAllIsCurrentPolygon(); - WimaServicePolygon* newPoly = new WimaServicePolygon(this); - newPoly->setInteractive(true); - _visualItems->append(newPoly); - - 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::recalcVehicleMeasurementAreas() -{ - -} - -void WimaController::recalcAll() -{ - -} - -void WimaController::recalcPolygonInteractivity(int index) -{ - resetAllIsCurrentPolygon(); - WimaPolygon* interactivePoly = qobject_cast(_visualItems->get(index)); - interactivePoly->setInteractive(true); -} - -void WimaController::resetAllIsCurrentPolygon() -{ - int itemCount = _visualItems->count(); - for (int i = 0; i < itemCount; i++) { - WimaPolygon* iteratorPoly = qobject_cast(_visualItems->get(i)); - iteratorPoly->setInteractive(false); - } -} - - - diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.cc b/src/MissionManager/WimaGlobalMeasurementPolygon.cc deleted file mode 100644 index ae28848ab..000000000 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.cc +++ /dev/null @@ -1,113 +0,0 @@ -#include "WimaGlobalMeasurementPolygon.h" - - -const char* WimaGlobalMeasurementPolygon::settingsGroup = "OperatingArea"; -const char* WimaGlobalMeasurementPolygon::bottomLayerAltitudeName = "BottomLayerAltitude"; -const char* WimaGlobalMeasurementPolygon::numberOfLayersName = "NumberOfLayers"; -const char* WimaGlobalMeasurementPolygon::layerDistanceName = "LayerDistance"; - -WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent) - : WimaPolygon (parent) - , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGlobalMeasurementPolygon.SettingsGroup.json"), this /* QObject parent */)) - , _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName]) - , _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName]) - , _layerDistance (settingsGroup, _metaDataMap[layerDistanceName]) - , _vehicleList (new QmlObjectListModel(this)) - , _vehiclePolygons (new QmlObjectListModel(this)) -{ - this->setObjectName("Operating Area"); - _polyline.bindPolygon(this->polygon()); -} - -WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent) - : WimaPolygon (other, parent) - , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGlobalMeasurementPolygon.SettingsGroup.json"), this /* QObject parent */)) - , _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName]) - , _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName]) - , _layerDistance (settingsGroup, _metaDataMap[layerDistanceName]) - , _vehicleList (new QmlObjectListModel(this)) - , _vehiclePolygons (new QmlObjectListModel(this)) -{ - this->setObjectName("Operating Area"); - _polyline.bindPolygon(this->polygon()); -} - -void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle) -{ - if(vehicle != nullptr){ - _vehicleList->append(vehicle); - emit vehicleListChanged(); - } -} - -void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex) -{ - if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){ - _vehicleList->removeAt(vehicleIndex); - emit vehicleListChanged(); - } -} - -void WimaGlobalMeasurementPolygon::recalculatesubPolygons() -{ - int vehicleCount = _vehicleList->count(); - QScopedPointer> listQGCPoly(this->splitPolygonArea(vehicleCount)); - - int polyCount = listQGCPoly->size(); - _vehiclePolygons->clear(); - for(int i = 0; i < polyCount; i++){ - WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this); - _vehiclePolygons->append(subPoly); - } -} - -void WimaGlobalMeasurementPolygon::removeAllVehicles() -{ - int count = _vehicleList->count(); - - if(count > 0){ - do{ - _vehicleList->removeAt(0); - count--; - }while(count > 0); - - emit vehicleListChanged(); - } - -} - - -void WimaGlobalMeasurementPolygon::addVehiclePolygon() -{ - _vehiclePolygons->append(new WimaVehicleMeasurementPolygon(this)); - - emit vehiclePolygonsChanged(); -} - -void WimaGlobalMeasurementPolygon::removeVehiclePolygon(int polygonIndex) -{ - if(polygonIndex >= 0 && polygonIndex < _vehiclePolygons->count()){ - _vehiclePolygons->removeAt(polygonIndex); - - emit vehiclePolygonsChanged(); - }else { - qWarning("Index out of bounds!"); - } -} - -void WimaGlobalMeasurementPolygon::removeVehiclePolygon(WimaVehicleMeasurementPolygon *wimaPolygon) -{ - if(wimaPolygon != nullptr){ - QObject* removedPolygon = _vehiclePolygons->removeOne(wimaPolygon); - if(removedPolygon){ - emit vehiclePolygonsChanged(); - }else { - qWarning("Polygon not inside polygon list."); - } - }else { - qWarning("Not a valid Polygon."); - } -} - - - diff --git a/src/MissionManager/WimaVehicle.h b/src/MissionManager/WimaVehicle.h deleted file mode 100644 index 2a41f4ad6..000000000 --- a/src/MissionManager/WimaVehicle.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include "Vehicle.h" - -class WimaServicePolygon; -class WimaVehicleCorridor; -class WimaVehicleMeasurementPolygon; - -class WimaVehicle : public QObject -{ - Q_OBJECT -public: - 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; - -}; - - diff --git a/src/Wima/WimaArea.cc b/src/Wima/WimaArea.cc new file mode 100644 index 000000000..e0a0f97e3 --- /dev/null +++ b/src/Wima/WimaArea.cc @@ -0,0 +1,6 @@ +#include "WimaArea.h" + +WimaArea::WimaArea() +{ + +} diff --git a/src/Wima/WimaArea.h b/src/Wima/WimaArea.h new file mode 100644 index 000000000..784672dd6 --- /dev/null +++ b/src/Wima/WimaArea.h @@ -0,0 +1,11 @@ +#ifndef WIMAAREA_H +#define WIMAAREA_H + + +class WimaArea +{ +public: + WimaArea(); +}; + +#endif // WIMAAREA_H \ No newline at end of file diff --git a/src/Wima/WimaController.cc b/src/Wima/WimaController.cc new file mode 100644 index 000000000..0a54782d9 --- /dev/null +++ b/src/Wima/WimaController.cc @@ -0,0 +1,6 @@ +#include "WimaController.h" + +WimaController::WimaController(QObject *parent) : QObject(parent) +{ + +} diff --git a/src/Wima/WimaController.h b/src/Wima/WimaController.h new file mode 100644 index 000000000..4996dede5 --- /dev/null +++ b/src/Wima/WimaController.h @@ -0,0 +1,17 @@ +#ifndef WIMACONTROLLER_H +#define WIMACONTROLLER_H + +#include + +class WimaController : public QObject +{ + Q_OBJECT +public: + explicit WimaController(QObject *parent = nullptr); + +signals: + +public slots: +}; + +#endif // WIMACONTROLLER_H \ No newline at end of file diff --git a/src/Wima/WimaGOperationArea.SettingsGroup.json b/src/Wima/WimaGOperationArea.SettingsGroup.json new file mode 100644 index 000000000..e69de29bb diff --git a/src/Wima/WimaGOperationArea.cc b/src/Wima/WimaGOperationArea.cc new file mode 100644 index 000000000..4fe0ecf8a --- /dev/null +++ b/src/Wima/WimaGOperationArea.cc @@ -0,0 +1,6 @@ +#include "WimaGOperationArea.h" + +WimaGOperationArea::WimaGOperationArea() +{ + +} diff --git a/src/Wima/WimaGOperationArea.h b/src/Wima/WimaGOperationArea.h new file mode 100644 index 000000000..fcc3de3c3 --- /dev/null +++ b/src/Wima/WimaGOperationArea.h @@ -0,0 +1,11 @@ +#ifndef WIMAGOPERATIONAREA_H +#define WIMAGOPERATIONAREA_H + + +class WimaGOperationArea +{ +public: + WimaGOperationArea(); +}; + +#endif // WIMAGOPERATIONAREA_H \ No newline at end of file diff --git a/src/Wima/WimaServiceArea.cc b/src/Wima/WimaServiceArea.cc new file mode 100644 index 000000000..e493648f0 --- /dev/null +++ b/src/Wima/WimaServiceArea.cc @@ -0,0 +1,6 @@ +#include "WimaServiceArea.h" + +WimaServiceArea::WimaServiceArea() +{ + +} diff --git a/src/Wima/WimaServiceArea.h b/src/Wima/WimaServiceArea.h new file mode 100644 index 000000000..3d5922c85 --- /dev/null +++ b/src/Wima/WimaServiceArea.h @@ -0,0 +1,11 @@ +#ifndef WIMASERVICEAREA_H +#define WIMASERVICEAREA_H + + +class WimaServiceArea +{ +public: + WimaServiceArea(); +}; + +#endif // WIMASERVICEAREA_H \ No newline at end of file diff --git a/src/Wima/WimaTrackerPolyline.cc b/src/Wima/WimaTrackerPolyline.cc new file mode 100644 index 000000000..4752bc0cc --- /dev/null +++ b/src/Wima/WimaTrackerPolyline.cc @@ -0,0 +1,6 @@ +#include "WimaTrackerPolyline.h" + +WimaTrackerPolyline::WimaTrackerPolyline() +{ + +} diff --git a/src/Wima/WimaTrackerPolyline.h b/src/Wima/WimaTrackerPolyline.h new file mode 100644 index 000000000..189524739 --- /dev/null +++ b/src/Wima/WimaTrackerPolyline.h @@ -0,0 +1,11 @@ +#ifndef WIMATRACKERPOLYLINE_H +#define WIMATRACKERPOLYLINE_H + + +class WimaTrackerPolyline +{ +public: + WimaTrackerPolyline(); +}; + +#endif // WIMATRACKERPOLYLINE_H \ No newline at end of file diff --git a/src/Wima/WimaVCorridor.cc b/src/Wima/WimaVCorridor.cc new file mode 100644 index 000000000..646684d36 --- /dev/null +++ b/src/Wima/WimaVCorridor.cc @@ -0,0 +1,6 @@ +#include "WimaVCorridor.h" + +WimaVCorridor::WimaVCorridor() +{ + +} diff --git a/src/Wima/WimaVCorridor.h b/src/Wima/WimaVCorridor.h new file mode 100644 index 000000000..0b3c20d44 --- /dev/null +++ b/src/Wima/WimaVCorridor.h @@ -0,0 +1,11 @@ +#ifndef WIMAVCORRIDOR_H +#define WIMAVCORRIDOR_H + + +class WimaVCorridor +{ +public: + WimaVCorridor(); +}; + +#endif // WIMAVCORRIDOR_H \ No newline at end of file diff --git a/src/Wima/WimaVehicle.cc b/src/Wima/WimaVehicle.cc new file mode 100644 index 000000000..4dc930908 --- /dev/null +++ b/src/Wima/WimaVehicle.cc @@ -0,0 +1,6 @@ +#include "WimaVehicle.h" + +WimaVehicle::WimaVehicle() +{ + +} diff --git a/src/Wima/WimaVehicle.h b/src/Wima/WimaVehicle.h new file mode 100644 index 000000000..c0fb67114 --- /dev/null +++ b/src/Wima/WimaVehicle.h @@ -0,0 +1,11 @@ +#ifndef WIMAVEHICLE_H +#define WIMAVEHICLE_H + + +class WimaVehicle +{ +public: + WimaVehicle(); +}; + +#endif // WIMAVEHICLE_H \ No newline at end of file diff --git a/src/WimaView/WimaGOperationAreaEditor.qml b/src/WimaView/WimaGOperationAreaEditor.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/src/WimaView/WimaGOperationAreaEditor.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/WimaView/WimaGOperationAreaMapVisual.qml b/src/WimaView/WimaGOperationAreaMapVisual.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/src/WimaView/WimaGOperationAreaMapVisual.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/WimaView/WimaGlobalMeasurementPolygonEditor.cc b/src/WimaView/WimaGlobalMeasurementPolygonEditor.cc new file mode 100644 index 000000000..60645d112 --- /dev/null +++ b/src/WimaView/WimaGlobalMeasurementPolygonEditor.cc @@ -0,0 +1,46 @@ +#include "WimaGlobalMeasurementPolygonEditor.h" + +WimaGlobalMeasurementPolygonEditor::WimaGlobalMeasurementPolygonEditor(QObject *parent) + : QAbstractItemModel(parent) +{ +} + +QVariant WimaGlobalMeasurementPolygonEditor::headerData(int section, Qt::Orientation orientation, int role) const +{ + // FIXME: Implement me! +} + +QModelIndex WimaGlobalMeasurementPolygonEditor::index(int row, int column, const QModelIndex &parent) const +{ + // FIXME: Implement me! +} + +QModelIndex WimaGlobalMeasurementPolygonEditor::parent(const QModelIndex &index) const +{ + // FIXME: Implement me! +} + +int WimaGlobalMeasurementPolygonEditor::rowCount(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return 0; + + // FIXME: Implement me! +} + +int WimaGlobalMeasurementPolygonEditor::columnCount(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return 0; + + // FIXME: Implement me! +} + +QVariant WimaGlobalMeasurementPolygonEditor::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + // FIXME: Implement me! + return QVariant(); +} diff --git a/src/WimaView/WimaGlobalMeasurementPolygonEditor.h b/src/WimaView/WimaGlobalMeasurementPolygonEditor.h new file mode 100644 index 000000000..f2ccafb47 --- /dev/null +++ b/src/WimaView/WimaGlobalMeasurementPolygonEditor.h @@ -0,0 +1,29 @@ +#ifndef WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H +#define WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H + +#include + +class WimaGlobalMeasurementPolygonEditor : public QAbstractItemModel +{ + Q_OBJECT + +public: + explicit WimaGlobalMeasurementPolygonEditor(QObject *parent = nullptr); + + // Header: + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + + // Basic functionality: + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +private: +}; + +#endif // WIMAGLOBALMEASUREMENTPOLYGONEDITOR_H \ No newline at end of file diff --git a/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml b/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml deleted file mode 100644 index c7ad14e6d..000000000 --- a/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * 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 areaItem: object - property var _polygon: areaItem.polygon - property var subPolylines: areaItem.subPolylines - property var subPolygons: areaItem.subPolygons - - 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) - } - } - - function _addInitialPolyline() { - if (subPolylines.count < 1) { - areaItem.addSubPolyline() - console.log("SubPolylines count: ", subPolylines.count) - var newPolyline = subPolylines.get(0) - newPolyline.appendVertex(_polygon.vertexCoordinate(0)) - newPolyline.appendVertex(_polygon.vertexCoordinate(1)) - } - } - - Component.onCompleted: { - _addInitialPolygon() - _addInitialPolyline()// always call _addInitialPolyline() after _addInitialPolygon() - } - - Component.onDestruction: { - } - - QGCMapPolygonVisuals { - qgcView: _root.qgcView - mapControl: map - mapPolygon: _polygon - borderWidth: 1 - borderColor: "black" - interiorColor: "green" - interiorOpacity: 0.25 - } - - Repeater { - model: subPolylines - delegate: QGCMapPolylineVisuals { - qgcView: _root.qgcView - mapControl: map - mapPolyline: object - lineWidth: 4 - lineColor: interactive ? "yellow" : "white" - } - } - - - - - - - -} diff --git a/src/WimaView/WimaMapPolygonVisuals.qml b/src/WimaView/WimaMapPolygonVisuals.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/src/WimaView/WimaMapPolygonVisuals.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/WimaView/WimaMapPolylineVisuals.qml b/src/WimaView/WimaMapPolylineVisuals.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/src/WimaView/WimaMapPolylineVisuals.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/WimaView/WimaServiceAreaMapVisual.qml b/src/WimaView/WimaServiceAreaMapVisual.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/src/WimaView/WimaServiceAreaMapVisual.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/WimaView/WimaServicePolygonMapVisual.qml b/src/WimaView/WimaServicePolygonMapVisual.qml deleted file mode 100644 index 8fec7f55a..000000000 --- a/src/WimaView/WimaServicePolygonMapVisual.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * 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 - } - - - - -} -- 2.22.0