QGCToolbox.cc 4.53 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 19
#include "HomePositionManager.h"
#include "JoystickManager.h"
Don Gagne's avatar
Don Gagne committed
20 21
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
22
#include "MissionCommandTree.h"
Don Gagne's avatar
Don Gagne committed
23
#include "MultiVehicleManager.h"
dogmaphobic's avatar
dogmaphobic committed
24
#include "QGCImageProvider.h"
Don Gagne's avatar
Don Gagne committed
25
#include "UASMessageHandler.h"
dogmaphobic's avatar
dogmaphobic committed
26
#include "QGCMapEngineManager.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
27
#include "FollowMe.h"
Jimmy Johnson's avatar
Jimmy Johnson committed
28
#include "PositionManager.h"
29
#include "VideoManager.h"
Gus Grubba's avatar
Gus Grubba committed
30
#include "MAVLinkLogManager.h"
31 32 33 34 35 36
#include "QGCCorePlugin.h"
#include "QGCOptions.h"

#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
46
    , _homePositionManager(NULL)
Don Gagne's avatar
Don Gagne committed
47
    , _imageProvider(NULL)
48
    , _joystickManager(NULL)
Don Gagne's avatar
Don Gagne committed
49 50
    , _linkManager(NULL)
    , _mavlinkProtocol(NULL)
51
    , _missionCommandTree(NULL)
Don Gagne's avatar
Don Gagne committed
52
    , _multiVehicleManager(NULL)
dogmaphobic's avatar
dogmaphobic committed
53
    , _mapEngineManager(NULL)
54
    , _uasMessageHandler(NULL)
Jimmy Johnson's avatar
Jimmy Johnson committed
55
    , _followMe(NULL)
Jimmy Johnson's avatar
Jimmy Johnson committed
56
    , _qgcPositionManager(NULL)
57
    , _videoManager(NULL)
Gus Grubba's avatar
Gus Grubba committed
58
    , _mavlinkLogManager(NULL)
59
    , _corePlugin(NULL)
60
{
61 62
    //-- Scan and load plugins
    _scanAndLoadPlugins(app);
Don Gagne's avatar
Don Gagne committed
63 64 65
    _audioOutput =              new GAudioOutput(app);
    _factSystem =               new FactSystem(app);
    _firmwarePluginManager =    new FirmwarePluginManager(app);
66
    _flightMapSettings =        new FlightMapSettings(app);
67
#ifndef __mobile__
68
    _gpsManager =               new GPSManager(app);
Don Gagne's avatar
Don Gagne committed
69
#endif
70
    _homePositionManager =      new HomePositionManager(app);
Don Gagne's avatar
Don Gagne committed
71 72
    _imageProvider =            new QGCImageProvider(app);
    _joystickManager =          new JoystickManager(app);
73 74
    _linkManager =              new LinkManager(app);
    _mavlinkProtocol =          new MAVLinkProtocol(app);
75
    _missionCommandTree =       new MissionCommandTree(app);
Don Gagne's avatar
Don Gagne committed
76
    _multiVehicleManager =      new MultiVehicleManager(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
77
    _mapEngineManager =         new QGCMapEngineManager(app);
78
    _uasMessageHandler =        new UASMessageHandler(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
79
    _qgcPositionManager =       new QGCPositionManager(app);
Jimmy Johnson's avatar
Jimmy Johnson committed
80
    _followMe =                 new FollowMe(app);
81
    _videoManager =             new VideoManager(app);
Gus Grubba's avatar
Gus Grubba committed
82
    _mavlinkLogManager =        new MAVLinkLogManager(app);
83
}
84

85 86
void QGCToolbox::setChildToolboxes(void)
{
87
    _corePlugin->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
88 89 90
    _audioOutput->setToolbox(this);
    _factSystem->setToolbox(this);
    _firmwarePluginManager->setToolbox(this);
91
    _flightMapSettings->setToolbox(this);
92
#ifndef __mobile__
93
    _gpsManager->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
94
#endif
95
    _homePositionManager->setToolbox(this);
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 118 119
    delete _flightMapSettings;
    delete _homePositionManager;
    delete _joystickManager;
Don Gagne's avatar
Don Gagne committed
120 121
    delete _linkManager;
    delete _mavlinkProtocol;
122
    delete _missionCommandTree;
dogmaphobic's avatar
dogmaphobic committed
123
    delete _mapEngineManager;
Don Gagne's avatar
Don Gagne committed
124
    delete _multiVehicleManager;
125
    delete _uasMessageHandler;
Jimmy Johnson's avatar
Jimmy Johnson committed
126
    delete _followMe;
Jimmy Johnson's avatar
Jimmy Johnson committed
127
    delete _qgcPositionManager;
128 129 130 131 132
    delete _corePlugin;
}

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

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

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