From ecbe947bc6ff1f54d16d5818985bac89311f35c6 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 7 Jun 2013 09:17:52 -0400 Subject: [PATCH] CvPcb pin count filtering improvement. (fixes lp:1188325) * Add option to MODULE::GetPadCount() to exclude non-plated through holes. --- common/footprint_info.cpp | 4 ++-- pcbnew/class_module.cpp | 19 +++++++++++++++++++ pcbnew/class_module.h | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 810076be05..a82f809d7a 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -99,7 +99,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) fpinfo->SetLibraryName( filename.GetName() ); fpinfo->SetLibraryPath( filename.GetFullPath() ); fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_KeyWord = m->GetKeywords(); fpinfo->m_Doc = m->GetDescription(); @@ -163,7 +163,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) fpinfo->SetLibraryName( libNickNames[ii] ); fpinfo->SetLibraryPath( path ); fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_KeyWord = m->GetKeywords(); fpinfo->m_Doc = m->GetDescription(); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 64d03bb031..b0115bb119 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -603,6 +603,25 @@ D_PAD* MODULE::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask ) } +unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const +{ + if( aIncludeNPTH ) + return m_Pads.GetCount(); + + unsigned cnt = 0; + + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) + { + if( pad->GetAttribute() == PAD_HOLE_NOT_PLATED ) + continue; + + cnt++; + } + + return cnt; +} + + void MODULE::Add3DModel( S3D_MASTER* a3DModel ) { a3DModel->SetParent( this ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 30f979b9b0..cc68cab05c 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -384,11 +384,21 @@ public: */ D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS ); + enum INCLUDE_NPTH_T + { + DO_NOT_INCLUDE_NPTH = false, + INCLUDE_NPTH = true + }; + /** * GetPadCount * returns the number of pads. + * + * @param aIncludeNPTH includes non-plated through holes when true. Does not include + * non-plated through holes when false. + * @return the number of pads according to \a aIncludeNPTH. */ - unsigned GetPadCount() const { return m_Pads.GetCount() ; } + unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH ) const; double GetArea() const { return m_Surface; }