Gui: MayaGesture navigation fixes (#20948)
* Gui: Gesture and MayaGesture style disable H key in editing mode * Gui: MayaGesture style go back to IDLE after dragging/panning/zooming * Gui: MayaGesture more Maya like zoom behavior
This commit is contained in:
@@ -315,7 +315,8 @@ public:
|
||||
bool press = (kbev->getState() == SoKeyboardEvent::DOWN);
|
||||
switch (kbev->getKey()) {
|
||||
case SoKeyboardEvent::H:
|
||||
if (!press) {
|
||||
// Disable H key in editing mode because of conflict with sketcher
|
||||
if (!ns.viewer->isEditing() && !press) {
|
||||
ns.setupPanningPlane(ns.viewer->getCamera());
|
||||
ns.lookAtPoint(kbev->getPosition());
|
||||
}
|
||||
|
||||
@@ -113,6 +113,19 @@ bool MayaGestureNavigationStyle::testMoveThreshold(const SbVec2s currentPos) con
|
||||
return SbVec2f(movedBy).length() >= this->mouseMoveThreshold;
|
||||
}
|
||||
|
||||
void MayaGestureNavigationStyle::zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos)
|
||||
{
|
||||
const float dx = thispos[0] - prevpos[0];
|
||||
const float dy = thispos[1] - prevpos[1];
|
||||
|
||||
// Compute zoom based on diagonal difference.
|
||||
float value = (dx - dy) * 10.0f;
|
||||
|
||||
if (this->invertZoom)
|
||||
value = -value;
|
||||
zoom(viewer->getSoRenderManager()->getCamera(), value);
|
||||
}
|
||||
|
||||
SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
{
|
||||
// Events when in "ready-to-seek" mode are ignored, except those
|
||||
@@ -279,11 +292,14 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
switch (event->getKey()) {
|
||||
case SoKeyboardEvent::H:
|
||||
processed = true;
|
||||
if (!press) {
|
||||
setupPanningPlane(viewer->getCamera());
|
||||
lookAtPoint(event->getPosition());
|
||||
}
|
||||
// Disable H key in editing mode because of conflict with sketcher
|
||||
if (!viewer->isEditing()) {
|
||||
processed = true;
|
||||
if (!press) {
|
||||
setupPanningPlane(viewer->getCamera());
|
||||
lookAtPoint(event->getPosition());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -514,7 +530,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = true;
|
||||
} else { //all buttons are released
|
||||
//end of dragging/panning/whatever
|
||||
setViewingMode(NavigationStyle::SELECTION);
|
||||
setViewingMode(NavigationStyle::IDLE);
|
||||
processed = true;
|
||||
} //end of else (some buttons down)
|
||||
break;
|
||||
|
||||
@@ -214,7 +214,7 @@ protected:
|
||||
void setupPanningPlane(const SoCamera* camera);
|
||||
int getDelta() const;
|
||||
void zoom(SoCamera * camera, float diffvalue);
|
||||
void zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos);
|
||||
virtual void zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos);
|
||||
void doZoom(SoCamera * camera, int wheeldelta, const SbVec2f& pos);
|
||||
void doZoom(SoCamera * camera, float logzoomfactor, const SbVec2f& pos);
|
||||
void doRotate(SoCamera * camera, float angle, const SbVec2f& pos);
|
||||
@@ -412,6 +412,8 @@ public:
|
||||
const char* mouseButtons(ViewerMode) override;
|
||||
|
||||
protected:
|
||||
void zoomByCursor(const SbVec2f & thispos, const SbVec2f & prevpos) override;
|
||||
|
||||
SbBool processSoEvent(const SoEvent * const ev) override;
|
||||
|
||||
SbVec2s mousedownPos;//the position where some mouse button was pressed (local pixel coordinates).
|
||||
|
||||
Reference in New Issue
Block a user