Commit ddf64f6f authored by Valentin Platzgummer's avatar Valentin Platzgummer

last commit for today

parent e7ee7d09
......@@ -210,7 +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/FlightMap/FlyAreaMapVisual.qml">src/WimaView/FlyAreaMapVisual.qml</file>
<file alias="QGroundControl/Controls/FlyAreaPolygonMapVisual.qml">src/WimaView/FlyAreaPolygonMapVisual.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
......@@ -32,6 +32,7 @@ Item {
property real interiorOpacity: 1
property int borderWidth: 0
property color borderColor: "black"
property bool initPolygon: false
property var _polygonComponent
property var _dragHandlesComponent
......@@ -80,17 +81,17 @@ Item {
/// Calculate the default/initial 4 sided polygon
function defaultPolygonVertices() {
// 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)
var rect = Qt.rect(mapControl.centerViewport.x, mapControl.centerViewport.y, mapControl.centerViewport.width, mapControl.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 */)
var centerCoord = mapControl.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = mapControl.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = mapControl.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = mapControl.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = mapControl.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Initial polygon has max width and height of 3000 meters
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), 3000) / 2
......@@ -106,7 +107,7 @@ Item {
/// Add an initial 4 sided polygon
function addInitialPolygon() {
if (mapPolygon.count < 3) {
initialVertices = defaultPolygonVertices()
var initialVertices = defaultPolygonVertices()
mapPolygon.appendVertex(initialVertices[0])
mapPolygon.appendVertex(initialVertices[1])
mapPolygon.appendVertex(initialVertices[2])
......@@ -158,6 +159,10 @@ Item {
}
Component.onCompleted: {
if(initPolygon){
addInitialPolygon()
}
addVisuals()
if (interactive) {
addHandles()
......
......@@ -20,6 +20,7 @@ public:
//Property Accessors
WimaFlyArea *flyArea (void) { return _flyArea; }
//QmlObjectListModel* visualItems (void) { return _visualItems; }
QString QMLView
Q_INVOKABLE void start(void);
......
......@@ -83,3 +83,4 @@ ToolStrip 1.0 ToolStrip.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml
FlyAreaPolygonMapVisual 1.0 FlyAreaPolygonMapVisual.qml
/****************************************************************************
*
* (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
}
}
......@@ -18,7 +18,7 @@ import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Survey Complex Mission Item visuals
/// Fly Area visuals
Item {
id: _root
......@@ -31,7 +31,7 @@ Item {
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_structurePolygon.count < 3) {
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
......@@ -54,10 +54,10 @@ Item {
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)
_flyAreaPolygon.appendVertex(topLeftCoord)
_flyAreaPolygon.appendVertex(topRightCoord)
_flyAreaPolygon.appendVertex(bottomRightCoord)
_flyAreaPolygon.appendVertex(bottomLeftCoord)
}
}
......
......@@ -539,19 +539,11 @@ QGCView {
//Add fly area
Repeater {
model: _flyArea.polygons
delegate: QGCMapPolygonVisuals {
qgcView: _qgcView ///< QGCView for popping dialogs
mapControl: editorMap ///< Map control to place item in
mapPolygon: object
interiorColor: "green"
interiorOpacity: 1
borderWidth: 1
borderColor: "white"
Component.onCompleted: {
addInitialPolygon()
}
model: _flyArea.polygons
delegate: FlyAreaPolygonMapVisual {
map: editorMap ///< Map control to place item in
qgcView: _qgcView ///< QGCView to use for popping dialogs
_flyAreaPolygon: object
}
onItemAdded: {
......
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