TOOL_EVENTs autoregister themselves in ACTION_MANAGER.
ROUTER_TOOL events have temporarily changed their hotkeys assignment.
This commit is contained in:
parent
426844896e
commit
0694f2fa1c
|
@ -60,8 +60,6 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
||||||
|
|
||||||
m_actionHotKeys[aAction->m_currentHotKey] = aAction;
|
m_actionHotKeys[aAction->m_currentHotKey] = aAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
aAction->setActionMgr( this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +69,6 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
|
||||||
m_actionIdIndex.erase( aAction->m_id );
|
m_actionIdIndex.erase( aAction->m_id );
|
||||||
|
|
||||||
// Indicate that the ACTION_MANAGER no longer care about the object
|
// Indicate that the ACTION_MANAGER no longer care about the object
|
||||||
aAction->setActionMgr( NULL );
|
|
||||||
aAction->setId( -1 );
|
aAction->setId( -1 );
|
||||||
|
|
||||||
if( aAction->HasHotKey() )
|
if( aAction->HasHotKey() )
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <tool/tool_base.h>
|
#include <tool/tool_base.h>
|
||||||
#include <tool/action_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TOOL_ACTION
|
* Class TOOL_ACTION
|
||||||
|
@ -50,14 +50,14 @@ public:
|
||||||
const std::string& aMenuDesc = std::string( "" ) ) :
|
const std::string& aMenuDesc = std::string( "" ) ) :
|
||||||
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
|
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
|
||||||
m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
|
m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
|
||||||
m_menuDescription( aMenuDesc ), m_id( -1 ), m_actionMgr( NULL )
|
m_menuDescription( aMenuDesc ), m_id( -1 )
|
||||||
{
|
{
|
||||||
|
TOOL_MANAGER::Instance().RegisterAction( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
~TOOL_ACTION()
|
~TOOL_ACTION()
|
||||||
{
|
{
|
||||||
if( m_actionMgr )
|
TOOL_MANAGER::Instance().UnregisterAction( this );
|
||||||
m_actionMgr->UnregisterAction( this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( const TOOL_ACTION& aRhs ) const
|
bool operator==( const TOOL_ACTION& aRhs ) const
|
||||||
|
@ -180,12 +180,6 @@ private:
|
||||||
m_id = aId;
|
m_id = aId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assigns ACTION_MANAGER object that handles the TOOL_ACTION.
|
|
||||||
void setActionMgr( ACTION_MANAGER* aManager )
|
|
||||||
{
|
|
||||||
m_actionMgr = aManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the action (convention is: app.[tool.]action.name)
|
/// Name of the action (convention is: app.[tool.]action.name)
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
|
@ -210,9 +204,6 @@ private:
|
||||||
/// Unique ID for fast matching. Assigned by ACTION_MANAGER.
|
/// Unique ID for fast matching. Assigned by ACTION_MANAGER.
|
||||||
int m_id;
|
int m_id;
|
||||||
|
|
||||||
/// Action manager that handles this TOOL_ACTION.
|
|
||||||
ACTION_MANAGER* m_actionMgr;
|
|
||||||
|
|
||||||
/// Origin of the action
|
/// Origin of the action
|
||||||
// const TOOL_BASE* m_origin;
|
// const TOOL_BASE* m_origin;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,13 @@ class wxWindow;
|
||||||
class TOOL_MANAGER
|
class TOOL_MANAGER
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TOOL_MANAGER();
|
static TOOL_MANAGER& Instance()
|
||||||
|
{
|
||||||
|
static TOOL_MANAGER manager;
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
~TOOL_MANAGER();
|
~TOOL_MANAGER();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,6 +217,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TOOL_MANAGER();
|
||||||
|
|
||||||
struct TOOL_STATE;
|
struct TOOL_STATE;
|
||||||
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ protected:
|
||||||
/// main window.
|
/// main window.
|
||||||
wxAuiToolBar* m_auxiliaryToolBar;
|
wxAuiToolBar* m_auxiliaryToolBar;
|
||||||
|
|
||||||
TOOL_MANAGER* m_toolManager;
|
TOOL_MANAGER& m_toolManager;
|
||||||
TOOL_DISPATCHER* m_toolDispatcher;
|
TOOL_DISPATCHER* m_toolDispatcher;
|
||||||
|
|
||||||
void updateGridSelectBox();
|
void updateGridSelectBox();
|
||||||
|
|
|
@ -131,10 +131,10 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
|
||||||
const wxString& aTitle,
|
const wxString& aTitle,
|
||||||
const wxPoint& aPos, const wxSize& aSize,
|
const wxPoint& aPos, const wxSize& aSize,
|
||||||
long aStyle, const wxString & aFrameName) :
|
long aStyle, const wxString & aFrameName) :
|
||||||
EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
|
EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
|
||||||
|
m_toolManager( TOOL_MANAGER::Instance() )
|
||||||
{
|
{
|
||||||
m_Pcb = NULL;
|
m_Pcb = NULL;
|
||||||
m_toolManager = NULL;
|
|
||||||
m_toolDispatcher = NULL;
|
m_toolDispatcher = NULL;
|
||||||
|
|
||||||
m_DisplayPadFill = true; // How to draw pads
|
m_DisplayPadFill = true; // How to draw pads
|
||||||
|
|
|
@ -629,7 +629,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
// Inform tools that undo command was issued
|
// Inform tools that undo command was issued
|
||||||
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
|
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
|
||||||
m_toolManager->ProcessEvent( event );
|
m_toolManager.ProcessEvent( event );
|
||||||
|
|
||||||
/* Get the old list */
|
/* Get the old list */
|
||||||
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
||||||
|
@ -652,7 +652,7 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
// Inform tools that redo command was issued
|
// Inform tools that redo command was issued
|
||||||
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
|
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
|
||||||
m_toolManager->ProcessEvent( event );
|
m_toolManager.ProcessEvent( event );
|
||||||
|
|
||||||
/* Get the old list */
|
/* Get the old list */
|
||||||
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
|
||||||
|
|
|
@ -1466,7 +1466,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
|
std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
|
||||||
|
|
||||||
if( !actionName.empty() )
|
if( !actionName.empty() )
|
||||||
m_toolManager->RunAction( actionName );
|
m_toolManager.RunAction( actionName );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,12 +528,9 @@ void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard )
|
||||||
ViewReloadBoard( aBoard );
|
ViewReloadBoard( aBoard );
|
||||||
|
|
||||||
// update the tool manager with the new board and its view.
|
// update the tool manager with the new board and its view.
|
||||||
if( m_toolManager )
|
m_toolManager.SetEnvironment( aBoard, GetGalCanvas()->GetView(),
|
||||||
{
|
GetGalCanvas()->GetViewControls(), this );
|
||||||
m_toolManager->SetEnvironment( aBoard, GetGalCanvas()->GetView(),
|
m_toolManager.ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||||
GetGalCanvas()->GetViewControls(), this );
|
|
||||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,9 +711,9 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
|
||||||
// Update potential changes in the ratsnest
|
// Update potential changes in the ratsnest
|
||||||
m_Pcb->GetRatsnest()->Recalculate();
|
m_Pcb->GetRatsnest()->Recalculate();
|
||||||
|
|
||||||
m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
|
m_toolManager.SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
|
||||||
GetGalCanvas()->GetViewControls(), this );
|
GetGalCanvas()->GetViewControls(), this );
|
||||||
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
|
m_toolManager.ResetTools( TOOL_BASE::GAL_SWITCH );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,11 @@
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
using boost::optional;
|
using boost::optional;
|
||||||
|
|
||||||
static TOOL_ACTION ACT_AutoEndRoute( "AutoEndRoute", AS_CONTEXT, 'F' );
|
static TOOL_ACTION ACT_AutoEndRoute( "AutoEndRoute", AS_CONTEXT, 'G' );
|
||||||
static TOOL_ACTION ACT_PlaceVia( "PlaceVia", AS_CONTEXT, 'V' );
|
static TOOL_ACTION ACT_PlaceVia( "PlaceVia", AS_CONTEXT, 'V' );
|
||||||
static TOOL_ACTION ACT_OpenRouteOptions( "OpenRouterOptions", AS_CONTEXT, 'E' );
|
static TOOL_ACTION ACT_OpenRouteOptions( "OpenRouterOptions", AS_CONTEXT, 'Y' );
|
||||||
static TOOL_ACTION ACT_SwitchPosture( "SwitchPosture", AS_CONTEXT, '/' );
|
static TOOL_ACTION ACT_SwitchPosture( "SwitchPosture", AS_CONTEXT, '/' );
|
||||||
static TOOL_ACTION ACT_EndTrack( "SwitchPosture", AS_CONTEXT, WXK_END );
|
static TOOL_ACTION ACT_EndTrack( "EndTrack", AS_CONTEXT, WXK_END );
|
||||||
|
|
||||||
ROUTER_TOOL::ROUTER_TOOL() :
|
ROUTER_TOOL::ROUTER_TOOL() :
|
||||||
TOOL_INTERACTIVE( "pcbnew.InteractiveRouter" )
|
TOOL_INTERACTIVE( "pcbnew.InteractiveRouter" )
|
||||||
|
|
|
@ -38,54 +38,36 @@
|
||||||
#include "edit_tool.h"
|
#include "edit_tool.h"
|
||||||
#include "drawing_tool.h"
|
#include "drawing_tool.h"
|
||||||
#include "point_editor.h"
|
#include "point_editor.h"
|
||||||
|
#include "settings_tool.h"
|
||||||
#include "common_actions.h"
|
#include "common_actions.h"
|
||||||
#include <router/router_tool.h>
|
#include <router/router_tool.h>
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::setupTools()
|
void PCB_EDIT_FRAME::setupTools()
|
||||||
{
|
{
|
||||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||||
m_toolManager = new TOOL_MANAGER;
|
m_toolManager = TOOL_MANAGER::Instance();
|
||||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this );
|
m_toolDispatcher = new TOOL_DISPATCHER( &m_toolManager, this );
|
||||||
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
|
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
|
||||||
|
|
||||||
// Register tool actions
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::selectionSingle );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::selectionClear );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::editActivate );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::rotate );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::flip );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::remove );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::properties );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawLine );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawCircle );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawArc );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawText );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawDimension );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawZone );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawKeepout );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::placeTarget );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::placeModule );
|
|
||||||
m_toolManager->RegisterAction( &COMMON_ACTIONS::routerActivate );
|
|
||||||
|
|
||||||
// Register tools
|
// Register tools
|
||||||
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
m_toolManager.RegisterTool( new SELECTION_TOOL );
|
||||||
m_toolManager->RegisterTool( new ROUTER_TOOL );
|
m_toolManager.RegisterTool( new ROUTER_TOOL );
|
||||||
m_toolManager->RegisterTool( new EDIT_TOOL );
|
m_toolManager.RegisterTool( new EDIT_TOOL );
|
||||||
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
m_toolManager.RegisterTool( new DRAWING_TOOL );
|
||||||
m_toolManager->RegisterTool( new POINT_EDITOR );
|
m_toolManager.RegisterTool( new POINT_EDITOR );
|
||||||
|
m_toolManager.RegisterTool( new SETTINGS_TOOL );
|
||||||
|
|
||||||
m_toolManager->SetEnvironment( NULL, GetGalCanvas()->GetView(),
|
m_toolManager.SetEnvironment( NULL, GetGalCanvas()->GetView(),
|
||||||
GetGalCanvas()->GetViewControls(), this );
|
GetGalCanvas()->GetViewControls(), this );
|
||||||
m_toolManager->ResetTools( TOOL_BASE::RUN );
|
m_toolManager.ResetTools( TOOL_BASE::RUN );
|
||||||
|
|
||||||
// Run the selection tool, it is supposed to be always active
|
// Run the selection tool, it is supposed to be always active
|
||||||
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
m_toolManager.InvokeTool( "pcbnew.InteractiveSelection" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::destroyTools()
|
void PCB_EDIT_FRAME::destroyTools()
|
||||||
{
|
{
|
||||||
delete m_toolManager;
|
|
||||||
delete m_toolDispatcher;
|
delete m_toolDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue