Commit 15517ff3 authored by Gus Grubba's avatar Gus Grubba
Browse files

Merge branch 'master' of https://github.com/mavlink/qgroundcontrol into Airmap

# Conflicts:
#	src/FlightDisplay/FlightDisplayViewWidgets.qml
#	src/PlanView/MissionItemEditor.qml
#	src/PlanView/RallyPointItemEditor.qml
#	src/QmlControls/QGCButton.qml
#	src/api/QGCOptions.h
parents 7f89c8eb 5957f29e
......@@ -185,9 +185,11 @@ Item {
// Called when an action is about to be executed in order to confirm
function confirmAction(actionCode, actionData) {
var showImmediate = true
closeAll()
confirmDialog.action = actionCode
confirmDialog.actionData = actionData
confirmDialog.hideTrigger = true
_actionData = actionData
switch (actionCode) {
case actionArm:
......@@ -219,6 +221,7 @@ Item {
altitudeSlider.visible = true
break;
case actionStartMission:
showImmediate = false
confirmDialog.title = startMissionTitle
confirmDialog.message = startMissionMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showStartMission })
......@@ -229,11 +232,13 @@ Item {
confirmDialog.hideTrigger = true
break;
case actionContinueMission:
showImmediate = false
confirmDialog.title = continueMissionTitle
confirmDialog.message = continueMissionMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showContinueMission })
break;
case actionResumeMission:
showImmediate = false
confirmDialog.title = resumeMissionTitle
confirmDialog.message = resumeMissionMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showResumeMission })
......@@ -308,11 +313,13 @@ Item {
console.warn("Unknown actionCode", actionCode)
return
}
confirmDialog.visible = true
confirmDialog.show(showImmediate)
}
// Executes the specified action
function executeAction(actionCode, actionData) {
var i;
var rgVehicle;
switch (actionCode) {
case actionRTL:
_activeVehicle.guidedModeRTL()
......@@ -336,10 +343,9 @@ Item {
_activeVehicle.startMission()
break
case actionMVStartMission:
var rgVehicle = QGroundControl.multiVehicleManager.vehicles
for (var i=0; i<rgVehicle.count; i++) {
var vehicle = rgVehicle.get(i)
vehicle.startMission()
rgVehicle = QGroundControl.multiVehicleManager.vehicles
for (i = 0; i < rgVehicle.count; i++) {
rgVehicle.get(i).startMission()
}
break
case actionArm:
......@@ -370,10 +376,9 @@ Item {
_activeVehicle.pauseVehicle()
break
case actionMVPause:
var rgVehicle = QGroundControl.multiVehicleManager.vehicles
for (var i=0; i<rgVehicle.count; i++) {
var vehicle = rgVehicle.get(i)
vehicle.pauseVehicle()
rgVehicle = QGroundControl.multiVehicleManager.vehicles
for (i = 0; i < rgVehicle.count; i++) {
rgVehicle.get(i).pauseVehicle()
}
break
case actionVtolTransitionToFwdFlight:
......
......@@ -28,7 +28,7 @@ Item {
QGCPalette { id: qgcPal }
NoMouseThroughRectangle {
Rectangle {
id: mvCommands
anchors.left: parent.left
anchors.right: parent.right
......@@ -37,6 +37,10 @@ Item {
opacity: _rectOpacity
radius: _margin
DeadMouseArea {
anchors.fill: parent
}
Column {
id: mvCommandsColumn
anchors.margins: _margin
......@@ -152,7 +156,7 @@ Item {
QGCButton {
text: "Start Mission"
visible: _vehicle.armed && _vehicle.flightMode != _vehicle.missionFlightMode
visible: _vehicle.armed && _vehicle.flightMode !== _vehicle.missionFlightMode
onClicked: _vehicle.startMission()
}
......@@ -164,13 +168,13 @@ Item {
QGCButton {
text: "RTL"
visible: _vehicle.armed && _vehicle.flightMode != _vehicle.rtlFlightMode
visible: _vehicle.armed && _vehicle.flightMode !== _vehicle.rtlFlightMode
onClicked: _vehicle.flightMode = _vehicle.rtlFlightMode
}
QGCButton {
text: "Take control"
visible: _vehicle.armed && _vehicle.flightMode != _vehicle.takeControlFlightMode
visible: _vehicle.armed && _vehicle.flightMode !== _vehicle.takeControlFlightMode
onClicked: _vehicle.flightMode = _vehicle.takeControlFlightMode
}
} // Row
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 288 288" enable-background="new 0 0 288 288" xml:space="preserve">
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="143.999" y1="36.793" x2="143.999" y2="18.793"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="171.739" y1="40.458" x2="176.398" y2="23.072"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="197.586" y1="51.179" x2="206.586" y2="35.591"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="219.777" y1="68.224" x2="232.505" y2="55.496"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="236.801" y1="90.432" x2="252.389" y2="81.432"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="116.254" y1="40.431" x2="111.596" y2="23.045"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="90.397" y1="51.127" x2="81.397" y2="35.539"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="68.189" y1="68.151" x2="55.461" y2="55.423"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="51.144" y1="90.342" x2="35.556" y2="81.342"/>
<rect x="135" y="270" fill="none" width="18" height="18"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 288 288" style="enable-background:new 0 0 288 288;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FFFFFF;stroke-width:4;}
.st1{fill:none;stroke:#FFFFFF;stroke-miterlimit:10;}
</style>
<g id="Layer_2">
<line class="st0" x1="144" y1="45.8" x2="144" y2="18.8"/>
<line class="st0" x1="171.7" y1="40.5" x2="176.4" y2="23.1"/>
<line class="st0" x1="197.6" y1="51.2" x2="206.6" y2="35.6"/>
<line class="st0" x1="219.8" y1="68.2" x2="232.5" y2="55.5"/>
<line class="st0" x1="236.8" y1="90.4" x2="252.4" y2="81.4"/>
<line class="st0" x1="116.3" y1="40.4" x2="111.6" y2="23"/>
<line class="st0" x1="90.4" y1="51.1" x2="81.4" y2="35.5"/>
<line class="st0" x1="68.2" y1="68.2" x2="55.5" y2="55.4"/>
<line class="st0" x1="51.1" y1="90.3" x2="35.6" y2="81.3"/>
<rect x="135" y="270" class="st1" width="18" height="18"/>
</g>
<g id="Layer_3">
</g>
</svg>
......@@ -29,9 +29,9 @@ Item {
Component.onCompleted: {
var controlUrl = object.url
if (controlUrl != "") {
if (controlUrl !== "") {
var component = Qt.createComponent(controlUrl);
if (component.status == Component.Ready) {
if (component.status === Component.Ready) {
_customObject = component.createObject(map, { "customMapObject": object })
if (_customObject) {
map.addMapItem(_customObject)
......
......@@ -233,7 +233,7 @@ Item {
var clickCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
var polygonPath = _newPolygon.path
if (polygonPath.length == 0) {
if (polygonPath.length === 0) {
// Add first coordinate
polygonPath.push(clickCoordinate)
} else {
......@@ -252,10 +252,10 @@ Item {
_currentPolygon.path = polygonPath
_newPolygon.path = polygonPath
if (_mobile && _currentPolygon.path.length == 1) {
if (_mobile && _currentPolygon.path.length === 1) {
_mobilePoint.coordinate = _currentPolygon.path[0]
_mobilePoint.visible = true
} else if (_mobile && _currentPolygon.path.length == 2) {
} else if (_mobile && _currentPolygon.path.length === 2) {
// Show initial line segment on mobile
_mobileSegment.path = [ _currentPolygon.path[0], _currentPolygon.path[1] ]
_mobileSegment.visible = true
......
......@@ -115,7 +115,7 @@ Item {
var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y), false /* clipToViewPort */)
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord))
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value == UnitsSettings.DistanceUnitsFeet) {
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value === UnitsSettings.DistanceUnitsFeet) {
calculateFeetRatio(scaleLineMeters, scaleLinePixelLength)
} else {
calculateMetersRatio(scaleLineMeters, scaleLinePixelLength)
......
......@@ -61,7 +61,7 @@ DropButton {
/// Fits the visible region of the map to inclues all of the specified coordinates. If no coordinates
/// are specified the map will center to fitHomePosition()
function fitMapViewportToAllCoordinates(coordList) {
if (coordList.length == 0) {
if (coordList.length === 0) {
map.center = fitHomePosition()
return
}
......@@ -115,16 +115,17 @@ DropButton {
}
function addFenceItemCoordsForFit(coordList) {
var i
var homePosition = fitHomePosition()
if (homePosition.isValid && geoFenceController.circleEnabled) {
var azimuthList = [ 0, 180, 90, 270 ]
for (var i=0; i<azimuthList.length; i++) {
for (i = 0; i < azimuthList.length; i++) {
var edgeCoordinate = homePosition.atDistanceAndAzimuth(geoFenceController.circleRadius, azimuthList[i])
coordList.push(edgeCoordinate)
}
}
if (geoFenceController.polygonEnabled && geoFenceController.polygon.count() > 2) {
for (var i=0; i<geoFenceController.polygon.count(); i++) {
for (i = 0; i < geoFenceController.polygon.count(); i++) {
coordList.push(geoFenceController.polygon.path[i])
}
}
......
......@@ -49,7 +49,7 @@ Item {
/// are specified the map will center to fitHomePosition()
function fitMapViewportToAllCoordinates(coordList) {
var mapFitViewport = Qt.rect(0, 0, map.width, map.height)
if (coordList.length == 0) {
if (coordList.length === 0) {
var homeCoord = fitHomePosition()
if (homeCoord.isValid) {
map.center = homeCoord
......@@ -113,16 +113,17 @@ Item {
}
function addFenceItemCoordsForFit(coordList) {
var i
var homePosition = fitHomePosition()
if (homePosition.isValid && _geoFenceController.circleEnabled) {
var azimuthList = [ 0, 180, 90, 270 ]
for (var i=0; i<azimuthList.length; i++) {
for (i = 0; i < azimuthList.length; i++) {
var edgeCoordinate = homePosition.atDistanceAndAzimuth(_geoFenceController.circleRadius, azimuthList[i])
coordList.push(edgeCoordinate)
}
}
if (_geoFenceController.polygonEnabled && _geoFenceController.mapPolygon.path.count > 2) {
for (var i=0; i<_geoFenceController.mapPolygon.path.count; i++) {
for (i = 0; i < _geoFenceController.mapPolygon.path.count; i++) {
coordList.push(_geoFenceController.mapPolygon.path[i])
}
}
......
......@@ -174,8 +174,8 @@ Column {
anchors.right: parent.right
sourceComponent: factGroupList
property var factGroup: _activeVehicle
property var factGroupName: "Vehicle"
property var factGroup: _activeVehicle
property string factGroupName: "Vehicle"
}
}
}
......
......@@ -32,6 +32,11 @@ const char* Joystick::_roverTXModeSettingsKey = "TXMode_Rover";
const char* Joystick::_vtolTXModeSettingsKey = "TXMode_VTOL";
const char* Joystick::_submarineTXModeSettingsKey = "TXMode_Submarine";
const char* Joystick::_buttonActionArm = QT_TR_NOOP("Arm");
const char* Joystick::_buttonActionDisarm = QT_TR_NOOP("Disarm");
const char* Joystick::_buttonActionVTOLFixedWing = QT_TR_NOOP("VTOL: Fixed Wing");
const char* Joystick::_buttonActionVTOLMultiRotor = QT_TR_NOOP("VTOL: Multi-Rotor");
const char* Joystick::_rgFunctionSettingsKey[Joystick::maxFunction] = {
"RollAxis",
"PitchAxis",
......@@ -49,7 +54,7 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
, _hatCount(hatCount)
, _hatButtonCount(4*hatCount)
, _totalButtonCount(_buttonCount+_hatButtonCount)
, _calibrationMode(CalibrationModeOff)
, _calibrationMode(false)
, _rgAxisValues(NULL)
, _rgCalibration(NULL)
, _rgButtonValues(NULL)
......@@ -84,6 +89,10 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
Joystick::~Joystick()
{
// Crash out of the thread if it is still running
terminate();
wait();
delete[] _rgAxisValues;
delete[] _rgCalibration;
delete[] _rgButtonValues;
......@@ -431,7 +440,7 @@ void Joystick::run(void)
}
}
if (_calibrationMode != CalibrationModeCalibrating && _calibrated) {
if (_outputEnabled && _calibrated) {
int axis = _rgFunctionAxis[rollFunction];
float roll = _adjustRange(_rgAxisValues[axis], _rgCalibration[axis], _deadband);
......@@ -638,11 +647,12 @@ QStringList Joystick::actions(void)
{
QStringList list;
list << "Arm" << "Disarm";
list << _buttonActionArm << _buttonActionDisarm;
if (_activeVehicle) {
list << _activeVehicle->flightModes();
}
list << _buttonActionVTOLFixedWing << _buttonActionVTOLMultiRotor;
return list;
}
......@@ -757,48 +767,44 @@ void Joystick::setDeadband(bool deadband)
_saveSettings();
}
void Joystick::startCalibrationMode(CalibrationMode_t mode)
void Joystick::setCalibrationMode(bool calibrating)
{
if (mode == CalibrationModeOff) {
qWarning() << "Incorrect mode CalibrationModeOff";
return;
}
_calibrationMode = calibrating;
_calibrationMode = mode;
if (!isRunning()) {
if (calibrating && !isRunning()) {
_pollingStartedForCalibration = true;
startPolling(_multiVehicleManager->activeVehicle());
}
}
void Joystick::stopCalibrationMode(CalibrationMode_t mode)
{
if (mode == CalibrationModeOff) {
qWarning() << "Incorrect mode: CalibrationModeOff";
return;
else if (_pollingStartedForCalibration) {
stopPolling();
}
if (mode == CalibrationModeCalibrating) {
_calibrationMode = CalibrationModeMonitor;
} else {
_calibrationMode = CalibrationModeOff;
if (_pollingStartedForCalibration) {
stopPolling();
}
if (calibrating){
setOutputEnabled(false); //Disable the joystick output before calibrating
}
else if (!calibrating && _calibrated){
setOutputEnabled(true); //Enable joystick output after calibration
}
}
void Joystick::setOutputEnabled(bool enabled){
_outputEnabled = enabled;
emit outputEnabledChanged(_outputEnabled);
}
void Joystick::_buttonAction(const QString& action)
{
if (!_activeVehicle || !_activeVehicle->joystickEnabled()) {
return;
}
if (action == "Arm") {
if (action == _buttonActionArm) {
_activeVehicle->setArmed(true);
} else if (action == "Disarm") {
} else if (action == _buttonActionDisarm) {
_activeVehicle->setArmed(false);
} else if (action == _buttonActionVTOLFixedWing) {
_activeVehicle->setVtolInFwdFlight(true);
} else if (action == _buttonActionVTOLMultiRotor) {
_activeVehicle->setVtolInFwdFlight(false);
} else if (_activeVehicle->flightModes().contains(action)) {
_activeVehicle->setFlightMode(action);
} else {
......
......@@ -61,6 +61,7 @@ public:
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool calibrated MEMBER _calibrated NOTIFY calibratedChanged)
Q_PROPERTY(bool outputEnabled MEMBER _outputEnabled WRITE setOutputEnabled NOTIFY outputEnabledChanged)
Q_PROPERTY(int totalButtonCount READ totalButtonCount CONSTANT)
Q_PROPERTY(int axisCount READ axisCount CONSTANT)
......@@ -122,20 +123,13 @@ public:
void setTXMode(int mode);
int getTXMode(void) { return _transmitterMode; }
typedef enum {
CalibrationModeOff, // Not calibrating
CalibrationModeMonitor, // Monitors are active, continue to send to vehicle if already polling
CalibrationModeCalibrating, // Calibrating, stop sending joystick to vehicle
} CalibrationMode_t;
/// Set the current calibration mode
void startCalibrationMode(CalibrationMode_t mode);
/// Clear the current calibration mode
void stopCalibrationMode(CalibrationMode_t mode);
void setCalibrationMode(bool calibrating);
void setOutputEnabled(bool enabled);
signals:
void calibratedChanged(bool calibrated);
void outputEnabledChanged(bool enabled);
// The raw signals are only meant for use by calibration
void rawAxisValueChanged(int index, int value);
......@@ -201,7 +195,8 @@ protected:
int _totalButtonCount;
static int _transmitterMode;
CalibrationMode_t _calibrationMode;
bool _calibrationMode;
bool _outputEnabled;
int* _rgAxisValues;
Calibration_t* _rgCalibration;
......@@ -241,6 +236,11 @@ private:
static const char* _vtolTXModeSettingsKey;
static const char* _submarineTXModeSettingsKey;
static const char* _buttonActionArm;
static const char* _buttonActionDisarm;
static const char* _buttonActionVTOLFixedWing;
static const char* _buttonActionVTOLMultiRotor;
private slots:
void _activeVehicleChanged(Vehicle* activeVehicle);
};
......
......@@ -356,6 +356,22 @@ void PlanMasterController::loadFromFile(const QString& filename)
}
}
QJsonDocument PlanMasterController::saveToJson()
{
QJsonObject planJson;
QJsonObject missionJson;
QJsonObject fenceJson;
QJsonObject rallyJson;
JsonHelper::saveQGCJsonFileHeader(planJson, _planFileType, _planFileVersion);
_missionController.save(missionJson);
_geoFenceController.save(fenceJson);
_rallyPointController.save(rallyJson);
planJson[_jsonMissionObjectKey] = missionJson;
planJson[_jsonGeoFenceObjectKey] = fenceJson;
planJson[_jsonRallyPointsObjectKey] = rallyJson;
return QJsonDocument(planJson);
}
void PlanMasterController::saveToFile(const QString& filename)
{
if (filename.isEmpty()) {
......@@ -372,20 +388,7 @@ void PlanMasterController::saveToFile(const QString& filename)
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qgcApp()->showMessage(tr("Plan save error %1 : %2").arg(filename).arg(file.errorString()));
} else {
QJsonObject planJson;
QJsonObject missionJson;
QJsonObject fenceJson;
QJsonObject rallyJson;
JsonHelper::saveQGCJsonFileHeader(planJson, _planFileType, _planFileVersion);
_missionController.save(missionJson);
_geoFenceController.save(fenceJson);
_rallyPointController.save(rallyJson);
planJson[_jsonMissionObjectKey] = missionJson;
planJson[_jsonGeoFenceObjectKey] = fenceJson;
planJson[_jsonRallyPointsObjectKey] = rallyJson;
QJsonDocument saveDoc(planJson);
QJsonDocument saveDoc = saveToJson();
file.write(saveDoc.toJson());
}
......
......@@ -80,6 +80,8 @@ public:
QStringList saveNameFilters (void) const;
QStringList saveKmlFilters (void) const;
QJsonDocument saveToJson ();
Vehicle* controllerVehicle(void) { return _controllerVehicle; }
Vehicle* managerVehicle(void) { return _managerVehicle; }
......
......@@ -177,8 +177,7 @@ Item {
title: qsTr("Select KML File")
selectExisting: true
nameFilters: [ qsTr("KML files (*.kml)") ]
fileExtension: "kml"
onAcceptedForLoad: {
mapPolygon.loadKMLFile(file)
close()
......
......@@ -300,7 +300,7 @@ private:
static const char* _jsonFixedValueIsAltitudeKey;
static const char* _jsonRefly90DegreesKey;
static const int _hoverAndCaptureDelaySeconds = 2;
static const int _hoverAndCaptureDelaySeconds = 4;
};
#endif
......@@ -39,7 +39,7 @@ Column {
}
gridTypeCombo.model = _cameraList
var knownCameraIndex = gridTypeCombo.find(cameraCalc.cameraName)
if (knownCameraIndex != -1) {
if (knownCameraIndex !== -1) {
gridTypeCombo.currentIndex = knownCameraIndex
} else {
console.log("Internal error: Known camera not found", cameraCalc.cameraName)
......
......@@ -46,7 +46,7 @@ Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraAction.rawValue == 1
visible: _camera.cameraAction.rawValue === 1
QGCLabel {
text: qsTr("Time")
......@@ -62,7 +62,7 @@ Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraAction.rawValue == 2
visible: _camera.cameraAction.rawValue === 2
QGCLabel {
text: qsTr("Distance")
......
......@@ -154,7 +154,7 @@ QGCFlickable {
QGCLabel {
text: qsTr("None")
visible: polygonSection.checked && myGeoFenceController.polygons.count == 0
visible: polygonSection.checked && myGeoFenceController.polygons.count === 0
}
GridLayout {
......@@ -239,7 +239,7 @@ QGCFlickable {
QGCLabel {
text: qsTr("None")
visible: circleSection.checked && myGeoFenceController.circles.count == 0
visible: circleSection.checked && myGeoFenceController.circles.count === 0
}
GridLayout {
......
This diff is collapsed.
......@@ -36,6 +36,7 @@ Rectangle {
property var _fileExtension: QGroundControl.settingsManager.appSettings.missionFileExtension
property var _appSettings: QGroundControl.settingsManager.appSettings
property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
property bool _showCameraSection: !_waypointsOnlyMode || QGroundControl.corePlugin.showAdvancedUI
readonly property string _firmwareLabel: qsTr("Firmware")
readonly property string _vehicleLabel: qsTr("Vehicle")
......@@ -91,6 +92,7 @@ Rectangle {
CameraSection {
id: cameraSection
checked: missionItem.cameraSection.settingsSpecified
visible: _showCameraSection
}
QGCLabel {
......@@ -100,7 +102,7 @@ Rectangle {
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
font.pointSize: ScreenTools.smallFontPointSize
visible: cameraSection.checked
visible: _showCameraSection && cameraSection.checked
}
SectionHeader {
......
Supports Markdown
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