5#include <QtCore/QPersistentModelIndex>
6#include <QtCore/QVariant>
7#include <QtPositioning/QGeoCoordinate>
8#include <QtQmlIntegration/QtQmlIntegration>
41 Q_MOC_INCLUDE(
"FlightPathSegment.h")
42 Q_MOC_INCLUDE(
"VisualMissionItem.h")
43 Q_MOC_INCLUDE(
"TakeoffMissionItem.h")
65 Q_PROPERTY(QGeoCoordinate previousCoordinate MEMBER _previousCoordinate NOTIFY
planViewStateChanged)
85 Q_PROPERTY(
bool onlyInsertTakeoffValid MEMBER _onlyInsertTakeoffValid NOTIFY
planViewStateChanged)
92 Q_PROPERTY(
bool flyThroughCommandsAllowed MEMBER _flyThroughCommandsAllowed NOTIFY
planViewStateChanged)
177 bool repositionTakeoffItems =
true,
178 bool repositionLandingItems =
true);
191 double upMeters = 0.0,
192 bool offsetTakeoffItems =
false,
193 bool offsetLandingItems =
false);
206 bool rotateTakeoffItems =
false,
207 bool rotateLandingItems =
false);
234 void start (
bool flyView)
final;
235 void save (QJsonObject& json)
final;
242 bool dirty (
void)
const final;
341 void _newMissionItemsAvailableFromVehicle (
bool removeAllRequested);
342 void _itemCommandChanged (
void);
343 void _inProgressChanged (
bool inProgress);
344 void _currentMissionIndexChanged (
int sequenceNumber);
345 void _recalcFlightPathSegments (
void);
346 void _recalcMissionFlightStatus (
void);
348 void _visualItemsDirtyChanged (
bool dirty);
349 void _managerSendComplete (
bool error);
350 void _managerRemoveAllComplete (
bool error);
351 void _updateTimeout (
void);
352 void _complexBoundingBoxChanged (
void);
353 void _recalcAll (
void);
354 void _managerVehicleChanged (
Vehicle* managerVehicle);
355 void _forceRecalcOfAllowedBits (
void);
357 void _syncTreeMissionItemsInserted (
const QModelIndex& parent,
int first,
int last);
358 void _syncTreeMissionItemsAboutToBeRemoved (
const QModelIndex& parent,
int first,
int last);
359 void _syncTreeMissionItemsReset (
void);
360 void _syncTreeRallyPointsInserted (
const QModelIndex& parent,
int first,
int last);
361 void _syncTreeRallyPointsAboutToBeRemoved (
const QModelIndex& parent,
int first,
int last);
362 void _syncTreeRallyPointsRemoved (
const QModelIndex& parent,
int first,
int last);
364 void _syncTreeRallyPointsReset (
void);
367 void _setupTreeModel (
void);
368 void _recalcSequence (
void);
369 void _recalcChildItems (
void);
370 void _recalcAllWithCoordinate (
const QGeoCoordinate& coordinate);
372 void _initAllVisualItems (
void);
373 void _deinitAllVisualItems (
void);
376 void _setupActiveVehicle (
Vehicle* activeVehicle,
bool forceLoadFromVehicle);
381 int _nextSequenceNumber (
void);
383 void _setPlannedHomePositionFromFirstCoordinate(
const QGeoCoordinate& clickCoordinate);
384 void _resetMissionFlightStatus (
void);
387 VisualMissionItem* _insertSimpleMissionItemWorker (QGeoCoordinate coordinate, MAV_CMD command,
int visualItemIndex,
bool makeCurrentItem);
388 void _insertComplexMissionItemWorker (
const QGeoCoordinate& mapCenterCoordinate,
ComplexMissionItem* complexItem,
int visualItemIndex,
bool makeCurrentItem);
392 void _allItemsRemoved (
void);
393 void _firstItemAdded (
void);
395 static double _normalizeLat (
double lat);
396 static double _normalizeLon (
double lon);
397 static bool _convertToMissionItems (
QmlObjectListModel* visualMissionItems, QList<MissionItem*>& rgMissionItems, QObject* missionItemParent);
400 Vehicle* _controllerVehicle =
nullptr;
401 Vehicle* _managerVehicle =
nullptr;
404 QPersistentModelIndex _planFileGroupIndex;
405 QPersistentModelIndex _defaultsGroupIndex;
406 QPersistentModelIndex _missionGroupIndex;
407 QPersistentModelIndex _fenceGroupIndex;
408 QPersistentModelIndex _rallyGroupIndex;
409 QPersistentModelIndex _transformGroupIndex;
410 QObject _planFileGroupNode;
411 QObject _planFileInfoMarker;
412 QObject _defaultsGroupNode;
413 QObject _defaultsInfoMarker;
414 QObject _missionItemsGroupNode;
415 QObject _fenceGroupNode;
416 QObject _rallyGroupNode;
417 QObject _transformGroupNode;
418 QObject _fenceEditorMarker;
419 QObject _rallyHeaderMarker;
420 QObject _transformEditorMarker;
427 bool _firstItemsFromVehicle =
false;
428 bool _itemsRequested =
false;
429 bool _inRecalcSequence =
false;
433 double _progressPct = 0;
434 int _currentPlanViewSeqNum = -1;
435 int _currentPlanViewVIIndex = -1;
440 QGeoCoordinate _takeoffCoordinate;
441 QGeoCoordinate _previousCoordinate;
443 bool _delayedSplitSegmentUpdate =
false;
444 bool _onlyInsertTakeoffValid =
true;
445 bool _isInsertTakeoffValid =
true;
446 bool _isInsertLandValid =
false;
447 bool _hasLandItem =
false;
448 bool _isROIActive =
false;
449 bool _flyThroughCommandsAllowed =
false;
450 bool _isROIBeginCurrentItem =
false;
451 double _minAMSLAltitude = 0;
452 double _maxAMSLAltitude = 0;
453 bool _missionContainsVTOLTakeoff =
false;
457 static constexpr const char* _settingsGroup =
"MissionController";
458 static constexpr const char* _jsonItemsKey =
"items";
459 static constexpr const char* _jsonPlannedHomePositionKey =
"plannedHomePosition";
460 static constexpr const char* _jsonFirmwareTypeKey =
"firmwareType";
461 static constexpr const char* _jsonVehicleTypeKey =
"vehicleType";
462 static constexpr const char* _jsonCruiseSpeedKey =
"cruiseSpeed";
463 static constexpr const char* _jsonHoverSpeedKey =
"hoverSpeed";
464 static constexpr const char* _jsonParamsKey =
"params";
465 static constexpr const char* _jsonGlobalPlanAltitudeModeKey =
"globalPlanAltitudeMode";
467 static constexpr int _missionFileVersion = 2;
QPair< VisualMissionItem *, VisualMissionItem * > VisualItemPair
QHash< VisualItemPair, FlightPathSegment * > FlightPathSegmentHashTable
Used to convert a Plan to a KML document.
void minAMSLAltitudeChanged(double minAMSLAltitude)
Q_INVOKABLE void resumeMission(int resumeIndex)
static constexpr int kDefaultsGroupRow
double missionHoverDistance(void) const
double progressPct(void) const
Q_INVOKABLE int visualItemIndexForObject(QObject *object) const
Returns the visual item index for the given VisualMissionItem object, or -1 if not found.
void complexMissionItemsChanged(void)
Q_INVOKABLE void setHomePosition(QGeoCoordinate coordinate)
Set the planned home position from a map click.
VisualMissionItem * currentPlanViewItem(void) const
bool showPlanFromManagerVehicle(void) final
Q_INVOKABLE SendToVehiclePreCheckState sendToVehiclePreCheck(void)
bool dirty(void) const final
static constexpr int kMissionGroupRow
Q_INVOKABLE VisualMissionItem * insertComplexMissionItem(QString itemName, QGeoCoordinate mapCenterCoordinate, int visualItemIndex, bool makeCurrentItem=false)
QmlObjectTreeModel * visualItemsTree(void)
void batteriesRequiredChanged(int batteriesRequired)
double missionTime(void) const
bool loadTextFile(QFile &file, QString &errorString)
QmlObjectListModel * directionArrows(void)
void multipleLandPatternsAllowedChanged(void)
double minAMSLAltitude(void) const
double missionPlannedDistance(void) const
bool multipleLandPatternsAllowed(void) const
Q_INVOKABLE VisualMissionItem * insertTakeoffItem(QGeoCoordinate coordinate, int visualItemIndex, bool makeCurrentItem=false)
QGeoCoordinate takeoffCoordinate()
Q_INVOKABLE VisualMissionItem * insertLandItem(QGeoCoordinate coordinate, int visualItemIndex, bool makeCurrentItem=false)
Q_INVOKABLE void offsetMission(double eastMeters, double northMeters, double upMeters=0.0, bool offsetTakeoffItems=false, bool offsetLandingItems=false)
Q_INVOKABLE void setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
double maxAMSLAltitude(void) const
void maxAMSLAltitudeChanged(double maxAMSLAltitude)
void removeAllFromVehicle(void) final
void homePositionSetChanged(void)
void recalcTerrainProfile(void)
void missionPlannedDistanceChanged(double missionPlannedDistance)
void missionTotalDistanceChanged(double missionTotalDistance)
QPersistentModelIndex planFileGroupIndex(void) const
void hasLandItemChanged(void)
void _recalcFlightPathSegmentsSignal(void)
QPersistentModelIndex fenceGroupIndex(void) const
int currentMissionIndex(void) const
void missionMaxTelemetryChanged(double missionMaxTelemetry)
static void sendItemsToVehicle(Vehicle *vehicle, QmlObjectListModel *visualMissionItems)
Sends the mission items to the specified vehicle.
bool load(const QJsonObject &json, QString &errorString) final
double missionMaxTelemetry(void) const
void splitSegmentChanged(void)
Q_INVOKABLE void repositionMission(const QGeoCoordinate &newHome, bool repositionTakeoffItems=true, bool repositionLandingItems=true)
void resumeMissionReady(void)
SendToVehiclePreCheckState
@ SendToVehiclePreCheckStateFirwmareVehicleMismatch
@ SendToVehiclePreCheckStateNoActiveVehicle
@ SendToVehiclePreCheckStateOk
@ SendToVehiclePreCheckStateActiveMission
void batteryChangePointChanged(int batteryChangePoint)
void takeoffMissionItemChanged(void)
Q_INVOKABLE void rotateMission(double degreesCW, bool rotateTakeoffItems=false, bool rotateLandingItems=false)
static constexpr int kGroupCount
void addMissionToKML(KMLPlanDomDocument &planKML)
void _recalcMissionFlightStatusSignal(void)
int batteriesRequired(void) const
-1 for not supported
void missionHoverDistanceChanged(double missionHoverDistance)
static constexpr int kFenceGroupRow
bool syncInProgress(void) const final
QPersistentModelIndex defaultsGroupIndex(void) const
TakeoffMissionItem * takeoffMissionItem(void) const
static constexpr int kRallyGroupRow
void sendToVehicle(void) final
void resumeMissionIndexChanged(void)
void currentMissionIndexChanged(int currentMissionIndex)
int batteryChangePoint(void) const
-1 for not supported, 0 for not needed
Q_INVOKABLE VisualMissionItem * insertROIMissionItem(QGeoCoordinate coordinate, int visualItemIndex, bool makeCurrentItem=false)
void plannedHomePositionChanged(QGeoCoordinate plannedHomePosition)
Q_INVOKABLE void removeVisualItem(int viIndex)
void newItemsFromVehicle(void)
void setGlobalAltitudeFrame(QGroundControlQmlGlobal::AltitudeFrame altFrame)
int currentPlanViewVIIndex(void) const
void save(QJsonObject &json) final
double missionCruiseDistance(void) const
Q_INVOKABLE VisualMissionItem * insertSimpleMissionItem(QGeoCoordinate coordinate, int visualItemIndex, bool makeCurrentItem=false)
void missionHoverTimeChanged(void)
bool isFirstLandingComplexItem(const LandingComplexItem *item) const
QGeoCoordinate plannedHomePosition(void) const
QPersistentModelIndex transformGroupIndex(void) const
bool homePositionSet(void) const
bool containsItems(void) const final
void progressPctChanged(double progressPct)
void missionCruiseTimeChanged(void)
QPersistentModelIndex missionGroupIndex(void) const
QGroundControlQmlGlobal::AltitudeFrame globalAltitudeFrame(void)
int readyForSaveState(void) const
static constexpr int kPlanFileGroupRow
QGroundControlQmlGlobal::AltitudeFrame globalAltitudeFrameDefault(void)
int currentPlanViewSeqNum(void) const
void removeAll(void) final
Removes all from controller only.
::MissionFlightStatus_t MissionFlightStatus_t
Default to use for newly created items.
void visualItemsReset(void)
void missionBoundingCubeChanged(void)
bool isInsertTakeoffValid(void) const
double missionCruiseTime(void) const
QVariantList complexMissionItems(void) const
void missionTimeChanged(void)
QPersistentModelIndex rallyGroupIndex(void) const
Q_INVOKABLE void applyDefaultMissionAltitude(void)
Updates the altitudes of the items in the current mission to the new default altitude.
void setDirty(bool dirty) final
void start(bool flyView) final
Should be called immediately upon Component.onCompleted.
QGCGeoBoundingCube * travelBoundingCube()
void planViewStateChanged(void)
All plan-view properties are recomputed together in setCurrentPlanViewSeqNum, so one signal covers th...
void globalAltitudeFrameChanged(void)
void missionCruiseDistanceChanged(double missionCruiseDistance)
double missionTotalDistance(void) const
void resumeMissionUploadFail(void)
void loadFromVehicle(void) final
double missionHoverTime(void) const
QmlObjectListModel * simpleFlightPathSegments(void)
bool supported(void) const final
true: controller is waiting for the current load to complete
Q_INVOKABLE VisualMissionItem * insertCancelROIMissionItem(int visualItemIndex, bool makeCurrentItem=false)
static constexpr int kTransformGroupRow
int resumeMissionIndex(void) const
Q_INVOKABLE VisualMissionItem * insertComplexMissionItemFromKMLOrSHP(QString itemName, QString file, int visualItemIndex, bool makeCurrentItem=false)
QmlObjectListModel * visualItems(void)
Computes mission flight status (distances, times, battery, altitude range)
This is the abstract base clas for Plan Element controllers.
PlanMasterController * masterController(void)
Master controller for mission, fence, rally.
A tree model for QObject* items, usable from both C++ and QML.
A SimpleMissionItem is used to represent a single MissionItem to the ui.
Takeoff mission item is a special case of a SimpleMissionItem which supports Launch Location display/...
int batteriesRequired
-1 for not supported
double maxTelemetryDistance
int batteryChangePoint
-1 for not supported, 0 for not needed