Add log trace for tool handling
This commit is contained in:
parent
5c80019541
commit
bea74c27e5
|
@ -307,7 +307,7 @@ bool EDA_BASE_FRAME::doAutoSave()
|
|||
|
||||
void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& event )
|
||||
{
|
||||
wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_FRAME::OnCharHook %s", dump( event ) );
|
||||
wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( event ) );
|
||||
// Key events can be filtered here.
|
||||
// Currently no filtering is made.
|
||||
event.Skip();
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_action.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_action.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <hotkeys_basic.h>
|
||||
#include <cctype>
|
||||
|
@ -92,6 +93,9 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
|||
if( key >= 'a' && key <= 'z' )
|
||||
key = std::toupper( key );
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "ACTION_MANAGER::RunHotKey Key: %s",
|
||||
KeyNameFromKeyCode( aHotKey ) );
|
||||
|
||||
HOTKEY_LIST::const_iterator it = m_actionHotKeys.find( key | mod );
|
||||
|
||||
// If no luck, try without Shift, to handle keys that require it
|
||||
|
@ -100,6 +104,9 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
|||
// different combination
|
||||
if( it == m_actionHotKeys.end() )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"ACTION_MANAGER::RunHotKey No actions found, searching with key: %s",
|
||||
KeyNameFromKeyCode( key | ( mod & ~MD_SHIFT ) ) );
|
||||
it = m_actionHotKeys.find( key | ( mod & ~MD_SHIFT ) );
|
||||
|
||||
if( it == m_actionHotKeys.end() )
|
||||
|
@ -141,15 +148,26 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
|||
|
||||
if( context )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"ACTION_MANAGER::RunHotKey Running action %s for hotkey %s", context->GetName(),
|
||||
KeyNameFromKeyCode( aHotKey ) );
|
||||
|
||||
m_toolMgr->RunAction( *context, true );
|
||||
return true;
|
||||
}
|
||||
else if( global )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"ACTION_MANAGER::RunHotKey Running action: %s for hotkey %s", global->GetName(),
|
||||
KeyNameFromKeyCode( aHotKey ) );
|
||||
|
||||
m_toolMgr->RunAction( *global, true );
|
||||
return true;
|
||||
}
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "ACTION_MANAGER::RunHotKey No action found for key %s",
|
||||
KeyNameFromKeyCode( aHotKey ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,16 +24,17 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <eda_base_frame.h>
|
||||
#include <functional>
|
||||
#include <id.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tool_interactive.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <wx/log.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <eda_base_frame.h>
|
||||
#include <id.h>
|
||||
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
@ -436,6 +437,9 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
|||
// clients that don't supply a tool will have to check GetSelected() themselves
|
||||
if( evt && m_tool )
|
||||
{
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "ACTION_MENU::OnMenuEvent %s", evt->Format() );
|
||||
|
||||
TOOL_MANAGER* toolMgr = m_tool->GetManager();
|
||||
|
||||
if( g_last_menu_highlighted_id == aEvent.GetId() && !m_isContextMenu )
|
||||
|
|
|
@ -463,6 +463,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
|
||||
if( evt )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent %s", evt->Format() );
|
||||
|
||||
handled = m_toolMgr->ProcessEvent( *evt );
|
||||
|
||||
// ESC is the special key for canceling tools, and is therefore seen as handled
|
||||
|
@ -499,7 +501,11 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
|
|||
OPT<TOOL_EVENT> evt = m_actions->TranslateLegacyId( aEvent.GetId() );
|
||||
|
||||
if( evt )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxCommand %s", evt->Format() );
|
||||
|
||||
m_toolMgr->ProcessEvent( *evt );
|
||||
}
|
||||
else
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
#include <core/optional.h>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/clipbrd.h>
|
||||
|
@ -528,6 +529,8 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
bool handled = false;
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal %s", aEvent.Format() );
|
||||
|
||||
// iterate over active tool stack
|
||||
for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
|
||||
{
|
||||
|
@ -555,6 +558,10 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( st->cofunc )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"TOOL_MANAGER::dispatchInternal Waking tool %s for event: %s",
|
||||
st->theTool->GetName(), aEvent.Format() );
|
||||
|
||||
setActiveState( st );
|
||||
bool end = !st->cofunc->Resume();
|
||||
|
||||
|
@ -565,6 +572,10 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
// If the tool did not request the event be passed to other tools, we're done
|
||||
if( !st->wakeupEvent.PassEvent() )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"TOOL_MANAGER::dispatchInternal %s stopped passing event: %s",
|
||||
st->theTool->GetName(), aEvent.Format() );
|
||||
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -604,6 +615,10 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
// as the state changes, the transition table has to be set up again
|
||||
st->transitions.clear();
|
||||
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"TOOL_MANAGER::dispatchInternal Running tool %s for event: %s",
|
||||
st->theTool->GetName(), aEvent.Format() );
|
||||
|
||||
// got match? Run the handler.
|
||||
setActiveState( st );
|
||||
st->idle = false;
|
||||
|
@ -626,6 +641,9 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
break; // only the first tool gets the event
|
||||
}
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal handled: %s %s",
|
||||
( handled ? "true" : "false" ), aEvent.Format() );
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
@ -641,6 +659,7 @@ bool TOOL_MANAGER::dispatchHotKey( const TOOL_EVENT& aEvent )
|
|||
|
||||
bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchActivation %s", aEvent.Format() );
|
||||
if( aEvent.IsActivate() )
|
||||
{
|
||||
wxString cmdStr( *aEvent.GetCommandStr() );
|
||||
|
@ -649,6 +668,10 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( tool != m_toolNameIndex.end() )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack,
|
||||
"TOOL_MANAGER::dispatchActivation Running tool %s for event: %s",
|
||||
tool->second->theTool->GetName(), aEvent.Format() );
|
||||
|
||||
runTool( tool->second->theTool );
|
||||
return true;
|
||||
}
|
||||
|
@ -931,6 +954,8 @@ void TOOL_MANAGER::applyViewControls( TOOL_STATE* aState )
|
|||
|
||||
bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent %s", aEvent.Format() );
|
||||
|
||||
if( dispatchHotKey( aEvent ) )
|
||||
return true;
|
||||
|
||||
|
@ -949,6 +974,9 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
|||
processEvent( event );
|
||||
}
|
||||
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent handled: %s %s",
|
||||
( handled ? "true" : "false" ), aEvent.Format() );
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
const wxChar* const traceFindReplace = wxT( "KICAD_FIND_REPLACE" );
|
||||
const wxChar* const kicadTraceCoords = wxT( "KICAD_COORDS" );
|
||||
const wxChar* const kicadTraceKeyEvent = wxT( "KICAD_KEY_EVENTS" );
|
||||
const wxChar* const kicadTraceToolStack = wxT( "KICAD_TOOL_STACK" );
|
||||
const wxChar* const traceSchLibMem = wxT( "KICAD_SCH_LIB_MEM" );
|
||||
const wxChar* const traceFindItem = wxT( "KICAD_FIND_ITEM" );
|
||||
const wxChar* const traceSchLegacyPlugin = wxT( "KICAD_SCH_LEGACY_PLUGIN" );
|
||||
|
|
|
@ -75,6 +75,13 @@ extern const wxChar* const kicadTraceCoords;
|
|||
*/
|
||||
extern const wxChar* const kicadTraceKeyEvent;
|
||||
|
||||
/**
|
||||
* Flag to enable tracing of the tool handling stack.
|
||||
*
|
||||
* Use "KICAD_TOOL_STACK" to enable.
|
||||
*/
|
||||
extern const wxChar* const kicadTraceToolStack;
|
||||
|
||||
/**
|
||||
* Flag to enable auto save feature debug tracing.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue