Browse Source

Add ROI editing menu

* Supports Cancel ROI, and Edit Position
* Created reusable popup menu control
QGC4.4
Don Gagne 1 year ago committed by Julian Oes
parent
commit
3c39c108b0
No known key found for this signature in database
GPG Key ID: F0ED380FEA56DE41
  1. 193
      src/FlightDisplay/FlyViewMap.qml

193
src/FlightDisplay/FlyViewMap.qml

@ -499,7 +499,13 @@ FlightMap {
checked: true checked: true
index: -1 index: -1
label: qsTr("ROI here", "Make this a Region Of Interest") label: qsTr("ROI here", "Make this a Region Of Interest")
onClicked: _activeVehicle.stopGuidedModeROI()
onClicked: (position) => {
var roiEditMenu = popupMenuComponent.createObject(_root, { coord: roiLocationItem.coordinate, contentItemComponent: roiEditMenuComponent })
var clickPoint = mapToItem(_root, position.x, position.y)
roiEditMenu.setPosition(clickPoint.x, clickPoint.y)
roiEditMenu.open()
}
} }
//-- Visibilty controlled by actual state //-- Visibilty controlled by actual state
@ -530,27 +536,26 @@ FlightMap {
} }
} }
Component {
// Handle guided mode clicks id: popupMenuComponent
MouseArea {
anchors.fill: parent
Popup { Popup {
id: clickMenu id: mapClickMenu
modal: true modal: true
property var coord property var coord
property var contentItemComponent
function setCoordinates(mouseX, mouseY) { function setPosition(mouseX, mouseY) {
var newX = mouseX var newX = mouseX
var newY = mouseY var newY = mouseY
// Filtering coordinates // Filtering coordinates
if (newX + clickMenu.width > _root.width) { if (newX + mapClickMenu.width > _root.width) {
newX = _root.width - clickMenu.width newX = _root.width - mapClickMenu.width
} }
if (newY + clickMenu.height > _root.height) { if (newY + mapClickMenu.height > _root.height) {
newY = _root.height - clickMenu.height newY = _root.height - mapClickMenu.height
} }
// Set coordiantes // Set coordiantes
@ -564,75 +569,139 @@ FlightMap {
border.color: qgcPal.text border.color: qgcPal.text
} }
ColumnLayout { contentItem: Loader {
id: mainLayout sourceComponent: contentItemComponent
spacing: ScreenTools.defaultFontPixelWidth / 2
property var mapClickCoord: mapClickMenu.coord
QGCButton { property var popup: mapClickMenu
Layout.fillWidth: true }
text: "Go to location" }
visible: globals.guidedControllerFlyView.showGotoLocation }
onClicked: {
if (clickMenu.opened) { Component {
clickMenu.close() id: mapClickMenuComponent
}
gotoLocationItem.show(clickMenu.coord) ColumnLayout {
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionGoto, clickMenu.coord, gotoLocationItem) id: mainLayout
spacing: ScreenTools.defaultFontPixelWidth / 2
QGCButton {
Layout.fillWidth: true
text: qsTr("Go to location")
visible: globals.guidedControllerFlyView.showGotoLocation
onClicked: {
if (popup.opened) {
popup.close()
}
gotoLocationItem.show(mapClickCoord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionGoto, mapClickCoord, gotoLocationItem)
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Orbit at location")
visible: globals.guidedControllerFlyView.showOrbit
onClicked: {
if (popup.opened) {
popup.close()
} }
orbitMapCircle.show(mapClickCoord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionOrbit, mapClickCoord, orbitMapCircle)
} }
}
QGCButton { QGCButton {
Layout.fillWidth: true Layout.fillWidth: true
text: "Orbit at location" text: qsTr("ROI at location")
visible: globals.guidedControllerFlyView.showOrbit visible: globals.guidedControllerFlyView.showROI
onClicked: { onClicked: {
if (clickMenu.opened) { if (popup.opened) {
clickMenu.close() popup.close()
}
orbitMapCircle.show(clickMenu.coord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionOrbit, clickMenu.coord, orbitMapCircle)
} }
roiLocationItem.show(mapClickCoord)
globals.guidedControllerFlyView.executeAction(globals.guidedControllerFlyView.actionROI, mapClickCoord, 0, false)
} }
}
QGCButton { QGCButton {
Layout.fillWidth: true Layout.fillWidth: true
text: "ROI at location" text: qsTr("Set home here")
visible: globals.guidedControllerFlyView.showROI visible: globals.guidedControllerFlyView.showSetHome
onClicked: { onClicked: {
if (clickMenu.opened) { if (popup.opened) {
clickMenu.close() popup.close()
}
roiLocationItem.show(clickMenu.coord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionROI, clickMenu.coord, roiLocationItem)
} }
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetHome, mapClickCoord)
} }
}
QGCButton { QGCButton {
Layout.fillWidth: true Layout.fillWidth: true
text: "Set home here" text: qsTr("Set Estimator Origin")
visible: globals.guidedControllerFlyView.showSetHome visible: globals.guidedControllerFlyView.showSetEstimatorOrigin
onClicked: { onClicked: {
if (clickMenu.opened) { if (popup.opened) {
clickMenu.close() popup.close()
}
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetHome, clickMenu.coord)
} }
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetEstimatorOrigin, mapClickCoord)
} }
} }
} }
}
Component {
id: roiEditPositionDialogComponent
EditPositionDialog {
title: qsTr("Edit ROI Position")
coordinate: roiLocationItem.coordinate
onCoordinateChanged: {
roiLocationItem.coordinate = coordinate
_activeVehicle.guidedModeROI(coordinate)
}
}
}
Component {
id: roiEditMenuComponent
onClicked: { ColumnLayout {
if (!globals.guidedControllerFlyView.guidedUIVisible && (globals.guidedControllerFlyView.showGotoLocation || globals.guidedControllerFlyView.showOrbit || globals.guidedControllerFlyView.showROI || globals.guidedControllerFlyView.showSetHome)) { id: mainLayout
orbitMapCircle.hide() spacing: ScreenTools.defaultFontPixelWidth / 2
gotoLocationItem.hide()
var clickCoord = _root.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */) QGCButton {
clickMenu.coord = clickCoord Layout.fillWidth: true
clickMenu.setCoordinates(mouse.x, mouse.y) text: qsTr("Cancel ROI")
clickMenu.open() onClicked: {
_activeVehicle.stopGuidedModeROI()
popup.close()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Edit Position")
onClicked: {
roiEditPositionDialogComponent.createObject(mainWindow, { showSetPositionFromVehicle: false }).open()
popup.close()
}
} }
} }
} }
onMapClicked: (position) => {
if (!globals.guidedControllerFlyView.guidedUIVisible &&
(globals.guidedControllerFlyView.showGotoLocation || globals.guidedControllerFlyView.showOrbit || globals.guidedControllerFlyView.showROI || globals.guidedControllerFlyView.showSetHome || globals.guidedControllerFlyView.showSetEstimatorOrigin)) {
orbitMapCircle.hide()
gotoLocationItem.hide()
var clickCoord = _root.toCoordinate(Qt.point(position.x, position.y), false /* clipToViewPort */)
var mapClickMenu = popupMenuComponent.createObject(_root, { coord: clickCoord, contentItemComponent: mapClickMenuComponent })
mapClickMenu.setPosition(position.x, position.y)
mapClickMenu.open()
}
}
MapScale { MapScale {
id: mapScale id: mapScale
anchors.margins: _toolsMargin anchors.margins: _toolsMargin

Loading…
Cancel
Save