Skip to content

Commit

Permalink
Gui: GestureNav: disable rotation when over a dragger
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepSOIC committed May 6, 2017
1 parent 2d61415 commit 6e39a78
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
43 changes: 40 additions & 3 deletions src/Gui/GestureNavigationStyle.cpp
Expand Up @@ -59,6 +59,10 @@
# include <QMenu>
# include <QMetaObject>
# include <QRegExp>
# include <Inventor/actions/SoRayPickAction.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/SoPath.h>
# include <Inventor/draggers/SoDragger.h>
#endif

#include <Inventor/sensors/SoTimerSensor.h>
Expand Down Expand Up @@ -314,8 +318,7 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
//all mode-dependent stuff is within this switch.
switch(curmode){
case NavigationStyle::IDLE:
case NavigationStyle::SELECTION:
case NavigationStyle::INTERACT: {
case NavigationStyle::SELECTION: {
//idle and interaction

//keyboard
Expand Down Expand Up @@ -363,7 +366,9 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
case SoMouseButtonEvent::BUTTON1:
case SoMouseButtonEvent::BUTTON2:
if(press){
if(this->thisClickIsComplex && this->mouseMoveThresholdBroken){
if (this->isDraggerUnderCursor(ev->getPosition())){
setViewingMode(NavigationStyle::INTERACT);
} else if(this->thisClickIsComplex && this->mouseMoveThresholdBroken){
//this should prevent re-attempts to enter navigation when doing more clicks after a move.
} else {
//on LMB-down or RMB-down, we don't know yet if we should propagate it or process it. Save the event to be refired later, when it becomes clear.
Expand Down Expand Up @@ -584,6 +589,25 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
setViewingMode(NavigationStyle::IDLE);
}
} break; //end of animation modes
case NavigationStyle::INTERACT:{
// Mouse Button / Spaceball Button handling
if (evIsButton) {
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
const int button = event->getButton();
//const SbBool press //the button was pressed (if false -> released)
// = event->getState() == SoButtonEvent::DOWN ? true : false;
switch(button){
case SoMouseButtonEvent::BUTTON1:
case SoMouseButtonEvent::BUTTON2:
if(!(comboAfter & BUTTON1DOWN || comboAfter & BUTTON2DOWN)) {
//all buttons are released - leave interact mode
setViewingMode(NavigationStyle::IDLE);
}
break;
} //switch(button)
} //if(evIsButton)

} break;
case NavigationStyle::BOXZOOM:
default:
//all the rest - will be pass on to inherited, later.
Expand All @@ -600,3 +624,16 @@ SbBool GestureNavigationStyle::processSoEvent(const SoEvent * const ev)
return processed;
}


bool GestureNavigationStyle::isDraggerUnderCursor(SbVec2s pos)
{
SoRayPickAction rp(this->viewer->getSoRenderManager()->getViewportRegion());
rp.setRadius(viewer->getPickRadius());
rp.setPoint(pos);
rp.apply(this->viewer->getSoRenderManager()->getSceneGraph());
SoPickedPoint* pick = rp.getPickedPoint();
if (pick)
return pick->getPath()->getTail()->isOfType(SoDragger::getClassTypeId());
else
return false;
}
1 change: 1 addition & 0 deletions src/Gui/NavigationStyle.h
Expand Up @@ -370,6 +370,7 @@ class GuiExport GestureNavigationStyle : public UserNavigationStyle {

protected:
SbBool processSoEvent(const SoEvent * const ev);
bool isDraggerUnderCursor(SbVec2s pos);

SbVec2s mousedownPos;//the position where some mouse button was pressed (local pixel coordinates).
short mouseMoveThreshold;//setting. Minimum move required to consider it a move (in pixels).
Expand Down

0 comments on commit 6e39a78

Please sign in to comment.