PlanElementController.h 3.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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"

/// 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:
    PlanElementController(QObject* parent = NULL);
    ~PlanElementController();
    
28 29 30 31 32
    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
    Q_PROPERTY(QString  fileExtension   READ fileExtension                  CONSTANT)                       ///< Returns the file extention for plan element file type.
    Q_PROPERTY(Vehicle* vehicle         READ vehicle                        NOTIFY vehicleChanged)
33

34 35
    virtual QString fileExtension(void) const = 0;

36

37 38 39 40
    /// Should be called immediately upon Component.onCompleted.
    ///     @param editMode true: controller being used in Plan view, false: controller being used in Fly view
    Q_INVOKABLE virtual void start(bool editMode);

41 42 43 44
    /// Starts the controller using a single static active vehicle. Will not track global active vehicle changes.
    ///     @param editMode true: controller being used in Plan view, false: controller being used in Fly view
    Q_INVOKABLE virtual void startStaticActiveVehicle(Vehicle* vehicle);

45 46 47 48 49 50
    Q_INVOKABLE virtual void loadFromVehicle(void) = 0;
    Q_INVOKABLE virtual void sendToVehicle(void) = 0;
    Q_INVOKABLE virtual void loadFromFilePicker(void) = 0;
    Q_INVOKABLE virtual void loadFromFile(const QString& filename) = 0;
    Q_INVOKABLE virtual void saveToFilePicker(void) = 0;
    Q_INVOKABLE virtual void saveToFile(const QString& filename) = 0;
51 52
    Q_INVOKABLE virtual void removeAll(void) = 0;                       ///< Removes all from controller only, synce required to remove from vehicle
    Q_INVOKABLE virtual void removeAllFromVehicle(void) = 0;            ///< Removes all from vehicle and controller
53

54
    virtual bool containsItems  (void) const = 0;
55 56 57 58
    virtual bool syncInProgress (void) const = 0;
    virtual bool dirty          (void) const = 0;
    virtual void setDirty       (bool dirty) = 0;

59 60
    Vehicle* vehicle(void) { return _activeVehicle; }

61
signals:
62
    void containsItemsChanged   (bool containsItems);
63 64
    void syncInProgressChanged  (bool syncInProgress);
    void dirtyChanged           (bool dirty);
65
    void vehicleChanged         (Vehicle* vehicle);
66 67 68

protected:
    MultiVehicleManager*    _multiVehicleMgr;
69
    Vehicle*                _activeVehicle;     ///< Currently active vehicle, can be disconnected offline editing vehicle
70 71
    bool                    _editMode;

72 73 74
    /// Called when the current active vehicle is about to be removed. Derived classes should override
    /// to implement custom behavior.
    virtual void _activeVehicleBeingRemoved(void) = 0;
75 76 77 78 79 80 81 82 83 84

    /// Called when a new active vehicle has been set. Derived classes should override
    /// to implement custom behavior.
    virtual void _activeVehicleSet(void) = 0;

private slots:
    void _activeVehicleChanged(Vehicle* activeVehicle);
};

#endif