void RNavigationAction::mousePressEvent(RMouseEvent& event) { if (event.button() == Qt::MidButton || ( event.button() == Qt::LeftButton && event.modifiers() == Qt::ControlModifier)) { panOrigin = event.getScreenPosition(); panning = true; event.getGraphicsView().startPan(); } }
/** * This should be called by the mouse move event handler of a higher level * GUI toolkit. Events are forwarded to the scene and the navigation action * that is attached to this view. */ void RGraphicsView::handleMouseMoveEvent(RMouseEvent& event) { lastKnownModelPosition = event.getModelPosition(); lastKnownScreenPosition = event.getScreenPosition(); if (scene != NULL) { scene->handleMouseMoveEvent(event); } if (navigationAction != NULL) { navigationAction->mouseMoveEvent(event); } }
/** * This should be called by the mouse double click event handler of a higher level * GUI toolkit. Events are forwarded to the scene and the navigation action * that is attached to this view. */ void RGraphicsView::handleMouseDoubleClickEvent(RMouseEvent& event) { lastKnownModelPosition = event.getModelPosition(); lastKnownScreenPosition = event.getScreenPosition(); if (scene == NULL) { return; } scene->handleMouseDoubleClickEvent(event); if (navigationAction!=NULL) { navigationAction->mouseDoubleClickEvent(event); } }
void RNavigationAction::mouseMoveEvent(RMouseEvent& event) { if (panning && ( event.buttons() == Qt::MidButton || ( event.buttons() == Qt::LeftButton && event.modifiers() == Qt::ControlModifier ) )) { RVector panTarget = event.getScreenPosition(); RVector panDelta = panTarget - panOrigin; if (fabs(panDelta.x) > 1 || fabs(panDelta.y) > 1) { event.getGraphicsView().pan(panDelta); panOrigin = panTarget; } } }
/** * This should be called by the mouse press event handler of a higher level * GUI toolkit. Events are forwarded to the scene and the navigation action * that is attached to this view. */ void RGraphicsView::handleMousePressEvent(RMouseEvent& event) { lastKnownModelPosition = event.getModelPosition(); lastKnownScreenPosition = event.getScreenPosition(); if (scene == NULL) { return; } scene->handleMousePressEvent(event); if (navigationAction!=NULL) { navigationAction->mousePressEvent(event); } // remember mouse press position to use for mouse release: //mousePressScreenPosition = event.getScreenPosition(); //mousePressModelPosition = event.getModelPosition(); }
/** * This should be called by the mouse release event handler of a higher level * GUI toolkit. Events are forwarded to the scene and the navigation action * that is attached to this view. */ void RGraphicsView::handleMouseReleaseEvent(RMouseEvent& event) { // use mouse press position for release and final posisiton: // if (mousePressModelPosition.isValid()) { // event.setModelPosition(mousePressModelPosition); // mousePressModelPosition = RVector::invalid; // } // if (mousePressScreenPosition.isValid()) { // event.setScreenPosition(mousePressScreenPosition); // mousePressScreenPosition = RVector::invalid; // } lastKnownModelPosition = event.getModelPosition(); lastKnownScreenPosition = event.getScreenPosition(); if (scene == NULL) { return; } scene->handleMouseReleaseEvent(event); if (navigationAction!=NULL && !event.isAccepted()) { navigationAction->mouseReleaseEvent(event); } }