Added resetting of tools after loading a new board.

This commit is contained in:
Maciej Suminski 2013-08-15 10:20:49 +02:00
parent 723424df07
commit 9bd7ba36ac
3 changed files with 14 additions and 7 deletions

View File

@ -145,7 +145,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
{
st->transitions.clear();
if(!st->cofunc)
if( !st->cofunc )
st->cofunc = new COROUTINE<int, TOOL_EVENT&>( tr.second );
else
st->cofunc->SetEntry( tr.second );
@ -174,7 +174,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if( st->contextMenuTrigger == CMENU_NOW )
{
st->pendingWait = true;
st->waitEvents = TOOL_EVENT ( TC_Any, TA_Any );
st->waitEvents = TOOL_EVENT( TC_Any, TA_Any );
st->contextMenuTrigger = CMENU_OFF;
GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() );
@ -222,5 +222,11 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
m_view = aView;
m_viewControls = aViewControls;
m_editFrame = aFrame;
// fixme: reset tools after changing environment
// Reset state of the registered tools
BOOST_FOREACH( TOOL_BASE* tool, m_toolState | boost::adaptors::map_keys )
{
if( tool->GetType() == TOOL_Interactive )
static_cast<TOOL_INTERACTIVE*>( tool )->Reset();
}
}

View File

@ -78,19 +78,18 @@ public:
template <class Parameters>
void InvokeTool( const std::string& name, const Parameters& aToolParams );
/**
* Function FindTool()
* Searches for a tool with given name or ID
*/
TOOL_BASE *FindTool( int aId );
TOOL_BASE *FindTool( const std::string& aName );
TOOL_BASE* FindTool( int aId );
TOOL_BASE* FindTool( const std::string& aName );
/**
* Resets the state of a given tool by clearing its wait and
* transition lists and calling tool's internal Reset() method.
*/
void ResetTool( TOOL_BASE *aTool );
void ResetTool( TOOL_BASE* aTool );
/**
* Takes an event from the TOOL_DISPATCHER and propagates it to

View File

@ -57,6 +57,8 @@ SELECTION_TOOL::~SELECTION_TOOL()
void SELECTION_TOOL::Reset()
{
m_selectedItems.clear();
// the tool launches upon reception of activate ("pcbnew.InteractiveSelection")
Go( &SELECTION_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveSelection"));
}