void DesktopDeviceNavigationTool::initialize(void) { /* Create a virtual input device to shadow the raw DesktopDevice device: */ virtualDevice=addVirtualInputDevice("VirtualDesktopDevice",factory->numButtons,0); getInputGraphManager()->getInputDeviceGlyph(virtualDevice)=factory->deviceGlyph; /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(virtualDevice,this); /* Store the device's home position: */ homePosition=virtualDevice->getTransformation(); }
void WaldoTool::initialize(void) { /* Initialize the base tool: */ TransformTool::initialize(); /* Set the virtual input device's glyph to the same as the source device's: */ waldoGlyph=&getInputGraphManager()->getInputDeviceGlyph(transformedDevice); *waldoGlyph=getInputGraphManager()->getInputDeviceGlyph(sourceDevice); GLMaterial waldoMaterial=waldoGlyph->getGlyphMaterial(); waldoMaterial.ambient=waldoMaterial.diffuse=GLMaterial::Color(1.0f,0.0f,0.0f); waldoGlyph->setGlyphMaterial(waldoMaterial); waldoGlyph->disable(); }
void RevolverTool::initialize(void) { /* Create a virtual input device to shadow the source input device: */ transformedDevice=addVirtualInputDevice("TransformedDevice",factory->numButtons,0); /* Disable the virtual input device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); /* Initialize the virtual input device's position: */ transformedDevice->setTransformation(getDeviceTransformation(0)); }
void InputDeviceAdapterMouse::lockMouse(void) { /* Do nothing if the mouse is already locked, or if the current window is unknown: */ if(mouseLocked||window==0) return; mouseLocked=true; /* Remember the current mouse pointer position to restore it upon unlock: */ for(int i=0; i<2; ++i) lockedMousePos[i]=mousePos[i]; /* Move the mouse pointer to the center of the current window: */ window->getWindowCenterPos(mousePos); window->updateMouseDevice(mousePos,inputDevices[0]); inputDevices[0]->setLinearVelocity(Vector::zero); window->setCursorPos(mousePos[0],mousePos[1]); /* Hide the mouse cursor: */ if(fakeMouseCursor) getInputGraphManager()->getInputDeviceGlyph(inputDevices[0]).disable(); else window->hideCursor(); /* Remember the mouse transformation and ray at the window center: */ lockedRayDirection=inputDevices[0]->getDeviceRayDirection(); lockedRayStart=inputDevices[0]->getDeviceRayStart(); lockedTransformation=inputDevices[0]->getTransformation(); }
MouseDialogNavigationTool::MouseDialogNavigationTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment) :NavigationTool(factory,inputAssignment), GUIInteractor(false,Scalar(0),getButtonDevice(0)), mouseAdapter(0), navigationDialogPopup(0), currentPos(Point::origin), navigationMode(ROTATING), spinning(false), showScreenCenter(false) { /* Find the mouse input device adapter controlling the input device: */ InputDevice* rootDevice=getInputGraphManager()->getRootDevice(getButtonDevice(0)); mouseAdapter=dynamic_cast<InputDeviceAdapterMouse*>(getInputDeviceManager()->findInputDeviceAdapter(rootDevice)); /* Create the tool's GUI: */ navigationDialogPopup=new GLMotif::PopupWindow("NavigationDialogPopup",getWidgetManager(),"Mouse Navigation Dialog"); GLMotif::RowColumn* navigationDialog=new GLMotif::RowColumn("NavigationDialog",navigationDialogPopup,false); GLMotif::RadioBox* navigationModes=new GLMotif::RadioBox("NavigationModes",navigationDialog,false); navigationModes->setOrientation(GLMotif::RowColumn::VERTICAL); navigationModes->setPacking(GLMotif::RowColumn::PACK_GRID); navigationModes->setSelectionMode(GLMotif::RadioBox::ALWAYS_ONE); navigationModes->addToggle("Rotate"); navigationModes->addToggle("Pan"); navigationModes->addToggle("Dolly"); navigationModes->addToggle("Scale"); switch(navigationMode) { case ROTATING: navigationModes->setSelectedToggle(0); break; case PANNING: navigationModes->setSelectedToggle(1); break; case DOLLYING: navigationModes->setSelectedToggle(2); break; case SCALING: navigationModes->setSelectedToggle(3); break; } navigationModes->getValueChangedCallbacks().add(this,&MouseDialogNavigationTool::navigationModesValueChangedCallback); navigationModes->manageChild(); GLMotif::ToggleButton* showScreenCenterToggle=new GLMotif::ToggleButton("ShowScreenCenterToggle",navigationDialog,"Show Screen Center"); showScreenCenterToggle->setToggle(showScreenCenter); showScreenCenterToggle->getValueChangedCallbacks().add(this,&MouseDialogNavigationTool::showScreenCenterToggleValueChangedCallback); navigationDialog->manageChild(); /* Pop up the navigation dialog: */ popupPrimaryWidget(navigationDialogPopup); }
void WidgetTool::initialize(void) { /* Create a virtual input device to shadow the button: */ buttonDevice=addVirtualInputDevice("WidgetToolButtonDevice",1,0); /* Copy the source device's tracking type: */ buttonDevice->setTrackType(getButtonDevice(0)->getTrackType()); /* Disable the virtual device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(buttonDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(buttonDevice,this); /* Initialize the virtual input device's position: */ buttonDevice->copyTrackingState(getButtonDevice(0)); }
void MouseTool::initialize(void) { /* Initialize the base tool: */ TransformTool::initialize(); /* Disable the transformed device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).disable(); }
void RevolverTool::initialize(void) { /* Create a virtual input device to shadow the source input device: */ transformedDevice=addVirtualInputDevice("RevolverToolTransformedDevice",factory->numChambers*(input.getNumButtonSlots()-1),factory->numChambers*input.getNumValuatorSlots()); /* Copy the source device's tracking type: */ transformedDevice->setTrackType(sourceDevice->getTrackType()); /* Disable the virtual input device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); /* Initialize the virtual input device's position: */ transformedDevice->setTransformation(sourceDevice->getTransformation()); }
void DesktopDeviceNavigationTool::deinitialize(void) { /* Release the virtual input device: */ getInputGraphManager()->releaseInputDevice(virtualDevice,this); /* Destroy the virtual input device: */ getInputDeviceManager()->destroyInputDevice(virtualDevice); }
void TransformTool::initialize(void) { /* Create a virtual input device to shadow the source input device: */ transformedDevice=addVirtualInputDevice("TransformedDevice",input.getNumButtonSlots()-numPrivateButtons,input.getNumValuatorSlots()-numPrivateValuators); if(sourceDevice!=0) { /* Set the virtual input device's glyph to the source device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice)=getInputGraphManager()->getInputDeviceGlyph(sourceDevice); } /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); /* Initialize the virtual input device's position: */ resetDevice(); }
void ValuatorToButtonTool::initialize(void) { /* Create a virtual input device to shadow the source input device: */ transformedDevice=addVirtualInputDevice("ValuatorToButtonToolTransformedDevice",input.getNumValuatorSlots()*2,0); /* Copy the source device's tracking type: */ transformedDevice->setTrackType(sourceDevice->getTrackType()); /* Disable the virtual input device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); /* Initialize the virtual input device's position: */ resetDevice(); }
void TransformTool::deinitialize(void) { /* Release the virtual input device: */ getInputGraphManager()->releaseInputDevice(transformedDevice,this); /* Destroy the virtual input device: */ getInputDeviceManager()->destroyInputDevice(transformedDevice); transformedDevice=0; }
void DesktopDeviceTool::initialize(void) { /* Create a virtual input device: */ transformedDevice=addVirtualInputDevice("TransformedDevice",factory->numButtons,factory->numValuators); /* Set the virtual device's glyph to the configured glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice)=factory->deviceGlyph; /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); /* Store the device's home position: */ homePosition=transformedDevice->getTransformation(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(transformedDevice,this); }
void WandNavigationTool::deinitialize(void) { /* Release the virtual input device: */ getInputGraphManager()->releaseInputDevice(buttonDevice,this); /* Destroy the virtual input device: */ getInputDeviceManager()->destroyInputDevice(buttonDevice); buttonDevice=0; }
void ScrollTool::initialize(void) { /* Create a virtual input device to shadow the valuator: */ valuatorDevice=addVirtualInputDevice("ScrollToolValuatorDevice",0,1); /* Copy the source device's tracking type: */ valuatorDevice->setTrackType(interactionDevice->getTrackType()); /* Disable the virtual device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(valuatorDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(valuatorDevice,this); /* Initialize the virtual input device's position: */ valuatorDevice->setTransformation(interactionDevice->getTransformation()); valuatorDevice->setDeviceRayDirection(interactionDevice->getDeviceRayDirection()); }
void ScrollTool::deinitialize(void) { /* Release the virtual input device: */ getInputGraphManager()->releaseInputDevice(valuatorDevice,this); /* Destroy the virtual input device: */ getInputDeviceManager()->destroyInputDevice(valuatorDevice); valuatorDevice=0; }
void SixAxisTransformTool::initialize(void) { /* Let the base class do its thing: */ TransformTool::initialize(); /* Calculate derived configuration values: */ for(int i=0; i<3; ++i) translations[i]=config.translations[i]*config.translateFactor; for(int i=0; i<3; ++i) rotations[i]=config.rotations[i]*Math::rad(config.rotateFactor); /* Set the virtual input device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).setGlyphType(config.deviceGlyphType.c_str()); getInputGraphManager()->getInputDeviceGlyph(transformedDevice).setGlyphMaterial(config.deviceGlyphMaterial); /* Initialize the virtual input device's position: */ transformedDevice->setDeviceRay(Vector(0,1,0),-getInchFactor()); transformedDevice->setTransformation(config.position.isSpecified()?config.position.getValue():config.getHomePosition()); }
void SixAxisTransformTool::initialize(void) { /* Let the base class do its thing: */ TransformTool::initialize(); /* Calculate derived configuration values: */ for(int i=0;i<3;++i) translations[i]=config.translations[i]*config.translateFactor; for(int i=0;i<3;++i) rotations[i]=config.rotations[i]*Math::rad(config.rotateFactor); /* Set the virtual input device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(transformedDevice).setGlyphType(config.deviceGlyphType.c_str()); getInputGraphManager()->getInputDeviceGlyph(transformedDevice).setGlyphMaterial(config.deviceGlyphMaterial); /* Initialize the virtual input device's position: */ transformedDevice->setDeviceRay(Vector(0,1,0),-getInchFactor()); transformedDevice->setTransformation(TrackerState::translateFromOriginTo(config.followDisplayCenter?getDisplayCenter():config.homePosition)); }
MouseNavigationTool::MouseNavigationTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment) :NavigationTool(factory,inputAssignment), GUIInteractor(false,Scalar(0),getButtonDevice(0)), mouseAdapter(0), currentPos(Point::origin),currentValue(0), dolly(MouseNavigationTool::factory->invertDolly),navigationMode(IDLE) { /* Find the mouse input device adapter controlling the input device: */ InputDevice* rootDevice=getInputGraphManager()->getRootDevice(getButtonDevice(0)); mouseAdapter=dynamic_cast<InputDeviceAdapterMouse*>(getInputDeviceManager()->findInputDeviceAdapter(rootDevice)); }
void WandNavigationTool::initialize(void) { /* Get the source input device: */ InputDevice* device=getButtonDevice(1); /* Create a virtual input device to shadow the zoom button: */ buttonDevice=addVirtualInputDevice("WandNavigationToolButtonDevice",1,0); /* Copy the source device's tracking type: */ buttonDevice->setTrackType(device->getTrackType()); /* Disable the virtual device's glyph: */ getInputGraphManager()->getInputDeviceGlyph(buttonDevice).disable(); /* Permanently grab the virtual input device: */ getInputGraphManager()->grabInputDevice(buttonDevice,this); /* Initialize the virtual input device's position: */ buttonDevice->setTransformation(device->getTransformation()); buttonDevice->setDeviceRayDirection(device->getDeviceRayDirection()); }
void InputDeviceAdapterMouse::unlockMouse(void) { /* Do nothing if the mouse is not locked: */ if(!mouseLocked) return; mouseLocked=false; /* Move the mouse pointer back to its pre-lock position: */ for(int i=0; i<2; ++i) mousePos[i]=lockedMousePos[i]; window->setCursorPos(mousePos[0],mousePos[1]); window->updateMouseDevice(mousePos,inputDevices[0]); inputDevices[0]->setLinearVelocity(Vector::zero); /* Show the mouse cursor: */ if(fakeMouseCursor) getInputGraphManager()->getInputDeviceGlyph(inputDevices[0]).enable(); else window->showCursor(); }