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();
122 view_->initializeGL();
123 cursorPainter_->initializeGL ();
127 if (cursorPainter_->enabled())
131 glGetDoublev(GL_PROJECTION_MATRIX, mat);
133 glMatrixMode(GL_MODELVIEW);
136 glPushAttrib (GL_ALL_ATTRIB_BITS);
137 view_->updateCursorPosition(cursorPainter_->cursorPosition ());
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())
166 view_->mouseMoveEvent(_e);
169 void SimpleGLGraphicsScene::setView(
glViewer * _view)
172 cursorPainter_->registerViewer (view_);
177 bool SimpleGLGraphicsScene::event(QEvent *_event)
179 if (_event->type() == QEvent::Enter)
181 cursorPainter_->setMouseIn (
true);
183 else if (_event->type() == QEvent::Leave)
185 cursorPainter_->setMouseIn (
false);
188 else if (cursorPainter_ && _event->type() == QEvent::GraphicsSceneMouseMove)
190 QGraphicsSceneMouseEvent *e =
static_cast<QGraphicsSceneMouseEvent*
>(_event);
191 cursorPainter_->updateCursorPosition (e->scenePos ());
194 return QGraphicsScene::event (_event);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.