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,