Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
<file alias="QGroundControl/Controls/TakeoffItemMapVisual.qml">../src/PlanView/TakeoffItemMapVisual.qml</file>
<file alias="QGroundControl/Controls/ToolIndicatorPage.qml">../src/QmlControls/ToolIndicatorPage.qml</file>
<file alias="QGroundControl/Controls/ToolStrip.qml">../src/QmlControls/ToolStrip.qml</file>
<file alias="QGroundControl/Controls/ToolStripDropPanel.qml">../src/QmlControls/ToolStripDropPanel.qml</file>
<file alias="QGroundControl/Controls/ToolStripHoverButton.qml">../src/QmlControls/ToolStripHoverButton.qml</file>
<file alias="QGroundControl/Controls/TransectStyleComplexItemEditor.qml">../src/PlanView/TransectStyleComplexItemEditor.qml</file>
<file alias="QGroundControl/Controls/TransectStyleComplexItemStats.qml">../src/PlanView/TransectStyleComplexItemStats.qml</file>
Expand Down
1 change: 1 addition & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
<file alias="QGroundControl/Controls/TakeoffItemMapVisual.qml">src/PlanView/TakeoffItemMapVisual.qml</file>
<file alias="QGroundControl/Controls/ToolIndicatorPage.qml">src/QmlControls/ToolIndicatorPage.qml</file>
<file alias="QGroundControl/Controls/ToolStrip.qml">src/QmlControls/ToolStrip.qml</file>
<file alias="QGroundControl/Controls/ToolStripDropPanel.qml">src/QmlControls/ToolStripDropPanel.qml</file>
<file alias="QGroundControl/Controls/ToolStripHoverButton.qml">src/QmlControls/ToolStripHoverButton.qml</file>
<file alias="QGroundControl/Controls/TransectStyleComplexItemEditor.qml">src/PlanView/TransectStyleComplexItemEditor.qml</file>
<file alias="QGroundControl/Controls/TransectStyleComplexItemStats.qml">src/PlanView/TransectStyleComplexItemStats.qml</file>
Expand Down
267 changes: 115 additions & 152 deletions src/FlightDisplay/FlyViewMap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,12 @@ FlightMap {
MouseArea {
anchors.fill: parent
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()
position = Qt.point(position.x, position.y)
var clickCoord = _root.toCoordinate(position, false /* clipToViewPort */)
// For some strange reason using mainWindow in mapToItem doesn't work, so we use globals.parent instead which also gets us mainWindow
position = mapToItem(globals.parent, position)
var dropPanel = roiEditDropPanelComponent.createObject(mainWindow, { clickRect: Qt.rect(position.x, position.y, 0, 0) })
dropPanel.open()
}
}

Expand Down Expand Up @@ -542,185 +544,146 @@ FlightMap {
}

Component {
id: popupMenuComponent

Popup {
id: mapClickMenu
modal: true

property var coord
property var contentItemComponent

function setPosition(mouseX, mouseY) {
var newX = mouseX
var newY = mouseY

// Filtering coordinates
if (newX + mapClickMenu.width > _root.width) {
newX = _root.width - mapClickMenu.width
}
if (newY + mapClickMenu.height > _root.height) {
newY = _root.height - mapClickMenu.height
}

// Set coordiantes
x = newX
y = newY
}

background: Rectangle {
radius: ScreenTools.defaultFontPixelHeight * 0.5
color: qgcPal.window
border.color: qgcPal.text
}

contentItem: Loader {
sourceComponent: contentItemComponent
id: roiEditPositionDialogComponent

property var mapClickCoord: mapClickMenu.coord
property var popup: mapClickMenu
EditPositionDialog {
title: qsTr("Edit ROI Position")
coordinate: roiLocationItem.coordinate
onCoordinateChanged: {
roiLocationItem.coordinate = coordinate
_activeVehicle.guidedModeROI(coordinate)
}
}
}

Component {
id: mapClickMenuComponent

ColumnLayout {
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()
id: roiEditDropPanelComponent

DropPanel {
id: roiEditDropPanel

sourceComponent: Component {
ColumnLayout {
spacing: ScreenTools.defaultFontPixelWidth / 2

QGCButton {
Layout.fillWidth: true
text: qsTr("Cancel ROI")
onClicked: {
_activeVehicle.stopGuidedModeROI()
roiEditDropPanel.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()
QGCButton {
Layout.fillWidth: true
text: qsTr("Edit Position")
onClicked: {
roiEditPositionDialogComponent.createObject(mainWindow, { showSetPositionFromVehicle: false }).open()
roiEditDropPanel.close()
}
}
orbitMapCircle.show(mapClickCoord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionOrbit, mapClickCoord, orbitMapCircle)
}
}
}
}

QGCButton {
Layout.fillWidth: true
text: qsTr("ROI at location")
visible: globals.guidedControllerFlyView.showROI
onClicked: {
if (popup.opened) {
popup.close()
Component {
id: mapClickDropPanelComponent

DropPanel {
id: mapClickDropPanel

property var mapClickCoord

sourceComponent: Component {
ColumnLayout {
spacing: ScreenTools.defaultFontPixelWidth / 2

QGCButton {
Layout.fillWidth: true
text: qsTr("Go to location")
visible: globals.guidedControllerFlyView.showGotoLocation
onClicked: {
mapClickDropPanel.close()
gotoLocationItem.show(mapClickCoord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionGoto, mapClickCoord, gotoLocationItem)
}
}
globals.guidedControllerFlyView.executeAction(globals.guidedControllerFlyView.actionROI, mapClickCoord, 0, false)
}
}

QGCButton {
Layout.fillWidth: true
text: qsTr("Set home here")
visible: globals.guidedControllerFlyView.showSetHome
onClicked: {
if (popup.opened) {
popup.close()
QGCButton {
Layout.fillWidth: true
text: qsTr("Orbit at location")
visible: globals.guidedControllerFlyView.showOrbit
onClicked: {
mapClickDropPanel.close()
orbitMapCircle.show(mapClickCoord)
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionOrbit, mapClickCoord, orbitMapCircle)
}
}
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetHome, mapClickCoord)
}
}

QGCButton {
Layout.fillWidth: true
text: qsTr("Set Estimator Origin")
visible: globals.guidedControllerFlyView.showSetEstimatorOrigin
onClicked: {
if (popup.opened) {
popup.close()
QGCButton {
Layout.fillWidth: true
text: qsTr("ROI at location")
visible: globals.guidedControllerFlyView.showROI
onClicked: {
mapClickDropPanel.close()
globals.guidedControllerFlyView.executeAction(globals.guidedControllerFlyView.actionROI, mapClickCoord, 0, false)
}
}
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetEstimatorOrigin, mapClickCoord)
}
}

QGCButton {
Layout.fillWidth: true
text: qsTr("Set Heading")
visible: globals.guidedControllerFlyView.showChangeHeading
onClicked: {
if (popup.opened) {
popup.close()
QGCButton {
Layout.fillWidth: true
text: qsTr("Set home here")
visible: globals.guidedControllerFlyView.showSetHome
onClicked: {
mapClickDropPanel.close()
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetHome, mapClickCoord)
}
}
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionChangeHeading, mapClickCoord)
}
}

ColumnLayout {
spacing: 0
QGCLabel { text: qsTr("Lat: %1").arg(mapClickCoord.latitude.toFixed(6)) }
QGCLabel { text: qsTr("Lon: %1").arg(mapClickCoord.longitude.toFixed(6)) }
}
}
}

Component {
id: roiEditPositionDialogComponent

EditPositionDialog {
title: qsTr("Edit ROI Position")
coordinate: roiLocationItem.coordinate
onCoordinateChanged: {
roiLocationItem.coordinate = coordinate
_activeVehicle.guidedModeROI(coordinate)
}
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Set Estimator Origin")
visible: globals.guidedControllerFlyView.showSetEstimatorOrigin
onClicked: {
mapClickDropPanel.close()
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionSetEstimatorOrigin, mapClickCoord)
}
}

Component {
id: roiEditMenuComponent

ColumnLayout {
id: mainLayout
spacing: ScreenTools.defaultFontPixelWidth / 2

QGCButton {
Layout.fillWidth: true
text: qsTr("Cancel ROI")
onClicked: {
_activeVehicle.stopGuidedModeROI()
popup.close()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Set Heading")
visible: globals.guidedControllerFlyView.showChangeHeading
onClicked: {
mapClickDropPanel.close()
globals.guidedControllerFlyView.confirmAction(globals.guidedControllerFlyView.actionChangeHeading, mapClickCoord)
}
}

QGCButton {
Layout.fillWidth: true
text: qsTr("Edit Position")
onClicked: {
roiEditPositionDialogComponent.createObject(mainWindow, { showSetPositionFromVehicle: false }).open()
popup.close()
ColumnLayout {
spacing: 0
QGCLabel { text: qsTr("Lat: %1").arg(mapClickCoord.latitude.toFixed(6)) }
QGCLabel { text: qsTr("Lon: %1").arg(mapClickCoord.longitude.toFixed(6)) }
}
}
}
}
}

onMapClicked: (position) => {
if (!globals.guidedControllerFlyView.guidedUIVisible &&
(globals.guidedControllerFlyView.showGotoLocation || globals.guidedControllerFlyView.showOrbit || globals.guidedControllerFlyView.showROI || globals.guidedControllerFlyView.showSetHome || globals.guidedControllerFlyView.showSetEstimatorOrigin)) {
(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()

position = Qt.point(position.x, position.y)
var clickCoord = _root.toCoordinate(position, false /* clipToViewPort */)
// For some strange reason using mainWindow in mapToItem doesn't work, so we use globals.parent instead which also gets us mainWindow
position = _root.mapToItem(globals.parent, position)
var dropPanel = mapClickDropPanelComponent.createObject(mainWindow, { mapClickCoord: clickCoord, clickRect: Qt.rect(position.x, position.y, 0, 0) })
dropPanel.open()
}
}

Expand Down
Loading
Loading