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 FilterByTextPattern (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_FP_FILTER = 0x0001, FILTERING_BY_PIN_COUNT = 0x0002, FILTERING_BY_LIBRARY = 0x0004,
  FILTERING_BY_TEXT_PATTERN = 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
 
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_pattern_filters
 
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

◆ FP_FILTER_T

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_FP_FILTER 
FILTERING_BY_PIN_COUNT 
FILTERING_BY_LIBRARY 
FILTERING_BY_TEXT_PATTERN 

Definition at line 128 of file footprint_filter.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_FILTER() [1/2]

FOOTPRINT_FILTER::FOOTPRINT_FILTER ( FOOTPRINT_LIST aList)

Construct a filter.

Parameters
aList- unfiltered list of footprints

Definition at line 164 of file footprint_filter.cpp.

164  : FOOTPRINT_FILTER()
165 {
166  SetList( aList );
167 }
void SetList(FOOTPRINT_LIST &aList)
Set the list to filter.
FOOTPRINT_FILTER()
Construct a filter without assigning a footprint list.

References SetList().

◆ FOOTPRINT_FILTER() [2/2]

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 170 of file footprint_filter.cpp.

Member Function Documentation

◆ begin()

FOOTPRINT_FILTER_IT FOOTPRINT_FILTER::begin ( )

Get an iterator to the beginning of the filtered view.

Definition at line 232 of file footprint_filter.cpp.

233 {
234  return FOOTPRINT_FILTER_IT( *this );
235 }
FOOTPRINT_FILTER::ITERATOR FOOTPRINT_FILTER_IT

◆ ClearFilters()

void FOOTPRINT_FILTER::ClearFilters ( )

Clear all filter criteria.

Definition at line 182 of file footprint_filter.cpp.

References m_filter_type, and UNFILTERED_FP_LIST.

Referenced by FOOTPRINT_SELECT_WIDGET::ClearFilters().

◆ end()

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 238 of file footprint_filter.cpp.

239 {
240  FOOTPRINT_FILTER_IT end_it( *this );
241  end_it.m_pos = m_list ? m_list->GetCount() : 0;
242  return end_it;
243 }
unsigned GetCount() const
FOOTPRINT_LIST * m_list
Inner iterator class returned by begin() and end().

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

◆ FilterByFootprintFilters()

void FOOTPRINT_FILTER::FilterByFootprintFilters ( wxArrayString const &  aFilters)

Set a list of footprint filters to filter by.

Definition at line 202 of file footprint_filter.cpp.

203 {
204  m_footprint_filters.clear();
205 
206  for( const wxString& each_pattern : aFilters )
207  {
208  m_footprint_filters.push_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD_EXPLICIT>() );
209  m_footprint_filters.back()->SetPattern( each_pattern.Lower() );
210  }
211 
213 }
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_footprint_filters

References FILTERING_BY_COMPONENT_FP_FILTER, m_filter_type, and m_footprint_filters.

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

◆ FilterByLibrary()

void FOOTPRINT_FILTER::FilterByLibrary ( wxString const &  aLibName)

Add library name to filter criteria.

Definition at line 188 of file footprint_filter.cpp.

References FILTERING_BY_LIBRARY, m_filter_type, and m_lib_name.

Referenced by FOOTPRINTS_LISTBOX::SetFootprints().

◆ FilterByPinCount()

void FOOTPRINT_FILTER::FilterByPinCount ( int  aPinCount)

◆ FilterByTextPattern()

void FOOTPRINT_FILTER::FilterByTextPattern ( wxString const &  aPattern)

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

Definition at line 216 of file footprint_filter.cpp.

217 {
218  m_filter_pattern = aPattern;
219 
220  wxStringTokenizer tokenizer( aPattern.Lower() );
221 
222  while( tokenizer.HasMoreTokens() )
223  {
224  const wxString term = tokenizer.GetNextToken().Lower();
225  m_pattern_filters.push_back( std::make_unique<EDA_COMBINED_MATCHER>( term ) );
226  }
227 
229 }
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_pattern_filters

References FILTERING_BY_TEXT_PATTERN, m_filter_pattern, m_filter_type, and m_pattern_filters.

Referenced by FOOTPRINTS_LISTBOX::SetFootprints().

◆ SetList()

void FOOTPRINT_FILTER::SetList ( FOOTPRINT_LIST aList)

Set the list to filter.

Definition at line 176 of file footprint_filter.cpp.

177 {
178  m_list = &aList;
179 }
FOOTPRINT_LIST * m_list

References m_list.

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

Member Data Documentation

◆ m_filter_pattern

wxString FOOTPRINT_FILTER::m_filter_pattern
private

Definition at line 140 of file footprint_filter.h.

Referenced by FilterByTextPattern().

◆ m_filter_type

int FOOTPRINT_FILTER::m_filter_type
private

◆ m_footprint_filters

std::vector<std::unique_ptr<EDA_PATTERN_MATCH> > FOOTPRINT_FILTER::m_footprint_filters
private

Definition at line 145 of file footprint_filter.h.

Referenced by FilterByFootprintFilters().

◆ m_lib_name

wxString FOOTPRINT_FILTER::m_lib_name
private

Definition at line 139 of file footprint_filter.h.

Referenced by FilterByLibrary().

◆ m_list

FOOTPRINT_LIST* FOOTPRINT_FILTER::m_list
private

Definition at line 137 of file footprint_filter.h.

Referenced by FOOTPRINT_FILTER::ITERATOR::dereference(), end(), and SetList().

◆ m_pattern_filters

std::vector<std::unique_ptr<EDA_COMBINED_MATCHER> > FOOTPRINT_FILTER::m_pattern_filters
private

Definition at line 144 of file footprint_filter.h.

Referenced by FilterByTextPattern().

◆ m_pin_count

int FOOTPRINT_FILTER::m_pin_count
private

Definition at line 141 of file footprint_filter.h.

Referenced by FilterByPinCount().


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