55#include <ACG/GL/acg_glew.hh>
58#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
59#include <QApplication>
61#include <QPaintEngine>
62#include <QGraphicsSceneMouseEvent>
64#include "simpleGLGraphicsScene.hh"
70SimpleGLGraphicsScene::SimpleGLGraphicsScene () :
76 cursorPainter_->setEnabled(
OpenFlipperSettings().value(
"Core/Gui/glViewer/nativeMouse",
false).toBool() );
80void SimpleGLGraphicsScene::drawBackground(QPainter *_painter,
const QRectF &_rect)
84 if (_painter->paintEngine()->type() != QPaintEngine::OpenGL && _painter->paintEngine()->type() != QPaintEngine::OpenGL2 ) {
85 std::cerr <<
"QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
90 _painter->setBackground(QApplication::palette().window());
91 _painter->eraseRect(_rect);
98 _painter->beginNativePainting();
116 glGetDoublev(GL_PROJECTION_MATRIX, mat);
118 glMatrixMode(GL_MODELVIEW);
121 glPushAttrib (GL_ALL_ATTRIB_BITS);
125 glMatrixMode(GL_PROJECTION);
127 glMatrixMode(GL_MODELVIEW);
129 glClear(GL_DEPTH_BUFFER_BIT);
133 glClear(GL_DEPTH_BUFFER_BIT);
138 _painter->endNativePainting();
142void SimpleGLGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
144 QGraphicsScene::mouseMoveEvent(_e);
145 if (_e->isAccepted())
152void SimpleGLGraphicsScene::setView(
glViewer * _view)
160bool SimpleGLGraphicsScene::event(QEvent *_event)
162 if (_event->type() == QEvent::Enter)
166 else if (_event->type() == QEvent::Leave)
171 else if (cursorPainter_ && _event->type() == QEvent::GraphicsSceneMouseMove)
173 QGraphicsSceneMouseEvent *e =
static_cast<QGraphicsSceneMouseEvent*
>(_event);
177 return QGraphicsScene::event (_event);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void initializeGL()
Needs to be called after the gl context has been set up to initialize internal values.
void updateCursorPosition(QPointF _scenePos)
Sets the current cursor position.
bool enabled()
Returns true if cursor painting is enabled and compatible cursor is set.
void setMouseIn(bool _in)
Inform the cursor painter about mouse enter / leave.
QPointF cursorPosition()
Return the current cursor position.
void registerViewer(glViewer *_viewer)
Add a glViewer that will use this CursorPainter.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *_event)
handle mouse move events
virtual void paintGL(double _aspect=0.0)
draw the scene. Triggered by updateGL().
virtual void initializeGL()
Return a resonable size hint.
void updateCursorPosition(QPointF _scenePos)
will be called from CursorPainter to inform the viewer that the cursor position changed