Unverified Commit d58982ea authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8145 from DonLakeFlyer/ChildItemVisuals

Plan: When a child item is current show the parent as selected
parents 7a6373d7 81f914d9
...@@ -37,6 +37,7 @@ MapQuickItem { ...@@ -37,6 +37,7 @@ MapQuickItem {
showGimbalYaw: !isNaN(missionItem.missionGimbalYaw) showGimbalYaw: !isNaN(missionItem.missionGimbalYaw)
highlightSelected: true highlightSelected: true
onClicked: _item.clicked() onClicked: _item.clicked()
property bool _isCurrentItem: missionItem ? missionItem.isCurrentItem : false
property bool _isCurrentItem: missionItem ? missionItem.isCurrentItem || missionItem.hasCurrentChildItem : false
} }
} }
...@@ -1707,14 +1707,21 @@ void MissionController::_recalcChildItems(void) ...@@ -1707,14 +1707,21 @@ void MissionController::_recalcChildItems(void)
currentParentItem->childItems()->clear(); currentParentItem->childItems()->clear();
for (int i=1; i<_visualItems->count(); i++) { for (int i=1; i<_visualItems->count(); i++) {
VisualMissionItem* item = qobject_cast<VisualMissionItem*>(_visualItems->get(i)); VisualMissionItem* item = _visualItems->value<VisualMissionItem*>(i);
item->setParentItem(nullptr);
item->setHasCurrentChildItem(false);
// Set up non-coordinate item child hierarchy // Set up non-coordinate item child hierarchy
if (item->specifiesCoordinate()) { if (item->specifiesCoordinate()) {
item->childItems()->clear(); item->childItems()->clear();
currentParentItem = item; currentParentItem = item;
} else if (item->isSimpleItem()) { } else if (item->isSimpleItem()) {
item->setParentItem(currentParentItem);
currentParentItem->childItems()->append(item); currentParentItem->childItems()->append(item);
if (item->isCurrentItem()) {
currentParentItem->setHasCurrentChildItem(true);
}
} }
} }
} }
...@@ -2308,11 +2315,14 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2308,11 +2315,14 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
if (pVI->sequenceNumber() == sequenceNumber) { if (pVI->sequenceNumber() == sequenceNumber) {
pVI->setIsCurrentItem(true); pVI->setIsCurrentItem(true);
pVI->setHasCurrentChildItem(false);
_currentPlanViewItem = pVI; _currentPlanViewItem = pVI;
_currentPlanViewSeqNum = sequenceNumber; _currentPlanViewSeqNum = sequenceNumber;
_currentPlanViewVIIndex = viIndex; _currentPlanViewVIIndex = viIndex;
if (pVI->specifiesCoordinate() && !pVI->isStandaloneCoordinate()) { if (pVI->specifiesCoordinate()) {
if (!pVI->isStandaloneCoordinate()) {
// Determine split segment used to display line split editing ui. // Determine split segment used to display line split editing ui.
for (int j=viIndex-1; j>0; j--) { for (int j=viIndex-1; j>0; j--) {
VisualMissionItem* pPrev = qobject_cast<VisualMissionItem*>(_visualItems->get(j)); VisualMissionItem* pPrev = qobject_cast<VisualMissionItem*>(_visualItems->get(j));
...@@ -2324,6 +2334,9 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2324,6 +2334,9 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
} }
} }
} }
} else if (pVI->parentItem()) {
pVI->parentItem()->setHasCurrentChildItem(true);
}
} else { } else {
pVI->setIsCurrentItem(false); pVI->setIsCurrentItem(false);
} }
......
...@@ -26,21 +26,6 @@ VisualMissionItem::VisualMissionItem(Vehicle* vehicle, bool flyView, QObject* pa ...@@ -26,21 +26,6 @@ VisualMissionItem::VisualMissionItem(Vehicle* vehicle, bool flyView, QObject* pa
: QObject (parent) : QObject (parent)
, _vehicle (vehicle) , _vehicle (vehicle)
, _flyView (flyView) , _flyView (flyView)
, _isCurrentItem (false)
, _dirty (false)
, _homePositionSpecialCase (false)
, _terrainAltitude (qQNaN())
, _altDifference (0.0)
, _altPercent (0.0)
, _terrainPercent (qQNaN())
, _terrainCollision (false)
, _azimuth (0.0)
, _distance (0.0)
, _missionGimbalYaw (qQNaN())
, _missionVehicleYaw (qQNaN())
, _wizardMode (false)
, _lastLatTerrainQuery (0)
, _lastLonTerrainQuery (0)
{ {
_commonInit(); _commonInit();
} }
...@@ -49,16 +34,6 @@ VisualMissionItem::VisualMissionItem(const VisualMissionItem& other, bool flyVie ...@@ -49,16 +34,6 @@ VisualMissionItem::VisualMissionItem(const VisualMissionItem& other, bool flyVie
: QObject (parent) : QObject (parent)
, _vehicle (nullptr) , _vehicle (nullptr)
, _flyView (flyView) , _flyView (flyView)
, _isCurrentItem (false)
, _dirty (false)
, _homePositionSpecialCase (false)
, _altDifference (0.0)
, _altPercent (0.0)
, _terrainPercent (qQNaN())
, _terrainCollision (false)
, _azimuth (0.0)
, _distance (0.0)
, _wizardMode (false)
{ {
*this = other; *this = other;
...@@ -106,6 +81,14 @@ void VisualMissionItem::setIsCurrentItem(bool isCurrentItem) ...@@ -106,6 +81,14 @@ void VisualMissionItem::setIsCurrentItem(bool isCurrentItem)
} }
} }
void VisualMissionItem::setHasCurrentChildItem(bool hasCurrentChildItem)
{
if (_hasCurrentChildItem != hasCurrentChildItem) {
_hasCurrentChildItem = hasCurrentChildItem;
emit hasCurrentChildItemChanged(hasCurrentChildItem);
}
}
void VisualMissionItem::setDistance(double distance) void VisualMissionItem::setDistance(double distance)
{ {
if (!qFuzzyCompare(_distance, distance)) { if (!qFuzzyCompare(_distance, distance)) {
...@@ -228,3 +211,11 @@ void VisualMissionItem::setWizardMode(bool wizardMode) ...@@ -228,3 +211,11 @@ void VisualMissionItem::setWizardMode(bool wizardMode)
emit wizardModeChanged(_wizardMode); emit wizardModeChanged(_wizardMode);
} }
} }
void VisualMissionItem::setParentItem(VisualMissionItem* parentItem)
{
if (_parentItem != parentItem) {
_parentItem = parentItem;
emit parentItemChanged(parentItem);
}
}
...@@ -59,6 +59,7 @@ public: ...@@ -59,6 +59,7 @@ public:
Q_PROPERTY(QString abbreviation READ abbreviation NOTIFY abbreviationChanged) Q_PROPERTY(QString abbreviation READ abbreviation NOTIFY abbreviationChanged)
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) ///< Item is dirty and requires save/send Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) ///< Item is dirty and requires save/send
Q_PROPERTY(bool isCurrentItem READ isCurrentItem WRITE setIsCurrentItem NOTIFY isCurrentItemChanged) Q_PROPERTY(bool isCurrentItem READ isCurrentItem WRITE setIsCurrentItem NOTIFY isCurrentItemChanged)
Q_PROPERTY(bool hasCurrentChildItem READ hasCurrentChildItem WRITE setHasCurrentChildItem NOTIFY hasCurrentChildItemChanged) ///< true: On of this items children is current
Q_PROPERTY(int sequenceNumber READ sequenceNumber WRITE setSequenceNumber NOTIFY sequenceNumberChanged) Q_PROPERTY(int sequenceNumber READ sequenceNumber WRITE setSequenceNumber NOTIFY sequenceNumberChanged)
Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged) Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged)
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY specifiesCoordinateChanged) ///< true: Item is associated with a coordinate position Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY specifiesCoordinateChanged) ///< true: Item is associated with a coordinate position
...@@ -77,6 +78,7 @@ public: ...@@ -77,6 +78,7 @@ public:
Q_PROPERTY(bool flyView READ flyView CONSTANT) Q_PROPERTY(bool flyView READ flyView CONSTANT)
Q_PROPERTY(bool wizardMode READ wizardMode WRITE setWizardMode NOTIFY wizardModeChanged) Q_PROPERTY(bool wizardMode READ wizardMode WRITE setWizardMode NOTIFY wizardModeChanged)
Q_PROPERTY(ReadyForSaveState readyForSaveState READ readyForSaveState NOTIFY readyForSaveStateChanged) Q_PROPERTY(ReadyForSaveState readyForSaveState READ readyForSaveState NOTIFY readyForSaveStateChanged)
Q_PROPERTY(VisualMissionItem* parentItem READ parentItem WRITE setParentItem NOTIFY parentItemChanged)
Q_PROPERTY(QGCGeoBoundingCube* boundingCube READ boundingCube NOTIFY boundingCubeChanged) Q_PROPERTY(QGCGeoBoundingCube* boundingCube READ boundingCube NOTIFY boundingCubeChanged)
...@@ -94,24 +96,28 @@ public: ...@@ -94,24 +96,28 @@ public:
double altDifference (void) const { return _altDifference; } double altDifference (void) const { return _altDifference; }
double altPercent (void) const { return _altPercent; } double altPercent (void) const { return _altPercent; }
double terrainPercent (void) const { return _terrainPercent; } double terrainPercent (void) const { return _terrainPercent; }
bool terrainCollision(void) const { return _terrainCollision; } bool terrainCollision (void) const { return _terrainCollision; }
double azimuth (void) const { return _azimuth; } double azimuth (void) const { return _azimuth; }
double distance (void) const { return _distance; } double distance (void) const { return _distance; }
bool isCurrentItem (void) const { return _isCurrentItem; } bool isCurrentItem (void) const { return _isCurrentItem; }
bool hasCurrentChildItem (void) const { return _hasCurrentChildItem; }
double terrainAltitude (void) const { return _terrainAltitude; } double terrainAltitude (void) const { return _terrainAltitude; }
bool flyView (void) const { return _flyView; } bool flyView (void) const { return _flyView; }
bool wizardMode (void) const { return _wizardMode; } bool wizardMode (void) const { return _wizardMode; }
VisualMissionItem* parentItem(void) { return _parentItem; }
QmlObjectListModel* childItems(void) { return &_childItems; } QmlObjectListModel* childItems(void) { return &_childItems; }
void setIsCurrentItem (bool isCurrentItem); void setIsCurrentItem (bool isCurrentItem);
void setHasCurrentChildItem (bool hasCurrentChildItem);
void setAltDifference (double altDifference); void setAltDifference (double altDifference);
void setAltPercent (double altPercent); void setAltPercent (double altPercent);
void setTerrainPercent (double terrainPercent); void setTerrainPercent (double terrainPercent);
void setTerrainCollision(bool terrainCollision); void setTerrainCollision (bool terrainCollision);
void setAzimuth (double azimuth); void setAzimuth (double azimuth);
void setDistance (double distance); void setDistance (double distance);
void setWizardMode (bool wizardMode); void setWizardMode (bool wizardMode);
void setParentItem (VisualMissionItem* parentItem);
void setHomePositionSpecialCase (bool homePositionSpecialCase) { _homePositionSpecialCase = homePositionSpecialCase; } void setHomePositionSpecialCase (bool homePositionSpecialCase) { _homePositionSpecialCase = homePositionSpecialCase; }
...@@ -194,6 +200,7 @@ signals: ...@@ -194,6 +200,7 @@ signals:
void dirtyChanged (bool dirty); void dirtyChanged (bool dirty);
void distanceChanged (double distance); void distanceChanged (double distance);
void isCurrentItemChanged (bool isCurrentItem); void isCurrentItemChanged (bool isCurrentItem);
void hasCurrentChildItemChanged (bool hasCurrentChildItem);
void sequenceNumberChanged (int sequenceNumber); void sequenceNumberChanged (int sequenceNumber);
void isSimpleItemChanged (bool isSimpleItem); void isSimpleItemChanged (bool isSimpleItem);
void isTakeoffItemChanged (bool isTakeoffItem); void isTakeoffItemChanged (bool isTakeoffItem);
...@@ -211,6 +218,7 @@ signals: ...@@ -211,6 +218,7 @@ signals:
void boundingCubeChanged (void); void boundingCubeChanged (void);
void readyForSaveStateChanged (void); void readyForSaveStateChanged (void);
void wizardModeChanged (bool wizardMode); void wizardModeChanged (bool wizardMode);
void parentItemChanged (VisualMissionItem* parentItem);
void coordinateHasRelativeAltitudeChanged (bool coordinateHasRelativeAltitude); void coordinateHasRelativeAltitudeChanged (bool coordinateHasRelativeAltitude);
void exitCoordinateHasRelativeAltitudeChanged (bool exitCoordinateHasRelativeAltitude); void exitCoordinateHasRelativeAltitudeChanged (bool exitCoordinateHasRelativeAltitude);
...@@ -218,22 +226,24 @@ signals: ...@@ -218,22 +226,24 @@ signals:
protected: protected:
Vehicle* _vehicle; Vehicle* _vehicle;
bool _flyView; bool _flyView = false;
bool _isCurrentItem; bool _isCurrentItem = false;
bool _dirty; bool _hasCurrentChildItem = false;
bool _homePositionSpecialCase; ///< true: This item is being used as a ui home position indicator bool _dirty = false;
double _terrainAltitude; ///< Altitude of terrain at coordinate position, NaN for not known bool _homePositionSpecialCase = false; ///< true: This item is being used as a ui home position indicator
double _altDifference; ///< Difference in altitude from previous waypoint bool _wizardMode = false; ///< true: Item editor is showing wizard completion panel
double _altPercent; ///< Percent of total altitude change in mission double _terrainAltitude = qQNaN(); ///< Altitude of terrain at coordinate position, NaN for not known
double _terrainPercent; ///< Percent of terrain altitude for coordinate double _altDifference = 0; ///< Difference in altitude from previous waypoint
bool _terrainCollision; ///< true: item collides with terrain double _altPercent = 0; ///< Percent of total altitude change in mission
double _azimuth; ///< Azimuth to previous waypoint double _terrainPercent = qQNaN(); ///< Percent of terrain altitude for coordinate
double _distance; ///< Distance to previous waypoint bool _terrainCollision = false; ///< true: item collides with terrain
double _azimuth = 0; ///< Azimuth to previous waypoint
double _distance = 0; ///< Distance to previous waypoint
QString _editorQml; ///< Qml resource for editing item QString _editorQml; ///< Qml resource for editing item
double _missionGimbalYaw; double _missionGimbalYaw = qQNaN();
double _missionVehicleYaw; double _missionVehicleYaw = qQNaN();
bool _wizardMode; ///< true: Item editor is showing wizard completion panel
VisualMissionItem* _parentItem = nullptr;
QGCGeoBoundingCube _boundingCube; ///< The bounding "cube" of this element. QGCGeoBoundingCube _boundingCube; ///< The bounding "cube" of this element.
MissionController::MissionFlightStatus_t _missionFlightStatus; MissionController::MissionFlightStatus_t _missionFlightStatus;
...@@ -253,6 +263,6 @@ private: ...@@ -253,6 +263,6 @@ private:
void _commonInit(void); void _commonInit(void);
QTimer _updateTerrainTimer; QTimer _updateTerrainTimer;
double _lastLatTerrainQuery; double _lastLatTerrainQuery = 0;
double _lastLonTerrainQuery; double _lastLonTerrainQuery = 0;
}; };
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