-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGlobeOsg.h
73 lines (47 loc) · 1.6 KB
/
GlobeOsg.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef GLOBE_OSG_H
#define GLOBE_OSG_H
#include <QQuickItem>
#include <QtOpenGL/QGLShaderProgram>
#include <QOpenGLShaderProgram>
// osg
#include <osgViewer/Viewer>
#include <osg/PositionAttitudeTransform>
#include <osgGA/OrbitManipulator>
#include <osgQuickNode.h>
class GlobeOsg : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(qreal zoom READ getZoom WRITE setZoom)
Q_PROPERTY(bool animate READ getAnimate WRITE setAnimate)
public:
// default ctor and dtor
GlobeOsg();
~GlobeOsg();
void setZoom(qreal zoom);
qreal getZoom();
void setAnimate(bool animate);
bool getAnimate();
// reimplement QuickItem update method
virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
// sample qml invokable method
Q_INVOKABLE void home();
protected:
// NOTE by Riccardo Corsi - this is a workaround to receive mouse events from the qml window.
// I could not find a way to use QuickItem native methods like mousePressEvent(QMouseEvent*) and so on...
Q_INVOKABLE void _mousePressEvent(int x, int y);
Q_INVOKABLE void _mouseDragEvent(int x, int y);
void setupScene();
// implement timerEvent method to force update on every frame
void timerEvent(QTimerEvent *);
qreal _zoomProp;
QImage m_texture;
// internal render node
OsgQuickNode* _osgQuickNode;
// local scene root
osg::ref_ptr<osg::PositionAttitudeTransform> _pat;
osg::ref_ptr<osgGA::OrbitManipulator> _orbit;
float _defaultDistance;
std::vector<osg::Vec2> _mousePressVec;
std::vector<osg::Vec2> _mouseDragVec;
};
#endif // GLOBE_OSG_H