QGCToolBar.h 4.76 KB
Newer Older
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
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009 - 2011 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/>.

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

#ifndef QGCTOOLBAR_H
#define QGCTOOLBAR_H

#include <QToolBar>
#include <QAction>
#include <QToolButton>
30
#include <QPushButton>
31
#include <QLabel>
LM's avatar
LM committed
32
#include <QProgressBar>
33
#include <QComboBox>
34
#include <QTimer>
35

36
#include "UASInterface.h"
37
#include "SerialLink.h"
38
#include "LinkManager.h"
39

40
class UASMessageViewRollDown;
41

42 43 44 45 46
class QGCToolBar : public QToolBar
{
    Q_OBJECT

public:
lm's avatar
lm committed
47
    explicit QGCToolBar(QWidget* parent = 0);
Lorenz Meier's avatar
Lorenz Meier committed
48
    void setPerspectiveChangeActions(const QList<QAction*> &action);
49
    void setPerspectiveChangeAdvancedActions(const QList<QAction*> &action);
50 51 52 53 54 55 56 57
    /**
     * @brief Mouse entered Message label area
     */
    void enterMessageLabel();
    /**
     * @brief Mouse left message drop down list area (and closed it)
     */
    void leaveMessageView();
58 59 60 61 62 63 64 65 66 67 68 69

public slots:
    /** @brief Set the system that is currently displayed by this widget */
    void setActiveUAS(UASInterface* active);
    /** @brief Set the system state */
    void updateState(UASInterface* system, QString name, QString description);
    /** @brief Set the system mode */
    void updateMode(int system, QString name, QString description);
    /** @brief Update the system name */
    void updateName(const QString& name);
    /** @brief Set the MAV system type */
    void setSystemType(UASInterface* uas, unsigned int systemType);
LM's avatar
LM committed
70 71
    /** @brief Received system text message */
    void receiveTextMessage(int uasid, int componentid, int severity, QString text);
LM's avatar
LM committed
72
    /** @brief Update battery charge state */
dongfang's avatar
dongfang committed
73
    void updateBatteryRemaining(UASInterface* uas, double voltage, double current, double percent, int seconds);
74 75 76 77
    /** @brief Update current waypoint */
    void updateCurrentWaypoint(quint16 id);
    /** @brief Update distance to current waypoint */
    void updateWaypointDistance(double distance);
78 79
    /** @brief Update arming state */
    void updateArmingState(bool armed);
lm's avatar
lm committed
80 81
    /** @brief Repaint widgets */
    void updateView();
82 83
    /** @brief Update connection timeout time */
    void heartbeatTimeout(bool timeout, unsigned int ms);
84 85
    /** @brief Set an activity action as checked in menu */
    void advancedActivityTriggered(QAction* action);
86

87
protected:
88
    void createUI();
89
    void resetToolbarUI();
90
    UASInterface* mav;
91
    QLabel* symbolLabel;
LM's avatar
LM committed
92
    QLabel* toolBarNameLabel;
93
    QLabel* toolBarTimeoutLabel;
94
    QAction* toolBarTimeoutAction; ///< Needed to set label (in)visible.
95 96
    QAction* toolBarMessageAction;
    QAction* toolBarWpAction;
Lorenz Meier's avatar
Lorenz Meier committed
97 98
    QAction* toolBarBatteryBarAction;
    QAction* toolBarBatteryVoltageAction;
99
    QLabel* toolBarSafetyLabel;
LM's avatar
LM committed
100 101 102 103 104
    QLabel* toolBarModeLabel;
    QLabel* toolBarStateLabel;
    QLabel* toolBarWpLabel;
    QLabel* toolBarMessageLabel;
    QProgressBar* toolBarBatteryBar;
105
    QLabel* toolBarBatteryVoltageLabel;
106

lm's avatar
lm committed
107 108 109 110 111
    bool changed;
    float batteryPercent;
    float batteryVoltage;
    int wpId;
    double wpDistance;
112
    float altitudeRel;
lm's avatar
lm committed
113 114 115 116
    QString state;
    QString mode;
    QString systemName;
    QString lastSystemMessage;
117
    quint64 lastSystemMessageTimeMs;
lm's avatar
lm committed
118
    QTimer updateViewTimer;
119
    bool systemArmed;
120
    LinkInterface* currentLink;
121
    QAction* firstAction;
122
    QToolButton *advancedButton;
123
    QButtonGroup *group;
124

125
private slots:
126 127 128 129 130
    void _linkConnected(LinkInterface* link);
    void _linkDisconnected(LinkInterface* link);
    void _disconnectFromMenu(bool checked);
    void _connectButtonClicked(bool checked);
    void _linkComboActivated(int index);
131 132
    void _updateConfigurations();

133
private:
134
    void _updateConnectButton(LinkInterface* disconnectedLink = NULL);
135

136
    LinkManager*    _linkMgr;
137

138 139
    QComboBox*  _linkCombo;
    QAction*    _linkComboAction;
140

141
    UASMessageViewRollDown* _rollDownMessages;
142

143 144
    QPushButton*    _connectButton;
    bool            _linksConnected;
145
    bool            _linkSelected;      // User selected a link. Stop autoselecting it.
146 147 148
};

#endif // QGCTOOLBAR_H