From ca234ed5bc3f474ea326d00d3c2ca729aa80a28b Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 6 Sep 2015 21:11:00 -0700 Subject: [PATCH] commit --- QGCApplication.pro | 3 + qgroundcontrol.qrc | 1 + src/MissionEditor/MissionEditor.cc | 78 +++++++++++++++++++++++ src/MissionEditor/MissionEditor.h | 55 +++++++++++++++++ src/MissionEditor/MissionEditor.qml | 95 +++++++++++++++++++++++++++++ src/ui/MainWindow.cc | 42 +++++++++++-- src/ui/MainWindow.h | 14 ++--- src/ui/MainWindow.ui | 12 ++++ 8 files changed, 287 insertions(+), 13 deletions(-) create mode 100644 src/MissionEditor/MissionEditor.cc create mode 100644 src/MissionEditor/MissionEditor.h create mode 100644 src/MissionEditor/MissionEditor.qml diff --git a/QGCApplication.pro b/QGCApplication.pro index 37f5a30fc..c62f3e279 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -144,6 +144,7 @@ INCLUDEPATH += \ src/input \ src/Joystick \ src/lib/qmapcontrol \ + src/MissionEditor \ src/QmlControls \ src/uas \ src/ui \ @@ -244,6 +245,7 @@ HEADERS += \ src/Joystick/JoystickManager.h \ src/LogCompressor.h \ src/MG.h \ + src/MissionEditor/MissionEditor.h \ src/QGC.h \ src/QGCApplication.h \ src/QGCComboBox.h \ @@ -381,6 +383,7 @@ SOURCES += \ src/Joystick/JoystickManager.cc \ src/LogCompressor.cc \ src/main.cc \ + src/MissionEditor/MissionEditor.cc \ src/QGC.cc \ src/QGCApplication.cc \ src/QGCComboBox.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 657dda618..1ab4651b3 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -128,6 +128,7 @@ src/FlightDisplay/FlightDisplayView.qml src/FlightDisplay/FlightDisplayWidget.qml src/ui/mapdisplay/MapDisplay.qml + src/MissionEditor/MissionEditor.qml src/FlightMap/qmldir diff --git a/src/MissionEditor/MissionEditor.cc b/src/MissionEditor/MissionEditor.cc new file mode 100644 index 000000000..d50d572d5 --- /dev/null +++ b/src/MissionEditor/MissionEditor.cc @@ -0,0 +1,78 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +#include "MissionEditor.h" +#include "ScreenToolsController.h" + +#include +#include +#include + +const char* MissionEditor::_settingsGroup = "MissionEditor"; + +MissionEditor::MissionEditor(QWidget *parent) + : QGCQmlWidgetHolder(parent) +{ + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + // Get rid of layout default margins + QLayout* pl = layout(); + if(pl) { + pl->setContentsMargins(0,0,0,0); + } +#ifndef __android__ + setMinimumWidth( 31 * ScreenToolsController::defaultFontPixelSize_s()); + setMinimumHeight(33 * ScreenToolsController::defaultFontPixelSize_s()); +#endif + + setContextPropertyObject("controller", this); + + setSource(QUrl::fromUserInput("qrc:/qml/MissionEditor.qml")); +} + +MissionEditor::~MissionEditor() +{ +} + +void MissionEditor::saveSetting(const QString &name, const QString& value) +{ + QSettings settings; + + settings.beginGroup(_settingsGroup); + + settings.setValue(name, value); +} + +QString MissionEditor::loadSetting(const QString &name, const QString& defaultValue) +{ + QSettings settings; + + settings.beginGroup(_settingsGroup); + + return settings.value(name, defaultValue).toString(); +} + +void MissionEditor::addMissionItem(QGeoCoordinate coordinate) +{ + MissionItem * newItem = new MissionItem(this, _missionItems.count(), coordinate.longitude(), coordinate.latitude()); + _missionItems.append(newItem); +} diff --git a/src/MissionEditor/MissionEditor.h b/src/MissionEditor/MissionEditor.h new file mode 100644 index 000000000..03e0c11ab --- /dev/null +++ b/src/MissionEditor/MissionEditor.h @@ -0,0 +1,55 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +#ifndef MissionEditor_H +#define MissionEditor_H + +#include "QGCQmlWidgetHolder.h" +#include "QmlObjectListModel.h" + +class MissionEditor : public QGCQmlWidgetHolder +{ + Q_OBJECT + +public: + MissionEditor(QWidget* parent = NULL); + ~MissionEditor(); + + Q_PROPERTY(QmlObjectListModel* missionItems READ missionItemsModel CONSTANT) + + Q_INVOKABLE void addMissionItem(QGeoCoordinate coordinate); + + Q_INVOKABLE void saveSetting (const QString &key, const QString& value); + Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue); + + // Property accessors + + QmlObjectListModel* missionItemsModel(void) { return &_missionItems; } + +private: + QmlObjectListModel _missionItems; + + static const char* _settingsGroup; +}; + +#endif diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml new file mode 100644 index 000000000..b7ebb79e8 --- /dev/null +++ b/src/MissionEditor/MissionEditor.qml @@ -0,0 +1,95 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Dialogs 1.2 + +import QGroundControl.FlightMap 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 + +/// Mission Editor +Item { + id: root + + property var __qgcPal: QGCPalette { colorGroupEnabled: enabled } + + property var _activeVehicle: multiVehicleManager.activeVehicle + + readonly property real _defaultLatitude: 37.803784 + readonly property real _defaultLongitude: -122.462276 + + FlightMap { + id: editorMap + anchors.fill: parent + mapName: "MissionEditor" + latitude: parent._defaultLatitude + longitude: parent._defaultLongitude + + MouseArea { + anchors.fill: parent + + onClicked: controller.addMissionItem(editorMap.mapItem.toCoordinate(Qt.point(mouse.x, mouse.y))) + } + } + + Column { + id: controlWidgets + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.right: parent.left + anchors.bottom: parent.top + spacing: ScreenTools.defaultFontPixelWidth / 2 + + QGCButton { + id: addMode + text: "+" + checkable: true + } + } + + // Mission item list + ListView { + id: missionItemSummaryList + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.bottom: parent.bottom + width: parent.width + height: ScreenTools.defaultFontPixelHeight * 7 + spacing: ScreenTools.defaultFontPixelWidth / 2 + opacity: 0.75 + orientation: ListView.Horizontal + model: controller.missionItems + + property real _maxItemHeight: 0 + + delegate: + MissionItemSummary { + opacity: 0.75 + missionItem: object +Component.onCompleted: console.log("add", object.id) + } + } + +} diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index e2bc21778..afe26d8b1 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -72,6 +72,7 @@ This file is part of the QGROUNDCONTROL project #include "MultiVehicleManager.h" #include "CustomCommandWidget.h" #include "HomePositionManager.h" +#include "MissionEditor.h" #ifdef UNITTEST_BUILD #include "QmlControls/QmlTestWidget.h" @@ -425,6 +426,14 @@ void MainWindow::_buildPlanView(void) } } +void MainWindow::_buildMissionEditorView(void) +{ + if (!_missionEditorView) { + _missionEditorView = new MissionEditor(this); + _missionEditorView->setVisible(false); + } +} + void MainWindow::_buildFlightView(void) { if (!_flightView) { @@ -700,6 +709,7 @@ void MainWindow::connectCommonActions() perspectives->addAction(_ui.actionFlight); perspectives->addAction(_ui.actionSimulationView); perspectives->addAction(_ui.actionPlan); + perspectives->addAction(_ui.actionMissionEditor); perspectives->addAction(_ui.actionSetup); perspectives->setExclusive(true); @@ -724,6 +734,11 @@ void MainWindow::connectCommonActions() _ui.actionPlan->setChecked(true); _ui.actionPlan->activate(QAction::Trigger); } + if (_currentView == VIEW_MISSIONEDITOR) + { + _ui.actionMissionEditor->setChecked(true); + _ui.actionMissionEditor->activate(QAction::Trigger); + } if (_currentView == VIEW_SETUP) { _ui.actionSetup->setChecked(true); @@ -738,11 +753,12 @@ void MainWindow::connectCommonActions() connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleRemoved, this, &MainWindow::_vehicleRemoved); // Views actions - connect(_ui.actionFlight, SIGNAL(triggered()), this, SLOT(loadFlightView())); - connect(_ui.actionSimulationView, SIGNAL(triggered()), this, SLOT(loadSimulationView())); - connect(_ui.actionAnalyze, SIGNAL(triggered()), this, SLOT(loadAnalyzeView())); - connect(_ui.actionPlan, SIGNAL(triggered()), this, SLOT(loadPlanView())); - + connect(_ui.actionFlight, SIGNAL(triggered()), this, SLOT(loadFlightView())); + connect(_ui.actionSimulationView, SIGNAL(triggered()), this, SLOT(loadSimulationView())); + connect(_ui.actionAnalyze, SIGNAL(triggered()), this, SLOT(loadAnalyzeView())); + connect(_ui.actionPlan, SIGNAL(triggered()), this, SLOT(loadPlanView())); + connect(_ui.actionMissionEditor, SIGNAL(triggered()), this, SLOT(loadMissionEditorView())); + // Help Actions connect(_ui.actionOnline_Documentation, SIGNAL(triggered()), this, SLOT(showHelp())); connect(_ui.actionDeveloper_Credits, SIGNAL(triggered()), this, SLOT(showCredits())); @@ -891,6 +907,11 @@ void MainWindow::_loadCurrentViewState(void) defaultWidgets = "WAYPOINT_LIST_DOCKWIDGET"; break; + case VIEW_MISSIONEDITOR: + _buildMissionEditorView(); + centerView = _missionEditorView; + break; + case VIEW_SIMULATION: _buildSimView(); centerView = _simView; @@ -993,6 +1014,17 @@ void MainWindow::loadPlanView() } } +void MainWindow::loadMissionEditorView() +{ + if (_currentView != VIEW_MISSIONEDITOR) + { + _storeCurrentViewState(); + _currentView = VIEW_MISSIONEDITOR; + _ui.actionMissionEditor->setChecked(true); + _loadCurrentViewState(); + } +} + void MainWindow::loadSetupView() { if (_currentView != VIEW_SETUP) diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 8a31ed2f5..00ec87b41 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -130,17 +130,13 @@ public slots: /** @brief Show the application settings */ void showSettings(); - /** @brief Load configuration views */ void loadSetupView(); - /** @brief Load view for pilot */ void loadFlightView(); - /** @brief Load view for simulation */ void loadSimulationView(); - /** @brief Load view for engineer */ void loadAnalyzeView(); - /** @brief Load New (QtQuick) Map View (Mission) */ void loadPlanView(); - /** @brief Manage Links */ + void loadMissionEditorView(); + void manageLinks(); /** @brief Show the online help for users */ @@ -204,12 +200,13 @@ protected: typedef enum _VIEW_SECTIONS { VIEW_ANALYZE, // Engineering/Analyze view mode. Used for analyzing data and modifying onboard parameters - VIEW_PLAN, // New (QtQuick) Mission/Map/Plan view mode. Used for setting mission waypoints and high-level system commands. + VIEW_PLAN, // Old mission editor VIEW_FLIGHT, // Flight/Fly/Operate view mode. Used for 1st-person observation of the vehicle. VIEW_SIMULATION, // HIL Simulation view. Useful overview of the entire system when doing hardware-in-the-loop simulations. VIEW_SETUP, // Setup view. Used for initializing the system for operation. Includes UI for calibration, firmware updating/checking, and parameter modifcation. VIEW_UNUSED1, // Unused (don't remove, or it will screw up saved settigns indices) VIEW_UNUSED2, // Unused (don't remove, or it will screw up saved settigns indices) + VIEW_MISSIONEDITOR, // New mission editor } VIEW_SECTIONS; /** @brief Catch window resize events */ @@ -288,6 +285,7 @@ private: QPointer _analyzeView; QPointer _simView; QPointer _terminalView; + QPointer _missionEditorView; // Dock widget names static const char* _uasControlDockWidgetName; @@ -316,6 +314,7 @@ private: void _buildAnalyzeView(void); void _buildSimView(void); void _buildTerminalView(void); + void _buildMissionEditorView(void); void _storeCurrentViewState(void); void _loadCurrentViewState(void); @@ -344,7 +343,6 @@ private: QString _getWindowStateKey(); QString _getWindowGeometryKey(); - }; #endif /* _MAINWINDOW_H_ */ diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index 17a5d99b5..05fbb5134 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -79,6 +79,7 @@ + @@ -242,6 +243,17 @@ Show Status Bar + + + true + + + New Mission Editor + + + Mission Editor + + -- 2.22.0