Moving modules from DLIST to std::deque

This commit is contained in:
Seth Hillbrand 2019-05-30 17:15:57 -07:00
parent 961b22d603
commit d1877d7c1b
58 changed files with 292 additions and 274 deletions

View File

@ -488,7 +488,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// Add holes of modules // Add holes of modules
// ///////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////
for( const MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
const D_PAD* pad = module->PadsList(); const D_PAD* pad = module->PadsList();
@ -522,7 +522,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// Add contours of the pad holes (pads can be Circle or Segment holes) // Add contours of the pad holes (pads can be Circle or Segment holes)
// ///////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////
for( const MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
const D_PAD* pad = module->PadsList(); const D_PAD* pad = module->PadsList();
@ -566,7 +566,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id]; CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
// ADD PADS // ADD PADS
for( const MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
// Note: NPTH pads are not drawn on copper layers when the pad // Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole // has same shape as its hole
@ -603,7 +603,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id]; SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
// ADD PADS // ADD PADS
for( const MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
// Construct polys // Construct polys
// ///////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////
@ -993,7 +993,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// Add modules tech layers - objects // Add modules tech layers - objects
// ///////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) ) if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
{ {
@ -1020,7 +1020,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// Add modules tech layers - contours // Add modules tech layers - contours
// ///////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) ) if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
{ {

View File

@ -800,9 +800,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
tht_inner_holes_poly.RemoveAllContours(); tht_inner_holes_poly.RemoveAllContours();
// Insert pads holes (vertical cylinders) // Insert pads holes (vertical cylinders)
for( const MODULE* module = m_settings.GetBoard()->m_Modules; for( const auto module : m_settings.GetBoard()->Modules() )
module;
module = module->Next() )
{ {
for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{ {
@ -907,8 +905,7 @@ void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter )
return; return;
// Go for all modules // Go for all modules
for( const MODULE* module = m_settings.GetBoard()->m_Modules; for( auto module : m_settings.GetBoard()->Modules() )
module; module = module->Next() )
{ {
if( !module->Models().empty() ) if( !module->Models().empty() )
{ {

View File

@ -980,18 +980,13 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot,
bool aRenderTransparentOnly ) bool aRenderTransparentOnly )
{ {
// Go for all modules // Go for all modules
if( m_settings.GetBoard()->m_Modules.GetCount() ) for( auto module : m_settings.GetBoard()->Modules() )
{ {
for( const MODULE* module = m_settings.GetBoard()->m_Modules; if( !module->Models().empty() )
module; if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T) module->GetAttributes() ) )
module = module->Next() ) if( ( aRenderTopOrBot && !module->IsFlipped() )
{ || ( !aRenderTopOrBot && module->IsFlipped() ) )
if( !module->Models().empty() ) render_3D_module( module, aRenderTransparentOnly );
if( m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) )
if( ( aRenderTopOrBot && !module->IsFlipped()) ||
(!aRenderTopOrBot && module->IsFlipped()) )
render_3D_module( module, aRenderTransparentOnly );
}
} }
} }

View File

@ -1183,9 +1183,7 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container()
} }
// Insert pads holes (vertical cylinders) // Insert pads holes (vertical cylinders)
for( const MODULE* module = m_settings.GetBoard()->m_Modules; for( auto module : m_settings.GetBoard()->Modules() )
module;
module = module->Next() )
{ {
for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED ) if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
@ -1199,9 +1197,7 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container()
void C3D_RENDER_RAYTRACING::load_3D_models() void C3D_RENDER_RAYTRACING::load_3D_models()
{ {
// Go for all modules // Go for all modules
for( const MODULE* module = m_settings.GetBoard()->m_Modules; for( auto module : m_settings.GetBoard()->Modules() )
module;
module = module->Next() )
{ {
if( (!module->Models().empty() ) && if( (!module->Models().empty() ) &&
m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) ) m_settings.ShouldModuleBeDisplayed( (MODULE_ATTR_T)module->GetAttributes() ) )

View File

@ -413,8 +413,10 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
MODULE* module = nullptr; MODULE* module = nullptr;
const FOOTPRINT_INFO* module_info = nullptr; const FOOTPRINT_INFO* module_info = nullptr;
if( GetBoard()->m_Modules.GetCount() ) for( auto it = GetBoard()->Modules().begin(); it != GetBoard()->Modules().end(); it++ )
GetBoard()->m_Modules.DeleteAll(); delete *it;
GetBoard()->Modules().clear();
wxString footprintName = parentframe->GetSelectedFootprint(); wxString footprintName = parentframe->GetSelectedFootprint();
@ -436,7 +438,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
} }
if( module ) if( module )
GetBoard()->m_Modules.PushBack( module ); GetBoard()->Modules().push_back( module );
if( module_info ) if( module_info )
SetStatusText( wxString::Format( _( "Lib: %s" ), module_info->GetLibNickname() ), 0 ); SetStatusText( wxString::Format( _( "Lib: %s" ), module_info->GetLibNickname() ), 0 );
@ -471,7 +473,7 @@ void DISPLAY_FOOTPRINTS_FRAME::updateView()
void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel() void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
{ {
MODULE* footprint = GetBoard()->m_Modules; MODULE* footprint = GetBoard()->GetFirstModule();
MSG_PANEL_ITEMS items; MSG_PANEL_ITEMS items;
if( footprint ) if( footprint )
@ -515,7 +517,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SyncMenusAndToolbars()
*/ */
void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
{ {
if( m_Modules ) if( !m_modules.empty() )
m_Modules->Print( aFrame, aDC ); {
GetFirstModule()->Print( aFrame, aDC );
}
} }

View File

@ -129,10 +129,10 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
// modules inside modules are not supported yet // modules inside modules are not supported yet
wxASSERT( boardItem->Type() != PCB_MODULE_T ); wxASSERT( boardItem->Type() != PCB_MODULE_T );
boardItem->SetParent( board->m_Modules.GetFirst() ); boardItem->SetParent( board->Modules().front() );
if( !( changeFlags & CHT_DONE ) ) if( !( changeFlags & CHT_DONE ) )
board->m_Modules->Add( boardItem ); board->Modules().front()->Add( boardItem );
} }
view->Add( boardItem ); view->Add( boardItem );

View File

@ -83,7 +83,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_
} }
// convert pads // convert pads
for( MODULE* module = m_Modules; module != NULL; module = module->Next() ) for( auto module : m_modules )
{ {
module->TransformPadsShapesWithClearanceToPolygon( aLayer, aOutlines, 0 ); module->TransformPadsShapesWithClearanceToPolygon( aLayer, aOutlines, 0 );

View File

@ -530,12 +530,10 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist ) bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
{ {
wxString msg; wxString msg;
MODULE* nextModule;
const COMPONENT* component; const COMPONENT* component;
for( MODULE* module = m_board->m_Modules; module != NULL; module = nextModule ) for( auto module : m_board->Modules() )
{ {
nextModule = module->Next();
if( m_lookupByTimestamp ) if( m_lookupByTimestamp )
component = aNetlist.GetComponentByTimeStamp( module->GetPath() ); component = aNetlist.GetComponentByTimeStamp( module->GetPath() );
@ -691,7 +689,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
m_errorCount = 0; m_errorCount = 0;
m_warningCount = 0; m_warningCount = 0;
m_newFootprintsCount = 0; m_newFootprintsCount = 0;
MODULE* lastPreexistingFootprint = m_board->m_Modules.GetLast(); MODULE* lastPreexistingFootprint = m_board->Modules().back();
cacheCopperZoneConnections(); cacheCopperZoneConnections();
@ -717,7 +715,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
component->GetFPID().Format().wx_str() ); component->GetFPID().Format().wx_str() );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
for( MODULE* footprint = m_board->m_Modules; footprint; footprint = footprint->Next() ) for( auto footprint : m_board->Modules() )
{ {
bool match = false; bool match = false;

View File

@ -77,10 +77,9 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
{ {
wxFileName fn; wxFileName fn;
FILE* fp_bom; FILE* fp_bom;
MODULE* module = GetBoard()->m_Modules;
wxString msg; wxString msg;
if( module == NULL ) if( GetBoard()->Modules().empty() )
{ {
DisplayError( this, _( "Cannot export BOM: there are no footprints in the PCB" ) ); DisplayError( this, _( "Cannot export BOM: there are no footprints in the PCB" ) );
return; return;
@ -126,7 +125,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
CmpList::iterator iter; CmpList::iterator iter;
int i = 1; int i = 1;
while( module != NULL ) for( auto module : GetBoard()->Modules() )
{ {
bool valExist = false; bool valExist = false;
@ -157,9 +156,6 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
comp->m_CmpCount = 1; comp->m_CmpCount = 1;
list.Append( comp ); list.Append( comp );
} }
// increment module
module = module->Next();
} }
// Print list. Also delete temporary created objects. // Print list. Also delete temporary created objects.

View File

@ -902,9 +902,9 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
case PCB_MODULE_T: case PCB_MODULE_T:
if( aMode == ADD_APPEND ) if( aMode == ADD_APPEND )
m_Modules.PushBack( (MODULE*) aBoardItem ); m_modules.push_back( (MODULE*) aBoardItem );
else else
m_Modules.PushFront( (MODULE*) aBoardItem ); m_modules.push_front( (MODULE*) aBoardItem );
break; break;
@ -977,7 +977,8 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem )
break; break;
case PCB_MODULE_T: case PCB_MODULE_T:
m_Modules.Remove( (MODULE*) aBoardItem ); m_modules.erase( std::remove_if( m_modules.begin(), m_modules.end(),
[aBoardItem]( BOARD_ITEM* aItem ) { return aItem == aBoardItem; } ) );
break; break;
case PCB_TRACE_T: case PCB_TRACE_T:
@ -1123,7 +1124,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
if( !aBoardEdgesOnly ) if( !aBoardEdgesOnly )
{ {
// Check modules // Check modules
for( MODULE* module = m_Modules; module; module = module->Next() ) for( auto module : m_modules )
{ {
if( !( module->GetLayerSet() & visible ).any() ) if( !( module->GetLayerSet() & visible ).any() )
continue; continue;
@ -1240,7 +1241,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
// this calls MODULE::Visit() on each module. // this calls MODULE::Visit() on each module.
result = IterateForward( m_Modules, inspector, testData, p ); result = IterateForward<MODULE*>( m_modules, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
for( ; ; ) for( ; ; )
@ -1434,7 +1435,7 @@ MODULE* BOARD::FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeSt
{ {
if( aSearchByTimeStamp ) if( aSearchByTimeStamp )
{ {
for( MODULE* module = m_Modules; module; module = module->Next() ) for( auto module : m_modules )
{ {
if( aRefOrTimeStamp.CmpNoCase( module->GetPath() ) == 0 ) if( aRefOrTimeStamp.CmpNoCase( module->GetPath() ) == 0 )
return module; return module;
@ -1605,7 +1606,7 @@ D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet )
if( !aLayerSet.any() ) if( !aLayerSet.any() )
aLayerSet = LSET::AllCuMask(); aLayerSet = LSET::AllCuMask();
for( MODULE* module = m_Modules; module; module = module->Next() ) for( auto module : m_modules )
{ {
D_PAD* pad = NULL; D_PAD* pad = NULL;
@ -2137,14 +2138,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrackList, TRACK* aTrace, int* aCount,
MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer, MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked ) bool aVisibleOnly, bool aIgnoreLocked )
{ {
MODULE* pt_module;
MODULE* module = NULL; MODULE* module = NULL;
MODULE* alt_module = NULL; MODULE* alt_module = NULL;
int min_dim = 0x7FFFFFFF; int min_dim = 0x7FFFFFFF;
int alt_min_dim = 0x7FFFFFFF; int alt_min_dim = 0x7FFFFFFF;
bool current_layer_back = IsBackLayer( aActiveLayer ); bool current_layer_back = IsBackLayer( aActiveLayer );
for( pt_module = m_Modules; pt_module; pt_module = pt_module->Next() ) for( auto pt_module : m_modules )
{ {
// is the ref point within the module's bounds? // is the ref point within the module's bounds?
if( !pt_module->HitTest( aPosition ) ) if( !pt_module->HitTest( aPosition ) )
@ -2205,7 +2205,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LSET aLayerSet ) BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LSET aLayerSet )
{ {
for( MODULE* module = m_Modules; module; module = module->Next() ) for( auto module : m_modules )
{ {
D_PAD* pad = module->GetPad( aPosition, aLayerSet ); D_PAD* pad = module->GetPad( aPosition, aLayerSet );
@ -2497,9 +2497,9 @@ D_PAD* BOARD::GetPad( unsigned aIndex ) const
{ {
unsigned count = 0; unsigned count = 0;
for( MODULE* mod = m_Modules; mod ; mod = mod->Next() ) // FIXME: const DLIST_ITERATOR for( auto mod : m_modules )
{ {
for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() ) for( auto pad : mod->Pads() )
{ {
if( count == aIndex ) if( count == aIndex )
return pad; return pad;

View File

@ -34,17 +34,18 @@
#include <dlist.h> #include <dlist.h>
#include <core/iterators.h> #include <core/iterators.h>
#include <common.h> // PAGE_INFO #include <board_design_settings.h>
#include <layers_id_colors_and_visibility.h> #include <board_item_container.h>
#include <netinfo.h> #include <class_module.h>
#include <class_pad.h> #include <class_pad.h>
#include <colors_design_settings.h> #include <colors_design_settings.h>
#include <board_design_settings.h> #include <common.h> // PAGE_INFO
#include <eda_rect.h>
#include <layers_id_colors_and_visibility.h>
#include <netinfo.h>
#include <pcb_plot_params.h>
#include <title_block.h> #include <title_block.h>
#include <zone_settings.h> #include <zone_settings.h>
#include <pcb_plot_params.h>
#include <board_item_container.h>
#include <eda_rect.h>
#include <memory> #include <memory>
@ -158,10 +159,11 @@ protected:
}; };
DECL_VEC_FOR_SWIG(MARKERS, MARKER_PCB*) DECL_VEC_FOR_SWIG( MARKERS, MARKER_PCB* )
DECL_VEC_FOR_SWIG(ZONE_CONTAINERS, ZONE_CONTAINER*) DECL_VEC_FOR_SWIG( ZONE_CONTAINERS, ZONE_CONTAINER* )
DECL_VEC_FOR_SWIG(TRACKS, TRACK*) DECL_VEC_FOR_SWIG( TRACKS, TRACK* )
DECL_DEQ_FOR_SWIG(DRAWINGS, BOARD_ITEM*) DECL_DEQ_FOR_SWIG( DRAWINGS, BOARD_ITEM* )
DECL_DEQ_FOR_SWIG( MODULES, MODULE* )
/** /**
@ -182,6 +184,9 @@ private:
/// BOARD_ITEMs for drawings on the board, owned by pointer. /// BOARD_ITEMs for drawings on the board, owned by pointer.
DRAWINGS m_drawings; DRAWINGS m_drawings;
/// MODULES for components on the board, owned by pointer.
MODULES m_modules;
/// edge zone descriptors, owned by pointer. /// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList; ZONE_CONTAINERS m_ZoneDescriptorList;
@ -245,11 +250,17 @@ public:
public: public:
DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and VIAs DLIST<TRACK> m_Track; // linked list of TRACKs and VIAs
DLIST_ITERATOR_WRAPPER<TRACK> Tracks() { return DLIST_ITERATOR_WRAPPER<TRACK>(m_Track); } DLIST_ITERATOR_WRAPPER<TRACK> Tracks() { return DLIST_ITERATOR_WRAPPER<TRACK>(m_Track); }
DLIST_ITERATOR_WRAPPER<MODULE> Modules() { return DLIST_ITERATOR_WRAPPER<MODULE>(m_Modules); } MODULES& Modules()
{
return m_modules;
}
const MODULES& Modules() const
{
return m_modules;
}
DRAWINGS& Drawings() { return m_drawings; } DRAWINGS& Drawings() { return m_drawings; }
ZONE_CONTAINERS& Zones() { return m_ZoneDescriptorList; } ZONE_CONTAINERS& Zones() { return m_ZoneDescriptorList; }
const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems(); const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
@ -265,7 +276,7 @@ public:
bool IsEmpty() const bool IsEmpty() const
{ {
return m_drawings.empty() && m_Modules.GetCount() == 0 && m_Track.GetCount() == 0; return m_drawings.empty() && m_modules.empty() && m_Track.GetCount() == 0;
} }
void Move( const wxPoint& aMoveVector ) override; void Move( const wxPoint& aMoveVector ) override;
@ -277,6 +288,26 @@ public:
void Remove( BOARD_ITEM* aBoardItem ) override; void Remove( BOARD_ITEM* aBoardItem ) override;
/**
* Gets the first module in the list (used in footprint viewer/editor) or NULL if none
* @return first module or null pointer
*/
MODULE* GetFirstModule() const
{
return m_modules.empty() ? nullptr : m_modules.front();
}
/**
* Removes all modules from the deque and frees the memory associated with them
*/
void DeleteAllModules()
{
for( MODULE* mod : m_modules )
delete mod;
m_modules.clear();
}
BOARD_ITEM* GetItem( void* aWeakReference ); BOARD_ITEM* GetItem( void* aWeakReference );
BOARD_ITEM* Duplicate( const BOARD_ITEM* aItem, bool aAddToBoard = false ); BOARD_ITEM* Duplicate( const BOARD_ITEM* aItem, bool aAddToBoard = false );

View File

@ -119,9 +119,6 @@ public:
return aItem && PCB_MODULE_T == aItem->Type(); return aItem && PCB_MODULE_T == aItem->Type();
} }
MODULE* Next() const { return static_cast<MODULE*>( Pnext ); }
MODULE* Back() const { return static_cast<MODULE*>( Pback ); }
///> @copydoc BOARD_ITEM_CONTAINER::Add() ///> @copydoc BOARD_ITEM_CONTAINER::Add()
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_INSERT ) override; void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_INSERT ) override;

View File

@ -284,13 +284,11 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClicked( wxCommandEvent& event )
bool DIALOG_EXCHANGE_FOOTPRINTS::processMatchingModules() bool DIALOG_EXCHANGE_FOOTPRINTS::processMatchingModules()
{ {
MODULE* Module;
MODULE* PtBack;
bool change = false; bool change = false;
LIB_ID newFPID; LIB_ID newFPID;
wxString value; wxString value;
if( !m_parent->GetBoard()->m_Modules ) if( m_parent->GetBoard()->Modules().empty() )
return false; return false;
if( !m_updateMode ) if( !m_updateMode )
@ -303,26 +301,23 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processMatchingModules()
/* The change is done from the last module because processModule() modifies the last item /* The change is done from the last module because processModule() modifies the last item
* in the list. * in the list.
* Note: for the first module in chain (the last here), Module->Back() points to the board
* or is NULL.
*/ */
Module = m_parent->GetBoard()->m_Modules.GetLast(); for( auto it = m_parent->GetBoard()->Modules().rbegin();
it != m_parent->GetBoard()->Modules().rend(); it++ )
for( ; Module && Module->Type() == PCB_MODULE_T; Module = PtBack )
{ {
PtBack = Module->Back(); auto mod = *it;
if( !isMatch( Module ) ) if( !isMatch( mod ) )
continue; continue;
if( m_updateMode ) if( m_updateMode )
{ {
if( processModule( Module, Module->GetFPID()) ) if( processModule( mod, mod->GetFPID() ) )
change = true; change = true;
} }
else else
{ {
if( processModule( Module, newFPID ) ) if( processModule( mod, newFPID ) )
change = true; change = true;
} }
} }

View File

@ -99,7 +99,7 @@ void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
int count = 0; int count = 0;
for( MODULE* module = parent->GetBoard()->m_Modules; module; module = module->Next() ) for( auto module : parent->GetBoard()->Modules() )
{ {
if( WildCompareString( searchString, module->GetReference().GetData(), false ) ) if( WildCompareString( searchString, module->GetReference().GetData(), false ) )
{ {

View File

@ -153,7 +153,7 @@ void DIALOG_GENDRILL::InitDisplayParams()
m_microViasCount = 0; m_microViasCount = 0;
m_blindOrBuriedViasCount = 0; m_blindOrBuriedViasCount = 0;
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
for( D_PAD* pad = module->PadsList(); pad != NULL; pad = pad->Next() ) for( D_PAD* pad = module->PadsList(); pad != NULL; pad = pad->Next() )
{ {

View File

@ -110,7 +110,6 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
BOARD* pcb = m_Parent->GetBoard(); BOARD* pcb = m_Parent->GetBoard();
BOARD_COMMIT commit( m_Parent ); BOARD_COMMIT commit( m_Parent );
BOARD_ITEM* item;
LSET layers_filter = LSET().set(); LSET layers_filter = LSET().set();
@ -120,7 +119,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( delAll || m_DelZones->GetValue() ) if( delAll || m_DelZones->GetValue() )
{ {
int area_index = 0; int area_index = 0;
item = pcb->GetArea( area_index ); auto item = pcb->GetArea( area_index );
while( item ) while( item )
{ {
@ -170,7 +169,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
if( delAll || m_DelModules->GetValue() ) if( delAll || m_DelModules->GetValue() )
{ {
for( item = pcb->m_Modules; item; item = item->Next() ) for( auto item : pcb->Modules() )
{ {
bool del_fp = delAll; bool del_fp = delAll;

View File

@ -178,7 +178,7 @@ void DIALOG_NETLIST::OnUpdatePCB( wxCommandEvent& event )
void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event ) void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
{ {
if( m_parent->GetBoard()->m_Modules == nullptr ) if( m_parent->GetBoard()->GetFirstModule() == nullptr )
{ {
DisplayInfoMessage( this, _( "No footprints." ) ); DisplayInfoMessage( this, _( "No footprints." ) );
return; return;

View File

@ -1478,23 +1478,25 @@ void DRC::doFootprintOverlappingDrc()
void DRC::TestFootprints( NETLIST& aNetlist, BOARD* aPCB, EDA_UNITS_T aUnits, void DRC::TestFootprints( NETLIST& aNetlist, BOARD* aPCB, EDA_UNITS_T aUnits,
DRC_LIST& aDRCList ) DRC_LIST& aDRCList )
{ {
MODULE* module; auto mods = aPCB->Modules();
MODULE* nextModule;
std::sort( mods.begin(), mods.end(), []( const MODULE* a, const MODULE* b ) {
return a->GetReference().CmpNoCase( b->GetReference() );
} );
// Search for duplicate footprints. // Search for duplicate footprints.
for( module = aPCB->m_Modules; module != NULL; module = module->Next() ) for( auto it = mods.begin(); it != mods.end(); it++ )
{ {
nextModule = module->Next(); auto next_it = it + 1;
for( ; nextModule != NULL; nextModule = nextModule->Next() ) if( next_it == mods.end() )
break;
if( ( *it )->GetReference().CmpNoCase( ( *next_it )->GetReference() ) == 0 )
{ {
if( module->GetReference().CmpNoCase( nextModule->GetReference() ) == 0 ) aDRCList.emplace_back( new DRC_ITEM( aUnits, DRCE_DUPLICATE_FOOTPRINT, *it,
{ ( *it )->GetPosition(), *next_it, ( *next_it )->GetPosition() ) );
aDRCList.emplace_back( new DRC_ITEM( aUnits, DRCE_DUPLICATE_FOOTPRINT, break;
module, module->GetPosition(),
nextModule, nextModule->GetPosition() ) );
break;
}
} }
} }
@ -1503,7 +1505,7 @@ void DRC::TestFootprints( NETLIST& aNetlist, BOARD* aPCB, EDA_UNITS_T aUnits,
{ {
COMPONENT* component = aNetlist.GetComponent( ii ); COMPONENT* component = aNetlist.GetComponent( ii );
module = aPCB->FindModuleByReference( component->GetReference() ); auto module = aPCB->FindModuleByReference( component->GetReference() );
if( module == NULL ) if( module == NULL )
{ {
@ -1516,9 +1518,8 @@ void DRC::TestFootprints( NETLIST& aNetlist, BOARD* aPCB, EDA_UNITS_T aUnits,
} }
// Search for component footprints found on board but not in netlist. // Search for component footprints found on board but not in netlist.
for( module = aPCB->m_Modules; module != NULL; module = module->Next() ) for( auto module : mods )
{ {
COMPONENT* component = aNetlist.GetComponentByReference( module->GetReference() ); COMPONENT* component = aNetlist.GetComponentByReference( module->GetReference() );
if( component == NULL ) if( component == NULL )

View File

@ -65,7 +65,7 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const
const DRC_MARKER_FACTORY& marker_factory = GetMarkerFactory(); const DRC_MARKER_FACTORY& marker_factory = GetMarkerFactory();
// Update courtyard polygons, and test for missing courtyard definition: // Update courtyard polygons, and test for missing courtyard definition:
for( MODULE* footprint = aBoard.m_Modules; footprint; footprint = footprint->Next() ) for( auto footprint : aBoard.Modules() )
{ {
wxPoint pos = footprint->GetPosition(); wxPoint pos = footprint->GetPosition();
bool is_ok = footprint->BuildPolyCourtyard(); bool is_ok = footprint->BuildPolyCourtyard();
@ -99,13 +99,17 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const
// Now test for overlapping on top layer: // Now test for overlapping on top layer:
SHAPE_POLY_SET courtyard; // temporary storage of the courtyard of current footprint SHAPE_POLY_SET courtyard; // temporary storage of the courtyard of current footprint
for( MODULE* footprint = aBoard.m_Modules; footprint; footprint = footprint->Next() ) for( auto it1 = aBoard.Modules().begin(); it1 != aBoard.Modules().end(); it1++ )
{ {
auto footprint = *it1;
if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 ) if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 )
continue; // No courtyard defined continue; // No courtyard defined
for( MODULE* candidate = footprint->Next(); candidate; candidate = candidate->Next() ) for( auto it2 = it1 + 1; it2 != aBoard.Modules().end(); it2++ )
{ {
auto candidate = *it2;
if( candidate->GetPolyCourtyardFront().OutlineCount() == 0 ) if( candidate->GetPolyCourtyardFront().OutlineCount() == 0 )
continue; // No courtyard defined continue; // No courtyard defined
@ -132,13 +136,17 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const
} }
// Test for overlapping on bottom layer: // Test for overlapping on bottom layer:
for( MODULE* footprint = aBoard.m_Modules; footprint; footprint = footprint->Next() ) for( auto it1 = aBoard.Modules().begin(); it1 != aBoard.Modules().end(); it1++ )
{ {
auto footprint = *it1;
if( footprint->GetPolyCourtyardBack().OutlineCount() == 0 ) if( footprint->GetPolyCourtyardBack().OutlineCount() == 0 )
continue; // No courtyard defined continue; // No courtyard defined
for( MODULE* candidate = footprint->Next(); candidate; candidate = candidate->Next() ) for( auto it2 = it1 + 1; it2 != aBoard.Modules().end(); it2++ )
{ {
auto candidate = *it2;
if( candidate->GetPolyCourtyardBack().OutlineCount() == 0 ) if( candidate->GetPolyCourtyardBack().OutlineCount() == 0 )
continue; // No courtyard defined continue; // No courtyard defined

View File

@ -114,8 +114,7 @@ static void build_pad_testpoints( BOARD *aPcb,
{ {
wxPoint origin = aPcb->GetAuxOrigin(); wxPoint origin = aPcb->GetAuxOrigin();
for( MODULE* module = aPcb->m_Modules; for( auto module : aPcb->Modules() )
module; module = module->Next() )
{ {
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{ {

View File

@ -40,7 +40,7 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) ); fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
for( MODULE* module = aBrd->m_Modules; module != NULL; module = module->Next() ) for( auto module : aBrd->Modules() )
{ {
fprintf( cmpFile, "\nBeginCmp\n" ); fprintf( cmpFile, "\nBeginCmp\n" );
fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() ); fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );

View File

@ -311,9 +311,8 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
* these changes will be undone later * these changes will be undone later
*/ */
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
MODULE* module;
for( module = pcb->m_Modules; module; module = module->Next() ) for( auto module : pcb->Modules() )
{ {
module->SetFlag( 0 ); module->SetFlag( 0 );
@ -349,7 +348,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
fclose( file ); fclose( file );
// Undo the footprints modifications (flipped footprints) // Undo the footprints modifications (flipped footprints)
for( module = pcb->m_Modules; module; module = module->Next() ) for( auto module : pcb->Modules() )
{ {
if( module->GetFlag() ) if( module->GetFlag() )
{ {
@ -732,7 +731,6 @@ static size_t hashModule( const MODULE* aModule )
*/ */
static void CreateShapesSection( FILE* aFile, BOARD* aPcb ) static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
{ {
MODULE* module;
D_PAD* pad; D_PAD* pad;
const char* layer; const char* layer;
wxString pinname; wxString pinname;
@ -741,7 +739,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
fputs( "$SHAPES\n", aFile ); fputs( "$SHAPES\n", aFile );
for( module = aPcb->m_Modules; module; module = module->Next() ) for( auto module : aPcb->Modules() )
{ {
if( !individualShapes ) if( !individualShapes )
{ {
@ -854,7 +852,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
int cu_count = aPcb->GetCopperLayerCount(); int cu_count = aPcb->GetCopperLayerCount();
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) for( auto module : aPcb->Modules() )
{ {
const char* mirror; const char* mirror;
const char* flip; const char* flip;
@ -929,7 +927,6 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
wxString msg; wxString msg;
NETINFO_ITEM* net; NETINFO_ITEM* net;
D_PAD* pad; D_PAD* pad;
MODULE* module;
int NbNoConn = 1; int NbNoConn = 1;
fputs( "$SIGNALS\n", aFile ); fputs( "$SIGNALS\n", aFile );
@ -951,7 +948,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
fputs( "\n", aFile ); fputs( "\n", aFile );
for( module = aPcb->m_Modules; module; module = module->Next() ) for( auto module : aPcb->Modules() )
{ {
for( pad = module->PadsList(); pad; pad = pad->Next() ) for( pad = module->PadsList(); pad; pad = pad->Next() )
{ {

View File

@ -596,7 +596,7 @@ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName,
idf_export_outline( aPcb, idfBoard ); idf_export_outline( aPcb, idfBoard );
// Output the drill holes and module (library) data. // Output the drill holes and module (library) data.
for( MODULE* module = aPcb->m_Modules; module != 0; module = module->Next() ) for( auto module : aPcb->Modules() )
idf_export_module( aPcb, module, idfBoard ); idf_export_module( aPcb, module, idfBoard );
if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) ) if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) )

View File

@ -1622,7 +1622,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
output_file << " children [\n"; output_file << " children [\n";
// Export footprints // Export footprints
for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() ) for( auto module : pcb->Modules() )
export_vrml_module( model3d, pcb, module, &output_file ); export_vrml_module( model3d, pcb, module, &output_file );
// write out the board and all layers // write out the board and all layers
@ -1636,7 +1636,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
else else
{ {
// Export footprints // Export footprints
for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() ) for( auto module : pcb->Modules() )
export_vrml_module( model3d, pcb, module, NULL ); export_vrml_module( model3d, pcb, module, NULL );
// write out the board and all layers // write out the board and all layers

View File

@ -431,8 +431,6 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
bool aForceSmdItems, int aSide, bool aForceSmdItems, int aSide,
bool aFormatCSV ) bool aFormatCSV )
{ {
MODULE* footprint;
// Minimal text lengths: // Minimal text lengths:
int lenRefText = 8; int lenRefText = 8;
int lenValText = 8; int lenValText = 8;
@ -451,7 +449,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
std::vector<LIST_MOD> list; std::vector<LIST_MOD> list;
list.reserve( footprintCount ); list.reserve( footprintCount );
for( footprint = GetBoard()->m_Modules; footprint; footprint = footprint->Next() ) for( auto footprint : GetBoard()->Modules() )
{ {
if( aSide != PCB_BOTH_SIDES ) if( aSide != PCB_BOTH_SIDES )
{ {
@ -696,7 +694,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fputs( "$EndBOARD\n\n", rptfile ); fputs( "$EndBOARD\n\n", rptfile );
for( MODULE* Module = GetBoard()->m_Modules; Module; Module = Module->Next() ) for( auto Module : GetBoard()->Modules() )
{ {
fprintf( rptfile, "$MODULE %s\n", EscapedUTF8( Module->GetReference() ).c_str() ); fprintf( rptfile, "$MODULE %s\n", EscapedUTF8( Module->GetReference() ).c_str() );

View File

@ -115,7 +115,7 @@ void GENDRILL_WRITER_BASE::buildHolesList( DRILL_LAYER_PAIR aLayerPair,
if( aLayerPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) ) if( aLayerPair == DRILL_LAYER_PAIR( F_Cu, B_Cu ) )
{ {
// add holes for thru hole pads // add holes for thru hole pads
for( MODULE* module = m_pcb->m_Modules; module; module = module->Next() ) for( auto module : m_pcb->Modules() )
{ {
for( auto& pad : module->Pads() ) for( auto& pad : module->Pads() )
{ {

View File

@ -327,7 +327,7 @@ bool FOOTPRINT_EDIT_FRAME::IsSearchTreeShown()
BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
{ {
return GetBoard()->m_Modules; return GetBoard()->GetFirstModule();
} }
@ -345,7 +345,7 @@ LIB_ID FOOTPRINT_EDIT_FRAME::getTargetFPID() const
LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
{ {
MODULE* module = GetBoard()->m_Modules; MODULE* module = GetBoard()->GetFirstModule();
if( module ) if( module )
return LIB_ID( module->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded ); return LIB_ID( module->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
@ -356,7 +356,7 @@ LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
{ {
MODULE* module = GetBoard()->m_Modules; MODULE* module = GetBoard()->GetFirstModule();
return ( module && module->GetLink() > 0 ); return ( module && module->GetLink() > 0 );
} }
@ -498,10 +498,10 @@ double FOOTPRINT_EDIT_FRAME::BestZoom()
void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
if( GetScreen()->IsModify() && GetBoard()->m_Modules ) if( GetScreen()->IsModify() && GetBoard()->GetFirstModule() )
{ {
if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ), if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ),
[&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) ) [&]() -> bool { return SaveFootprint( GetBoard()->GetFirstModule() ); } ) )
{ {
Event.Veto(); Event.Veto();
return; return;
@ -531,7 +531,7 @@ void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ) void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
{ {
aEvent.Enable( GetBoard()->m_Modules != NULL ); aEvent.Enable( GetBoard()->GetFirstModule() != NULL );
if( aEvent.GetEventObject() == m_drawToolBar ) if( aEvent.GetEventObject() == m_drawToolBar )
aEvent.Check( GetToolId() == aEvent.GetId() ); aEvent.Check( GetToolId() == aEvent.GetId() );
@ -540,7 +540,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ) void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
{ {
aEvent.Enable( GetBoard()->m_Modules != NULL ); aEvent.Enable( GetBoard()->GetFirstModule() != NULL );
} }
@ -554,7 +554,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent
{ {
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
aEvent.Enable( frame && frame->GetBoard()->m_Modules != NULL ); aEvent.Enable( frame && frame->GetBoard()->GetFirstModule() != NULL );
} }
@ -562,23 +562,24 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent
{ {
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
MODULE* module_in_edit = GetBoard()->m_Modules; MODULE* module_in_edit = GetBoard()->GetFirstModule();
bool canInsert = frame && module_in_edit && !module_in_edit->GetLink(); bool canInsert = frame && module_in_edit && !module_in_edit->GetLink();
// If the source was deleted, the module can inserted but not updated in the board. // If the source was deleted, the module can inserted but not updated in the board.
if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module
{ {
BOARD* mainpcb = frame->GetBoard(); BOARD* mainpcb = frame->GetBoard();
MODULE* source_module = mainpcb->m_Modules; canInsert = true;
// search if the source module was not deleted: // search if the source module was not deleted:
for( ; source_module != NULL; source_module = source_module->Next() ) for( auto source_module : mainpcb->Modules() )
{ {
if( module_in_edit->GetLink() == source_module->GetTimeStamp() ) if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
{
canInsert = false;
break; break;
}
} }
canInsert = ( source_module == NULL );
} }
aEvent.Enable( canInsert ); aEvent.Enable( canInsert );
@ -658,8 +659,8 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
if( IsCurrentFPFromBoard() ) if( IsCurrentFPFromBoard() )
{ {
title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ), title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
GetBoard()->m_Modules->GetReference(), GetBoard()->GetFirstModule()->GetReference(), Prj().GetProjectName(),
Prj().GetProjectName(), PcbFileExtension ); PcbFileExtension );
} }
else if( fpid.IsValid() ) else if( fpid.IsValid() )
{ {
@ -674,15 +675,15 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
// Note: don't used GetLoadedFPID(); footprint name may have been edited // Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( " \u2014 %s %s" ), title += wxString::Format( wxT( " \u2014 %s %s" ),
FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ), FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().Format().c_str() ),
writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) ); writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
} }
else if( !fpid.GetLibItemName().empty() ) else if( !fpid.GetLibItemName().empty() )
{ {
// Note: don't used GetLoadedFPID(); footprint name may have been edited // Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( " \u2014 %s %s" ), title += wxString::Format( wxT( " \u2014 %s %s" ),
FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ), FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().GetLibItemName().c_str() ),
_( "[Unsaved]" ) ); _( "[Unsaved]" ) );
} }
SetTitle( title ); SetTitle( title );

View File

@ -89,14 +89,16 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
AddModuleToBoard( module ); AddModuleToBoard( module );
if( GetBoard()->m_Modules ) auto fp = GetBoard()->GetFirstModule();
if( fp )
{ {
GetBoard()->m_Modules->ClearFlags(); fp->ClearFlags();
// if either m_Reference or m_Value are gone, reinstall them - // if either m_Reference or m_Value are gone, reinstall them -
// otherwise you cannot see what you are doing on board // otherwise you cannot see what you are doing on board
TEXTE_MODULE* ref = &GetBoard()->m_Modules->Reference(); TEXTE_MODULE* ref = &fp->Reference();
TEXTE_MODULE* val = &GetBoard()->m_Modules->Value(); TEXTE_MODULE* val = &fp->Value();
if( val && ref ) if( val && ref )
{ {
@ -210,8 +212,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->BuildListOfNets(); GetBoard()->BuildListOfNets();
module->SetPosition( wxPoint( 0, 0 ) ); module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->m_Modules ) if( GetBoard()->GetFirstModule() )
GetBoard()->m_Modules->ClearFlags(); GetBoard()->GetFirstModule()->ClearFlags();
Zoom_Automatique( false ); Zoom_Automatique( false );
GetScreen()->SetModify(); GetScreen()->SetModify();
@ -240,8 +242,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() ) if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
{ {
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. Save changes?" ), if( !HandleUnsavedChanges( this,
[&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) ) _( "The current footprint has been modified. Save changes?" ),
[&]() -> bool {
return SaveFootprint( GetBoard()->GetFirstModule() );
} ) )
{ {
break; break;
} }
@ -299,9 +304,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_SAVE: case ID_MODEDIT_SAVE:
if( getTargetFPID() == GetLoadedFPID() ) if( getTargetFPID() == GetLoadedFPID() )
{ {
if( SaveFootprint( GetBoard()->m_Modules ) ) if( SaveFootprint( GetBoard()->GetFirstModule() ) )
{ {
m_toolManager->GetView()->Update( GetBoard()->m_Modules ); m_toolManager->GetView()->Update( GetBoard()->GetFirstModule() );
GetGalCanvas()->ForceRefresh(); GetGalCanvas()->ForceRefresh();
GetScreen()->ClrModify(); GetScreen()->ClrModify();
@ -324,12 +329,12 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
else if( getTargetFPID() == GetLoadedFPID() ) else if( getTargetFPID() == GetLoadedFPID() )
{ {
// Save Board Footprint As // Save Board Footprint As
MODULE* footprint = GetBoard()->m_Modules; MODULE* footprint = GetBoard()->GetFirstModule();
if( footprint && SaveFootprintAs( footprint ) ) if( footprint && SaveFootprintAs( footprint ) )
{ {
m_footprintNameWhenLoaded = footprint->GetFPID().GetLibItemName(); m_footprintNameWhenLoaded = footprint->GetFPID().GetLibItemName();
m_toolManager->GetView()->Update( GetBoard()->m_Modules ); m_toolManager->GetView()->Update( footprint );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
GetGalCanvas()->ForceRefresh(); GetGalCanvas()->ForceRefresh();
@ -359,7 +364,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
LIB_ID fpID = getTargetFPID(); LIB_ID fpID = getTargetFPID();
if( fpID == GetLoadedFPID() ) if( fpID == GetLoadedFPID() )
m_copiedModule.reset( new MODULE( *GetBoard()->m_Modules.GetFirst() ) ); m_copiedModule.reset( new MODULE( *GetBoard()->GetFirstModule() ) );
else else
m_copiedModule.reset( LoadFootprint( fpID ) ); m_copiedModule.reset( LoadFootprint( fpID ) );
@ -404,8 +409,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
Import_Module(); Import_Module();
if( GetBoard()->m_Modules ) if( GetBoard()->GetFirstModule() )
GetBoard()->m_Modules->ClearFlags(); GetBoard()->GetFirstModule()->ClearFlags();
GetScreen()->SetModify(); GetScreen()->SetModify();
Zoom_Automatique( false ); Zoom_Automatique( false );
@ -416,7 +421,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_EXPORT_PART: case ID_MODEDIT_EXPORT_PART:
if( getTargetFPID() == GetLoadedFPID() ) if( getTargetFPID() == GetLoadedFPID() )
Export_Module( GetBoard()->m_Modules ); Export_Module( GetBoard()->GetFirstModule() );
else else
Export_Module( LoadFootprint( getTargetFPID() ) ); Export_Module( LoadFootprint( getTargetFPID() ) );
break; break;
@ -453,9 +458,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_EDIT_MODULE_PROPERTIES: case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
if( GetBoard()->m_Modules ) if( GetBoard()->GetFirstModule() )
{ {
editFootprintProperties( GetBoard()->m_Modules ); editFootprintProperties( GetBoard()->GetFirstModule() );
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
} }
break; break;
@ -530,8 +535,8 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileS
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
Import_Module( aFileSet[0] ); Import_Module( aFileSet[0] );
if( GetBoard()->m_Modules ) if( GetBoard()->GetFirstModule() )
GetBoard()->m_Modules->ClearFlags(); GetBoard()->GetFirstModule()->ClearFlags();
GetScreen()->ClrModify(); GetScreen()->ClrModify();
Zoom_Automatique( false ); Zoom_Automatique( false );

View File

@ -634,7 +634,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aC
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName, void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName,
wxString* aLibPath ) wxString* aLibPath )
{ {
if( GetBoard()->m_Modules == NULL ) if( GetBoard()->GetFirstModule() == NULL )
{ {
DisplayInfoMessage( this, _( "No footprints to archive!" ) ); DisplayInfoMessage( this, _( "No footprints to archive!" ) );
return; return;
@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString&
{ {
FP_LIB_TABLE* tbl = prj.PcbFootprintLibs(); FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
for( MODULE* curr_fp = GetBoard()->m_Modules; curr_fp; curr_fp = curr_fp->Next() ) for( auto curr_fp : GetBoard()->Modules() )
{ {
if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards. if( !curr_fp->GetFPID().GetLibItemName().empty() ) // Can happen with old boards.
tbl->FootprintSave( nickname, curr_fp, false ); tbl->FootprintSave( nickname, curr_fp, false );
@ -684,7 +684,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString&
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP; IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
for( MODULE* curr_fp = GetBoard()->m_Modules; curr_fp; curr_fp = curr_fp->Next() ) for( auto curr_fp : GetBoard()->Modules() )
{ {
try try
{ {
@ -794,18 +794,21 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
BOARD* mainpcb = pcbframe->GetBoard(); BOARD* mainpcb = pcbframe->GetBoard();
MODULE* source_module = NULL; MODULE* source_module = NULL;
MODULE* module_in_edit = GetBoard()->m_Modules; MODULE* module_in_edit = GetBoard()->GetFirstModule();
// Search the old module (source) if exists // Search the old module (source) if exists
// Because this source could be deleted when editing the main board... // Because this source could be deleted when editing the main board...
if( module_in_edit->GetLink() ) // this is not a new module ... if( module_in_edit->GetLink() ) // this is not a new module ...
{ {
source_module = mainpcb->m_Modules; source_module = nullptr;
for( ; source_module != NULL; source_module = source_module->Next() ) for( auto mod : mainpcb->Modules() )
{ {
if( module_in_edit->GetLink() == source_module->GetTimeStamp() ) if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
{
source_module = mod;
break; break;
}
} }
} }

View File

@ -406,7 +406,8 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
// Delete the current footprint (MUST reset tools first) // Delete the current footprint (MUST reset tools first)
GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD ); GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
GetBoard()->m_Modules.DeleteAll();
GetBoard()->DeleteAllModules();
LIB_ID id; LIB_ID id;
id.SetLibNickname( getCurNickname() ); id.SetLibNickname( getCurNickname() );
@ -459,7 +460,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event )
Close( true ); Close( true );
} }
else if( GetBoard()->m_Modules ) else if( GetBoard()->GetFirstModule() )
{ {
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
@ -473,7 +474,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event )
BOARD_COMMIT commit( pcbframe ); BOARD_COMMIT commit( pcbframe );
// Create the "new" module // Create the "new" module
MODULE* newmodule = new MODULE( *GetBoard()->m_Modules ); MODULE* newmodule = new MODULE( *GetBoard()->GetFirstModule() );
newmodule->SetParent( pcbframe->GetBoard() ); newmodule->SetParent( pcbframe->GetBoard() );
newmodule->SetLink( 0 ); newmodule->SetLink( 0 );
@ -584,7 +585,7 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent ) void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
{ {
aEvent.Enable( GetBoard()->m_Modules != nullptr ); aEvent.Enable( GetBoard()->GetFirstModule() != nullptr );
} }
@ -765,7 +766,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
setCurFootprintName( m_footprintList->GetString( (unsigned) selection ) ); setCurFootprintName( m_footprintList->GetString( (unsigned) selection ) );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->DeleteAllModules();
MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(), MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(),
getCurFootprintName() ); getCurFootprintName() );

View File

@ -324,7 +324,7 @@ void FOOTPRINT_WIZARD_FRAME::updateView()
void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel() void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
{ {
BOARD_ITEM* footprint = GetBoard()->m_Modules; BOARD_ITEM* footprint = GetBoard()->GetFirstModule();
if( footprint ) if( footprint )
{ {

View File

@ -100,7 +100,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->DeleteAllModules();
// Creates the module // Creates the module
wxString msg; wxString msg;
@ -254,4 +254,3 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
} }
} }

View File

@ -162,7 +162,11 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
case 0: case 0:
if( node->LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() ) if( node->LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() )
{ {
wxString currentFPName = m_frame->GetBoard()->m_Modules->GetFPID().GetLibItemName(); auto mod = m_frame->GetBoard()->GetFirstModule();
wxASSERT( mod );
wxString currentFPName = mod->GetFPID().GetLibItemName();
// mark modified part with an asterix // mark modified part with an asterix
if( m_frame->GetScreen()->IsModify() ) if( m_frame->GetScreen()->IsModify() )
@ -176,7 +180,11 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
case 1: case 1:
if( node->LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() ) if( node->LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() )
aVariant = m_frame->GetBoard()->m_Modules->GetDescription(); {
auto mod = m_frame->GetBoard()->GetFirstModule();
wxASSERT( mod );
aVariant = mod->GetDescription();
}
else else
aVariant = node->Desc; aVariant = node->Desc;
break; break;

View File

@ -70,7 +70,7 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
m_parent = aParent; m_parent = aParent;
if( aImportAsFootprintGraphic ) if( aImportAsFootprintGraphic )
m_importer.reset( new GRAPHICS_IMPORTER_MODULE( m_parent->GetBoard()->m_Modules ) ); m_importer.reset( new GRAPHICS_IMPORTER_MODULE( m_parent->GetBoard()->GetFirstModule() ) );
else else
m_importer.reset( new GRAPHICS_IMPORTER_BOARD( m_parent->GetBoard() ) ); m_importer.reset( new GRAPHICS_IMPORTER_BOARD( m_parent->GetBoard() ) );

View File

@ -101,8 +101,9 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
{ {
wxSafeYield( this, true ); // Allow frame to come to front before showing warning. wxSafeYield( this, true ); // Allow frame to come to front before showing warning.
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. Save changes?" ), if( !HandleUnsavedChanges( this,
[&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) ) _( "The current footprint has been modified. Save changes?" ),
[&]() -> bool { return SaveFootprint( GetBoard()->Modules().front() ); } ) )
{ {
return false; return false;
} }

View File

@ -135,7 +135,7 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
} }
// Set the new relative internal local coordinates of copied items // Set the new relative internal local coordinates of copied items
MODULE* editedModule = m_board->m_Modules; MODULE* editedModule = m_board->Modules().front();
wxPoint moveVector = partialModule.GetPosition() + editedModule->GetPosition(); wxPoint moveVector = partialModule.GetPosition() + editedModule->GetPosition();
partialModule.MoveAnchorPosition( moveVector ); partialModule.MoveAnchorPosition( moveVector );

View File

@ -603,7 +603,7 @@ void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(drawings %zu)\n", aBoard->Drawings().size() ); m_out->Print( aNestLevel+1, "(drawings %zu)\n", aBoard->Drawings().size() );
m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() ); m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() );
m_out->Print( aNestLevel+1, "(modules %d)\n", aBoard->m_Modules.GetCount() ); m_out->Print( aNestLevel + 1, "(modules %zu)\n", aBoard->Modules().size() );
m_out->Print( aNestLevel+1, "(nets %d)\n", m_mapping->GetSize() ); m_out->Print( aNestLevel+1, "(nets %d)\n", m_mapping->GetSize() );
m_out->Print( aNestLevel, ")\n\n" ); m_out->Print( aNestLevel, ")\n\n" );
@ -717,7 +717,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
formatHeader( aBoard, aNestLevel ); formatHeader( aBoard, aNestLevel );
// Save the modules. // Save the modules.
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
Format( module, aNestLevel ); Format( module, aNestLevel );
m_out->Print( 0, "\n" ); m_out->Print( 0, "\n" );

View File

@ -98,7 +98,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
if( aModule == NULL ) if( aModule == NULL )
{ {
if( ! frame->GetBoard() || ! frame->GetBoard()->m_Modules ) if( !frame->GetBoard() || !frame->GetBoard()->GetFirstModule() )
return false; return false;
aModule = SelectFootprintFromBoard( frame->GetBoard() ); aModule = SelectFootprintFromBoard( frame->GetBoard() );
@ -336,9 +336,8 @@ MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard( BOARD* aPcb )
wxString fpname; wxString fpname;
wxString msg; wxString msg;
wxArrayString listnames; wxArrayString listnames;
MODULE* module = aPcb->m_Modules;
for( ; module; module = module->Next() ) for( auto module : aPcb->Modules() )
listnames.Add( module->GetReference() ); listnames.Add( module->GetReference() );
msg.Printf( _( "Footprints [%u items]" ), (unsigned) listnames.GetCount() ); msg.Printf( _( "Footprints [%u items]" ), (unsigned) listnames.GetCount() );
@ -367,15 +366,13 @@ MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard( BOARD* aPcb )
oldName = fpname; oldName = fpname;
module = aPcb->m_Modules; for( auto mod : aPcb->Modules() )
for( ; module; module = module->Next() )
{ {
if( fpname == module->GetReference() ) if( fpname == mod->GetReference() )
break; return mod;
} }
return module; return nullptr;
} }
@ -437,11 +434,10 @@ static PICKED_ITEMS_LIST s_PickedList; // a pick-list to save in
MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
{ {
wxString moduleName; wxString moduleName;
MODULE* module = NULL;
wxArrayString fplist; wxArrayString fplist;
// Build list of available fp references, to display them in dialog // Build list of available fp references, to display them in dialog
for( MODULE* fp = GetBoard()->m_Modules; fp; fp = fp->Next() ) for( auto fp : GetBoard()->Modules() )
fplist.Add( fp->GetReference() + wxT(" ( ") + fp->GetValue() + wxT(" )") ); fplist.Add( fp->GetReference() + wxT(" ( ") + fp->GetValue() + wxT(" )") );
fplist.Sort(); fplist.Sort();
@ -457,18 +453,14 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
if( !moduleName.IsEmpty() ) if( !moduleName.IsEmpty() )
{ {
module = GetBoard()->m_Modules; for( auto mod : GetBoard()->Modules() )
while( module )
{ {
if( module->GetReference().CmpNoCase( moduleName ) == 0 ) if( mod->GetReference().CmpNoCase( moduleName ) == 0 )
break; return mod;
module = module->Next();
} }
} }
return module; return nullptr;
} }

View File

@ -48,8 +48,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar(); wxMenuBar* menuBar = new wxMenuBar();
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) { auto modifiedDocumentCondition = [this]( const SELECTION& sel ) {
return GetBoard()->m_Modules && GetScreen()->IsModify(); return !GetBoard()->Modules().empty() && GetScreen()->IsModify();
}; };
auto libraryPartCondition = [ this ] ( const SELECTION& sel ) { auto libraryPartCondition = [ this ] ( const SELECTION& sel ) {
LIB_ID libId = getTargetFPID(); LIB_ID libId = getTargetFPID();

View File

@ -212,7 +212,7 @@ void NETINFO_MAPPING::Update()
nets.insert( track->GetNetCode() ); nets.insert( track->GetNetCode() );
// Modules/pads // Modules/pads
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
for( D_PAD* pad = module->PadsList().GetFirst(); pad; pad = pad->Next() ) for( D_PAD* pad = module->PadsList().GetFirst(); pad; pad = pad->Next() )
{ {

View File

@ -135,7 +135,7 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater,
MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName() MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName()
{ {
if( GetBoard()->m_Modules == NULL ) if( GetBoard()->Modules().empty() )
{ {
DisplayError( this, _( "No footprints" ) ); DisplayError( this, _( "No footprints" ) );
return 0; return 0;
@ -143,9 +143,7 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName()
wxArrayString listnames; wxArrayString listnames;
MODULE* module; for( auto module : GetBoard()->Modules() )
for( module = GetBoard()->m_Modules; module; module = module->Next() )
listnames.Add( module->GetReference() ); listnames.Add( module->GetReference() );
wxArrayString headers; wxArrayString headers;
@ -163,17 +161,17 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName()
EDA_LIST_DIALOG dlg( this, _( "Components" ), headers, itemsToDisplay, wxEmptyString ); EDA_LIST_DIALOG dlg( this, _( "Components" ), headers, itemsToDisplay, wxEmptyString );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return NULL; return nullptr;
wxString ref = dlg.GetTextSelection(); wxString ref = dlg.GetTextSelection();
for( module = GetBoard()->m_Modules; module; module = module->Next() ) for( auto module : GetBoard()->Modules() )
{ {
if( module->GetReference() == ref ) if( module->GetReference() == ref )
break; return module;
} }
return module; return nullptr;
} }

View File

@ -511,7 +511,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
// Update pads // Update pads
BOARD* board = GetBoard(); BOARD* board = GetBoard();
for( MODULE* module = board->m_Modules; module; module = module->Next() ) for( auto module : board->Modules() )
{ {
for( auto pad : module->Pads() ) for( auto pad : module->Pads() )
view->Update( pad, KIGFX::GEOMETRY ); view->Update( pad, KIGFX::GEOMETRY );

View File

@ -174,7 +174,7 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
m_view->Add( track ); m_view->Add( track );
// Load modules and its additional elements // Load modules and its additional elements
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
m_view->Add( module ); m_view->Add( module );
// DRC markers // DRC markers

View File

@ -639,7 +639,7 @@ void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
UpdateUserInterface(); UpdateUserInterface();
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) for( auto module : GetBoard()->Modules() )
GetGalCanvas()->GetView()->Update( module ); GetGalCanvas()->GetView()->Update( module );
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
@ -1303,11 +1303,11 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
} }
else else
{ {
for( aModule = GetBoard()->m_Modules; aModule != NULL; aModule = aModule->Next() ) for( auto mod : GetBoard()->Modules() )
{ {
if( WildCompareString( ModulesMaskSelection, aModule->GetReference() ) ) if( WildCompareString( ModulesMaskSelection, mod->GetReference() ) )
{ {
aModule->SetLocked( aLocked ); mod->SetLocked( aLocked );
OnModify(); OnModify();
} }
} }

View File

@ -110,7 +110,7 @@ void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset )
LSET all_cu = LSET::AllCuMask(); LSET all_cu = LSET::AllCuMask();
for( MODULE* module = m_Modules; module; module = module->Next() ) for( auto module : m_modules )
{ {
bool display = true; bool display = true;
LSET layerMask = all_cu; LSET layerMask = all_cu;

View File

@ -88,7 +88,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
if( layersmask_plotpads.any() ) if( layersmask_plotpads.any() )
{ {
for( MODULE* Module = aBoard->m_Modules; Module; Module = Module->Next() ) for( auto Module : aBoard->Modules() )
{ {
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( NULL );
@ -115,7 +115,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
// Plot footprints fields (ref, value ...) // Plot footprints fields (ref, value ...)
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
if( ! itemplotter.PlotAllTextsModule( module ) ) if( ! itemplotter.PlotAllTextsModule( module ) )
{ {
@ -299,7 +299,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
// We plot here module texts, but they are usually on silkscreen layer, // We plot here module texts, but they are usually on silkscreen layer,
// so they are not plot here but plot by PlotSilkScreen() // so they are not plot here but plot by PlotSilkScreen()
// Plot footprints fields (ref, value ...) // Plot footprints fields (ref, value ...)
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
if( ! itemplotter.PlotAllTextsModule( module ) ) if( ! itemplotter.PlotAllTextsModule( module ) )
{ {
@ -308,7 +308,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
} }
} }
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
{ {
@ -328,7 +328,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
} }
// Plot footprint pads // Plot footprint pads
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
aPlotter->StartBlock( NULL ); aPlotter->StartBlock( NULL );
@ -695,7 +695,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter,
int smallDrill = (aPlotOpt.GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) int smallDrill = (aPlotOpt.GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE)
? SMALL_DRILL : INT_MAX; ? SMALL_DRILL : INT_MAX;
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{ {
@ -773,7 +773,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
// on this layer (like logos), not actually areas around pads. // on this layer (like logos), not actually areas around pads.
itemplotter.PlotBoardGraphicItems(); itemplotter.PlotBoardGraphicItems();
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
{ {
@ -804,7 +804,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
SHAPE_POLY_SET initialPolys; // Contains exact shapes to plot SHAPE_POLY_SET initialPolys; // Contains exact shapes to plot
// Plot pads // Plot pads
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
// add shapes with exact size // add shapes with exact size
module->TransformPadsShapesWithClearanceToPolygon( layer, initialPolys, 0 ); module->TransformPadsShapesWithClearanceToPolygon( layer, initialPolys, 0 );

View File

@ -430,7 +430,7 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire )
// Plot footprints graphic items (outlines) // Plot footprints graphic items (outlines)
void BRDITEMS_PLOTTER::Plot_Edges_Modules() void BRDITEMS_PLOTTER::Plot_Edges_Modules()
{ {
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() ) for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() )
{ {
@ -843,7 +843,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
} }
} }
for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() ) for( auto Module : m_board->Modules() )
{ {
for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() ) for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
{ {

View File

@ -132,7 +132,7 @@ PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER*
} }
// Build clearance cache for pads // Build clearance cache for pads
for( MODULE* mod = m_board->m_Modules; mod ; mod = mod->Next() ) for( auto mod : m_board->Modules() )
{ {
auto moduleClearance = mod->GetLocalClearance(); auto moduleClearance = mod->GetLocalClearance();

View File

@ -1758,7 +1758,7 @@ void SPECCTRA_DB::exportNETCLASS( const NETCLASSPTR& aNetClass, BOARD* aBoard )
void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard ) void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard )
{ {
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
module->SetFlag( 0 ); module->SetFlag( 0 );
if( module->GetLayer() == B_Cu ) if( module->GetLayer() == B_Cu )
@ -1779,7 +1779,7 @@ void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard )
// DSN Images (=KiCad MODULES and pads) must be presented from the // DSN Images (=KiCad MODULES and pads) must be presented from the
// top view. Restore those that were flipped. // top view. Restore those that were flipped.
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( auto module : aBoard->Modules() )
{ {
if( module->GetFlag() ) if( module->GetFlag() )
{ {

View File

@ -225,7 +225,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
} }
// Append modules: // Append modules:
for( BOARD_ITEM* item = currentPcb->m_Modules; item != NULL; item = item->Next() ) for( auto item : currentPcb->Modules() )
{ {
ITEM_PICKER picker( item, UR_CHANGED ); ITEM_PICKER picker( item, UR_CHANGED );
itemsList.PushItem( picker ); itemsList.PushItem( picker );
@ -336,7 +336,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
} }
// Find new modules // Find new modules
for( BOARD_ITEM* item = currentPcb->m_Modules; item != NULL; item = item->Next() ) for( auto item : currentPcb->Modules() )
{ {
if( !oldBuffer->ContainsItem( item ) ) if( !oldBuffer->ContainsItem( item ) )
{ {

View File

@ -1085,7 +1085,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
if( m_editModules ) if( m_editModules )
{ {
dupe_item = editFrame->GetBoard()->m_Modules->Duplicate( orig_item, increment ); dupe_item = editFrame->GetBoard()->GetFirstModule()->Duplicate( orig_item, increment );
} }
else else
{ {

View File

@ -104,7 +104,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{ {
std::unique_ptr<BOARD_ITEM> CreateItem() override std::unique_ptr<BOARD_ITEM> CreateItem() override
{ {
D_PAD* pad = new D_PAD ( m_board->m_Modules ); D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad
pad->IncrementPadName( true, true ); pad->IncrementPadName( true, true );
return std::unique_ptr<BOARD_ITEM>( pad ); return std::unique_ptr<BOARD_ITEM>( pad );
@ -130,7 +130,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
wxASSERT( board()->m_Modules ); wxASSERT( board()->GetFirstModule() );
doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP ); doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
@ -142,7 +142,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
{ {
if( !board()->m_Modules || !board()->m_Modules->PadsList() ) if( !board()->GetFirstModule() || !board()->GetFirstModule()->PadsList() )
return 0; return 0;
DIALOG_ENUM_PADS settingsDlg( frame() ); DIALOG_ENUM_PADS settingsDlg( frame() );
@ -318,7 +318,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) ); statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
} }
for( auto p : board()->m_Modules->Pads() ) for( auto p : board()->GetFirstModule()->Pads() )
{ {
p->ClearSelected(); p->ClearSelected();
view->Update( p ); view->Update( p );
@ -354,7 +354,7 @@ int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent )
for( auto prim : pad->GetPrimitives() ) for( auto prim : pad->GetPrimitives() )
{ {
auto ds = new EDGE_MODULE( board()->m_Modules ); auto ds = new EDGE_MODULE( board()->GetFirstModule() );
prim.ExportTo( ds ); // ExportTo exports to a DRAWSEGMENT prim.ExportTo( ds ); // ExportTo exports to a DRAWSEGMENT
// Fix an arbitray draw layer for this EDGE_MODULE // Fix an arbitray draw layer for this EDGE_MODULE
@ -385,7 +385,7 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection(); SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
std::unique_ptr<D_PAD> pad ( new D_PAD ( board()->m_Modules ) ); std::unique_ptr<D_PAD> pad( new D_PAD( board()->GetFirstModule() ) );
D_PAD *refPad = nullptr; D_PAD *refPad = nullptr;
bool multipleRefPadsFound = false; bool multipleRefPadsFound = false;
bool illegalItemsFound = false; bool illegalItemsFound = false;

View File

@ -161,7 +161,7 @@ void PAD_TOOL::Reset( RESET_REASON aReason )
bool PAD_TOOL::haveFootprints() bool PAD_TOOL::haveFootprints()
{ {
auto& board = *getModel<BOARD>(); auto& board = *getModel<BOARD>();
return board.m_Modules.GetCount() > 0; return board.Modules().size() > 0;
} }
@ -267,7 +267,7 @@ static void doPushPadProperties( BOARD& board, const D_PAD& aSrcPad, BOARD_COMMI
double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation(); double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
for( const MODULE* module = board.m_Modules; module; module = module->Next() ) for( auto module : board.Modules() )
{ {
if( !aSameFootprints && ( module != moduleRef ) ) if( !aSameFootprints && ( module != moduleRef ) )
continue; continue;

View File

@ -138,7 +138,10 @@ protected:
KIGFX::VIEW_CONTROLS* controls() const { return getViewControls(); } KIGFX::VIEW_CONTROLS* controls() const { return getViewControls(); }
PCB_EDIT_FRAME* frame() const { return getEditFrame<PCB_EDIT_FRAME>(); } PCB_EDIT_FRAME* frame() const { return getEditFrame<PCB_EDIT_FRAME>(); }
BOARD* board() const { return getModel<BOARD>(); } BOARD* board() const { return getModel<BOARD>(); }
MODULE* module() const { return board()->m_Modules; } MODULE* module() const
{
return board()->Modules().front();
}
PCB_DISPLAY_OPTIONS* displayOptions() const; PCB_DISPLAY_OPTIONS* displayOptions() const;
PCB_DRAW_PANEL_GAL* canvas() const; PCB_DRAW_PANEL_GAL* canvas() const;
const SELECTION& selection() const; const SELECTION& selection() const;

View File

@ -705,7 +705,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
if( editModules ) if( editModules )
{ {
auto oldModule = static_cast<MODULE*>( clipItem ); auto oldModule = static_cast<MODULE*>( clipItem );
auto newModule = board()->m_Modules.GetFirst(); auto newModule = board()->GetFirstModule();
for( D_PAD* pad = oldModule->PadsList(), *next = nullptr; pad; pad = next ) for( D_PAD* pad = oldModule->PadsList(), *next = nullptr; pad; pad = next )
{ {
@ -839,7 +839,7 @@ int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard )
std::vector<BOARD_ITEM*> items; std::vector<BOARD_ITEM*> items;
moveNoFlagToVector( aBoard->m_Track, items, isNew ); moveNoFlagToVector( aBoard->m_Track, items, isNew );
moveNoFlagToVector( aBoard->m_Modules, items, isNew ); moveNoFlagToVector( aBoard->Modules(), items, isNew );
moveNoFlagToVector( aBoard->Drawings(), items, isNew ); moveNoFlagToVector( aBoard->Drawings(), items, isNew );
moveNoFlagToVector( aBoard->Zones(), items, isNew ); moveNoFlagToVector( aBoard->Zones(), items, isNew );

View File

@ -992,11 +992,10 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath )
{ {
auto modules = board()->m_Modules.GetFirst();
std::list<MODULE*> modList; std::list<MODULE*> modList;
// store all modules that are on that sheet // store all modules that are on that sheet
for( MODULE* mitem = modules; mitem; mitem = mitem->Next() ) for( auto mitem : board()->Modules() )
{ {
if( mitem != NULL && mitem->GetPath().Contains( aSheetpath ) ) if( mitem != NULL && mitem->GetPath().Contains( aSheetpath ) )
{ {

View File

@ -119,7 +119,7 @@ using namespace std::placeholders;
static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem ) static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
{ {
static std::list<BOARD_ITEM*> itemsList; static std::set<BOARD_ITEM*> itemsList;
if( aItem == NULL ) // Build list if( aItem == NULL ) // Build list
{ {
@ -130,33 +130,30 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
// Store items in list: // Store items in list:
// Append tracks: // Append tracks:
for( item = aPcb->m_Track; item != NULL; item = item->Next() ) for( item = aPcb->m_Track; item != NULL; item = item->Next() )
itemsList.push_back( item ); itemsList.insert( item );
// Append modules: // Append modules:
for( item = aPcb->m_Modules; item != NULL; item = item->Next() ) std::copy( aPcb->Modules().begin(), aPcb->Modules().end(),
itemsList.push_back( item ); std::inserter( itemsList, itemsList.end() ) );
// Append drawings // Append drawings
for( auto ditem : aPcb->Drawings() ) for( auto ditem : aPcb->Drawings() )
itemsList.push_back( ditem ); itemsList.insert( ditem );
// Append zones outlines // Append zones outlines
for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
itemsList.push_back( aPcb->GetArea( ii ) ); itemsList.insert( aPcb->GetArea( ii ) );
NETINFO_LIST& netInfo = aPcb->GetNetInfo(); NETINFO_LIST& netInfo = aPcb->GetNetInfo();
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i ) for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
itemsList.push_back( *i ); itemsList.insert( *i );
// Sort list
itemsList.sort();
return false; return false;
} }
// search in list: // search in list:
return std::binary_search( itemsList.begin(), itemsList.end(), aItem ); return itemsList.count( aItem );
} }
static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
@ -625,4 +622,4 @@ void PCB_BASE_EDIT_FRAME::RollbackFromUndo()
delete undo; delete undo;
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
} }

View File

@ -377,7 +377,7 @@ void ZONE_FILLER::buildZoneFeatureHoleList( const ZONE_CONTAINER* aZone,
MODULE dummymodule( m_board ); // Creates a dummy parent MODULE dummymodule( m_board ); // Creates a dummy parent
D_PAD dummypad( &dummymodule ); D_PAD dummypad( &dummymodule );
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( auto module : m_board->Modules() )
{ {
D_PAD* nextpad; D_PAD* nextpad;