Unverified Commit 09b28319 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5841 from DonLakeFlyer/WaypointsOnlyROI

Support ROI tool button in WaypointsOnly mode
parents dce6c6aa 19c5257e
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
"id": 21, "id": 21,
"comment": "MAV_CMD_NAV_LAND", "comment": "MAV_CMD_NAV_LAND",
"paramRemove": "1" "paramRemove": "1"
},
{
"id": 201,
"comment": "MAV_CMD_DO_SET_ROI",
"paramRemove": "1,2,3"
} }
] ]
} }
...@@ -655,7 +655,7 @@ ...@@ -655,7 +655,7 @@
{ {
"id": 201, "id": 201,
"rawName": "MAV_CMD_DO_SET_ROI", "rawName": "MAV_CMD_DO_SET_ROI",
"friendlyName": "Region of interest (cmd)" , "friendlyName": "Region of interest" ,
"description": "Sets the region of interest for cameras.", "description": "Sets the region of interest for cameras.",
"specifiesCoordinate": true, "specifiesCoordinate": true,
"standaloneCoordinate": true, "standaloneCoordinate": true,
......
...@@ -359,6 +359,30 @@ int MissionController::insertSimpleMissionItem(QGeoCoordinate coordinate, int i) ...@@ -359,6 +359,30 @@ int MissionController::insertSimpleMissionItem(QGeoCoordinate coordinate, int i)
return newItem->sequenceNumber(); return newItem->sequenceNumber();
} }
int MissionController::insertROIMissionItem(QGeoCoordinate coordinate, int i)
{
int sequenceNumber = _nextSequenceNumber();
SimpleMissionItem * newItem = new SimpleMissionItem(_controllerVehicle, this);
newItem->setSequenceNumber(sequenceNumber);
newItem->setCoordinate(coordinate);
newItem->setCommand(MavlinkQmlSingleton::MAV_CMD_DO_SET_ROI);
_initVisualItem(newItem);
newItem->setDefaultsForCommand();
double prevAltitude;
MAV_FRAME prevFrame;
if (_findPreviousAltitude(i, &prevAltitude, &prevFrame)) {
newItem->missionItem().setFrame(prevFrame);
newItem->missionItem().setParam7(prevAltitude);
}
_visualItems->insert(i, newItem);
_recalcAll();
return newItem->sequenceNumber();
}
int MissionController::insertComplexMissionItem(QString itemName, QGeoCoordinate mapCenterCoordinate, int i) int MissionController::insertComplexMissionItem(QString itemName, QGeoCoordinate mapCenterCoordinate, int i)
{ {
ComplexMissionItem* newItem; ComplexMissionItem* newItem;
......
...@@ -95,6 +95,11 @@ public: ...@@ -95,6 +95,11 @@ public:
/// @return Sequence number for new item /// @return Sequence number for new item
Q_INVOKABLE int insertSimpleMissionItem(QGeoCoordinate coordinate, int i); Q_INVOKABLE int insertSimpleMissionItem(QGeoCoordinate coordinate, int i);
/// Add a new ROI mission item to the list
/// @param i: index to insert at
/// @return Sequence number for new item
Q_INVOKABLE int insertROIMissionItem(QGeoCoordinate coordinate, int i);
/// Add a new complex mission item to the list /// Add a new complex mission item to the list
/// @param itemName: Name of complex item to create (from complexMissionItemNames) /// @param itemName: Name of complex item to create (from complexMissionItemNames)
/// @param mapCenterCoordinate: coordinate for current center of map /// @param mapCenterCoordinate: coordinate for current center of map
......
...@@ -349,19 +349,21 @@ QString SimpleMissionItem::commandName(void) const ...@@ -349,19 +349,21 @@ QString SimpleMissionItem::commandName(void) const
QString SimpleMissionItem::abbreviation() const QString SimpleMissionItem::abbreviation() const
{ {
if (homePosition()) if (homePosition())
return QStringLiteral("H"); return tr("H");
switch(command()) { switch(command()) {
default:
return QString();
case MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF: case MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF:
return QStringLiteral("Takeoff"); return tr("Takeoff");
case MavlinkQmlSingleton::MAV_CMD_NAV_LAND: case MavlinkQmlSingleton::MAV_CMD_NAV_LAND:
return QStringLiteral("Land"); return tr("Land");
case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_TAKEOFF: case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_TAKEOFF:
return QStringLiteral("VTOL Takeoff"); return tr("VTOL Takeoff");
case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_LAND: case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_LAND:
return QStringLiteral("VTOL Land"); return tr("VTOL Land");
case MavlinkQmlSingleton::MAV_CMD_DO_SET_ROI:
return tr("ROI");
default:
return QString();
} }
} }
......
...@@ -39,6 +39,7 @@ QGCView { ...@@ -39,6 +39,7 @@ QGCView {
readonly property real _rightPanelWidth: Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30) readonly property real _rightPanelWidth: Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
readonly property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2) readonly property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2)
readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276) readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276)
readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
property var _planMasterController: masterController property var _planMasterController: masterController
property var _missionController: _planMasterController.missionController property var _missionController: _planMasterController.missionController
...@@ -47,6 +48,7 @@ QGCView { ...@@ -47,6 +48,7 @@ QGCView {
property var _visualItems: _missionController.visualItems property var _visualItems: _missionController.visualItems
property bool _lightWidgetBorders: editorMap.isSatelliteMap property bool _lightWidgetBorders: editorMap.isSatelliteMap
property bool _addWaypointOnClick: false property bool _addWaypointOnClick: false
property bool _addROIOnClick: false
property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1 property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1
property real _toolbarHeight: _qgcView.height - ScreenTools.availableHeight property real _toolbarHeight: _qgcView.height - ScreenTools.availableHeight
property int _editingLayer: _layerMission property int _editingLayer: _layerMission
...@@ -219,6 +221,16 @@ QGCView { ...@@ -219,6 +221,16 @@ QGCView {
_missionController.setCurrentPlanViewIndex(sequenceNumber, true) _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
} }
/// Inserts a new ROI mission item
/// @param coordinate Location to insert item
/// @param index Insert item at this index
function insertROIMissionItem(coordinate, index) {
var sequenceNumber = _missionController.insertROIMissionItem(coordinate, index)
_missionController.setCurrentPlanViewIndex(sequenceNumber, true)
_addROIOnClick = false
toolStrip.uncheckAll()
}
property int _moveDialogMissionItemIndex property int _moveDialogMissionItemIndex
QGCFileDialog { QGCFileDialog {
...@@ -329,6 +341,9 @@ QGCView { ...@@ -329,6 +341,9 @@ QGCView {
case _layerMission: case _layerMission:
if (_addWaypointOnClick) { if (_addWaypointOnClick) {
insertSimpleMissionItem(coordinate, _missionController.visualItems.count) insertSimpleMissionItem(coordinate, _missionController.visualItems.count)
} else if (_addROIOnClick) {
_addROIOnClick = false
insertROIMissionItem(coordinate, _missionController.visualItems.count)
} }
break break
case _layerRallyPoints: case _layerRallyPoints:
...@@ -394,11 +409,11 @@ QGCView { ...@@ -394,11 +409,11 @@ QGCView {
color: qgcPal.window color: qgcPal.window
title: qsTr("Plan") title: qsTr("Plan")
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
showAlternateIcon: [ false, false, masterController.dirty, false, false, false ] showAlternateIcon: [ false, false, false, masterController.dirty, false, false, false ]
rotateImage: [ false, false, masterController.syncInProgress, false, false, false ] rotateImage: [ false, false, false, masterController.syncInProgress, false, false, false ]
animateImage: [ false, false, masterController.dirty, false, false, false ] animateImage: [ false, false, false, masterController.dirty, false, false, false ]
buttonEnabled: [ true, true, !masterController.syncInProgress, true, true, true ] buttonEnabled: [ true, true, true, !masterController.syncInProgress, true, true, true ]
buttonVisible: [ true, true, true, true, _showZoom, _showZoom ] buttonVisible: [ true, _waypointsOnlyMode, true, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile property bool _showZoom: !ScreenTools.isMobile
...@@ -409,6 +424,11 @@ QGCView { ...@@ -409,6 +424,11 @@ QGCView {
iconSource: "/qmlimages/MapAddMission.svg", iconSource: "/qmlimages/MapAddMission.svg",
toggle: true toggle: true
}, },
{
name: "ROI",
iconSource: "/qmlimages/MapAddMission.svg",
toggle: true
},
{ {
name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : "Pattern", name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : "Pattern",
iconSource: "/qmlimages/MapDrawShape.svg", iconSource: "/qmlimages/MapDrawShape.svg",
...@@ -439,16 +459,21 @@ QGCView { ...@@ -439,16 +459,21 @@ QGCView {
switch (index) { switch (index) {
case 0: case 0:
_addWaypointOnClick = checked _addWaypointOnClick = checked
_addROIOnClick = false
break break
case 1: case 1:
_addROIOnClick = checked
_addWaypointOnClick = false
break
case 2:
if (_singleComplexItem) { if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0]) addComplexItem(_missionController.complexMissionItemNames[0])
} }
break break
case 4: case 5:
editorMap.zoomLevel += 0.5 editorMap.zoomLevel += 0.5
break break
case 5: case 6:
editorMap.zoomLevel -= 0.5 editorMap.zoomLevel -= 0.5
break break
} }
......
...@@ -84,7 +84,6 @@ void QGCPositionManager::setPositionSource(QGCPositionManager::QGCPositionSource ...@@ -84,7 +84,6 @@ void QGCPositionManager::setPositionSource(QGCPositionManager::QGCPositionSource
_currentSource->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods); _currentSource->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
_currentSource->setUpdateInterval(_updateInterval); _currentSource->setUpdateInterval(_updateInterval);
connect(_currentSource, &QGeoPositionInfoSource::positionUpdated, this, &QGCPositionManager::_positionUpdated); connect(_currentSource, &QGeoPositionInfoSource::positionUpdated, this, &QGCPositionManager::_positionUpdated);
connect(_currentSource, &QGeoPositionInfoSource::updateTimeout, this, &QGCPositionManager::_updateTimeout);
connect(_currentSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(_error(QGeoPositionInfoSource::Error))); connect(_currentSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(_error(QGeoPositionInfoSource::Error)));
_currentSource->startUpdates(); _currentSource->startUpdates();
} }
...@@ -94,8 +93,3 @@ void QGCPositionManager::_error(QGeoPositionInfoSource::Error positioningError) ...@@ -94,8 +93,3 @@ void QGCPositionManager::_error(QGeoPositionInfoSource::Error positioningError)
{ {
qWarning() << "QGCPositionManager error" << positioningError; qWarning() << "QGCPositionManager error" << positioningError;
} }
void QGCPositionManager::_updateTimeout(void)
{
qWarning() << "QGCPositionManager updateTimeout";
}
...@@ -39,7 +39,6 @@ public: ...@@ -39,7 +39,6 @@ public:
private slots: private slots:
void _positionUpdated(const QGeoPositionInfo &update); void _positionUpdated(const QGeoPositionInfo &update);
void _error(QGeoPositionInfoSource::Error positioningError); void _error(QGeoPositionInfoSource::Error positioningError);
void _updateTimeout(void);
signals: signals:
void lastPositionUpdated(bool valid, QVariant lastPosition); void lastPositionUpdated(bool valid, QVariant lastPosition);
......
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