0000772: Navigation style suggestion - do not change cursor location when you are controling view

This commit is contained in:
wmayer 2012-07-07 00:28:03 +02:00
parent 32d38561c8
commit c3d84e9bf8
7 changed files with 65 additions and 0 deletions

View File

@ -181,6 +181,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -221,6 +222,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -285,6 +287,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (this->currentmode == NavigationStyle::DRAGGING) {
this->addToLog(event->getPosition(), event->getTime());
this->spin(posn);
moveCursorPosition();
processed = TRUE;
}
}
@ -338,6 +341,9 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
newmode = NavigationStyle::PANNING;
break;
case BUTTON3DOWN:
if (newmode != NavigationStyle::DRAGGING) {
saveCursorPosition(ev);
}
newmode = NavigationStyle::DRAGGING;
break;
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:

View File

@ -210,6 +210,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -250,6 +251,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -314,6 +316,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (this->currentmode == NavigationStyle::DRAGGING) {
this->addToLog(event->getPosition(), event->getTime());
this->spin(posn);
moveCursorPosition();
processed = TRUE;
}
}
@ -379,6 +382,9 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
newmode = NavigationStyle::PANNING;
break;
case SHIFTDOWN|BUTTON2DOWN:
if (newmode != NavigationStyle::DRAGGING) {
saveCursorPosition(ev);
}
newmode = NavigationStyle::DRAGGING;
break;
case CTRLDOWN|SHIFTDOWN|BUTTON2DOWN:

View File

@ -279,6 +279,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (this->currentmode == NavigationStyle::DRAGGING) {
this->addToLog(event->getPosition(), event->getTime());
this->spin(posn);
moveCursorPosition();
processed = TRUE;
}
}
@ -316,6 +317,9 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
}
break;
case BUTTON1DOWN:
if (newmode != NavigationStyle::DRAGGING) {
saveCursorPosition(ev);
}
newmode = NavigationStyle::DRAGGING;
break;
case BUTTON3DOWN:

View File

@ -55,11 +55,13 @@ struct NavigationStyleP {
SbRotation endRotation;
SoTimerSensor * animsensor;
float sensitivity;
SbBool resetcursorpos;
NavigationStyleP()
{
this->animationsteps = 0;
this->sensitivity = 2.0f;
this->resetcursorpos = FALSE;
}
static void viewAnimationCB(void * data, SoSensor * sensor);
};
@ -844,6 +846,25 @@ SbBool NavigationStyle::doSpin()
return FALSE;
}
void NavigationStyle::saveCursorPosition(const SoEvent * const ev)
{
this->globalPos.setValue(QCursor::pos().x(), QCursor::pos().y());
this->localPos = ev->getPosition();
}
void NavigationStyle::moveCursorPosition()
{
if (!isResetCursorPosition())
return;
QPoint cpos = QCursor::pos();
if (abs(cpos.x()-globalPos[0]) > 10 ||
abs(cpos.y()-globalPos[1]) > 10) {
QCursor::setPos(globalPos[0], globalPos[1]-1);
this->log.position[0] = localPos;
}
}
void NavigationStyle::updateAnimation()
{
SbTime now = SbTime::getTimeOfDay();
@ -943,6 +964,16 @@ float NavigationStyle::getSensitivity() const
return PRIVATE(this)->sensitivity;
}
void NavigationStyle::setResetCursorPosition(SbBool on)
{
PRIVATE(this)->resetcursorpos = on;
}
SbBool NavigationStyle::isResetCursorPosition() const
{
return PRIVATE(this)->resetcursorpos;
}
void NavigationStyle::setZoomInverted(SbBool on)
{
this->invertZoom = on;

View File

@ -113,6 +113,9 @@ public:
void setSensitivity(float);
float getSensitivity() const;
void setResetCursorPosition(SbBool);
SbBool isResetCursorPosition() const;
void setZoomInverted(SbBool);
SbBool isZoomInverted() const;
void setZoomStep(float);
@ -175,6 +178,8 @@ protected:
void doZoom(SoCamera * camera, SbBool forward, const SbVec2f& pos);
void spin(const SbVec2f & pointerpos);
SbBool doSpin();
void moveCursorPosition();
void saveCursorPosition(const SoEvent * const ev);
SbBool handleEventInForeground(const SoEvent* const e);
virtual SbBool processSoEvent(const SoEvent * const ev);
@ -195,6 +200,8 @@ protected:
View3DInventorViewer* viewer;
ViewerMode currentmode;
SbVec2f lastmouseposition;
SbVec2s globalPos;
SbVec2s localPos;
SbPlane panningplane;
SbTime prevRedrawTime;
SbTime centerTime;

View File

@ -185,6 +185,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -225,6 +226,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
processed = TRUE;
}
@ -259,6 +261,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
else if (this->currentmode == NavigationStyle::DRAGGING) {
this->addToLog(event->getPosition(), event->getTime());
this->spin(posn);
moveCursorPosition();
processed = TRUE;
}
}
@ -305,6 +308,9 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
break;
case ALTDOWN:
case CTRLDOWN|SHIFTDOWN:
if (newmode != NavigationStyle::DRAGGING) {
saveCursorPosition(ev);
}
newmode = NavigationStyle::DRAGGING;
break;
case CTRLDOWN|SHIFTDOWN|BUTTON1DOWN:

View File

@ -141,6 +141,7 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, Qt::W
OnChange(*hGrp,"NavigationStyle");
OnChange(*hGrp,"OrbitStyle");
OnChange(*hGrp,"Sensitivity");
OnChange(*hGrp,"ResetCursorPosition");
stopSpinTimer = new QTimer(this);
connect(stopSpinTimer, SIGNAL(timeout()), this, SLOT(stopAnimating()));
@ -279,6 +280,10 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
float val = rGrp.GetFloat("Sensitivity",2.0f);
_viewer->navigationStyle()->setSensitivity(val);
}
else if (strcmp(Reason,"ResetCursorPosition") == 0) {
bool on = rGrp.GetBool("ResetCursorPosition",false);
_viewer->navigationStyle()->setResetCursorPosition(on);
}
else if (strcmp(Reason,"InvertZoom") == 0) {
bool on = rGrp.GetBool("InvertZoom", false);
_viewer->navigationStyle()->setZoomInverted(on);