root/OpenSceneGraph/trunk/examples/osgQtBrowser/QGraphicsViewAdapter.h @ 10888

Revision 10888, 2.6 kB (checked in by robert, 5 years ago)

Fixed warnings

Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef QGRAPHICSVIEWADAPTER
15#define QGRAPHICSVIEWADAPTER
16
17#include <osg/Image>
18#include <osg/observer_ptr>
19
20#include <QtWebKit/QWebSettings>
21#include <QtWebKit/QtWebKit>
22#include <QtGui/QGraphicsScene>
23#include <QtGui/QGraphicsView>
24#include <QtGui/QApplication>
25#include <QtGui/QPainter>
26#include <QtGui/QtEvents>
27
28extern QCoreApplication* getOrCreateQApplication();
29
30class QGraphicsViewAdapter : public QObject
31{
32    Q_OBJECT
33
34    public:
35
36        QGraphicsViewAdapter(osg::Image* image, QWidget* widget);
37
38        void setUpKeyMap();
39
40        bool sendPointerEvent(int x, int y, int buttonMask);
41
42
43        bool sendKeyEvent(int key, bool keyDown);
44
45
46        void setFrameLastRendered(const osg::FrameStamp* frameStamp);
47
48        void clearWriteBuffer();
49
50        void render();
51
52        void assignImage(unsigned int i);
53
54    protected:
55
56        bool handlePointerEvent(int x, int y, int buttonMask);
57        bool handleKeyEvent(int key, bool keyDown);
58
59        osg::observer_ptr<osg::Image>   _image;
60
61        int                             _previousButtonMask;
62        int                             _previousMouseX;
63        int                             _previousMouseY;
64
65        typedef std::map<int, Qt::Key> KeyMap;
66        KeyMap                          _keyMap;
67        Qt::KeyboardModifiers           _qtKeyModifiers;
68
69        QColor                          _backgroundColor;
70        QPointer<QGraphicsView>         _graphicsView;
71        QPointer<QGraphicsScene>        _graphicsScene;
72
73        OpenThreads::Mutex              _qimagesMutex;
74        int                             _previousFrameNumber;
75        bool                            _newImageAvailable;
76        unsigned int                    _currentRead;
77        unsigned int                    _currentWrite;
78        unsigned int                    _previousWrite;
79        QImage                          _qimages[3];
80
81        virtual void customEvent ( QEvent * event ) ;
82
83    private slots:
84
85        void repaintRequestedSlot(const QList<QRectF> &regions);
86
87};
88
89#endif
Note: See TracBrowser for help on using the browser.