From 86388db394ad9ce15927c2526791f9c4eb35e655 Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Mon, 1 Apr 2019 13:42:38 +0200 Subject: [PATCH] facts added to global m area --- WimaGlobalMeasurementPolygonEditor.qml | 144 +++++++++++++++++- qgroundcontrol.qrc | 1 + ...lobalMeasurementPolygon.SettingsGroup.json | 27 ++++ .../WimaGlobalMeasurementPolygon.cc | 34 ++--- .../WimaGlobalMeasurementPolygon.h | 27 ++-- 5 files changed, 189 insertions(+), 44 deletions(-) diff --git a/WimaGlobalMeasurementPolygonEditor.qml b/WimaGlobalMeasurementPolygonEditor.qml index 9c36e13c5..3fb34fa10 100644 --- a/WimaGlobalMeasurementPolygonEditor.qml +++ b/WimaGlobalMeasurementPolygonEditor.qml @@ -1,5 +1,143 @@ -import QtQuick 2.0 +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 -Item { +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 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 missionItem ///< Mission Item for editor + + property real _margin: ScreenTools.defaultFontPixelWidth / 2 + property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5 + + + + 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("Scan") + } + + 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 + + FactComboBox { + fact: missionItem.startFromTop + indexModel: true + model: [ qsTr("Start Scan From Bottom"), qsTr("Start Scan From Top") ] + Layout.columnSpan: 2 + Layout.fillWidth: true + } + + QGCLabel { + text: qsTr("Structure Height") + } + FactTextField { + fact: missionItem.structureHeight + Layout.fillWidth: true + } + + QGCLabel { text: qsTr("Scan Bottom Alt") } + FactTextField { + fact: missionItem.scanBottomAlt + Layout.fillWidth: true + } + + QGCLabel { text: qsTr("Entrance/Exit Alt") } + FactTextField { + fact: missionItem.entranceAlt + LayoWimaGlobalMeasurementPolygonEditor.qmlut.fillWidth: true + } + + QGCLabel { + text: qsTr("Gimbal Pitch") + visible: missionItem.cameraCalc.isManualCamera + } + FactTextField { + fact: missionItem.gimbalPitch + Layout.fillWidth: true + visible: missionItem.cameraCalc.isManualCamera + } + } + + Item { + height: ScreenTools.defaultFontPixelHeight / 2 + width: 1 + } + + QGCButton { + text: qsTr("Rotate entry point") + onClicked: missionItem.rotateEntryPoint() + } + } // Column - Scan + + SectionHeader { + id: statsHeader + text: qsTr("Statistics") + } + + Grid { + columns: 2 + columnSpacing: ScreenTools.defaultFontPixelWidth + visible: statsHeader.checked + + QGCLabel { text: qsTr("Layers") } + QGCLabel { text: missionItem.layers.valueString } + + QGCLabel { text: qsTr("Layer Height") } + QGCLabel { text: missionItem.cameraCalc.adjustedFootprintFrontal.valueString + " " + QGroundControl.appSettingsDistanceUnitsString } + + QGCLabel { text: qsTr("Top Layer Alt") } + QGCLabel { text: QGroundControl.metersToAppSettingsDistanceUnits(missionItem.topFlightAlt).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString } + + QGCLabel { text: qsTr("Bottom Layer Alt") } + QGCLabel { text: QGroundControl.metersToAppSettingsDistanceUnits(missionItem.bottomFlightAlt).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString } + + QGCLabel { text: qsTr("Photo Count") } + QGCLabel { text: missionItem.cameraShots } + + QGCLabel { text: qsTr("Photo Interval") } + QGCLabel { text: missionItem.timeBetweenShots.toFixed(1) + " " + qsTr("secs") } + + QGCLabel { text: qsTr("Trigger Distance") } + QGCLabel { text: missionItem.cameraCalc.adjustedFootprintSide.valueString + " " + QGroundControl.appSettingsDistanceUnitsString } + } + } // Column +} // Rectangle diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 5c3bc7358..8711bce22 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -259,6 +259,7 @@ src/Vehicle/VibrationFact.json src/Vehicle/WindFact.json src/Settings/Video.SettingsGroup.json + src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json src/comm/APMArduCopterMockLink.params diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json b/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json index e69de29bb..b5fcb0b7f 100644 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json +++ b/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json @@ -0,0 +1,27 @@ +[ +{ + "name": "BottomLayerAltitude", + "shortDescription": "Altitude of the bottom layer.", + "type": "double", + "units": "m", + "min": 1, + "decimalPlaces": 2, + "defaultValue": 5 +}, +{ + "name": "NumberOfLayers", + "shortDescription": "The number of layers", + "type": "unint32", + "min": 1, + "defaultValue": 1 +}, +{ + "name": "LayerDistance", + "shortDescription": "The distance between to adjacent layers.", + "type": "double", + "units": "m", + "min": 0, + "decimalPlaces": 2, + "defaultValue": 1 +} +] diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.cc b/src/MissionManager/WimaGlobalMeasurementPolygon.cc index 7f7c41b87..5b4d1d83a 100644 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.cc +++ b/src/MissionManager/WimaGlobalMeasurementPolygon.cc @@ -1,9 +1,17 @@ #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) +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]) { this->setObjectName("Operating Area"); } @@ -55,26 +63,4 @@ void WimaGlobalMeasurementPolygon::removeAllVehicles() emit vehicleListChanged(); } -void WimaGlobalMeasurementPolygon::setBottomLayerAltitude(double altitude) -{ - if(altitude > 0 && altitude != _bottomLayerAltitude){ - _bottomLayerAltitude = altitude; - emit bottomLayerAltitudeChanged(); - } -} - -void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers) -{ - if(numberOfLayers > 0 && _numberOfLayers != numberOfLayers){ - _numberOfLayers = numberOfLayers; - emit numberOfLayersChanged(); - } -} -void WimaGlobalMeasurementPolygon::setLayerDistance(double distance) -{ - if(distance > 0 && distance != _layerDistance){ - _layerDistance = distance; - emit layerDistanceChanged(); - } -} diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.h b/src/MissionManager/WimaGlobalMeasurementPolygon.h index 9d62c13d0..d15cba81a 100644 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.h +++ b/src/MissionManager/WimaGlobalMeasurementPolygon.h @@ -5,6 +5,7 @@ #include "QGCMapPolyline.h" #include "QGCMapPolygon.h" #include "WimaVehicleMeasurementPolygon.h" +#include "SettingsFact.h" #include "QScopedPointer" @@ -15,9 +16,9 @@ public: WimaGlobalMeasurementPolygon(QObject* parent); WimaGlobalMeasurementPolygon(QGCMapPolygon* other, QObject* parent); - Q_PROPERTY(double bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged) - Q_PROPERTY(int numberOfLayers READ numberOfLayers WRITE setNumberOfLayers NOTIFY numberOfLayersChanged) - Q_PROPERTY(double layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged) + Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT) + Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT) + Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT) Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged) Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged) @@ -32,20 +33,17 @@ public: QString editorQML (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";} // Property accessors - double bottomLayerAltitude (void) const { return _bottomLayerAltitude;} - int numberOfLayers (void) const { return _numberOfLayers;} - double layerDistance (void) const { return _layerDistance;} + Fact* bottomLayerAltitude (void) { return &_bottomLayerAltitude;} + Fact* numberOfLayers (void) { return &_numberOfLayers;} + Fact* layerDistance (void) { return &_layerDistance;} QmlObjectListModel* vehicleList (void) const { return _vehicleList;} QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;} - // Property setters - - void setBottomLayerAltitude (double altitude); - void setNumberOfLayers (int numberOfLayers); - void setLayerDistance (double distance); - static const char* settingsGroup; + static const char* bottomLayerAltitudeName; + static const char* numberOfLayersName; + static const char* layerDistanceName; signals: @@ -69,10 +67,5 @@ private: QGCMapPolyline* _entryPolyline; - - - - SettingsFact - }; -- 2.22.0