Commit 9bd7ba36 authored by Maciej Suminski's avatar Maciej Suminski

Added resetting of tools after loading a new board.

parent 723424df
...@@ -145,7 +145,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -145,7 +145,7 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
{ {
st->transitions.clear(); st->transitions.clear();
if(!st->cofunc) if( !st->cofunc )
st->cofunc = new COROUTINE<int, TOOL_EVENT&>( tr.second ); st->cofunc = new COROUTINE<int, TOOL_EVENT&>( tr.second );
else else
st->cofunc->SetEntry( tr.second ); st->cofunc->SetEntry( tr.second );
...@@ -174,7 +174,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -174,7 +174,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if( st->contextMenuTrigger == CMENU_NOW ) if( st->contextMenuTrigger == CMENU_NOW )
{ {
st->pendingWait = true; st->pendingWait = true;
st->waitEvents = TOOL_EVENT ( TC_Any, TA_Any ); st->waitEvents = TOOL_EVENT( TC_Any, TA_Any );
st->contextMenuTrigger = CMENU_OFF; st->contextMenuTrigger = CMENU_OFF;
GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() ); GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() );
...@@ -222,5 +222,11 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView, ...@@ -222,5 +222,11 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
m_view = aView; m_view = aView;
m_viewControls = aViewControls; m_viewControls = aViewControls;
m_editFrame = aFrame; 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();
}
} }
...@@ -78,19 +78,18 @@ public: ...@@ -78,19 +78,18 @@ public:
template <class Parameters> template <class Parameters>
void InvokeTool( const std::string& name, const Parameters& aToolParams ); void InvokeTool( const std::string& name, const Parameters& aToolParams );
/** /**
* Function FindTool() * Function FindTool()
* Searches for a tool with given name or ID * Searches for a tool with given name or ID
*/ */
TOOL_BASE *FindTool( int aId ); TOOL_BASE* FindTool( int aId );
TOOL_BASE *FindTool( const std::string& aName ); TOOL_BASE* FindTool( const std::string& aName );
/** /**
* Resets the state of a given tool by clearing its wait and * Resets the state of a given tool by clearing its wait and
* transition lists and calling tool's internal Reset() method. * 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 * Takes an event from the TOOL_DISPATCHER and propagates it to
......
...@@ -57,6 +57,8 @@ SELECTION_TOOL::~SELECTION_TOOL() ...@@ -57,6 +57,8 @@ SELECTION_TOOL::~SELECTION_TOOL()
void SELECTION_TOOL::Reset() void SELECTION_TOOL::Reset()
{ {
m_selectedItems.clear();
// the tool launches upon reception of activate ("pcbnew.InteractiveSelection") // the tool launches upon reception of activate ("pcbnew.InteractiveSelection")
Go( &SELECTION_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveSelection")); Go( &SELECTION_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveSelection"));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment