Commit 7a105693 authored by Don Gagne's avatar Don Gagne

Add missing values and better ui

parent 1f5b8f6a
......@@ -31,7 +31,8 @@ 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 / 4
property real _spacer: ScreenTools.defaultFontPixelWidth / 2
Column {
id: editorColumn
......@@ -40,17 +41,78 @@ Rectangle {
anchors.right: parent.right
visible: missionItem.landingCoordSet
QGCLabel { text: "WIP (NOT FOR REAL FLIGHT!)" }
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
font.pointSize: ScreenTools.smallFontPointSize
text: "WIP (NOT FOR REAL FLIGHT!)"
}
Item { width: 1; height: _margin }
QGCLabel { text: qsTr("Loiter point") }
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: qgcPal.text
}
Item { width: 1; height: _spacer }
FactTextFieldGrid {
anchors.left: parent.left
anchors.right: parent.right
factList: [ missionItem.loiterAltitude, missionItem.loiterRadius ]
}
Item { width: 1; height: _spacer }
QGCCheckBox {
id: loiterAltRelative
anchors.right: parent.right
text: qsTr("Altitude relative to home")
checked: missionItem.loiterAltitudeRelative
onClicked: missionItem.loiterAltitudeRelative = checked
}
Item { width: 1; height: _spacer }
QGCCheckBox {
anchors.left: loiterAltRelative.left
text: qsTr("Loiter clockwise")
checked: missionItem.loiterClockwise
onClicked: missionItem.loiterClockwise = checked
}
Item { width: 1; height: ScreenTools.defaultFontPixelHeight / 2 }
QGCLabel { text: qsTr("Landing point") }
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: qgcPal.text
}
Item { width: 1; height: _spacer }
FactTextFieldGrid {
anchors.left: parent.left
anchors.right: parent.right
factList: missionItem.textFieldFacts
factList: [ missionItem.landingAltitude, missionItem.landingDistance, missionItem.landingHeading ]
}
FactCheckBox {
text: missionItem.loiterClockwise.name
fact: missionItem.loiterClockwise
Item { width: 1; height: _spacer }
QGCCheckBox {
anchors.right: parent.right
text: qsTr("Altitude relative to home")
checked: missionItem.landingAltitudeRelative
onClicked: missionItem.landingAltitudeRelative = checked
}
}
......
......@@ -17,7 +17,7 @@
},
{
"name": "Loiter altitude",
"shortDescription": "Altitude to loiter prior to landing.",
"shortDescription": "Aircraft will proceed to the loiter point and loiter until it reaches this altitude. Once altitude is reached the aircraft will proceed to land.",
"type": "double",
"units": "m",
"decimalPlaces": 1,
......@@ -33,9 +33,11 @@
"defaultValue": 75.0
},
{
"name": "Clockwise loiter",
"shortDescription": "If true, loiter will be clockwise. False, loiter will be counter-clockwise.",
"type": "bool",
"defaultValue": true
"name": "Landing altitude",
"shortDescription": "Altitude for landing point.",
"type": "double",
"units": "m",
"decimalPlaces": 1,
"defaultValue": 0.0
}
]
......@@ -23,7 +23,7 @@ const char* FixedWingLandingComplexItem::_loiterToLandDistanceName = "Landing
const char* FixedWingLandingComplexItem::_landingHeadingName = "Landing heading";
const char* FixedWingLandingComplexItem::_loiterAltitudeName = "Loiter altitude";
const char* FixedWingLandingComplexItem::_loiterRadiusName = "Loiter radius";
const char* FixedWingLandingComplexItem::_loiterClockwiseName = "Clockwise loiter";
const char* FixedWingLandingComplexItem::_landingAltitudeName = "Landing altitude";
QMap<QString, FactMetaData*> FixedWingLandingComplexItem::_metaDataMap;
......@@ -36,8 +36,11 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(Vehicle* vehicle, QObje
, _loiterToLandDistanceFact (0, _loiterToLandDistanceName, FactMetaData::valueTypeDouble)
, _loiterAltitudeFact (0, _loiterAltitudeName, FactMetaData::valueTypeDouble)
, _loiterRadiusFact (0, _loiterRadiusName, FactMetaData::valueTypeDouble)
, _loiterClockwiseFact (0, _loiterClockwiseName, FactMetaData::valueTypeBool)
, _landingHeadingFact (0, _landingHeadingName, FactMetaData::valueTypeDouble)
, _landingAltitudeFact (0, _landingAltitudeName, FactMetaData::valueTypeDouble)
, _loiterClockwise(true)
, _loiterAltitudeRelative(true)
, _landingAltitudeRelative(true)
{
_editorQml = "qrc:/qml/FWLandingPatternEditor.qml";
......@@ -48,21 +51,19 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(Vehicle* vehicle, QObje
_loiterToLandDistanceFact.setMetaData (_metaDataMap[_loiterToLandDistanceName]);
_loiterAltitudeFact.setMetaData (_metaDataMap[_loiterAltitudeName]);
_loiterRadiusFact.setMetaData (_metaDataMap[_loiterRadiusName]);
_loiterClockwiseFact.setMetaData (_metaDataMap[_loiterClockwiseName]);
_landingHeadingFact.setMetaData (_metaDataMap[_landingHeadingName]);
_landingAltitudeFact.setMetaData (_metaDataMap[_landingAltitudeName]);
_loiterToLandDistanceFact.setRawValue (_loiterToLandDistanceFact.rawDefaultValue());
_loiterAltitudeFact.setRawValue (_loiterAltitudeFact.rawDefaultValue());
_loiterRadiusFact.setRawValue (_loiterRadiusFact.rawDefaultValue());
_loiterClockwiseFact.setRawValue (_loiterClockwiseFact.rawDefaultValue());
_landingHeadingFact.setRawValue (_landingHeadingFact.rawDefaultValue());
_landingAltitudeFact.setRawValue (_landingAltitudeFact.rawDefaultValue());
connect(&_loiterToLandDistanceFact, &Fact::valueChanged, this, &FixedWingLandingComplexItem::_recalcLoiterCoordFromFacts);
connect(&_landingHeadingFact, &Fact::valueChanged, this, &FixedWingLandingComplexItem::_recalcLoiterCoordFromFacts);
connect(this, &FixedWingLandingComplexItem::loiterCoordinateChanged, this, &FixedWingLandingComplexItem::_recalcFactsFromCoords);
connect(this, &FixedWingLandingComplexItem::landingCoordinateChanged, this, &FixedWingLandingComplexItem::_recalcFactsFromCoords);
_textFieldFacts << QVariant::fromValue(&_loiterToLandDistanceFact) << QVariant::fromValue(&_loiterAltitudeFact) << QVariant::fromValue(&_loiterRadiusFact) << QVariant::fromValue(&_landingHeadingFact);
}
int FixedWingLandingComplexItem::lastSequenceNumber(void) const
......@@ -147,10 +148,10 @@ QmlObjectListModel* FixedWingLandingComplexItem::getMissionItems(void) const
pMissionItems); // parent - allow delete on pMissionItems to delete everthing
pMissionItems->append(item);
float loiterRadius = _loiterRadiusFact.rawValue().toDouble() * (_loiterClockwiseFact.rawValue().toBool() ? 1.0 : -1.0);
float loiterRadius = _loiterRadiusFact.rawValue().toDouble() * (_loiterClockwise ? 1.0 : -1.0);
item = new MissionItem(seqNum++,
MAV_CMD_NAV_LOITER_TO_ALT,
MAV_FRAME_GLOBAL_RELATIVE_ALT,
_loiterAltitudeRelative ? MAV_FRAME_GLOBAL_RELATIVE_ALT : MAV_FRAME_GLOBAL,
1.0, // Heading required = true
loiterRadius, // Loiter radius
0.0, // param 3 - unused
......@@ -165,7 +166,7 @@ QmlObjectListModel* FixedWingLandingComplexItem::getMissionItems(void) const
item = new MissionItem(seqNum++,
MAV_CMD_NAV_LAND,
MAV_FRAME_GLOBAL_RELATIVE_ALT,
_landingAltitudeRelative ? MAV_FRAME_GLOBAL_RELATIVE_ALT : MAV_FRAME_GLOBAL,
0.0, 0.0, 0.0, 0.0, // param 1-4
_landingCoordinate.latitude(),
_landingCoordinate.longitude(),
......
......@@ -24,13 +24,23 @@ class FixedWingLandingComplexItem : public ComplexMissionItem
public:
FixedWingLandingComplexItem(Vehicle* vehicle, QObject* parent = NULL);
Q_PROPERTY(QVariantList textFieldFacts MEMBER _textFieldFacts CONSTANT)
Q_PROPERTY(Fact* loiterClockwise READ loiterClockwise CONSTANT)
Q_PROPERTY(QGeoCoordinate loiterCoordinate READ loiterCoordinate WRITE setLoiterCoordinate NOTIFY loiterCoordinateChanged)
Q_PROPERTY(QGeoCoordinate landingCoordinate READ landingCoordinate WRITE setLandingCoordinate NOTIFY landingCoordinateChanged)
Q_PROPERTY(bool landingCoordSet MEMBER _landingCoordSet NOTIFY landingCoordSetChanged)
Fact* loiterClockwise (void) { return &_loiterClockwiseFact; }
Q_PROPERTY(Fact* loiterAltitude READ loiterAltitude CONSTANT)
Q_PROPERTY(Fact* loiterRadius READ loiterRadius CONSTANT)
Q_PROPERTY(Fact* landingAltitude READ landingAltitude CONSTANT)
Q_PROPERTY(Fact* landingDistance READ landingDistance CONSTANT)
Q_PROPERTY(Fact* landingHeading READ landingHeading CONSTANT)
Q_PROPERTY(bool loiterClockwise MEMBER _loiterClockwise NOTIFY loiterClockwiseChanged)
Q_PROPERTY(bool loiterAltitudeRelative MEMBER _loiterAltitudeRelative NOTIFY loiterAltitudeRelativeChanged)
Q_PROPERTY(bool landingAltitudeRelative MEMBER _landingAltitudeRelative NOTIFY landingAltitudeRelativeChanged)
Q_PROPERTY(QGeoCoordinate loiterCoordinate READ loiterCoordinate WRITE setLoiterCoordinate NOTIFY loiterCoordinateChanged)
Q_PROPERTY(QGeoCoordinate landingCoordinate READ landingCoordinate WRITE setLandingCoordinate NOTIFY landingCoordinateChanged)
Q_PROPERTY(bool landingCoordSet MEMBER _landingCoordSet NOTIFY landingCoordSetChanged)
Fact* loiterAltitude (void) { return &_loiterAltitudeFact; }
Fact* loiterRadius (void) { return &_loiterRadiusFact; }
Fact* landingAltitude (void) { return &_landingAltitudeFact; }
Fact* landingDistance (void) { return &_loiterToLandDistanceFact; }
Fact* landingHeading (void) { return &_landingHeadingFact; }
QGeoCoordinate landingCoordinate (void) const { return _landingCoordinate; }
QGeoCoordinate loiterCoordinate (void) const { return _loiterCoordinate; }
......@@ -73,9 +83,12 @@ public:
static const char* jsonComplexItemTypeValue;
signals:
void loiterCoordinateChanged (QGeoCoordinate coordinate);
void landingCoordinateChanged (QGeoCoordinate coordinate);
void landingCoordSetChanged (bool landingCoordSet);
void loiterCoordinateChanged (QGeoCoordinate coordinate);
void landingCoordinateChanged (QGeoCoordinate coordinate);
void landingCoordSetChanged (bool landingCoordSet);
void loiterClockwiseChanged (bool loiterClockwise);
void loiterAltitudeRelativeChanged (bool loiterAltitudeRelative);
void landingAltitudeRelativeChanged (bool loiterAltitudeRelative);
private slots:
void _recalcLoiterCoordFromFacts(void);
......@@ -94,18 +107,20 @@ private:
Fact _loiterToLandDistanceFact;
Fact _loiterAltitudeFact;
Fact _loiterRadiusFact;
Fact _loiterClockwiseFact;
Fact _landingHeadingFact;
Fact _landingAltitudeFact;
static QMap<QString, FactMetaData*> _metaDataMap;
bool _loiterClockwise;
bool _loiterAltitudeRelative;
bool _landingAltitudeRelative;
QVariantList _textFieldFacts;
static QMap<QString, FactMetaData*> _metaDataMap;
static const char* _loiterToLandDistanceName;
static const char* _loiterAltitudeName;
static const char* _loiterRadiusName;
static const char* _loiterClockwiseName;
static const char* _landingHeadingName;
static const char* _landingAltitudeName;
};
#endif
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