Remove ACTIONS::TranslateLegacyId and TOOL_DISPATCHER::DispatchWxCommand

After commit 9535153f9e there were no more IDs inside the legacy ID
system. Therefore the entire system for dispatching and looking up
the legacy ideas and handling those events can now be removed and
the tool dispatcher simplified (it no longer needs to know about
the ACTIONS class).
This commit is contained in:
Ian McInerney 2021-03-27 20:02:34 +00:00
parent 148c3b3419
commit 0a0935e0f3
28 changed files with 21 additions and 129 deletions

View File

@ -104,7 +104,7 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRI
m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this ); m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
m_actions = new EDA_3D_ACTIONS(); m_actions = new EDA_3D_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
m_previewPane->SetEventDispatcher( m_toolDispatcher ); m_previewPane->SetEventDispatcher( m_toolDispatcher );
// Register tools // Register tools

View File

@ -557,20 +557,6 @@ void EDA_3D_CANVAS::DoRePaint()
void EDA_3D_CANVAS::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher ) void EDA_3D_CANVAS::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
{ {
m_eventDispatcher = aEventDispatcher; m_eventDispatcher = aEventDispatcher;
if( m_eventDispatcher )
{
m_parent->Connect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
nullptr, m_eventDispatcher );
}
else
{
// While loop is used to be sure that all event handlers are removed.
while( m_parent->Disconnect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
nullptr, m_eventDispatcher ) );
}
} }

View File

@ -122,7 +122,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this ); m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
m_actions = new EDA_3D_ACTIONS(); m_actions = new EDA_3D_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
m_canvas->SetEventDispatcher( m_toolDispatcher ); m_canvas->SetEventDispatcher( m_toolDispatcher );
// Register tools // Register tools

View File

@ -98,9 +98,6 @@ public:
static TOOL_ACTION toggleSolderPaste; static TOOL_ACTION toggleSolderPaste;
static TOOL_ACTION toggleComments; static TOOL_ACTION toggleComments;
static TOOL_ACTION toggleECO; static TOOL_ACTION toggleECO;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
}; };
#endif #endif

View File

@ -334,27 +334,6 @@ void EDA_DRAW_PANEL_GAL::ForceRefresh()
void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher ) void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
{ {
m_eventDispatcher = aEventDispatcher; m_eventDispatcher = aEventDispatcher;
const wxEventType eventTypes[] = { wxEVT_TOOL };
if( m_eventDispatcher )
{
for( wxEventType type : eventTypes )
{
m_parent->Connect( type, wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
}
else
{
for( wxEventType type : eventTypes )
{
// While loop is used to be sure that all event handlers are removed.
while( m_parent->Disconnect(
type, wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ), NULL,
m_eventDispatcher ) )
;
}
}
} }

View File

@ -121,9 +121,8 @@ struct TOOL_DISPATCHER::BUTTON_STATE
}; };
TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, ACTIONS *aActions ) : TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr ) :
m_toolMgr( aToolMgr ), m_toolMgr( aToolMgr )
m_actions( aActions )
{ {
m_buttons.push_back( new BUTTON_STATE( BUT_LEFT, wxEVT_LEFT_DOWN, m_buttons.push_back( new BUTTON_STATE( BUT_LEFT, wxEVT_LEFT_DOWN,
wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) ); wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
@ -621,18 +620,3 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s", wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s",
( aEvent.GetSkipped() ? "true" : "false" ) ); ( aEvent.GetSkipped() ? "true" : "false" ) );
} }
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();
}

View File

@ -232,7 +232,7 @@ void CVPCB_MAINFRAME::setupTools()
m_actions = new CVPCB_ACTIONS(); m_actions = new CVPCB_ACTIONS();
m_toolManager = new TOOL_MANAGER; m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this ); m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_CONTROL );
@ -365,7 +365,6 @@ void CVPCB_MAINFRAME::setupEventHandlers()
} ); } );
// Attach the events to the tool dispatcher // Attach the events to the tool dispatcher
Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher );
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
} }

View File

@ -106,7 +106,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(), m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
gal_drawPanel->GetViewControls(), config(), this ); gal_drawPanel->GetViewControls(), config(), this );
m_actions = new CVPCB_ACTIONS(); m_actions = new CVPCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
gal_drawPanel->SetEventDispatcher( m_toolDispatcher ); gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new COMMON_TOOLS );

View File

@ -69,9 +69,6 @@ public:
static TOOL_ACTION FilterFPbyFPFilters; static TOOL_ACTION FilterFPbyFPFilters;
static TOOL_ACTION filterFPbyPin; static TOOL_ACTION filterFPbyPin;
static TOOL_ACTION FilterFPbyLibrary; static TOOL_ACTION FilterFPbyLibrary;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
}; };
#endif #endif

View File

@ -334,7 +334,7 @@ void SCH_EDIT_FRAME::setupTools()
m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(), m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new EE_ACTIONS(); m_actions = new EE_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_CONTROL );

View File

@ -298,7 +298,7 @@ void SYMBOL_EDIT_FRAME::setupTools()
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(), m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new EE_ACTIONS(); m_actions = new EE_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_CONTROL );

View File

@ -231,7 +231,7 @@ void SYMBOL_VIEWER_FRAME::setupTools()
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(), m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new EE_ACTIONS(); m_actions = new EE_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new COMMON_TOOLS );

View File

@ -215,12 +215,6 @@ public:
static TOOL_ACTION clearHighlight; static TOOL_ACTION clearHighlight;
static TOOL_ACTION updateNetHighlighting; static TOOL_ACTION updateNetHighlighting;
static TOOL_ACTION highlightNetTool; static TOOL_ACTION highlightNetTool;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
{
return OPT<TOOL_EVENT>();
}
}; };

View File

@ -1026,7 +1026,7 @@ void GERBVIEW_FRAME::setupTools()
m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(), m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new GERBVIEW_ACTIONS(); m_actions = new GERBVIEW_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_CONTROL );

View File

@ -91,9 +91,6 @@ public:
static TOOL_ACTION highlightComponent; static TOOL_ACTION highlightComponent;
static TOOL_ACTION highlightAttribute; static TOOL_ACTION highlightAttribute;
static TOOL_ACTION highlightDCode; static TOOL_ACTION highlightDCode;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
}; };
#endif // __GERBVIEW_ACTIONS_H #endif // __GERBVIEW_ACTIONS_H

View File

@ -181,15 +181,6 @@ public:
static TOOL_ACTION getInvolved; static TOOL_ACTION getInvolved;
static TOOL_ACTION reportBug; static TOOL_ACTION reportBug;
/**
* Translate legacy tool ids to the corresponding TOOL_ACTION name.
*
* @param aId is legacy tool id to be translated.
* @return std::string is name of the corresponding TOOL_ACTION. It may be empty, if there is
* no corresponding TOOL_ACTION.
*/
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) = 0;
///< Cursor control event types ///< Cursor control event types
enum CURSOR_EVENT_TYPE { CURSOR_NONE, CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, enum CURSOR_EVENT_TYPE { CURSOR_NONE, CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT,
CURSOR_CLICK, CURSOR_DBL_CLICK, CURSOR_RIGHT_CLICK, CURSOR_CLICK, CURSOR_DBL_CLICK, CURSOR_RIGHT_CLICK,

View File

@ -53,9 +53,8 @@ class TOOL_DISPATCHER : public wxEvtHandler
public: public:
/** /**
* @param aToolMgr: tool manager instance the events will be sent to. * @param aToolMgr: tool manager instance the events will be sent to.
* @param aActions: ACTIONS subclass instance for ACTIONS::TranslateLegacyId().
*/ */
TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, ACTIONS *aActions ); TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr );
virtual ~TOOL_DISPATCHER(); virtual ~TOOL_DISPATCHER();
@ -77,14 +76,6 @@ public:
*/ */
OPT<TOOL_EVENT> GetToolEvent( wxKeyEvent* aKeyEvent, bool* aSpecialKeyFlag ); OPT<TOOL_EVENT> GetToolEvent( wxKeyEvent* aKeyEvent, bool* aSpecialKeyFlag );
/**
* Process wxCommands (mostly menu related events) and runs appropriate actions (eg. run the
* specified tool).
*
* @param aEvent is the wxCommandEvent to be processed.
*/
virtual void DispatchWxCommand( wxCommandEvent& aEvent );
private: private:
///< Number of mouse buttons that is handled in events. ///< Number of mouse buttons that is handled in events.
static const int MouseButtonCount = 3; static const int MouseButtonCount = 3;

View File

@ -201,10 +201,9 @@ void KICAD_MANAGER_FRAME::setupTools()
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this ); m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
m_actions = new KICAD_MANAGER_ACTIONS(); m_actions = new KICAD_MANAGER_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Attach the events to the tool dispatcher // Attach the events to the tool dispatcher
Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher );
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );

View File

@ -53,12 +53,6 @@ public:
static TOOL_ACTION editOtherSch; static TOOL_ACTION editOtherSch;
static TOOL_ACTION editOtherPCB; static TOOL_ACTION editOtherPCB;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
{
return OPT<TOOL_EVENT>();
}
}; };

View File

@ -231,7 +231,7 @@ void PL_EDITOR_FRAME::setupTools()
m_toolManager->SetEnvironment( nullptr, GetCanvas()->GetView(), m_toolManager->SetEnvironment( nullptr, GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new PL_ACTIONS(); m_actions = new PL_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
GetCanvas()->SetEventDispatcher( m_toolDispatcher ); GetCanvas()->SetEventDispatcher( m_toolDispatcher );

View File

@ -75,9 +75,6 @@ public:
static TOOL_ACTION refreshPreview; static TOOL_ACTION refreshPreview;
static TOOL_ACTION showInspector; static TOOL_ACTION showInspector;
static TOOL_ACTION previewSettings; static TOOL_ACTION previewSettings;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
}; };

View File

@ -929,7 +929,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
m_toolManager->SetEnvironment( GetBoard(), GetCanvas()->GetView(), m_toolManager->SetEnvironment( GetBoard(), GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new PCB_ACTIONS(); m_actions = new PCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
GetCanvas()->SetEventDispatcher( m_toolDispatcher ); GetCanvas()->SetEventDispatcher( m_toolDispatcher );

View File

@ -200,7 +200,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
drawPanel->GetViewControls(), config(), this ); drawPanel->GetViewControls(), config(), this );
m_actions = new PCB_ACTIONS(); m_actions = new PCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
drawPanel->SetEventDispatcher( m_toolDispatcher ); drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new PCB_CONTROL ); m_toolManager->RegisterTool( new PCB_CONTROL );

View File

@ -142,7 +142,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(), m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
gal_drawPanel->GetViewControls(), config(), this ); gal_drawPanel->GetViewControls(), config(), this );
m_actions = new PCB_ACTIONS(); m_actions = new PCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
gal_drawPanel->SetEventDispatcher( m_toolDispatcher ); gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new PCB_CONTROL ); m_toolManager->RegisterTool( new PCB_CONTROL );

View File

@ -479,7 +479,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(), m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), config(), this ); GetCanvas()->GetViewControls(), config(), this );
m_actions = new PCB_ACTIONS(); m_actions = new PCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools // Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL ); m_toolManager->RegisterTool( new COMMON_CONTROL );

View File

@ -33,11 +33,6 @@
#include <router/pns_router.h> #include <router/pns_router.h>
#include <router/pns_routing_settings.h> #include <router/pns_routing_settings.h>
OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
{
return OPT<TOOL_EVENT>();
}
// Actions, being statically-defined, require specialized I18N handling. We continue to // Actions, being statically-defined, require specialized I18N handling. We continue to
// use the _() macro so that string harvesting by the I18N framework doesn't have to be // use the _() macro so that string harvesting by the I18N framework doesn't have to be

View File

@ -475,9 +475,6 @@ public:
static TOOL_ACTION convertToLines; static TOOL_ACTION convertToLines;
static TOOL_ACTION convertToArc; static TOOL_ACTION convertToArc;
static TOOL_ACTION convertToTracks; static TOOL_ACTION convertToTracks;
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
}; };
#endif #endif

View File

@ -80,7 +80,7 @@ void PCB_TEST_FRAME_BASE::SetBoard( std::shared_ptr<BOARD> b )
m_galPanel->UpdateColors(); m_galPanel->UpdateColors();
#ifdef USE_TOOL_MANAGER #ifdef USE_TOOL_MANAGER
m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(), m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
m_galPanel->GetViewControls(), nullptr ); m_galPanel->GetViewControls(), nullptr );
@ -114,10 +114,6 @@ BOARD* PCB_TEST_FRAME_BASE::LoadAndDisplayBoard( const std::string& filename )
class TEST_ACTIONS : public ACTIONS class TEST_ACTIONS : public ACTIONS
{ {
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
{
return OPT<TOOL_EVENT> ();
}
}; };
void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType ) void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType )
@ -127,7 +123,7 @@ void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL
m_galPanel = std::make_shared<PCB_DRAW_PANEL_GAL>( aParent, -1, wxPoint( 0, m_galPanel = std::make_shared<PCB_DRAW_PANEL_GAL>( aParent, -1, wxPoint( 0,
0 ), wxDefaultSize, m_displayOptions, aGalType ); 0 ), wxDefaultSize, m_displayOptions, aGalType );
m_galPanel->UpdateColors(); m_galPanel->UpdateColors();
m_galPanel->SetEvtHandlerEnabled( true ); m_galPanel->SetEvtHandlerEnabled( true );
m_galPanel->SetFocus(); m_galPanel->SetFocus();
m_galPanel->Show( true ); m_galPanel->Show( true );
@ -151,13 +147,12 @@ void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL
m_galPanel->GetViewControls(), nullptr ); m_galPanel->GetViewControls(), nullptr );
m_pcbActions = std::make_unique<TEST_ACTIONS>( ); m_pcbActions = std::make_unique<TEST_ACTIONS>( );
m_toolDispatcher = std::make_unique<TOOL_DISPATCHER>( m_toolManager.get(), m_pcbActions.get() ); m_toolDispatcher = std::make_unique<TOOL_DISPATCHER>( m_toolManager.get() );
//m_toolManager->RegisterTool( new PCB_SELECTION_TOOL ); //m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
createUserTools(); createUserTools();
m_toolManager->InitTools(); m_toolManager->InitTools();
m_galPanel->SetEventDispatcher( m_toolDispatcher.get() );
m_toolManager->InvokeTool( "test.DefaultTool" ); m_toolManager->InvokeTool( "test.DefaultTool" );
#endif #endif
@ -179,4 +174,4 @@ void PCB_TEST_FRAME_BASE::LoadSettings()
auto cs = Pgm().GetSettingsManager().GetColorSettings(); auto cs = Pgm().GetSettingsManager().GetColorSettings();
//cs->SetColorContext( COLOR_CONTEXT::PCB ); //cs->SetColorContext( COLOR_CONTEXT::PCB );
cs->Load(); cs->Load();
} }