MainToolBar.h 6.08 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief QGC Main Tool Bar
 *   @author Gus Grubba <mavlink@grubba.com>
 */

#ifndef MAINTOOLBAR_H
#define MAINTOOLBAR_H

#include "QGCQmlWidgetHolder.h"

35 36 37 38 39
#define TOOL_BAR_SETTINGS_GROUP "TOOLBAR_SETTINGS_GROUP"
#define TOOL_BAR_SHOW_BATTERY   "ShowBattery"
#define TOOL_BAR_SHOW_GPS       "ShowGPS"
#define TOOL_BAR_SHOW_MAV       "ShowMav"
#define TOOL_BAR_SHOW_MESSAGES  "ShowMessages"
40
#define TOOL_BAR_SHOW_RSSI      "ShowRSSI"
41

dogmaphobic's avatar
dogmaphobic committed
42 43 44 45 46 47 48 49 50
class UASInterface;
class UASMessage;
class UASMessageViewRollDown;

class MainToolBar : public QGCQmlWidgetHolder
{
    Q_OBJECT
    Q_ENUMS(ViewType_t)
public:
51

dogmaphobic's avatar
dogmaphobic committed
52 53 54 55 56 57 58 59
    typedef enum {
        ViewNone    = -1,
        ViewAnalyze, // MainWindow::VIEW_ENGINEER
        ViewPlan   , // MainWindow::VIEW_MISSION
        ViewFly    , // MainWindow::VIEW_FLIGHT
        ViewSetup  , // MainWindow::VIEW_SETUP
    } ViewType_t;

60 61 62
    MainToolBar(QWidget* parent = NULL);
    ~MainToolBar();

dogmaphobic's avatar
dogmaphobic committed
63 64 65
    Q_INVOKABLE void    onSetupView();
    Q_INVOKABLE void    onPlanView();
    Q_INVOKABLE void    onFlyView();
dogmaphobic's avatar
dogmaphobic committed
66
    Q_INVOKABLE void    onFlyViewMenu();
dogmaphobic's avatar
dogmaphobic committed
67 68
    Q_INVOKABLE void    onAnalyzeView();
    Q_INVOKABLE void    onConnect(QString conf);
dogmaphobic's avatar
dogmaphobic committed
69
    Q_INVOKABLE void    onDisconnect(QString conf);
dogmaphobic's avatar
dogmaphobic committed
70 71
    Q_INVOKABLE void    onEnterMessageArea(int x, int y);

72 73
    Q_PROPERTY(ViewType_t    currentView        MEMBER _currentView             NOTIFY currentViewChanged)
    Q_PROPERTY(QStringList   configList         MEMBER _linkConfigurations      NOTIFY configListChanged)
74
    Q_PROPERTY(int           connectionCount    READ connectionCount            NOTIFY connectionCountChanged)
75 76 77 78 79
    Q_PROPERTY(QStringList   connectedList      MEMBER _connectedList           NOTIFY connectedListChanged)
    Q_PROPERTY(bool          showGPS            MEMBER _showGPS                 NOTIFY showGPSChanged)
    Q_PROPERTY(bool          showMav            MEMBER _showMav                 NOTIFY showMavChanged)
    Q_PROPERTY(bool          showMessages       MEMBER _showMessages            NOTIFY showMessagesChanged)
    Q_PROPERTY(bool          showBattery        MEMBER _showBattery             NOTIFY showBatteryChanged)
80
    Q_PROPERTY(bool          showRSSI           MEMBER _showRSSI                NOTIFY showRSSIChanged)
81
    Q_PROPERTY(float         progressBarValue   MEMBER _progressBarValue        NOTIFY progressBarValueChanged)
82 83 84
    Q_PROPERTY(int           remoteRSSI         READ remoteRSSI                 NOTIFY remoteRSSIChanged)
    Q_PROPERTY(int           telemetryRRSSI     READ telemetryRRSSI             NOTIFY telemetryRRSSIChanged)
    Q_PROPERTY(int           telemetryLRSSI     READ telemetryLRSSI             NOTIFY telemetryLRSSIChanged)
85

86 87
    void        setCurrentView          (int currentView);
    void        viewStateChanged        (const QString& key, bool value);
88 89 90
    int         remoteRSSI              () { return _remoteRSSI; }
    int         telemetryRRSSI          () { return _telemetryRRSSI; }
    int         telemetryLRSSI          () { return _telemetryLRSSI; }
91
    int         connectionCount         () { return _connectionCount; }
dogmaphobic's avatar
dogmaphobic committed
92 93 94 95 96 97

signals:
    void connectionCountChanged         (int count);
    void currentViewChanged             ();
    void configListChanged              ();
    void connectedListChanged           (QStringList connectedList);
98 99 100 101
    void showGPSChanged                 (bool value);
    void showMavChanged                 (bool value);
    void showMessagesChanged            (bool value);
    void showBatteryChanged             (bool value);
102
    void showRSSIChanged                (bool value);
103
    void progressBarValueChanged        (float value);
104 105 106
    void remoteRSSIChanged              (int value);
    void telemetryRRSSIChanged          (int value);
    void telemetryLRSSIChanged          (int value);
dogmaphobic's avatar
dogmaphobic committed
107 108

private slots:
109 110
    void _forgetUAS                     (UASInterface* uas);
    void _setActiveUAS                  (UASInterface* uas);
dogmaphobic's avatar
dogmaphobic committed
111 112 113 114
    void _updateConfigurations          ();
    void _linkConnected                 (LinkInterface* link);
    void _linkDisconnected              (LinkInterface* link);
    void _leaveMessageView              ();
115
    void _setProgressBarValue           (float value);
116
    void _updatePixelSize               ();
117
    void _remoteControlRSSIChanged      (uint8_t rssi);
118
    void _telemetryChanged              (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
dogmaphobic's avatar
dogmaphobic committed
119 120 121

private:
    void _updateConnection              (LinkInterface *disconnectedLink = NULL);
122
    void _setToolBarState               (const QString& key, bool value);
dogmaphobic's avatar
dogmaphobic committed
123 124 125 126 127 128 129 130

private:
    UASInterface*   _mav;
    QQuickItem*     _toolBar;
    ViewType_t      _currentView;
    QStringList     _linkConfigurations;
    int             _connectionCount;
    QStringList     _connectedList;
131 132 133
    bool            _showGPS;
    bool            _showMav;
    bool            _showMessages;
134
    bool            _showRSSI;
135
    bool            _showBattery;
136
    float           _progressBarValue;
137 138 139
    int             _remoteRSSI;
    int             _telemetryRRSSI;
    int             _telemetryLRSSI;
dogmaphobic's avatar
dogmaphobic committed
140 141 142 143 144

    UASMessageViewRollDown* _rollDownMessages;
};

#endif // MAINTOOLBAR_H