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)
92 Q_PROPERTY(
bool flyThroughCommandsAllowed MEMBER _flyThroughCommandsAllowed NOTIFY
planViewStateChanged)
127 QGeoCoordinate coordinate,
int visualItemIndex,
bool makeCurrentItem =
false);
185 bool repositionTakeoffItems =
true,
186 bool repositionLandingItems =
true);
199 double upMeters = 0.0,
200 bool offsetTakeoffItems =
false,
201 bool offsetLandingItems =
false);
214 bool rotateTakeoffItems =
false,
215 bool rotateLandingItems =
false);
242 void start (
bool flyView)
final;
243 void save (QJsonObject& json)
final;
250 bool dirty (
void)
const final;
349 void _newMissionItemsAvailableFromVehicle (
bool removeAllRequested);
350 void _itemCommandChanged (
void);
351 void _inProgressChanged (
bool inProgress);
352 void _currentMissionIndexChanged (
int sequenceNumber);
353 void _recalcFlightPathSegments (
void);
354 void _recalcMissionFlightStatus (
void);
356 void _visualItemsDirtyChanged (
bool dirty);
357 void _managerSendComplete (
bool error);
358 void _managerRemoveAllComplete (
bool error);
359 void _updateTimeout (
void);
360 void _complexBoundingBoxChanged (
void);
361 void _recalcAll (
void);
362 void _managerVehicleChanged (
Vehicle* managerVehicle);
363 void _recalcPlanViewState (
void);
365 void _syncTreeMissionItemsInserted (
const QModelIndex& parent,
int first,
int last);
366 void _syncTreeMissionItemsAboutToBeRemoved (
const QModelIndex& parent,
int first,
int last);
367 void _syncTreeMissionItemsReset (
void);
368 void _syncTreeRallyPointsInserted (
const QModelIndex& parent,
int first,
int last);
369 void _syncTreeRallyPointsAboutToBeRemoved (
const QModelIndex& parent,
int first,
int last);
370 void _syncTreeRallyPointsRemoved (
const QModelIndex& parent,
int first,
int last);
372 void _syncTreeRallyPointsReset (
void);
375 void _setupTreeModel (
void);
376 void _recalcSequence (
void);
377 void _recalcChildItems (
void);
378 void _recalcAllWithCoordinate (
const QGeoCoordinate& coordinate);
380 void _initAllVisualItems (
void);
381 void _deinitAllVisualItems (
void);
384 void _setupActiveVehicle (
Vehicle* activeVehicle,
bool forceLoadFromVehicle);
389 int _nextSequenceNumber (
void);
391 void _setPlannedHomePositionFromFirstCoordinate(
const QGeoCoordinate& clickCoordinate);
392 void _resetMissionFlightStatus (
void);
395 VisualMissionItem* _insertSimpleMissionItemWorker (QGeoCoordinate coordinate, MAV_CMD command,
int visualItemIndex,
bool makeCurrentItem);
396 VisualMissionItem* _insertTakeoffItemWorker (MAV_CMD command,
int visualItemIndex,
bool makeCurrentItem);
397 void _insertComplexMissionItemWorker (
const QGeoCoordinate& mapCenterCoordinate,
ComplexMissionItem* complexItem,
int visualItemIndex,
bool makeCurrentItem);
401 void _allItemsRemoved (
void);
402 void _firstItemAdded (
void);
404 static double _normalizeLat (
double lat);
405 static double _normalizeLon (
double lon);
406 static bool _convertToMissionItems (
QmlObjectListModel* visualMissionItems, QList<MissionItem*>& rgMissionItems, QObject* missionItemParent);
409 Vehicle* _controllerVehicle =
nullptr;
410 Vehicle* _managerVehicle =
nullptr;
413 QPersistentModelIndex _planFileGroupIndex;
414 QPersistentModelIndex _defaultsGroupIndex;
415 QPersistentModelIndex _missionGroupIndex;
416 QPersistentModelIndex _fenceGroupIndex;
417 QPersistentModelIndex _rallyGroupIndex;
418 QPersistentModelIndex _transformGroupIndex;
419 QObject _planFileGroupNode;
420 QObject _planFileInfoMarker;
421 QObject _defaultsGroupNode;
422 QObject _defaultsInfoMarker;
423 QObject _missionItemsGroupNode;
424 QObject _fenceGroupNode;
425 QObject _rallyGroupNode;
426 QObject _transformGroupNode;
427 QObject _fenceEditorMarker;
428 QObject _rallyHeaderMarker;
429 QObject _transformEditorMarker;
436 bool _firstItemsFromVehicle =
false;
437 bool _itemsRequested =
false;
438 bool _inRecalcSequence =
false;
442 double _progressPct = 0;
443 int _currentPlanViewSeqNum = -1;
444 int _currentPlanViewVIIndex = -1;
449 QGeoCoordinate _takeoffCoordinate;
450 QGeoCoordinate _previousCoordinate;
452 bool _isInsertTakeoffValid =
true;
453 bool _isInsertLandValid =
false;
454 bool _isInsertROIValid =
false;
455 bool _hasLandItem =
false;
456 bool _isROIActive =
false;
457 bool _flyThroughCommandsAllowed =
false;
458 bool _isROIBeginCurrentItem =
false;
459 double _minAMSLAltitude = 0;
460 double _maxAMSLAltitude = 0;
461 bool _missionStartsInVTOLMulticopterMode =
false;
465 static constexpr const char* _settingsGroup =
"MissionController";
466 static constexpr const char* _jsonItemsKey =
"items";
467 static constexpr const char* _jsonPlannedHomePositionKey =
"plannedHomePosition";
468 static constexpr const char* _jsonFirmwareTypeKey =
"firmwareType";
469 static constexpr const char* _jsonVehicleTypeKey =
"vehicleType";
470 static constexpr const char* _jsonCruiseSpeedKey =
"cruiseSpeed";
471 static constexpr const char* _jsonHoverSpeedKey =
"hoverSpeed";
472 static constexpr const char* _jsonParamsKey =
"params";
473 static constexpr const char* _jsonGlobalPlanAltitudeModeKey =
"globalPlanAltitudeMode";
475 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)
Q_INVOKABLE VisualMissionItem * insertVTOLMulticopterTakeoffItem(QGeoCoordinate coordinate, int visualItemIndex, bool makeCurrentItem=false)
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