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