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

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){
break;
case QtMultiViewLayout::HSplit:
baseLayout_->setMode (QtMultiViewLayout::SingleView);
PluginFunctions::setActiveExaminer (0);
break;
}
}
......
......@@ -40,8 +40,10 @@
//== INCLUDES =================================================================
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include "QtGLGraphicsScene.hh"
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <QApplication>
#include <QPainter>
#include <QPaintEngine>
#include <QGraphicsSceneMouseEvent>
......@@ -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) {
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 &)
glewInit();
}
_painter->setBackground(QApplication::palette().window());
_painter->eraseRect(_rect);
for (unsigned int i = 0; i < views_->size (); i++)
{
if (views_->at(i)->isVisible())
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++)
{
if (views_->at(i)->contains(views_->at(i)->mapFromScene (p)))
return views_->at(i);
if (views_->at(i)->contains(views_->at(i)->mapFromScene (_p)))
{
if (_setActive && PluginFunctions::activeExaminer() != i)
{
PluginFunctions::setActiveExaminer (i);
update();
}
return views_->at(i);
}
}
return NULL;
}
......@@ -95,7 +130,7 @@ void QtGLGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* _e)
QGraphicsScene::mousePressEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos());
glViewer *v = findView (_e->scenePos(), true);
if (!v)
return;
......@@ -111,7 +146,7 @@ void QtGLGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e)
QGraphicsScene::mouseDoubleClickEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos());
glViewer *v = findView (_e->scenePos(), true);
if (!v)
return;
......@@ -161,7 +196,7 @@ void QtGLGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent* _e)
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos());
glViewer *v = findView (_e->scenePos(), true);
if (!v)
return;
......
......@@ -82,7 +82,7 @@ protected:
private:
glViewer* findView (const QPointF &p);
glViewer* findView (const QPointF &_p, bool _setActive = false);
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