pcbnew: Move pads to std::deque

This commit is contained in:
Seth Hillbrand 2019-06-01 16:23:36 -07:00
parent 6c93cccb70
commit 9163ac543a
41 changed files with 127 additions and 131 deletions

View File

@ -482,7 +482,7 @@ class CINFO3D_VISU
SHAPE_POLY_SET &aCornerBuffer,
int aWidth) const;
void transformPadsShapesWithClearanceToPolygon( const DLIST<D_PAD> &aPads,
void transformPadsShapesWithClearanceToPolygon( const PADS &aPads,
PCB_LAYER_ID aLayer,
SHAPE_POLY_SET &aCornerBuffer,
int aInflateValue,

View File

@ -623,11 +623,9 @@ void CINFO3D_VISU::AddPadsShapesWithClearanceToContainer( const MODULE* aModule,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper )
{
const D_PAD* pad = aModule->PadsList();
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
for( auto pad : aModule->Pads() )
{
if( !pad->IsOnLayer( aLayerId ) )
continue;

View File

@ -490,9 +490,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// /////////////////////////////////////////////////////////////////////////
for( auto module : m_board->Modules() )
{
const D_PAD* pad = module->PadsList();
for( ; pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
const wxSize padHole = pad->GetDrillSize();
@ -524,9 +522,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// /////////////////////////////////////////////////////////////////////////
for( auto module : m_board->Modules() )
{
const D_PAD* pad = module->PadsList();
for( ; pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
const wxSize padHole = pad->GetDrillSize();
@ -610,7 +606,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
// Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole
transformPadsShapesWithClearanceToPolygon( module->PadsList(),
transformPadsShapesWithClearanceToPolygon( module->Pads(),
curr_layer_id,
*layerPoly,
0,
@ -997,10 +993,9 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
{
if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
{
D_PAD* pad = module->PadsList();
int linewidth = g_DrawDefaultLineThickness;
for( ; pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
@ -1024,10 +1019,9 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
{
if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
{
D_PAD* pad = module->PadsList();
const int linewidth = g_DrawDefaultLineThickness;
for( ; pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
@ -1038,7 +1032,7 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter )
else
{
transformPadsShapesWithClearanceToPolygon(
module->PadsList(), curr_layer_id, *layerPoly, 0, false );
module->Pads(), curr_layer_id, *layerPoly, 0, false );
}
// On tech layers, use a poor circle approximation, only for texts (stroke font)

View File

@ -139,15 +139,13 @@ void CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad,
// Based on the same function name in board_items_to_polyshape_transform.cpp
// It was implemented here to allow dynamic segments count per pad shape
void CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon( const DLIST<D_PAD>& aPads, PCB_LAYER_ID aLayer,
void CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon( const PADS& aPads, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper ) const
{
const D_PAD* pad = aPads;
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
for( auto pad : aPads )
{
if( !pad->IsOnLayer(aLayer) )
continue;

View File

@ -800,7 +800,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
// Insert pads holes (vertical cylinders)
for( const auto module : m_settings.GetBoard()->Modules() )
{
for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
{

View File

@ -1183,7 +1183,7 @@ void C3D_RENDER_RAYTRACING::add_3D_vias_and_pads_to_container()
// Insert pads holes (vertical cylinders)
for( auto module : m_settings.GetBoard()->Modules() )
{
for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
{
insert3DPadHole( pad );

View File

@ -69,8 +69,8 @@ size_t hash_eda( const EDA_ITEM* aItem, int aFlags )
for( const BOARD_ITEM* i = module->GraphicalItemsList(); i; i = i->Next() )
ret ^= hash_eda( i, aFlags );
for( const D_PAD* i = module->PadsList(); i; i = i->Next() )
ret ^= hash_eda( i, aFlags );
for( auto i : module->Pads() )
ret ^= hash_eda( static_cast<EDA_ITEM*>( i ), aFlags );
}
break;

View File

@ -45,7 +45,7 @@ ARRAY_PAD_NAME_PROVIDER::ARRAY_PAD_NAME_PROVIDER(
if( aMod )
{
// reserve the name of each existing pad
for( D_PAD* pad = aMod->PadsList(); pad; pad = pad->Next() )
for( auto pad : aMod->Pads() )
{
m_existing_pad_names.insert( pad->GetName() );
}

View File

@ -128,10 +128,9 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aMaxError,
bool aSkipNPTHPadsWihNoCopper ) const
{
D_PAD* pad = PadsList();
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
for( auto pad : m_pads )
{
if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
continue;

View File

@ -291,7 +291,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
bool changed = false;
// At this point, the component footprint is updated. Now update the nets.
for( D_PAD* pad = aPcbComponent->PadsList(); pad; pad = pad->Next() )
for( auto pad : aPcbComponent->Pads() )
{
COMPONENT_NET net = aNewComponent->GetNet( pad->GetName() );

View File

@ -1725,7 +1725,7 @@ unsigned BOARD::GetPadCount()
unsigned retval = 0;
for( auto mod : Modules() )
retval += mod->Pads().Size();
retval += mod->Pads().size();
return retval;
}

View File

@ -32,7 +32,6 @@
#include <tuple>
#include <dlist.h>
#include <core/iterators.h>
#include <board_design_settings.h>
@ -163,8 +162,6 @@ protected:
DECL_VEC_FOR_SWIG( MARKERS, MARKER_PCB* )
DECL_VEC_FOR_SWIG( ZONE_CONTAINERS, ZONE_CONTAINER* )
DECL_DEQ_FOR_SWIG( TRACKS, TRACK* )
DECL_DEQ_FOR_SWIG( DRAWINGS, BOARD_ITEM* )
DECL_DEQ_FOR_SWIG( MODULES, MODULE* )
/**

View File

@ -103,7 +103,7 @@ MODULE::MODULE( const MODULE& aModule ) :
m_Value->SetParent( this );
// Copy auxiliary data: Pads
for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() )
for( auto pad : aModule.Pads() )
{
Add( new D_PAD( *pad ) );
}
@ -179,9 +179,9 @@ MODULE& MODULE::operator=( const MODULE& aOther )
m_Value->SetParent( this );
// Copy auxiliary data: Pads
m_Pads.DeleteAll();
m_pads.clear();
for( D_PAD* pad = aOther.m_Pads; pad; pad = pad->Next() )
for( auto pad : aOther.Pads() )
{
Add( new D_PAD( *pad ) );
}
@ -221,7 +221,7 @@ void MODULE::ClearAllNets()
{
// Force the ORPHANED dummy net info for all pads.
// ORPHANED dummy net does not depend on a board
for( D_PAD* pad = PadsList(); pad; pad = pad->Next() )
for( auto pad : m_pads )
pad->SetNetCode( NETINFO_LIST::ORPHANED );
}
@ -245,9 +245,9 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
case PCB_PAD_T:
if( aMode == ADD_APPEND )
m_Pads.PushBack( static_cast<D_PAD*>( aBoardItem ) );
m_pads.push_back( static_cast<D_PAD*>( aBoardItem ) );
else
m_Pads.PushFront( static_cast<D_PAD*>( aBoardItem ) );
m_pads.push_front( static_cast<D_PAD*>( aBoardItem ) );
break;
default:
@ -280,7 +280,8 @@ void MODULE::Remove( BOARD_ITEM* aBoardItem )
break;
case PCB_PAD_T:
m_Pads.Remove( static_cast<D_PAD*>( aBoardItem ) );
m_pads.erase( std::remove_if( m_pads.begin(), m_pads.end(),
[aBoardItem]( BOARD_ITEM* aItem ) { return aItem == aBoardItem; } ) );
break;
default:
@ -321,7 +322,7 @@ void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings )
aModule->SetThermalGap( GetThermalGap() );
}
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : m_pads )
{
// Fix me: if aCopyLocalSettings == true, for "multiple" pads
// (set of pads having the same name/number) this is broken
@ -343,7 +344,7 @@ void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings )
void MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
pad->Print( aFrame, aDC, aOffset );
BOARD* brd = GetBoard();
@ -399,7 +400,7 @@ EDA_RECT MODULE::GetFootprintRect() const
area.Merge( item->GetBoundingBox() );
}
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
area.Merge( pad->GetBoundingBox() );
return area;
@ -475,7 +476,6 @@ SHAPE_POLY_SET MODULE::GetBoundingPoly() const
void MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
{
int nbpad;
wxString msg;
aList.push_back( MSG_PANEL_ITEM( m_Reference->GetShownText(), m_Value->GetShownText(), DARKCYAN ) );
@ -498,16 +498,8 @@ void MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >&
aList.push_back( MSG_PANEL_ITEM( _( "Board Side" ),
IsFlipped()? _( "Back (Flipped)" ) : _( "Front" ), RED ) );
EDA_ITEM* PtStruct = m_Pads;
nbpad = 0;
while( PtStruct )
{
nbpad++;
PtStruct = PtStruct->Next();
}
msg.Printf( wxT( "%d" ), nbpad );
msg.Printf( wxT( "%zu" ), m_pads.size() );
aList.push_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
msg = wxT( ".." );
@ -592,7 +584,7 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co
return false;
// Determine if any elements in the MODULE intersect the rect
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
if( pad->HitTest( arect, false, 0 ) )
return true;
@ -612,7 +604,7 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co
D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
if( pad->GetName().CmpNoCase( aPadName ) == 0 ) // why case insensitive?
return pad;
@ -624,7 +616,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
D_PAD* MODULE::GetPad( const wxPoint& aPosition, LSET aLayerMask )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
// ... and on the correct layer.
if( !( pad->GetLayerSet() & aLayerMask ).any() )
@ -640,9 +632,9 @@ D_PAD* MODULE::GetPad( const wxPoint& aPosition, LSET aLayerMask )
D_PAD* MODULE::GetTopLeftPad()
{
D_PAD* topLeftPad = m_Pads;
D_PAD* topLeftPad = GetFirstPad();
for( D_PAD* p = m_Pads->Next(); p; p = p->Next() )
for( auto p : m_pads )
{
wxPoint pnt = p->GetPosition(); // GetPosition() returns the center of the pad
@ -661,11 +653,11 @@ D_PAD* MODULE::GetTopLeftPad()
unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
{
if( aIncludeNPTH )
return m_Pads.GetCount();
return m_pads.size();
unsigned cnt = 0;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
if( pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
continue;
@ -682,7 +674,7 @@ unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
std::set<wxString> usedNames;
// Create a set of used pad numbers
for( D_PAD* pad = PadsList(); pad; pad = pad->Next() )
for( auto pad : m_pads )
{
// Skip pads not on copper layers (used to build complex
// solder paste shapes for instance)
@ -746,7 +738,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T
break;
case PCB_PAD_T:
result = IterateForward( m_Pads, inspector, testData, p );
result = IterateForward<D_PAD*>( m_pads, inspector, testData, p );
++p;
break;
@ -824,7 +816,7 @@ void MODULE::RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction )
{
try
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
aFunction( static_cast<BOARD_ITEM*>( pad ) );
for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() )
@ -851,7 +843,7 @@ void MODULE::GetAllDrawingLayers( int aLayers[], int& aCount, bool aIncludePads
if( aIncludePads )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
int pad_layers[KIGFX::VIEW::VIEW_MAX_LAYERS], pad_layers_count;
pad->ViewGetLayers( pad_layers, pad_layers_count );
@ -904,7 +896,7 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
non_silk = true;
}
if( ( f_silk || b_silk ) && !non_silk && m_Pads.GetCount() == 0 )
if( ( f_silk || b_silk ) && !non_silk && m_pads.empty() )
{
if( f_silk )
aLayers[ aCount++ ] = F_SilkS;
@ -1015,7 +1007,7 @@ void MODULE::Flip( const wxPoint& aCentre )
NORMALIZE_ANGLE_POS( m_Orient );
// Mirror pads to other side of board about the x axis, i.e. vertically.
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
pad->Flip( m_Pos );
// Mirror reference and value.
@ -1054,7 +1046,7 @@ void MODULE::SetPosition( const wxPoint& newpos )
m_Reference->EDA_TEXT::Offset( delta );
m_Value->EDA_TEXT::Offset( delta );
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
pad->SetPosition( pad->GetPosition() + delta );
}
@ -1109,7 +1101,7 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
m_Value->SetDrawCoord();
// Update the pad local coordinates.
for( D_PAD* pad = PadsList(); pad; pad = pad->Next() )
for( auto pad : m_pads )
{
pad->SetPos0( pad->GetPos0() + moveVector );
pad->SetDrawCoord();
@ -1152,7 +1144,7 @@ void MODULE::SetOrientation( double newangle )
m_Orient = newangle;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
{
pad->SetOrientation( pad->GetOrientation() + angleChange );
pad->SetDrawCoord();
@ -1192,7 +1184,7 @@ BOARD_ITEM* MODULE::Duplicate( const BOARD_ITEM* aItem,
new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
if( aAddToModule )
PadsList().PushBack( new_pad );
m_pads.push_back( new_pad );
new_item = new_pad;
break;
@ -1253,7 +1245,7 @@ wxString MODULE::GetNextPadName( bool aFillSequenceGaps ) const
std::set<int> usedNumbers;
// Create a set of used pad numbers
for( D_PAD* pad = PadsList(); pad; pad = pad->Next() )
for( auto pad : m_pads )
{
int padNumber = GetTrailingInt( pad->GetName() );
usedNumbers.insert( padNumber );
@ -1310,7 +1302,7 @@ double MODULE::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
// build list of holes (covered areas not available for selection)
SHAPE_POLY_SET holes;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
for( auto pad : m_pads )
addRect( holes, pad->GetBoundingBox() );
addRect( holes, m_Reference->GetBoundingBox() );

View File

@ -31,6 +31,7 @@
#ifndef MODULE_H_
#define MODULE_H_
#include <deque>
#include <board_item_container.h>
#include <class_board_item.h>
@ -103,6 +104,10 @@ class MODULE_3D_SETTINGS
bool m_Preview; ///< Include module in 3D preview
};
DECL_DEQ_FOR_SWIG( PADS, D_PAD* )
DECL_DEQ_FOR_SWIG( DRAWINGS, BOARD_ITEM* )
DECL_DEQ_FOR_SWIG( MODULES, MODULE* )
class MODULE : public BOARD_ITEM_CONTAINER
{
public:
@ -156,15 +161,17 @@ public:
// Virtual function
const EDA_RECT GetBoundingBox() const override;
DLIST<D_PAD>& PadsList() { return m_Pads; }
const DLIST<D_PAD>& PadsList() const { return m_Pads; }
DLIST<BOARD_ITEM>& GraphicalItemsList() { return m_Drawings; }
const DLIST<BOARD_ITEM>& GraphicalItemsList() const { return m_Drawings; }
DLIST_ITERATOR_WRAPPER<D_PAD> Pads()
PADS& Pads()
{
return DLIST_ITERATOR_WRAPPER<D_PAD>( m_Pads );
return m_pads;
}
const PADS& Pads() const
{
return m_pads;
}
DLIST_ITERATOR_WRAPPER<BOARD_ITEM> GraphicalItems()
@ -464,6 +471,15 @@ public:
D_PAD* GetTopLeftPad();
/**
* Gets the first pad in the list or NULL if none
* @return first pad or null pointer
*/
D_PAD* GetFirstPad() const
{
return m_pads.empty() ? nullptr : m_pads.front();
}
/**
* GetPadCount
* returns the number of pads.
@ -543,6 +559,7 @@ public:
* Function RunOnChildren
*
* Invokes a function on all BOARD_ITEMs that belong to the module (pads, drawings, texts).
* Note that this function should not add or remove items to the module
* @param aFunction is the function to be invoked.
*/
void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction );
@ -652,8 +669,17 @@ public:
#endif
private:
DLIST<D_PAD> m_Pads; ///< Linked list of pads.
DLIST<BOARD_ITEM> m_Drawings; ///< Linked list of graphical items.
/// BOARD_ITEMs for drawings on the board, owned by pointer.
DRAWINGS m_drawings;
/// D_PAD items, owned by pointer
PADS m_pads;
std::list<MODULE_3D_SETTINGS> m_3D_Drawings; ///< Linked list of 3D models.
double m_Orient; ///< Orientation in tenths of a degree, 900=90.0 degrees.
wxPoint m_Pos; ///< Position of module on the board in internal units.

View File

@ -157,8 +157,6 @@ public:
return aItem && PCB_PAD_T == aItem->Type();
}
D_PAD* Next() const { return static_cast<D_PAD*>( Pnext ); }
MODULE* GetParent() const { return (MODULE*) m_Parent; }
/**

View File

@ -103,7 +103,7 @@ void CN_CONNECTIVITY_ALGO::markItemNetAsDirty( const BOARD_ITEM* aItem )
{
auto mod = static_cast <const MODULE*>( aItem );
for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() )
for( auto pad : mod->Pads() )
MarkNetAsDirty( pad->GetNetCode() );
}
}

View File

@ -155,7 +155,7 @@ void DIALOG_GENDRILL::InitDisplayParams()
for( auto module : m_board->Modules() )
{
for( D_PAD* pad = module->PadsList(); pad != NULL; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
{

View File

@ -908,7 +908,7 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
m_board->Add( m, ADD_APPEND );
// update the nets within the pads of the clone
for( D_PAD* pad = m->PadsList(); pad; pad = pad->Next() )
for( auto pad : m->Pads() )
{
wxString pn_key = makeKey( e.name, pad->GetName() );
@ -1515,7 +1515,7 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree ) const
int shape = EPAD::UNDEF;
D_PAD* pad = new D_PAD( aModule );
aModule->PadsList().PushBack( pad );
aModule->Add( pad );
transferPad( e, pad );
if( e.first && *e.first && m_rules->psFirst != EPAD::UNDEF )
@ -1858,7 +1858,7 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter
// we add a PAD_ATTRIB_HOLE_NOT_PLATED pad to this module.
D_PAD* pad = new D_PAD( aModule );
aModule->PadsList().PushBack( pad );
aModule->Add( pad );
pad->SetShape( PAD_SHAPE_CIRCLE );
pad->SetAttribute( PAD_ATTRIB_HOLE_NOT_PLATED );
@ -1902,7 +1902,7 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
bool shape_set = false;
int shape = EPAD::UNDEF;
D_PAD* pad = new D_PAD( aModule );
aModule->PadsList().PushBack( pad );
aModule->Add( pad );
transferPad( e, pad );
if( pad->GetName() == wxT( "1" ) && m_rules->psFirst != EPAD::UNDEF )

View File

@ -116,7 +116,7 @@ static void build_pad_testpoints( BOARD *aPcb,
for( auto module : aPcb->Modules() )
{
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
D356_RECORD rk;
rk.access = compute_pad_access_code( aPcb, pad->GetLayerSet() );

View File

@ -707,7 +707,7 @@ static size_t hashModule( const MODULE* aModule )
for( const BOARD_ITEM* i = aModule->GraphicalItemsList(); i; i = i->Next() )
ret ^= hash_eda( i, flags );
for( const D_PAD* i = aModule->PadsList(); i; i = i->Next() )
for( auto i : aModule->Pads() )
ret ^= hash_eda( i, flags );
return ret;
@ -720,7 +720,6 @@ static size_t hashModule( const MODULE* aModule )
*/
static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
{
D_PAD* pad;
const char* layer;
wxString pinname;
const char* mirror = "0";
@ -784,7 +783,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
// set of already emitted pins to check for duplicates
std::set<wxString> pins;
for( pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
/* Padstacks are defined using the correct layers for the pads, therefore to
* all pads need to be marked as TOP to use the padstack information correctly.
@ -915,7 +914,6 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
{
wxString msg;
NETINFO_ITEM* net;
D_PAD* pad;
int NbNoConn = 1;
fputs( "$SIGNALS\n", aFile );
@ -939,7 +937,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
for( auto module : aPcb->Modules() )
{
for( pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( pad->GetNetCode() != net->GetNet() )
continue;

View File

@ -287,7 +287,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule,
aIDFBoard.GetUserOffset( dx, dy );
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : aModule->Pads() )
{
drill = (double) pad->GetDrillSize().x * scale;
x = pad->GetPosition().x * scale + dx;

View File

@ -1358,7 +1358,7 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
}
// Export pads
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : aModule->Pads() )
export_vrml_pad( aModel, aPcb, pad );
bool isFlipped = aModule->GetLayer() == B_Cu;

View File

@ -401,9 +401,7 @@ static bool sortFPlist( const LIST_MOD& ref, const LIST_MOD& tst )
*/
static bool HasNonSMDPins( MODULE* aModule )
{
D_PAD* pad;
for( pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : aModule->Pads() )
{
if( pad->GetAttribute() != PAD_ATTRIB_SMD )
return true;
@ -733,7 +731,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
else
fputs( "layer other\n", rptfile );
for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
for( auto pad : Module->Pads() )
{
fprintf( rptfile, "$PAD \"%s\"\n", TO_UTF8( pad->GetName() ) );
int layer = 0;

View File

@ -99,7 +99,7 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
// Do not modify existing board
MODULE newModule(*mod);
for( D_PAD* pad = newModule.PadsList().begin(); pad; pad = pad->Next() )
for( auto pad : newModule.Pads() )
{
pad->SetNetCode( 0, 0 );
}

View File

@ -1094,7 +1094,7 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
Format( gr, aNestLevel+1 );
// Save pads.
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : aModule->Pads() )
format( pad, aNestLevel+1 );
// Save 3D info.

View File

@ -1617,7 +1617,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
pad->SetPosition( padpos + aModule->GetPosition() );
aModule->PadsList().PushBack( pad.release() );
aModule->Add( pad.release() );
return; // preferred exit
}
}

View File

@ -76,7 +76,7 @@ MODULE* PCB_EDIT_FRAME::CreateMuWaveBaseFootprint( const wxString& aValue,
{
D_PAD* pad = new D_PAD( module );
module->PadsList().PushFront( pad );
module->Add( pad, ADD_INSERT );
int tw = GetDesignSettings().GetCurrentTrackWidth();
pad->SetSize( wxSize( tw, tw ) );
@ -175,7 +175,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
return NULL;
module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count );
pad = module->PadsList();
auto it = module->Pads().begin();
pad = *it;
switch( shape_type )
{
@ -185,7 +186,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
pad = pad->Next();
pad = *( it + 1 );
pad->SetX0( oX + gap_size + pad->GetSize().x );
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
@ -193,7 +194,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
case 1: //Stub :
pad->SetName( wxT( "1" ) );
pad = pad->Next();
pad = *( it + 1 );
pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
pad->SetSize( wxSize( pad->GetSize().x, gap_size ) );
pad->SetY( pad->GetPos0().y + pad->GetPosition().y );
@ -479,11 +480,13 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
wxPoint offset;
offset.x = -ShapeSize.x / 2;
pad1 = module->PadsList();
auto it = module->Pads().begin();
pad1 = *it;
pad1->SetX0( offset.x );
pad1->SetX( pad1->GetPos0().x );
pad2 = pad1->Next();
pad2 = *( ++it );
pad2->SetX0( offset.x + ShapeSize.x );
pad2->SetX( pad2->GetPos0().x );

View File

@ -404,7 +404,7 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern,
// Place a pad on each end of coil.
pad = new D_PAD( module );
module->PadsList().PushFront( pad );
module->Add( pad );
pad->SetName( "1" );
pad->SetPosition( inductorPattern.m_End );
@ -418,7 +418,7 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern,
D_PAD* newpad = new D_PAD( *pad );
module->PadsList().Insert( newpad, pad->Next() );
module->Add( newpad );
pad = newpad;
pad->SetName( "2" );

View File

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

View File

@ -114,7 +114,7 @@ void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
D_PAD* pad = new D_PAD( aModule );
// Add the new pad to end of the module pad list.
aModule->PadsList().PushBack( pad );
aModule->Add( pad );
// Update the pad properties,
// and keep NETINFO_LIST::ORPHANED as net info

View File

@ -304,7 +304,7 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad
pad->SetPosition( padpos + aModule->GetPosition() );
}
aModule->PadsList().PushBack( pad );
aModule->Add( pad );
}

View File

@ -162,7 +162,7 @@ static void Trace_Pads_Only( PCB_BASE_FRAME* aFrame, wxDC* DC, MODULE* aModule,
displ_opts->m_DisplayPadFill = false;
// Draw pads.
for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
for( auto pad : aModule->Pads() )
{
if( (pad->GetLayerSet() & aLayerMask) == 0 )
continue;

View File

@ -92,7 +92,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
{
aPlotter->StartBlock( NULL );
for( D_PAD* pad = Module->PadsList(); pad; pad = pad->Next() )
for( auto pad : Module->Pads() )
{
// See if the pad is on this layer
LSET masklayer = pad->GetLayerSet();
@ -332,7 +332,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
{
aPlotter->StartBlock( NULL );
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( (pad->GetLayerSet() & aLayerMask) == 0 )
continue;
@ -697,7 +697,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter,
for( auto module : aBoard->Modules() )
{
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
wxSize hole = pad->GetDrillSize();

View File

@ -845,7 +845,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
for( auto Module : m_board->Modules() )
{
for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
for( auto pad : Module->Pads() )
{
if( pad->GetDrillSize().x == 0 )
continue;

View File

@ -136,7 +136,7 @@ PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER*
{
auto moduleClearance = mod->GetLocalClearance();
for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() )
for( auto pad : mod->Pads() )
{
int padClearance = pad->GetLocalClearance();

View File

@ -142,7 +142,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
{
if( !board()->GetFirstModule() || !board()->GetFirstModule()->PadsList() )
if( !board()->GetFirstModule() || !board()->GetFirstModule()->Pads().empty() )
return 0;
DIALOG_ENUM_PADS settingsDlg( frame() );

View File

@ -275,7 +275,7 @@ static void doPushPadProperties( BOARD& board, const D_PAD& aSrcPad, BOARD_COMMI
if( module->GetFPID() != moduleRef->GetFPID() )
continue;
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
for( auto pad : module->Pads() )
{
if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
continue;

View File

@ -707,9 +707,9 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
auto oldModule = static_cast<MODULE*>( clipItem );
auto newModule = board()->GetFirstModule();
for( D_PAD* pad = oldModule->PadsList(), *next = nullptr; pad; pad = next )
for( auto it = oldModule->Pads().begin(); it != oldModule->Pads().end(); it++ )
{
next = pad->Next();
auto pad = *it;
oldModule->Remove( pad );
pad->SetParent( newModule );
items.push_back( pad );

View File

@ -246,7 +246,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
for( EDA_ITEM* child = clone->GraphicalItemsList(); child; child = child->Next() )
child->ClearEditFlags();
for( D_PAD* pad = clone->PadsList(); pad; pad = pad->Next() )
for( auto pad : clone->Pads() )
pad->ClearEditFlags();
clone->Reference().ClearEditFlags();

View File

@ -379,13 +379,8 @@ void ZONE_FILLER::buildZoneFeatureHoleList( const ZONE_CONTAINER* aZone,
for( auto module : m_board->Modules() )
{
D_PAD* nextpad;
for( D_PAD* pad = module->PadsList(); pad != NULL; pad = nextpad )
for( auto pad : module->Pads() )
{
nextpad = pad->Next(); // pad pointer can be modified by next code, so
// calculate the next pad here
if( !pad->IsOnLayer( aZone->GetLayer() ) )
{
/* Test for pads that are on top or bottom only and have a hole.

View File

@ -48,7 +48,7 @@ static std::unique_ptr<MODULE> ModuleWithPads( const std::vector<wxString> aName
pad->SetName( name );
module->PadsList().PushBack( pad.release() );
module->Add( pad.release() );
}
return module;