QGCToolbox.cc 4.33 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 32 33 34 35
#include "QGCCorePlugin.h"
#include "QGCOptions.h"

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

82 83
void QGCToolbox::setChildToolboxes(void)
{
84
    _corePlugin->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
85 86 87
    _audioOutput->setToolbox(this);
    _factSystem->setToolbox(this);
    _firmwarePluginManager->setToolbox(this);
88
    _flightMapSettings->setToolbox(this);
89
#ifndef __mobile__
90
    _gpsManager->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
91
#endif
Don Gagne's avatar
Don Gagne committed
92 93
    _imageProvider->setToolbox(this);
    _joystickManager->setToolbox(this);
94 95
    _linkManager->setToolbox(this);
    _mavlinkProtocol->setToolbox(this);
96
    _missionCommandTree->setToolbox(this);
Don Gagne's avatar
Don Gagne committed
97
    _multiVehicleManager->setToolbox(this);
dogmaphobic's avatar
dogmaphobic committed
98
    _mapEngineManager->setToolbox(this);
99
    _uasMessageHandler->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
100
    _followMe->setToolbox(this);
Jimmy Johnson's avatar
Jimmy Johnson committed
101
    _qgcPositionManager->setToolbox(this);
102
    _videoManager->setToolbox(this);
Gus Grubba's avatar
Gus Grubba committed
103
    _mavlinkLogManager->setToolbox(this);
104 105 106 107
}

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

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

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

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