Commit 2c785a79 authored by Jan Möbius's avatar Jan Möbius

Dennis: Fixed-multiview-mouse-handling

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5979 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a4e0a50a
......@@ -223,6 +223,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glViewer* examinerWidget = new glViewer(glScene_,
glWidget_,
PluginFunctions::viewerProperties(0),
0,
centerWidget_,
"Examiner Widget",
statusBar_);
......@@ -241,6 +242,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glViewer* newWidget = new glViewer(glScene_,
glWidget_,
PluginFunctions::viewerProperties(i),
i,
centerWidget_,
"Examiner Widget",
statusBar_);
......
......@@ -117,11 +117,12 @@ static const char VIEW_MAGIC[] =
glViewer::glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget,
QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent,
const char* /* _name */ ,
QStatusBar *_statusBar) :
unsigned int _id,
QGraphicsWidget* _parent,
const char* /* _name */ ,
QStatusBar *_statusBar) :
QGraphicsWidget(_parent),
statusbar_(_statusBar),
glareaGrabbed_(false),
......@@ -129,6 +130,7 @@ glViewer::glViewer( QtGLGraphicsScene* _scene,
blending_(true),
glScene_(_scene),
glWidget_(_glWidget),
id_(_id),
properties_(_properties),
glstate_(0)
{
......@@ -1269,31 +1271,39 @@ void glViewer::contextMenuEvent(QGraphicsSceneContextMenuEvent* _e)
//-----------------------------------------------------------------------------
void glViewer::glMousePressEvent(QMouseEvent* _event)
void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
{
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonPress ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
_e->accept ();
PluginFunctions::setActiveExaminer (id_);
glScene_->update ();
// right button pressed => popup menu (ignore here)
if (_event->button() != Qt::RightButton )
if (_e->button() != Qt::RightButton )
{
switch (PluginFunctions::actionMode())
{
case Viewer::ExamineMode:
if ((_event->modifiers() & Qt::ControlModifier)) // drag&drop
emit startDragEvent( _event );
if ((_e->modifiers() & Qt::ControlModifier)) // drag&drop
emit startDragEvent( &me );
else
viewMouseEvent(_event); // examine
viewMouseEvent(&me); // examine
break;
case Viewer::LightMode:
lightMouseEvent(_event);
lightMouseEvent(&me);
break;
case Viewer::PickingMode: // give event to application
emit(signalMouseEvent(_event, PluginFunctions::pickMode() ));
emit(signalMouseEvent(_event));
emit(signalMouseEvent(&me, PluginFunctions::pickMode() ));
emit(signalMouseEvent(&me));
break;
case Viewer::QuestionMode: // give event to application
emit(signalMouseEventIdentify(_event));
emit(signalMouseEventIdentify(&me));
break;
}
}
......@@ -1303,25 +1313,33 @@ void glViewer::glMousePressEvent(QMouseEvent* _event)
//-----------------------------------------------------------------------------
void glViewer::glMouseDoubleClickEvent(QMouseEvent* _event)
void glViewer::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e)
{
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonDblClick ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
_e->accept ();
PluginFunctions::setActiveExaminer (id_);
glScene_->update ();
switch (PluginFunctions::actionMode())
{
case Viewer::ExamineMode:
viewMouseEvent(_event);
viewMouseEvent(&me);
break;
case Viewer::LightMode:
lightMouseEvent(_event);
lightMouseEvent(&me);
break;
case Viewer::PickingMode: // give event to application
emit(signalMouseEvent(_event, PluginFunctions::pickMode() ));
emit(signalMouseEvent(_event));
emit(signalMouseEvent(&me, PluginFunctions::pickMode() ));
emit(signalMouseEvent(&me));
break;
case Viewer::QuestionMode: // give event to application
emit(signalMouseEventIdentify(_event));
emit(signalMouseEventIdentify(&me));
break;
}
}
......@@ -1330,31 +1348,36 @@ void glViewer::glMouseDoubleClickEvent(QMouseEvent* _event)
//-----------------------------------------------------------------------------
void glViewer::glMouseMoveEvent(QMouseEvent* _event)
void glViewer::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
{
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseMove ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
_e->accept();
switch ( PluginFunctions::actionMode() )
{
case Viewer::ExamineMode:
viewMouseEvent(_event);
viewMouseEvent(&me);
break;
case Viewer::LightMode:
lightMouseEvent(_event);
lightMouseEvent(&me);
break;
case Viewer::PickingMode:
// give event to application
// deliver mouse moves with no button down, if tracking is enabled,
if ((_event->buttons() & (Qt::LeftButton | Qt::MidButton | Qt::RightButton))
if ((_e->buttons() & (Qt::LeftButton | Qt::MidButton | Qt::RightButton))
|| trackMouse_)
{
emit(signalMouseEvent(_event, PluginFunctions::pickMode() ));
emit(signalMouseEvent(_event));
emit(signalMouseEvent(&me, PluginFunctions::pickMode() ));
emit(signalMouseEvent(&me));
}
break;
case Viewer::QuestionMode: // give event to application
emit(signalMouseEventIdentify(_event));
emit(signalMouseEventIdentify(&me));
break;
default: // avoid warning
......@@ -1366,30 +1389,35 @@ void glViewer::glMouseMoveEvent(QMouseEvent* _event)
//-----------------------------------------------------------------------------
void glViewer::glMouseReleaseEvent(QMouseEvent* _event)
void glViewer::mouseReleaseEvent(QGraphicsSceneMouseEvent* _e)
{
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonRelease ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
_e->accept();
// if (_event->button() == Qt::RightButton )
// hidePopupMenus();
if (_event->button() != Qt::RightButton || (PluginFunctions::actionMode() == Viewer::PickingMode) )
if (_e->button() != Qt::RightButton || (PluginFunctions::actionMode() == Viewer::PickingMode) )
{
switch ( PluginFunctions::actionMode() )
{
case Viewer::ExamineMode:
viewMouseEvent(_event);
viewMouseEvent(&me);
break;
case Viewer::LightMode:
lightMouseEvent(_event);
lightMouseEvent(&me);
break;
case Viewer::PickingMode: // give event to application
emit(signalMouseEvent(_event, PluginFunctions::pickMode() ));
emit(signalMouseEvent(_event));
emit(signalMouseEvent(&me, PluginFunctions::pickMode() ));
emit(signalMouseEvent(&me));
break;
case Viewer::QuestionMode: // give event to application
emit(signalMouseEventIdentify(_event));
emit(signalMouseEventIdentify(&me));
break;
default: // avoid warning
......@@ -1404,16 +1432,21 @@ void glViewer::glMouseReleaseEvent(QMouseEvent* _event)
//-----------------------------------------------------------------------------
void glViewer::glMouseWheelEvent(QWheelEvent* _event)
void glViewer::wheelEvent(QGraphicsSceneWheelEvent* _e)
{
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QWheelEvent we(p, _e->screenPos(), _e->delta(), _e->buttons(),
_e->modifiers(), _e->orientation());
_e->accept();
switch ( PluginFunctions::actionMode() )
{
case Viewer::ExamineMode:
viewWheelEvent(_event);
viewWheelEvent(&we);
break;
case Viewer::PickingMode: // give event to application
emit(signalWheelEvent(_event, PluginFunctions::pickMode() ));
emit(signalWheelEvent(&we, PluginFunctions::pickMode() ));
break;
default: // avoid warning
......@@ -1504,10 +1537,6 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
{
QPoint newPoint2D = pos;
if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) ||
(newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) )
return;
double value_x, value_y;
ACG::Vec3d newPoint3D;
bool newPoint_hitSphere = mapToSphere( newPoint2D, newPoint3D );
......
......@@ -122,16 +122,18 @@ public:
\param _parent parent widget
\param _name name (qt internal, qt debugging)
\param _properties viewerOptions controlled by PluginFunctions
\param _id examiner id
\param _statusBar pointer to an existing status bar for this widget,
if \c statusBar==0 then a \a private status bar will be created
\param _format OpenGL context settings, will be passed to glarea()
*/
glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
QGraphicsWidget* _parent=0,
const char* _name=0,
QStatusBar *_statusBar=0);
QGLWidget* _glWidget,
Viewer::ViewerProperties& _properties,
unsigned int _id,
QGraphicsWidget* _parent=0,
const char* _name=0,
QStatusBar *_statusBar=0);
/// Destructor.
virtual ~glViewer();
......@@ -392,15 +394,15 @@ protected:
virtual void moveEvent (QGraphicsSceneMoveEvent * _e);
/// handle mouse press events
virtual void glMousePressEvent(QMouseEvent* _event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* _event);
/// handle mouse double click events
virtual void glMouseDoubleClickEvent(QMouseEvent* _event);
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _event);
/// handle mouse move events
virtual void glMouseMoveEvent(QMouseEvent* _event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _event);
/// handle mouse release events
virtual void glMouseReleaseEvent(QMouseEvent* _event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* _event);
/// handle mouse wheel events
virtual void glMouseWheelEvent(QWheelEvent* _event);
virtual void wheelEvent(QGraphicsSceneWheelEvent* _event);
/// handle mouse press events
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* _e);
......@@ -531,6 +533,9 @@ private:
// Base graphics widget layout
QtGLViewerLayout* glBaseLayout_;
// examiner id
unsigned int id_;
// vector of current draw mode actions
......
......@@ -116,6 +116,7 @@ void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &_rect)
}
}
glViewer* QtGLGraphicsScene::findView (const QPointF &_p, bool _setActive)
{
for (unsigned int i = 0; i < views_->size (); i++)
......@@ -133,86 +134,17 @@ glViewer* QtGLGraphicsScene::findView (const QPointF &_p, bool _setActive)
return NULL;
}
void QtGLGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* _e)
{
QGraphicsScene::mousePressEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos(), true);
if (!v)
return;
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonPress ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
v->glMousePressEvent(&me);
_e->accept();
}
void QtGLGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e)
{
QGraphicsScene::mouseDoubleClickEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos(), true);
if (!v)
return;
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonDblClick ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
v->glMouseDoubleClickEvent(&me);
_e->accept();
}
void QtGLGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* _e)
{
QGraphicsScene::mouseReleaseEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos());
if (!v)
return;
QPointF f (v->mapFromScene (_e->scenePos()));
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonRelease ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
v->glMouseReleaseEvent(&me);
_e->accept();
}
void QtGLGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* _e)
{
QGraphicsScene::mouseMoveEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos());
if (!v)
return;
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseMove ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers());
v->glMouseMoveEvent(&me);
_e->accept();
}
void QtGLGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent* _e)
{
QGraphicsScene::wheelEvent(_e);
if (_e->isAccepted())
return;
glViewer *v = findView (_e->scenePos(), true);
glViewer *v = findView (_e->scenePos());
if (!v)
return;
QPoint p (_e->scenePos().x(), _e->scenePos().y());
QWheelEvent we(p, _e->screenPos(), _e->delta(), _e->buttons(),
_e->modifiers(), _e->orientation());
v->glMouseWheelEvent(&we);
_e->accept();
v->mouseMoveEvent(_e);
}
......
......@@ -75,11 +75,7 @@ protected:
virtual void drawBackground(QPainter *_painter, const QRectF &_rect);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* _e);
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* _e);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _e);
virtual void wheelEvent(QGraphicsSceneWheelEvent* _e);
private:
......
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