49 const LIB_ID& aPreselectedLibId,
50 int aUnit,
int aConvert )
63 if( aPreselectedLibId.
IsValid() )
76 if( viewer->
ShowModal( &symbol, aParent ) )
80 if(
id.Parse( symbol ) == -1 )
94 std::vector<PICKED_SYMBOL>& aHistoryList,
95 bool aUseLibBrowser,
int aUnit,
int aConvert,
96 bool aShowFootprints,
const LIB_ID* aHighlight,
105 if( !dialogLock.try_lock() )
113 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> dataPtr
123 for(
const wxString& nickname : liblist )
143 std::vector<LIB_SYMBOL> history_list_storage;
144 std::vector<LIB_TREE_ITEM*> history_list;
146 history_list_storage.reserve( aHistoryList.size() );
155 history_list_storage.emplace_back( *symbol );
157 for(
const std::pair<int, wxString>& fieldDef : i.Fields )
159 LIB_FIELD* field = history_list_storage.back().GetFieldById( fieldDef.first );
162 field->
SetText( fieldDef.second );
165 history_list.push_back( &history_list_storage.back() );
169 modelAdapter->
DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
170 history_list,
false,
true );
172 if( !aHistoryList.empty() )
173 modelAdapter->
SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
175 const std::vector< wxString > libNicknames = libs->
GetLogicalLibs();
186 if( aHighlight && aHighlight->
IsValid() )
189 wxString dialogTitle;
192 dialogTitle.Printf(
_(
"Choose Power Symbol (%d items loaded)" ), dataPtr->GetItemCount() );
194 dialogTitle.Printf(
_(
"Choose Symbol (%d items loaded)" ), dataPtr->GetItemCount() );
199 int ret = dlg.ShowModal();
204 if( ret == wxID_CANCEL )
234 aHistoryList.insert( aHistoryList.begin(), sel );
251 if( unitCount <= 1 || aSymbol->GetUnit() == aUnit )
254 if( aUnit > unitCount )
264 if( !commit.
Empty() )
266 if(
eeconfig()->m_AutoplaceFields.enable )
269 commit.
Push(
_(
"Change Unit" ) );
286 msg.Printf(
_(
"No alternate body style found for symbol '%s' in library '%s'." ),
287 id.GetLibItemName().wx_str(),
288 id.GetLibNickname().wx_str() );
309 commit.
Push(
_(
"Convert Symbol" ) );
321 if( aFunction == aPin->
GetName() )
322 aPin->
SetAlt( wxEmptyString );
324 aPin->
SetAlt( aFunction );
326 commit.
Push(
_(
"Set Pin Function" ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
bool Empty() const
Returns status of an item.
Dialog class to select a symbol from the libraries.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
static std::mutex g_Mutex
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
bool IsExternalBrowserSelected() const
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM_FLAGS GetEditFlags() const
virtual void SetText(const wxString &aText)
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Field object used in symbol libraries.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
int GetUnitCount() const override
For items with units, return the number of units.
bool GetIsVisible() const
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
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.
void SetFilter(SYM_FILTER_TYPE aFilter)
Set the symbol filter type.
void AssignIntrinsicRanks()
Sort the tree and assign ranks after adding libraries.
SYM_FILTER_TYPE GetFilter() const
Return the active filter.
void SaveSettings()
Save the column widths to the config file.
@ SYM_FILTER_POWER
list symbols flagged PWR
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
PICKED_SYMBOL PickSymbolFromLibBrowser(wxTopLevelWindow *aParent, const SYMBOL_LIBRARY_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
Call the library viewer to select symbol to import into schematic.
PICKED_SYMBOL PickSymbolFromLibTree(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
void ConvertPart(SCH_SYMBOL *aSymbol)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetAltPinFunction(SCH_PIN *aPin, const wxString &aFunction)
SCH_SHEET_PATH & GetCurrentSheet() const
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
void SetAlt(const wxString &aAlt)
void SetConvert(int aConvert)
void SetUnit(int aUnit)
Change the unit number to aUnit.
const LIB_ID & GetLibId() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Helper object to filter a list of libraries.
bool GetFilterPowerSymbols() const
const wxArrayString & GetAllowedLibList() const
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...
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.
void AddLibrary(wxString const &aLibNickname, bool pinned)
Symbol library viewer main window.
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
void SetSelectedLibrary(const wxString &aLibName, const wxString &aSubLibName=wxEmptyString)
Set the selected library in the library window.
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Runs the symbol viewer as a modal dialog.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
void SetFilter(const SYMBOL_LIBRARY_FILTER *aFilter)
Set a filter to display only libraries and/or symbols which match the filter.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
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
std::vector< std::pair< int, wxString > > Fields