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" 70 SimpleGLGraphicsScene::SimpleGLGraphicsScene () :
76 cursorPainter_->setEnabled(
OpenFlipperSettings().value(
"Core/Gui/glViewer/nativeMouse",
false).toBool() );
80 void 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();
107 view_->initializeGL();
108 cursorPainter_->initializeGL ();
112 if (cursorPainter_->enabled())
116 glGetDoublev(GL_PROJECTION_MATRIX, mat);
118 glMatrixMode(GL_MODELVIEW);
121 glPushAttrib (GL_ALL_ATTRIB_BITS);
122 view_->updateCursorPosition(cursorPainter_->cursorPosition ());
125 glMatrixMode(GL_PROJECTION);
127 glMatrixMode(GL_MODELVIEW);
129 glClear(GL_DEPTH_BUFFER_BIT);
133 glClear(GL_DEPTH_BUFFER_BIT);
138 _painter->endNativePainting();
142 void SimpleGLGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
144 QGraphicsScene::mouseMoveEvent(_e);
145 if (_e->isAccepted())
149 view_->mouseMoveEvent(_e);
152 void SimpleGLGraphicsScene::setView(
glViewer * _view)
155 cursorPainter_->registerViewer (view_);
160 bool SimpleGLGraphicsScene::event(QEvent *_event)
162 if (_event->type() == QEvent::Enter)
164 cursorPainter_->setMouseIn (
true);
166 else if (_event->type() == QEvent::Leave)
168 cursorPainter_->setMouseIn (
false);
171 else if (cursorPainter_ && _event->type() == QEvent::GraphicsSceneMouseMove)
173 QGraphicsSceneMouseEvent *e =
static_cast<QGraphicsSceneMouseEvent*
>(_event);
174 cursorPainter_->updateCursorPosition (e->scenePos ());
177 return QGraphicsScene::event (_event);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.