Add more tool stack tracing

This commit is contained in:
Ian McInerney 2023-12-28 17:42:39 +00:00
parent f2702b223c
commit b6fffb3923
4 changed files with 35 additions and 1 deletions

View File

@ -163,7 +163,7 @@ const std::string TOOL_EVENT::Format() const
} }
else else
{ {
ev += "none"; ev += "none ";
} }
if( m_actions & TA_MOUSE ) if( m_actions & TA_MOUSE )
@ -195,6 +195,17 @@ const std::string TOOL_EVENT_LIST::Format() const
} }
const std::string TOOL_EVENT_LIST::Names() const
{
std::string s;
for( const TOOL_EVENT& e : m_events )
s += e.m_commandStr + " ";
return s;
}
bool TOOL_EVENT::IsClick( int aButtonMask ) const bool TOOL_EVENT::IsClick( int aButtonMask ) const
{ {
return ( m_actions & TA_MOUSE_CLICK ) && ( m_mouseButtons & aButtonMask ) == m_mouseButtons; return ( m_actions & TA_MOUSE_CLICK ) && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;

View File

@ -24,11 +24,15 @@
#include <string> #include <string>
#include <trace_helpers.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <wx/log.h>
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
TOOL_BASE( INTERACTIVE, aId, aName ), TOOL_BASE( INTERACTIVE, aId, aName ),
m_menu( *this ) m_menu( *this )
@ -69,6 +73,10 @@ void TOOL_INTERACTIVE::resetTransitions()
void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions ) void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions )
{ {
wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_INTERACTIVE::goInternal: Tool '%s', Registering handler for actions '%s'" ),
GetName(), aConditions.Names() );
m_toolMgr->ScheduleNextState( this, aState, aConditions ); m_toolMgr->ScheduleNextState( this, aState, aConditions );
} }

View File

@ -245,6 +245,9 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(), wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
wxT( "Adding two tools of the same type may result in unexpected behavior.") ); wxT( "Adding two tools of the same type may result in unexpected behavior.") );
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::RegisterTool: Registering tool %s with ID %d" ),
aTool->GetName(), aTool->GetId() );
m_toolOrder.push_back( aTool ); m_toolOrder.push_back( aTool );
TOOL_STATE* st = new TOOL_STATE( aTool ); TOOL_STATE* st = new TOOL_STATE( aTool );
@ -612,6 +615,10 @@ void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
for( auto& state : m_toolState ) for( auto& state : m_toolState )
{ {
TOOL_BASE* tool = state.first; TOOL_BASE* tool = state.first;
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::ResetTools: Resetting tool '%s'" ),
tool->GetName() );
setActiveState( state.second ); setActiveState( state.second );
tool->Reset( aReason ); tool->Reset( aReason );

View File

@ -535,6 +535,7 @@ public:
bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const; bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const;
private: private:
friend class TOOL_EVENT_LIST;
friend class TOOL_DISPATCHER; friend class TOOL_DISPATCHER;
friend class TOOL_MANAGER; friend class TOOL_MANAGER;
friend class TOOLS_HOLDER; friend class TOOLS_HOLDER;
@ -665,6 +666,13 @@ public:
*/ */
const std::string Format() const; const std::string Format() const;
/**
* Returns a string containing the names of all the events in this list.
*
* @return Event names.
*/
const std::string Names() const;
OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const
{ {
for( const TOOL_EVENT& event : m_events ) for( const TOOL_EVENT& event : m_events )