23#include <wx/tokenzr.h>
42#define PROGRESS_INTERVAL_MILLIS 33
45wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
49 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
69 std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter =
nullptr;
73 progressReporter = std::make_unique<WX_PROGRESS_REPORTER>( aFrame,
74 _(
"Loading Symbol Libraries" ),
75 aNicknames.size(),
true );
81 std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
84 progressReporter.get() );
90 while( !loader.
Done() )
92 if( progressReporter && !progressReporter->KeepRefreshing() )
100 bool cancelled =
false;
102 if( progressReporter )
103 cancelled = progressReporter->IsCancelled();
112 msg.Replace(
"\n",
"<BR>" );
118 if( loadedSymbols.size() > 0 )
124 [&](
const wxString& aLibName, std::vector<LIB_SYMBOL*> aSymbolList,
125 const wxString& aDescription )
127 std::vector<LIB_TREE_ITEM*> treeItems( aSymbolList.begin(), aSymbolList.end() );
131 DoAddLibrary( aLibName, aDescription, treeItems, pinned,
false );
134 for(
const std::pair<
const wxString, std::vector<LIB_SYMBOL*>>& pair : loadedSymbols )
138 wxCHECK2( row,
continue );
143 std::vector<wxString> additionalColumns;
146 for(
const wxString& column : additionalColumns )
151 std::vector<wxString> subLibraries;
156 for(
const wxString& lib : subLibraries )
158 wxString suffix = lib.IsEmpty() ? wxString( wxT(
"" ) )
159 : wxString::Format( wxT(
" - %s" ), lib );
160 wxString
name = wxString::Format( wxT(
"%s%s" ), pair.first, suffix );
163 if( !parentDesc.IsEmpty() )
164 desc = wxString::Format( wxT(
"%s (%s)" ), parentDesc, lib );
166 std::vector<LIB_SYMBOL*> symbols;
168 std::copy_if( pair.second.begin(), pair.second.end(),
169 std::back_inserter( symbols ),
172 return lib.IsSameAs( aSym->GetLibId().GetSubLibraryName() );
175 addFunc(
name, symbols, desc );
189 if( progressReporter )
196 progressReporter.reset();
206 bool onlyPowerSymbols = (
GetFilter() != nullptr );
207 std::vector<LIB_SYMBOL*> symbols;
208 std::vector<LIB_TREE_ITEM*> comp_list;
216 wxLogError(
_(
"Error loading symbol library '%s'." ) + wxS(
"\n%s" ),
222 if( symbols.size() > 0 )
224 comp_list.assign( symbols.begin(), symbols.end() );
The base frame for deriving all KiCad main window classes.
void MessageSet(const wxString &message)
Add a message (in bold) to message list.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
static void CreateNilUuids(bool aNil=true)
A performance optimization which disables/enables the generation of pseudo-random UUIDs.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
bool GetIsVisible() const
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
const wxString GetDescription(const wxString &aNickname)
LIB_TREE_NODE_ROOT m_tree
void addColumnIfNecessary(const wxString &aHeader)
void 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.
std::function< bool(LIB_TREE_NODE &aNode)> * GetFilter() const
Return the active filter.
std::vector< wxString > m_availableColumns
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
bool Done()
Returns a string containing any errors generated during the load.
const wxString & GetErrors() const
Represents a pair of <nickname, loaded parts list>
void Start()
Spins up threads to load all the libraries in m_nicknames.
bool Join()
Finalizes the threads and combines the output into the target output map.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void GetAvailableSymbolFields(std::vector< wxString > &aNames) const
void GetSubLibraryNames(std::vector< wxString > &aNames) const
bool SupportsSubLibraries() const
void LoadSymbolLib(std::vector< LIB_SYMBOL * > &aAliasList, const wxString &aNickname, bool aPowerSymbolsOnly=false)
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
wxString GenerateInfo(LIB_ID const &aLibId, int aUnit) override
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
bool AddLibraries(const std::vector< wxString > &aNicknames, SCH_BASE_FRAME *aFrame)
Add all the libraries in a SYMBOL_LIB_TABLE to the model.
static bool m_show_progress
Flag to only show the symbol library table load progress dialog the first time.
void AddLibrary(wxString const &aLibNickname, bool pinned)
~SYMBOL_TREE_MODEL_ADAPTER()
Destructor.
SYMBOL_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Constructor; takes a set of libraries to be included in the search.
SYMBOL_LIB_TABLE * m_libs
Abstract pattern-matching tool and implementations.
wxString GenerateAliasInfo(SYMBOL_LIB_TABLE *aSymLibTable, LIB_ID const &aLibId, int aUnit)
Return an HTML page describing a LIB_ID in a SYMBOL_LIB_TABLE.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< wxString > pinned_symbol_libs
#define PROGRESS_INTERVAL_MILLIS