Commit 921f015a authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4599 from DonLakeFlyer/FWLandingPattern

Complex Item: Fixed Wing Landing Pattern
parents 08d7827f 248ec047
......@@ -56,6 +56,7 @@
<file alias="QGroundControl/Controls/FactSliderPanel.qml">src/QmlControls/FactSliderPanel.qml</file>
<file alias="QGroundControl/Controls/FlightModeDropdown.qml">src/QmlControls/FlightModeDropdown.qml</file>
<file alias="QGroundControl/Controls/FlightModeMenu.qml">src/QmlControls/FlightModeMenu.qml</file>
<file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">src/MissionEditor/FWLandingPatternMapVisual.qml</file>
<file alias="QGroundControl/Controls/GuidedBar.qml">src/QmlControls/GuidedBar.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file>
......
......@@ -31,11 +31,25 @@ Rectangle {
//property real availableWidth ///< Width for control
//property var missionItem ///< Mission Item for editor
property real _margin: ScreenTools.defaultFontPixelWidth * 0.25
property real _margin: ScreenTools.defaultFontPixelWidth * 0.25
Column {
id: editorColumn
id: editorColumn
anchors.margins: _margin
anchors.left: parent.left
anchors.right: parent.right
QGCLabel { text: "WIP" }
QGCLabel { text: "WIP (NOT FOR REAL FLIGHT!)" }
FactTextFieldGrid {
anchors.left: parent.left
anchors.right: parent.right
factList: missionItem.textFieldFacts
}
FactCheckBox {
text: missionItem.loiterClockwise.name
fact: missionItem.loiterClockwise
}
}
}
/****************************************************************************
*
* (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.2
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.2
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
/// Fixed Wing Landing Pattern map visuals
Item {
property var map ///< Map control to place item in
property var _loiterPoint
property var _flightPath
Component.onCompleted: {
_flightPath = flightPathComponent.createObject(map)
_loiterPoint = loiterComponent.createObject(map)
map.addMapItem(_flightPath)
map.addMapItem(_loiterPoint)
}
Component.onDestruction: {
_loiterPoint.destroy()
_flightPath.destroy()
}
// Flight path
Component {
id: flightPathComponent
MapPolyline {
line.color: "white"
line.width: 2
path: [ object.loiterCoordinate, object.exitCoordinate ]
}
}
// Loiter point
Component {
id: loiterComponent
MapQuickItem {
anchorPoint.x: sourceItem.width / 2
anchorPoint.y: sourceItem.height / 2
coordinate: object.loiterCoordinate
sourceItem:
MissionItemIndexLabel {
label: "L"
}
}
}
}
[
{
"name": "Landing distance",
"shortDescription": "Distance between landing and loiter points.",
"type": "double",
"units": "m",
"decimalPlaces": 1,
"defaultValue": 100.0
},
{
"name": "Landing heading",
"shortDescription": "Heading from land point to loiter point.",
"type": "double",
"units": "deg",
"decimalPlaces": 0,
"defaultValue": 0.0
},
{
"name": "Loiter altitude",
"shortDescription": "Altitude to loiter prior to landing.",
"type": "double",
"units": "m",
"decimalPlaces": 1,
"defaultValue": 40.0
},
{
"name": "Loiter radius",
"shortDescription": "Loiter radius.",
"type": "double",
"decimalPlaces": 1,
"min": 0.1,
"units": "m",
"defaultValue": 75.0
},
{
"name": "Clockwise loiter",
"shortDescription": "If true, loiter will be clockwise. False, loiter will be counter-clockwise.",
"type": "bool",
"defaultValue": true
}
]
......@@ -22,7 +22,13 @@ class FixedWingLandingComplexItem : public ComplexMissionItem
Q_OBJECT
public:
FixedWingLandingComplexItem(Vehicle* vehicle, QObject* parent = NULL);
FixedWingLandingComplexItem(Vehicle* vehicle, QGeoCoordinate mapClickCoordinate, QObject* parent = NULL);
Q_PROPERTY(QVariantList textFieldFacts MEMBER _textFieldFacts CONSTANT)
Q_PROPERTY(Fact* loiterClockwise READ loiterClockwise CONSTANT)
Q_PROPERTY(QGeoCoordinate loiterCoordinate MEMBER _loiterCoordinate NOTIFY loiterCoordinateChanged)
Fact* loiterClockwise(void) { return &_loiterClockwiseFact; }
// Overrides from ComplexMissionItem
......@@ -32,7 +38,7 @@ public:
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final;
double greatestDistanceTo (const QGeoCoordinate &other) const final;
void setCruiseSpeed (double cruiseSpeed) final;
QString mapVisualQML (void) const final { return QString(); }
QString mapVisualQML (void) const final { return QStringLiteral("FWLandingPatternMapVisual.qml"); }
// Overrides from VisualMissionItem
......@@ -60,18 +66,36 @@ public:
static const char* jsonComplexItemTypeValue;
signals:
void loiterCoordinateChanged(QGeoCoordinate coordinate);
private slots:
void _recalcLoiterPosition(void);
private:
void _setExitCoordinate(const QGeoCoordinate& coordinate);
QPointF _rotatePoint(const QPointF& point, const QPointF& origin, double angle);
int _sequenceNumber;
bool _dirty;
QGeoCoordinate _coordinate;
QGeoCoordinate _exitCoordinate;
QGeoCoordinate _loiterCoordinate;
Fact _loiterToLandDistanceFact;
Fact _loiterAltitudeFact;
Fact _loiterRadiusFact;
Fact _loiterClockwiseFact;
Fact _landingHeadingFact;
static QMap<QString, FactMetaData*> _metaDataMap;
QVariantList _textFieldFacts;
static const char* _loiterToLandDistanceName;
static const char* _loiterAltitudeName;
static const char* _loiterRadiusName;
static const char* _loiterClockwiseName;
static const char* _landingHeadingName;
};
#endif
......@@ -226,14 +226,14 @@ int MissionController::insertComplexMissionItem(QString itemName, QGeoCoordinate
int sequenceNumber = _nextSequenceNumber();
if (itemName == _surveyMissionItemName) {
newItem = new SurveyMissionItem(_activeVehicle, _visualItems);
newItem->setCoordinate(mapCenterCoordinate);
} else if (itemName == _fwLandingMissionItemName) {
newItem = new FixedWingLandingComplexItem(_activeVehicle, _visualItems);
newItem = new FixedWingLandingComplexItem(_activeVehicle, mapCenterCoordinate, _visualItems);
} else {
qWarning() << "Internal error: Unknown complex item:" << itemName;
return sequenceNumber;
}
newItem->setSequenceNumber(sequenceNumber);
newItem->setCoordinate(mapCenterCoordinate);
_initVisualItem(newItem);
_visualItems->insert(i, newItem);
......
Markdown is supported
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