QGCToolBar.h 4.58 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 41 42 43 44

class QGCToolBar : public QToolBar
{
    Q_OBJECT

public:
lm's avatar
lm committed
45
    explicit QGCToolBar(QWidget* parent = 0);
Lorenz Meier's avatar
Lorenz Meier committed
46
    void setPerspectiveChangeActions(const QList<QAction*> &action);
47
    void setPerspectiveChangeAdvancedActions(const QList<QAction*> &action);
48 49 50 51 52 53 54 55 56 57 58 59

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
60 61
    /** @brief Received system text message */
    void receiveTextMessage(int uasid, int componentid, int severity, QString text);
LM's avatar
LM committed
62
    /** @brief Update battery charge state */
dongfang's avatar
dongfang committed
63
    void updateBatteryRemaining(UASInterface* uas, double voltage, double current, double percent, int seconds);
64 65 66 67
    /** @brief Update current waypoint */
    void updateCurrentWaypoint(quint16 id);
    /** @brief Update distance to current waypoint */
    void updateWaypointDistance(double distance);
68 69
    /** @brief Update arming state */
    void updateArmingState(bool armed);
lm's avatar
lm committed
70 71
    /** @brief Repaint widgets */
    void updateView();
72 73
    /** @brief Update connection timeout time */
    void heartbeatTimeout(bool timeout, unsigned int ms);
74 75
    /** @brief Clear status string */
    void clearStatusString();
76 77
    /** @brief Set an activity action as checked in menu */
    void advancedActivityTriggered(QAction* action);
78

79
protected:
80
    void createUI();
81
    void resetToolbarUI();
82
    UASInterface* mav;
83
    QLabel* symbolLabel;
LM's avatar
LM committed
84
    QLabel* toolBarNameLabel;
85
    QLabel* toolBarTimeoutLabel;
86
    QAction* toolBarTimeoutAction; ///< Needed to set label (in)visible.
87 88
    QAction* toolBarMessageAction;
    QAction* toolBarWpAction;
Lorenz Meier's avatar
Lorenz Meier committed
89 90
    QAction* toolBarBatteryBarAction;
    QAction* toolBarBatteryVoltageAction;
91
    QLabel* toolBarSafetyLabel;
LM's avatar
LM committed
92 93 94 95 96
    QLabel* toolBarModeLabel;
    QLabel* toolBarStateLabel;
    QLabel* toolBarWpLabel;
    QLabel* toolBarMessageLabel;
    QProgressBar* toolBarBatteryBar;
97
    QLabel* toolBarBatteryVoltageLabel;
98

lm's avatar
lm committed
99 100 101 102 103
    bool changed;
    float batteryPercent;
    float batteryVoltage;
    int wpId;
    double wpDistance;
104
    float altitudeRel;
lm's avatar
lm committed
105 106 107 108
    QString state;
    QString mode;
    QString systemName;
    QString lastSystemMessage;
109
    quint64 lastSystemMessageTimeMs;
lm's avatar
lm committed
110
    QTimer updateViewTimer;
111
    bool systemArmed;
112
    LinkInterface* currentLink;
113
    QAction* firstAction;
114
    QToolButton *advancedButton;
115
    QButtonGroup *group;
116 117
    
private slots:
118 119 120 121 122
    void _linkConnected(LinkInterface* link);
    void _linkDisconnected(LinkInterface* link);
    void _disconnectFromMenu(bool checked);
    void _connectButtonClicked(bool checked);
    void _linkComboActivated(int index);
123 124
    
private:
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    void _updateConnectButton(void);
    void _updatePortList(void);
    
    LinkManager*    _linkMgr;
    
    QComboBox*  _linkCombo;
    QAction*    _linkComboAction;
    bool        _linkSelectedOnce;
    QTimer      _portListTimer;
    
    QComboBox*  _baudCombo;
    QAction*    _baudComboAction;
    
    QPushButton*    _connectButton;
    bool            _linksConnected;
140 141 142
};

#endif // QGCTOOLBAR_H