QGCToolbox.cc 4.97 KB
Newer Older
1 2 3 4 5 6 7 8
 /****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
9 10


Don Gagne's avatar
Don Gagne committed
11 12
#include "FactSystem.h"
#include "FirmwarePluginManager.h"
13
#include "AudioOutput.h"
14
#ifndef __mobile__
15
#include "GPSManager.h"
Don Gagne's avatar
Don Gagne committed
16
#endif
17
#include "JoystickManager.h"
Don Gagne's avatar
Don Gagne committed
18 19
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
20
#include "MissionCommandTree.h"
Don Gagne's avatar
Don Gagne committed
21
#include "MultiVehicleManager.h"
dogmaphobic's avatar
dogmaphobic committed
22
#include "QGCImageProvider.h"
Don Gagne's avatar
Don Gagne committed
23
#include "UASMessageHandler.h"
dogmaphobic's avatar
dogmaphobic committed
24
#include "QGCMapEngineManager.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
25
#include "FollowMe.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
26
#include "PositionManager.h"
27
#include "VideoManager.h"
Gus Grubba's avatar
Gus Grubba committed
28
#include "MAVLinkLogManager.h"
29 30
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
31
#include "SettingsManager.h"
32
#include "QGCApplication.h"
33
#if defined(QGC_AIRMAP_ENABLED)
34
#include "AirMapManager.h"
35 36
#else
#include "AirspaceManager.h"
37
#endif
38 39 40 41

#if defined(QGC_CUSTOM_BUILD)
#include CUSTOMHEADER
#endif
42 43

QGCToolbox::QGCToolbox(QGCApplication* app)
44 45
    : _audioOutput          (NULL)
    , _factSystem           (NULL)
Don Gagne's avatar
Don Gagne committed
46
    , _firmwarePluginManager(NULL)
Don Gagne's avatar
Don Gagne committed
47
#ifndef __mobile__
48
    , _gpsManager           (NULL)
Don Gagne's avatar
Don Gagne committed
49
#endif
50 51 52 53 54 55 56 57 58 59 60 61 62 63
    , _imageProvider        (NULL)
    , _joystickManager      (NULL)
    , _linkManager          (NULL)
    , _mavlinkProtocol      (NULL)
    , _missionCommandTree   (NULL)
    , _multiVehicleManager  (NULL)
    , _mapEngineManager     (NULL)
    , _uasMessageHandler    (NULL)
    , _followMe             (NULL)
    , _qgcPositionManager   (NULL)
    , _videoManager         (NULL)
    , _mavlinkLogManager    (NULL)
    , _corePlugin           (NULL)
    , _settingsManager      (NULL)
64
    , _airspaceManager      (NULL)
65
{
66
    // SettingsManager must be first so settings are available to any subsequent tools
67
    _settingsManager =          new SettingsManager(app, this);
68

69 70
    //-- Scan and load plugins
    _scanAndLoadPlugins(app);
71
    _audioOutput =              new AudioOutput             (app, this);
72 73
    _factSystem =               new FactSystem              (app, this);
    _firmwarePluginManager =    new FirmwarePluginManager   (app, this);
74
#ifndef __mobile__
75
    _gpsManager =               new GPSManager              (app, this);
Don Gagne's avatar
Don Gagne committed
76
#endif
77 78 79 80 81 82 83 84 85 86 87 88
    _imageProvider =            new QGCImageProvider        (app, this);
    _joystickManager =          new JoystickManager         (app, this);
    _linkManager =              new LinkManager             (app, this);
    _mavlinkProtocol =          new MAVLinkProtocol         (app, this);
    _missionCommandTree =       new MissionCommandTree      (app, this);
    _multiVehicleManager =      new MultiVehicleManager     (app, this);
    _mapEngineManager =         new QGCMapEngineManager     (app, this);
    _uasMessageHandler =        new UASMessageHandler       (app, this);
    _qgcPositionManager =       new QGCPositionManager      (app, this);
    _followMe =                 new FollowMe                (app, this);
    _videoManager =             new VideoManager            (app, this);
    _mavlinkLogManager =        new MAVLinkLogManager       (app, this);
89 90 91
    //-- Airmap Manager
    //-- This should be "pluggable" so an arbitrary AirSpace manager can be used
    //-- For now, we instantiate the one and only AirMap provider
92
#if defined(QGC_AIRMAP_ENABLED)
93
    _airspaceManager =          new AirMapManager           (app, this);
94 95
#else
    _airspaceManager =          new AirspaceManager         (app, this);
96
#endif
97
}
98

99 100
void QGCToolbox::setChildToolboxes(void)
{
101 102 103
    // SettingsManager must be first so settings are available to any subsequent tools
    _settingsManager->setToolbox(this);

104
    _corePlugin->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
105 106 107
    _audioOutput->setToolbox(this);
    _factSystem->setToolbox(this);
    _firmwarePluginManager->setToolbox(this);
108
#ifndef __mobile__
109
    _gpsManager->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
110
#endif
Don Gagne's avatar
Don Gagne committed
111 112
    _imageProvider->setToolbox(this);
    _joystickManager->setToolbox(this);
113 114
    _linkManager->setToolbox(this);
    _mavlinkProtocol->setToolbox(this);
115
    _missionCommandTree->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
116
    _multiVehicleManager->setToolbox(this);
dogmaphobic's avatar
dogmaphobic committed
117
    _mapEngineManager->setToolbox(this);
118
    _uasMessageHandler->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
119
    _followMe->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
120
    _qgcPositionManager->setToolbox(this);
121
    _videoManager->setToolbox(this);
Gus Grubba's avatar
Gus Grubba committed
122
    _mavlinkLogManager->setToolbox(this);
123
    _airspaceManager->setToolbox(this);
124 125
}

126 127
void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
{
Gus Grubba's avatar
Gus Grubba committed
128
#if defined (QGC_CUSTOM_BUILD)
129
    //-- Create custom plugin (Static)
130
    _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app, app->toolbox());
131 132 133 134 135
    if(_corePlugin) {
        return;
    }
#endif
    //-- No plugins found, use default instance
136
    _corePlugin = new QGCCorePlugin(app, app->toolbox());
137 138
}

139 140
QGCTool::QGCTool(QGCApplication* app, QGCToolbox* toolbox)
    : QObject(toolbox)
141 142 143 144 145 146 147 148 149
    , _app(app)
    , _toolbox(NULL)
{
}

void QGCTool::setToolbox(QGCToolbox* toolbox)
{
    _toolbox = toolbox;
}