KiCad PCB EDA Suite
Loading...
Searching...
No Matches
FOOTPRINT_SELECT_WIDGET Class Reference

#include <footprint_select_widget.h>

Inheritance diagram for FOOTPRINT_SELECT_WIDGET:

Public Member Functions

 FOOTPRINT_SELECT_WIDGET (EDA_DRAW_FRAME *aFrame, wxWindow *aParent, FOOTPRINT_LIST *aFpList, bool aUpdate=true, int aMaxItems=400)
 Construct a footprint selector widget. More...
 
virtual ~FOOTPRINT_SELECT_WIDGET ()
 
void Load (KIWAY &aKiway, PROJECT &aProject)
 Start loading. More...
 
void ClearFilters ()
 Clear all filters. More...
 
void FilterByPinCount (int aPinCount)
 Filter by pin count. More...
 
void FilterByFootprintFilters (const wxArrayString &aFilters, bool aZeroFilters)
 Filter by footprint filter list. More...
 
void SetDefaultFootprint (const wxString &aFp)
 Set the default footprint for a part. More...
 
bool UpdateList ()
 Update the contents of the list to match the filters. More...
 
void SelectDefault ()
 Set current selection to the default footprint. More...
 
virtual bool Enable (bool aEnable=true) override
 Enable or disable the control for input. More...
 

Private Member Functions

void OnComboBox (wxCommandEvent &aEvent)
 

Private Attributes

FOOTPRINT_CHOICEm_fp_sel_ctrl
 
wxSizer * m_sizer
 
bool m_update
 
int m_max_items
 
wxString m_default_footprint
 
FOOTPRINT_LISTm_fp_list
 
FOOTPRINT_FILTER m_fp_filter
 
bool m_zero_filter
 
EDA_DRAW_FRAMEm_frame
 

Detailed Description

Definition at line 39 of file footprint_select_widget.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_SELECT_WIDGET()

FOOTPRINT_SELECT_WIDGET::FOOTPRINT_SELECT_WIDGET ( EDA_DRAW_FRAME aFrame,
wxWindow *  aParent,
FOOTPRINT_LIST aFpList,
bool  aUpdate = true,
int  aMaxItems = 400 
)

Construct a footprint selector widget.

This requires references to an external footprint loader, and an external unique_ptr-to-FOOTPRINT_LIST. The latter will be populated with a FOOTPRINT_LIST instance the first time Load() is called.

The reason for this is that footprint loading tends to be very expensive, especially when using online libraries. The caller is expected to keep these objects around (e.g. they may be statics on the dialog this FOOTPRINT_SELECT_WIDGET is created in) so footprints do not have to be loaded more than once.

Parameters
aParent- parent window
aFpList- FOOTPRINT_LIST container
aUpdate- whether to call UpdateList() automatically when finished loading
aMaxItems- maximum number of filter items to display, in addition to Default and Other

Definition at line 36 of file footprint_select_widget.cpp.

References m_fp_sel_ctrl, m_sizer, m_zero_filter, and OnComboBox().

◆ ~FOOTPRINT_SELECT_WIDGET()

virtual FOOTPRINT_SELECT_WIDGET::~FOOTPRINT_SELECT_WIDGET ( )
inlinevirtual

Definition at line 64 of file footprint_select_widget.h.

Member Function Documentation

◆ ClearFilters()

void FOOTPRINT_SELECT_WIDGET::ClearFilters ( )

Clear all filters.

Does not update the list.

Definition at line 106 of file footprint_select_widget.cpp.

References FOOTPRINT_FILTER::ClearFilters(), m_default_footprint, m_fp_filter, and m_zero_filter.

Referenced by PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

◆ Enable()

bool FOOTPRINT_SELECT_WIDGET::Enable ( bool  aEnable = true)
overridevirtual

Enable or disable the control for input.

Definition at line 177 of file footprint_select_widget.cpp.

References m_fp_sel_ctrl.

Referenced by PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

◆ FilterByFootprintFilters()

void FOOTPRINT_SELECT_WIDGET::FilterByFootprintFilters ( const wxArrayString &  aFilters,
bool  aZeroFilters 
)

Filter by footprint filter list.

Does not update the list.

Parameters
aFiltersis a wxArrayString of strings used to filter the list of available footprints (can be empty). The final fp list is the list of footprint names matching at least one filtering string. A filtering string is something like sm0402 or DIP*
aZeroFilters- if true, zero filters = zero footprints. If false, zero filters = not filtering.

Definition at line 120 of file footprint_select_widget.cpp.

References FOOTPRINT_FILTER::FilterByFootprintFilters(), m_fp_filter, and m_zero_filter.

Referenced by PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

◆ FilterByPinCount()

void FOOTPRINT_SELECT_WIDGET::FilterByPinCount ( int  aPinCount)

Filter by pin count.

Does not update the list.

Definition at line 114 of file footprint_select_widget.cpp.

References FOOTPRINT_FILTER::FilterByPinCount(), and m_fp_filter.

Referenced by PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

◆ Load()

void FOOTPRINT_SELECT_WIDGET::Load ( KIWAY aKiway,
PROJECT aProject 
)

Start loading.

This function returns immediately; footprints will continue to load in the background.

Parameters
aKiway- active kiway instance. This is cached for use when "Other" is selected.
aProject- current project

Definition at line 58 of file footprint_select_widget.cpp.

References _, FOOTPRINT_LIST::GetCount(), FOOTPRINT_LIST::GetInstance(), m_fp_filter, m_fp_list, m_frame, m_update, PROJECT::PcbFootprintLibs(), FOOTPRINT_FILTER::SetList(), and UpdateList().

Referenced by PANEL_SYMBOL_CHOOSER::FinishSetup().

◆ OnComboBox()

void FOOTPRINT_SELECT_WIDGET::OnComboBox ( wxCommandEvent &  aEvent)
private

Definition at line 89 of file footprint_select_widget.cpp.

References m_fp_sel_ctrl.

Referenced by FOOTPRINT_SELECT_WIDGET().

◆ SelectDefault()

void FOOTPRINT_SELECT_WIDGET::SelectDefault ( )

Set current selection to the default footprint.

Definition at line 171 of file footprint_select_widget.cpp.

References m_fp_sel_ctrl.

Referenced by UpdateList().

◆ SetDefaultFootprint()

void FOOTPRINT_SELECT_WIDGET::SetDefaultFootprint ( const wxString &  aFp)

Set the default footprint for a part.

This will be listed at the top. May be an empty string.

Definition at line 128 of file footprint_select_widget.cpp.

References m_default_footprint.

Referenced by PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

◆ UpdateList()

bool FOOTPRINT_SELECT_WIDGET::UpdateList ( )

Update the contents of the list to match the filters.

Has no effect if the footprint list has not been loaded yet. The "default" footprint will be selected.

Returns
true if the footprint list has been loaded (and the list was updated)

Definition at line 134 of file footprint_select_widget.cpp.

References _, m_default_footprint, m_fp_filter, m_fp_list, m_fp_sel_ctrl, m_max_items, m_zero_filter, and SelectDefault().

Referenced by Load(), and PANEL_SYMBOL_CHOOSER::populateFootprintSelector().

Member Data Documentation

◆ m_default_footprint

wxString FOOTPRINT_SELECT_WIDGET::m_default_footprint
private

Definition at line 131 of file footprint_select_widget.h.

Referenced by ClearFilters(), SetDefaultFootprint(), and UpdateList().

◆ m_fp_filter

FOOTPRINT_FILTER FOOTPRINT_SELECT_WIDGET::m_fp_filter
private

◆ m_fp_list

FOOTPRINT_LIST* FOOTPRINT_SELECT_WIDGET::m_fp_list
private

Definition at line 133 of file footprint_select_widget.h.

Referenced by Load(), and UpdateList().

◆ m_fp_sel_ctrl

FOOTPRINT_CHOICE* FOOTPRINT_SELECT_WIDGET::m_fp_sel_ctrl
private

◆ m_frame

EDA_DRAW_FRAME* FOOTPRINT_SELECT_WIDGET::m_frame
private

Definition at line 136 of file footprint_select_widget.h.

Referenced by Load().

◆ m_max_items

int FOOTPRINT_SELECT_WIDGET::m_max_items
private

Definition at line 130 of file footprint_select_widget.h.

Referenced by UpdateList().

◆ m_sizer

wxSizer* FOOTPRINT_SELECT_WIDGET::m_sizer
private

Definition at line 127 of file footprint_select_widget.h.

Referenced by FOOTPRINT_SELECT_WIDGET().

◆ m_update

bool FOOTPRINT_SELECT_WIDGET::m_update
private

Definition at line 129 of file footprint_select_widget.h.

Referenced by Load().

◆ m_zero_filter

bool FOOTPRINT_SELECT_WIDGET::m_zero_filter
private

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