From 389287e942877b6473c14ac07808f8600f88ee9d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 17 Jun 2021 22:22:10 +0100 Subject: [PATCH] A bit more Part -> Symbol. --- eeschema/dialogs/dialog_change_symbols.cpp | 6 ++--- eeschema/dialogs/dialog_edit_one_field.cpp | 4 ++-- eeschema/dialogs/dialog_symbol_properties.cpp | 2 +- eeschema/erc.cpp | 2 +- eeschema/getpart.cpp | 4 ++-- eeschema/libarch.cpp | 4 ++-- eeschema/project_rescue.cpp | 23 ++++++++++++------- eeschema/sch_base_frame.cpp | 10 ++++---- eeschema/sch_base_frame.h | 12 ++++------ eeschema/tools/sch_drawing_tools.cpp | 2 +- 10 files changed, 37 insertions(+), 32 deletions(-) diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index a84a2f6432..4d6870cb78 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -289,7 +289,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() ) { - LIB_SYMBOL* libSymbol = frame->GetLibPart( symbol->GetLibId() ); + LIB_SYMBOL* libSymbol = frame->GetLibSymbol( symbol->GetLibId() ); if( libSymbol ) { @@ -315,7 +315,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() if( newId.IsValid() ) { - LIB_SYMBOL* libSymbol = frame->GetLibPart( newId ); + LIB_SYMBOL* libSymbol = frame->GetLibSymbol( newId ); if( libSymbol ) { @@ -532,7 +532,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_ } } - LIB_SYMBOL* libSymbol = frame->GetLibPart( aNewId ); + LIB_SYMBOL* libSymbol = frame->GetLibSymbol( aNewId ); if( !libSymbol ) { diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index df216009d2..8be48407f1 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -317,8 +317,8 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, // be entirely accurate if the power library is missing but it's better then a segfault. if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T ) { - const SCH_SYMBOL* symbol = (SCH_SYMBOL*) aField->GetParent(); - const LIB_SYMBOL* libSymbol = GetParent()->GetLibPart( symbol->GetLibId(), true ); + const SCH_SYMBOL* symbol = static_cast( aField->GetParent() ); + const LIB_SYMBOL* libSymbol = GetParent()->GetLibSymbol( symbol->GetLibId(), true ); if( libSymbol && libSymbol->IsPower() ) m_isPower = true; diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index df0bdf6800..03fd7668cc 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -659,7 +659,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() for( unsigned i = 0; i < m_fields->size(); ++i ) m_fields->at( i ).Offset( m_symbol->GetPosition() ); - LIB_SYMBOL* entry = GetParent()->GetLibPart( m_symbol->GetLibId() ); + LIB_SYMBOL* entry = GetParent()->GetLibSymbol( m_symbol->GetLibId() ); if( entry && entry->IsPower() ) m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index af2b87c575..fa91f3931d 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -723,7 +723,7 @@ int ERC_TESTER::TestLibSymbolIssues() } wxString symbolName = symbol->GetLibId().GetLibItemName(); - LIB_SYMBOL* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable ); + LIB_SYMBOL* libSymbol = SchGetLibSymbol( symbol->GetLibId(), libTable ); if( libSymbol == nullptr ) { diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 19d0c70008..bfc3aacfbc 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -124,7 +124,7 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte for( const PICKED_SYMBOL& i : aHistoryList ) { - LIB_SYMBOL* symbol = GetLibPart( i.LibId ); + LIB_SYMBOL* symbol = GetLibSymbol( i.LibId ); // This can be null, for example when a symbol has been deleted from a library if( symbol ) @@ -197,7 +197,7 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte void SCH_EDIT_FRAME::SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ) { - LIB_SYMBOL* symbol = GetLibPart( aSymbol->GetLibId() ); + LIB_SYMBOL* symbol = GetLibSymbol( aSymbol->GetLibId() ); if( !symbol ) return; diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 5c9073b910..04483ee6ff 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -83,7 +83,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) { - for( auto aItem : screen->Items().OfType( SCH_SYMBOL_T ) ) + for( SCH_ITEM* aItem : screen->Items().OfType( SCH_SYMBOL_T ) ) { LIB_SYMBOL* libSymbol = nullptr; SCH_SYMBOL* symbol = static_cast( aItem ); @@ -93,7 +93,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) if( archLib->FindSymbol( symbol->GetLibId() ) ) continue; - libSymbol = GetLibPart( symbol->GetLibId(), true ); + libSymbol = GetLibSymbol( symbol->GetLibId(), true ); } catch( const IO_ERROR& ) { diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 36293a8072..ebd090c328 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -394,7 +394,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( true ); // Get the library symbol from the symbol library table. - lib_match = SchGetLibPart( symbol_id, aRescuer.GetPrj()->SchSymbolLibTable() ); + lib_match = SchGetLibSymbol( symbol_id, aRescuer.GetPrj()->SchSymbolLibTable() ); if( !cache_match && !lib_match ) continue; @@ -407,13 +407,9 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( lib_match_parent = lib_match->GetParent().lock(); if( !lib_match_parent ) - { lib_match = nullptr; - } else - { lib_match = lib_match_parent.get(); - } } // Test whether there is a conflict or if the symbol can only be found in the cache. @@ -421,7 +417,9 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( { if( cache_match && lib_match && !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) ) + { continue; + } if( !cache_match && lib_match ) continue; @@ -460,14 +458,23 @@ wxString RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription() const wxString action; if( !m_cache_candidate && !m_lib_candidate ) + { action.Printf( _( "Cannot rescue symbol %s which is not available in any library or " - "the cache." ), m_requested_id.GetLibItemName().wx_str() ); + "the cache." ), + m_requested_id.GetLibItemName().wx_str() ); + } else if( m_cache_candidate && !m_lib_candidate ) + { action.Printf( _( "Rescue symbol %s found only in cache library to %s." ), - m_requested_id.Format().wx_str(), m_new_id.Format().wx_str() ); + m_requested_id.Format().wx_str(), + m_new_id.Format().wx_str() ); + } else + { action.Printf( _( "Rescue modified symbol %s to %s" ), - m_requested_id.Format().wx_str(), m_new_id.Format().wx_str() ); + m_requested_id.Format().wx_str(), + m_new_id.Format().wx_str() ); + } return action; } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 2e6f4018e3..8be853041e 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -43,8 +43,8 @@ #include -LIB_SYMBOL* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, SYMBOL_LIB* aCacheLib, - wxWindow* aParent, bool aShowErrorMsg ) +LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, + SYMBOL_LIB* aCacheLib, wxWindow* aParent, bool aShowErrorMsg ) { wxCHECK_MSG( aLibTable, nullptr, "Invalid symbol library table." ); @@ -192,12 +192,12 @@ void SCH_BASE_FRAME::UpdateStatusBar() } -LIB_SYMBOL* SCH_BASE_FRAME::GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib, - bool aShowErrorMsg ) +LIB_SYMBOL* SCH_BASE_FRAME::GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib, + bool aShowErrorMsg ) { SYMBOL_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL; - return SchGetLibPart( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowErrorMsg ); + return SchGetLibSymbol( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowErrorMsg ); } diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index 68ef0a4539..dac0f2d49c 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -72,9 +72,9 @@ class SYMBOL_EDITOR_SETTINGS; * * @return The symbol found in the library or NULL if the symbol was not found. */ -LIB_SYMBOL* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, - SYMBOL_LIB* aCacheLib = NULL, wxWindow* aParent = NULL, - bool aShowErrorMsg = false ); +LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, + SYMBOL_LIB* aCacheLib = NULL, wxWindow* aParent = NULL, + bool aShowErrorMsg = false ); /** * A shim class between EDA_DRAW_FRAME and several derived classes: @@ -177,10 +177,8 @@ public: * @param aShowErrorMessage set to true to show any error messages. * @return The symbol found in the library or NULL if the symbol was not found. */ - LIB_SYMBOL* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false, - bool aShowErrorMsg = false ); - - LIB_SYMBOL* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false ); + LIB_SYMBOL* GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib = false, + bool aShowErrorMsg = false ); /** * Call the library viewer to select symbol to import into schematic. diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 0ab9b88708..d905150d84 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -260,7 +260,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) controls->WarpCursor( canvas_area.Centre(), false ); LIB_SYMBOL* libSymbol = sel.LibId.IsValid() ? - m_frame->GetLibPart( sel.LibId ) : nullptr; + m_frame->GetLibSymbol( sel.LibId ) : nullptr; if( !libSymbol ) continue;