QGCToolBar.h 5.18 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
#include "UASInterface.h"
36
#include "SerialLink.h"
37 38 39 40 41 42

class QGCToolBar : public QToolBar
{
    Q_OBJECT

public:
lm's avatar
lm committed
43
    explicit QGCToolBar(QWidget* parent = 0);
Lorenz Meier's avatar
Lorenz Meier committed
44
    void setPerspectiveChangeActions(const QList<QAction*> &action);
45
    void setPerspectiveChangeAdvancedActions(const QList<QAction*> &action);
46 47 48 49 50
    ~QGCToolBar();

public slots:
    /** @brief Set the system that is currently displayed by this widget */
    void setActiveUAS(UASInterface* active);
51 52 53 54
    /** @brief Set the link which is currently handled with connecting / disconnecting */
    void addLink(LinkInterface* link);
    /** @brief Remove link which is currently handled */
    void removeLink(LinkInterface* link);
55 56 57 58 59 60 61 62
    /** @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
63 64
    /** @brief Received system text message */
    void receiveTextMessage(int uasid, int componentid, int severity, QString text);
LM's avatar
LM committed
65
    /** @brief Update battery charge state */
dongfang's avatar
dongfang committed
66
    void updateBatteryRemaining(UASInterface* uas, double voltage, double current, double percent, int seconds);
67 68 69 70
    /** @brief Update current waypoint */
    void updateCurrentWaypoint(quint16 id);
    /** @brief Update distance to current waypoint */
    void updateWaypointDistance(double distance);
71 72
    /** @brief Update arming state */
    void updateArmingState(bool armed);
lm's avatar
lm committed
73 74
    /** @brief Repaint widgets */
    void updateView();
75 76
    /** @brief Update connection timeout time */
    void heartbeatTimeout(bool timeout, unsigned int ms);
77
    /** @brief Update global position */
78
    void globalPositionChanged(UASInterface* uas, double lat, double lon, double altAMSL, double altWGS84, quint64 usec);
79 80
    /** @brief Create or connect link */
    void connectLink(bool connect);
81 82
    /** @brief Clear status string */
    void clearStatusString();
83 84
    /** @brief Set an activity action as checked in menu */
    void advancedActivityTriggered(QAction* action);
85
    void updateComboBox();
86

87 88 89 90 91 92
    /**
     * @brief User selected baud rate
     * @param index The current index of the combo box
     */
    void baudSelected(int index);

93 94 95 96 97 98
    /**
     * @brief User selected port
     * @param index The current index of the combo box
     */
    void portSelected(int index);

99
protected:
100 101
    void storeSettings();
    void loadSettings();
102
    void createUI();
103
    void resetToolbarUI();
104
    UASInterface* mav;
105
    QLabel* symbolLabel;
LM's avatar
LM committed
106
    QLabel* toolBarNameLabel;
107
    QLabel* toolBarTimeoutLabel;
108
    QAction* toolBarTimeoutAction; ///< Needed to set label (in)visible.
109 110 111 112
    QAction* toolBarMessageAction;
    QAction* toolBarPortAction;
    QAction* toolBarBaudAction;
    QAction* toolBarWpAction;
Lorenz Meier's avatar
Lorenz Meier committed
113 114
    QAction* toolBarBatteryBarAction;
    QAction* toolBarBatteryVoltageAction;
115
    QLabel* toolBarSafetyLabel;
LM's avatar
LM committed
116 117 118 119
    QLabel* toolBarModeLabel;
    QLabel* toolBarStateLabel;
    QLabel* toolBarWpLabel;
    QLabel* toolBarMessageLabel;
120
    QPushButton* connectButton;
LM's avatar
LM committed
121
    QProgressBar* toolBarBatteryBar;
122
    QLabel* toolBarBatteryVoltageLabel;
123

124
    QComboBox *portComboBox;
125
    QComboBox *baudcomboBox;
126
    QTimer portBoxTimer;
127
    bool userBaudChoice;
128
    bool userPortChoice;
lm's avatar
lm committed
129 130 131 132 133
    bool changed;
    float batteryPercent;
    float batteryVoltage;
    int wpId;
    double wpDistance;
134 135
    float altitudeMSL;
    float altitudeRel;
lm's avatar
lm committed
136 137 138 139
    QString state;
    QString mode;
    QString systemName;
    QString lastSystemMessage;
140
    quint64 lastSystemMessageTimeMs;
lm's avatar
lm committed
141
    QTimer updateViewTimer;
142
    bool systemArmed;
143
    LinkInterface* currentLink;
144
    QAction* firstAction;
145
    QToolButton *advancedButton;
146
    QButtonGroup *group;
147 148 149 150 151 152 153 154
    
private slots:
    void _linkConnected(void);
    void _linkDisconnected(void);
    
private:
    /** @brief Update the link state */
    void _updateLinkState(bool connected);
155 156 157
};

#endif // QGCTOOLBAR_H