KiCad PCB EDA Suite
FOOTPRINT_FILTER Class Reference

Footprint display filter. More...

#include <footprint_filter.h>

Classes

class  ITERATOR
 Inner iterator class returned by begin() and end(). More...
 

Public Member Functions

 FOOTPRINT_FILTER (FOOTPRINT_LIST &aList)
 Construct a filter. More...
 
 FOOTPRINT_FILTER ()
 Construct a filter without assigning a footprint list. More...
 
void SetList (FOOTPRINT_LIST &aList)
 Set the list to filter. More...
 
void ClearFilters ()
 Clear all filter criteria. More...
 
void FilterByLibrary (wxString const &aLibName)
 Add library name to filter criteria. More...
 
void FilterByPinCount (int aPinCount)
 Set a pin count to filter by. More...
 
void FilterByFootprintFilters (wxArrayString const &aFilters)
 Set a list of footprint filters to filter by. More...
 
void FilterByPattern (wxString const &aPattern)
 Add a pattern to filter by name, including wildcards and optionally a colon-delimited library name. More...
 
ITERATOR begin ()
 Get an iterator to the beginning of the filtered view. More...
 
ITERATOR end ()
 Get an iterator to the end of the filtered view. More...
 

Private Types

enum  FP_FILTER_T : int {
  UNFILTERED_FP_LIST = 0, FILTERING_BY_COMPONENT_KEYWORD = 0x0001, FILTERING_BY_PIN_COUNT = 0x0002, FILTERING_BY_LIBRARY = 0x0004,
  FILTERING_BY_NAME = 0x0008
}
 Filter setting constants. More...
 

Private Attributes

FOOTPRINT_LISTm_list
 
wxString m_lib_name
 
wxString m_filter_pattern
 
int m_pin_count
 
int m_filter_type
 
EDA_PATTERN_MATCH_WILDCARD m_filter
 
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_footprint_filters
 

Detailed Description

Footprint display filter.

Takes a list of footprints and filtering settings, and provides an iterable view of the filtered data.

Definition at line 32 of file footprint_filter.h.

Member Enumeration Documentation

enum FOOTPRINT_FILTER::FP_FILTER_T : int
private

Filter setting constants.

The filter type is a bitwise OR of these flags, and only footprints matching all selected filter types are shown.

Enumerator
UNFILTERED_FP_LIST 
FILTERING_BY_COMPONENT_KEYWORD 
FILTERING_BY_PIN_COUNT 
FILTERING_BY_LIBRARY 
FILTERING_BY_NAME 

Definition at line 128 of file footprint_filter.h.

Constructor & Destructor Documentation

FOOTPRINT_FILTER::FOOTPRINT_FILTER ( FOOTPRINT_LIST aList)

Construct a filter.

Parameters
aList- unfiltered list of footprints

Definition at line 160 of file footprint_filter.cpp.

References SetList().

160  : FOOTPRINT_FILTER()
161 {
162  SetList( aList );
163 }
void SetList(FOOTPRINT_LIST &aList)
Set the list to filter.
FOOTPRINT_FILTER()
Construct a filter without assigning a footprint list.
FOOTPRINT_FILTER::FOOTPRINT_FILTER ( )

Construct a filter without assigning a footprint list.

The filter MUST NOT be iterated over until SetList() is called.

Definition at line 166 of file footprint_filter.cpp.

Member Function Documentation

FOOTPRINT_FILTER_IT FOOTPRINT_FILTER::begin ( )

Get an iterator to the beginning of the filtered view.

Definition at line 220 of file footprint_filter.cpp.

221 {
222  return FOOTPRINT_FILTER_IT( *this );
223 }
FOOTPRINT_FILTER::ITERATOR FOOTPRINT_FILTER_IT
void FOOTPRINT_FILTER::ClearFilters ( )

Clear all filter criteria.

Definition at line 178 of file footprint_filter.cpp.

References m_filter_type, and UNFILTERED_FP_LIST.

Referenced by FOOTPRINT_SELECT_WIDGET::ClearFilters().

FOOTPRINT_FILTER_IT FOOTPRINT_FILTER::end ( )

Get an iterator to the end of the filtered view.

The end iterator is invalid and may not be dereferenced, only compared against.

Definition at line 226 of file footprint_filter.cpp.

References FOOTPRINT_LIST::GetCount(), m_list, and FOOTPRINT_FILTER::ITERATOR::m_pos.

227 {
228  FOOTPRINT_FILTER_IT end_it( *this );
229  end_it.m_pos = m_list ? m_list->GetCount() : 0;
230  return end_it;
231 }
unsigned GetCount() const
FOOTPRINT_LIST * m_list
Inner iterator class returned by begin() and end().
void FOOTPRINT_FILTER::FilterByFootprintFilters ( wxArrayString const &  aFilters)

Set a list of footprint filters to filter by.

Definition at line 198 of file footprint_filter.cpp.

References FILTERING_BY_COMPONENT_KEYWORD, m_filter_type, and m_footprint_filters.

Referenced by FOOTPRINT_SELECT_WIDGET::FilterByFootprintFilters(), and FOOTPRINTS_LISTBOX::SetFootprints().

199 {
200  m_footprint_filters.clear();
201 
202  for( auto const& each_pattern : aFilters )
203  {
204  m_footprint_filters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_EXPLICIT>() );
205  m_footprint_filters.back()->SetPattern( each_pattern.Lower() );
206  }
207 
209 }
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_footprint_filters
void FOOTPRINT_FILTER::FilterByLibrary ( wxString const &  aLibName)

Add library name to filter criteria.

Definition at line 184 of file footprint_filter.cpp.

References FILTERING_BY_LIBRARY, m_filter_type, and m_lib_name.

Referenced by FOOTPRINTS_LISTBOX::SetFootprints().

void FOOTPRINT_FILTER::FilterByPattern ( wxString const &  aPattern)

Add a pattern to filter by name, including wildcards and optionally a colon-delimited library name.

Definition at line 212 of file footprint_filter.cpp.

References FILTERING_BY_NAME, m_filter, m_filter_pattern, m_filter_type, and EDA_PATTERN_MATCH_WILDCARD::SetPattern().

Referenced by FOOTPRINTS_LISTBOX::SetFootprints().

213 {
214  m_filter_pattern = aPattern;
215  m_filter.SetPattern( aPattern.Lower() );
217 }
virtual bool SetPattern(const wxString &aPattern) override
Set the pattern against which candidates will be matched.
EDA_PATTERN_MATCH_WILDCARD m_filter
void FOOTPRINT_FILTER::FilterByPinCount ( int  aPinCount)
void FOOTPRINT_FILTER::SetList ( FOOTPRINT_LIST aList)

Set the list to filter.

Definition at line 172 of file footprint_filter.cpp.

References m_list.

Referenced by FOOTPRINT_FILTER(), and FOOTPRINT_SELECT_WIDGET::FootprintsLoaded().

173 {
174  m_list = &aList;
175 }
FOOTPRINT_LIST * m_list

Member Data Documentation

EDA_PATTERN_MATCH_WILDCARD FOOTPRINT_FILTER::m_filter
private

Definition at line 143 of file footprint_filter.h.

Referenced by FilterByPattern(), and FOOTPRINT_FILTER::ITERATOR::increment().

wxString FOOTPRINT_FILTER::m_filter_pattern
private

Definition at line 140 of file footprint_filter.h.

Referenced by FilterByPattern(), and FOOTPRINT_FILTER::ITERATOR::increment().

int FOOTPRINT_FILTER::m_filter_type
private
std::vector<std::unique_ptr<EDA_PATTERN_MATCH> > FOOTPRINT_FILTER::m_footprint_filters
private
wxString FOOTPRINT_FILTER::m_lib_name
private

Definition at line 139 of file footprint_filter.h.

Referenced by FilterByLibrary(), and FOOTPRINT_FILTER::ITERATOR::increment().

FOOTPRINT_LIST* FOOTPRINT_FILTER::m_list
private
int FOOTPRINT_FILTER::m_pin_count
private

The documentation for this class was generated from the following files: