39#include <wx/settings.h>
42wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
46 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
67 return node ? node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY :
true;
71#define PROGRESS_INTERVAL_MILLIS 33
78 for(
auto it =
m_tree.m_Children.begin(); it !=
m_tree.m_Children.end(); )
80 const wxString&
name = it->get()->m_Name;
110 for(
const wxString& libName :
m_libs->GetLogicalLibs() )
112 if(
m_libMap.count( libName ) == 0 )
151 auto footprintIt = std::lower_bound( footprints.begin(), footprints.end(), &
dummy,
154 return StrNumCmp( a->GetName(), b->GetName(), false ) < 0;
157 if( footprintIt != footprints.end() &&
dummy.GetName() == (*footprintIt)->GetName() )
162 footprints.erase( footprintIt );
181LIB_TREE_NODE::PTR_VECTOR::iterator
186 auto it =
m_tree.m_Children.erase( aLibNodeIt );
198 unsigned int aCol )
const
202 aVariant = wxEmptyString;
216 m_frame->GetBoard()->GetFirstFootprint()->GetFPID().GetUniStringLibItemName();
219 if(
m_frame->GetScreen()->IsContentModified() )
220 aVariant = node->
m_Name + wxT(
" *" );
240 node->
m_Desc =
m_frame->GetBoard()->GetFirstFootprint()->GetLibDescription();
242 else if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
258 descStr.Replace( wxS(
"\n" ), wxS(
" " ) );
272 wxDataViewItemAttr& aAttr )
const
282 if(
m_frame->IsCurrentFPFromBoard() )
286 wxCHECK( node,
false );
290 case LIB_TREE_NODE::TYPE::LIBRARY:
291 if( node->
m_Name ==
m_frame->GetLoadedFPID().GetLibNickname().wx_str() )
296 aAttr.SetStrikethrough(
true );
301 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
302 aAttr.SetBold(
true );
306 case LIB_TREE_NODE::TYPE::ITEM:
310 aAttr.SetStrikethrough(
true );
314 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
315 aAttr.SetBold(
true );
330 wxCHECK( node,
false );
344 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
349 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
350 aParent->SetSizer( mainSizer );
357 mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
367 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
371 preview->GetCanvas()->SetEvtHandlerEnabled(
false );
372 preview->GetCanvas()->StopDrawing();
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
FP_TREE_MODEL_ADAPTER(PCB_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Constructor; takes a set of libraries to be included in the search.
std::vector< LIB_TREE_ITEM * > getFootprints(const wxString &aLibName)
bool HasPreview(const wxDataViewItem &aItem) override
FP_TREE_SYNCHRONIZING_ADAPTER(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
FOOTPRINT_EDIT_FRAME * m_frame
void updateLibrary(LIB_TREE_NODE_LIBRARY &aLibNode)
wxDataViewItem GetCurrentDataViewItem() override
int GetLibrariesCount() const override
Return the number of libraries loaded in the tree.
void ShutdownPreview(wxWindow *aParent) override
bool IsContainer(const wxDataViewItem &aItem) const override
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary(LIB_TREE_NODE::PTR_VECTOR::iterator &aLibNodeIt)
std::set< wxString > m_libMap
TOOL_INTERACTIVE * GetContextMenuTool() override
void Sync(FP_LIB_TABLE *aLibs)
void ShowPreview(wxWindow *aParent, const wxDataViewItem &aItem) override
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
const wxString & GetDescr() const
Return the description of the library referenced by this row.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
LIB_TREE_NODE_ROOT m_tree
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
static wxDataViewItem ToItem(const LIB_TREE_NODE *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
static const wxString GetPinningSymbol()
@ NAME_COL
Library or library item name column.
@ DESC_COL
Library or library description column.
wxDataViewCtrl * m_widget
std::vector< wxString > m_shownColumns
LIB_TREE_NODE_LIBRARY & DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
wxDataViewItem FindItem(const LIB_ID &aLibId)
Returns tree item corresponding to part.
void Update(LIB_TREE_ITEM *aItem)
Update the node using data from a LIB_ALIAS object.
LIB_TREE_NODE_ITEM & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void AssignIntrinsicRanks(const std::vector< wxString > &aShownColumns, bool presorted=false)
Store intrinsic ranks on all children of this node.
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_fp_libs
static const wxString c_previewName