ADDED: Deselect net action
You can now deselect nets and netclasses (i.e. remove them from the active selection) via the context menus in the appearance panel
This commit is contained in:
parent
2b43ffd12d
commit
4a25db599e
|
@ -670,6 +670,8 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
||||||
|
|
||||||
mgr->SetConditions( PCB_ACTIONS::selectNet,
|
mgr->SetConditions( PCB_ACTIONS::selectNet,
|
||||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
||||||
|
mgr->SetConditions( PCB_ACTIONS::deselectNet,
|
||||||
|
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
||||||
mgr->SetConditions( PCB_ACTIONS::selectConnection,
|
mgr->SetConditions( PCB_ACTIONS::selectConnection,
|
||||||
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
ENABLE( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) ) );
|
||||||
mgr->SetConditions( PCB_ACTIONS::selectSameSheet,
|
mgr->SetConditions( PCB_ACTIONS::selectSameSheet,
|
||||||
|
|
|
@ -1156,6 +1156,12 @@ TOOL_ACTION PCB_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet",
|
||||||
_( "Selects all tracks & vias belonging to the same net." ),
|
_( "Selects all tracks & vias belonging to the same net." ),
|
||||||
mode_track_xpm );
|
mode_track_xpm );
|
||||||
|
|
||||||
|
TOOL_ACTION PCB_ACTIONS::deselectNet( "pcbnew.InteractiveSelection.DeselectNet",
|
||||||
|
AS_GLOBAL, 0, "",
|
||||||
|
_( "Deselect All Tracks in Net" ),
|
||||||
|
_( "Deselects all tracks & vias belonging to the same net." ),
|
||||||
|
mode_track_xpm );
|
||||||
|
|
||||||
TOOL_ACTION PCB_ACTIONS::selectOnSheetFromEeschema( "pcbnew.InteractiveSelection.SelectOnSheet",
|
TOOL_ACTION PCB_ACTIONS::selectOnSheetFromEeschema( "pcbnew.InteractiveSelection.SelectOnSheet",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Sheet" ),
|
_( "Sheet" ),
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
/// Selects all connections belonging to a single net.
|
/// Selects all connections belonging to a single net.
|
||||||
static TOOL_ACTION selectNet;
|
static TOOL_ACTION selectNet;
|
||||||
|
|
||||||
|
/// Removes all connections belonging to a single net from the active selection
|
||||||
|
static TOOL_ACTION deselectNet;
|
||||||
|
|
||||||
/// Selects all components on sheet from Eeschema crossprobing.
|
/// Selects all components on sheet from Eeschema crossprobing.
|
||||||
static TOOL_ACTION selectOnSheetFromEeschema;
|
static TOOL_ACTION selectOnSheetFromEeschema;
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
|
|
||||||
Add( PCB_ACTIONS::selectConnection );
|
Add( PCB_ACTIONS::selectConnection );
|
||||||
Add( PCB_ACTIONS::selectNet );
|
Add( PCB_ACTIONS::selectNet );
|
||||||
|
Add( PCB_ACTIONS::deselectNet );
|
||||||
Add( PCB_ACTIONS::selectSameSheet );
|
Add( PCB_ACTIONS::selectSameSheet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,25 +1067,27 @@ void SELECTION_TOOL::selectConnectedTracks( BOARD_CONNECTED_ITEM& aStartItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SELECTION_TOOL::selectAllItemsOnNet( int aNetCode )
|
void SELECTION_TOOL::selectAllItemsOnNet( int aNetCode, bool aSelect )
|
||||||
{
|
{
|
||||||
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
||||||
auto connectivity = board()->GetConnectivity();
|
auto connectivity = board()->GetConnectivity();
|
||||||
|
|
||||||
for( BOARD_CONNECTED_ITEM* item : connectivity->GetNetItems( aNetCode, types ) )
|
for( BOARD_CONNECTED_ITEM* item : connectivity->GetNetItems( aNetCode, types ) )
|
||||||
if( itemPassesFilter( item ) )
|
if( itemPassesFilter( item ) )
|
||||||
select( item );
|
aSelect ? select( item ) : unselect( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
// If we've been passed an argument, just select that netcode
|
bool select = aEvent.IsAction( &PCB_ACTIONS::selectNet );
|
||||||
|
|
||||||
|
// If we've been passed an argument, just select that netcode1
|
||||||
int netcode = aEvent.Parameter<intptr_t>();
|
int netcode = aEvent.Parameter<intptr_t>();
|
||||||
|
|
||||||
if( netcode > 0 )
|
if( netcode > 0 )
|
||||||
{
|
{
|
||||||
selectAllItemsOnNet( netcode );
|
selectAllItemsOnNet( netcode, select );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1102,7 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
||||||
BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( i );
|
BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( i );
|
||||||
|
|
||||||
if( connItem )
|
if( connItem )
|
||||||
selectAllItemsOnNet( connItem->GetNetCode() );
|
selectAllItemsOnNet( connItem->GetNetCode(), select );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform other potentially interested tools
|
// Inform other potentially interested tools
|
||||||
|
@ -2600,6 +2603,7 @@ void SELECTION_TOOL::setTransitions()
|
||||||
Go( &SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() );
|
Go( &SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::expandConnection, PCB_ACTIONS::selectConnection.MakeEvent() );
|
Go( &SELECTION_TOOL::expandConnection, PCB_ACTIONS::selectConnection.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
|
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::selectNet.MakeEvent() );
|
||||||
|
Go( &SELECTION_TOOL::selectNet, PCB_ACTIONS::deselectNet.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() );
|
Go( &SELECTION_TOOL::selectSameSheet, PCB_ACTIONS::selectSameSheet.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::selectSheetContents, PCB_ACTIONS::selectOnSheetFromEeschema.MakeEvent() );
|
Go( &SELECTION_TOOL::selectSheetContents, PCB_ACTIONS::selectOnSheetFromEeschema.MakeEvent() );
|
||||||
Go( &SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsModified );
|
Go( &SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsModified );
|
||||||
|
|
|
@ -278,8 +278,10 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects all items with the given net code
|
* Selects all items with the given net code
|
||||||
|
* @param aNetCode is the target net to select
|
||||||
|
* @param aSelect is true to add the items to the selection, false to remove them (deselect)
|
||||||
*/
|
*/
|
||||||
void selectAllItemsOnNet( int aNetCode );
|
void selectAllItemsOnNet( int aNetCode, bool aSelect = true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects all items with the given sheet timestamp/UUID name
|
* Selects all items with the given sheet timestamp/UUID name
|
||||||
|
|
|
@ -812,6 +812,9 @@ void APPEARANCE_CONTROLS::OnNetGridRightClick( wxGridEvent& event )
|
||||||
menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
|
menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
|
||||||
wxString::Format( _( "Select tracks and vias in %s" ), netName ),
|
wxString::Format( _( "Select tracks and vias in %s" ), netName ),
|
||||||
wxEmptyString, wxITEM_NORMAL ) );
|
wxEmptyString, wxITEM_NORMAL ) );
|
||||||
|
menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
|
||||||
|
wxString::Format( _( "Deselect tracks and vias in %s" ), netName ),
|
||||||
|
wxEmptyString, wxITEM_NORMAL ) );
|
||||||
|
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
|
|
||||||
|
@ -1947,6 +1950,10 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
wxString::Format( _( "Select tracks and vias in %s" ),
|
wxString::Format( _( "Select tracks and vias in %s" ),
|
||||||
name ),
|
name ),
|
||||||
wxEmptyString, wxITEM_NORMAL ) );
|
wxEmptyString, wxITEM_NORMAL ) );
|
||||||
|
menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
|
||||||
|
wxString::Format( _( "Deselect tracks and vias in %s" ),
|
||||||
|
name ),
|
||||||
|
wxEmptyString, wxITEM_NORMAL ) );
|
||||||
|
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
|
|
||||||
|
@ -2277,6 +2284,13 @@ void APPEARANCE_CONTROLS::onNetContextMenu( wxCommandEvent& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ID_DESELECT_NET:
|
||||||
|
{
|
||||||
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::deselectNet, true, net.code );
|
||||||
|
m_frame->GetCanvas()->Refresh();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ID_SHOW_ALL_NETS:
|
case ID_SHOW_ALL_NETS:
|
||||||
m_netsTable->ShowAllNets();
|
m_netsTable->ShowAllNets();
|
||||||
break;
|
break;
|
||||||
|
@ -2504,9 +2518,12 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
case ID_SELECT_NET:
|
case ID_SELECT_NET:
|
||||||
|
case ID_DESELECT_NET:
|
||||||
{
|
{
|
||||||
if( netclass )
|
if( netclass )
|
||||||
{
|
{
|
||||||
|
TOOL_ACTION& action = aEvent.GetId() == ID_SELECT_NET ? PCB_ACTIONS::selectNet :
|
||||||
|
PCB_ACTIONS::deselectNet;
|
||||||
runOnNetsOfClass( netclass,
|
runOnNetsOfClass( netclass,
|
||||||
[&]( NETINFO_ITEM* aItem )
|
[&]( NETINFO_ITEM* aItem )
|
||||||
{
|
{
|
||||||
|
@ -2514,8 +2531,7 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int code = aItem->GetNet();
|
int code = aItem->GetNet();
|
||||||
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectNet, true,
|
m_frame->GetToolManager()->RunAction( action, true, code );
|
||||||
code );
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -366,6 +366,7 @@ private:
|
||||||
ID_HIDE_OTHER_NETS,
|
ID_HIDE_OTHER_NETS,
|
||||||
ID_HIGHLIGHT_NET,
|
ID_HIGHLIGHT_NET,
|
||||||
ID_SELECT_NET,
|
ID_SELECT_NET,
|
||||||
|
ID_DESELECT_NET,
|
||||||
ID_SHOW_ALL_COPPER_LAYERS,
|
ID_SHOW_ALL_COPPER_LAYERS,
|
||||||
ID_HIDE_ALL_COPPER_LAYERS,
|
ID_HIDE_ALL_COPPER_LAYERS,
|
||||||
ID_HIDE_ALL_BUT_ACTIVE,
|
ID_HIDE_ALL_BUT_ACTIVE,
|
||||||
|
|
Loading…
Reference in New Issue