Commit 24f08224 authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: Set-and-visualize-active-examiner

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4729 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 786d2c0a
...@@ -564,6 +564,7 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){ ...@@ -564,6 +564,7 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
break; break;
case QtMultiViewLayout::HSplit: case QtMultiViewLayout::HSplit:
baseLayout_->setMode (QtMultiViewLayout::SingleView); baseLayout_->setMode (QtMultiViewLayout::SingleView);
PluginFunctions::setActiveExaminer (0);
break; break;
} }
} }
......
...@@ -40,8 +40,10 @@ ...@@ -40,8 +40,10 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include "QtGLGraphicsScene.hh" #include "QtGLGraphicsScene.hh"
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <QApplication>
#include <QPainter> #include <QPainter>
#include <QPaintEngine> #include <QPaintEngine>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
...@@ -58,7 +60,7 @@ QtGLGraphicsScene::QtGLGraphicsScene(std::vector< glViewer *> *_views) : ...@@ -58,7 +60,7 @@ QtGLGraphicsScene::QtGLGraphicsScene(std::vector< glViewer *> *_views) :
} }
void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &) void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &_rect)
{ {
if (_painter->paintEngine()->type() != QPaintEngine::OpenGL) { if (_painter->paintEngine()->type() != QPaintEngine::OpenGL) {
std::cerr << "QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n"; std::cerr << "QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
...@@ -73,19 +75,52 @@ void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &) ...@@ -73,19 +75,52 @@ void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &)
glewInit(); glewInit();
} }
_painter->setBackground(QApplication::palette().window());
_painter->eraseRect(_rect);
for (unsigned int i = 0; i < views_->size (); i++) for (unsigned int i = 0; i < views_->size (); i++)
{ {
if (views_->at(i)->isVisible()) if (views_->at(i)->isVisible())
views_->at(i)->paintGL(); views_->at(i)->paintGL();
} }
int i = PluginFunctions::activeExaminer();
QPen pen(Qt::red);
pen.setWidth (2);
_painter->setPen(pen);
_painter->drawLine(views_->at(i)->scenePos().x(),
views_->at(i)->scenePos().y(),
views_->at(i)->scenePos().x(),
views_->at(i)->scenePos().y() + views_->at(i)->size().height() - 1);
_painter->drawLine(views_->at(i)->scenePos().x() + views_->at(i)->size().width(),
views_->at(i)->scenePos().y(),
views_->at(i)->scenePos().x() + views_->at(i)->size().width(),
views_->at(i)->scenePos().y() + views_->at(i)->size().height() - 1);
_painter->drawLine(views_->at(i)->scenePos().x(),
views_->at(i)->scenePos().y() - 1,
views_->at(i)->scenePos().x() + views_->at(i)->size().width(),
views_->at(i)->scenePos().y() - 1);
_painter->drawLine(views_->at(i)->scenePos().x(),
views_->at(i)->scenePos().y() + views_->at(i)->size().height() - 1,
views_->at(i)->scenePos().x() + views_->at(i)->size().width(),
views_->at(i)->scenePos().y() + views_->at(i)->size().height() - 1);
} }
glViewer* QtGLGraphicsScene::findView (const QPointF &p) glViewer* QtGLGraphicsScene::findView (const QPointF &_p, bool _setActive)
{ {
for (unsigned int i = 0; i < views_->size (); i++) for (unsigned int i = 0; i < views_->size (); i++)
{ {
if (views_->at(i)->contains(views_->at(i)->mapFromScene (p))) if (views_->at(i)->contains(views_->at(i)->mapFromScene (_p)))
return views_->at(i); {
if (_setActive && PluginFunctions::activeExaminer() != i)
{
PluginFunctions::setActiveExaminer (i);
update();
}
return views_->at(i);
}
} }
return NULL; return NULL;
} }
...@@ -95,7 +130,7 @@ void QtGLGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* _e) ...@@ -95,7 +130,7 @@ void QtGLGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* _e)
QGraphicsScene::mousePressEvent(_e); QGraphicsScene::mousePressEvent(_e);
if (_e->isAccepted()) if (_e->isAccepted())
return; return;
glViewer *v = findView (_e->scenePos()); glViewer *v = findView (_e->scenePos(), true);
if (!v) if (!v)
return; return;
...@@ -111,7 +146,7 @@ void QtGLGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e) ...@@ -111,7 +146,7 @@ void QtGLGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e)
QGraphicsScene::mouseDoubleClickEvent(_e); QGraphicsScene::mouseDoubleClickEvent(_e);
if (_e->isAccepted()) if (_e->isAccepted())
return; return;
glViewer *v = findView (_e->scenePos()); glViewer *v = findView (_e->scenePos(), true);
if (!v) if (!v)
return; return;
...@@ -161,7 +196,7 @@ void QtGLGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent* _e) ...@@ -161,7 +196,7 @@ void QtGLGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent* _e)
if (_e->isAccepted()) if (_e->isAccepted())
return; return;
glViewer *v = findView (_e->scenePos()); glViewer *v = findView (_e->scenePos(), true);
if (!v) if (!v)
return; return;
......
...@@ -82,7 +82,7 @@ protected: ...@@ -82,7 +82,7 @@ protected:
private: private:
glViewer* findView (const QPointF &p); glViewer* findView (const QPointF &_p, bool _setActive = false);
std::vector< glViewer *> *views_; std::vector< glViewer *> *views_;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment