-
Notifications
You must be signed in to change notification settings - Fork 0
/
osgRenderNode.h
88 lines (75 loc) · 2.5 KB
/
osgRenderNode.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef OSGRENDERNODE_H
#define OSGRENDERNODE_H
#include <QSGRenderNode>
#include <osgViewer/Viewer>
#include <QOpenGLFunctions_2_0>
class QQuickItem;
class QInputEvent;
class QKeyEvent;
class QMouseEvent;
class QWheelEvent;
namespace eveBIM
{
class ViewerWidget;
}
class OSGRenderNode: public QSGRenderNode , public osgViewer::Viewer, public QObject
{
public:
OSGRenderNode(QQuickItem *parent);
~OSGRenderNode() override;
void render(const RenderState *state) override;
void releaseResources() override;
StateFlags changedStates() const override;
RenderingFlags flags() const override;
QRectF rect() const override;
void sync(QQuickItem *item);
//osg----------------------------------------
bool continuousUpdate() const
{
return mcontinuousUpdate;
}
void setContinuousUpdate(bool continuousUpdate)
{
mcontinuousUpdate = continuousUpdate;
}
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void mouseDoubleClickEvent(QMouseEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void wheelEvent(QWheelEvent* event);
virtual void resize(int windowX, int windowY, int windowWidth, int windowHeight, float windowScale);
void setupOSG(int windowX, int windowY, int windowWidth, int windowHeight, float windowScale);
// overrided from osgViewer::Viewer
virtual bool checkNeedToDoFrame() override;
// overrided from osgViewer::ViewerBase
void frame(double simulationTime = USE_REFERENCE_TIME) override;
// overrided from osgViewer::Viewer
void requestRedraw() override;
// overrided from osgViewer::Viewer
bool checkEvents() override;
void update();
protected:
void timerEvent(QTimerEvent* event) override;
void setKeyboardModifiers(QInputEvent* event);
private:
friend class eveBIM::ViewerWidget;
bool mosgInitialized {false};
osg::ref_ptr<osgViewer::GraphicsWindow> mosgWinEmb;
float mwindowScale {1.0f};
bool mcontinuousUpdate {true};
int _timerId{0};
osg::Timer _lastFrameStartTime;
bool _applicationAboutToQuit {false};
bool _osgWantsToRenderFrame{true};
int mWidth = 0;
int mHeight = 0;
int mX = 0;
int mXOld = -1;
int mY = 0;
int mYOld = -1;
QQuickItem* mOSGItem{nullptr};
QOpenGLFunctions_2_0 *mGLFunctions = nullptr;
};
#endif // OSGRENDERNODE_H