Commit 1b6d3ca9 authored by Valentin Platzgummer's avatar Valentin Platzgummer

fly area edited

parent 7aea4ba9
<RCC>
<qresource prefix="/unittest">
<file alias="SectionTest.plan">src/MissionManager/UnitTest/SectionTest.plan</file>
<file alias="SectionTest.plan">src/MissionManager/UnitTest/SectionTest.plan</file>
<file alias="MavCmdInfoCommon.json">src/MissionManager/UnitTest/MavCmdInfoCommon.json</file>
<file alias="MavCmdInfoFixedWing.json">src/MissionManager/UnitTest/MavCmdInfoFixedWing.json</file>
<file alias="MavCmdInfoMultiRotor.json">src/MissionManager/UnitTest/MavCmdInfoMultiRotor.json</file>
......@@ -9,10 +9,13 @@
<file alias="MavCmdInfoVTOL.json">src/MissionManager/UnitTest/MavCmdInfoVTOL.json</file>
<file alias="MissionPlanner.waypoints">src/MissionManager/UnitTest/MissionPlanner.waypoints</file>
<file alias="OldFileFormat.mission">src/MissionManager/UnitTest/OldFileFormat.mission</file>
<file alias="PolygonAreaTest.kml">src/MissionManager/UnitTest/PolygonAreaTest.kml</file>
<file alias="PolygonGood.kml">src/MissionManager/UnitTest/PolygonGood.kml</file>
<file alias="PolygonMissingNode.kml">src/MissionManager/UnitTest/PolygonMissingNode.kml</file>
<file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file>
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
<file alias="PolygonAreaTest.kml">src/MissionManager/UnitTest/PolygonAreaTest.kml</file>
<file alias="PolygonGood.kml">src/MissionManager/UnitTest/PolygonGood.kml</file>
<file alias="PolygonMissingNode.kml">src/MissionManager/UnitTest/PolygonMissingNode.kml</file>
<file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file>
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
</qresource>
<qresource prefix="/">
<file>src/WimaView/FlyAreaMapVisual.qml</file>
</qresource>
</RCC>
......@@ -351,4 +351,5 @@
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode4/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode4/joystickYawRight.png</file>
</qresource>
<qresource prefix="/"/>
</RCC>
......@@ -407,7 +407,8 @@ HEADERS += \
src/api/QmlComponentInfo.h \
src/comm/MavlinkMessagesTimer.h \
src/GPS/Drivers/src/base_station.h \
src/MissionManager/WimaController.h
src/MissionManager/WimaController.h \
src/MissionManager/WimaFlyArea.h
SOURCES += \
src/api/QGCCorePlugin.cc \
......@@ -415,7 +416,8 @@ SOURCES += \
src/api/QGCSettings.cc \
src/api/QmlComponentInfo.cc \
src/comm/MavlinkMessagesTimer.cc \
src/MissionManager/WimaController.cc
src/MissionManager/WimaController.cc \
src/MissionManager/WimaFlyArea.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......
......@@ -210,6 +210,7 @@
<file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file>
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file>
<file alias="WimaView.qml">src/WimaView/WimaView.qml</file>
<file alias="QGroundControl/Controls/FlyAreaMapVisual.qml">src/WimaView/FlyAreaMapVisual.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
#include "WimaController.h"
#include "MissionController.h"
WimaController::WimaController(QObject *parent) : QObject(parent)
{
this->_flyArea = WimaFlyArea(parent);
}
void WimaController::initWimaFlyArea()
{
this->_flyArea.setReady();
return;
}
#ifndef WIMACONTROLLER_H
#ifndef WIMACONTROLLER_H
#define WIMACONTROLLER_H
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "WimaFlyArea.h"
class WimaController : public QObject
{
......@@ -9,9 +12,28 @@ class WimaController : public QObject
public:
explicit WimaController(QObject *parent = nullptr);
Q_PROPERTY(WimaFlyArea *flyArea READ flyArea CONSTANT)
//Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
/// Add a fly area to the list
/// @param itemName: Name of complex item to create (from complexMissionItemNames)
/// @param mapCenterCoordinate: coordinate for current center of map
/// @param i: index to insert at
/// @return Sequence number for new item
Q_INVOKABLE void initWimaFlyArea();
//Property Accessors
WimaFlyArea *flyArea (void) { return &_flyArea; }
//QmlObjectListModel* visualItems (void) { return _visualItems; }
signals:
public slots:
private:
//QmlObjectListModel* _visualItems;
WimaFlyArea _flyArea;
};
#endif // WIMACONTROLLER_H
\ No newline at end of file
#endif // WIMACONTROLLER_H
#include "WimaFlyArea.h"
WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent)
{
this->_isReady = false;
}
WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent)
{
*this = other;
}
const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other)
{
this->_flyAreaPolygon = other._flyAreaPolygon;
this->_isReady = other._isReady;
return *this;
}
void WimaFlyArea::setReady()
{
this->_isReady = true;
emit readyStateChanged();
}
#ifndef WIMAFLYAREA_H
#define WIMAFLYAREA_H
#include <QObject>
#include "QGCMapPolygon.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(QString mapVisualQML READ mapVisualQML CONSTANT)
Q_PROPERTY(bool isReady READ isReady NOTIFY readyStateChanged)
Q_PROPERTY(QGCMapPolygon flyAreaPolygon READ flyAreaPolygon CONSTANT)
// Property Accessors
QString mapVisualQML (void) const { return QStringLiteral("FlyAreaMapVisual.qml"); }
bool isReady (void) { return _isReady;}
QGCMapPolygon flyAreaPolygon (void) { return _flyAreaPolygon;}
// Methodes
void setReady();
signals:
void readyStateChanged(void);
public slots:
private:
QGCMapPolygon _flyAreaPolygon;
bool _isReady;
};
#endif // WIMAFLYAREA_H
......@@ -67,6 +67,8 @@
#include "FlightMapSettings.h"
#include "CoordinateVector.h"
#include "PlanMasterController.h"
#include "WimaController.h" //custom
#include "WimaFlyArea.h" //custom
#include "VideoManager.h"
#include "VideoSurface.h"
#include "VideoReceiver.h"
......@@ -422,6 +424,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<RallyPointController>(kQGCControllers, 1, 0, "RallyPointController", kRefOnly);
qmlRegisterUncreatableType<VisualMissionItem> (kQGCControllers, 1, 0, "VisualMissionItem", kRefOnly);
qmlRegisterUncreatableType<CoordinateVector> ("QGroundControl", 1, 0, "CoordinateVector", kRefOnly);
qmlRegisterUncreatableType<QmlObjectListModel> ("QGroundControl", 1, 0, "QmlObjectListModel", kRefOnly);
qmlRegisterUncreatableType<MissionCommandTree> ("QGroundControl", 1, 0, "MissionCommandTree", kRefOnly);
......@@ -435,6 +438,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<FactValueSliderListModel>("QGroundControl.FactControls", 1, 0, "FactValueSliderListModel", kRefOnly);
qmlRegisterUncreatableType<QGCMapPolygon> ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", kRefOnly);
qmlRegisterUncreatableType<WimaFlyArea> ("QGroundControl.FlightMap", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterUncreatableType<QGCGeoBoundingCube> ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly);
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
......@@ -443,6 +447,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<ESP8266ComponentController> (kQGCControllers, 1, 0, "ESP8266ComponentController");
qmlRegisterType<ScreenToolsController> (kQGCControllers, 1, 0, "ScreenToolsController");
qmlRegisterType<PlanMasterController> (kQGCControllers, 1, 0, "PlanMasterController");
qmlRegisterType<WimaController> (kQGCControllers, 1, 0, "WimaController"); //custom
qmlRegisterType<ValuesWidgetController> (kQGCControllers, 1, 0, "ValuesWidgetController");
qmlRegisterType<QGCFileDialogController> (kQGCControllers, 1, 0, "QGCFileDialogController");
qmlRegisterType<RCChannelMonitorController> (kQGCControllers, 1, 0, "RCChannelMonitorController");
......
/****************************************************************************
*
* (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
/// Fly Area Map visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _flyAreaPolygon
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_flyAreaPolygon.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)
_flyAreaPolygon.appendVertex(topLeftCoord)
_flyAreaPolygon.appendVertex(topRightCoord)
_flyAreaPolygon.appendVertex(bottomRightCoord)
_flyAreaPolygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _flyAreaPolygon
interactive: true
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
}
/****************************************************************************
*
* (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
/// Survey Complex Mission Item visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _flyAreaPolygon
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_structurePolygon.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)
_structurePolygon.appendVertex(topLeftCoord)
_structurePolygon.appendVertex(topRightCoord)
_structurePolygon.appendVertex(bottomRightCoord)
_structurePolygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _flyAreaPolygon
interactive: true
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
}
......@@ -51,6 +51,8 @@ QGCView {
readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
property bool _airspaceEnabled: QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
property var _wimaController: wimaController
property var _flyArea: wimaController.flyArea
property var _planMasterController: masterController
property var _missionController: _planMasterController.missionController
property var _geoFenceController: _planMasterController.geoFenceController
......@@ -197,6 +199,9 @@ QGCView {
message: qsTr("You need at least one item to create a KML.")
}
}
WimaController {
id:wimaController
}
PlanMasterController {
id: masterController
......@@ -511,7 +516,6 @@ QGCView {
// Add the mission item visuals to the map
Repeater {
model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
delegate: MissionItemMapVisual {
map: editorMap
qgcView: _qgcView
......@@ -525,6 +529,14 @@ QGCView {
model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
}
//Add fly area
FlyAreaMapVisual {
map: editorMap
qgcView: _qgcView
_flyAreaPolygon: _flyArea.flyAreaPolygon
}
// Add the vehicles to the map
MapItemView {
model: QGroundControl.multiVehicleManager.vehicles
......@@ -601,7 +613,7 @@ QGCView {
dropPanelComponent: syncDropPanel
},
{
name: qsTr("ROI"),
name: qsTr("Fly Area"),
iconSource: "/qmlimages/Target.svg",
toggle: true
},
......@@ -638,12 +650,13 @@ QGCView {
onClicked: {
switch (index) {
case 1:
addComplexItem(_missionController.complexMissionItemNames[2])
wimaController.initWimaFlyArea();
//addComplexItem(_missionController.complexMissionItemNames[2])
/*_addWaypointOnClick = checked
_addROIOnClick = false*/
break
case 2:
addComplexItem(_missionController.complexMissionItemNames[2])
/*
_addROIOnClick = checked
_addWaypointOnClick = false*/
......
/****************************************************************************
*
* (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
/// Survey Complex Mission Item visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var _flyAreaPolygon
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_structurePolygon.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)
_structurePolygon.appendVertex(topLeftCoord)
_structurePolygon.appendVertex(topRightCoord)
_structurePolygon.appendVertex(bottomRightCoord)
_structurePolygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
QGCMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _flyAreaPolygon
interactive: true
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
}
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