Remove unused nets when updating PCB.
Fixes https://gitlab.com/kicad/code/kicad/issues/4247
This commit is contained in:
parent
940570e9ec
commit
efc3f8c29d
|
@ -164,7 +164,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
board->Add( boardItem ); // handles connectivity
|
||||
}
|
||||
|
||||
if( boardItem->Type() != PCB_NETINFO_T )
|
||||
view->Add( boardItem );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -240,6 +242,12 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
}
|
||||
break;
|
||||
|
||||
// Metadata items
|
||||
case PCB_NETINFO_T:
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
board->Remove( boardItem );
|
||||
break;
|
||||
|
||||
default: // other types do not need to (or should not) be handled
|
||||
wxASSERT( false );
|
||||
break;
|
||||
|
|
|
@ -460,6 +460,8 @@ public:
|
|||
* Removes a new from the net list.
|
||||
*/
|
||||
void RemoveNet( NETINFO_ITEM* aNet );
|
||||
void RemoveUnusedNets();
|
||||
|
||||
/**
|
||||
* Function GetPadCount
|
||||
* @return the number of pads in board
|
||||
|
|
|
@ -108,6 +108,24 @@ void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
|||
}
|
||||
|
||||
|
||||
void NETINFO_LIST::RemoveUnusedNets()
|
||||
{
|
||||
NETCODES_MAP existingNets = m_netCodes;
|
||||
|
||||
m_netCodes.clear();
|
||||
m_netNames.clear();
|
||||
|
||||
for( std::pair<const int, NETINFO_ITEM*> item : existingNets )
|
||||
{
|
||||
if( item.second->IsCurrent() )
|
||||
{
|
||||
m_netNames.insert( std::make_pair( item.second->GetNetname(), item.second ) );
|
||||
m_netCodes.insert( std::make_pair( item.first, item.second ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
||||
{
|
||||
// if there is a net with such name then just assign the correct number
|
||||
|
|
|
@ -827,13 +827,25 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
|
||||
if( !m_isDryRun )
|
||||
{
|
||||
m_commit.Push( _( "Update netlist" ) );
|
||||
m_board->GetConnectivity()->Build( m_board );
|
||||
testConnectivity( aNetlist );
|
||||
|
||||
// Now the connectivity data is rebuilt, we can delete single pads nets
|
||||
if( m_deleteSinglePadNets )
|
||||
deleteSinglePadNets();
|
||||
|
||||
for( NETINFO_ITEM* net : m_board->GetNetInfo() )
|
||||
{
|
||||
if( !net->IsCurrent() )
|
||||
{
|
||||
msg.Printf( _( "Remove unused net \"%s\"." ), net->GetNetname() );
|
||||
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
|
||||
m_commit.Removed( net );
|
||||
}
|
||||
}
|
||||
|
||||
m_board->GetNetInfo().RemoveUnusedNets();
|
||||
m_commit.Push( _( "Update netlist" ) );
|
||||
}
|
||||
else if( m_deleteSinglePadNets && !m_newFootprintsCount )
|
||||
// We can delete single net pads in dry run mode only if no new footprints
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
#include <functional>
|
||||
using namespace std::placeholders;
|
||||
#include <fctsys.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <macros.h>
|
||||
#include <pcbnew.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <class_board.h>
|
||||
#include <class_track.h>
|
||||
|
@ -39,8 +37,6 @@ using namespace std::placeholders;
|
|||
#include <class_pcb_target.h>
|
||||
#include <class_module.h>
|
||||
#include <class_dimension.h>
|
||||
#include <class_zone.h>
|
||||
#include <class_edge_mod.h>
|
||||
#include <origin_viewitem.h>
|
||||
#include <connectivity/connectivity_data.h>
|
||||
#include <pcbnew_settings.h>
|
||||
|
@ -49,7 +45,6 @@ using namespace std::placeholders;
|
|||
#include <tools/selection_tool.h>
|
||||
#include <tools/pcbnew_control.h>
|
||||
#include <tools/pcb_editor_control.h>
|
||||
#include <view/view.h>
|
||||
#include <ws_proxy_undo_item.h>
|
||||
|
||||
/* Functions to undo and redo edit commands.
|
||||
|
@ -483,13 +478,19 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
|||
case UR_NEW: /* new items are deleted */
|
||||
aList->SetPickedItemStatus( UR_DELETED, ii );
|
||||
GetModel()->Remove( (BOARD_ITEM*) eda_item );
|
||||
|
||||
if( eda_item->Type() != PCB_NETINFO_T )
|
||||
view->Remove( eda_item );
|
||||
|
||||
break;
|
||||
|
||||
case UR_DELETED: /* deleted items are put in List, as new items */
|
||||
aList->SetPickedItemStatus( UR_NEW, ii );
|
||||
GetModel()->Add( (BOARD_ITEM*) eda_item );
|
||||
|
||||
if( eda_item->Type() != PCB_NETINFO_T )
|
||||
view->Add( eda_item );
|
||||
|
||||
break;
|
||||
|
||||
case UR_MOVED:
|
||||
|
|
Loading…
Reference in New Issue