1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-13 20:48:42 +01:00
LibrePilot/ground/openpilotgcs/src/plugins/pfdqml/osgearth.h
Dmytro Poplavskiy f95bd8bc1b Initial implementation of QML based PFD widget
It uses the same pfd.svg file as original PFD widget;
depends on osgearth for terrain rendering
2012-07-23 17:19:24 +10:00

118 lines
3.4 KiB
C++

/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef OSGEARTH_H
#define OSGEARTH_H
#include <osgViewer/Viewer>
#include <QtDeclarative/QDeclarativeItem>
#include <osgQt/GraphicsWindowQt>
class QGLFramebufferObject;
class QGLWidget;
class OsgEarthItem : public QDeclarativeItem
{
Q_OBJECT
Q_DISABLE_COPY(OsgEarthItem)
Q_PROPERTY(QString sceneFile READ sceneFile WRITE setSceneFile NOTIFY sceneFileChanged)
Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged)
Q_PROPERTY(qreal roll READ roll WRITE setRoll NOTIFY rollChanged)
Q_PROPERTY(qreal pitch READ pitch WRITE setPitch NOTIFY pitchChanged)
Q_PROPERTY(qreal yaw READ yaw WRITE setYaw NOTIFY yawChanged)
Q_PROPERTY(double latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged)
Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged)
public:
OsgEarthItem(QDeclarativeItem *parent = 0);
~OsgEarthItem();
QString sceneFile() const { return m_sceneFile; }
qreal fieldOfView() const { return m_fieldOfView; }
qreal roll() const { return m_roll; }
qreal pitch() const { return m_pitch; }
qreal yaw() const { return m_yaw; }
double latitude() const { return m_latitude; }
double longitude() const { return m_longitude; }
double altitude() const { return m_altitude; }
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *style, QWidget *widget);
public slots:
void setSceneFile(QString arg);
void setFieldOfView(qreal arg);
void setRoll(qreal arg);
void setPitch(qreal arg);
void setYaw(qreal arg);
void setLatitude(double arg);
void setLongitude(double arg);
void setAltitude(double arg);
signals:
void rollChanged(qreal arg);
void pitchChanged(qreal arg);
void yawChanged(qreal arg);
void latitudeChanged(double arg);
void longitudeChanged(double arg);
void altitudeChanged(double arg);
void sceneFileChanged(QString arg);
void fieldOfViewChanged(qreal arg);
private slots:
void markCameraDirty();
void updateFBO();
void initScene();
private:
osg::ref_ptr<osgViewer::Viewer> m_viewer;
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> m_gw;
osg::ref_ptr<osg::Node> m_model;
QWeakPointer<QGLWidget> m_glWidget;
QGLFramebufferObject *m_fbo;
QSize m_currentSize;
qreal m_roll;
qreal m_pitch;
qreal m_yaw;
double m_latitude;
double m_longitude;
double m_altitude;
qreal m_fieldOfView;
QString m_sceneFile;
bool m_cameraDirty;
};
QML_DECLARE_TYPE(OsgEarthItem)
#endif // OSGEARTH_H