Commit 3924f851 authored by Don Gagne's avatar Don Gagne

parent e1e6df46
......@@ -244,6 +244,17 @@ FlightMap {
}
}
MapItemView {
model: mainIsMap ? _missionController.directionArrows : undefined
delegate: MapLineArrow {
fromCoord: object ? object.coordinate1 : undefined
toCoord: object ? object.coordinate2 : undefined
arrowPosition: 2
z: QGroundControl.zOrderWaypointLines
}
}
// Allow custom builds to add map items
CustomMapItems {
map: flightMap
......
......@@ -1101,7 +1101,7 @@ CoordinateVector* MissionController::_addWaypointLineSegment(CoordVectHashTable&
void MissionController::_recalcWaypointLines(void)
{
int segmentCount = 0;
CoordinateVector* lastCoordVector = nullptr;
VisualItemPair lastSegmentVisualItemPair;
bool firstCoordinateItem = true;
VisualMissionItem* lastCoordinateItem = qobject_cast<VisualMissionItem*>(_visualItems->get(0));
......@@ -1138,6 +1138,22 @@ void MissionController::_recalcWaypointLines(void)
if (item->specifiesCoordinate() && !item->isStandaloneCoordinate()) {
if (lastCoordinateItem != _settingsItem || (homePositionValid && linkStartToHome)) {
#if 1
// Direction arrows are added to the first segment and every 5 segments in the middle.
bool addDirectionArrow = false;
if (firstCoordinateItem || !lastCoordinateItem->isSimpleItem() || !item->isSimpleItem()) {
addDirectionArrow = true;
} else if (segmentCount > 5) {
segmentCount = 0;
addDirectionArrow = true;
}
segmentCount++;
lastSegmentVisualItemPair = VisualItemPair(lastCoordinateItem, item);
if (!_flyView || addDirectionArrow) {
_directionArrows.append(_addWaypointLineSegment(old_table, lastSegmentVisualItemPair));
}
#else
if (!_flyView) {
VisualItemPair pair(lastCoordinateItem, item);
lastCoordVector = _addWaypointLineSegment(old_table, pair);
......@@ -1149,6 +1165,7 @@ void MissionController::_recalcWaypointLines(void)
_directionArrows.append(lastCoordVector);
}
}
#endif
}
firstCoordinateItem = false;
_waypointPath.append(QVariant::fromValue(item->coordinate()));
......@@ -1161,15 +1178,36 @@ void MissionController::_recalcWaypointLines(void)
}
if (linkEndToHome && lastCoordinateItem != _settingsItem && homePositionValid) {
if (!_flyView) {
VisualItemPair pair(lastCoordinateItem, _settingsItem);
lastCoordVector = _addWaypointLineSegment(old_table, pair);
} else {
lastSegmentVisualItemPair = VisualItemPair(lastCoordinateItem, _settingsItem);
if (_flyView) {
_waypointPath.append(QVariant::fromValue(_settingsItem->coordinate()));
}
_addWaypointLineSegment(old_table, lastSegmentVisualItemPair);
}
{
// Add direction arrow to last segment
if (lastSegmentVisualItemPair.first) {
CoordinateVector* coordVector = nullptr;
// The pair may not be in the hash, this can happen in the fly view where only segments with arrows on them are added to ahsh.
// check for that first and add if needed
if (_linesTable.contains(lastSegmentVisualItemPair)) {
// Pair exists in the new table already just reuse it
coordVector = _linesTable[lastSegmentVisualItemPair];
} else if (old_table.contains(lastSegmentVisualItemPair)) {
// Pair already exists in old table, pull from old to new and reuse
_linesTable[lastSegmentVisualItemPair] = coordVector = old_table.take(lastSegmentVisualItemPair);
} else {
// Create a new segment. Since this is the fly view there is no need to wire change signals.
coordVector = new CoordinateVector(lastSegmentVisualItemPair.first->isSimpleItem() ? lastSegmentVisualItemPair.first->coordinate() : lastSegmentVisualItemPair.first->exitCoordinate(), lastSegmentVisualItemPair.second->coordinate(), this);
_linesTable[lastSegmentVisualItemPair] = coordVector;
}
_directionArrows.append(coordVector);
}
if (!_flyView) {
// Create a temporary QObjectList and replace the model data
QObjectList objs;
objs.reserve(_linesTable.count());
......@@ -1184,10 +1222,6 @@ void MissionController::_recalcWaypointLines(void)
// Anything left in the old table is an obsolete line object that can go
qDeleteAll(old_table);
if (lastCoordVector) {
_directionArrows.append(lastCoordVector);
}
_recalcMissionFlightStatus();
if (_waypointPath.count() == 0) {
......
......@@ -7,10 +7,6 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "CoordinateVector.h"
CoordinateVector::CoordinateVector(QObject* parent)
......
......@@ -7,7 +7,6 @@
*
****************************************************************************/
#ifndef CoordinateVector_H
#define CoordinateVector_H
......@@ -24,7 +23,10 @@ public:
Q_PROPERTY(QGeoCoordinate coordinate1 MEMBER _coordinate1 NOTIFY coordinate1Changed)
Q_PROPERTY(QGeoCoordinate coordinate2 MEMBER _coordinate2 NOTIFY coordinate2Changed)
QGeoCoordinate coordinate1(void) const { return _coordinate1; }
QGeoCoordinate coordinate2(void) const { return _coordinate2; }
void setCoordinates(const QGeoCoordinate& coordinate1, const QGeoCoordinate& coordinate2);
public slots:
......
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