QGCToolbox.cc 4.65 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 "FlightMapSettings.h"
Don Gagne's avatar
Don Gagne committed
14
#include "GAudioOutput.h"
15
#ifndef __mobile__
16
#include "GPSManager.h"
Don Gagne's avatar
Don Gagne committed
17
#endif
18
#include "JoystickManager.h"
Don Gagne's avatar
Don Gagne committed
19 20
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
21
#include "MissionCommandTree.h"
Don Gagne's avatar
Don Gagne committed
22
#include "MultiVehicleManager.h"
dogmaphobic's avatar
dogmaphobic committed
23
#include "QGCImageProvider.h"
Don Gagne's avatar
Don Gagne committed
24
#include "UASMessageHandler.h"
dogmaphobic's avatar
dogmaphobic committed
25
#include "QGCMapEngineManager.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
26
#include "FollowMe.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
27
#include "PositionManager.h"
28
#include "VideoManager.h"
Gus Grubba's avatar
Gus Grubba committed
29
#include "MAVLinkLogManager.h"
30 31
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
32
#include "SettingsManager.h"
33 34 35 36

#if defined(QGC_CUSTOM_BUILD)
#include CUSTOMHEADER
#endif
37 38

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

64 65
    //-- Scan and load plugins
    _scanAndLoadPlugins(app);
Don Gagne's avatar
Don Gagne committed
66 67 68
    _audioOutput =              new GAudioOutput(app);
    _factSystem =               new FactSystem(app);
    _firmwarePluginManager =    new FirmwarePluginManager(app);
69
    _flightMapSettings =        new FlightMapSettings(app);
70
#ifndef __mobile__
71
    _gpsManager =               new GPSManager(app);
Don Gagne's avatar
Don Gagne committed
72
#endif
Don Gagne's avatar
Don Gagne committed
73 74
    _imageProvider =            new QGCImageProvider(app);
    _joystickManager =          new JoystickManager(app);
75 76
    _linkManager =              new LinkManager(app);
    _mavlinkProtocol =          new MAVLinkProtocol(app);
77
    _missionCommandTree =       new MissionCommandTree(app);
Don Gagne's avatar
Don Gagne committed
78
    _multiVehicleManager =      new MultiVehicleManager(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
79
    _mapEngineManager =         new QGCMapEngineManager(app);
80
    _uasMessageHandler =        new UASMessageHandler(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
81
    _qgcPositionManager =       new QGCPositionManager(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
82
    _followMe =                 new FollowMe(app);
83
    _videoManager =             new VideoManager(app);
Gus Grubba's avatar
Gus Grubba committed
84
    _mavlinkLogManager =        new MAVLinkLogManager(app);
85
}
86

87 88
void QGCToolbox::setChildToolboxes(void)
{
89 90 91
    // SettingsManager must be first so settings are available to any subsequent tools
    _settingsManager->setToolbox(this);

92
    _corePlugin->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
93 94 95
    _audioOutput->setToolbox(this);
    _factSystem->setToolbox(this);
    _firmwarePluginManager->setToolbox(this);
96
    _flightMapSettings->setToolbox(this);
97
#ifndef __mobile__
98
    _gpsManager->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
99
#endif
Don Gagne's avatar
Don Gagne committed
100 101
    _imageProvider->setToolbox(this);
    _joystickManager->setToolbox(this);
102 103
    _linkManager->setToolbox(this);
    _mavlinkProtocol->setToolbox(this);
104
    _missionCommandTree->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
105
    _multiVehicleManager->setToolbox(this);
dogmaphobic's avatar
dogmaphobic committed
106
    _mapEngineManager->setToolbox(this);
107
    _uasMessageHandler->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
108
    _followMe->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
109
    _qgcPositionManager->setToolbox(this);
110
    _videoManager->setToolbox(this);
Gus Grubba's avatar
Gus Grubba committed
111
    _mavlinkLogManager->setToolbox(this);
112 113 114 115
}

QGCToolbox::~QGCToolbox()
{
116
    delete _videoManager;
Gus Grubba's avatar
Gus Grubba committed
117
    delete _mavlinkLogManager;
Don Gagne's avatar
Don Gagne committed
118 119 120
    delete _audioOutput;
    delete _factSystem;
    delete _firmwarePluginManager;
121 122
    delete _flightMapSettings;
    delete _joystickManager;
Don Gagne's avatar
Don Gagne committed
123 124
    delete _linkManager;
    delete _mavlinkProtocol;
125
    delete _missionCommandTree;
dogmaphobic's avatar
dogmaphobic committed
126
    delete _mapEngineManager;
Don Gagne's avatar
Don Gagne committed
127
    delete _multiVehicleManager;
128
    delete _uasMessageHandler;
Jimmy Johnson's avatar
Jimmy Johnson committed
129
    delete _followMe;
Jimmy Johnson's avatar
Jimmy Johnson committed
130
    delete _qgcPositionManager;
131 132 133 134 135
    delete _corePlugin;
}

void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
{
Gus Grubba's avatar
Gus Grubba committed
136
#if defined (QGC_CUSTOM_BUILD)
137 138 139 140 141 142 143 144
    //-- Create custom plugin (Static)
    _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app);
    if(_corePlugin) {
        return;
    }
#endif
    //-- No plugins found, use default instance
    _corePlugin = new QGCCorePlugin(app);
145 146 147 148 149 150 151 152 153 154 155 156 157
}

QGCTool::QGCTool(QGCApplication* app)
    : QObject((QObject*)app)
    , _app(app)
    , _toolbox(NULL)
{
}

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