Fix double disambiguation menu on track removal

Commit complementary to 4f0c9b6b. In case there were multiple tracks
under the cursor, disambiguation was shown twice because
SELECTION_TOOL::selectConnection() cleared the selection and requested
it again.
This commit is contained in:
Maciej Suminski 2018-02-13 11:20:14 +01:00
parent a1af13f34d
commit 90d53df790
4 changed files with 20 additions and 2 deletions

View File

@ -858,8 +858,8 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
if( isAlt && selection.IsHover()
&& ( selection.HasType( PCB_TRACE_T ) || selection.HasType( PCB_VIA_T ) ) )
{
m_toolMgr->RunAction( PCB_ACTIONS::selectConnection, true );
selection = m_selectionTool->RequestSelection( SELECTION_DELETABLE | SELECTION_SANITIZE_PADS );
m_toolMgr->RunAction( PCB_ACTIONS::expandSelectedConnection, true );
selection = m_selectionTool->GetSelection();
}
if( selection.Empty() )

View File

@ -67,6 +67,9 @@ public:
/// Selects a connection between junctions.
static TOOL_ACTION selectConnection;
/// Expands the current selection to select a connection between two junctions
static TOOL_ACTION expandSelectedConnection;
/// Selects whole copper connection.
static TOOL_ACTION selectCopper;

View File

@ -99,6 +99,11 @@ TOOL_ACTION PCB_ACTIONS::selectCopper( "pcbnew.InteractiveSelection.SelectCopper
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SEL_COPPER_CONNECTION ),
_( "Copper Connection" ), _( "Selects whole copper connection." ) );
TOOL_ACTION PCB_ACTIONS::expandSelectedConnection( "pcbnew.InteractiveSelection.ExpandConnection",
AS_GLOBAL, 0,
_( "Expand Selected Connection" ),
_( "Expands the current selection to select a connection between two junctions." ) );
TOOL_ACTION PCB_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet",
AS_GLOBAL, 0,
_( "Whole Net" ), _( "Selects all tracks & vias belonging to the same net." ) );
@ -660,6 +665,7 @@ void SELECTION_TOOL::setTransitions()
Go( &SELECTION_TOOL::findMove, PCB_ACTIONS::findMove.MakeEvent() );
Go( &SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() );
Go( &SELECTION_TOOL::selectConnection, PCB_ACTIONS::selectConnection.MakeEvent() );
Go( &SELECTION_TOOL::expandSelectedConnection, PCB_ACTIONS::expandSelectedConnection.MakeEvent() );
Go( &SELECTION_TOOL::selectCopper, PCB_ACTIONS::selectCopper.MakeEvent() );
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
Go( &SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() );
@ -832,6 +838,12 @@ int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent )
if( !selectCursor( true, connectedTrackFilter ) )
return 0;
return expandSelectedConnection( aEvent );
}
int SELECTION_TOOL::expandSelectedConnection( const TOOL_EVENT& aEvent )
{
// copy the selection, since we're going to iterate and modify
auto selection = m_selection.GetItems();

View File

@ -181,6 +181,9 @@ private:
///> Selects a trivial connection (between two junctions) of items in selection
int selectConnection( const TOOL_EVENT& aEvent );
///> Expands the current selection to select a connection between two junctions
int expandSelectedConnection( const TOOL_EVENT& aEvent );
///> Selects items with a continuous copper connection to items in selection
int selectCopper( const TOOL_EVENT& aEvent );