Commit 24a317ce authored by Maciej Suminski's avatar Maciej Suminski

The Selection Tool is always active. Removed entries for toolbar menu and hotkeys for the tool.

parent 7d788109
...@@ -280,11 +280,6 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent ) ...@@ -280,11 +280,6 @@ void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
toolName = "pcbnew.InteractiveRouter"; toolName = "pcbnew.InteractiveRouter";
activateTool = true; activateTool = true;
break; break;
case ID_SELECTION_TOOL:
toolName = "pcbnew.InteractiveSelection";
activateTool = true;
break;
} }
// do nothing if the legacy view is active // do nothing if the legacy view is active
......
...@@ -97,7 +97,7 @@ struct TOOL_MANAGER::TOOL_STATE ...@@ -97,7 +97,7 @@ struct TOOL_MANAGER::TOOL_STATE
TOOL_MANAGER::TOOL_MANAGER() : TOOL_MANAGER::TOOL_MANAGER() :
m_model( NULL ), m_view( NULL ) m_model( NULL ), m_view( NULL ), m_viewControls( NULL ), m_editFrame( NULL )
{ {
m_actionMgr = new ACTION_MANAGER( this ); m_actionMgr = new ACTION_MANAGER( this );
} }
...@@ -476,6 +476,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -476,6 +476,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if( m_view->IsDirty() ) if( m_view->IsDirty() )
{ {
PCB_EDIT_FRAME* f = static_cast<PCB_EDIT_FRAME*>( GetEditFrame() ); PCB_EDIT_FRAME* f = static_cast<PCB_EDIT_FRAME*>( GetEditFrame() );
if( f->IsGalCanvasActive() )
f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER. f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
} }
......
...@@ -310,11 +310,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -310,11 +310,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
editMenu->AppendSeparator(); editMenu->AppendSeparator();
AddMenuItem( editMenu, ID_SELECTION_TOOL,
_( "Select Tool" ),
_( "Interactive selection and drag&drop tool." ),
KiBitmap( tools_xpm ) );
AddMenuItem( editMenu, ID_PNS_ROUTER_TOOL, AddMenuItem( editMenu, ID_PNS_ROUTER_TOOL,
_( "Interactive router" ), _( "Interactive router" ),
_( "Interactive router drag&drop tool." ), _( "Interactive router drag&drop tool." ),
......
...@@ -121,8 +121,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) ...@@ -121,8 +121,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
// menu Config // menu Config
/* Tom's hacks start */ /* Tom's hacks start */
EVT_MENU ( ID_SELECTION_TOOL, PCB_EDIT_FRAME::onGenericCommand )
EVT_TOOL ( ID_SELECTION_TOOL, PCB_EDIT_FRAME::onGenericCommand )
EVT_MENU ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand ) EVT_MENU ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand )
EVT_TOOL ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand ) EVT_TOOL ( ID_PNS_ROUTER_TOOL, PCB_EDIT_FRAME::onGenericCommand )
/* Tom's hacks end */ /* Tom's hacks end */
......
...@@ -370,7 +370,6 @@ enum pcbnew_ids ...@@ -370,7 +370,6 @@ enum pcbnew_ids
ID_FOOTPRINT_WIZARD_SELECT_WIZARD, ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD, ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD,
ID_SELECTION_TOOL,
ID_PNS_ROUTER_TOOL ID_PNS_ROUTER_TOOL
}; };
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
// Selection tool actions // Selection tool actions
TOOL_ACTION COMMON_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection", TOOL_ACTION COMMON_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection",
AS_GLOBAL, 'S', AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
"Selection tool", "Allows to select items" );
// Edit tool actions // Edit tool actions
TOOL_ACTION COMMON_ACTIONS::editActivate( "pcbnew.InteractiveEdit", TOOL_ACTION COMMON_ACTIONS::editActivate( "pcbnew.InteractiveEdit",
......
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
class COMMON_ACTIONS class COMMON_ACTIONS
{ {
public: public:
/// Activation of the move tool
static TOOL_ACTION editActivate;
/// Activation of the selection tool /// Activation of the selection tool
static TOOL_ACTION selectionActivate; static TOOL_ACTION selectionActivate;
/// Activation of the edit tool
static TOOL_ACTION editActivate;
/// Rotation of selected objects /// Rotation of selected objects
static TOOL_ACTION rotate; static TOOL_ACTION rotate;
......
...@@ -48,7 +48,6 @@ void PCB_EDIT_FRAME::setupTools() ...@@ -48,7 +48,6 @@ void PCB_EDIT_FRAME::setupTools()
// Register tool actions // Register tool actions
m_toolManager->RegisterAction( &COMMON_ACTIONS::editActivate ); m_toolManager->RegisterAction( &COMMON_ACTIONS::editActivate );
m_toolManager->RegisterAction( &COMMON_ACTIONS::selectionActivate );
m_toolManager->RegisterAction( &COMMON_ACTIONS::rotate ); m_toolManager->RegisterAction( &COMMON_ACTIONS::rotate );
m_toolManager->RegisterAction( &COMMON_ACTIONS::flip ); m_toolManager->RegisterAction( &COMMON_ACTIONS::flip );
m_toolManager->RegisterAction( &COMMON_ACTIONS::properties ); m_toolManager->RegisterAction( &COMMON_ACTIONS::properties );
...@@ -57,6 +56,12 @@ void PCB_EDIT_FRAME::setupTools() ...@@ -57,6 +56,12 @@ void PCB_EDIT_FRAME::setupTools()
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->SetEnvironment( NULL, m_galCanvas->GetView(),
m_galCanvas->GetViewControls(), this );
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
} }
......
...@@ -66,6 +66,8 @@ SELECTION_TOOL::~SELECTION_TOOL() ...@@ -66,6 +66,8 @@ SELECTION_TOOL::~SELECTION_TOOL()
void SELECTION_TOOL::Reset() void SELECTION_TOOL::Reset()
{ {
clearSelection();
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView()->Remove( m_selection.group ); getView()->Remove( m_selection.group );
getView()->Add( m_selection.group ); getView()->Add( m_selection.group );
...@@ -77,12 +79,6 @@ void SELECTION_TOOL::Reset() ...@@ -77,12 +79,6 @@ void SELECTION_TOOL::Reset()
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{ {
KIGFX::VIEW* view = getView();
assert( getModel<BOARD>( PCB_T ) != NULL );
view->Add( m_selection.group );
// Main loop: keep receiving events // Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
...@@ -94,8 +90,8 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -94,8 +90,8 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{ {
if( !m_selection.Empty() ) // Cancel event deselects items... if( !m_selection.Empty() ) // Cancel event deselects items...
clearSelection(); clearSelection();
else // ...unless there is nothing selected
break; // then exit the tool // This tool never exits
} }
// single click? Select single object // single click? Select single object
...@@ -142,8 +138,8 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -142,8 +138,8 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
} }
} }
m_selection.group->Clear(); // This tool is supposed to be active forever
view->Remove( m_selection.group ); assert( false );
return 0; return 0;
} }
...@@ -188,6 +184,7 @@ void SELECTION_TOOL::clearSelection() ...@@ -188,6 +184,7 @@ void SELECTION_TOOL::clearSelection()
{ {
KIGFX::VIEW_GROUP::const_iter it, it_end; KIGFX::VIEW_GROUP::const_iter it, it_end;
// Restore the initial properties
for( it = m_selection.group->Begin(), it_end = m_selection.group->End(); it != it_end; ++it ) for( it = m_selection.group->Begin(), it_end = m_selection.group->End(); it != it_end; ++it )
{ {
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
...@@ -196,8 +193,7 @@ void SELECTION_TOOL::clearSelection() ...@@ -196,8 +193,7 @@ void SELECTION_TOOL::clearSelection()
item->ClearSelected(); item->ClearSelected();
} }
m_selection.group->Clear(); m_selection.Clear();
m_selection.items.clear();
// Do not show the context menu when there is nothing selected // Do not show the context menu when there is nothing selected
SetContextMenu( &m_menu, CMENU_OFF ); SetContextMenu( &m_menu, CMENU_OFF );
...@@ -609,3 +605,10 @@ bool SELECTION_TOOL::containsSelected( const VECTOR2I& aPoint ) const ...@@ -609,3 +605,10 @@ bool SELECTION_TOOL::containsSelected( const VECTOR2I& aPoint ) const
return false; return false;
} }
void SELECTION_TOOL::SELECTION::Clear()
{
items.clear();
group->Clear();
}
...@@ -78,6 +78,10 @@ public: ...@@ -78,6 +78,10 @@ public:
{ {
return items.size(); return items.size();
} }
/// Clears both the VIEW_GROUP and set of selected items. Please note that it does not
/// change properties of selected items (e.g. selection flag).
void Clear();
}; };
/// @copydoc TOOL_INTERACTIVE::Reset() /// @copydoc TOOL_INTERACTIVE::Reset()
......
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