Added some comments & asserts.
This commit is contained in:
parent
08fd9d8cbd
commit
bec2e9b178
|
@ -44,6 +44,8 @@ ACTION_MANAGER::~ACTION_MANAGER()
|
||||||
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
||||||
{
|
{
|
||||||
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before
|
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before
|
||||||
|
assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() );
|
||||||
|
assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() );
|
||||||
|
|
||||||
aAction->setId( MakeActionId( aAction->m_name ) );
|
aAction->setId( MakeActionId( aAction->m_name ) );
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,11 @@ TOOL_MANAGER::~TOOL_MANAGER()
|
||||||
|
|
||||||
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
|
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
|
||||||
|
wxT( "Adding two tools with the same name may result in unexpected behaviour.") );
|
||||||
|
wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
|
||||||
|
wxT( "Adding two tools with the same ID may result in unexpected behaviour.") );
|
||||||
|
|
||||||
TOOL_STATE* st = new TOOL_STATE;
|
TOOL_STATE* st = new TOOL_STATE;
|
||||||
|
|
||||||
st->theTool = aTool;
|
st->theTool = aTool;
|
||||||
|
@ -227,7 +232,10 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
|
||||||
wxASSERT( aTool != NULL );
|
wxASSERT( aTool != NULL );
|
||||||
|
|
||||||
if( !isRegistered( aTool ) )
|
if( !isRegistered( aTool ) )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
TOOL_STATE* state = m_toolState[aTool];
|
TOOL_STATE* state = m_toolState[aTool];
|
||||||
|
|
||||||
|
@ -334,10 +342,11 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
|
||||||
// Go() method that match the event.
|
// Go() method that match the event.
|
||||||
if( st->transitions.size() )
|
if( st->transitions.size() )
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( TRANSITION tr, st->transitions )
|
BOOST_FOREACH( TRANSITION& tr, st->transitions )
|
||||||
{
|
{
|
||||||
if( tr.first.Matches( aEvent ) )
|
if( tr.first.Matches( aEvent ) )
|
||||||
{
|
{
|
||||||
|
// as the state changes, the transition table has to be set up again
|
||||||
st->transitions.clear();
|
st->transitions.clear();
|
||||||
|
|
||||||
// no tool context allocated yet? Create one.
|
// no tool context allocated yet? Create one.
|
||||||
|
@ -351,6 +360,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( !st->cofunc->Running() )
|
if( !st->cofunc->Running() )
|
||||||
finishTool( st ); // The couroutine has finished immediately?
|
finishTool( st ); // The couroutine has finished immediately?
|
||||||
|
|
||||||
|
// there is no point in further checking, as transitions got cleared
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,8 +418,6 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
||||||
|
|
||||||
if( it != m_activeTools.end() )
|
if( it != m_activeTools.end() )
|
||||||
m_activeTools.erase( it );
|
m_activeTools.erase( it );
|
||||||
else
|
|
||||||
wxLogWarning( wxT( "Tried to finish inactive tool" ) );
|
|
||||||
|
|
||||||
aState->idle = true;
|
aState->idle = true;
|
||||||
delete aState->cofunc;
|
delete aState->cofunc;
|
||||||
|
|
|
@ -321,6 +321,9 @@ public:
|
||||||
|
|
||||||
if( m_commandId && aEvent.m_commandId )
|
if( m_commandId && aEvent.m_commandId )
|
||||||
return *m_commandId == *aEvent.m_commandId;
|
return *m_commandId == *aEvent.m_commandId;
|
||||||
|
|
||||||
|
// Command-type event has to contain either id or string
|
||||||
|
assert( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,7 +68,16 @@ public:
|
||||||
KIGFX::VIEW_GROUP* group;
|
KIGFX::VIEW_GROUP* group;
|
||||||
|
|
||||||
/// Checks if there is anything selected
|
/// Checks if there is anything selected
|
||||||
bool Empty() const { return items.empty(); }
|
bool Empty() const
|
||||||
|
{
|
||||||
|
return items.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the number of selected parts
|
||||||
|
int Size() const
|
||||||
|
{
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
|
|
Loading…
Reference in New Issue