Commit 7303aafc authored by Don Gagne's avatar Don Gagne

Add relative altitude support

Also much other cleanup/change
parent cd2d960a
This diff is collapsed.
......@@ -60,7 +60,7 @@ public:
Q_PROPERTY(int sequenceNumber READ sequenceNumber WRITE setSequenceNumber NOTIFY sequenceNumberChanged)
Q_PROPERTY(bool isCurrentItem READ isCurrentItem WRITE setIsCurrentItem NOTIFY isCurrentItemChanged)
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY specifiesCoordinateChanged)
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY commandChanged)
Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
Q_PROPERTY(double yaw READ yawDegrees WRITE setYawDegrees NOTIFY yawChanged)
Q_PROPERTY(QStringList commandNames READ commandNames CONSTANT)
......@@ -68,8 +68,8 @@ public:
Q_PROPERTY(QStringList valueLabels READ valueLabels NOTIFY commandChanged)
Q_PROPERTY(QStringList valueStrings READ valueStrings NOTIFY valueStringsChanged)
Q_PROPERTY(int commandByIndex READ commandByIndex WRITE setCommandByIndex NOTIFY commandChanged)
Q_PROPERTY(QmlObjectListModel* facts READ facts NOTIFY commandChanged)
Q_PROPERTY(int factCount READ factCount NOTIFY commandChanged)
Q_PROPERTY(QmlObjectListModel* textFieldFacts READ textFieldFacts NOTIFY commandChanged)
Q_PROPERTY(QmlObjectListModel* checkboxFacts READ checkboxFacts NOTIFY commandChanged)
Q_PROPERTY(MavlinkQmlSingleton::Qml_MAV_CMD command READ command WRITE setCommand NOTIFY commandChanged)
// Property accesors
......@@ -82,7 +82,7 @@ public:
bool specifiesCoordinate(void) const;
QGeoCoordinate coordinate(void) const { return _coordinate; }
QGeoCoordinate coordinate(void) const;
void setCoordinate(const QGeoCoordinate& coordinate);
QStringList commandNames(void);
......@@ -97,17 +97,17 @@ public:
QStringList valueLabels(void);
QStringList valueStrings(void);
QmlObjectListModel* facts(void);
int factCount(void);
QmlObjectListModel* textFieldFacts(void);
QmlObjectListModel* checkboxFacts(void);
double yawDegrees(void) const;
void setYawDegrees(double yaw);
// C++ only methods
double latitude(void) const { return _coordinate.latitude(); }
double longitude(void) const { return _coordinate.longitude(); }
double altitude(void) const { return _coordinate.altitude(); }
double latitude(void) const { return _latitudeFact->value().toDouble(); }
double longitude(void) const { return _longitudeFact->value().toDouble(); }
double altitude(void) const { return _altitudeFact->value().toDouble(); }
void setLatitude(double latitude);
void setLongitude(double longitude);
......@@ -158,9 +158,8 @@ public:
return altitude();
}
// MAV_FRAME
int frame() const {
return _frame;
}
int frame() const;
// MAV_CMD
int command() const {
return _command;
......@@ -176,7 +175,6 @@ public:
signals:
void sequenceNumberChanged(int sequenceNumber);
void specifiesCoordinateChanged(bool specifiesCoordinate);
void isCurrentItemChanged(bool isCurrentItem);
void coordinateChanged(const QGeoCoordinate& coordinate);
void yawChanged(double yaw);
......@@ -226,17 +224,20 @@ private:
} MavCmd2Name_t;
int _sequenceNumber;
QGeoCoordinate _coordinate;
int _frame;
MavlinkQmlSingleton::Qml_MAV_CMD _command;
bool _autocontinue;
bool _isCurrentItem;
quint64 _reachedTime;
Fact* _latitudeFact;
Fact* _longitudeFact;
Fact* _altitudeFact;
Fact* _yawRadiansFact;
Fact* _loiterOrbitRadiusFact;
Fact* _param1Fact;
Fact* _param2Fact;
Fact* _altitudeRelativeToHomeFact;
FactMetaData* _pitchMetaData;
FactMetaData* _acceptanceRadiusMetaData;
......@@ -251,4 +252,7 @@ private:
static const MavCmd2Name_t _rgMavCmd2Name[_cMavCmd2Name];
};
QDebug operator<<(QDebug dbg, const MissionItem& missionItem);
QDebug operator<<(QDebug dbg, const MissionItem* missionItem);
#endif
......@@ -20,13 +20,14 @@ Rectangle {
signal moveUp
signal moveDown
// FIXME: THis doesn't work right for RTL
height: missionItem.isCurrentItem ?
((missionItem.factCount + (missionItem.specifiesCoordinate ? 3 : 0)) * (latitudeField.height + _margin)) + commandPicker.height + deleteButton.height + (_margin * 6) :
(missionItem.textFieldFacts.count * (measureTextField.height + _margin)) +
(missionItem.checkboxFacts.count * (measureCheckbox.height + _margin)) +
commandPicker.height + deleteButton.height + (_margin * 9) :
commandPicker.height + (_margin * 2)
color: missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
readonly property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 13
readonly property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 16
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 3
QGCPalette {
......@@ -34,6 +35,16 @@ Rectangle {
colorGroupEnabled: enabled
}
QGCTextField {
id: measureTextField
visible: false
}
QGCCheckBox {
id: measureCheckbox
visible: false
}
Item {
anchors.margins: _margin
anchors.fill: parent
......@@ -65,7 +76,7 @@ Rectangle {
}
Rectangle {
anchors.margins: _margin
anchors.topMargin: _margin
anchors.top: commandPicker.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
......@@ -77,76 +88,18 @@ Rectangle {
anchors.margins: _margin
anchors.fill: parent
QGCTextField {
id: latitudeField
anchors.right: parent.right
width: _editFieldWidth
text: missionItem.coordinate.latitude
visible: missionItem.specifiesCoordinate
onAccepted: missionItem.coordinate.latitude = text
}
QGCTextField {
id: longitudeField
anchors.topMargin: _margin
anchors.top: latitudeField.bottom
anchors.right: parent.right
width: _editFieldWidth
text: missionItem.coordinate.longitude
visible: missionItem.specifiesCoordinate
onAccepted: missionItem.coordinate.longtitude = text
}
QGCTextField {
id: altitudeField
anchors.topMargin: _margin
anchors.top: longitudeField.bottom
anchors.right: parent.right
width: _editFieldWidth
text: missionItem.coordinate.altitude
visible: missionItem.specifiesCoordinate
showUnits: true
unitsLabel: "meters"
onAccepted: missionItem.coordinate.altitude = text
}
QGCLabel {
anchors.left: parent.left
anchors.baseline: latitudeField.baseline
text: "Lat:"
visible: missionItem.specifiesCoordinate
}
QGCLabel {
anchors.left: parent.left
anchors.baseline: longitudeField.baseline
text: "Long:"
visible: missionItem.specifiesCoordinate
}
QGCLabel {
anchors.left: parent.left
anchors.baseline: altitudeField.baseline
text: "Alt:"
visible: missionItem.specifiesCoordinate
}
Column {
id: valueColumn
anchors.topMargin: _margin
anchors.left: parent.left
anchors.right: parent.right
anchors.top: missionItem.specifiesCoordinate ? altitudeField.bottom : parent.top
spacing: _margin
id: valuesColumn
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: _margin
Repeater {
model: missionItem.facts
model: missionItem.textFieldFacts
Item {
width: valueColumn.width
width: valuesColumn.width
height: textField.height
QGCLabel {
......@@ -163,39 +116,57 @@ Rectangle {
}
}
}
} // Column - Values column
Row {
anchors.topMargin: _margin
anchors.top: valueColumn.bottom
width: parent.width
spacing: _margin
Item {
width: 10
height: missionItem.textFieldFacts.count ? _margin : 0
}
readonly property real buttonWidth: (width - (_margin * 2)) / 3
Repeater {
model: missionItem.checkboxFacts
QGCButton {
id: deleteButton
width: parent.buttonWidth
text: "Delete"
FactCheckBox {
id: textField
text: object.name
fact: object
}
}
onClicked: _root.remove()
Item {
width: 10
height: missionItem.checkboxFacts.count ? _margin : 0
}
QGCButton {
width: parent.buttonWidth
text: "Up"
Row {
width: parent.width
spacing: _margin
onClicked: _root.moveUp()
}
readonly property real buttonWidth: (width - (_margin * 2)) / 3
QGCButton {
id: deleteButton
width: parent.buttonWidth
text: "Delete"
onClicked: _root.remove()
}
QGCButton {
width: parent.buttonWidth
text: "Down"
QGCButton {
width: parent.buttonWidth
text: "Up"
onClicked: _root.moveDown()
onClicked: _root.moveUp()
}
QGCButton {
width: parent.buttonWidth
text: "Down"
onClicked: _root.moveDown()
}
}
}
} // Column
} // Item
} // Rectangle
} // Item
......
......@@ -117,7 +117,6 @@ bool QmlObjectListModel::removeRows(int position, int rows, const QModelIndex& p
//_objectList[position]->deleteLater();
_objectList.removeAt(position);
}
qDebug() << _objectList;
endRemoveRows();
emit countChanged(count());
......
......@@ -46,6 +46,13 @@ public:
QObject* operator[](int i);
const QObject* operator[](int i) const;
template <class T>
const QList<T*>& list(void) { return *((QList<T*>*)((void*)(&_objectList))); }
signals:
void countChanged(int count);
private:
// Overrides from QAbstractListModel
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
......@@ -53,9 +60,6 @@ public:
virtual bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
virtual bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
signals:
void countChanged(int count);
private:
QList<QObject*> _objectList;
......
......@@ -936,5 +936,9 @@ void Vehicle::setActive(bool active)
QmlObjectListModel* Vehicle::missionItemsModel(void)
{
return &_missionItems;
if (qgcApp()->useNewMissionEditor()) {
return missionManager()->missionItems();
} else {
return &_missionItems;
}
}
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