QGCToolbox.cc 4.46 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 13
#include "FactSystem.h"
#include "FirmwarePluginManager.h"
#include "GAudioOutput.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 33 34 35

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

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

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

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

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

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

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

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

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