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 "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 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)
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
    , _settingsManager(NULL)
59
{
60
    // SettingsManager must be first so settings are available to any subsequent tools
61
    _settingsManager =          new SettingsManager(app, this);
62

63 64
    //-- Scan and load plugins
    _scanAndLoadPlugins(app);
65
    _audioOutput =              new AudioOutput             (app, this);
66 67
    _factSystem =               new FactSystem              (app, this);
    _firmwarePluginManager =    new FirmwarePluginManager   (app, this);
68
#ifndef __mobile__
69
    _gpsManager =               new GPSManager              (app, this);
Don Gagne's avatar
Don Gagne committed
70
#endif
71 72 73 74 75 76 77 78 79 80 81 82
    _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);
83
}
84

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

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

111 112
void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
{
Gus Grubba's avatar
Gus Grubba committed
113
#if defined (QGC_CUSTOM_BUILD)
114
    //-- Create custom plugin (Static)
115
    _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app, app->toolbox());
116 117 118 119 120
    if(_corePlugin) {
        return;
    }
#endif
    //-- No plugins found, use default instance
121
    _corePlugin = new QGCCorePlugin(app, app->toolbox());
122 123
}

124 125
QGCTool::QGCTool(QGCApplication* app, QGCToolbox* toolbox)
    : QObject(toolbox)
126 127 128 129 130 131 132 133 134
    , _app(app)
    , _toolbox(NULL)
{
}

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