Commit f27fbb7c authored by Don Gagne's avatar Don Gagne

parent b397e0be
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file> <file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
<file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file> <file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
<file alias="QGroundControl/Controls/QGCComboBox.qml">src/QmlControls/QGCComboBox.qml</file> <file alias="QGroundControl/Controls/QGCComboBox.qml">src/QmlControls/QGCComboBox.qml</file>
<file alias="QGroundControl/Controls/QGCDynamicObjectManager.qml">src/QmlControls/QGCDynamicObjectManager.qml</file>
<file alias="QGroundControl/Controls/QGCFileDialog.qml">src/QmlControls/QGCFileDialog.qml</file> <file alias="QGroundControl/Controls/QGCFileDialog.qml">src/QmlControls/QGCFileDialog.qml</file>
<file alias="QGroundControl/Controls/QGCFlickable.qml">src/QmlControls/QGCFlickable.qml</file> <file alias="QGroundControl/Controls/QGCFlickable.qml">src/QmlControls/QGCFlickable.qml</file>
<file alias="QGroundControl/Controls/QGCFlickableHorizontalIndicator.qml">src/QmlControls/QGCFlickableHorizontalIndicator.qml</file> <file alias="QGroundControl/Controls/QGCFlickableHorizontalIndicator.qml">src/QmlControls/QGCFlickableHorizontalIndicator.qml</file>
......
...@@ -30,7 +30,6 @@ Item { ...@@ -30,7 +30,6 @@ Item {
readonly property real _landingLengthMeters: 100 readonly property real _landingLengthMeters: 100
property var _missionItem: object property var _missionItem: object
property var _itemVisuals: [ ]
property var _mouseArea property var _mouseArea
property var _dragAreas: [ ] property var _dragAreas: [ ]
property var _flightPath property var _flightPath
...@@ -39,30 +38,16 @@ Item { ...@@ -39,30 +38,16 @@ Item {
property var _landingPointObject property var _landingPointObject
function hideItemVisuals() { function hideItemVisuals() {
for (var i=0; i<_itemVisuals.length; i++) { objMgr.destroyObjects()
_itemVisuals[i].destroy()
}
_itemVisuals = [ ]
} }
function showItemVisuals() { function showItemVisuals() {
if (_itemVisuals.length === 0) { if (objMgr.rgDynamicObjects.length === 0) {
var itemVisual = loiterPointComponent.createObject(map) _loiterPointObject = objMgr.createObject(loiterPointComponent, map, true /* parentObjectIsMap */)
map.addMapItem(itemVisual) _landingPointObject = objMgr.createObject(landingPointComponent, map, true /* parentObjectIsMap */)
_itemVisuals.push(itemVisual)
_loiterPointObject = itemVisual
itemVisual = landingPointComponent.createObject(map)
map.addMapItem(itemVisual)
_itemVisuals.push(itemVisual)
_landingPointObject = itemVisual
var rgComponents = [ flightPathComponent, loiterRadiusComponent, landingAreaComponent, landingAreaLabelComponent, glideSlopeComponent, glideSlopeLabelComponent ] var rgComponents = [ flightPathComponent, loiterRadiusComponent, landingAreaComponent, landingAreaLabelComponent, glideSlopeComponent, glideSlopeLabelComponent ]
for (var i=0; i<rgComponents.length; i++) { objMgr.createObjects(rgComponents, map, true /* parentObjectIsMap */)
var obj = rgComponents[i].createObject(map)
_itemVisuals.push(obj)
map.addMapItem(obj)
}
} }
} }
...@@ -98,6 +83,10 @@ Item { ...@@ -98,6 +83,10 @@ Item {
_flightPath = [ _missionItem.loiterTangentCoordinate, _missionItem.landingCoordinate ] _flightPath = [ _missionItem.loiterTangentCoordinate, _missionItem.landingCoordinate ]
} }
QGCDynamicObjectManager {
id: objMgr
}
Component.onCompleted: { Component.onCompleted: {
if (_missionItem.landingCoordSet) { if (_missionItem.landingCoordSet) {
showItemVisuals() showItemVisuals()
......
...@@ -27,21 +27,15 @@ Item { ...@@ -27,21 +27,15 @@ Item {
property var _missionItem: object property var _missionItem: object
property var _structurePolygon: object.structurePolygon property var _structurePolygon: object.structurePolygon
property var _flightPolygon: object.flightPolygon property var _flightPolygon: object.flightPolygon
property var _entryCoordinate
property var _exitCoordinate
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
function _addVisualElements() { function _addVisualElements() {
_entryCoordinate = entryPointComponent.createObject(map) objMgr.createObjects([entryPointComponent, exitPointComponent], map, true /* parentObjectIsMap */)
_exitCoordinate = exitPointComponent.createObject(map)
map.addMapItem(_entryCoordinate)
map.addMapItem(_exitCoordinate)
} }
function _destroyVisualElements() { function _destroyVisualElements() {
_entryCoordinate.destroy() objMgr.destroyObjects()
_exitCoordinate.destroy()
} }
/// Add an initial 4 sided polygon if there is none /// Add an initial 4 sided polygon if there is none
...@@ -85,6 +79,10 @@ Item { ...@@ -85,6 +79,10 @@ Item {
_destroyVisualElements() _destroyVisualElements()
} }
QGCDynamicObjectManager {
id: objMgr
}
QGCMapPolygonVisuals { QGCMapPolygonVisuals {
mapControl: map mapControl: map
mapPolygon: _structurePolygon mapPolygon: _structurePolygon
......
...@@ -39,24 +39,17 @@ Item { ...@@ -39,24 +39,17 @@ Item {
property var _exitTransectsComponent: null property var _exitTransectsComponent: null
property var _entryCoordinate property var _entryCoordinate
property var _exitCoordinate property var _exitCoordinate
property var _dynamicComponents: [ ]
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
function _addVisualElements() { function _addVisualElements() {
var toAdd = [ fullTransectsComponent, entryTransectComponent, exitTransectComponent, entryPointComponent, exitPointComponent, var toAdd = [ fullTransectsComponent, entryTransectComponent, exitTransectComponent, entryPointComponent, exitPointComponent,
entryArrow1Component, entryArrow2Component, exitArrow1Component, exitArrow2Component ] entryArrow1Component, entryArrow2Component, exitArrow1Component, exitArrow2Component ]
for (var i=0; i<toAdd.length; i++) { objMgr.createObjects(toAdd, map, true /* parentObjectIsMap */)
_dynamicComponents.push(toAdd[i].createObject(map))
map.addMapItem(_dynamicComponents[_dynamicComponents.length -1])
}
} }
function _destroyVisualElements() { function _destroyVisualElements() {
for (var i=0; i<_dynamicComponents.length; i++) { objMgr.destroyObjects()
_dynamicComponents[i].destroy()
}
_dynamicComponents = [ ]
} }
Component.onCompleted: { Component.onCompleted: {
...@@ -67,6 +60,10 @@ Item { ...@@ -67,6 +60,10 @@ Item {
_destroyVisualElements() _destroyVisualElements()
} }
QGCDynamicObjectManager {
id: objMgr
}
// Area polygon // Area polygon
QGCMapPolygonVisuals { QGCMapPolygonVisuals {
id: mapPolygonVisuals id: mapPolygonVisuals
......
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
/// Provides a standard set of tools for dynamically create/adding/removing Qml objects
Item {
visible: false
property var rgDynamicObjects: [ ]
function createObject(sourceComponent, parentObject, parentObjectIsMap) {
var obj = sourceComponent.createObject(parentObject)
rgDynamicObjects.push(obj)
if (arguments.length < 3) {
parentObjectIsMap = false
}
if (parentObjectIsMap) {
map.addMapItem(obj)
}
return obj
}
function createObjects(rgSourceComponents, parentObject, parentObjectIsMap) {
if (arguments.length < 3) {
parentObjectIsMap = false
}
for (var i=0; i<rgSourceComponents.length; i++) {
createObject(rgSourceComponents[i], parentObject, parentObjectIsMap)
}
}
function destroyObjects() {
for (var i=0; i<rgDynamicObjects.length; i++) {
rgDynamicObjects[i].destroy()
}
rgDynamicObjects = [ ]
}
}
...@@ -42,6 +42,7 @@ QGCButton 1.0 QGCButton.qml ...@@ -42,6 +42,7 @@ QGCButton 1.0 QGCButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml QGCCheckBox 1.0 QGCCheckBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml QGCColoredImage 1.0 QGCColoredImage.qml
QGCComboBox 1.0 QGCComboBox.qml QGCComboBox 1.0 QGCComboBox.qml
QGCDynamicObjectManager 1.0 QGCDynamicObjectManager.qml
QGCFileDialog 1.0 QGCFileDialog.qml QGCFileDialog 1.0 QGCFileDialog.qml
QGCFlickable 1.0 QGCFlickable.qml QGCFlickable 1.0 QGCFlickable.qml
QGCGroupBox 1.0 QGCGroupBox.qml QGCGroupBox 1.0 QGCGroupBox.qml
......
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