Ejemplo n.º 1
0
bool TOOL_MANAGER::runTool( const std::string& aToolName )
{
    TOOL_BASE* tool = FindTool( aToolName );

    if( tool && tool->GetType() == INTERACTIVE )
        return runTool( tool );

    return false;       // there is no tool with the given name
}
Ejemplo n.º 2
0
bool TOOL_MANAGER::runTool( TOOL_ID aToolId )
{
    TOOL_BASE* tool = FindTool( aToolId );

    if( tool && tool->GetType() == INTERACTIVE )
        return runTool( tool );

    return false;       // there is no tool with the given id
}
void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
{
    DeactivateTool();

    for( auto& state : m_toolState )
    {
        TOOL_BASE* tool = state.first;
        setActiveState( state.second );
        tool->Reset( aReason );

        if( tool->GetType() == INTERACTIVE )
            static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
    }
}
TOOL_MANAGER::ID_LIST::iterator TOOL_MANAGER::finishTool( TOOL_STATE* aState )
{
    auto it = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() );

    if( !aState->Pop() )
    {
        // Deactivate the tool if there are no other contexts saved on the stack
        if( it != m_activeTools.end() )
            it = m_activeTools.erase( it );

        aState->idle = true;
    }

    if( aState == m_activeState )
        setActiveState( nullptr );

    // Set transitions to be ready for future TOOL_EVENTs
    TOOL_BASE* tool = aState->theTool;

    if( tool->GetType() == INTERACTIVE )
        static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();

    return it;
}