void ActorEditTool::onToggleBrush(){ if(isToolFocused()){ getToolManager()->giveupFocus(this); } else{ getToolManager()->requestFocus(this); } }
void Application::run(void) { /* Install callbacks with the tool manager: */ ToolManager* toolManager=getToolManager(); toolManager->getToolCreationCallbacks().add(this,&Application::toolCreationCallback); toolManager->getToolDestructionCallbacks().add(this,&Application::toolDestructionCallback); /* Install Vrui callbacks: */ setFrameFunction(frameWrapper,this); setDisplayFunction(displayWrapper,this); setSoundFunction(soundWrapper,this); /* Start the display: */ startDisplay(0,0); /* Start the sound renderer if requested: */ if(useSound) startSound(initSoundWrapper,this); /* Run the Vrui main loop: */ mainLoop(); /* Uninstall tool manager callbacks: */ toolManager->getToolCreationCallbacks().remove(this,&Application::toolCreationCallback); toolManager->getToolDestructionCallbacks().remove(this,&Application::toolDestructionCallback); }
void CONTEXT_MENU::updateHotKeys() { TOOL_MANAGER* toolMgr = getToolManager(); for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin(); it != m_toolActions.end(); ++it ) { int id = it->first; const TOOL_ACTION& action = *it->second; int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK; if( key ) { int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK; int flags = 0; wxMenuItem* item = FindChildItem( id ); if( item ) { flags |= ( mod & MD_ALT ) ? wxACCEL_ALT : 0; flags |= ( mod & MD_CTRL ) ? wxACCEL_CTRL : 0; flags |= ( mod & MD_SHIFT ) ? wxACCEL_SHIFT : 0; if( !flags ) flags = wxACCEL_NORMAL; wxAcceleratorEntry accel( flags, key, id, item ); item->SetAccel( &accel ); } } } }
Application::~Application(void) { /* Uninstall tool manager callbacks: */ ToolManager* toolManager=getToolManager(); toolManager->getToolCreationCallbacks().remove(this,&Application::toolCreationCallback); toolManager->getToolDestructionCallbacks().remove(this,&Application::toolDestructionCallback); /* Deinitialize Vrui: */ deinit(); }
void update() { SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>(); // lines like this make me really think about a better name for SELECTION_CONDITIONS class bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) && /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/ SELECTION_CONDITIONS::SameNet( true ) && SELECTION_CONDITIONS::SameLayer() )( selTool->GetSelection() ); Enable( getMenuId( COMMON_ACTIONS::zoneMerge ), mergeEnabled ); }
void Application::addEventTool(const char* toolName,ToolFactory* parentClass,Application::EventID eventId) { typedef EventToolFactory<Application> ETF; /* Create a new event tool factory class: */ char* toolClassName=createEventToolClassName(); ETF* toolFactory=new ETF(toolClassName,toolName,parentClass,this,&Application::eventCallback,eventId); delete[] toolClassName; /* Register the tool factory class with the tool manager: */ getToolManager()->addClass(toolFactory,ToolManager::defaultToolFactoryDestructor); }
Application::Application(int& argc,char**& argv,char**& appDefaults) { /* Initialize Vrui: */ init(argc,argv,appDefaults); /* Install callbacks with the tool manager: */ ToolManager* toolManager=getToolManager(); toolManager->getToolCreationCallbacks().add(this,&Application::toolCreationCallback); toolManager->getToolDestructionCallbacks().add(this,&Application::toolDestructionCallback); /* Enable navigation per default: */ setNavigationTransformation(NavTransform::identity); }
void TwoRayTransformTool::buttonCallback(int deviceIndex,int deviceButtonIndex,InputDevice::ButtonCallbackData* cbData) { /* Check the first tool button: */ if(deviceIndex==0&&deviceButtonIndex==0&&getToolManager()->doesButtonHaveTool(transformedDevice,0)) { if(cbData->newButtonState) // Button was just pressed { /* Update the tool's state: */ if(numRays==2) { /* Reset the tool: */ numRays=0; } else if(numRays==1) { /* Press the transformed tool's first button: */ transformedDevice->setButtonState(0,true); } /* Start dragging: */ active=true; } else // Button was just released { /* Update the tool's state: */ ++numRays; if(numRays==2) { /* Release the transformed tool's first button: */ transformedDevice->setButtonState(0,false); } /* Stop dragging: */ active=false; } } else { /* Let the base class handle it: */ TransformTool::buttonCallback(deviceIndex,deviceButtonIndex,cbData); } }