PlanElementController.h 3.27 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#ifndef PlanElementController_H
#define PlanElementController_H

#include <QObject>

#include "Vehicle.h"
#include "MultiVehicleManager.h"

18 19
class PlanMasterController;

20 21 22 23 24 25 26
/// This is the abstract base clas for Plan Element controllers.
/// Examples of plan elements are: missions (MissionController), geofence (GeoFenceController)
class PlanElementController : public QObject
{
    Q_OBJECT
    
public:
27
    PlanElementController(PlanMasterController* masterController, QObject* parent = nullptr);
28 29
    ~PlanElementController();
    
30 31 32 33 34 35 36
    Q_PROPERTY(PlanMasterController*    masterController    READ masterController               CONSTANT)
    Q_PROPERTY(bool                     supported           READ supported                      NOTIFY supportedChanged)        ///< true: Element is supported by Vehicle
    Q_PROPERTY(bool                     containsItems       READ containsItems                  NOTIFY containsItemsChanged)    ///< true: Elemement is non-empty
    Q_PROPERTY(bool                     syncInProgress      READ syncInProgress                 NOTIFY syncInProgressChanged)   ///< true: information is currently being saved/sent, false: no active save/send in progress
    Q_PROPERTY(bool                     dirty               READ dirty          WRITE setDirty  NOTIFY dirtyChanged)            ///< true: unsaved/sent changes are present, false: no changes since last save/send

    PlanMasterController* masterController(void) { return _masterController; }
37

38
    /// Should be called immediately upon Component.onCompleted.
39
    virtual void start(bool flyView);
40

DonLakeFlyer's avatar
DonLakeFlyer committed
41 42 43 44 45
    virtual void save                       (QJsonObject& json) = 0;
    virtual bool load                       (const QJsonObject& json, QString& errorString) = 0;
    virtual void loadFromVehicle            (void) = 0;
    virtual void removeAll                  (void) = 0;     ///< Removes all from controller only
    virtual bool showPlanFromManagerVehicle (void) = 0;     /// true: controller is waiting for the current load to complete
46

47 48 49 50 51
    virtual bool    supported       (void) const = 0;
    virtual bool    containsItems   (void) const = 0;
    virtual bool    syncInProgress  (void) const = 0;
    virtual bool    dirty           (void) const = 0;
    virtual void    setDirty        (bool dirty) = 0;
52

DonLakeFlyer's avatar
DonLakeFlyer committed
53 54 55 56 57 58 59 60
    /// Sends the current plan element to the vehicle
    ///     Signals sendComplete when done
    virtual void sendToVehicle(void) = 0;

    /// Removes all from vehicle and controller
    ///     Signals removeAllComplete when done
    virtual void removeAllFromVehicle(void) = 0;

61
signals:
62
    void supportedChanged       (bool supported);
63
    void containsItemsChanged   (bool containsItems);
64 65
    void syncInProgressChanged  (bool syncInProgress);
    void dirtyChanged           (bool dirty);
DonLakeFlyer's avatar
DonLakeFlyer committed
66 67
    void sendComplete           (void);
    void removeAllComplete      (void);
68 69

protected:
70
    PlanMasterController*   _masterController;
71
    bool                    _flyView;
72 73 74
};

#endif