-
Notifications
You must be signed in to change notification settings - Fork 61
/
OSGWidget.h
72 lines (52 loc) · 1.57 KB
/
OSGWidget.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 OSGWidget_h__
#define OSGWidget_h__
#include <QPoint>
#include <QOpenGLWidget>
#include <osg/ref_ptr>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/CompositeViewer>
namespace osgWidget
{
//! The subclass of osgViewer::CompositeViewer we use
/*!
* This subclassing allows us to remove the annoying automatic
* setting of the CPU affinity to core 0 by osgViewer::ViewerBase,
* osgViewer::CompositeViewer's base class.
*/
class Viewer : public osgViewer::CompositeViewer
{
public:
virtual void setupThreading();
};
}
class OSGWidget : public QOpenGLWidget
{
Q_OBJECT
public:
OSGWidget( QWidget* parent = 0,
Qt::WindowFlags f = 0 );
virtual ~OSGWidget();
protected:
virtual void paintEvent( QPaintEvent* paintEvent );
virtual void paintGL();
virtual void resizeGL( int width, int height );
virtual void keyPressEvent( QKeyEvent* event );
virtual void keyReleaseEvent( QKeyEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent* event );
virtual bool event( QEvent* event );
private:
virtual void onHome();
virtual void onResize( int width, int height );
osgGA::EventQueue* getEventQueue() const;
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> graphicsWindow_;
osg::ref_ptr<osgWidget::Viewer> viewer_;
QPoint selectionStart_;
QPoint selectionEnd_;
bool selectionActive_;
bool selectionFinished_;
void processSelection();
};
#endif