Skip to content
QGCGoogleEarthView.h 2.41 KiB
Newer Older
pixhawk's avatar
pixhawk committed
#ifndef QGCGOOGLEEARTHVIEW_H
#define QGCGOOGLEEARTHVIEW_H

#include <QWidget>
#include <QTimer>
#include <UASInterface.h>
#if (defined Q_OS_MAC)
#include <QWebView>
#endif

#include <ActiveQt/QAxWidget>
#include "windows.h"

class QGCWebAxWidget : public QAxWidget
    QGCWebAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0)
        : QAxWidget(parent, f)
    {
		// Set web browser control
		setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}");
    }
protected:
    virtual bool translateKeyEvent(int message, int keycode) const
    {
        if (message >= WM_KEYFIRST && message <= WM_KEYLAST)
            return true;
        else
            return QAxWidget::translateKeyEvent(message, keycode);
    }

};
pixhawk's avatar
pixhawk committed
namespace Ui {
#ifdef _MSC_VER
    class QGCGoogleEarthView;
pixhawk's avatar
pixhawk committed
    class QGCGoogleEarthView;
pixhawk's avatar
pixhawk committed
}

class QGCGoogleEarthView : public QWidget
{
    Q_OBJECT

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

public slots:
    /** @brief Update the internal state. Does not trigger a redraw */
    void updateState();
pixhawk's avatar
pixhawk committed
    /** @brief Add a new MAV/UAS to the visualization */
    void addUAS(UASInterface* uas);
    /** @brief Set the currently selected UAS */
    void setActiveUAS(UASInterface* uas);
pixhawk's avatar
pixhawk committed
    /** @brief Update the global position */
    void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
    /** @brief Show the vehicle trail */
pixhawk's avatar
pixhawk committed
    void showTrail(bool state);
    /** @brief Show the waypoints */
pixhawk's avatar
pixhawk committed
    void showWaypoints(bool state);
    /** @brief Follow the aircraft during flight */
    void follow(bool follow);
pixhawk's avatar
pixhawk committed
    /** @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();
pixhawk's avatar
pixhawk committed
protected:
    void changeEvent(QEvent *e);
    QTimer* updateTimer;
pixhawk's avatar
pixhawk committed
    int refreshRateMs;
    UASInterface* mav;
    bool followCamera;
pixhawk's avatar
pixhawk committed
    bool trailEnabled;
pixhawk's avatar
pixhawk committed
    bool webViewInitialized;
pixhawk's avatar
pixhawk committed
    bool gEarthInitialized;
#ifdef _MSC_VER
    QGCWebAxWidget* webViewWin;
#endif
#if (defined Q_OS_MAC)
    QWebView* webViewMac;
#endif
    /** @brief Enable / disable widget updating */
    void showEvent(QShowEvent* event);

pixhawk's avatar
pixhawk committed
private:
#ifdef _MSC_VER
    Ui::QGCGoogleEarthView* ui;
#else
    Ui::QGCGoogleEarthView* ui;