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