Skip to content

Commit

Permalink
Merge pull request mavlink#2871 from DonLakeFlyer/SimpleComplex
Browse files Browse the repository at this point in the history
Rearchitecture of Simple/Complex mission item concept
  • Loading branch information
DonLakeFlyer committed Feb 24, 2016
2 parents 2862588 + 10c7e17 commit 36d5774
Show file tree
Hide file tree
Showing 37 changed files with 2,532 additions and 1,342 deletions.
4 changes: 4 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ HEADERS += \
src/MissionManager/MissionManager.h \
src/MissionManager/ComplexMissionItem.h \
src/MissionManager/SimpleMissionItem.h \
src/MissionManager/VisualMissionItem.h \
src/QGC.h \
src/QGCApplication.h \
src/QGCComboBox.h \
Expand Down Expand Up @@ -392,6 +393,7 @@ SOURCES += \
src/MissionManager/MissionManager.cc \
src/MissionManager/ComplexMissionItem.cc \
src/MissionManager/SimpleMissionItem.cc \
src/MissionManager/VisualMissionItem.cc \
src/QGC.cc \
src/QGCApplication.cc \
src/QGCComboBox.cc \
Expand Down Expand Up @@ -508,6 +510,7 @@ HEADERS += \
src/MissionManager/MissionControllerManagerTest.h \
src/MissionManager/MissionItemTest.h \
src/MissionManager/MissionManagerTest.h \
src/MissionManager/SimpleMissionItemTest.h \
src/qgcunittest/GeoTest.h \
src/qgcunittest/FileDialogTest.h \
src/qgcunittest/FileManagerTest.h \
Expand All @@ -531,6 +534,7 @@ SOURCES += \
src/MissionManager/MissionControllerManagerTest.cc \
src/MissionManager/MissionItemTest.cc \
src/MissionManager/MissionManagerTest.cc \
src/MissionManager/SimpleMissionItemTest.cc \
src/qgcunittest/GeoTest.cc \
src/qgcunittest/FileDialogTest.cc \
src/qgcunittest/FileManagerTest.cc \
Expand Down
10 changes: 8 additions & 2 deletions src/FirmwarePlugin/APM/MavCmdInfoCommon.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
"category": "Basic",
"param1": {
"label": "Pitch:",
"units": "radians",
"default": 0.26179939,
"units": "degrees",
"default": 15,
"decimalPlaces": 2
},
"param7": {
"label": "Altitude:",
"units": "meters",
"default": 25.0,
"decimalPlaces": 2
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/FirmwarePlugin/APM/MavCmdInfoMultiRotor.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"description": "Take off from the ground.",
"specifiesCoordinate": false,
"friendlyEdit": true,
"category": "Basic"
"category": "Basic",
"param7": {
"label": "Altitude:",
"units": "meters",
"default": 25.0,
"decimalPlaces": 2
}
},
{
"id": 17,
Expand Down
2 changes: 1 addition & 1 deletion src/FlightDisplay/FlightDisplayViewMap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ FlightMap {

// Add the mission items to the map
MissionItemView {
model: _mainIsMap ? _missionController.missionItems : 0
model: _mainIsMap ? _missionController.visualItems : 0
}

// Add lines between waypoints
Expand Down
7 changes: 5 additions & 2 deletions src/FlightMap/MapItems/MissionItemIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ MapQuickItem {
sourceItem:
MissionItemIndexLabel {
id: _label
isCurrentItem: missionItem.isCurrentItem
label: missionItem.sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
isCurrentItem: _isCurrentItem
label: _sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
onClicked: _item.clicked()

property bool _isCurrentItem: missionItem ? missionItem.isCurrentItem : false
property bool _sequenceNumber: missionItem ? missionItem.sequenceNumber : 0
}
}
9 changes: 8 additions & 1 deletion src/JsonHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ bool JsonHelper::toQGeoCoordinate(const QJsonValue& jsonValue, QGeoCoordinate& c
QJsonArray coordinateArray = jsonValue.toArray();
int requiredCount = altitudeRequired ? 3 : 2;
if (coordinateArray.count() != requiredCount) {
errorString = QString("Json array must contains %1 values").arg(requiredCount);
errorString = QString("Coordinate array must contain %1 values").arg(requiredCount);
return false;
}

foreach(const QJsonValue& jsonValue, coordinateArray) {
if (jsonValue.type() != QJsonValue::Double) {
errorString = QString("Coordinate array may only contain double values, found: %1").arg(jsonValue.type());
return false;
}
}

coordinate = QGeoCoordinate(coordinateArray[0].toDouble(), coordinateArray[1].toDouble());
if (altitudeRequired) {
coordinate.setAltitude(coordinateArray[2].toDouble());
Expand Down
60 changes: 30 additions & 30 deletions src/MissionEditor/MissionEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import QGroundControl.Controllers 1.0
QGCView {
id: _root

property bool syncNeeded: controller.missionItems.dirty // Unsaved changes, visible to parent container
property bool syncNeeded: controller.visualItems.dirty // Unsaved changes, visible to parent container

viewPanel: panel
topDialogMargin: height - mainWindow.availableHeight
Expand All @@ -60,13 +60,11 @@ QGCView {
readonly property int _addMissionItemsButtonAutoOffTimeout: 10000
readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276)

property var _missionItems: controller.missionItems
property var _visualItems: controller.visualItems
property var _currentMissionItem
property bool _firstVehiclePosition: true
property var activeVehiclePosition: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()

property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false

onActiveVehiclePositionChanged: updateMapToVehiclePosition()

Connections {
Expand Down Expand Up @@ -119,19 +117,19 @@ QGCView {

/// Fix the map viewport to the current mission items.
function fitViewportToMissionItems() {
if (_missionItems.count == 1) {
editorMap.center = _missionItems.get(0).coordinate
if (_visualItems.count == 1) {
editorMap.center = _visualItems.get(0).coordinate
} else {
var missionItem = _missionItems.get(0)
var missionItem = _visualItems.get(0)
var north = normalizeLat(missionItem.coordinate.latitude)
var south = north
var east = normalizeLon(missionItem.coordinate.longitude)
var west = east

for (var i=1; i<_missionItems.count; i++) {
missionItem = _missionItems.get(i)
for (var i=1; i<_visualItems.count; i++) {
missionItem = _visualItems.get(i)

if (missionItem.specifiesCoordinate && !missionItem.standaloneCoordinate) {
if (missionItem.specifiesCoordinate && !missionItem.isStandaloneCoordinate) {
var lat = normalizeLat(missionItem.coordinate.latitude)
var lon = normalizeLon(missionItem.coordinate.longitude)

Expand Down Expand Up @@ -161,7 +159,7 @@ QGCView {
onAutoSyncChanged: QGroundControl.flightMapSettings.saveMapSetting(editorMap.mapName, _autoSyncKey, autoSync)
*/

onMissionItemsChanged: itemDragger.clearItem()
onVisualItemsChanged: itemDragger.clearItem()
onNewItemsFromVehicle: fitViewportToMissionItems()
}

Expand All @@ -177,12 +175,12 @@ QGCView {

function setCurrentItem(index) {
_currentMissionItem = undefined
for (var i=0; i<_missionItems.count; i++) {
for (var i=0; i<_visualItems.count; i++) {
if (i == index) {
_currentMissionItem = _missionItems.get(i)
_currentMissionItem = _visualItems.get(i)
_currentMissionItem.isCurrentItem = true
} else {
_missionItems.get(i).isCurrentItem = false
_visualItems.get(i).isCurrentItem = false
}
}
}
Expand Down Expand Up @@ -266,7 +264,7 @@ QGCView {

QGCComboBox {
id: toCombo
model: _missionItems.count
model: _visualItems.count
currentIndex: _moveDialogMissionItemIndex
}
}
Expand Down Expand Up @@ -308,7 +306,7 @@ QGCView {
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
if (addMissionItemsButton.checked) {
var index = controller.insertSimpleMissionItem(coordinate, controller.missionItems.count)
var index = controller.insertSimpleMissionItem(coordinate, controller.visualItems.count)
setCurrentItem(index)
} else {
editorMap.mapClicked(coordinate)
Expand Down Expand Up @@ -368,7 +366,7 @@ QGCView {

// Add the simple mission items to the map
MapItemView {
model: controller.missionItems
model: controller.visualItems
delegate: missionItemComponent
}

Expand Down Expand Up @@ -399,8 +397,8 @@ QGCView {
Connections {
target: object

onIsCurrentItemChanged: updateItemIndicator()
onCommandChanged: updateItemIndicator()
onIsCurrentItemChanged: updateItemIndicator()
onSpecifiesCoordinateChanged: updateItemIndicator()
}

// These are the non-coordinate child mission items attached to this item
Expand All @@ -425,7 +423,7 @@ QGCView {

// Add the complex mission items to the map
MapItemView {
model: controller.complexMissionItems
model: controller.complexVisualItems
delegate: polygonItemComponent
}

Expand Down Expand Up @@ -480,10 +478,10 @@ QGCView {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: Math.min(contentHeight, parent.height)
height: parent.height
spacing: _margin / 2
orientation: ListView.Vertical
model: controller.missionItems
model: controller.visualItems
cacheBuffer: height * 2

delegate: MissionItemEditor {
Expand All @@ -504,7 +502,7 @@ QGCView {
setCurrentItem(i)
}

onMoveHomeToMapCenter: controller.missionItems.get(0).coordinate = editorMap.center
onMoveHomeToMapCenter: controller.visualItems.get(0).coordinate = editorMap.center
}
} // ListView
} // Item - Mission Item editor
Expand Down Expand Up @@ -551,7 +549,7 @@ QGCView {
coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
var index = controller.insertComplexMissionItem(coordinate, controller.missionItems.count)
var index = controller.insertComplexMissionItem(coordinate, controller.visualItems.count)
setCurrentItem(index)
checked = false
}
Expand All @@ -565,8 +563,8 @@ QGCView {
exclusiveGroup: _dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
dropDownComponent: syncDropDownComponent
enabled: !_syncInProgress
rotateImage: _syncInProgress
enabled: !controller.syncInProgress
rotateImage: controller.syncInProgress
}

DropButton {
Expand All @@ -589,7 +587,7 @@ QGCView {

onClicked: {
centerMapButton.hideDropDown()
editorMap.center = controller.missionItems.get(0).coordinate
editorMap.center = controller.visualItems.get(0).coordinate
}
}

Expand Down Expand Up @@ -688,7 +686,7 @@ QGCView {
anchors.bottom: parent.bottom
z: QGroundControl.zOrderTopMost
currentMissionItem: _currentMissionItem
missionItems: controller.missionItems
missionItems: controller.visualItems
expandedWidth: missionItemEditor.x - (ScreenTools.defaultFontPixelWidth * 2)
}
} // FlightMap
Expand Down Expand Up @@ -758,7 +756,7 @@ QGCView {

QGCButton {
text: "Send to vehicle"
enabled: _activeVehicle && !_activeVehicle.missionManager.inProgress
enabled: !controller.syncInProgress

onClicked: {
syncButton.hideDropDown()
Expand All @@ -768,7 +766,7 @@ QGCView {

QGCButton {
text: "Load from vehicle"
enabled: _activeVehicle && !_activeVehicle.missionManager.inProgress
enabled: !controller.syncInProgress

onClicked: {
syncButton.hideDropDown()
Expand All @@ -786,6 +784,7 @@ QGCView {

QGCButton {
text: "Save to file..."
enabled: !controller.syncInProgress

onClicked: {
syncButton.hideDropDown()
Expand All @@ -795,6 +794,7 @@ QGCView {

QGCButton {
text: "Load from file..."
enabled: !controller.syncInProgress

onClicked: {
syncButton.hideDropDown()
Expand Down
2 changes: 1 addition & 1 deletion src/MissionEditor/MissionItemStatus.qml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Rectangle {
Item {
height: graphRow.height
width: ScreenTools.smallFontPixelWidth * 2
visible: object.specifiesCoordinate && !object.standaloneCoordinate
visible: object.specifiesCoordinate && !object.isStandaloneCoordinate


property real availableHeight: height - ScreenTools.smallFontPixelHeight - indicator.height
Expand Down
Loading

0 comments on commit 36d5774

Please sign in to comment.