Example #1
0
RayMenuTool::RayMenuTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment)
	:MenuTool(factory,inputAssignment),
	 GUIInteractor(isUseEyeRay(),getRayOffset(),getButtonDevice(0))
	{
	/* Set the interaction device: */
	interactionDevice=getButtonDevice(0);
	}
Example #2
0
void RayMenuTool::buttonCallback(int,InputDevice::ButtonCallbackData* cbData)
	{
	if(cbData->newButtonState) // Button has just been pressed
		{
		/* Check if the GUI interactor refuses the event: */
		GUIInteractor::updateRay();
		if(!(factory->interactWithWidgets&&GUIInteractor::buttonDown(false)))
			{
			/* Try activating this tool: */
			if(GUIInteractor::canActivate()&&activate())
				{
				/***************************************************************
				Pop up the tool's menu at the appropriate position and
				orientation:
				***************************************************************/
				
				if(isUseEyeRay()||interactionDevice->isRayDevice())
					{
					/* Pop up the menu at the ray's intersection with the UI plane: */
					popupPrimaryWidget(menu->getPopup(),calcRayPoint(GUIInteractor::getRay()),false);
					}
				else
					{
					/* Pop up the menu: */
					popupPrimaryWidget(menu->getPopup(),GUIInteractor::getRay()(factory->initialMenuOffset),false);
					}
				
				/* Grab the pointer: */
				getWidgetManager()->grabPointer(menu->getPopup());
				
				/* Force the event on the GUI interactor: */
				GUIInteractor::buttonDown(true);
				}
			}
		}
	else // Button has just been released
		{
		/* Check if the GUI interactor is active: */
		if(GUIInteractor::isActive())
			{
			/* Deliver the event: */
			GUIInteractor::buttonUp();
			
			/* Check if the tool's menu is popped up: */
			if(MenuTool::isActive())
				{
				/* Release the pointer: */
				getWidgetManager()->releasePointer(menu->getPopup());
				
				/* Pop down the menu: */
				getWidgetManager()->popdownWidget(menu->getPopup());
				
				/* Deactivate the tool: */
				deactivate();
				}
			}
		}
	}
ScrollTool::ScrollTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment)
	:UserInterfaceTool(factory,inputAssignment),
	 GUIInteractor(isUseEyeRay(),getRayOffset(),getValuatorDevice(0)),
	 valuatorDevice(0),
	 sendingEvents(false)
	{
	/* Set the interaction device: */
	interactionDevice=getValuatorDevice(0);
	}
Example #4
0
Point RayMenuTool::calcHotSpot(void) const
	{
	if(isUseEyeRay()||interactionDevice->isRayDevice())
		{
		/* Return the ray's intersection with the UI plane: */
		return calcRayPoint(GUIInteractor::getRay());
		}
	else
		{
		/* Return a position in front of the input device: */
		return GUIInteractor::getRay()(factory->initialMenuOffset);
		}
	}
Example #5
0
Point RayMenuTool::calcHotSpot(void) const
	{
	if(isUseEyeRay()||interactionDevice->isRayDevice())
		{
		/* Find the intersection point of the interaction ray and a screen: */
		std::pair<VRScreen*,Scalar> si=findScreen(GUIInteractor::getRay());
		if(si.first!=0)
			return GUIInteractor::getRay()(si.second);
		else
			return getDisplayCenter();
		}
	else
		{
		/* Return a position in front of the input device: */
		return GUIInteractor::getRay()(factory->initialMenuOffset);
		}
	}