diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index a4700b3774..b44f8d1481 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -719,25 +719,34 @@ unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const { - std::set usedNumbers; + std::set usedNames; // Create a set of used pad numbers for( D_PAD* pad = Pads(); pad; pad = pad->Next() ) { + // Skip pads not on copper layers (used to build complex + // solder paste shapes for instance) + if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none() ) + continue; + + // Skip pads with no name, because they are usually "mechanical" + // pads, not "electrical" pads + if( pad->GetPadName().IsEmpty() ) + continue; + if( !aIncludeNPTH ) { - //remove NPTH + // skip NPTH if( pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ) { continue; } } - int padNumber = getTrailingInt( pad->GetPadName() ); - usedNumbers.insert( padNumber ); + usedNames.insert( pad->GetPackedPadName() ); } - return usedNumbers.size(); + return usedNames.size(); } diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 2d56894f09..fedc62eaa0 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -499,6 +499,10 @@ public: /** * GetUniquePadCount * returns the number of unique pads. + * A complex pad can be built with many pads having the same pad name + * to create a complex shape or fragmented solder paste areas. + * + * GetUniquePadCount calculate the count of not blank pad names * * @param aIncludeNPTH includes non-plated through holes when true. Does not include * non-plated through holes when false. diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index ac24696ef4..03340d7b28 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -105,9 +105,27 @@ public: MODULE* GetParent() const { return (MODULE*) m_Parent; } + /** + * Set the pad name (sometimes called pad number, although + * it can be an array ref like AA12 + * the pad name is limited to 4 ASCII chars + */ void SetPadName( const wxString& name ); // Change pad name + + /** + * @return the pad name + * the pad name is limited to 4 ASCII chars + */ const wxString GetPadName() const; + /** + * @return the pad name in a wxUint32 which is possible + * because the pad name is limited to 4 ASCII chars + * The packed pad name should be used only to compare 2 + * pad names, not to try to print this name + */ + const wxUint32 GetPackedPadName() const { return m_NumPadName; } + /*! * Function IncrementItemReference * Implementation of the generic "reference" incrementing interface