Unverified Commit 8ea8748f authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8043 from DonLakeFlyer/ContextualTools

Plan: More work on contextual Plan tools
parents 4f44cd18 ab9e64b8
...@@ -219,7 +219,7 @@ const MissionCommandUIInfo* MissionCommandTree::getUIInfo(Vehicle* vehicle, MAV_ ...@@ -219,7 +219,7 @@ const MissionCommandUIInfo* MissionCommandTree::getUIInfo(Vehicle* vehicle, MAV_
} }
} }
QVariantList MissionCommandTree::getCommandsForCategory(Vehicle* vehicle, const QString& category) QVariantList MissionCommandTree::getCommandsForCategory(Vehicle* vehicle, const QString& category, bool showFlyThroughCommands)
{ {
MAV_AUTOPILOT baseFirmwareType; MAV_AUTOPILOT baseFirmwareType;
MAV_TYPE baseVehicleType; MAV_TYPE baseVehicleType;
...@@ -237,7 +237,8 @@ QVariantList MissionCommandTree::getCommandsForCategory(Vehicle* vehicle, const ...@@ -237,7 +237,8 @@ QVariantList MissionCommandTree::getCommandsForCategory(Vehicle* vehicle, const
for (MAV_CMD command: commandMap.keys()) { for (MAV_CMD command: commandMap.keys()) {
if (supportedCommands.contains(command)) { if (supportedCommands.contains(command)) {
MissionCommandUIInfo* uiInfo = commandMap[command]; MissionCommandUIInfo* uiInfo = commandMap[command];
if (uiInfo->category() == category || category == _allCommandsCategory) { if ((uiInfo->category() == category || category == _allCommandsCategory) &&
(showFlyThroughCommands || !uiInfo->specifiesCoordinate() || uiInfo->isStandaloneCoordinate())) {
list.append(QVariant::fromValue(uiInfo)); list.append(QVariant::fromValue(uiInfo));
} }
} }
......
...@@ -62,7 +62,8 @@ public: ...@@ -62,7 +62,8 @@ public:
const MissionCommandUIInfo* getUIInfo(Vehicle* vehicle, MAV_CMD command); const MissionCommandUIInfo* getUIInfo(Vehicle* vehicle, MAV_CMD command);
Q_INVOKABLE QVariantList getCommandsForCategory(Vehicle* vehicle, const QString& category); /// @param showFlyThroughCommands - true: al commands shows, false: filter out commands which the vehicle flies through (specifiedCoordinate=true, standaloneCoordinate=false)
Q_INVOKABLE QVariantList getCommandsForCategory(Vehicle* vehicle, const QString& category, bool showFlyThroughCommands);
// Overrides from QGCTool // Overrides from QGCTool
virtual void setToolbox(QGCToolbox* toolbox); virtual void setToolbox(QGCToolbox* toolbox);
......
...@@ -2181,14 +2181,16 @@ VisualMissionItem* MissionController::currentPlanViewItem(void) const ...@@ -2181,14 +2181,16 @@ VisualMissionItem* MissionController::currentPlanViewItem(void) const
void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force) void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force)
{ {
if (_visualItems && (force || sequenceNumber != _currentPlanViewIndex)) { if (_visualItems && (force || sequenceNumber != _currentPlanViewIndex)) {
bool foundLand = false; bool foundLand = false;
int takeoffIndex = -1; int takeoffIndex = -1;
int landIndex = -1;
_splitSegment = nullptr; _splitSegment = nullptr;
_currentPlanViewItem = nullptr; _currentPlanViewItem = nullptr;
_currentPlanViewIndex = -1; _currentPlanViewIndex = -1;
_isInsertTakeoffValid = true; _isInsertTakeoffValid = true;
_isInsertLandValid = true; _isInsertLandValid = true;
_flyThroughCommandsAllowed = true;
for (int i = 0; i < _visualItems->count(); i++) { for (int i = 0; i < _visualItems->count(); i++) {
VisualMissionItem* pVI = qobject_cast<VisualMissionItem*>(_visualItems->get(i)); VisualMissionItem* pVI = qobject_cast<VisualMissionItem*>(_visualItems->get(i));
...@@ -2214,6 +2216,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force) ...@@ -2214,6 +2216,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force)
case MAV_CMD_DO_LAND_START: case MAV_CMD_DO_LAND_START:
case MAV_CMD_NAV_RETURN_TO_LAUNCH: case MAV_CMD_NAV_RETURN_TO_LAUNCH:
foundLand = true; foundLand = true;
landIndex = i;
break; break;
default: default:
break; break;
...@@ -2222,6 +2225,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force) ...@@ -2222,6 +2225,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force)
FixedWingLandingComplexItem* fwLanding = qobject_cast<FixedWingLandingComplexItem*>(pVI); FixedWingLandingComplexItem* fwLanding = qobject_cast<FixedWingLandingComplexItem*>(pVI);
if (fwLanding) { if (fwLanding) {
foundLand = true; foundLand = true;
landIndex = i;
} }
} }
} }
...@@ -2248,13 +2252,23 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force) ...@@ -2248,13 +2252,23 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force)
} }
} }
if (takeoffIndex != -1 && sequenceNumber <= takeoffIndex) { if (takeoffIndex != -1) {
// Takeoff item was found which means mission starts from ground. // Takeoff item was found which means mission starts from ground
// Land is only valid after the takeoff item. if (sequenceNumber < takeoffIndex) {
_isInsertLandValid = false; // Land is only valid after the takeoff item.
} else if (foundLand) { _isInsertLandValid = false;
// Can't have to land sequences // Fly through commands are not allowed prior to the takeoff command
_flyThroughCommandsAllowed = false;
}
}
if (foundLand) {
// Can't have more than one land sequence
_isInsertLandValid = false; _isInsertLandValid = false;
if (sequenceNumber >= landIndex) {
// Can't have fly through commands after a land item
_flyThroughCommandsAllowed = false;
}
} }
emit currentPlanViewIndexChanged(); emit currentPlanViewIndexChanged();
...@@ -2262,6 +2276,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force) ...@@ -2262,6 +2276,7 @@ void MissionController::setCurrentPlanViewIndex(int sequenceNumber, bool force)
emit splitSegmentChanged(); emit splitSegmentChanged();
emit isInsertTakeoffValidChanged(); emit isInsertTakeoffValidChanged();
emit isInsertLandValidChanged(); emit isInsertLandValidChanged();
emit flyThroughCommandsAllowedChanged();
} }
} }
......
...@@ -92,8 +92,9 @@ public: ...@@ -92,8 +92,9 @@ public:
Q_PROPERTY(QString surveyComplexItemName READ surveyComplexItemName CONSTANT) Q_PROPERTY(QString surveyComplexItemName READ surveyComplexItemName CONSTANT)
Q_PROPERTY(QString corridorScanComplexItemName READ corridorScanComplexItemName CONSTANT) Q_PROPERTY(QString corridorScanComplexItemName READ corridorScanComplexItemName CONSTANT)
Q_PROPERTY(QString structureScanComplexItemName READ structureScanComplexItemName CONSTANT) Q_PROPERTY(QString structureScanComplexItemName READ structureScanComplexItemName CONSTANT)
Q_PROPERTY(bool isInsertTakeoffValid MEMBER _isInsertTakeoffValid NOTIFY isInsertTakeoffValidChanged) ///< true: Takeoff tool should be enabled Q_PROPERTY(bool isInsertTakeoffValid MEMBER _isInsertTakeoffValid NOTIFY isInsertTakeoffValidChanged)
Q_PROPERTY(bool isInsertLandValid MEMBER _isInsertLandValid NOTIFY isInsertLandValidChanged) ///< true: Land tool should be enabled Q_PROPERTY(bool isInsertLandValid MEMBER _isInsertLandValid NOTIFY isInsertLandValidChanged)
Q_PROPERTY(bool flyThroughCommandsAllowed MEMBER _flyThroughCommandsAllowed NOTIFY flyThroughCommandsAllowedChanged)
Q_INVOKABLE void removeMissionItem(int index); Q_INVOKABLE void removeMissionItem(int index);
...@@ -228,32 +229,33 @@ public: ...@@ -228,32 +229,33 @@ public:
static const QString patternSurveyName; static const QString patternSurveyName;
signals: signals:
void visualItemsChanged (void); void visualItemsChanged (void);
void waypointPathChanged (void); void waypointPathChanged (void);
void splitSegmentChanged (void); void splitSegmentChanged (void);
void newItemsFromVehicle (void); void newItemsFromVehicle (void);
void missionDistanceChanged (double missionDistance); void missionDistanceChanged (double missionDistance);
void missionTimeChanged (void); void missionTimeChanged (void);
void missionHoverDistanceChanged (double missionHoverDistance); void missionHoverDistanceChanged (double missionHoverDistance);
void missionHoverTimeChanged (void); void missionHoverTimeChanged (void);
void missionCruiseDistanceChanged (double missionCruiseDistance); void missionCruiseDistanceChanged (double missionCruiseDistance);
void missionCruiseTimeChanged (void); void missionCruiseTimeChanged (void);
void missionMaxTelemetryChanged (double missionMaxTelemetry); void missionMaxTelemetryChanged (double missionMaxTelemetry);
void complexMissionItemNamesChanged (void); void complexMissionItemNamesChanged (void);
void resumeMissionIndexChanged (void); void resumeMissionIndexChanged (void);
void resumeMissionReady (void); void resumeMissionReady (void);
void resumeMissionUploadFail (void); void resumeMissionUploadFail (void);
void batteryChangePointChanged (int batteryChangePoint); void batteryChangePointChanged (int batteryChangePoint);
void batteriesRequiredChanged (int batteriesRequired); void batteriesRequiredChanged (int batteriesRequired);
void plannedHomePositionChanged (QGeoCoordinate plannedHomePosition); void plannedHomePositionChanged (QGeoCoordinate plannedHomePosition);
void progressPctChanged (double progressPct); void progressPctChanged (double progressPct);
void currentMissionIndexChanged (int currentMissionIndex); void currentMissionIndexChanged (int currentMissionIndex);
void currentPlanViewIndexChanged (void); void currentPlanViewIndexChanged (void);
void currentPlanViewItemChanged (void); void currentPlanViewItemChanged (void);
void missionBoundingCubeChanged (void); void missionBoundingCubeChanged (void);
void missionItemCountChanged (int missionItemCount); void missionItemCountChanged (int missionItemCount);
void isInsertTakeoffValidChanged (void); void isInsertTakeoffValidChanged (void);
void isInsertLandValidChanged (void); void isInsertLandValidChanged (void);
void flyThroughCommandsAllowedChanged (void);
private slots: private slots:
void _newMissionItemsAvailableFromVehicle(bool removeAllRequested); void _newMissionItemsAvailableFromVehicle(bool removeAllRequested);
...@@ -330,8 +332,9 @@ private: ...@@ -330,8 +332,9 @@ private:
QGCGeoBoundingCube _travelBoundingCube; QGCGeoBoundingCube _travelBoundingCube;
QGeoCoordinate _takeoffCoordinate; QGeoCoordinate _takeoffCoordinate;
CoordinateVector* _splitSegment; CoordinateVector* _splitSegment;
bool _isInsertTakeoffValid = true; bool _isInsertTakeoffValid = true;
bool _isInsertLandValid = true; bool _isInsertLandValid = true;
bool _flyThroughCommandsAllowed = true;
static const char* _settingsGroup; static const char* _settingsGroup;
......
...@@ -399,6 +399,7 @@ QString SimpleMissionItem::abbreviation() const ...@@ -399,6 +399,7 @@ QString SimpleMissionItem::abbreviation() const
case MAV_CMD_NAV_VTOL_LAND: case MAV_CMD_NAV_VTOL_LAND:
return tr("VTOL Land"); return tr("VTOL Land");
case MAV_CMD_DO_SET_ROI: case MAV_CMD_DO_SET_ROI:
case MAV_CMD_DO_SET_ROI_LOCATION:
return tr("ROI"); return tr("ROI");
default: default:
return QString(); return QString();
......
...@@ -240,8 +240,9 @@ Rectangle { ...@@ -240,8 +240,9 @@ Rectangle {
id: commandDialog id: commandDialog
MissionCommandDialog { MissionCommandDialog {
missionItem: _root.missionItem missionItem: _root.missionItem
map: _root.map map: _root.map
flyThroughCommandsAllowed: _missionController.flyThroughCommandsAllowed
} }
} }
......
...@@ -304,10 +304,8 @@ Item { ...@@ -304,10 +304,8 @@ Item {
/// @param coordinate Location to insert item /// @param coordinate Location to insert item
/// @param index Insert item at this index /// @param index Insert item at this index
function insertROIMissionItem(coordinate, index) { function insertROIMissionItem(coordinate, index) {
var sequenceNumber = _missionController.insertROIMissionItem(coordinate, index) _missionController.insertROIMissionItem(coordinate, index, true /* makeCurrentItem */)
_missionController.setCurrentPlanViewIndex(sequenceNumber, true)
_addROIOnClick = false _addROIOnClick = false
toolStrip.lastClickedButton.checked = false
} }
function selectNextNotReady() { function selectNextNotReady() {
...@@ -491,6 +489,7 @@ Item { ...@@ -491,6 +489,7 @@ Item {
_addROIOnClick = false _addROIOnClick = false
insertROIMissionItem(coordinate, _missionController.visualItems.count) insertROIMissionItem(coordinate, _missionController.visualItems.count)
} }
break break
case _layerRallyPoints: case _layerRallyPoints:
if (_rallyPointController.supported && _addWaypointOnClick) { if (_rallyPointController.supported && _addWaypointOnClick) {
...@@ -632,7 +631,8 @@ Item { ...@@ -632,7 +631,8 @@ Item {
readonly property int landButtonIndex: 6 readonly property int landButtonIndex: 6
readonly property int centerButtonIndex: 7 readonly property int centerButtonIndex: 7
property bool _isRally: _editingLayer == _layerRallyPoints property bool _isRallyLayer: _editingLayer == _layerRallyPoints
property bool _isMissionLayer: _editingLayer == _layerMission
model: [ model: [
{ {
...@@ -654,13 +654,13 @@ Item { ...@@ -654,13 +654,13 @@ Item {
name: qsTr("Takeoff"), name: qsTr("Takeoff"),
iconSource: "/res/takeoff.svg", iconSource: "/res/takeoff.svg",
buttonEnabled: _missionController.isInsertTakeoffValid, buttonEnabled: _missionController.isInsertTakeoffValid,
buttonVisible: _editingLayer == _layerMission buttonVisible: _isMissionLayer
}, },
{ {
name: _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"), name: _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
iconSource: "/qmlimages/MapAddMission.svg", iconSource: "/qmlimages/MapAddMission.svg",
buttonEnabled: true, buttonEnabled: _isRallyLayer ? true : _missionController.flyThroughCommandsAllowed,
buttonVisible: true, buttonVisible: _isRallyLayer || _isMissionLayer,
toggle: true, toggle: true,
checked: _addWaypointOnClick checked: _addWaypointOnClick
}, },
...@@ -668,21 +668,21 @@ Item { ...@@ -668,21 +668,21 @@ Item {
name: qsTr("ROI"), name: qsTr("ROI"),
iconSource: "/qmlimages/MapAddMission.svg", iconSource: "/qmlimages/MapAddMission.svg",
buttonEnabled: true, buttonEnabled: true,
buttonVisible: !_isRally && _waypointsOnlyMode, buttonVisible: _isMissionLayer,
toggle: true toggle: true
}, },
{ {
name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"), name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
iconSource: "/qmlimages/MapDrawShape.svg", iconSource: "/qmlimages/MapDrawShape.svg",
buttonEnabled: true, buttonEnabled: _missionController.flyThroughCommandsAllowed,
buttonVisible: !_isRally, buttonVisible: _isMissionLayer,
dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
}, },
{ {
name: _planMasterController.controllerVehicle.fixedWing ? qsTr("Land") : qsTr("Return"), name: _planMasterController.controllerVehicle.fixedWing ? qsTr("Land") : qsTr("Return"),
iconSource: "/res/rtl.svg", iconSource: "/res/rtl.svg",
buttonEnabled: _missionController.isInsertLandValid, buttonEnabled: _missionController.isInsertLandValid,
buttonVisible: _editingLayer == _layerMission buttonVisible: _isMissionLayer
}, },
{ {
name: qsTr("Center"), name: qsTr("Center"),
...@@ -693,39 +693,49 @@ Item { ...@@ -693,39 +693,49 @@ Item {
} }
] ]
function allAddClickBoolsOff() {
_addROIOnClick = false
_addWaypointOnClick = false
}
onClicked: { onClicked: {
switch (index) { switch (index) {
case flyButtonIndex: case flyButtonIndex:
mainWindow.showFlyView() mainWindow.showFlyView()
break break
case takeoffButtonIndex: case takeoffButtonIndex:
allAddClickBoolsOff()
_missionController.insertTakeoffItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */) _missionController.insertTakeoffItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */)
break break
case waypointButtonIndex: case waypointButtonIndex:
if(_addWaypointOnClick) { if (_addWaypointOnClick) {
//-- Toggle it off allAddClickBoolsOff()
_addWaypointOnClick = false
_addROIOnClick = false
setChecked(index, false) setChecked(index, false)
} else { } else {
allAddClickBoolsOff()
_addWaypointOnClick = checked _addWaypointOnClick = checked
_addROIOnClick = false
} }
break break
case roiButtonIndex: case roiButtonIndex:
allAddClickBoolsOff()
_addROIOnClick = checked _addROIOnClick = checked
_addWaypointOnClick = false
break break
case patternButtonIndex: case patternButtonIndex:
allAddClickBoolsOff()
if (_singleComplexItem) { if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0]) addComplexItem(_missionController.complexMissionItemNames[0])
} }
break break
case landButtonIndex: case landButtonIndex:
allAddClickBoolsOff()
_missionController.insertLandItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */) _missionController.insertLandItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */)
break break
} }
} }
onDropped: {
allAddClickBoolsOff()
}
} }
//----------------------------------------------------------- //-----------------------------------------------------------
...@@ -1257,8 +1267,6 @@ Item { ...@@ -1257,8 +1267,6 @@ Item {
} }
} }
} }
} }
} }
} }
...@@ -19,8 +19,9 @@ import QGroundControl.Palette 1.0 ...@@ -19,8 +19,9 @@ import QGroundControl.Palette 1.0
QGCViewDialog { QGCViewDialog {
id: root id: root
property var missionItem property var missionItem
property var map property var map
property bool flyThroughCommandsAllowed
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle
...@@ -40,7 +41,7 @@ QGCViewDialog { ...@@ -40,7 +41,7 @@ QGCViewDialog {
model: QGroundControl.missionCommandTree.categoriesForVehicle(_vehicle) model: QGroundControl.missionCommandTree.categoriesForVehicle(_vehicle)
function categorySelected(category) { function categorySelected(category) {
commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(_vehicle, category) commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(_vehicle, category, flyThroughCommandsAllowed)
} }
Component.onCompleted: { Component.onCompleted: {
...@@ -97,7 +98,7 @@ QGCViewDialog { ...@@ -97,7 +98,7 @@ QGCViewDialog {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
missionItem.setMapCenterHintForCommandChange(map.center) missionItem.setMapCenterHintForCommandChange(map.center)
missionItem.command = mavCmdInfo.command missionItem.command = mavCmdInfo.command
root.reject() root.reject()
} }
......
...@@ -36,6 +36,7 @@ Rectangle { ...@@ -36,6 +36,7 @@ Rectangle {
property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 8) + toolStripColumn.anchors.margins * 2 property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 8) + toolStripColumn.anchors.margins * 2
signal clicked(int index, bool checked) signal clicked(int index, bool checked)
signal dropped(int index)
function setChecked(idx, check) { function setChecked(idx, check) {
repeater.itemAt(idx).checked = check repeater.itemAt(idx).checked = check
...@@ -88,6 +89,7 @@ Rectangle { ...@@ -88,6 +89,7 @@ Rectangle {
} else if (checked) { } else if (checked) {
var panelEdgeTopPoint = mapToItem(_root, width, 0) var panelEdgeTopPoint = mapToItem(_root, width, 0)
dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent) dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent)
_root.dropped(index)
} }
if(_root && buttonTemplate) if(_root && buttonTemplate)
_root.lastClickedButton = buttonTemplate _root.lastClickedButton = buttonTemplate
......
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