45#include <wx/clipbrd.h> 
   46#include <wx/filedlg.h> 
   66        title += wxS( 
" " ) + 
_( 
"[from schematic]" );
 
   76            title += wxS( 
" " ) + 
_( 
"[Read Only Library]" );
 
   80        title = 
_( 
"[no symbol loaded]" );
 
   83    title += wxT( 
" \u2014 " ) + 
_( 
"Symbol Editor" );
 
 
   90    wxString selectedLib = aLibrary;
 
   92    if( selectedLib.empty() )
 
   93        selectedLib = 
SelectLibrary( 
_( 
"Select Symbol Library" ), 
_( 
"Library:" ) );
 
   95    if( !selectedLib.empty() )
 
 
  126            if( 
m_libMgr->IsLibraryReadOnly( libName ) )
 
  128                wxString msg = wxString::Format( 
_( 
"Symbol library '%s' is not writable." ),
 
  130                wxString msg2 = 
_( 
"You must save to a different location." );
 
 
  159        if( type == SCH_IO_MGR::SCH_DATABASE
 
  160            || type == SCH_IO_MGR::SCH_CADSTAR_ARCHIVE
 
  161            || type == SCH_IO_MGR::SCH_HTTP )
 
  174                msg.Printf( 
_( 
"Error loading symbol %s from library '%s'." ),
 
  206        m_treePane->GetLibTree()->SelectLibId( libId );
 
  207        m_treePane->GetLibTree()->ExpandLibId( libId );
 
 
  240        msg.Printf( 
_( 
"Error loading symbol %s from library '%s'." ),
 
 
  263                                                 int aUnit, 
int aBodyStyle )
 
  265    bool rebuildMenuAndToolbar = 
false;
 
  267    if( !aEntry || aLibrary.empty() )
 
  270    if( aEntry->
GetName().IsEmpty() )
 
  272        wxLogWarning( 
"Symbol in library '%s' has empty name field.", aLibrary );
 
  288        rebuildMenuAndToolbar = 
true;
 
  292    wxCHECK( lib_symbol, 
false );
 
  294    m_unit = aUnit > 0 ? aUnit : 1;
 
  304    if( rebuildMenuAndToolbar )
 
 
  350    if( !
m_libMgr->LibraryExists( lib ) )
 
  352        lib = 
SelectLibrary( 
_( 
"New Symbol" ), 
_( 
"Create symbol in library:" ) );
 
  354        if( !
m_libMgr->LibraryExists( lib ) )
 
  358    const auto validator =
 
  359            [&]( wxString newName ) -> 
bool 
  361                if( newName.IsEmpty() )
 
  363                    wxMessageBox( 
_( 
"Symbol must have a name." ) );
 
  367                if( !lib.empty() && 
m_libMgr->SymbolNameInUse( newName, lib ) )
 
  371                    msg.Printf( 
_( 
"Symbol '%s' already exists in library '%s'." ),
 
  375                    KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ),
 
  376                                       wxOK | wxCANCEL | wxICON_WARNING );
 
  378                    errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
  386    wxArrayString symbolNamesInLib;
 
  387    m_libMgr->GetSymbolNames( lib, symbolNamesInLib );
 
  391    dlg.SetMinSize( dlg.GetSize() );
 
  416    m_libMgr->CreateNewSymbol( lib, props );
 
 
  429    if( libName.empty() )
 
  433    else if( 
m_libMgr->IsLibraryReadOnly( libName ) )
 
  435        wxString msg = wxString::Format( 
_( 
"Symbol library '%s' is not writable." ),
 
  437        wxString msg2 = 
_( 
"You must save to a different location." );
 
 
  458    if( !libName.IsEmpty() )
 
 
  485    std::vector<std::shared_ptr<LIB_SYMBOL>> 
chain;
 
  486    std::shared_ptr<LIB_SYMBOL>              sym = aSymbol.
SharedPtr();
 
  489        chain.push_back( sym );
 
  491    while( sym->IsDerived() )
 
  493        std::shared_ptr<LIB_SYMBOL> parent = sym->GetParent().lock();
 
  494        chain.push_back( parent );
 
 
  513                                                            const wxString& aNewSymbolName,
 
  514                                                            const wxString& aNewLibraryName )
 
  519    if( aNewLibraryName != oldLibraryName )
 
  520        return { 
false, 
false };
 
  524        return { 
false, 
false };
 
  526    bool inAncestry = 
false;
 
  527    bool inDescendents = 
false;
 
  530        const std::vector<std::shared_ptr<LIB_SYMBOL>> parentChainFromUs = 
GetParentChain( aSymbol, 
true );
 
  533        for( 
size_t i = 1; i < parentChainFromUs.size(); ++i )
 
  536            if( parentChainFromUs[i]->GetName() == aNewSymbolName )
 
  546        const std::vector<std::shared_ptr<LIB_SYMBOL>> parentChainFromTarget = 
GetParentChain( *targetSymbol, 
true );
 
  547        const wxString                                 oldSymbolName = aSymbol.
GetName();
 
  551        for( 
size_t i = 1; i < parentChainFromTarget.size(); ++i )
 
  553            if( parentChainFromTarget[i]->GetName() == oldSymbolName )
 
  555                inDescendents = 
true;
 
  561    return { inAncestry, inDescendents };
 
 
  575                                                             const wxString& newSymbolName,
 
  576                                                             const wxString& newLibraryName )
 
  578    std::vector<wxString> conflicts;
 
  581    if( newLibraryName == oldLibraryName || aFlattenSymbol )
 
  586            conflicts.push_back( newSymbolName );
 
  591        const std::vector<std::shared_ptr<LIB_SYMBOL>> parentChain = 
GetParentChain( aSymbol, 
true );
 
  593        for( 
size_t i = 0; i < parentChain.size(); ++i )
 
  599                    conflicts.push_back( newSymbolName );
 
  603                std::shared_ptr<LIB_SYMBOL> chainSymbol = parentChain[i];
 
  605                if( aLibMgr.
SymbolNameInUse( chainSymbol->GetName(), newLibraryName ) )
 
  606                    conflicts.push_back( chainSymbol->GetName() );
 
 
  642    bool DoSave( 
LIB_SYMBOL& symbol, 
const wxString& aNewSymName, 
const wxString& aNewLibName, 
bool aFlattenSymbol )
 
  644        std::unique_ptr<LIB_SYMBOL>              flattenedSymbol; 
 
  645        std::vector<std::shared_ptr<LIB_SYMBOL>> parentChain;
 
  653            flattenedSymbol = symbol.
Flatten();
 
  654            wxCHECK( flattenedSymbol, 
false );
 
  656            parentChain.push_back( flattenedSymbol->SharedPtr() );
 
  662            parentChain.push_back( symbol.
SharedPtr() );
 
  670        std::vector<wxString> newNames;
 
  673        for( 
int i = (
int) parentChain.size() - 1; i >= 0; --i )
 
  675            std::shared_ptr<LIB_SYMBOL>& oldSymbol = parentChain[i];
 
  682                newName = aNewSymName;
 
  687                newName = oldSymbol->GetName();
 
  696            if( i == (
int) parentChain.size() - 1 )
 
  707                wxASSERT( newParent );
 
  711            newNames.push_back( newName );
 
  712            m_libMgr.UpdateSymbol( &new_symbol, aNewLibName );
 
 
  719    wxString 
resolveConflict( 
const wxString& proposed, 
const wxString& aNewLibName )
 const 
  735                wxString newName = wxString::Format( 
"%s_%d", proposed, suffix );
 
  737                if( !
m_libMgr.SymbolNameInUse( newName, aNewLibName ) )
 
  747        wxFAIL_MSG( 
"Invalid conflict strategy" );
 
 
 
  781                           const std::vector<wxString>& aParentSymbolNames ) :
 
  786        wxArrayString              headers;
 
  787        std::vector<wxArrayString> itemsToDisplay;
 
  789        if( aParentSymbolNames.size() )
 
  793            const wxString aParentNames = AccumulateDescriptions( aParentSymbolNames );
 
  795                    wxString::Format( 
"Flatten/remove symbol inheritance (current parent symbols: %s)", aParentNames ),
 
  796                    &m_params.m_FlattenSymbol );
 
  805        wxBoxSizer* bNameSizer = 
new wxBoxSizer( wxHORIZONTAL );
 
  807        wxStaticText* label = 
new wxStaticText( 
this, wxID_ANY, 
_( 
"Name:" ) );
 
  808        bNameSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
 
  815        m_ButtonsSizer->Prepend( newLibraryButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
 
  817        GetSizer()->Prepend( bNameSizer, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
 
  820                [
this]( wxCommandEvent& )
 
  834        GetSizer()->Fit( 
this );
 
 
  843        symbolName.Trim( 
true );
 
  844        symbolName.Trim( 
false );
 
  845        symbolName.Replace( 
" ", 
"_" );
 
 
  866        if( ret == wxID_CANCEL )
 
 
 
  897    bool     flattenSymbol = 
false;
 
  901    const auto dialogValidatorFunc =
 
  902            [&]( 
const wxString& newLib, 
const wxString& newName ) -> 
int 
  904                if( newLib.IsEmpty() )
 
  906                    wxMessageBox( 
_( 
"A library must be specified." ) );
 
  910                if( newName.IsEmpty() )
 
  912                    wxMessageBox( 
_( 
"Symbol must have a name." ) );
 
  916                if( 
m_libMgr->IsLibraryReadOnly( newLib ) )
 
  918                    msg = wxString::Format( 
_( 
"Library '%s' is read-only. Choose a " 
  919                                               "different library to save the symbol '%s' to." ),
 
  935                    msg = wxString::Format( 
_( 
"Symbol '%s' cannot replace another symbol '%s' " 
  936                                               "that it descends from" ),
 
  945                    msg = wxString::Format( 
_( 
"Symbol '%s' cannot replace another symbol '%s' " 
  946                                               "that is a descendent of it." ),
 
  953                const std::vector<wxString> conflicts =
 
  956                if( conflicts.size() == 1 && conflicts.front() == newName )
 
  959                    msg = wxString::Format( 
_( 
"Symbol '%s' already exists in library '%s'. " 
  960                                               "Do you want to overwrite it?" ),
 
  964                    KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
 
  965                    errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
  969                else if( !conflicts.empty() )
 
  975                    msg = wxString::Format( 
_( 
"The following symbols in the inheritance chain of " 
  976                                               "'%s' already exist in library '%s':\n" ),
 
  980                    for( 
const wxString& conflict : conflicts )
 
  981                        msg += wxString::Format( 
"  %s\n", conflict );
 
  983                    msg += 
_( 
"\nDo you want to overwrite all of them, or rename the new symbols?" );
 
  985                    KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
 
  986                    errorDlg.SetYesNoCancelLabels( 
_( 
"Overwrite All" ), 
_( 
"Rename All" ), 
_( 
"Cancel" ) );
 
  992                    default:       
return wxID_CANCEL;
 
 1001    std::vector<wxString> parentSymbolNames;
 
 1005        std::vector<std::shared_ptr<LIB_SYMBOL>> parentChain = 
GetParentChain( *symbol, 
false );
 
 1007        for( 
const auto& parent : parentChain )
 
 1008            parentSymbolNames.push_back( parent->GetName() );
 
 1040            params.m_LibraryName = newLibrary.GetName();
 
 1053    saver.
DoSave( *symbol, params.m_SymbolName, params.m_LibraryName, params.m_FlattenSymbol );
 
 1058        LoadSymbol( params.m_SymbolName, params.m_LibraryName, 1 );
 
 
 1075    fn.SetName( symbol->
GetName().Lower() );
 
 1078    wxFileDialog dlg( 
this, 
_( 
"Export Symbol" ), 
m_mruPath, fn.GetFullName(),
 
 1081    if( dlg.ShowModal() == wxID_CANCEL )
 
 1091    wxString                    libraryName;
 
 1092    std::unique_ptr<LIB_SYMBOL> flattenedSymbol = symbol->
Flatten();
 
 1094    for( 
const wxString& candidate : 
m_libMgr->GetLibraryNames() )
 
 1098            if( *uri == fn.GetFullPath() )
 
 1099                libraryName = candidate;
 
 1103    if( !libraryName.IsEmpty() )
 
 1107        if( 
m_libMgr->IsLibraryReadOnly( libraryName ) )
 
 1109            msg = wxString::Format( 
_( 
"Library '%s' is read-only." ), libraryName );
 
 1116            msg = wxString::Format( 
_( 
"Symbol '%s' already exists in library '%s'." ),
 
 1117                                    symbol->
GetName(), libraryName );
 
 1119            KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
 
 1120            errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
 1123            if( errorDlg.
ShowModal() == wxID_CANCEL )
 
 1127        saver.
DoSave( *flattenedSymbol, symbol->
GetName(), libraryName, 
false );
 
 1136    if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
 
 1137        pluginType = SCH_IO_MGR::SCH_KICAD;
 
 1141    if( fn.FileExists() )
 
 1145            old_symbol = pi->LoadSymbol( fn.GetFullPath(), symbol->
GetName() );
 
 1149            msg.Printf( 
_( 
"Error occurred attempting to load symbol library file '%s'." ),
 
 1157            msg.Printf( 
_( 
"Symbol %s already exists in library '%s'." ),
 
 1161            KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
 
 1162            errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
 1165            if( errorDlg.
ShowModal() == wxID_CANCEL )
 
 1170    if( !fn.IsDirWritable() )
 
 1172        msg.Printf( 
_( 
"Insufficient permissions to save library '%s'." ), fn.GetFullPath() );
 
 1179        if( !fn.FileExists() )
 
 1180            pi->CreateLibrary( fn.GetFullPath() );
 
 1185        pi->SaveSymbol( fn.GetFullPath(), flattenedSymbol.release() );
 
 1189        msg.Printf( 
_( 
"Failed to create symbol library file '%s'." ), fn.GetFullPath() );
 
 1191        msg.Printf( 
_( 
"Error creating symbol library '%s'." ), fn.GetFullName() );
 
 1192        SetStatusText( msg );
 
 1198    msg.Printf( 
_( 
"Symbol %s saved to library '%s'." ),
 
 1201    SetStatusText( msg );
 
 
 1211    if( !lib.IsEmpty() && aOldName && *aOldName != 
m_symbol->GetName() )
 
 1216            wxString msg = wxString::Format( 
_( 
"Symbol name '%s' already in use." ),
 
 
 1247    if( toDelete.empty() )
 
 1250    for( 
LIB_ID& libId : toDelete )
 
 1252        if( 
m_libMgr->IsSymbolModified( libId.GetLibItemName(), libId.GetLibNickname() )
 
 1253            && !
IsOK( 
this, wxString::Format( 
_( 
"The symbol '%s' has been modified.\n" 
 1254                                                 "Do you want to remove it from the library?" ),
 
 1255                                              libId.GetUniStringLibItemName() ) ) )
 
 1260        wxArrayString derived;
 
 1262        if( 
m_libMgr->GetDerivedSymbolNames( libId.GetLibItemName(), libId.GetLibNickname(), derived ) > 0 )
 
 1264            wxString msg = 
_( 
"Deleting a base symbol will delete all symbols derived from it.\n\n" );
 
 1266            msg += libId.GetLibItemName().wx_str() + 
_( 
" (base)\n" );
 
 1268            for( 
const wxString& 
name : derived )
 
 1269                msg += 
name + wxT( 
"\n" );
 
 1272            dlg.SetExtendedMessage( wxT( 
" " ) );
 
 1273            dlg.SetYesNoLabels( 
_( 
"Delete All Listed Symbols" ), 
_( 
"Cancel" ) );
 
 1275            if( dlg.ShowModal() == wxID_NO )
 
 1283                if( symbol->GetLibId() == libId )
 
 1291        m_libMgr->RemoveSymbol( libId.GetLibItemName(), libId.GetLibNickname() );
 
 
 1300    std::vector<LIB_ID> symbols;
 
 1307    for( 
LIB_ID& libId : symbols )
 
 1310                                                          libId.GetLibNickname() );
 
 1315        std::unique_ptr<LIB_SYMBOL> tmp = symbol->
Flatten();
 
 1319    std::string prettyData = formatter.
GetString();
 
 1324    auto clipboard = wxTheClipboard;
 
 1325    wxClipboardLocker clipboardLock( clipboard );
 
 1327    if( !clipboardLock || !clipboard->IsOpened() )
 
 1330    auto data = 
new wxTextDataObject( wxString( prettyData.c_str(), wxConvUTF8 ) );
 
 1331    clipboard->SetData( data );
 
 
 1342    if( !
m_libMgr->LibraryExists( lib ) )
 
 1345    std::vector<LIB_SYMBOL*> newSymbols;
 
 1347    if( aFromClipboard )
 
 1357            wxLogMessage( wxS( 
"Can not paste: %s" ), e.
Problem() );
 
 1362        newSymbols.emplace_back( 
new LIB_SYMBOL( *srcSymbol ) );
 
 1365        if( srcSymbol->IsDerived() )
 
 1367            if( std::shared_ptr<LIB_SYMBOL> srcParent = srcSymbol->GetParent().lock() )
 
 1368                newSymbols.back()->SetParent( srcParent.get() );
 
 1372    if( newSymbols.empty() )
 
 1378        m_libMgr->UpdateSymbol( symbol, lib );
 
 1384    m_treePane->GetLibTree()->SelectLibId( 
LIB_ID( lib, newSymbols[0]->GetName() ) );
 
 
 1396        wxString newName = aSymbol->
GetName();
 
 1399        while( 
m_libMgr->SymbolNameInUse( newName, aLibrary ) )
 
 1400            newName.Printf( 
"%s_%d", aSymbol->
GetName(), i++ );
 
 
 1415    wxString msg = wxString::Format( 
_( 
"Revert '%s' to last version saved?" ),
 
 1416                                     symbolName.IsEmpty() ? libName : symbolName );
 
 1421    bool reload_currentSymbol = 
false;
 
 1422    wxString curr_symbolName = symbolName;
 
 1428        if( symbolName.IsEmpty() )
 
 1433            if( reload_currentSymbol )
 
 1444    if( reload_currentSymbol )
 
 1447    if( symbolName.IsEmpty() )
 
 1449        m_libMgr->RevertLibrary( libName );
 
 1455        m_treePane->GetLibTree()->SelectLibId( libId );
 
 1459    if( reload_currentSymbol && 
m_libMgr->SymbolExists( curr_symbolName, libName ) )
 
 1460        LoadSymbol( curr_symbolName, libName, unit );
 
 
 1468    wxCHECK_RET( 
m_libMgr, 
"Library manager object not created." );
 
 
 1493        DisplayError( 
this, wxString::Format( 
_( 
"Symbol %s not found in library '%s'." ),
 
 
 1515    SCH_IO_MGR::SCH_FILE_T 
fileType = SCH_IO_MGR::SCH_FILE_T::SCH_KICAD;
 
 1522    if( !aNewFile && ( aLibrary.empty() || !adapter->
HasLibrary( aLibrary ) ) )
 
 1538        fn.SetName( aLibrary );
 
 1543        wxFileDialog dlg( 
this, wxString::Format( 
_( 
"Save Library '%s' As..." ), aLibrary ), default_path,
 
 1544                          fn.GetFullName(), wildcards, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
 
 1547        dlg.SetCustomizeHook( saveAsHook );
 
 1549        if( dlg.ShowModal() == wxID_CANCEL )
 
 1556        if( fn.GetExt().IsEmpty() )
 
 1563        std::optional<LIBRARY_TABLE_ROW*> optRow = adapter->
GetRow( aLibrary );
 
 1564        wxCHECK( optRow, 
false );
 
 1569        if( 
fileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
 
 1574    if( !aNewFile && 
m_libMgr->IsLibraryReadOnly( aLibrary ) )
 
 1585        msg.Printf( 
_( 
"Failed to save changes to symbol library file '%s'." ),
 
 1593        m_libMgr->ClearLibraryModified( aLibrary );
 
 1601        bool resyncLibTree = 
false;
 
 1603        wxString forceRefresh;
 
 1609            forceRefresh = originalLibNickname;
 
 1633    msg.Printf( 
_( 
"Symbol library file '%s' saved." ), fn.GetFullPath() );
 
 
 1645    bool     applyToAll = 
false;
 
 1648    for( 
const wxString& libNickname : 
m_libMgr->GetLibraryNames() )
 
 1650        if( 
m_libMgr->IsLibraryModified( libNickname ) )
 
 1654    for( 
const wxString& libNickname : 
m_libMgr->GetLibraryNames() )
 
 1656        if( 
m_libMgr->IsLibraryModified( libNickname ) )
 
 1658            if( aRequireConfirmation && !applyToAll )
 
 1660                msg.Printf( 
_( 
"Save changes to '%s' before closing?" ), libNickname );
 
 1664                case wxID_YES: doSave = 
true;  
break;
 
 1665                case wxID_NO:  doSave = 
false; 
break;
 
 1667                case wxID_CANCEL: 
return false;
 
 1675                if( 
m_libMgr->IsLibraryReadOnly( libNickname ) )
 
 1677                    msg.Printf( 
_( 
"Symbol library '%s' is not writable." ), libNickname );
 
 1678                    msg2 = 
_( 
"You must save to a different location." );
 
 1680                    if( dirtyCount == 1 )
 
 1691                        m_infoBar->ShowMessageFor( msg + wxS( 
"  " ) + msg2,
 
 1692                                                   2000, wxICON_EXCLAMATION );
 
 
 1724    wxString msg = 
m_symbol->GetName();
 
 1730        std::shared_ptr<LIB_SYMBOL> parent = 
m_symbol->GetParent().lock();
 
 1732        msg = parent ? parent->GetName() : 
_( 
"Undefined!" );
 
 1737        msg = 
_( 
"Power Symbol" );
 
 1738    else if( 
m_symbol->IsLocalPower() )
 
 1739        msg = 
_( 
"Power Symbol (Local)" );
 
 1741        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 GetTransferUserFields()
 
bool GetKeepContentUserFields()
 
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()
 
virtual void RecreateToolbars()
 
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()
Recreate 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.
 
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)
 
void GetExtraCheckboxValues()
Fills in the value pointers from the checkboxes after the dialog has run.
 
EDA_LIST_DIALOG(wxWindow *aParent, const wxString &aTitle, const wxArrayString &aItemHeaders, const std::vector< wxArrayString > &aItemList, const wxString &aPreselectText=wxEmptyString, bool aSortList=true)
 
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 DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
 
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
 
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
 
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
 
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
 
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
 
std::optional< LIBRARY_TABLE_ROW * > GetRow(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
 
const wxString & Type() const
 
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.
 
const LIB_ID & GetLibId() const override
 
bool UnitsLocked() const
Check whether symbol units are interchangeable.
 
LIB_ID GetSourceLibId() const
 
void SetParent(LIB_SYMBOL *aParent=nullptr)
 
wxString GetName() const override
 
SCH_FIELD & GetValueField()
Return reference to the value field.
 
std::shared_ptr< LIB_SYMBOL > SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
 
bool IsMultiUnit() const override
 
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
 
virtual void SetName(const wxString &aName)
 
virtual LIBRARY_MANAGER & GetLibraryManager() const
 
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
 
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
 
Container for project specific data.
 
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
 
std::function< int(const wxString &libName, const wxString &symbolName)> SymLibNameValidator
 
bool TransferDataToWindow() override
 
SymLibNameValidator m_validator
 
SAVE_SYMBOL_AS_DIALOG(SYMBOL_EDIT_FRAME *aParent, PARAMS &aParams, SymLibNameValidator aValidator, const std::vector< wxString > &aParentSymbolNames)
 
wxString getSymbolName() const
 
wxTextCtrl * m_symbolNameCtrl
 
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.
 
void GetLibraryItemsForListDialog(wxArrayString &aHeaders, std::vector< wxArrayString > &aItemsToDisplay)
 
wxString SelectLibrary(const wxString &aDialogTitle, const wxString &aListLabel, const std::vector< std::pair< wxString, bool * > > &aExtraCheckboxes={})
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.
 
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 EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
 
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 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.
 
void RebuildSymbolUnitAndBodyStyleLists()
 
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...
 
bool addLibTableEntry(const wxString &aLibFile, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::GLOBAL)
Add aLibFile to the symbol library table defined by aScope.
 
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.
 
bool LoadSymbolFromCurrentLib(const wxString &aSymbolName, int aUnit=0, int aBodyStyle=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
 
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 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 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 ...
 
An interface to the global shared library manager that is schematic-specific and linked to one projec...
 
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
 
bool SymbolNameInUse(const wxString &aName, const wxString &aLibrary)
Return true if the symbol name is already in use in the specified library.
 
LIB_SYMBOL * GetSymbol(const wxString &aSymbolName, 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...
 
SYMBOL_SAVEAS_TYPE GetOption() const
 
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, bool aFlattenSymbol)
 
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.
 
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.
 
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
 
This file is part of the common library.
 
#define KICAD_MESSAGE_DIALOG_BASE
 
static const std::string KiCadSymbolLibFileExtension
 
static wxString KiCadSymbolLibFileWildcard()
 
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
 
@ ALL
All except INITIAL_ADD.
 
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)
 
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
 
wxString parentSymbolName
 
bool keepContentUserFields
 
bool unitsInterchangeable
 
SYMBOL_SAVE_AS_HANDLER::CONFLICT_STRATEGY m_ConflictStrategy
 
static std::vector< wxString > CheckForParentalChainConflicts(LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, LIB_SYMBOL &aSymbol, bool aFlattenSymbol, 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::vector< std::shared_ptr< LIB_SYMBOL > > GetParentChain(const LIB_SYMBOL &aSymbol, bool aIncludeLeaf=true)
Get a list of all the symbols in the parental chain of a symbol, with the "leaf" symbol at the start ...
 
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.
 
@ ADD_PROJECT_TABLE_ENTRY
 
const SHAPE_LINE_CHAIN chain
 
Definition of file extensions used in Kicad.