47#include <wx/clipbrd.h>
48#include <wx/filedlg.h>
68 title += wxS(
" " ) +
_(
"[from schematic]" );
78 title += wxS(
" " ) +
_(
"[Read Only Library]" );
82 title =
_(
"[no symbol loaded]" );
85 title += wxT(
" \u2014 " ) +
_(
"Symbol Editor" );
92 wxString selectedLib = aLibrary;
94 if( selectedLib.empty() )
97 if( !selectedLib.empty() )
130 wxString msg = wxString::Format(
_(
"Symbol library '%s' is not writable." ),
132 wxString msg2 =
_(
"You must save to a different location." );
155 if( lib->SchLibType() == SCH_IO_MGR::SCH_DATABASE
156 || lib->SchLibType() == SCH_IO_MGR::SCH_CADSTAR_ARCHIVE
157 || lib->SchLibType() == SCH_IO_MGR::SCH_HTTP )
171 msg.Printf(
_(
"Error loading symbol %s from library '%s'." ),
237 msg.Printf(
_(
"Error loading symbol %s from library '%s'." ),
262 int aUnit,
int aBodyStyle )
264 bool rebuildMenuAndToolbar =
false;
266 if( !aEntry || aLibrary.empty() )
269 if( aEntry->
GetName().IsEmpty() )
271 wxLogWarning(
"Symbol in library '%s' has empty name field.", aLibrary );
287 rebuildMenuAndToolbar =
true;
291 wxCHECK( lib_symbol,
false );
293 m_unit = aUnit > 0 ? aUnit : 1;
303 if( rebuildMenuAndToolbar )
348 wxArrayString symbolNames;
359 const auto validator = [&]( wxString newName ) ->
bool
361 if( newName.IsEmpty() )
363 wxMessageBox(
_(
"Symbol must have a name." ) );
369 wxString msg = wxString::Format(
370 _(
"Symbol '%s' already exists in library '%s'." ), newName, lib );
372 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
373 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
381 wxArrayString symbolNamesInLib;
386 dlg.SetMinSize( dlg.GetSize() );
397 if( parentSymbolName.IsEmpty() )
445 wxCHECK( parentField, );
447 *field = *parentField;
465 field->
SetText( wxEmptyString );
494 if( libName.empty() )
500 wxString msg = wxString::Format(
_(
"Symbol library '%s' is not writable." ),
502 wxString msg2 =
_(
"You must save to a different location." );
523 if( !libName.IsEmpty() )
547 std::vector<LIB_SYMBOL_SPTR> chain( { aSymbol.
SharedPtr() } );
549 while( chain.back()->IsAlias() )
552 chain.push_back( parent );
570 const wxString& aNewSymbolName,
571 const wxString& aNewLibraryName )
576 if( aNewLibraryName != oldLibraryName )
577 return {
false,
false };
580 if( !aLibMgr.
SymbolExists( aNewSymbolName, aNewLibraryName ) )
581 return {
false,
false };
583 bool inAncestry =
false;
584 bool inDescendents =
false;
587 const std::vector<LIB_SYMBOL_SPTR> parentChainFromUs =
GetParentChain( aSymbol );
590 for(
size_t i = 1; i < parentChainFromUs.size(); ++i )
593 if( parentChainFromUs[i]->GetName() == aNewSymbolName )
603 const std::vector<LIB_SYMBOL_SPTR> parentChainFromTarget =
GetParentChain( *targetSymbol );
604 const wxString oldSymbolName = aSymbol.
GetName();
608 for(
size_t i = 1; i < parentChainFromTarget.size(); ++i )
610 if( parentChainFromTarget[i]->GetName() == oldSymbolName )
612 inDescendents =
true;
618 return { inAncestry, inDescendents };
631 const wxString& newSymbolName,
632 const wxString& newLibraryName )
634 std::vector<wxString> conflicts;
637 if( newLibraryName == oldLibraryName )
640 if( aLibMgr.
SymbolExists( newSymbolName, newLibraryName ) )
642 conflicts.push_back( newSymbolName );
648 const std::vector<LIB_SYMBOL_SPTR> parentChain =
GetParentChain( aSymbol );
650 for(
size_t i = 0; i < parentChain.size(); ++i )
655 if( aLibMgr.
SymbolExists( newSymbolName, newLibraryName ) )
657 conflicts.push_back( newSymbolName );
663 if( aLibMgr.
SymbolExists( chainSymbol->GetName(), newLibraryName ) )
665 conflicts.push_back( chainSymbol->GetName() );
696 bool aValueFollowsName ) :
701 bool DoSave(
LIB_SYMBOL& symbol,
const wxString& aNewSymName,
const wxString& aNewLibName )
703 std::vector<LIB_SYMBOL_SPTR> parentChain;
707 parentChain.push_back( symbol.
SharedPtr() );
711 std::vector<wxString> newNames;
714 for(
int i = (
int) parentChain.size() - 1; i >= 0; --i )
724 newName = aNewSymName;
729 newName = oldSymbol->GetName();
738 if( i == (
int) parentChain.size() - 1 )
749 wxASSERT( newParent );
753 newNames.push_back( newName );
761 wxString
resolveConflict(
const wxString& proposed,
const wxString& aNewLibName )
const
777 wxString newName = wxString::Format(
"%s_%d", proposed, suffix );
789 wxFAIL_MSG(
"Invalid conflict strategy" );
811 std::function<int(
const wxString& libName,
const wxString& symbolName )>;
823 wxArrayString headers;
824 std::vector<wxArrayString> itemsToDisplay;
826 headers.Add(
_(
"Nickname" ) );
827 headers.Add(
_(
"Description" ) );
829 for(
const wxString& nickname : libNicknames )
837 itemsToDisplay.push_back( item );
841 for(
const wxString& nickname : libNicknames )
847 item.Add( nickname );
849 itemsToDisplay.push_back( item );
853 initDialog( headers, itemsToDisplay, aLibraryPreselect );
858 wxBoxSizer* bNameSizer =
new wxBoxSizer( wxHORIZONTAL );
860 wxStaticText* label =
new wxStaticText(
this, wxID_ANY,
_(
"Name:" ) );
861 bNameSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
868 m_ButtonsSizer->Prepend( newLibraryButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
870 GetSizer()->Prepend( bNameSizer, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
873 [
this]( wxCommandEvent& )
887 GetSizer()->Fit(
this );
895 symbolName.Trim(
true );
896 symbolName.Trim(
false );
897 symbolName.Replace(
" ",
"_" );
906 if( ret == wxID_CANCEL )
940 const auto dialogValidatorFunc = [&](
const wxString& newLib,
const wxString& newName ) ->
int
942 if( newLib.IsEmpty() )
944 wxMessageBox(
_(
"A library must be specified." ) );
948 if( newName.IsEmpty() )
950 wxMessageBox(
_(
"Symbol must have a name." ) );
956 msg = wxString::Format(
_(
"Library '%s' is read-only. Choose a "
957 "different library to save the symbol '%s' to." ),
967 const auto& [inAncestry, inDescendents] =
972 msg = wxString::Format(
_(
"Symbol '%s' cannot replace another symbol '%s' that it "
974 symbolName, newName );
981 msg = wxString::Format(
_(
"Symbol '%s' cannot replace another symbol '%s' that is "
982 "a descendent of it." ),
983 symbolName, newName );
988 const std::vector<wxString> conflicts =
991 if( conflicts.size() == 1 && conflicts.front() == newName )
994 msg = wxString::Format(
_(
"Symbol '%s' already exists in library '%s'."
995 "Do you want to overwrite it?" ),
998 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
999 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
1003 else if( !conflicts.empty() )
1009 msg = wxString::Format(
_(
"The following symbols in the inheritance chain of '%s' "
1010 "already exist in library '%s':\n" ),
1011 symbolName, newLib );
1013 for(
const wxString& conflict : conflicts )
1014 msg += wxString::Format(
" %s\n", conflict );
1016 msg +=
_(
"\nDo you want to overwrite all of them, or rename the new symbols?" );
1018 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ),
1019 wxYES_NO | wxCANCEL | wxICON_WARNING );
1020 errorDlg.SetYesNoCancelLabels(
_(
"Overwrite All" ),
_(
"Rename All" ),
_(
"Cancel" ) );
1039 SAVE_AS_DIALOG dlg(
this, symbolName, libraryName, dialogValidatorFunc, strategy );
1067 libraryName = newLibrary.GetName();
1078 saver.
DoSave( *symbol, symbolName, libraryName );
1098 wxString msg = wxString::Format(
_(
"Symbol name '%s' already in use." ),
1130 if( toDelete.empty() )
1133 for(
LIB_ID& libId : toDelete )
1136 && !
IsOK(
this, wxString::Format(
_(
"The symbol '%s' has been modified.\n"
1137 "Do you want to remove it from the library?" ),
1138 libId.GetUniStringLibItemName() ) ) )
1148 _(
"The symbol %s is used to derive other symbols.\n"
1149 "Deleting this symbol will delete all of the symbols derived from it.\n\n"
1150 "Do you wish to delete this symbol and all of its derivatives?" ),
1151 libId.GetLibItemName().wx_str() );
1153 wxMessageDialog::ButtonLabel yesButtonLabel(
_(
"Delete Symbol" ) );
1154 wxMessageDialog::ButtonLabel noButtonLabel(
_(
"Keep Symbol" ) );
1156 wxMessageDialog dlg(
this, msg,
_(
"Warning" ),
1157 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER );
1158 dlg.SetYesNoLabels( yesButtonLabel, noButtonLabel );
1160 if( dlg.ShowModal() == wxID_NO )
1176 std::vector<LIB_ID> symbols;
1183 for(
LIB_ID& libId : symbols )
1186 libId.GetLibNickname() );
1191 std::unique_ptr<LIB_SYMBOL> tmp = symbol->
Flatten();
1195 std::string prettyData = formatter.
GetString();
1200 auto clipboard = wxTheClipboard;
1201 wxClipboardLocker clipboardLock( clipboard );
1203 if( !clipboardLock || !clipboard->IsOpened() )
1206 auto data =
new wxTextDataObject( wxString( prettyData.c_str(), wxConvUTF8 ) );
1207 clipboard->SetData( data );
1221 std::vector<LIB_SYMBOL*> newSymbols;
1223 if( aFromClipboard )
1233 wxLogMessage( wxS(
"Can not paste: %s" ), e.
Problem() );
1238 newSymbols.emplace_back(
new LIB_SYMBOL( *srcSymbol ) );
1241 if( srcSymbol->IsAlias() )
1243 if( std::shared_ptr<LIB_SYMBOL> srcParent = srcSymbol->GetParent().lock() )
1244 newSymbols.back()->SetParent( srcParent.get() );
1248 if( newSymbols.empty() )
1272 wxString newName = aSymbol->
GetName();
1276 newName.Printf(
"%s_%d", aSymbol->
GetName(), i++ );
1291 wxString msg = wxString::Format(
_(
"Revert '%s' to last version saved?" ),
1292 symbolName.IsEmpty() ? libName : symbolName );
1297 bool reload_currentSymbol =
false;
1298 wxString curr_symbolName = symbolName;
1304 if( symbolName.IsEmpty() )
1309 if( reload_currentSymbol )
1320 if( reload_currentSymbol )
1323 if( symbolName.IsEmpty() )
1336 LoadSymbol( curr_symbolName, libName, unit );
1344 wxCHECK_RET(
m_libMgr,
"Library manager object not created." );
1369 DisplayError(
this, wxString::Format(
_(
"Symbol %s not found in library '%s'." ),
1391 SCH_IO_MGR::SCH_FILE_T
fileType = SCH_IO_MGR::SCH_FILE_T::SCH_KICAD;
1412 fn.SetName( aLibrary );
1417 wxFileDialog dlg(
this, wxString::Format(
_(
"Save Library '%s' As..." ), aLibrary ),
1418 default_path, fn.GetFullName(), wildcards,
1419 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1422 dlg.SetCustomizeHook( saveAsHook );
1424 if( dlg.ShowModal() == wxID_CANCEL )
1431 if( fn.GetExt().IsEmpty() )
1441 if(
fileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
1457 msg.Printf(
_(
"Failed to save changes to symbol library file '%s'." ),
1473 bool resyncLibTree =
false;
1475 wxString forceRefresh;
1479 case SYMBOL_SAVEAS_TYPE::REPLACE_TABLE_ENTRY:
1481 forceRefresh = originalLibNickname;
1484 case SYMBOL_SAVEAS_TYPE::ADD_GLOBAL_TABLE_ENTRY:
1488 case SYMBOL_SAVEAS_TYPE::ADD_PROJECT_TABLE_ENTRY:
1505 msg.Printf(
_(
"Symbol library file '%s' saved." ), fn.GetFullPath() );
1517 bool applyToAll =
false;
1530 if( aRequireConfirmation && !applyToAll )
1532 msg.Printf(
_(
"Save changes to '%s' before closing?" ), libNickname );
1536 case wxID_YES: doSave =
true;
break;
1537 case wxID_NO: doSave =
false;
break;
1539 case wxID_CANCEL:
return false;
1549 msg.Printf(
_(
"Symbol library '%s' is not writable." ), libNickname );
1550 msg2 =
_(
"You must save to a different location." );
1552 if( dirtyCount == 1 )
1564 2000, wxICON_EXCLAMATION );
1604 msg = parent ? parent->GetName() :
_(
"Undefined!" );
1608 static wxChar UnitLetter[] = wxT(
"?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
1609 msg = UnitLetter[
m_unit];
1614 msg =
_(
"Alternate" );
1616 msg =
_(
"Standard" );
1623 msg =
_(
"Power Symbol" );
1625 msg =
_(
"Symbol" );
static TOOL_ACTION cancelInteractive
static TOOL_ACTION zoomFitScreen
void SetContentModified(bool aModified=true)
wxString GetParentSymbolName() const
bool GetIncludeOnBoard() const
wxString GetName() const override
bool GetUnitsInterchangeable()
bool GetAlternateBodyStyle()
bool GetIncludeInBom() const
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void ReCreateMenuBar()
Recreates the menu bar.
WX_INFOBAR * GetInfoBar()
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
virtual void SetParent(EDA_ITEM *aParent)
wxBoxSizer * m_ButtonsSizer
void SetOKLabel(const wxString &aLabel)
void initDialog(const wxArrayString &aItemHeaders, const std::vector< wxArrayString > &aItemList, const wxString &aPreselectText)
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
virtual const wxString & GetText() const
Return the string associated with the text object.
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()
virtual const wxString Problem() const
what was the problem?
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
wxString GetUniStringLibId() const
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Symbol library management helper that is specific to the symbol library editor frame.
Define a library symbol object.
wxString GetDescription() const override
const LIB_ID & GetLibId() const override
wxString GetKeyWords() const override
bool IsMulti() const override
bool IsPower() const override
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
SCH_FIELD & GetValueField() const
Return reference to the value field.
LIB_ID GetSourceLibId() const
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
SCH_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
SCH_FIELD & GetDatasheetField() const
Return reference to the datasheet field.
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
void SetParent(LIB_SYMBOL *aParent=nullptr)
wxString GetName() const override
SCH_FIELD & GetReferenceField() const
Return reference to the reference designator field.
LIB_SYMBOL_SPTR SharedPtr() const
void SetHasAlternateBodyStyle(bool aHasAlternate, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the symbol.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_SYMBOL_REF & GetParent()
virtual void SetName(const wxString &aName)
const wxString GetDescription(const wxString &aNickname)
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.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
static const wxString GetPinningSymbol()
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
Container for project specific data.
virtual PROJECT_FILE & GetProjectFile() const
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
bool TransferDataFromWindow() override
wxTextCtrl * m_symbolNameCtrl
SymLibNameValidator m_validator
SYMBOL_SAVE_AS_HANDLER::CONFLICT_STRATEGY & m_conflictStrategy
SAVE_AS_DIALOG(SYMBOL_EDIT_FRAME *aParent, const wxString &aSymbolName, const wxString &aLibraryPreselect, SymLibNameValidator aValidator, SYMBOL_SAVE_AS_HANDLER::CONFLICT_STRATEGY &aConflictStrategy)
std::function< int(const wxString &libName, const wxString &symbolName)> SymLibNameValidator
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
void SetSymModificationTime(const wxDateTime &aTime)
Set the modification time of the symbol library table file.
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void SetText(const wxString &aText) override
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
static std::vector< LIB_SYMBOL * > ParseLibSymbols(std::string &aSymbolText, std::string aSource, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Look for files in a number of paths.
const wxString LastVisitedPath(const wxString &aSubPathToSearch=wxEmptyString)
A quirky function inherited from old code that seems to serve particular needs in the UI.
The symbol library editor main window.
bool m_isSymbolFromSchematic
void ClearMsgPanel() override
Clear all messages from the message panel.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
void SaveAll()
Save all modified symbols and libraries.
void DeleteSymbolFromLibrary()
bool addLibTableEntry(const wxString &aLibFile, TABLE_SCOPE aScope=GLOBAL_LIB_TABLE)
Add aLibFile to the symbol library table defined by aScope.
bool IsLibraryTreeShown() const override
wxString getTargetLib() const
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Return currently edited symbol.
int GetTreeLIBIDs(std::vector< LIB_ID > &aSelection) const
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
void Save()
Save the selected symbol or library.
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
void RebuildSymbolUnitsList()
void Revert(bool aConfirm=true)
Revert unsaved changes in a symbol, restoring to the last saved state.
void centerItemIdleHandler(wxIdleEvent &aEvent)
bool replaceLibTableEntry(const wxString &aLibNickname, const wxString &aLibFile)
Replace the file path of the symbol library table entry aLibNickname with aLibFile.
bool IsSymbolFromSchematic() const
void SetScreen(BASE_SCREEN *aScreen) override
void DuplicateSymbol(bool aFromClipboard)
Insert a duplicate symbol.
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
LIB_ID m_centerItemOnIdle
void saveSymbolCopyAs(bool aOpenCopy)
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
KIID m_schematicSymbolUUID
RefDes of the symbol (only valid if symbol was loaded from schematic)
std::vector< LIB_ID > GetSelectedLibIds() const
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
LIB_ID GetTargetLibId() const override
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
bool saveLibrary(const wxString &aLibrary, bool aNewFile)
Save the changes to the current library.
void SelectActiveLibrary(const wxString &aLibrary=wxEmptyString)
Set the current active library to aLibrary.
int m_bodyStyle
Flag if the symbol being edited was loaded directly from a schematic.
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void UpdateMsgPanel() override
Redraw the message panel.
void CreateNewSymbol(const wxString &newName=wxEmptyString)
Create a new symbol in the selected library.
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
void ReCreateHToolbar() override
SYMBOL_TREE_PANE * m_treePane
bool LoadOneLibrarySymbolAux(LIB_SYMBOL *aLibEntry, const wxString &aLibrary, int aUnit, int aBodyStyle)
Create a copy of aLibEntry into memory.
bool LoadSymbolFromCurrentLib(const wxString &aAliasName, int aUnit=0, int aBodyStyle=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
bool saveCurrentSymbol()
Store the currently modified symbol in the library manager buffer.
void CopySymbolToClipboard()
void SaveSymbolCopyAs(bool aOpenCopy)
Save the currently selected symbol to a new name and/or location.
wxString AddLibraryFile(bool aCreateNew)
Create or add an existing library to the symbol library table.
void ensureUniqueName(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SetShowDeMorgan(bool show)
void SaveLibraryAs()
Save the currently selected library to a new file.
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
SYMBOL_SAVEAS_TYPE GetOption() const
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool ClearSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Clear the modified flag for a symbol.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool ClearLibraryModified(const wxString &aLibrary) const
Clear the modified flag for all symbols in a library.
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
SCH_SCREEN * GetScreen(const wxString &aAlias, const wxString &aLibrary)
Return the screen used to edit a specific symbol.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
wxArrayString GetLibraryNames() const
Return the array of library names.
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
bool RemoveSymbol(const wxString &aName, const wxString &aLibrary)
Remove the symbol from the symbol buffer.
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
bool RevertLibrary(const wxString &aLibrary)
Revert unsaved changes for a symbolicular library.
void GetSymbolNames(const wxString &aLibName, wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
bool RevertAll()
Revert all pending changes.
LIB_ID RevertSymbol(const wxString &aAlias, const wxString &aLibrary)
Revert unsaved changes for a symbolicular symbol.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
bool SaveLibrary(const wxString &aLibrary, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aFileType=SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY)
Save library to a file, including unsaved changes.
bool HasDerivedSymbols(const wxString &aSymbolName, const wxString &aLibraryName)
Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
This is a class that handles state involved in saving a symbol copy as a new symbol.
CONFLICT_STRATEGY m_strategy
wxString resolveConflict(const wxString &proposed, const wxString &aNewLibName) const
SYMBOL_SAVE_AS_HANDLER(LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, CONFLICT_STRATEGY aStrategy, bool aValueFollowsName)
LIB_SYMBOL_LIBRARY_MANAGER & m_libMgr
bool DoSave(LIB_SYMBOL &symbol, const wxString &aNewSymName, const wxString &aNewLibName)
LIB_TREE * GetLibTree() const
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
int GetPinNameOffset() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
void SetExcludedFromBoard(bool aExcludeFromBoard)
Set or clear exclude from board netlist flag.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
This file is part of the common library.
static const std::string KiCadSymbolLibFileExtension
static wxString KiCadSymbolLibFileWildcard()
This file is part of the common library.
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
@ ALL
All except INITIAL_ADD.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
PGM_BASE & Pgm()
The global Program "get" accessor.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
KIWAY Kiway(KFCTL_STANDALONE)
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_symbol_libs
static std::vector< LIB_SYMBOL_SPTR > GetParentChain(const LIB_SYMBOL &aSymbol)
Get a list of all the symbols in the parental chain of a symbol, with the "leaf" symbol at the start ...
static std::vector< wxString > CheckForParentalChainConflicts(LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, LIB_SYMBOL &aSymbol, const wxString &newSymbolName, const wxString &newLibraryName)
Get a list of all the symbols in the parental chain of a symbol that have conflicts when transposed t...
static std::pair< bool, bool > CheckSavingIntoOwnInheritance(LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, LIB_SYMBOL &aSymbol, const wxString &aNewSymbolName, const wxString &aNewLibraryName)
Check if a planned overwrite would put a symbol into it's own inheritance chain.
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
Definition of file extensions used in Kicad.