QGCGoogleEarthView.h 2.47 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4
#ifndef QGCGOOGLEEARTHVIEW_H
#define QGCGOOGLEEARTHVIEW_H

#include <QWidget>
5 6
#include <QTimer>
#include <UASInterface.h>
pixhawk's avatar
pixhawk committed
7

8 9 10 11
#if (defined Q_OS_MAC)
#include <QWebView>
#endif

12
#ifdef _MSC_VER
13 14 15
#include <ActiveQt/QAxWidget>
#include "windows.h"

16
class QGCWebAxWidget : public QAxWidget
17 18 19
{
public:

20
    QGCWebAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0)
21 22
        : QAxWidget(parent, f)
    {
23 24
		// Set web browser control
		setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}");
25 26 27 28 29 30 31 32 33 34 35
    }
protected:
    virtual bool translateKeyEvent(int message, int keycode) const
    {
        if (message >= WM_KEYFIRST && message <= WM_KEYLAST)
            return true;
        else
            return QAxWidget::translateKeyEvent(message, keycode);
    }

};
36 37
#endif

pixhawk's avatar
pixhawk committed
38
namespace Ui {
39 40
#ifdef _MSC_VER
    class QGCGoogleEarthView;
41
#else
pixhawk's avatar
pixhawk committed
42
    class QGCGoogleEarthView;
43
#endif
pixhawk's avatar
pixhawk committed
44 45 46 47 48 49 50 51 52 53
}

class QGCGoogleEarthView : public QWidget
{
    Q_OBJECT

public:
    explicit QGCGoogleEarthView(QWidget *parent = 0);
    ~QGCGoogleEarthView();

54 55 56
public slots:
    /** @brief Update the internal state. Does not trigger a redraw */
    void updateState();
pixhawk's avatar
pixhawk committed
57 58
    /** @brief Add a new MAV/UAS to the visualization */
    void addUAS(UASInterface* uas);
59 60
    /** @brief Set the currently selected UAS */
    void setActiveUAS(UASInterface* uas);
pixhawk's avatar
pixhawk committed
61 62
    /** @brief Update the global position */
    void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
63
    /** @brief Show the vehicle trail */
pixhawk's avatar
pixhawk committed
64
    void showTrail(bool state);
65
    /** @brief Show the waypoints */
pixhawk's avatar
pixhawk committed
66
    void showWaypoints(bool state);
67 68
    /** @brief Follow the aircraft during flight */
    void follow(bool follow);
pixhawk's avatar
pixhawk committed
69 70 71 72 73 74
    /** @brief Go to the home location */
    void goHome();
    /** @brief Set the home location */
    void setHome(double lat, double lon, double alt);
    /** @brief Initialize Google Earth */
    void initializeGoogleEarth();
75

pixhawk's avatar
pixhawk committed
76 77
protected:
    void changeEvent(QEvent *e);
78
    QTimer* updateTimer;
pixhawk's avatar
pixhawk committed
79
    int refreshRateMs;
80 81
    UASInterface* mav;
    bool followCamera;
pixhawk's avatar
pixhawk committed
82
    bool trailEnabled;
pixhawk's avatar
pixhawk committed
83
    bool webViewInitialized;
pixhawk's avatar
pixhawk committed
84
    bool gEarthInitialized;
85 86
#ifdef _MSC_VER
    QGCWebAxWidget* webViewWin;
87 88 89 90
#endif
#if (defined Q_OS_MAC)
    QWebView* webViewMac;
#endif
pixhawk's avatar
pixhawk committed
91

92
    /** @brief Start widget updating */
93
    void showEvent(QShowEvent* event);
94 95
    /** @brief Stop widget updating */
    void hideEvent(QHideEvent* event);
96

pixhawk's avatar
pixhawk committed
97
private:
98 99
#ifdef _MSC_VER
    Ui::QGCGoogleEarthView* ui;
100 101
#else
    Ui::QGCGoogleEarthView* ui;
102
#endif
pixhawk's avatar
pixhawk committed
103 104
};

105
#endif // QGCGOOGLEEARTHVIEW_H