void MouseDialogNavigationTool::startDollying(void) { /* Calculate the dollying direction: */ if(mouseAdapter!=0&&mouseAdapter->getWindow()!=0) dollyDirection=mouseAdapter->getWindow()->getViewer()->getHeadPosition()-calcScreenCenter(); else dollyDirection=getMainViewer()->getHeadPosition()-calcScreenCenter(); dollyDirection.normalize(); /* Calculate initial motion position: */ motionStart=calcScreenPos(); preScale=getNavigationTransformation(); }
void MouseDialogNavigationTool::startScaling(void) { /* Calculate the scaling center: */ screenCenter=calcScreenCenter(); /* Calculate initial motion position: */ motionStart=calcScreenPos(); preScale=NavTrackerState::translateFromOriginTo(screenCenter); postScale=NavTrackerState::translateToOriginFrom(screenCenter); postScale*=getNavigationTransformation(); }
void MouseDialogNavigationTool::startRotating(void) { /* Calculate the rotation center: */ screenCenter=calcScreenCenter(); /* Calculate initial rotation position: */ lastRotationPos=calcScreenPos(); /* Calculate the rotation offset vector: */ rotateOffset=getMainScreen()->getScreenTransformation().transform(Vector(0,0,factory->rotatePlaneOffset)); preScale=NavTrackerState::translateFromOriginTo(screenCenter); rotation=NavTrackerState::identity; postScale=NavTrackerState::translateToOriginFrom(screenCenter); postScale*=getNavigationTransformation(); }
void MouseDialogNavigationTool::startRotating(void) { /* Calculate the rotation center: */ screenCenter=calcScreenCenter(); /* Calculate initial rotation position: */ lastRotationPos=calcScreenPos(); /* Get the transformation of the screen currently containing the input device: */ Scalar viewport[4]; ONTransform screenT=getMouseScreenTransform(mouseAdapter,viewport); /* Calculate the rotation offset vector: */ rotateOffset=screenT.transform(Vector(0,0,factory->rotatePlaneOffset)); preScale=NavTrackerState::translateFromOriginTo(screenCenter); rotation=NavTrackerState::identity; postScale=NavTrackerState::translateToOriginFrom(screenCenter); postScale*=getNavigationTransformation(); }
void MouseNavigationTool::valuatorCallback(int,InputDevice::ValuatorCallbackData* cbData) { currentValue=Scalar(cbData->newValuatorValue); if(currentValue!=Scalar(0)) { /* Act depending on this tool's current state: */ switch(navigationMode) { case IDLE: case SPINNING: /* Try activating this tool: */ if(navigationMode==SPINNING||activate()) { if(dolly) { /* Calculate the dollying direction: */ if(mouseAdapter!=0) dollyDirection=mouseAdapter->getWindow()->getViewer()->getHeadPosition()-calcScreenCenter(); else dollyDirection=getMainViewer()->getHeadPosition()-calcScreenCenter(); dollyDirection.normalize(); /* Initialize the wheel dollying factor: */ currentWheelScale=Scalar(1); preScale=getNavigationTransformation(); /* Go to wheel dollying mode: */ navigationMode=DOLLYING_WHEEL; } else { /* Calculate the scaling center: */ screenCenter=calcScreenCenter(); /* Initialize the wheel scaling factor: */ currentWheelScale=Scalar(1); preScale=NavTrackerState::translateFromOriginTo(screenCenter); postScale=NavTrackerState::translateToOriginFrom(screenCenter); postScale*=getNavigationTransformation(); /* Go to wheel scaling mode: */ navigationMode=SCALING_WHEEL; } } break; default: /* This can definitely happen; just ignore the event */ break; } } else { /* Act depending on this tool's current state: */ switch(navigationMode) { case DOLLYING_WHEEL: case SCALING_WHEEL: /* Deactivate this tool: */ deactivate(); /* Go to idle mode: */ navigationMode=IDLE; break; default: /* This can definitely happen; just ignore the event */ break; } } }