From 9158a92e4f8c86e204a68ec51507b3676c035d1d Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Nov 2011 09:38:36 +0000 Subject: [PATCH] + fix issue with rotation enter with panning git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5103 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Gui/BlenderNavigationStyle.cpp | 5 ++++- src/Gui/CADNavigationStyle.cpp | 10 ++++++++-- src/Gui/InventorNavigationStyle.cpp | 10 ++++++++-- src/Gui/NavigationStyle.cpp | 26 ++++++++++++++++++++++++++ src/Gui/NavigationStyle.h | 1 + 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index 5a2eb76c5..3b431e1ba 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -247,7 +247,10 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) float dci = (float)QApplication::doubleClickInterval()/1000.0f; // is it just a middle click? if (tmp.getValue() < dci && !this->lockrecenter) { - panToCenter(panningplane, posn); + if (!this->moveToPoint(pos)) { + panToCenter(panningplane, posn); + this->interactiveCountDec(); + } processed = TRUE; } } diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index c75481f22..a54541c9e 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -189,7 +189,10 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) float dci = (float)QApplication::doubleClickInterval()/1000.0f; // is it just a left click? if (tmp.getValue() < dci && !this->lockrecenter) { - panToCenter(panningplane, posn); + if (!this->moveToPoint(pos)) { + panToCenter(panningplane, posn); + this->interactiveCountDec(); + } processed = TRUE; } } @@ -273,7 +276,10 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) float dci = (float)QApplication::doubleClickInterval()/1000.0f; // is it just a middle click? if (tmp.getValue() < dci && !this->lockrecenter) { - panToCenter(panningplane, posn); + if (!this->moveToPoint(pos)) { + panToCenter(panningplane, posn); + this->interactiveCountDec(); + } processed = TRUE; } } diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 9c40edc4e..aa4e41eec 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -182,7 +182,10 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) float dci = (float)QApplication::doubleClickInterval()/1000.0f; // is it just a left click? if (tmp.getValue() < dci && !this->lockrecenter) { - panToCenter(panningplane, posn); + if (!this->moveToPoint(pos)) { + panToCenter(panningplane, posn); + this->interactiveCountDec(); + } processed = TRUE; } } @@ -237,7 +240,10 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) float dci = (float)QApplication::doubleClickInterval()/1000.0f; // is it just a middle click? if (tmp.getValue() < dci && !this->lockrecenter) { - panToCenter(panningplane, posn); + if (!this->moveToPoint(pos)) { + panToCenter(panningplane, posn); + this->interactiveCountDec(); + } processed = TRUE; } } diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 52bb142a5..a4b325a93 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -281,6 +281,32 @@ void NavigationStyle::seekToPoint(const SbVec3f& scenepos) viewer->seekToPoint(scenepos); } +SbBool NavigationStyle::moveToPoint(const SbVec2s screenpos) +{ + SoCamera* cam = viewer->getCamera(); + if (cam == 0) return FALSE; + + SoRayPickAction rpaction(viewer->getViewportRegion()); + rpaction.setPoint(screenpos); + rpaction.setRadius(2); + rpaction.apply(viewer->getSceneManager()->getSceneGraph()); + + SoPickedPoint * picked = rpaction.getPickedPoint(); + if (!picked) { + this->interactiveCountInc(); + return FALSE; + } + + SbVec3f hitpoint; + hitpoint = picked->getPoint(); + + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->focalDistance = viewer->getSeekDistance(); + cam->position = hitpoint - cam->focalDistance.getValue() * direction; + return TRUE; +} + void NavigationStyle::setCameraOrientation(const SbRotation& rot) { SoCamera* cam = viewer->getCamera(); diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 3e5d3fd6d..43155948e 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -149,6 +149,7 @@ protected: void setSeekMode(SbBool enable); SbBool seekToPoint(const SbVec2s screenpos); void seekToPoint(const SbVec3f& scenepos); + SbBool moveToPoint(const SbVec2s screenpos); void reorientCamera(SoCamera * camera, const SbRotation & rot); void panCamera(SoCamera * camera,