QGroundControl无人机地面站 QGCApplication.h

联系作者 qq 843230304 ,欢迎交流分享
###QGroundControl无人机地面站 QGCApplication.h各个函数功能详解

集中管理地面站的各种功能


@brief The main application and management class.
 
This class is started by the main method and provides

the central management unit of the groundstation application.
 

  1. 程序配置
  2. 运行单元测试
  3. 消息提示
  4. 最后家点位置
  5. 窗口管理
  6. 日志管理
  7. 应用程序管理(界面风格)

private :
QGCToolbox* _toolbox; //整个应用程序的全局工具盒

/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT 
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/


/**
 * @file
 *   @brief Definition of main class
 *
 *   @author Lorenz Meier 
 *
 */

#ifndef QGCAPPLICATION_H
#define QGCAPPLICATION_H

#include 
#include 
#include 

#include "LinkConfiguration.h"
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "FlightMapSettings.h"
#include "FirmwarePluginManager.h"
#include "MultiVehicleManager.h"
#include "JoystickManager.h"
#include "GAudioOutput.h"
#include "UASMessageHandler.h"
#include "FactSystem.h"

#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
#endif

// Work around circular header includes
class QGCSingleton;
class MainWindow;
class QGCToolbox;

/**
 * @brief The main application and management class.
 *
 * This class is started by the main method and provides
 * the central management unit of the groundstation application.
 *
 **/
class QGCApplication : public
#ifdef __mobile__
    QGuiApplication // Native Qml based application
#else
    QApplication    // QtWidget based application
#endif
{
    Q_OBJECT

public:
    QGCApplication(int &argc, char* argv[], bool unitTesting);
    ~QGCApplication();

    static const char* parameterFileExtension;
    static const char* missionFileExtension;
    static const char* fenceFileExtension;
    static const char* rallyPointFileExtension;
    static const char* telemetryFileExtension;

    /// @brief Sets the persistent flag to delete all settings the next time QGroundControl is started.
    /// 重启删除所有设置
    void deleteAllSettingsNextBoot(void);

    /// @brief Clears the persistent flag to delete all settings the next time QGroundControl is started.
    /// 重启清空所有设置
    void clearDeleteAllSettingsNextBoot(void);

    /// @brief Returns truee if unit test are being run
    /// 运行单元测试
    bool runningUnitTests(void) { return _runningUnitTests; }

    /// Used to report a missing Parameter. Warning will be displayed to user.
    ///  Method may be called multiple times.
    /// 用于报告丢失的参数
    void reportMissingParameter(int componentId, const QString& name);

    /// Show a non-modal message to the user
    /// 向用户显示非模态消息
    void showMessage(const QString& message);

    /// @return true: Fake ui into showing mobile interface
    /// 返回真,隐藏UI界面 显示 移动设备的实例
    bool fakeMobile(void) { return _fakeMobile; }

#ifdef QT_DEBUG
    /// 测试 高分辨率 (像素/每英寸)
    bool testHighDPI(void) { return _testHighDPI; }
#endif

    // Still working on getting rid of this and using dependency injection instead for everything
    /// 获取APP的工具箱
    QGCToolbox* toolbox(void) { return _toolbox; }

    /// Do we have Bluetooth Support?
    /// 是否支持蓝牙
    bool isBluetoothAvailable() { return _bluetoothAvailable; }

    ///读取 最后家点位置
    QGeoCoordinate lastKnownHomePosition(void) { return _lastKnownHomePosition; }
    ///设置 最后家点位置
    void setLastKnownHomePosition(QGeoCoordinate& lastKnownHomePosition);

public slots:
    /// You can connect to this slot to show an information message box from a different thread.
    /// 您可以连接到这个槽,以显示来自不同线程的         信息消息框
    void informationMessageBoxOnMainThread(const QString& title, const QString& msg);

    /// You can connect to this slot to show a warning message box from a different thread.
    /// 您可以连接到这个槽,以显示来自不同线程的         警告消息框
    void warningMessageBoxOnMainThread(const QString& title, const QString& msg);

    /// You can connect to this slot to show a critical message box from a different thread.
    /// 您可以连接到这个槽,以显示来自不同线程的一个      危险消息框
    void criticalMessageBoxOnMainThread(const QString& title, const QString& msg);

    /// 显示设置界面
    void showSetupView(void);

    /// 程序关闭之前的处理
    void qmlAttemptWindowClose(void);

#ifndef __mobile__
    /// Save the specified telemetry Log
    /// 保存指定的日志文件
    void saveTelemetryLogOnMainThread(QString tempLogfile);

    /// Check that the telemetry save path is set correctly
    /// 检查飞行日志路径是否正确
    void checkTelemetrySavePathOnMainThread(void);
#endif

signals:
    /// This is connected to MAVLinkProtocol::checkForLostLogFiles. We signal this to ourselves to call the slot
    /// on the MAVLinkProtocol thread;
    ///
    /// 这个信号连接到MAVLinkProtocol::checkForLostLogFiles
    /// 我们把这个信号发送给我们自己 去调用在MAVLinkProtocol线程上的槽函数
    void checkForLostLogFiles(void);

public:
    // Although public, these methods are internal and should only be called by UnitTest code
    //----------------尽管公开, 这些方法是内部的, 只能由UnitTest代码调用----------------------------

    /// @brief Perform initialize which is common to both normal application running and unit tests.
    ///         Although public should only be called by main.
    /// 执行初始化,这在正常的应用程序运行和单元测试中都是常见的
    /// 注册qml对象
    void _initCommon(void);

    /// @brief Intialize the application for normal application boot. Or in other words we are not going to run
    ///         unit tests. Although public should only be called by main.
    /// 初始化应用程序用于正常启动.
    /// 否则不能运行单元测试
    /// 虽然是Public的,只能被main函数调用
    bool _initForNormalAppBoot(void);

    /// @brief Intialize the application for normal application boot. Or in other words we are not going to run
    ///         unit tests. Although public should only be called by main.
    /// 初始化应用程序用于正常启动.
    /// 否则不能运行单元测试
    /// 虽然是Public的,只能被main函数调用
    bool _initForUnitTests(void);

    /// 加载当前应用  程序风格
    void _loadCurrentStyleSheet(void);

    ///自己的单例。只能直接被 qgcApp() 引用
    static QGCApplication*  _app;   ///< Our own singleton. Should be reference directly by qgcApp

public:
    // Although public, these methods are internal and should only be called by UnitTest code
    //----------------尽管公开, 这些方法是内部的, 只能由UnitTest代码调用----------------------------

    /// Shutdown the application object
    /// 关闭 application 对象
    void _shutdown(void);

    /// 检查 遥测保存路径
    bool _checkTelemetrySavePath(bool useMessageBox);

private slots:
    /// 在延迟计时器触发时调用, 以显示丢失的参数警告
    void _missingParamsDisplay(void);

private:
    /// 返回 qml根对象
    QObject* _rootQmlObject(void);

#ifdef __mobile__
    QQmlApplicationEngine* _qmlAppEngine;
#endif

    ///< true: running unit tests, false: normal app
    ///< true: 运行单元测试, false: 正常app
    bool _runningUnitTests;

    static const char*  _darkStyleFile;
    static const char*  _lightStyleFile;
    static const int    _missingParamsDelayedDisplayTimerTimeout = 1000;    ///< Timeout to wait for next missing fact to come in before display
    QTimer              _missingParamsDelayedDisplayTimer;                  ///< Timer use to delay missing fact display
    QStringList         _missingParams;                                     ///< List of missing facts to be displayed
    bool				_fakeMobile;                                        ///< true: Fake ui into displaying mobile interface
    bool                _settingsUpgraded;                                  ///< true: Settings format has been upgrade to new version

#ifdef QT_DEBUG
    bool _testHighDPI;  ///< true: double fonts sizes for simulating high dpi devices
#endif

    QGCToolbox* _toolbox;

    bool _bluetoothAvailable;

    QGeoCoordinate _lastKnownHomePosition;    ///< Map position when all other sources fail

    static const char* _settingsVersionKey;             ///< Settings key which hold settings version
    static const char* _deleteAllSettingsKey;           ///< If this settings key is set on boot, all settings will be deleted
    static const char* _lastKnownHomePositionLatKey;
    static const char* _lastKnownHomePositionLonKey;
    static const char* _lastKnownHomePositionAltKey;

    /// Unit Test have access to creating and destroying singletons
    friend class UnitTest;

};

/// @brief Returns the QGCApplication object singleton.
QGCApplication* qgcApp(void);

#endif

你可能感兴趣的:(QGroundControl无人机地面站 QGCApplication.h)