Newer
Older
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.ShapeFileHelper 1.0
import QGroundControl.Airspace 1.0
import QGroundControl.Airmap 1.0
Gus Grubba
committed
Item {
readonly property int _decimalPlaces: 8
readonly property real _margin: ScreenTools.defaultFontPixelHeight * 0.5
readonly property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
readonly property real _radius: ScreenTools.defaultFontPixelWidth * 0.5
readonly property real _rightPanelWidth: Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276)
readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
property bool _airspaceEnabled: QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
property var _missionController: _planMasterController.missionController
property var _geoFenceController: _planMasterController.geoFenceController
property var _rallyPointController: _planMasterController.rallyPointController
property var _visualItems: _missionController.visualItems
property bool _lightWidgetBorders: editorMap.isSatelliteMap
property bool _addWaypointOnClick: false
property bool _addROIOnClick: false
property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1
property int _editingLayer: layerTabBar.currentIndex ? _layers[layerTabBar.currentIndex] : _layerMission
property int _toolStripBottom: toolStrip.height + toolStrip.y
property var _appSettings: QGroundControl.settingsManager.appSettings
property var _planViewSettings: QGroundControl.settingsManager.planViewSettings
readonly property var _layers: [_layerMission, _layerGeoFence, _layerRallyPoints]
readonly property int _layerMission: 1
readonly property int _layerGeoFence: 2
readonly property int _layerRallyPoints: 3
readonly property string _armedVehicleUploadPrompt: qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
var coordinate = editorMap.center
coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
Gus Grubba
committed
function updateAirspace(reset) {
Gus Grubba
committed
if(_airspaceEnabled) {
var coordinateNW = editorMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */)
var coordinateSE = editorMap.toCoordinate(Qt.point(width,height), false /* clipToViewPort */)
if(coordinateNW.isValid && coordinateSE.isValid) {
Gus Grubba
committed
QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
Gus Grubba
committed
}
}
}
property bool _firstMissionLoadComplete: false
property bool _firstFenceLoadComplete: false
property bool _firstRallyLoadComplete: false
property bool _firstLoadComplete: false
id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware!
map: editorMap
usePlannedHomePosition: true
planMasterController: _planMasterController
on_AirspaceEnabledChanged: {
if(QGroundControl.airmapSupported) {
if(_airspaceEnabled) {
planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Gus Grubba
committed
updateAirspace(true)
} else {
planControlColapsed = false
}
if(visible) {
editorMap.zoomLevel = QGroundControl.flightMapZoom
editorMap.center = QGroundControl.flightMapPosition
if (!_planMasterController.containsItems) {
toolStrip.simulateClick(toolStrip.fileButtonIndex)
}
target: _appSettings ? _appSettings.defaultMissionItemAltitude : null
mainWindow.showComponentDialog(applyNewAltitude, qsTr("Apply new alititude"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
}
}
}
Component {
id: applyNewAltitude
QGCViewMessage {
message: qsTr("You have changed the default altitude for mission items. Would you like to apply that altitude to all the items in the current mission?")
function accept() {
hideDialog()
_missionController.applyDefaultMissionAltitude()
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
Component {
id: promptForPlanUsageOnVehicleChangePopupComponent
QGCPopupDialog {
title: _planMasterController.managerVehicle.isOfflineEditingVehicle ? qsTr("Plan View - Vehicle Disconnected") : qsTr("Plan View - Vehicle Changed")
buttons: StandardButton.NoButton
ColumnLayout {
QGCLabel {
Layout.maximumWidth: parent.width
wrapMode: QGCLabel.WordWrap
text: _planMasterController.managerVehicle.isOfflineEditingVehicle ?
qsTr("The vehicle associated with the plan in the Plan View is no longer available. What would you like to do with that plan?") :
qsTr("The plan being worked on in the Plan View is not from the current vehicle. What would you like to do with that plan?")
}
QGCButton {
Layout.fillWidth: true
text: _planMasterController.dirty ?
(_planMasterController.managerVehicle.isOfflineEditingVehicle ?
qsTr("Discard Unsaved Changes") :
qsTr("Discard Unsaved Changes, Load New Plan From Vehicle")) :
qsTr("Load New Plan From Vehicle")
onClicked: {
_planMasterController.showPlanFromManagerVehicle()
_promptForPlanUsageShowing = false
hideDialog();
}
}
QGCButton {
Layout.fillWidth: true
text: _planMasterController.managerVehicle.isOfflineEditingVehicle ?
qsTr("Keep Current Plan") :
qsTr("Keep Current Plan, Don't Update From Vehicle")
onClicked: {
if (!_planMasterController.managerVehicle.isOfflineEditingVehicle) {
_planMasterController.dirty = true
}
_promptForPlanUsageShowing = false
hideDialog()
}
}
}
}
}
id: firmwareOrVehicleMismatchUploadDialogComponent
QGCViewMessage {
message: qsTr("This Plan was created for a different firmware or vehicle type than the firmware/vehicle type of vehicle you are uploading to. " +
"This can lead to errors or incorrect behavior. " +
"It is recommended to recreate the Plan for the correct firmware/vehicle type.\n\n" +
"Click 'Ok' to upload the Plan anyway.")
function accept() {
_planMasterController.sendToVehicle()
hideDialog()
Loading
Loading full blame...