diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index e04ca8143f..c0ac1f8119 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -3020,3 +3020,38 @@ void BOARD::ClearAllNetCodes() for( auto track : Tracks() ) track->SetNetCode( 0 ); } + +const std::vector BOARD::AllConnectedItems() +{ + std::vector items; + + for( auto track : Tracks() ) + { + items.push_back( track ); + } + + for( auto mod : Modules() ) + { + for( auto pad : mod->Pads() ) + { + items.push_back( pad ); + } + } + + for( int i = 0; iGetNetCode() ) == nullptr ) + item->SetNetCode( NETINFO_LIST::ORPHANED ); + } +} diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index a8a585157c..7074abf497 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -254,7 +254,7 @@ public: DLIST_ITERATOR_WRAPPER Modules() { return DLIST_ITERATOR_WRAPPER(m_Modules); } DLIST_ITERATOR_WRAPPER Drawings() { return DLIST_ITERATOR_WRAPPER(m_Drawings); } ZONE_CONTAINERS& Zones() { return m_ZoneDescriptorList; } - + const std::vector AllConnectedItems(); // will be deprecated as soon as append board functionality is fixed DLIST& DrawingsList() { return m_Drawings; } @@ -1358,6 +1358,8 @@ public: * Resets all items' netcodes to 0 (no net). */ void ClearAllNetCodes(); + + void SanitizeNetcodes(); }; #endif // CLASS_BOARD_H_ diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 46f63f88dc..06930609cb 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -581,13 +581,15 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool if( not_found ) wxMessageBox( wxT( "Incomplete undo/redo operation: some items not found" ) ); - + // Rebuild pointers and connectivity that can be changed. // connectivity can be rebuilt only in the board editor frame if( IsType( FRAME_PCB ) && ( reBuild_ratsnest || deep_reBuild_ratsnest ) ) { Compile_Ratsnest( NULL, false ); } + + GetBoard()->SanitizeNetcodes(); }