Commit a802ca87 authored by Maciej Suminski's avatar Maciej Suminski

Added TOOL_ACTION for PNS router activation.

Most of the GAL tools are activated by corresponding buttons on the right toolbar.
Removed menu entry for PNS router (as it is activated as the usual "Add track" tool).
parent e14d9aaf
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <class_drawpanel_gal.h> #include <class_drawpanel_gal.h>
#include <pcbnew_id.h>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -273,19 +271,5 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -273,19 +271,5 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent ) void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
{ {
bool activateTool = false; // no events to dispatch currently
std::string toolName;
// fixme: use TOOL_ACTIONs here
switch( aEvent.GetId() )
{
case ID_PNS_ROUTER_TOOL:
toolName = "pcbnew.InteractiveRouter";
activateTool = true;
break;
}
// do nothing if the legacy view is active
if( activateTool && m_editFrame->IsGalCanvasActive() )
m_toolMgr->InvokeTool( toolName );
} }
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
#include <dialog_global_edit_tracks_and_vias.h> #include <dialog_global_edit_tracks_and_vias.h>
#include <invoke_pcb_dialog.h> #include <invoke_pcb_dialog.h>
#include <tool/tool_manager.h>
#include <tools/common_actions.h>
// Handles the selection of command events. // Handles the selection of command events.
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
...@@ -1451,4 +1454,13 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) ...@@ -1451,4 +1454,13 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
break; break;
} }
if( IsGalCanvasActive() )
{
std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
if( !actionName.empty() )
m_toolManager->RunAction( actionName );
return;
}
} }
...@@ -312,13 +312,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -312,13 +312,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Reset text size and width of all module fields to current defaults" ), _( "Reset text size and width of all module fields to current defaults" ),
KiBitmap( reset_text_xpm ) ); KiBitmap( reset_text_xpm ) );
editMenu->AppendSeparator();
AddMenuItem( editMenu, ID_PNS_ROUTER_TOOL,
_( "Interactive router" ),
_( "Interactive router drag&drop tool." ),
KiBitmap( tools_xpm ) );
/** Create View menu **/ /** Create View menu **/
wxMenu* viewMenu = new wxMenu; wxMenu* viewMenu = new wxMenu;
......
...@@ -126,12 +126,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) ...@@ -126,12 +126,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit ) EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
// menu Config // menu Config
/* Tom's hacks start */
EVT_MENU ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand )
EVT_TOOL ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand )
/* Tom's hacks end */
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions ) EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions )
EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config )
......
...@@ -369,9 +369,7 @@ enum pcbnew_ids ...@@ -369,9 +369,7 @@ enum pcbnew_ids
ID_FOOTPRINT_WIZARD_PAGES_WINDOW, ID_FOOTPRINT_WIZARD_PAGES_WINDOW,
ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW,
ID_FOOTPRINT_WIZARD_SELECT_WIZARD, ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD, ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD
ID_PNS_ROUTER_TOOL
}; };
#endif // PCBNEW_ID_H_ #endif // PCBNEW_ID_H_
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <pcb_painter.h> #include <pcb_painter.h>
#include <tool/context_menu.h> #include <tool/context_menu.h>
#include <tools/common_actions.h>
#include <ratsnest_data.h> #include <ratsnest_data.h>
...@@ -88,7 +89,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason ) ...@@ -88,7 +89,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
if( getView() ) if( getView() )
m_router->SetView( getView() ); m_router->SetView( getView() );
Go( &ROUTER_TOOL::Main, TOOL_EVENT( TC_COMMAND, TA_ACTION, GetName() ) ); Go( &ROUTER_TOOL::Main, COMMON_ACTIONS::routerActivate.MakeEvent() );
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "common_actions.h" #include "common_actions.h"
#include <tool/action_manager.h> #include <tool/action_manager.h>
#include <pcbnew_id.h>
#include <wx/defs.h> #include <wx/defs.h>
// Selection tool actions // Selection tool actions
...@@ -57,38 +58,82 @@ TOOL_ACTION COMMON_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", ...@@ -57,38 +58,82 @@ TOOL_ACTION COMMON_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
AS_GLOBAL, 'E', AS_GLOBAL, 'E',
"Properties...", "Displays properties window" ); "Properties...", "Displays properties window" );
// Drawing tool actions
TOOL_ACTION COMMON_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line", TOOL_ACTION COMMON_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line",
AS_GLOBAL, 'D', AS_GLOBAL, 0,
"Draw a line", "Draw a line" ); "Draw a line", "Draw a line" );
TOOL_ACTION COMMON_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle", TOOL_ACTION COMMON_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle",
AS_GLOBAL, 'S', AS_GLOBAL, 0,
"Draw a circle", "Draw a circle" ); "Draw a circle", "Draw a circle" );
TOOL_ACTION COMMON_ACTIONS::drawArc( "pcbnew.InteractiveDrawing.arc", TOOL_ACTION COMMON_ACTIONS::drawArc( "pcbnew.InteractiveDrawing.arc",
AS_GLOBAL, 'A', AS_GLOBAL, 0,
"Draw an arc", "Draw an arc" ); "Draw an arc", "Draw an arc" );
TOOL_ACTION COMMON_ACTIONS::drawText( "pcbnew.InteractiveDrawing.text", TOOL_ACTION COMMON_ACTIONS::drawText( "pcbnew.InteractiveDrawing.text",
AS_GLOBAL, 'T', AS_GLOBAL, 0,
"Add a text", "Add a text" ); "Add a text", "Add a text" );
TOOL_ACTION COMMON_ACTIONS::drawDimension( "pcbnew.InteractiveDrawing.dimension", TOOL_ACTION COMMON_ACTIONS::drawDimension( "pcbnew.InteractiveDrawing.dimension",
AS_GLOBAL, 'X', AS_GLOBAL, 0,
"Add a dimension", "Add a dimension" ); "Add a dimension", "Add a dimension" );
TOOL_ACTION COMMON_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone", TOOL_ACTION COMMON_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone",
AS_GLOBAL, 'B', AS_GLOBAL, 0,
"Add a filled zone", "Add a filled zone" ); "Add a filled zone", "Add a filled zone" );
TOOL_ACTION COMMON_ACTIONS::drawKeepout( "pcbnew.InteractiveDrawing.keepout", TOOL_ACTION COMMON_ACTIONS::drawKeepout( "pcbnew.InteractiveDrawing.keepout",
AS_GLOBAL, 'N', AS_GLOBAL, 0,
"Add a keepout area", "Add a keepout area" ); "Add a keepout area", "Add a keepout area" );
TOOL_ACTION COMMON_ACTIONS::placeTarget( "pcbnew.InteractiveDrawing.placeTarget", TOOL_ACTION COMMON_ACTIONS::placeTarget( "pcbnew.InteractiveDrawing.placeTarget",
AS_GLOBAL, 'C', AS_GLOBAL, 0,
"Add layer alignment target", "Add layer alignment target" ); "Add layer alignment target", "Add layer alignment target" );
TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.InteractiveDrawing.placeModule", TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.InteractiveDrawing.placeModule",
AS_GLOBAL, 'V', AS_GLOBAL, 0,
"Add modules", "Add modules" ); "Add modules", "Add modules" );
TOOL_ACTION COMMON_ACTIONS::routerActivate( "pcbnew.InteractiveRouter",
AS_GLOBAL, 0,
"Run push & shove router", "Run push & shove router" );
std::string COMMON_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_PCB_MODULE_BUTT:
return COMMON_ACTIONS::placeModule.GetName();
case ID_TRACK_BUTT:
return COMMON_ACTIONS::routerActivate.GetName();
case ID_PCB_ZONES_BUTT:
return COMMON_ACTIONS::drawZone.GetName();
case ID_PCB_KEEPOUT_AREA_BUTT:
return COMMON_ACTIONS::drawKeepout.GetName();
case ID_PCB_ADD_LINE_BUTT:
return COMMON_ACTIONS::drawLine.GetName();
case ID_PCB_CIRCLE_BUTT:
return COMMON_ACTIONS::drawCircle.GetName();
case ID_PCB_ARC_BUTT:
return COMMON_ACTIONS::drawArc.GetName();
case ID_PCB_ADD_TEXT_BUTT:
return COMMON_ACTIONS::drawText.GetName();
case ID_PCB_DIMENSION_BUTT:
return COMMON_ACTIONS::drawDimension.GetName();
case ID_PCB_MIRE_BUTT:
return COMMON_ACTIONS::placeTarget.GetName();
}
return "";
}
...@@ -83,4 +83,16 @@ public: ...@@ -83,4 +83,16 @@ public:
/// Activation of the drawing tool (placing a MODULE) /// Activation of the drawing tool (placing a MODULE)
static TOOL_ACTION placeModule; static TOOL_ACTION placeModule;
/// Activation of the Push and Shove router
static TOOL_ACTION routerActivate;
/**
* Function TranslateLegacyId()
* Translates 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.
*/
static std::string TranslateLegacyId( int aId );
}; };
...@@ -64,6 +64,7 @@ void PCB_EDIT_FRAME::setupTools() ...@@ -64,6 +64,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager->RegisterAction( &COMMON_ACTIONS::drawKeepout ); m_toolManager->RegisterAction( &COMMON_ACTIONS::drawKeepout );
m_toolManager->RegisterAction( &COMMON_ACTIONS::placeTarget ); m_toolManager->RegisterAction( &COMMON_ACTIONS::placeTarget );
m_toolManager->RegisterAction( &COMMON_ACTIONS::placeModule ); 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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment