61 #include <ACG/GL/acg_glew.hh>
64 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
65 #include <QApplication>
67 #include <QPaintEngine>
68 #include <QGraphicsSceneMouseEvent>
70 #include "simpleGLGraphicsScene.hh"
76 SimpleGLGraphicsScene::SimpleGLGraphicsScene () :
82 cursorPainter_->setEnabled(
OpenFlipperSettings().value(
"Core/Gui/glViewer/nativeMouse",
false).toBool() );
86 void SimpleGLGraphicsScene::drawBackground(QPainter *_painter,
const QRectF &_rect)
90 #if QT_VERSION >= 0x040600
91 if (_painter->paintEngine()->type() != QPaintEngine::OpenGL && _painter->paintEngine()->type() != QPaintEngine::OpenGL2 ) {
92 std::cerr <<
"QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
96 if (_painter->paintEngine()->type() != QPaintEngine::OpenGL ) {
97 std::cerr <<
"QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
103 _painter->setBackground(QApplication::palette().window());
104 _painter->eraseRect(_rect);
110 #if QT_VERSION >= 0x040600
112 _painter->beginNativePainting();
131 glGetDoublev(GL_PROJECTION_MATRIX, mat);
133 glMatrixMode(GL_MODELVIEW);
136 glPushAttrib (GL_ALL_ATTRIB_BITS);
140 glMatrixMode(GL_PROJECTION);
142 glMatrixMode(GL_MODELVIEW);
144 glClear(GL_DEPTH_BUFFER_BIT);
148 glClear(GL_DEPTH_BUFFER_BIT);
152 #if QT_VERSION >= 0x040600
154 _painter->endNativePainting();
159 void SimpleGLGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
161 QGraphicsScene::mouseMoveEvent(_e);
162 if (_e->isAccepted())
169 void SimpleGLGraphicsScene::setView(
glViewer * _view)
177 bool SimpleGLGraphicsScene::event(QEvent *_event)
179 if (_event->type() == QEvent::Enter)
183 else if (_event->type() == QEvent::Leave)
188 else if (cursorPainter_ && _event->type() == QEvent::GraphicsSceneMouseMove)
190 QGraphicsSceneMouseEvent *e =
static_cast<QGraphicsSceneMouseEvent*
>(_event);
194 return QGraphicsScene::event (_event);
bool enabled()
Returns true if cursor painting is enabled and compatible cursor is set.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
virtual void paintGL(double _aspect=0.0)
draw the scene. Triggered by updateGL().
void updateCursorPosition(QPointF _scenePos)
Sets the current cursor position.
QPointF cursorPosition()
Return the current cursor position.
void updateCursorPosition(QPointF _scenePos)
will be called from CursorPainter to inform the viewer that the cursor position changed ...
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *_event)
handle mouse move events
void initializeGL()
Needs to be called after the gl context has been set up to initialize internal values.
void registerViewer(glViewer *_viewer)
Add a glViewer that will use this CursorPainter.
virtual void initializeGL()
Return a resonable size hint.
void setMouseIn(bool _in)
Inform the cursor painter about mouse enter / leave.