UASView.h 4.4 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2
/*=====================================================================

3
QGroundControl Open Source Ground Control Station
pixhawk's avatar
pixhawk committed
4

5
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
pixhawk's avatar
pixhawk committed
6

7
This file is part of the QGROUNDCONTROL project
pixhawk's avatar
pixhawk committed
8

9
    QGROUNDCONTROL is free software: you can redistribute it and/or modify
pixhawk's avatar
pixhawk committed
10 11 12 13
    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.

14
    QGROUNDCONTROL is distributed in the hope that it will be useful,
pixhawk's avatar
pixhawk committed
15 16 17 18 19
    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
20
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
pixhawk's avatar
pixhawk committed
21 22 23 24 25

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

/**
 * @file
26
 *   @brief Definition of class UASView
pixhawk's avatar
pixhawk committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *
 */

#ifndef UASVIEW_H
#define UASVIEW_H

#include <QtGui/QWidget>
#include <QString>
#include <QTimer>
#include <QMouseEvent>
#include <UASInterface.h>

namespace Ui {
    class UASView;
}

45 46
class UASView : public QWidget
{
pixhawk's avatar
pixhawk committed
47 48 49 50 51 52
    Q_OBJECT
public:
    UASView(UASInterface* uas, QWidget *parent = 0);
    ~UASView();

public slots:
53 54
    /** @brief Update the name of the system */
    void updateName(const QString& name);
pixhawk's avatar
pixhawk committed
55 56 57 58 59 60 61
    void receiveHeartbeat(UASInterface* uas);
    void updateThrust(UASInterface* uas, double thrust);
    void updateBattery(UASInterface* uas, double voltage, double percent, int seconds);
    void updateLocalPosition(UASInterface*, double x, double y, double z, quint64 usec);
    void updateGlobalPosition(UASInterface*, double lon, double lat, double alt, quint64 usec);
    void updateSpeed(UASInterface*, double x, double y, double z, quint64 usec);
    void updateState(UASInterface*, QString uasState, QString stateDescription);
pixhawk's avatar
pixhawk committed
62 63
    /** @brief Update the MAV mode */
    void updateMode(int sysId, QString status, QString description);
pixhawk's avatar
pixhawk committed
64
    void updateLoad(UASInterface* uas, double load);
65
    //void receiveValue(int uasid, QString id, double value, quint64 time);
pixhawk's avatar
pixhawk committed
66 67 68
    void refresh();
    /** @brief Receive new waypoint information */
    void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current);
69 70
    /** @brief Update the current active waypoint */
    void currentWaypointUpdated(quint16 waypoint);
pixhawk's avatar
pixhawk committed
71 72 73 74
    /** @brief Set waypoint as current target */
    void selectWaypoint(int uasId, int id);
    /** @brief Set the current system type */
    void setSystemType(UASInterface* uas, unsigned int systemType);
pixhawk's avatar
pixhawk committed
75 76
    /** @brief Set the current UAS as the globally active system */
    void setUASasActive(bool);
77 78
    /** @brief Update the view if an UAS has been set to active */
    void updateActiveUAS(UASInterface* uas, bool active);
79 80
    /** @brief Set the widget into critical mode */
    void heartbeatTimeout();
81 82
    /** @brief Set the background color for the widget */
    void setBackgroundColor();
83 84
    /** @brief Bring up the dialog to rename the system */
    void rename();
pixhawk's avatar
pixhawk committed
85 86 87 88 89 90

protected:
    void changeEvent(QEvent *e);
    QTimer* refreshTimer;
    QColor heartbeatColor;
    quint64 startTime;
91
    bool timeout;
92
    bool iconIsRed;
pixhawk's avatar
pixhawk committed
93
    int timeRemaining;
94
    float chargeLevel;
pixhawk's avatar
pixhawk committed
95
    UASInterface* uas;
96
    float load;
pixhawk's avatar
pixhawk committed
97 98
    QString state;
    QString stateDesc;
pixhawk's avatar
pixhawk committed
99
    QString mode;
100 101
    double thrust; ///< Current vehicle thrust: 0 - 1.0 for 100% thrust
    bool isActive; ///< Is this MAV selected by the user?
102 103 104 105 106 107 108
    float x;
    float y;
    float z;
    float totalSpeed;
    float lat;
    float lon;
    float alt;
109
    float groundDistance;
110
    bool localFrame;
111
    QAction* removeAction;
112
    QAction* renameAction;
113
    static const int updateInterval = 300;
114

pixhawk's avatar
pixhawk committed
115 116 117 118 119 120

    void mouseDoubleClickEvent (QMouseEvent * event);
    /** @brief Mouse enters the widget */
    void enterEvent(QEvent* event);
    /** @brief Mouse leaves the widget */
    void leaveEvent(QEvent* event);
121
    /** @brief Start widget updating */
122
    void showEvent(QShowEvent* event);
123 124
    /** @brief Stop widget updating */
    void hideEvent(QHideEvent* event);
125
    void contextMenuEvent(QContextMenuEvent* event);
pixhawk's avatar
pixhawk committed
126 127 128 129 130 131 132 133 134 135

private:
    Ui::UASView *m_ui;

signals:
    void uasInFocus(UASInterface* uas);
    void uasOutFocus(UASInterface* uas);
};

#endif // UASVIEW_H