diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index f9bf75db2c..01337e05b4 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -257,6 +257,9 @@ void NavigationStyle::initialize() setRotationCenterMode(NavigationStyle::RotationCenterMode::ScenePointAtCursor | NavigationStyle::RotationCenterMode::BoundingBoxCenter); } + + this->hasDragged = false; + this->hasPanned = false; } void NavigationStyle::finalize() @@ -583,6 +586,7 @@ void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane // Reposition camera according to the vector difference between the // projected points. cam->position = cam->position.getValue() - (current_planept - old_planept); + hasPanned = true; } void NavigationStyle::pan(SoCamera* camera) @@ -895,6 +899,8 @@ void NavigationStyle::spin(const SbVec2f & pointerpos) // when the user quickly trigger (as in "click-drag-release") a spin // animation. if (this->spinsamplecounter > 3) this->spinsamplecounter = 3; + + hasDragged = true; } /*! @@ -929,6 +935,7 @@ void NavigationStyle::spin_simplified(SoCamera* cam, SbVec2f curpos, SbVec2f pre r.invert(); this->reorientCamera(cam, r); + hasDragged = true; } SbBool NavigationStyle::doSpin() @@ -1345,6 +1352,11 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode) return; } + if (newmode != NavigationStyle::IDLE) { + hasPanned = false; + hasDragged = false; + } + switch (newmode) { case DRAGGING: // Set up initial projection point for the projector object when diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index e3e22e4761..8e17166781 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -259,6 +259,8 @@ protected: SbBool invertZoom; SbBool zoomAtCursor; float zoomStep; + SbBool hasDragged; + SbBool hasPanned; /** @name Mouse model */ //@{ diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/OpenSCADNavigationStyle.cpp index 3a9b183a8b..e5e388aab8 100644 --- a/src/Gui/OpenSCADNavigationStyle.cpp +++ b/src/Gui/OpenSCADNavigationStyle.cpp @@ -143,9 +143,10 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) if (!viewer->isEditing()) { // If we are in zoom or pan mode ignore RMB events otherwise // the canvas doesn't get any release events - if (curmode != NavigationStyle::ZOOMING && + if ((curmode != NavigationStyle::ZOOMING && curmode != NavigationStyle::PANNING && - curmode != NavigationStyle::DRAGGING) { + curmode != NavigationStyle::DRAGGING) || + (curmode == NavigationStyle::PANNING && !hasPanned)) { if (this->isPopupMenuEnabled()) { if (!press) { // release right mouse button this->openPopupMenu(event->getPosition()); @@ -165,6 +166,9 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) newmode = NavigationStyle::IDLE; processed = true; } + else if (!press && curmode == NavigationStyle::PANNING && hasPanned) { + processed = true; + } break; case SoMouseButtonEvent::BUTTON3: this->button3down = press; diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/TinkerCADNavigationStyle.cpp index 71d09932c4..e229a61f52 100644 --- a/src/Gui/TinkerCADNavigationStyle.cpp +++ b/src/Gui/TinkerCADNavigationStyle.cpp @@ -110,7 +110,6 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) const auto event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; - SbBool shortRMBclick = false; switch (button) { case SoMouseButtonEvent::BUTTON1: @@ -135,14 +134,6 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) mouseDownConsumedEvent = *event; mouseDownConsumedEvent.setTime(ev->getTime()); } - else if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON2) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = float(QApplication::doubleClickInterval())/1000.0f; - // time between press and release event - if (tmp.getValue() < dci) { - shortRMBclick = true; - } - } // About to start rotating if (press && (curmode == NavigationStyle::IDLE)) { @@ -151,16 +142,17 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) this->centerTime = ev->getTime(); processed = true; } - else if (!press && (curmode == NavigationStyle::DRAGGING)) { - if (shortRMBclick) { - newmode = NavigationStyle::IDLE; - if (!viewer->isEditing()) { - // If we are in drag mode but mouse hasn't been moved open the context-menu - if (this->isPopupMenuEnabled()) { - this->openPopupMenu(event->getPosition()); - } - processed = true; + else if (!press && curmode == NavigationStyle::DRAGGING && hasDragged) { + processed = true; + } + else if (!press && curmode == NavigationStyle::DRAGGING && !hasDragged) { + newmode = NavigationStyle::IDLE; + if (!viewer->isEditing()) { + // If we are in drag mode but mouse hasn't been moved open the context-menu + if (this->isPopupMenuEnabled()) { + this->openPopupMenu(event->getPosition()); } + processed = true; } } break;