Commit 3bc2c3a0 authored by Valentin Platzgummer's avatar Valentin Platzgummer

Fly Area Editor added

parent 0ca9e0a1
......@@ -211,6 +211,8 @@
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.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/FlyAreaEditor.qml">src/WimaView/FlyAreaEditor.qml</file>
<file alias="QGroundControl/Controls/FlyAreaItemEditor.qml">src/WimaView/FlyAreaItemEditor.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
......@@ -22,20 +22,47 @@ void WimaFlyArea::_init()
_polygons = new QmlObjectListModel(this);
}
void WimaFlyArea::append_WimaFlyArea()
void WimaFlyArea::appendFlyAreaPolygon()
{
QGCMapPolygon *newPolygon = new QGCMapPolygon();
newPolygon->setInteractive(true);
for (int i = 0; i < _polygons->count(); i++) {
QGCMapPolygon* polygon = qobject_cast<QGCMapPolygon*>(_polygons->get(i));
polygon->setInteractive(false);
}
_polygons->append(newPolygon);
int index = _polygons->count()-1;
setCurrentPolygon(index);
emit polygonsChanged();
}
void WimaFlyArea::removeFlyAreaPolygon(int index)
{
if(index >= 0 && index < _polygons->count()) {
_polygons->removeAt(index);
emit polygonsChanged();
}
}
void WimaFlyArea::setCurrentPolygon(int index)
{
if(index >= 0 && index < _polygons->count()) {
if(index == _currentPolygonIndex){
return;
}
for (int i = 0; i < _polygons->count(); i++) {
QGCMapPolygon* polygon = qobject_cast<QGCMapPolygon*>(_polygons->get(i));
polygon->setInteractive(false);
}
_currentPolygonIndex = index;
_currentPolygonItem = qobject_cast<QGCMapPolygon*>(_polygons->get(index));
_currentPolygonItem->setInteractive(true);
emit currentPolygonItemChanged(_currentPolygonItem);
emit currentPolygonIndexChanged(index);
}
}
......@@ -16,12 +16,18 @@ public:
Q_PROPERTY(QmlObjectListModel *polygons READ polygons NOTIFY polygonsChanged)
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_INVOKABLE void append_WimaFlyArea();
Q_INVOKABLE void appendFlyAreaPolygon();
Q_INVOKABLE void removeFlyAreaPolygon(int index);
Q_INVOKABLE void setCurrentPolygon(int index);
// Property Accessors
QmlObjectListModel * polygons (void) { return _polygons;}
QmlObjectListModel * polygons (void) { return _polygons;}
QGCMapPolygon * currentPolygonItem (void) { return _currentPolygonItem;}
int currentPolygonIndex (void) { return _currentPolygonIndex;}
// Methodes
......@@ -29,13 +35,19 @@ public:
signals:
void polygonsChanged(void);
void currentPolygonItemChanged(QGCMapPolygon * polygon);
void currentPolygonIndexChanged(int index);
public slots:
private:
QmlObjectListModel* _polygons;
QGCMapPolygon* _isCurrentPolygon;
QGCMapPolygon* _currentPolygonItem;
int _currentPolygonIndex;
};
......
......@@ -84,3 +84,4 @@ VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml
FlyAreaPolygonMapVisual 1.0 FlyAreaPolygonMapVisual.qml
FlyAreaItemEditor 1.0 FlyAreaItemEditor.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 var missionItem ///< Mission Item for editor
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
property real _cameraMinTriggerInterval: missionItem.cameraCalc.minTriggerInterval.rawValue
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
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 edit control
Rectangle {
id: _root
height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (commandPicker.y + commandPicker.height + _margin / 2)
color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
radius: _radius
property var map ///< Map control
property var masterController
property var missionItem ///< MissionItem associated with this editor
property bool readOnly ///< true: read only view, false: full editing view
property var rootQgcView
property var flyArea
signal clicked
signal remove
property var _masterController: masterController
property var _missionController: _masterController.missionController
property bool _currentItem: flyArea.currentPolygonIndex === index
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: commandPicker.height
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: commandPicker.verticalCenter
anchors.leftMargin: _margin
anchors.left: parent.left
text: index+1
color: _outerTextColor
}
QGCColoredImage {
id: hamburger
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.verticalCenter: commandPicker.verticalCenter
width: _hamburgerSize
height: _hamburgerSize
sourceSize.height: _hamburgerSize
source: "qrc:/qmlimages/Hamburger.svg"
visible: flyArea.currentPolygonIndex === index
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()
}
}
}
QGCButton {
id: commandPicker
anchors.topMargin: _margin / 2
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: label.right
anchors.top: parent.top
visible: !commandPicker.visible
text: missionItem.commandName
Component {
id: commandDialog
MissionCommandDialog {
missionItem: _root.missionItem
}
}
//onClicked: qgcView.showDialog(commandDialog, qsTr("Select Mission Command"), qgcView.showDialogDefaultWidth, StandardButton.Cancel)
}
QGCLabel {
id: commandLabel
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: "Fly Area"
color: _outerTextColor
}
Loader {
id: editorLoader
anchors.leftMargin: _margin
anchors.topMargin: _margin
anchors.left: parent.left
anchors.top: commandPicker.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
This diff is collapsed.
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