Newer
Older
/****************************************************************************
*
* (c) 2009-2016 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 _horizontalMargin: ScreenTools.defaultFontPixelWidth * 0.5
readonly property real _margin: ScreenTools.defaultFontPixelHeight * 0.5
readonly property real _radius: ScreenTools.defaultFontPixelWidth * 0.5
readonly property real _rightPanelWidth: Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
readonly property real _toolButtonTopMargin: ScreenTools.defaultFontPixelHeight * 0.5
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: _layerMission
property int _toolStripBottom: toolStrip.height + toolStrip.y
property var _appSettings: QGroundControl.settingsManager.appSettings
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?")
function addComplexItem(complexItemName) {
var coordinate = editorMap.center
coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
insertComplexMissionItem(complexItemName, coordinate, _missionController.visualItems.count)
}
function insertComplexMissionItem(complexItemName, coordinate, index) {
var sequenceNumber = _missionController.insertComplexMissionItem(complexItemName, coordinate, index)
_missionController.setCurrentPlanViewIndex(sequenceNumber, true)
function insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index) {
var sequenceNumber = _missionController.insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index)
_missionController.setCurrentPlanViewIndex(sequenceNumber, true)
}
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
}
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()
Component {
id: activeMissionUploadDialogComponent
QGCViewDialog {
Column {
anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Your vehicle is currently flying a mission. In order to upload a new or modified mission the current mission will be paused.")
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("After the mission is uploaded you can adjust the current waypoint and start the mission.")
}
QGCButton {
text: qsTr("Pause and Upload")
onClicked: {
}
}
}
}
}
target: QGroundControl.airspaceManager
onAirspaceVisibleChanged: {
planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Component {
id: noItemForKML
QGCViewMessage {
message: qsTr("You need at least one item to create a KML.")
}
}
_planMasterController.start(false /* flyView */)
_missionController.setCurrentPlanViewIndex(0, true)
mainWindow.planMasterControllerPlan = _planMasterController
Gus Grubba
committed
mainWindow.showMessageDialog(qsTr("Unable to Save/Upload"), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
if (!readyForSaveSend()) {
waitingOnDataMessage()
return
}
if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
mainWindow.showComponentDialog(activeMissionUploadDialogComponent, qsTr("Plan Upload"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
Loading
Loading full blame...