42#include <wx/settings.h>
45wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
49 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
70 return node ? node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY :
true;
79 for(
auto it =
m_tree.m_Children.begin(); it !=
m_tree.m_Children.end(); )
81 const wxString&
name = it->get()->m_Name;
86 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow(
name );
87 std::optional<LIB_STATUS> libStatus =
m_libs->GetLibraryStatus(
name );
89 bool loadFailed = libStatus.has_value()
92 if( !optRow.has_value()
93 || ( *optRow )->Disabled()
94 || ( *optRow )->Hidden()
118 for(
const auto& [libName, status] :
m_libs->GetLibraryStatuses() )
123 if(
m_libMap.count( libName ) != 0 )
126 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow( libName );
128 if( !optRow.has_value() || ( *optRow )->Disabled() || ( *optRow )->Hidden() )
134 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( libName,
true );
135 std::vector<LIB_TREE_ITEM*> treeItems;
136 treeItems.reserve( footprints.size() );
139 treeItems.push_back( fp );
141 DoAddLibrary( libName, ( *optRow )->Description(), treeItems, pinned,
true );
152 return m_libs->GetLibraryNames().size();
162 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( aLibNode.
m_Name,
true );
165 std::map<wxString, FOOTPRINT*> fpMap;
168 fpMap[fp->GetFPID().GetLibItemName()] = fp;
173 auto fpIt = fpMap.find( (*nodeIt)->m_Name );
175 if( fpIt != fpMap.end() )
188 for(
auto& [
name, fp] : fpMap )
196LIB_TREE_NODE::PTR_VECTOR::iterator
201 auto it =
m_tree.m_Children.erase( aLibNodeIt );
213 unsigned int aCol )
const
217 aVariant = wxEmptyString;
231 m_frame->GetBoard()->GetFirstFootprint()->GetFPID().GetUniStringLibItemName();
234 if(
m_frame->GetScreen()->IsContentModified() )
235 aVariant = node->
m_Name + wxT(
" *" );
255 node->
m_Desc =
m_frame->GetBoard()->GetFirstFootprint()->GetLibDescription();
257 else if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
267 descStr.Replace( wxS(
"\n" ), wxS(
" " ) );
281 wxDataViewItemAttr& aAttr )
const
291 if(
m_frame->IsCurrentFPFromBoard() )
295 wxCHECK( node,
false );
299 case LIB_TREE_NODE::TYPE::LIBRARY:
300 if( node->
m_Name ==
m_frame->GetLoadedFPID().GetLibNickname().wx_str() )
305 aAttr.SetStrikethrough(
true );
310 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
311 aAttr.SetBold(
true );
315 case LIB_TREE_NODE::TYPE::ITEM:
319 aAttr.SetStrikethrough(
true );
323 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
324 aAttr.SetBold(
true );
339 wxCHECK( node,
false );
353 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
358 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
359 aParent->SetSizer( mainSizer );
366 mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
376 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
380 preview->GetCanvas()->SetEvtHandlerEnabled(
false );
381 preview->GetCanvas()->StopDrawing();
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
FOOTPRINT_LIBRARY_ADAPTER * m_libs
FP_TREE_MODEL_ADAPTER(PCB_BASE_FRAME *aParent, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
Constructor; takes a set of libraries to be included in the search.
FP_TREE_SYNCHRONIZING_ADAPTER(FOOTPRINT_EDIT_FRAME *aFrame, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
bool HasPreview(const wxDataViewItem &aItem) override
void Sync(FOOTPRINT_LIBRARY_ADAPTER *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)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
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
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary(LIB_TREE_NODE::PTR_VECTOR::iterator &aLibNodeIt)
std::set< wxString > m_libMap
TOOL_INTERACTIVE * GetContextMenuTool() override
void ShowPreview(wxWindow *aParent, const wxDataViewItem &aItem) override
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
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.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global program "get" accessor.
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_fp_libs
static const wxString c_previewName