diff --git a/common/eda_item.cpp b/common/eda_item.cpp index f97e8d48d2..555c929e25 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -291,7 +291,7 @@ static struct EDA_ITEM_DESC .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) - .Map( LIB_PART_T, _HKI( "Symbol" ) ) + .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) .Map( LIB_ALIAS_T, _HKI( "Alias" ) ) .Map( LIB_ARC_T, _HKI( "Arc" ) ) .Map( LIB_CIRCLE_T, _HKI( "Circle" ) ) diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 37b39fc4f3..36bc537f3c 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -52,7 +52,7 @@ void SCH_EDIT_FRAME::mapExistingAnnotation( std::map& aMap ) wxString ref = symbol->GetRef( curr_sheetpath ); if( symbol->GetUnitCount() > 1 ) - ref << LIB_PART::SubReference( symbol->GetUnitSelection( curr_sheetpath ) ); + ref << LIB_SYMBOL::SubReference( symbol->GetUnitSelection( curr_sheetpath ) ); if( symbol->IsAnnotated( curr_sheetpath ) ) aMap[ curr_full_uuid.AsString() ] = ref; @@ -270,7 +270,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, wxString newRef = symbol->GetRef( sheet ); if( symbol->GetUnitCount() > 1 ) - newRef << LIB_PART::SubReference( symbol->GetUnitSelection( sheet ) ); + newRef << LIB_SYMBOL::SubReference( symbol->GetUnitSelection( sheet ) ); wxString msg; @@ -282,7 +282,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, if( symbol->GetUnitCount() > 1 ) msg.Printf( _( "Updated %s (unit %s) from %s to %s" ), symbol->GetValue( sheet, true ), - LIB_PART::SubReference( symbol->GetUnit(), false ), + LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), prevRef, newRef ); else @@ -296,7 +296,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, if( symbol->GetUnitCount() > 1 ) msg.Printf( _( "Annotated %s (unit %s) as %s" ), symbol->GetValue( sheet, true ), - LIB_PART::SubReference( symbol->GetUnit(), false ), + LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), newRef ); else msg.Printf( _( "Annotated %s as %s" ), diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 46743c35cd..dbecba8a30 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -84,8 +84,8 @@ PART_LIB::~PART_LIB() void PART_LIB::Save( bool aSaveDocFile ) { - wxCHECK_RET( m_plugin != NULL, wxString::Format( "no plugin defined for library `%s`.", - fileName.GetFullPath() ) ); + wxCHECK_RET( m_plugin != nullptr, wxString::Format( "no plugin defined for library `%s`.", + fileName.GetFullPath() ) ); PROPERTIES props; @@ -153,19 +153,19 @@ void PART_LIB::GetPartNames( wxArrayString& aNames ) const } -void PART_LIB::GetParts( std::vector& aSymbols ) const +void PART_LIB::GetParts( std::vector& aSymbols ) const { m_plugin->EnumerateSymbolLib( aSymbols, fileName.GetFullPath(), m_properties.get() ); std::sort( aSymbols.begin(), aSymbols.end(), - [](LIB_PART *lhs, LIB_PART *rhs) -> bool + [](LIB_SYMBOL *lhs, LIB_SYMBOL *rhs) -> bool { return lhs->GetName() < rhs->GetName(); }); } -LIB_PART* PART_LIB::FindPart( const wxString& aName ) const +LIB_SYMBOL* PART_LIB::FindPart( const wxString& aName ) const { - LIB_PART* symbol = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() ); + LIB_SYMBOL* symbol = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() ); // Set the library to this even though technically the legacy cache plugin owns the // symbols. This allows the symbol library table conversion tool to determine the @@ -177,16 +177,17 @@ LIB_PART* PART_LIB::FindPart( const wxString& aName ) const } -LIB_PART* PART_LIB::FindPart( const LIB_ID& aLibId ) const +LIB_SYMBOL* PART_LIB::FindPart( const LIB_ID& aLibId ) const { return FindPart( aLibId.Format().wx_str() ); } -void PART_LIB::AddPart( LIB_PART* aPart ) +void PART_LIB::AddPart( LIB_SYMBOL* aSymbol ) { // add a clone, not the caller's copy, the plugin take ownership of the new symbol. - m_plugin->SaveSymbol( fileName.GetFullPath(), new LIB_PART( *aPart->SharedPtr().get(), this ), + m_plugin->SaveSymbol( fileName.GetFullPath(), + new LIB_SYMBOL( *aSymbol->SharedPtr().get(), this ), m_properties.get() ); // If we are not buffering, the library file is updated immediately when the plugin @@ -198,9 +199,9 @@ void PART_LIB::AddPart( LIB_PART* aPart ) } -LIB_PART* PART_LIB::RemovePart( LIB_PART* aEntry ) +LIB_SYMBOL* PART_LIB::RemovePart( LIB_SYMBOL* aEntry ) { - wxCHECK_MSG( aEntry != NULL, NULL, "NULL pointer cannot be removed from library." ); + wxCHECK_MSG( aEntry != nullptr, nullptr, "NULL pointer cannot be removed from library." ); m_plugin->DeleteSymbol( fileName.GetFullPath(), aEntry->GetName(), m_properties.get() ); @@ -210,18 +211,18 @@ LIB_PART* PART_LIB::RemovePart( LIB_PART* aEntry ) isModified = true; ++m_mod_hash; - return NULL; + return nullptr; } -LIB_PART* PART_LIB::ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart ) +LIB_SYMBOL* PART_LIB::ReplacePart( LIB_SYMBOL* aOldPart, LIB_SYMBOL* aNewPart ) { - wxASSERT( aOldPart != NULL ); - wxASSERT( aNewPart != NULL ); + wxASSERT( aOldPart != nullptr ); + wxASSERT( aNewPart != nullptr ); m_plugin->DeleteSymbol( fileName.GetFullPath(), aOldPart->GetName(), m_properties.get() ); - LIB_PART* my_part = new LIB_PART( *aNewPart, this ); + LIB_SYMBOL* my_part = new LIB_SYMBOL( *aNewPart, this ); m_plugin->SaveSymbol( fileName.GetFullPath(), my_part, m_properties.get() ); @@ -239,16 +240,16 @@ PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) { std::unique_ptr lib = std::make_unique( SCH_LIB_TYPE::LT_EESCHEMA, aFileName ); - std::vector parts; + std::vector parts; // This loads the library. lib->GetParts( parts ); - // Now, set the LIB_PART m_library member but it will only be used + // Now, set the LIB_SYMBOL m_library member but it will only be used // when loading legacy libraries in the future. Once the symbols in the // schematic have a full #LIB_ID, this will not get called. for( size_t ii = 0; ii < parts.size(); ii++ ) { - LIB_PART* part = parts[ii]; + LIB_SYMBOL* part = parts[ii]; part->SetLib( lib.get() ); } @@ -318,7 +319,7 @@ PART_LIB* PART_LIBS::FindLibrary( const wxString& aName ) return &*it; } - return NULL; + return nullptr; } @@ -330,7 +331,7 @@ PART_LIB* PART_LIBS::GetCacheLibrary() return &*it; } - return NULL; + return nullptr; } @@ -342,7 +343,7 @@ PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName ) return &*it; } - return NULL; + return nullptr; } @@ -370,9 +371,9 @@ wxArrayString PART_LIBS::GetLibraryNames( bool aSorted ) } -LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName ) +LIB_SYMBOL* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName ) { - LIB_PART* part = NULL; + LIB_SYMBOL* part = nullptr; for( PART_LIB& lib : *this ) { @@ -389,7 +390,7 @@ LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibrary } -void PART_LIBS::FindLibraryNearEntries( std::vector& aCandidates, +void PART_LIBS::FindLibraryNearEntries( std::vector& aCandidates, const wxString& aEntryName, const wxString& aLibraryName ) { @@ -488,7 +489,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress ) wxArrayString lib_names; - LibNamesAndPaths( aProject, false, NULL, &lib_names ); + LibNamesAndPaths( aProject, false, nullptr, &lib_names ); // Post symbol library table, this should be empty. Only the cache library should get loaded. if( !lib_names.empty() ) @@ -496,7 +497,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress ) APP_PROGRESS_DIALOG lib_dialog( _( "Loading Symbol Libraries" ), wxEmptyString, lib_names.GetCount(), - NULL, + nullptr, false, wxPD_APP_MODAL ); diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 40e2e65631..cfee27e11f 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -39,7 +39,7 @@ #include #include -class LIB_PART; +class LIB_SYMBOL; class LIB_ID; class LINE_READER; class OUTPUTFORMATTER; @@ -170,7 +170,7 @@ class PART_LIB; class wxRegEx; /** - * LIB_PART map sorting. + * LIB_SYMBOL map sorting. */ struct LibPartMapSort { @@ -182,9 +182,9 @@ struct LibPartMapSort /// Part map used by part library object. -typedef std::map< wxString, LIB_PART*, LibPartMapSort > LIB_PART_MAP; -typedef std::vector< LIB_PART* > LIB_PARTS; -typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE; +typedef std::map< wxString, LIB_SYMBOL*, LibPartMapSort > LIB_SYMBOL_MAP; +typedef std::vector< LIB_SYMBOL* > LIB_SYMBOLS; +typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE; /** @@ -291,12 +291,12 @@ public: * * @param aLibId - The #LIB_ID of the symbol to search for. * @param aLibraryName - Name of the library to search for part. - * @return LIB_PART* - The part object if found, otherwise NULL. + * @return LIB_SYMBOL* - The part object if found, otherwise NULL. */ - LIB_PART* FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName = wxEmptyString ); + LIB_SYMBOL* FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName = wxEmptyString ); /** - * Search all libraries in the list for a #LIB_PART using a case insensitive comparison. + * Search all libraries in the list for a #LIB_SYMBOL using a case insensitive comparison. * * Helper function used in dialog to find all candidates. * During a long time, eeschema was using a case insensitive search. @@ -308,7 +308,7 @@ public: * @param aLibraryName - Name of the library to search. * @param aCandidates - a std::vector to store candidates */ - void FindLibraryNearEntries( std::vector& aCandidates, const wxString& aEntryName, + void FindLibraryNearEntries( std::vector& aCandidates, const wxString& aEntryName, const wxString& aLibraryName = wxEmptyString ); int GetLibraryCount() { return size(); } @@ -371,29 +371,29 @@ public: /** * Load a vector with all the entries in this library. * - * @param aParts - vector to receive the aliases. + * @param aSymbols is a vector to receive the aliases. */ - void GetParts( std::vector& aPart) const; + void GetParts( std::vector& aSymbols ) const; /** - * Find #LIB_PART by \a aName. + * Find #LIB_SYMBOL by \a aName. * * @param aName - Name of part, case sensitive. - * @return LIB_PART pointer part if found, else NULL. + * @return LIB_SYMBOL pointer part if found, else NULL. */ - LIB_PART* FindPart( const wxString& aName ) const; + LIB_SYMBOL* FindPart( const wxString& aName ) const; - LIB_PART* FindPart( const LIB_ID& aLibId ) const; + LIB_SYMBOL* FindPart( const LIB_ID& aLibId ) const; /** - * Add \a aPart entry to library. + * Add \a aSymbol entry to library. * - * @note A #LIB_PART can have an alias list so these alias will be added in library. + * @note A #LIB_SYMBOL can have an alias list so these alias will be added in library. * and the any existing duplicate aliases will be removed from the library. * - * @param aPart - Part to add, caller retains ownership, a clone is added. + * @param aSymbol - Part to add, caller retains ownership, a clone is added. */ - void AddPart( LIB_PART* aPart ); + void AddPart( LIB_SYMBOL* aSymbol ); /** * Safely remove \a aEntry from the library and return the next entry. @@ -406,7 +406,7 @@ public: * @param aEntry - Entry to remove from library. * @return The next entry in the library or NULL if the library is empty. */ - LIB_PART* RemovePart( LIB_PART* aEntry ); + LIB_SYMBOL* RemovePart( LIB_SYMBOL* aEntry ); /** * Replace an existing part entry in the library. @@ -416,7 +416,7 @@ public: * @param aOldPart - The part to replace. * @param aNewPart - The new part. */ - LIB_PART* ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart ); + LIB_SYMBOL* ReplacePart( LIB_SYMBOL* aOldSymbol, LIB_SYMBOL* aNewSymbol ); /** * Return the file name without path or extension. diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 991afb381f..a3c42b26ad 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -629,7 +629,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler ) msg.Printf( _( "Error: symbol %s%s%s (unit %d) exceeds units defined (%d)\n" ), flatList[ii].GetRef(), tmp, - LIB_PART::SubReference( flatList[ii].m_unit ), + LIB_SYMBOL::SubReference( flatList[ii].m_unit ), flatList[ii].m_unit, flatList[ii].GetLibPart()->GetUnitCount() ); @@ -666,7 +666,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler ) msg.Printf( _( "Duplicate items %s%s%s\n" ), flatList[ii].GetRef(), tmp, - LIB_PART::SubReference( flatList[ii].m_unit ) ); + LIB_SYMBOL::SubReference( flatList[ii].m_unit ) ); } else { @@ -696,7 +696,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler ) msg.Printf( _( "Duplicate items %s%s%s\n" ), flatList[ii].GetRef(), tmp, - LIB_PART::SubReference( flatList[ii].m_unit ) ); + LIB_SYMBOL::SubReference( flatList[ii].m_unit ) ); } else { @@ -717,11 +717,11 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler ) msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ), flatList[ii].GetRef(), flatList[ii].m_numRef, - LIB_PART::SubReference( flatList[ii].m_unit ), + LIB_SYMBOL::SubReference( flatList[ii].m_unit ), flatList[ii].m_value, flatList[next].GetRef(), flatList[next].m_numRef, - LIB_PART::SubReference( flatList[next].m_unit ), + LIB_SYMBOL::SubReference( flatList[next].m_unit ), flatList[next].m_value ); aHandler( ERCE_DIFFERENT_UNIT_VALUE, msg, &flatList[ii], &flatList[ii+1] ); @@ -733,14 +733,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler ) } -SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_PART* aLibPart, +SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol, const SCH_SHEET_PATH& aSheetPath ) { wxASSERT( aSymbol != NULL ); m_rootSymbol = aSymbol; - m_libPart = aLibPart; // Warning: can be nullptr for orphan symbols - // (i.e. with a symbol library not found) + m_libPart = aLibSymbol; // Warning: can be nullptr for orphan symbols + // (i.e. with a symbol library not found) m_unit = aSymbol->GetUnitSelection( &aSheetPath ); m_footprint = aSymbol->GetFootprint( &aSheetPath, true ); m_sheetPath = aSheetPath; diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 36aa67a712..a84a2f6432 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -261,7 +261,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets(); - // Load non-mandatory fields from all matching symbols and their library parts + // Load non-mandatory fields from all matching symbols and their library symbols std::vector fields; std::vector libFields; std::set fieldNames; @@ -289,24 +289,24 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() ) { - LIB_PART* libSymbol = frame->GetLibPart( symbol->GetLibId() ); + LIB_SYMBOL* libSymbol = frame->GetLibPart( symbol->GetLibId() ); if( libSymbol ) { - std::unique_ptr flattenedPart = libSymbol->Flatten(); + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); - flattenedPart->GetFields( libFields ); + flattenedSymbol->GetFields( libFields ); for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i ) fieldNames.insert( libFields[i]->GetName() ); - libFields.clear(); // flattenedPart is about to go out of scope... + libFields.clear(); // flattenedSymbol is about to go out of scope... } } } } - // Load non-mandatory fields from the change-to library part + // Load non-mandatory fields from the change-to library symbol if( m_mode == MODE::CHANGE ) { LIB_ID newId; @@ -315,18 +315,18 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList() if( newId.IsValid() ) { - LIB_PART* libSymbol = frame->GetLibPart( newId ); + LIB_SYMBOL* libSymbol = frame->GetLibPart( newId ); if( libSymbol ) { - std::unique_ptr flattenedPart = libSymbol->Flatten(); + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); - flattenedPart->GetFields( libFields ); + flattenedSymbol->GetFields( libFields ); for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i ) fieldNames.insert( libFields[i]->GetName() ); - libFields.clear(); // flattenedPart is about to go out of scope... + libFields.clear(); // flattenedSymbol is about to go out of scope... } } } @@ -532,7 +532,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_ } } - LIB_PART* libSymbol = frame->GetLibPart( aNewId ); + LIB_SYMBOL* libSymbol = frame->GetLibPart( aNewId ); if( !libSymbol ) { @@ -541,7 +541,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_ return false; } - std::unique_ptr flattenedSymbol = libSymbol->Flatten(); + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); if( flattenedSymbol->GetUnitCount() < aSymbol->GetUnit() ) { @@ -550,7 +550,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_ return false; } - // Removing the symbol needs to be done before the LIB_PART is changed to prevent stale + // Removing the symbol needs to be done before the LIB_SYMBOL is changed to prevent stale // library symbols in the schematic file. screen->Remove( aSymbol ); frame->SaveCopyInUndoList( screen, aSymbol, UNDO_REDO::CHANGED, aAppendToUndo ); diff --git a/eeschema/dialogs/dialog_choose_symbol.cpp b/eeschema/dialogs/dialog_choose_symbol.cpp index ea3e7871d4..37810ab290 100644 --- a/eeschema/dialogs/dialog_choose_symbol.cpp +++ b/eeschema/dialogs/dialog_choose_symbol.cpp @@ -396,7 +396,7 @@ void DIALOG_CHOOSE_SYMBOL::ShowFootprintFor( LIB_ID const& aLibId ) if( !m_fp_preview || !m_fp_preview->IsInitialized() ) return; - LIB_PART* symbol = nullptr; + LIB_SYMBOL* symbol = nullptr; try { @@ -453,7 +453,7 @@ void DIALOG_CHOOSE_SYMBOL::PopulateFootprintSelector( LIB_ID const& aLibId ) m_fp_sel_ctrl->ClearFilters(); - LIB_PART* symbol = nullptr; + LIB_SYMBOL* symbol = nullptr; if( aLibId.IsValid() ) { diff --git a/eeschema/dialogs/dialog_choose_symbol.h b/eeschema/dialogs/dialog_choose_symbol.h index 4c88194196..8c97d3792f 100644 --- a/eeschema/dialogs/dialog_choose_symbol.h +++ b/eeschema/dialogs/dialog_choose_symbol.h @@ -46,7 +46,6 @@ class SYMBOL_PREVIEW_WIDGET; class FOOTPRINT_PREVIEW_WIDGET; class FOOTPRINT_SELECT_WIDGET; class LIB_ALIAS; -class LIB_PART; class SCH_BASE_FRAME; class SCH_DRAW_PANEL; diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index d4e4beb98c..5f9eca9afb 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -714,7 +714,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow() if( cmp.m_Row != row ) continue; - LIB_PART* symbol = nullptr; + LIB_SYMBOL* symbol = nullptr; try { diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index df6a56629d..dd152ee194 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -318,9 +318,9 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T ) { const SCH_SYMBOL* symbol = (SCH_SYMBOL*) aField->GetParent(); - const LIB_PART* part = GetParent()->GetLibPart( symbol->GetLibId(), true ); + const LIB_SYMBOL* libSymbol = GetParent()->GetLibPart( symbol->GetLibId(), true ); - if( part && part->IsPower() ) + if( libSymbol && libSymbol->IsPower() ) m_isPower = true; } diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp index c229346209..0805814f05 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp @@ -66,7 +66,7 @@ bool DIALOG_LIB_EDIT_DRAW_ITEM::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; - LIB_PART* symbol = m_item->GetParent(); + LIB_SYMBOL* symbol = m_item->GetParent(); m_lineWidth.SetValue( m_item->GetWidth() ); m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 127fe07a86..f01eb17e6e 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -416,10 +416,11 @@ private: }; -DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, LIB_PART* aPart ) : +DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, + LIB_SYMBOL* aSymbol ) : DIALOG_LIB_EDIT_PIN_TABLE_BASE( parent ), m_editFrame( parent ), - m_part( aPart ) + m_part( aSymbol ) { m_dataModel = new PIN_TABLE_DATA_MODEL( GetUserUnits() ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 4110d10178..1838f5e7da 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -51,7 +51,7 @@ class SYMBOL_EDIT_FRAME; class DIALOG_LIB_EDIT_PIN_TABLE : public DIALOG_LIB_EDIT_PIN_TABLE_BASE { public: - DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, LIB_PART* aPart ); + DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, LIB_SYMBOL* aSymbol ); ~DIALOG_LIB_EDIT_PIN_TABLE() override; bool TransferDataToWindow() override; @@ -76,7 +76,7 @@ protected: bool m_initialized = false; int m_originalColWidths[ COL_COUNT ]; wxString m_columnsShown; - LIB_PART* m_part; + LIB_SYMBOL* m_part; LIB_PINS m_pins; // a copy of the pins owned by me bool m_modified; ///< true when there are unsaved changes diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 77917acb9b..23bc7227bb 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -47,7 +47,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::LAST_LAYOUT DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, - LIB_PART* aLibEntry ) : + LIB_SYMBOL* aLibEntry ) : DIALOG_LIB_SYMBOL_PROPERTIES_BASE( aParent ), m_Parent( aParent ), m_libEntry( aLibEntry ), @@ -345,7 +345,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() wxString libName = m_Parent->GetCurLib(); // Get the parent from the libManager based on the name set in the inheritance combo box. - LIB_PART* newParent = m_Parent->GetLibManager().GetAlias( parentName, libName ); + LIB_SYMBOL* newParent = m_Parent->GetLibManager().GetAlias( parentName, libName ); // Verify that the requested parent exists wxCHECK( newParent, false ); @@ -361,7 +361,8 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_libEntry->SetDescription( m_DescCtrl->GetValue() ); m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() ); m_libEntry->SetUnitCount( m_SelNumberOfUnits->GetValue() ); - m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && !m_OptionPartsInterchangeable->GetValue() ); + m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && + !m_OptionPartsInterchangeable->GetValue() ); m_libEntry->SetConversion( m_AsConvertButt->GetValue() ); if( m_OptionPower->GetValue() ) @@ -392,7 +393,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_Parent->UpdateAfterSymbolProperties( &oldName ); // It's possible that the symbol being edited has no pins, in which case there may be no - // alternate body style objects causing #LIB_PART::HasCoversion() to always return false. + // alternate body style objects causing #LIB_SYMBOL::HasCoversion() to always return false. // This allows the user to edit the alternate body style just in case this condition occurs. m_Parent->SetShowDeMorgan( m_AsConvertButt->GetValue() ); @@ -534,7 +535,9 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event ) m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); } else + { wxBell(); + } } diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.h b/eeschema/dialogs/dialog_lib_symbol_properties.h index f23eaa3c31..b6b3652456 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties.h @@ -31,14 +31,14 @@ class SYMBOL_EDIT_FRAME; -class LIB_PART; +class LIB_SYMBOL; class WX_GRID; class DIALOG_LIB_SYMBOL_PROPERTIES: public DIALOG_LIB_SYMBOL_PROPERTIES_BASE { public: - DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PART* aLibEntry ); + DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_SYMBOL* aLibEntry ); ~DIALOG_LIB_SYMBOL_PROPERTIES(); protected: @@ -71,7 +71,7 @@ private: public: SYMBOL_EDIT_FRAME* m_Parent; - LIB_PART* m_libEntry; + LIB_SYMBOL* m_libEntry; FIELDS_GRID_TABLE* m_fields; diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index bcd870b405..7ff23cf606 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -445,7 +445,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() if( m_symbol->GetUnitCount() > 1 ) { for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ ) - m_unitChoice->Append( LIB_PART::SubReference( ii, false ) ); + m_unitChoice->Append( LIB_SYMBOL::SubReference( ii, false ) ); if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() ) m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 ); @@ -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_PART* entry = GetParent()->GetLibPart( m_symbol->GetLibId() ); + LIB_SYMBOL* entry = GetParent()->GetLibPart( m_symbol->GetLibId() ); if( entry && entry->IsPower() ) m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() ); diff --git a/eeschema/dialogs/dialog_symbol_properties.h b/eeschema/dialogs/dialog_symbol_properties.h index 3e0dc74ffc..782bc18db9 100644 --- a/eeschema/dialogs/dialog_symbol_properties.h +++ b/eeschema/dialogs/dialog_symbol_properties.h @@ -30,7 +30,7 @@ #include -class LIB_PART; +class LIB_SYMBOL; class SCH_PIN_TABLE_DATA_MODEL; class SCH_EDIT_FRAME; @@ -90,7 +90,7 @@ private: private: SCH_SYMBOL* m_symbol; - LIB_PART* m_part; + LIB_SYMBOL* m_part; int m_width; int m_delayedFocusRow; diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index fbd54fc1c3..1fa3151280 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -296,7 +296,7 @@ bool DIALOG_SYMBOL_REMAP::remapSymbolToLibTable( SCH_SYMBOL* aSymbol ) if( it->IsCache() ) continue; - LIB_PART* alias = it->FindPart( aSymbol->GetLibId().GetLibItemName().wx_str() ); + LIB_SYMBOL* alias = it->FindPart( aSymbol->GetLibId().GetLibItemName().wx_str() ); // Found in the same library as the old look up method assuming the user didn't // change the libraries or library ordering since the last time the schematic was diff --git a/eeschema/dialogs/dialog_update_symbol_fields.cpp b/eeschema/dialogs/dialog_update_symbol_fields.cpp index b8fd83d6df..9345bcb24b 100644 --- a/eeschema/dialogs/dialog_update_symbol_fields.cpp +++ b/eeschema/dialogs/dialog_update_symbol_fields.cpp @@ -36,7 +36,7 @@ bool g_resetLibFieldPositions = true; DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS( SYMBOL_EDIT_FRAME* aParent, - LIB_PART* aSymbol ) : + LIB_SYMBOL* aSymbol ) : DIALOG_UPDATE_SYMBOL_FIELDS_BASE( aParent ), m_editFrame( aParent ), m_symbol( aSymbol) @@ -82,9 +82,9 @@ DIALOG_UPDATE_SYMBOL_FIELDS::~DIALOG_UPDATE_SYMBOL_FIELDS() void DIALOG_UPDATE_SYMBOL_FIELDS::updateFieldsList() { // Load non-mandatory fields from the parent part - std::vector libFields; - std::set fieldNames; - std::unique_ptr flattenedParent = m_symbol->GetParent().lock()->Flatten(); + std::vector libFields; + std::set fieldNames; + std::unique_ptr flattenedParent = m_symbol->GetParent().lock()->Flatten(); flattenedParent->GetFields( libFields ); @@ -135,7 +135,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent ) m_updateFields.insert( m_fieldsBox->GetString( i ) ); } - std::unique_ptr flattenedParent = m_symbol->GetParent().lock()->Flatten(); + std::unique_ptr flattenedParent = m_symbol->GetParent().lock()->Flatten(); bool removeExtras = m_removeExtraBox->GetValue(); bool resetVis = m_resetFieldVisibilities->GetValue(); diff --git a/eeschema/dialogs/dialog_update_symbol_fields.h b/eeschema/dialogs/dialog_update_symbol_fields.h index b21f3151a5..eed26248ff 100644 --- a/eeschema/dialogs/dialog_update_symbol_fields.h +++ b/eeschema/dialogs/dialog_update_symbol_fields.h @@ -24,7 +24,7 @@ #include class LIB_ID; -class LIB_PART; +class LIB_SYMBOL; class SYMBOL_EDIT_FRAME; /** @@ -33,7 +33,7 @@ class SYMBOL_EDIT_FRAME; class DIALOG_UPDATE_SYMBOL_FIELDS : public DIALOG_UPDATE_SYMBOL_FIELDS_BASE { public: - DIALOG_UPDATE_SYMBOL_FIELDS( SYMBOL_EDIT_FRAME* aParent, LIB_PART* aPart ); + DIALOG_UPDATE_SYMBOL_FIELDS( SYMBOL_EDIT_FRAME* aParent, LIB_SYMBOL* aSymbol ); ~DIALOG_UPDATE_SYMBOL_FIELDS() override; protected: @@ -56,7 +56,7 @@ private: void updateFieldsList(); SYMBOL_EDIT_FRAME* m_editFrame; - LIB_PART* m_symbol; + LIB_SYMBOL* m_symbol; ///< Set of field names that should have values updated std::set m_updateFields; diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index fe4388c55c..a911dac1e3 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -331,26 +331,26 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() t2->SetSelected(); { - LIB_PART* part = new LIB_PART( wxEmptyString ); + LIB_SYMBOL* symbol = new LIB_SYMBOL( wxEmptyString ); wxPoint p( 2625, -1600 ); - LIB_FIELD& ref = part->GetReferenceField(); + LIB_FIELD& ref = symbol->GetReferenceField(); ref.SetText( wxT( "U1" ) ); ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) ); ref.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - LIB_FIELD& value = part->GetValueField(); + LIB_FIELD& value = symbol->GetValueField(); value.SetText( wxT( "OPA604" ) ); value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) ); value.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - part->SetShowPinNames( true ); - part->SetShowPinNumbers( true ); - part->SetPinNameOffset( 0 ); + symbol->SetShowPinNames( true ); + symbol->SetShowPinNumbers( true ); + symbol->SetPinNameOffset( 0 ); - LIB_POLYLINE* comp_body = new LIB_POLYLINE( part ); + LIB_POLYLINE* comp_body = new LIB_POLYLINE( symbol ); comp_body->SetUnit( 0 ); comp_body->SetConvert( 0 ); @@ -363,7 +363,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() addItem( comp_body ); - LIB_PIN* pin = new LIB_PIN( part ); + LIB_PIN* pin = new LIB_PIN( symbol ); pin->SetPosition( MILS_POINT( p.x - 200, p.y + 100 ) ); pin->SetLength( Mils2iu( 100 ) ); @@ -372,9 +372,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() pin->SetNumber( wxT( "1" ) ); pin->SetName( wxT( "-" ) ); - part->AddDrawItem( pin ); + symbol->AddDrawItem( pin ); - pin = new LIB_PIN( part ); + pin = new LIB_PIN( symbol ); pin->SetPosition( MILS_POINT( p.x - 200, p.y - 100 ) ); pin->SetLength( Mils2iu( 100 ) ); @@ -383,9 +383,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() pin->SetNumber( wxT( "2" ) ); pin->SetName( wxT( "+" ) ); - part->AddDrawItem( pin ); + symbol->AddDrawItem( pin ); - pin = new LIB_PIN( part ); + pin = new LIB_PIN( symbol ); pin->SetPosition( MILS_POINT( p.x + 200, p.y ) ); pin->SetLength( Mils2iu( 100 ) ); @@ -394,9 +394,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() pin->SetNumber( wxT( "3" ) ); pin->SetName( wxT( "OUT" ) ); - part->AddDrawItem( pin ); + symbol->AddDrawItem( pin ); - addItem( part ); + addItem( symbol ); } SCH_SHEET* s = new SCH_SHEET( nullptr, MILS_POINT( 4000, 1300 ) ); diff --git a/eeschema/dialogs/panel_setup_formatting.cpp b/eeschema/dialogs/panel_setup_formatting.cpp index 76206f7cd6..54d1b9a54a 100644 --- a/eeschema/dialogs/panel_setup_formatting.cpp +++ b/eeschema/dialogs/panel_setup_formatting.cpp @@ -59,13 +59,13 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() // Reference style one of: "A" ".A" "-A" "_A" ".1" "-1" "_1" int refStyleSelection; - switch( LIB_PART::GetSubpartIdSeparator() ) + switch( LIB_SYMBOL::GetSubpartIdSeparator() ) { default: case 0: refStyleSelection = 0; break; - case '.': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 4 : 1; break; - case '-': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 5 : 2; break; - case '_': refStyleSelection = LIB_PART::GetSubpartFirstId() == '1' ? 6 : 3; break; + case '.': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 4 : 1; break; + case '-': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 5 : 2; break; + case '_': refStyleSelection = LIB_SYMBOL::GetSubpartFirstId() == '1' ? 6 : 3; break; } m_choiceSeparatorRefId->SetSelection( refStyleSelection ); @@ -119,10 +119,10 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() case 6: firstRefId = '1'; refSeparator = '_'; break; } - if( refSeparator != LIB_PART::GetSubpartIdSeparator() || - firstRefId != LIB_PART::GetSubpartFirstId() ) + if( refSeparator != LIB_SYMBOL::GetSubpartIdSeparator() || + firstRefId != LIB_SYMBOL::GetSubpartFirstId() ) { - LIB_PART::SetSubpartIdNotation( refSeparator, firstRefId ); + LIB_SYMBOL::SetSubpartIdNotation( refSeparator, firstRefId ); } settings.m_DefaultTextSize = (int) m_textSize.GetValue(); diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 67cd2e53e3..852523c721 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -799,11 +799,11 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event ) bool PANEL_SYM_LIB_TABLE::convertLibrary( const wxString& aLibrary, const wxString& legacyFilepath, const wxString& newFilepath ) { - SCH_PLUGIN::SCH_PLUGIN_RELEASER legacyPI( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); - SCH_PLUGIN::SCH_PLUGIN_RELEASER kicadPI( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) ); - std::vector parts; - std::vector newParts; - std::map partMap; + SCH_PLUGIN::SCH_PLUGIN_RELEASER legacyPI( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); + SCH_PLUGIN::SCH_PLUGIN_RELEASER kicadPI( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) ); + std::vector symbols; + std::vector newSymbols; + std::map symbolMap; try { @@ -816,32 +816,32 @@ bool PANEL_SYM_LIB_TABLE::convertLibrary( const wxString& aLibrary, const wxStri // This will write the file delete formatter; - legacyPI->EnumerateSymbolLib( parts, legacyFilepath ); + legacyPI->EnumerateSymbolLib( symbols, legacyFilepath ); - // Copy non-aliases first so we can build a map from parts to newParts - for( LIB_PART* part : parts ) + // Copy non-aliases first so we can build a map from symbols to newSymbols + for( LIB_SYMBOL* symbol : symbols ) { - if( part->IsAlias() ) + if( symbol->IsAlias() ) continue; - newParts.push_back( new LIB_PART( *part ) ); - partMap[part] = newParts.back(); + newSymbols.push_back( new LIB_SYMBOL( *symbol ) ); + symbolMap[symbol] = newSymbols.back(); } - // Now do the aliases using the map to hook them up to their newPart parents - for( LIB_PART* part : parts ) + // Now do the aliases using the map to hook them up to their newSymbol parents + for( LIB_SYMBOL* symbol : symbols ) { - if( !part->IsAlias() ) + if( !symbol->IsAlias() ) continue; - newParts.push_back( new LIB_PART( *part ) ); - newParts.back()->SetParent( partMap[ part->GetParent().lock().get() ] ); + newSymbols.push_back( new LIB_SYMBOL( *symbol ) ); + newSymbols.back()->SetParent( symbolMap[ symbol->GetParent().lock().get() ] ); } - // Finally write out newParts - for( LIB_PART* part : newParts ) + // Finally write out newSymbols + for( LIB_SYMBOL* symbol : newSymbols ) { - kicadPI->SaveSymbol( newFilepath, part ); + kicadPI->SaveSymbol( newFilepath, symbol ); } } catch( ... ) diff --git a/eeschema/ee_collectors.h b/eeschema/ee_collectors.h index 28b99f303a..292e38634d 100644 --- a/eeschema/ee_collectors.h +++ b/eeschema/ee_collectors.h @@ -90,7 +90,7 @@ public: /** * Scan an #EDA_ITEM using this class's Inspector method which does the collection. * - * @param aItems is a LIB_PART multivector holding the part items. + * @param aItems is a LIB_SYMBOL multivector holding the symbol items. * @param aFilterList is a list of #KICAD_T types with a terminating #EOT, that determines * what is to be collected and the priority order of the resulting * collection. diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 069527a83a..91fecebc13 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -86,8 +86,8 @@ bool SCH_EDIT_FRAME::LoadProjectSettings() // Verify some values, because the config file can be edited by hand, // and have bad values: - LIB_PART::SetSubpartIdNotation( LIB_PART::GetSubpartIdSeparator(), - LIB_PART::GetSubpartFirstId() ); + LIB_SYMBOL::SetSubpartIdNotation( LIB_SYMBOL::GetSubpartIdSeparator(), + LIB_SYMBOL::GetSubpartFirstId() ); // Load the drawing sheet description file, from the filename stored in // BASE_SCREEN::m_DrawingSheetFileName, read in config project file diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 90be30e40b..cbcdc518fb 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -690,7 +690,7 @@ int ERC_TESTER::TestLibSymbolIssues() wxCHECK2( symbol, continue ); - LIB_PART* libSymbolInSchematic = symbol->GetPartRef().get(); + LIB_SYMBOL* libSymbolInSchematic = symbol->GetPartRef().get(); wxCHECK2( libSymbolInSchematic, continue ); @@ -720,8 +720,8 @@ int ERC_TESTER::TestLibSymbolIssues() break; } - wxString symbolName = symbol->GetLibId().GetLibItemName(); - LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable ); + wxString symbolName = symbol->GetLibId().GetLibItemName(); + LIB_SYMBOL* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable ); if( libSymbol == nullptr ) { @@ -736,7 +736,7 @@ int ERC_TESTER::TestLibSymbolIssues() break; } - std::unique_ptr flattenedSymbol = libSymbol->Flatten(); + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); if( *flattenedSymbol != *libSymbolInSchematic ) { diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 082d98cb29..beb31d854c 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -47,13 +47,13 @@ enum template FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, - WX_GRID* aGrid, LIB_PART* aPart ) : + WX_GRID* aGrid, LIB_SYMBOL* aSymbol ) : m_frame( aFrame ), m_userUnits( aDialog->GetUserUnits() ), m_grid( aGrid ), m_parentType( SCH_SYMBOL_T ), m_mandatoryFieldCount( MANDATORY_FIELDS ), - m_part( aPart ), + m_part( aSymbol ), m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ), m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ), diff --git a/eeschema/fields_grid_table.h b/eeschema/fields_grid_table.h index e5543401e4..03fbc82ce2 100644 --- a/eeschema/fields_grid_table.h +++ b/eeschema/fields_grid_table.h @@ -73,7 +73,7 @@ class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector { public: FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, - LIB_PART* aPart ); + LIB_SYMBOL* aSymbol ); FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, SCH_SHEET* aSheet ); ~FIELDS_GRID_TABLE(); @@ -110,7 +110,7 @@ private: WX_GRID* m_grid; KICAD_T m_parentType; int m_mandatoryFieldCount; - LIB_PART* m_part; + LIB_SYMBOL* m_part; wxString m_curdir; SCH_FIELD_VALIDATOR m_fieldNameValidator; diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index ae1d0f22ac..f3dc1dffd3 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -50,7 +50,7 @@ class FOOTPRINT_INFO_GENERATOR wxString m_html; SYMBOL_LIB_TABLE* m_sym_lib_table; LIB_ID const m_lib_id; - LIB_PART* m_symbol; + LIB_SYMBOL* m_symbol; int m_unit; public: @@ -122,7 +122,7 @@ protected: wxString root_name = _( "Unknown" ); wxString root_desc = ""; - std::shared_ptr< LIB_PART > parent = m_symbol->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > parent = m_symbol->GetParent().lock(); if( parent ) { @@ -212,7 +212,7 @@ protected: if( m_symbol->IsAlias() ) { - std::shared_ptr parent = m_symbol->GetParent().lock(); + std::shared_ptr parent = m_symbol->GetParent().lock(); // Append all of the unique parent fields if this is an alias. if( parent ) diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 6ff44213c7..2072645a14 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_PART* symbol = GetLibPart( i.LibId ); + LIB_SYMBOL* symbol = GetLibPart( i.LibId ); // This can be null, for example when a symbol has been deleted from a library if( symbol ) @@ -196,12 +196,12 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilte void SCH_EDIT_FRAME::SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ) { - LIB_PART* part = GetLibPart( aSymbol->GetLibId() ); + LIB_SYMBOL* symbol = GetLibPart( aSymbol->GetLibId() ); - if( !part ) + if( !symbol ) return; - int unitCount = part->GetUnitCount(); + int unitCount = symbol->GetUnitCount(); if( unitCount <= 1 || aSymbol->GetUnit() == aUnit ) return; diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index b7d99da731..625efe4873 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -46,7 +46,6 @@ class wxFrame; class wxDialog; -class LIB_PART; class PART_LIBS; class SCH_SYMBOL; class SCH_TEXT; diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index bf0d887ffc..5833c86c1f 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -44,7 +44,7 @@ static inline wxPoint twoPointVector( const wxPoint &startPoint, const wxPoint & } -LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent ) +LIB_ARC::LIB_ARC( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_ARC_T, aParent ) { m_Radius = 0; m_t1 = 0; diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index b92211a30a..513a836851 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -35,7 +35,7 @@ class TRANSFORM; class LIB_ARC : public LIB_ITEM { public: - LIB_ARC( LIB_PART * aParent ); + LIB_ARC( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 56150859a1..6ab3a92a05 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -35,7 +35,7 @@ #include -LIB_BEZIER::LIB_BEZIER( LIB_PART* aParent ) : +LIB_BEZIER::LIB_BEZIER( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_BEZIER_T, aParent ) { m_fill = FILL_TYPE::NO_FILL; diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index b5c8b3b13e..6235df1985 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -34,7 +34,7 @@ class LIB_BEZIER : public LIB_ITEM { public: - LIB_BEZIER( LIB_PART * aParent ); + LIB_BEZIER( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index a026a35aa1..3ec9fcffa6 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -36,7 +36,7 @@ #include -LIB_CIRCLE::LIB_CIRCLE( LIB_PART* aParent ) : +LIB_CIRCLE::LIB_CIRCLE( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_CIRCLE_T, aParent ) { m_Width = 0; diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index 405382a54e..6676412f65 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -31,7 +31,7 @@ class LIB_CIRCLE : public LIB_ITEM { public: - LIB_CIRCLE( LIB_PART* aParent ); + LIB_CIRCLE( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 25a63bdda4..da62355e69 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -40,7 +40,7 @@ #include -LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) : +LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int idfield ) : LIB_ITEM( LIB_FIELD_T, aParent ) { Init( idfield ); @@ -129,7 +129,7 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const // Reference designator text has one or 2 additional character (displays U? or U?A) if( m_id == REFERENCE_FIELD ) { - const LIB_PART* parent = dynamic_cast( m_parent ); + const LIB_SYMBOL* parent = dynamic_cast( m_parent ); wxString extended_text = tmp_text.GetText(); extended_text.Append('?'); @@ -303,7 +303,7 @@ wxString LIB_FIELD::GetFullText( int unit ) const wxCHECK( GetParent(), text ); if( GetParent()->IsMulti() ) - text << LIB_PART::SubReference( unit ); + text << LIB_SYMBOL::SubReference( unit ); return text; } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 7840e1ca73..eb2b889406 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -58,35 +58,12 @@ class SCH_LEGACY_PLUGIN_CACHE; */ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT { - int m_id; ///< @see enum MANDATORY_FIELD_T - wxString m_name; ///< Name (not the field text value itself, that is .m_Text) - - /** - * Print the field. - *

- * If \a aData not NULL, \a aData must point a wxString which is used instead of - * the m_Text - *

- */ - void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; - - /** - * Calculate the new circle at \a aPosition when editing. - * - * @param aPosition - The position to edit the circle in drawing coordinates. - */ - void CalcEdit( const wxPoint& aPosition ) override; - - friend class SCH_LEGACY_PLUGIN_CACHE; // Required to access m_name. - public: - LIB_FIELD( int idfield = 2 ); LIB_FIELD( int aID, const wxString& aName ); - LIB_FIELD( LIB_PART * aParent, int idfield = 2 ); + LIB_FIELD( LIB_SYMBOL* aParent, int idfield = 2 ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -213,6 +190,27 @@ private: */ int compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override; + + /** + * Print the field. + * + * If \a aData not NULL, \a aData must point a wxString which is used instead of + * the m_Text + */ + void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; + + /** + * Calculate the new circle at \a aPosition when editing. + * + * @param aPosition - The position to edit the circle in drawing coordinates. + */ + void CalcEdit( const wxPoint& aPosition ) override; + + friend class SCH_LEGACY_PLUGIN_CACHE; // Required to access m_name. + + int m_id; ///< @see enum MANDATORY_FIELD_T + wxString m_name; ///< Name (not the field text value itself, that is .m_Text) }; #endif // CLASS_LIBENTRY_FIELDS_H diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp index 2d282b8d62..a8d60348e8 100644 --- a/eeschema/lib_item.cpp +++ b/eeschema/lib_item.cpp @@ -33,7 +33,7 @@ const int fill_tab[3] = { 'N', 'F', 'f' }; LIB_ITEM::LIB_ITEM( KICAD_T aType, - LIB_PART* aComponent, + LIB_SYMBOL* aSymbol, int aUnit, int aConvert, FILL_TYPE aFillType ) : @@ -42,7 +42,7 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType, m_unit = aUnit; m_convert = aConvert; m_fill = aFillType; - m_parent = (EDA_ITEM*) aComponent; + m_parent = (EDA_ITEM*) aSymbol; m_isFillable = false; } diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index aa21f27264..c466697a1e 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -34,7 +34,7 @@ class LINE_READER; class OUTPUTFORMATTER; -class LIB_PART; +class LIB_SYMBOL; class PLOTTER; class LIB_PIN; class MSG_PANEL_ITEM; @@ -61,7 +61,7 @@ typedef std::vector< LIB_PIN* > LIB_PINS; class LIB_ITEM : public EDA_ITEM { public: - LIB_ITEM( KICAD_T aType, LIB_PART* aComponent = NULL, int aUnit = 0, int aConvert = 0, + LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol = nullptr, int aUnit = 0, int aConvert = 0, FILL_TYPE aFillType = FILL_TYPE::NO_FILL ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -143,9 +143,9 @@ public: virtual int GetPenWidth() const = 0; - LIB_PART* GetParent() const + LIB_SYMBOL* GetParent() const { - return (LIB_PART*) m_parent; + return (LIB_SYMBOL*) m_parent; } void ViewGetLayers( int aLayers[], int& aCount ) const override; @@ -304,7 +304,7 @@ protected: const TRANSFORM& aTransform ) = 0; private: - friend class LIB_PART; + friend class LIB_SYMBOL; protected: /** diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index a2a433868c..2830acf4ce 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -90,7 +90,7 @@ static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN } -LIB_PIN::LIB_PIN( LIB_PART* aParent ) : +LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_PIN_T, aParent ), m_orientation( PIN_RIGHT ), m_shape( GRAPHIC_PINSHAPE::LINE ), @@ -117,7 +117,7 @@ LIB_PIN::LIB_PIN( LIB_PART* aParent ) : } -LIB_PIN::LIB_PIN( LIB_PART* aParent, const wxString& aName, const wxString& aNumber, +LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber, int aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, int aNameTextSize, int aNumTextSize, int aConvert, const wxPoint& aPos, int aUnit ) : LIB_ITEM( LIB_PIN_T, aParent ), @@ -185,7 +185,7 @@ void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, v bool showPinType = opts ? opts->show_elec_type : false; bool show_connect_point = opts ? opts->show_connect_point : false; - LIB_PART* part = GetParent(); + LIB_SYMBOL* part = GetParent(); /* Calculate pin orient taking in account the component orientation. */ int orient = PinDrawOrient( aTransform ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 74a3a2d7d8..40670cf3b6 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -152,9 +152,9 @@ public: */ int PinDrawOrient( const TRANSFORM& aTransform ) const; - LIB_PIN( LIB_PART* aParent ); + LIB_PIN( LIB_SYMBOL* aParent ); - LIB_PIN( LIB_PART* aParent, const wxString& aName, const wxString& aNumber, int aOrientation, + LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber, int aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, int aNameTextSize, int aNumTextSize, int aConvert, const wxPoint& aPos, int aUnit ); @@ -186,7 +186,7 @@ public: bool IsPowerConnection() const { return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN - && ( !IsVisible() || (LIB_PART*) GetParent()->IsPower() ); + && ( !IsVisible() || (LIB_SYMBOL*) GetParent()->IsPower() ); } int GetPenWidth() const override; diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 4a63b1d020..527526d4ec 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -36,7 +36,7 @@ #include -LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) : +LIB_POLYLINE::LIB_POLYLINE( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_POLYLINE_T, aParent ) { m_fill = FILL_TYPE::NO_FILL; diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 5a5cc26517..7516c39c05 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -31,7 +31,7 @@ class LIB_POLYLINE : public LIB_ITEM { public: - LIB_POLYLINE( LIB_PART * aParent ); + LIB_POLYLINE( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 8512bb0307..4bb75b931a 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -35,7 +35,7 @@ #include -LIB_RECTANGLE::LIB_RECTANGLE( LIB_PART* aParent ) : LIB_ITEM( LIB_RECTANGLE_T, aParent ) +LIB_RECTANGLE::LIB_RECTANGLE( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_RECTANGLE_T, aParent ) { m_Width = 0; m_fill = FILL_TYPE::NO_FILL; diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 6168a91705..afc5e0e312 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -31,7 +31,7 @@ class LIB_RECTANGLE : public LIB_ITEM { public: - LIB_RECTANGLE( LIB_PART * aParent ); + LIB_RECTANGLE( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 73c2092e21..1306c4e05f 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -38,15 +38,15 @@ // the separator char between the subpart id and the reference // 0 (no separator) or '.' or some other character -int LIB_PART::m_subpartIdSeparator = 0; +int LIB_SYMBOL::m_subpartIdSeparator = 0; // the ascii char value to calculate the subpart symbol id from the part number: // 'A' or '1' usually. (to print U1.A or U1.1) // if this a digit, a number is used as id symbol -int LIB_PART::m_subpartFirstId = 'A'; +int LIB_SYMBOL::m_subpartFirstId = 'A'; -wxString LIB_PART::GetSearchText() +wxString LIB_SYMBOL::GetSearchText() { // Matches are scored by offset from front of string, so inclusion of this spacer // discounts matches found after it. @@ -64,7 +64,7 @@ wxString LIB_PART::GetSearchText() } -bool operator<( const LIB_PART& aItem1, const LIB_PART& aItem2 ) +bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 ) { return aItem1.GetName() < aItem2.GetName(); } @@ -79,8 +79,8 @@ struct null_deleter }; -LIB_PART::LIB_PART( const wxString& aName, LIB_PART* aParent, PART_LIB* aLibrary ) : - EDA_ITEM( LIB_PART_T ), +LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, PART_LIB* aLibrary ) : + EDA_ITEM( LIB_SYMBOL_T ), m_me( this, null_deleter() ), m_includeInBom( true ), m_includeOnBoard( true ) @@ -110,31 +110,31 @@ LIB_PART::LIB_PART( const wxString& aName, LIB_PART* aParent, PART_LIB* aLibrary } -LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) : - EDA_ITEM( aPart ), +LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, PART_LIB* aLibrary ) : + EDA_ITEM( aSymbol ), m_me( this, null_deleter() ) { LIB_ITEM* newItem; m_library = aLibrary; - m_name = aPart.m_name; - m_fpFilters = wxArrayString( aPart.m_fpFilters ); - m_unitCount = aPart.m_unitCount; - m_unitsLocked = aPart.m_unitsLocked; - m_pinNameOffset = aPart.m_pinNameOffset; - m_showPinNumbers = aPart.m_showPinNumbers; - m_includeInBom = aPart.m_includeInBom; - m_includeOnBoard = aPart.m_includeOnBoard; - m_showPinNames = aPart.m_showPinNames; - m_lastModDate = aPart.m_lastModDate; - m_options = aPart.m_options; - m_libId = aPart.m_libId; - m_description = aPart.m_description; - m_keyWords = aPart.m_keyWords; + m_name = aSymbol.m_name; + m_fpFilters = wxArrayString( aSymbol.m_fpFilters ); + m_unitCount = aSymbol.m_unitCount; + m_unitsLocked = aSymbol.m_unitsLocked; + m_pinNameOffset = aSymbol.m_pinNameOffset; + m_showPinNumbers = aSymbol.m_showPinNumbers; + m_includeInBom = aSymbol.m_includeInBom; + m_includeOnBoard = aSymbol.m_includeOnBoard; + m_showPinNames = aSymbol.m_showPinNames; + m_lastModDate = aSymbol.m_lastModDate; + m_options = aSymbol.m_options; + m_libId = aSymbol.m_libId; + m_description = aSymbol.m_description; + m_keyWords = aSymbol.m_keyWords; ClearSelected(); - for( const LIB_ITEM& oldItem : aPart.m_drawings ) + for( const LIB_ITEM& oldItem : aSymbol.m_drawings ) { if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) continue; @@ -152,44 +152,44 @@ LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) : } } - PART_SPTR parent = aPart.m_parent.lock(); + PART_SPTR parent = aSymbol.m_parent.lock(); if( parent ) SetParent( parent.get() ); } -LIB_PART::~LIB_PART() +LIB_SYMBOL::~LIB_SYMBOL() { } -const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart ) +const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) { - if( &aPart == this ) - return aPart; + if( &aSymbol == this ) + return aSymbol; LIB_ITEM* newItem; - m_library = aPart.m_library; - m_name = aPart.m_name; - m_fpFilters = wxArrayString( aPart.m_fpFilters ); - m_unitCount = aPart.m_unitCount; - m_unitsLocked = aPart.m_unitsLocked; - m_pinNameOffset = aPart.m_pinNameOffset; - m_showPinNumbers = aPart.m_showPinNumbers; - m_showPinNames = aPart.m_showPinNames; - m_includeInBom = aPart.m_includeInBom; - m_includeOnBoard = aPart.m_includeOnBoard; - m_lastModDate = aPart.m_lastModDate; - m_options = aPart.m_options; - m_libId = aPart.m_libId; - m_description = aPart.m_description; - m_keyWords = aPart.m_keyWords; + m_library = aSymbol.m_library; + m_name = aSymbol.m_name; + m_fpFilters = wxArrayString( aSymbol.m_fpFilters ); + m_unitCount = aSymbol.m_unitCount; + m_unitsLocked = aSymbol.m_unitsLocked; + m_pinNameOffset = aSymbol.m_pinNameOffset; + m_showPinNumbers = aSymbol.m_showPinNumbers; + m_showPinNames = aSymbol.m_showPinNames; + m_includeInBom = aSymbol.m_includeInBom; + m_includeOnBoard = aSymbol.m_includeOnBoard; + m_lastModDate = aSymbol.m_lastModDate; + m_options = aSymbol.m_options; + m_libId = aSymbol.m_libId; + m_description = aSymbol.m_description; + m_keyWords = aSymbol.m_keyWords; m_drawings.clear(); - for( const LIB_ITEM& oldItem : aPart.m_drawings ) + for( const LIB_ITEM& oldItem : aSymbol.m_drawings ) { if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) continue; @@ -201,7 +201,7 @@ const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart ) m_drawings.sort(); - PART_SPTR parent = aPart.m_parent.lock(); + PART_SPTR parent = aSymbol.m_parent.lock(); if( parent ) SetParent( parent.get() ); @@ -210,7 +210,7 @@ const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart ) } -int LIB_PART::Compare( const LIB_PART& aRhs ) const +int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs ) const { if( m_me == aRhs.m_me ) return 0; @@ -305,13 +305,13 @@ int LIB_PART::Compare( const LIB_PART& aRhs ) const } -wxString LIB_PART::GetUnitReference( int aUnit ) +wxString LIB_SYMBOL::GetUnitReference( int aUnit ) { - return LIB_PART::SubReference( aUnit, false ); + return LIB_SYMBOL::SubReference( aUnit, false ); } -void LIB_PART::SetName( const wxString& aName ) +void LIB_SYMBOL::SetName( const wxString& aName ) { wxString validatedName = LIB_ID::FixIllegalChars( aName ); @@ -322,7 +322,7 @@ void LIB_PART::SetName( const wxString& aName ) } -void LIB_PART::SetParent( LIB_PART* aParent ) +void LIB_SYMBOL::SetParent( LIB_SYMBOL* aParent ) { if( aParent ) m_parent = aParent->SharedPtr(); @@ -331,9 +331,9 @@ void LIB_PART::SetParent( LIB_PART* aParent ) } -std::unique_ptr< LIB_PART > LIB_PART::Flatten() const +std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const { - std::unique_ptr< LIB_PART > retv; + std::unique_ptr< LIB_SYMBOL > retv; if( IsAlias() ) { @@ -343,7 +343,7 @@ std::unique_ptr< LIB_PART > LIB_PART::Flatten() const wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) ); // Copy the parent. - retv.reset( new LIB_PART( *parent.get() ) ); + retv.reset( new LIB_SYMBOL( *parent.get() ) ); retv->SetName( m_name ); @@ -392,14 +392,14 @@ std::unique_ptr< LIB_PART > LIB_PART::Flatten() const } else { - retv.reset( new LIB_PART( *this ) ); + retv.reset( new LIB_SYMBOL( *this ) ); } return retv; } -const wxString LIB_PART::GetLibraryName() const +const wxString LIB_SYMBOL::GetLibraryName() const { if( m_library ) return m_library->GetName(); @@ -408,7 +408,7 @@ const wxString LIB_PART::GetLibraryName() const } -bool LIB_PART::IsPower() const +bool LIB_SYMBOL::IsPower() const { if( PART_SPTR parent = m_parent.lock() ) return parent->m_options == ENTRY_POWER; @@ -417,7 +417,7 @@ bool LIB_PART::IsPower() const } -void LIB_PART::SetPower() +void LIB_SYMBOL::SetPower() { if( PART_SPTR parent = m_parent.lock() ) parent->m_options = ENTRY_POWER; @@ -426,7 +426,7 @@ void LIB_PART::SetPower() } -bool LIB_PART::IsNormal() const +bool LIB_SYMBOL::IsNormal() const { if( PART_SPTR parent = m_parent.lock() ) return parent->m_options == ENTRY_NORMAL; @@ -435,7 +435,7 @@ bool LIB_PART::IsNormal() const } -void LIB_PART::SetNormal() +void LIB_SYMBOL::SetNormal() { if( PART_SPTR parent = m_parent.lock() ) parent->m_options = ENTRY_NORMAL; @@ -444,7 +444,7 @@ void LIB_PART::SetNormal() } -wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator ) +wxString LIB_SYMBOL::SubReference( int aUnit, bool aAddSeparator ) { wxString subRef; @@ -476,8 +476,8 @@ wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator ) } -void LIB_PART::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, - int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ) +void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, + int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ) { /* draw background for filled items using background option * Solid lines will be drawn after the background @@ -543,8 +543,8 @@ void LIB_PART::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, } -void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, - const TRANSFORM& aTransform ) const +void LIB_SYMBOL::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, + const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != NULL ); @@ -589,8 +589,8 @@ void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& } -void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, - const wxPoint& aOffset, const TRANSFORM& aTransform ) +void LIB_SYMBOL::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, + const wxPoint& aOffset, const TRANSFORM& aTransform ) { wxASSERT( aPlotter != NULL ); @@ -626,7 +626,7 @@ void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, } -void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem ) +void LIB_SYMBOL::RemoveDrawItem( LIB_ITEM* aItem ) { wxASSERT( aItem != NULL ); @@ -652,7 +652,7 @@ void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem ) } -void LIB_PART::AddDrawItem( LIB_ITEM* aItem, bool aSort ) +void LIB_SYMBOL::AddDrawItem( LIB_ITEM* aItem, bool aSort ) { wxCHECK( aItem, /* void */ ); @@ -663,7 +663,7 @@ void LIB_PART::AddDrawItem( LIB_ITEM* aItem, bool aSort ) } -LIB_ITEM* LIB_PART::GetNextDrawItem( const LIB_ITEM* aItem, KICAD_T aType ) +LIB_ITEM* LIB_SYMBOL::GetNextDrawItem( const LIB_ITEM* aItem, KICAD_T aType ) { if( aItem == NULL ) { @@ -692,7 +692,7 @@ LIB_ITEM* LIB_PART::GetNextDrawItem( const LIB_ITEM* aItem, KICAD_T aType ) } -void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) const +void LIB_SYMBOL::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) const { /* Notes: * when aUnit == 0: no unit filtering @@ -719,7 +719,7 @@ void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert ) const } -LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert ) const +LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aConvert ) const { LIB_PINS pinList; @@ -737,8 +737,8 @@ LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert ) co } -bool LIB_PART::PinsConflictWith( const LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, - bool aTestType, bool aTestOrientation, bool aTestLength ) const +bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames, + bool aTestType, bool aTestOrientation, bool aTestLength ) const { LIB_PINS thisPinList; GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 ); @@ -804,7 +804,7 @@ bool LIB_PART::PinsConflictWith( const LIB_PART& aOtherPart, bool aTestNums, boo } -const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const +const EDA_RECT LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert ) const { EDA_RECT bBox; bool initialized = false; @@ -838,7 +838,7 @@ const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const } -void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const +void LIB_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 6; aLayers[0] = LAYER_DEVICE; @@ -850,7 +850,7 @@ void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const } -const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const +const EDA_RECT LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aConvert ) const { EDA_RECT bbox; @@ -875,19 +875,19 @@ const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const } -void LIB_PART::deleteAllFields() +void LIB_SYMBOL::deleteAllFields() { m_drawings[ LIB_FIELD_T ].clear(); } -void LIB_PART::AddField( LIB_FIELD* aField ) +void LIB_SYMBOL::AddField( LIB_FIELD* aField ) { AddDrawItem( aField ); } -void LIB_PART::SetFields( const std::vector & aFields ) +void LIB_SYMBOL::SetFields( const std::vector & aFields ) { deleteAllFields(); @@ -904,7 +904,7 @@ void LIB_PART::SetFields( const std::vector & aFields ) } -void LIB_PART::GetFields( std::vector& aList ) +void LIB_SYMBOL::GetFields( std::vector& aList ) { // Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T for( int id = 0; id < MANDATORY_FIELDS; ++id ) @@ -921,7 +921,7 @@ void LIB_PART::GetFields( std::vector& aList ) } -void LIB_PART::GetFields( std::vector& aList ) +void LIB_SYMBOL::GetFields( std::vector& aList ) { // Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T for( int id = 0; id < MANDATORY_FIELDS; ++id ) @@ -938,7 +938,7 @@ void LIB_PART::GetFields( std::vector& aList ) } -LIB_FIELD* LIB_PART::GetFieldById( int aId ) const +LIB_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const { for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { @@ -952,7 +952,7 @@ LIB_FIELD* LIB_PART::GetFieldById( int aId ) const } -LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName ) +LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName ) { for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { @@ -964,7 +964,7 @@ LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName ) } -const LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName ) const +const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName ) const { for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { @@ -976,7 +976,7 @@ const LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName ) const } -LIB_FIELD& LIB_PART::GetValueField() +LIB_FIELD& LIB_SYMBOL::GetValueField() { LIB_FIELD* field = GetFieldById( VALUE_FIELD ); wxASSERT( field != NULL ); @@ -984,7 +984,7 @@ LIB_FIELD& LIB_PART::GetValueField() } -LIB_FIELD& LIB_PART::GetReferenceField() +LIB_FIELD& LIB_SYMBOL::GetReferenceField() { LIB_FIELD* field = GetFieldById( REFERENCE_FIELD ); wxASSERT( field != NULL ); @@ -992,7 +992,7 @@ LIB_FIELD& LIB_PART::GetReferenceField() } -LIB_FIELD& LIB_PART::GetFootprintField() +LIB_FIELD& LIB_SYMBOL::GetFootprintField() { LIB_FIELD* field = GetFieldById( FOOTPRINT_FIELD ); wxASSERT( field != NULL ); @@ -1000,7 +1000,7 @@ LIB_FIELD& LIB_PART::GetFootprintField() } -LIB_FIELD& LIB_PART::GetDatasheetField() +LIB_FIELD& LIB_SYMBOL::GetDatasheetField() { LIB_FIELD* field = GetFieldById( DATASHEET_FIELD ); wxASSERT( field != NULL ); @@ -1008,20 +1008,20 @@ LIB_FIELD& LIB_PART::GetDatasheetField() } -void LIB_PART::SetOffset( const wxPoint& aOffset ) +void LIB_SYMBOL::SetOffset( const wxPoint& aOffset ) { for( LIB_ITEM& item : m_drawings ) item.Offset( aOffset ); } -void LIB_PART::RemoveDuplicateDrawItems() +void LIB_SYMBOL::RemoveDuplicateDrawItems() { m_drawings.unique(); } -bool LIB_PART::HasConversion() const +bool LIB_SYMBOL::HasConversion() const { for( const LIB_ITEM& item : m_drawings ) { @@ -1042,22 +1042,22 @@ bool LIB_PART::HasConversion() const } -void LIB_PART::ClearTempFlags() +void LIB_SYMBOL::ClearTempFlags() { for( LIB_ITEM& item : m_drawings ) item.ClearTempFlags(); } -void LIB_PART::ClearEditFlags() +void LIB_SYMBOL::ClearEditFlags() { for( LIB_ITEM& item : m_drawings ) item.ClearEditFlags(); } -LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, - KICAD_T aType, const wxPoint& aPoint ) +LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aConvert, + KICAD_T aType, const wxPoint& aPoint ) { for( LIB_ITEM& item : m_drawings ) { @@ -1076,8 +1076,8 @@ LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, } -LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, - const wxPoint& aPoint, const TRANSFORM& aTransform ) +LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, + const wxPoint& aPoint, const TRANSFORM& aTransform ) { /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const * wxPoint& pt ) to search items. @@ -1097,7 +1097,8 @@ LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, } -SEARCH_RESULT LIB_PART::Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aFilterTypes[] ) +SEARCH_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData, + const KICAD_T aFilterTypes[] ) { // The part itself is never inspected, only its children for( LIB_ITEM& item : m_drawings ) @@ -1113,7 +1114,7 @@ SEARCH_RESULT LIB_PART::Visit( INSPECTOR aInspector, void* aTestData, const KICA } -void LIB_PART::SetUnitCount( int aCount, bool aDuplicateDrawItems ) +void LIB_SYMBOL::SetUnitCount( int aCount, bool aDuplicateDrawItems ) { if( m_unitCount == aCount ) return; @@ -1161,7 +1162,7 @@ void LIB_PART::SetUnitCount( int aCount, bool aDuplicateDrawItems ) } -int LIB_PART::GetUnitCount() const +int LIB_SYMBOL::GetUnitCount() const { if( PART_SPTR parent = m_parent.lock() ) return parent->GetUnitCount(); @@ -1170,7 +1171,7 @@ int LIB_PART::GetUnitCount() const } -void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins ) +void LIB_SYMBOL::SetConversion( bool aSetConvert, bool aDuplicatePins ) { if( aSetConvert == HasConversion() ) return; @@ -1196,7 +1197,7 @@ void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins ) } } - // Transfer the new pins to the LIB_PART. + // Transfer the new pins to the LIB_SYMBOL. for( unsigned i = 0; i < tmp.size(); i++ ) m_drawings.push_back( tmp[i] ); } @@ -1220,7 +1221,7 @@ void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins ) } -void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId ) +void LIB_SYMBOL::SetSubpartIdNotation( int aSep, int aFirstId ) { m_subpartFirstId = 'A'; m_subpartIdSeparator = 0; @@ -1233,7 +1234,7 @@ void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId ) } -std::vector LIB_PART::GetUnitItems( int aUnit, int aConvert ) +std::vector LIB_SYMBOL::GetUnitItems( int aUnit, int aConvert ) { std::vector unitItems; @@ -1252,7 +1253,7 @@ std::vector LIB_PART::GetUnitItems( int aUnit, int aConvert ) } -std::vector LIB_PART::GetUnitDrawItems() +std::vector LIB_SYMBOL::GetUnitDrawItems() { std::vector units; @@ -1287,7 +1288,7 @@ std::vector LIB_PART::GetUnitDrawItems() } -std::vector LIB_PART::GetUniqueUnits() +std::vector LIB_SYMBOL::GetUniqueUnits() { int unitNum; size_t i; diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index cda92f9c04..871006c972 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -37,13 +37,13 @@ class EDA_RECT; class LINE_READER; class OUTPUTFORMATTER; class PART_LIB; -class LIB_PART; +class LIB_SYMBOL; class LIB_FIELD; -class TEST_LIB_PART_FIXTURE; +class TEST_LIB_SYMBOL_FIXTURE; -typedef std::shared_ptr PART_SPTR; ///< shared pointer to LIB_PART -typedef std::weak_ptr PART_REF; ///< weak pointer to LIB_PART +typedef std::shared_ptr PART_SPTR; ///< shared pointer to LIB_SYMBOL +typedef std::weak_ptr PART_REF; ///< weak pointer to LIB_SYMBOL typedef MULTIVECTOR LIB_ITEMS_CONTAINER; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; @@ -51,12 +51,12 @@ typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; /* values for member .m_options */ enum LIBRENTRYOPTIONS { - ENTRY_NORMAL, // Libentry is a standard part (real or alias) + ENTRY_NORMAL, // Libentry is a standard symbol (real or alias) ENTRY_POWER // Libentry is a power symbol }; -extern bool operator<( const LIB_PART& aItem1, const LIB_PART& aItem2 ); +extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 ); struct PART_DRAW_OPTIONS @@ -90,27 +90,28 @@ struct PART_UNITS /** * Define a library symbol object. * - * A library symbol object is typically saved and loaded in a part library file (.lib). + * A library symbol object is typically saved and loaded in a symbol library file (.lib). * Library symbols are different from schematic symbols. */ -class LIB_PART : public EDA_ITEM, public LIB_TREE_ITEM +class LIB_SYMBOL : public EDA_ITEM, public LIB_TREE_ITEM { public: - LIB_PART( const wxString& aName, LIB_PART* aParent = nullptr, PART_LIB* aLibrary = nullptr ); + LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, + PART_LIB* aLibrary = nullptr ); - LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary = NULL ); + LIB_SYMBOL( const LIB_SYMBOL& aSymbol, PART_LIB* aLibrary = NULL ); - virtual ~LIB_PART(); + virtual ~LIB_SYMBOL(); ///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared PART_SPTR SharedPtr() const { return m_me; } /** - * Create a copy of a LIB_PART and assigns unique KIIDs to the copy and its children. + * Create a copy of a LIB_SYMBOL and assigns unique KIIDs to the copy and its children. */ - virtual LIB_PART* Duplicate() const + virtual LIB_SYMBOL* Duplicate() const { - LIB_PART* dupe = new LIB_PART( *this, m_library ); + LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library ); const_cast( dupe->m_Uuid ) = KIID(); for( LIB_ITEM& item : dupe->m_drawings ) @@ -119,13 +120,13 @@ public: return dupe; } - void SetParent( LIB_PART* aParent = nullptr ); + void SetParent( LIB_SYMBOL* aParent = nullptr ); PART_REF& GetParent() { return m_parent; } const PART_REF& GetParent() const { return m_parent; } virtual wxString GetClass() const override { - return wxT( "LIB_PART" ); + return wxT( "LIB_SYMBOL" ); } virtual void SetName( const wxString& aName ); @@ -195,7 +196,7 @@ public: /** * Get the bounding box for the symbol. * - * @return the part bounding box ( in user coordinates ) + * @return the symbol bounding box ( in user coordinates ) * @param aUnit = unit selection = 0, or 1..n * @param aConvert = 0, 1 or 2 * If aUnit == 0, unit is not used @@ -207,7 +208,7 @@ public: /** * Get the symbol bounding box excluding fields. * - * @return the part bounding box ( in user coordinates ) without fields + * @return the symbol bounding box ( in user coordinates ) without fields * @param aUnit = unit selection = 0, or 1..n * @param aConvert = 0, 1 or 2 * If aUnit == 0, unit is not used @@ -228,13 +229,13 @@ public: void SetNormal(); /** - * Set interchangeable the property for part units. + * Set interchangeable the property for symbol units. * @param aLockUnits when true then units are set as not interchangeable. */ void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; } /** - * Check whether part units are interchangeable. + * Check whether symbol units are interchangeable. * @return False when interchangeable, true otherwise. */ bool UnitsLocked() const { return m_unitsLocked; } @@ -243,7 +244,7 @@ public: * Overwrite all the existing fields in this symbol with fields supplied * in \a aFieldsList. * - * The only known caller of this function is the library part field editor, and it + * The only known caller of this function is the library symbol field editor, and it * establishes needed behavior. * * @param aFieldsList is a set of fields to import, removing all previous fields. @@ -251,7 +252,7 @@ public: void SetFields( const std::vector & aFieldsList ); /** - * Return a list of fields within this part. + * Return a list of fields within this symbol. * * @param aList - List to add fields to */ @@ -264,7 +265,7 @@ public: void AddField( LIB_FIELD* aField ); /** - * Find a field within this part matching \a aFieldName and returns it + * Find a field within this symbol matching \a aFieldName and returns it * or NULL if not found. */ LIB_FIELD* FindField( const wxString& aFieldName ); @@ -292,10 +293,10 @@ public: LIB_FIELD& GetDatasheetField(); /** - * Print part. + * Print symbol. * - * @param aOffset - Position of part. - * @param aMulti - unit if multiple units per part. + * @param aOffset - Position of symbol. + * @param aMulti - unit if multiple units per symbol. * @param aConvert - Component conversion (DeMorgan) if available. * @param aOpts - Drawing options */ @@ -303,12 +304,12 @@ public: int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ); /** - * Plot lib part to plotter. + * Plot lib symbol to plotter. * Lib Fields not are plotted here, because this plot function * is used to plot schematic items, which have they own fields * * @param aPlotter - Plotter object to plot to. - * @param aUnit - Component part to plot. + * @param aUnit - Component symbol to plot. * @param aConvert - Component alternate body style to plot. * @param aOffset - Distance to shift the plot coordinates. * @param aTransform - Component plot transform matrix. @@ -317,11 +318,11 @@ public: const TRANSFORM& aTransform ) const; /** - * Plot Lib Fields only of the part to plotter. - * is used to plot the full lib part, outside the schematic + * Plot Lib Fields only of the symbol to plotter. + * is used to plot the full lib symbol, outside the schematic * * @param aPlotter - Plotter object to plot to. - * @param aUnit - Component part to plot. + * @param aUnit - Component symbol to plot. * @param aConvert - Component alternate body style to plot. * @param aOffset - Distance to shift the plot coordinates. * @param aTransform - Component plot transform matrix. @@ -376,15 +377,15 @@ public: /** * Return a list of pin object pointers from the draw item list. * - * Note pin objects are owned by the draw list of the part. + * Note pin objects are owned by the draw list of the symbol. * Deleting any of the objects will leave list in a unstable state * and will likely segfault when the list is destroyed. * * @param aList - Pin list to place pin object pointers into. * @param aUnit - Unit number of pin to add to list. Set to 0 to - * get pins from any part unit. + * get pins from any symbol unit. * @param aConvert - Convert number of pin to add to list. Set to 0 to - * get pins from any convert of part. + * get pins from any convert of symbol. */ void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 ) const; @@ -392,7 +393,7 @@ public: * Return pin object with the requested pin \a aNumber. * * @param aNumber - Number of the pin to find. - * @param aUnit - Unit of the part to find. Set to 0 if a specific + * @param aUnit - Unit of the symbol to find. Set to 0 if a specific * unit number is not required. * @param aConvert - Alternate body style filter (DeMorgan). Set to 0 if * no alternate body style is required. @@ -401,22 +402,22 @@ public: LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ) const; /** - * Return true if this part's pins do not match another part's pins. This + * Return true if this symbol's pins do not match another symbol's pins. This * is used to detect whether the project cache is out of sync with the * system libs. * - * @param aOtherPart - The other library part to test + * @param aOtherSymbol - The other library symbol to test * @param aTestNums - Whether two pins at the same point must have the same number. * @param aTestNames - Whether two pins at the same point must have the same name. * @param aTestType - Whether two pins at the same point must have the same electrical type. * @param aTestOrientation - Whether two pins at the same point must have the same orientation. * @param aTestLength - Whether two pins at the same point must have the same length. */ - bool PinsConflictWith( const LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, + bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength ) const; /** - * Move the part \a aOffset. + * Move the symbol \a aOffset. * * @param aOffset - Offset displacement. */ @@ -428,14 +429,14 @@ public: void RemoveDuplicateDrawItems(); /** - * Test if part has more than one body conversion type (DeMorgan). + * Test if symbol has more than one body conversion type (DeMorgan). * - * @return True if part has more than one conversion. + * @return True if symbol has more than one conversion. */ bool HasConversion() const; /** - * Clears the status flag all draw objects in this part. + * Clears the status flag all draw objects in this symbol. */ void ClearTempFlags(); void ClearEditFlags(); @@ -475,12 +476,12 @@ public: SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; /** - * Set the units per part count. + * Set the units per symbol count. * * If the count is greater than the current count, then the all of the - * current draw items are duplicated for each additional part. If the + * current draw items are duplicated for each additional symbol. If the * count is less than the current count, all draw objects for units - * greater that count are removed from the part. + * greater that count are removed from the symbol. * * @param aCount - Number of units per package. * @param aDuplicateDrawItems Create duplicate draw items of unit 1 for each additionl unit. @@ -494,15 +495,15 @@ public: wxString GetUnitReference( int aUnit ) override; /** - * @return true if the part has multiple units per part. - * When true, the reference has a sub reference to identify part. + * @return true if the symbol has multiple units per symbol. + * When true, the reference has a sub reference to identify symbol. */ bool IsMulti() const { return m_unitCount > 1; } /** - * @return the sub reference for part having multiple units per part. - * The sub reference identify the part (or unit) - * @param aUnit = the part identifier ( 1 to max count) + * @return the sub reference for symbol having multiple units per symbol. + * The sub reference identify the symbol (or unit) + * @param aUnit = the symbol identifier ( 1 to max count) * @param aAddSeparator = true (default) to prepend the sub ref * by the separator symbol (if any) * Note: this is a static function. @@ -526,25 +527,25 @@ public: /** * Set the separator char between the subpart id and the reference * 0 (no separator) or '.' , '-' and '_' - * and the ascii char value to calculate the subpart symbol id from the part number: + * and the ascii char value to calculate the subpart symbol id from the symbol number: * 'A' or '1' only are allowed. (to print U1.A or U1.1) * if this is a digit, a number is used as id symbol * Note also if the subpart symbol is a digit, the separator cannot be null. * @param aSep = the separator symbol (0 (no separator) or '.' , '-' and '_') - * @param aFirstId = the Id of the first part ('A' or '1') + * @param aFirstId = the Id of the first symbol ('A' or '1') */ static void SetSubpartIdNotation( int aSep, int aFirstId ); /** - * Set or clear the alternate body style (DeMorgan) for the part. + * Set or clear the alternate body style (DeMorgan) for the symbol. * - * If the part already has an alternate body style set and a + * If the symbol already has an alternate body style set and a * asConvert if false, all of the existing draw items for the alternate * body style are remove. If the alternate body style is not set and * asConvert is true, than the base draw items are duplicated and - * added to the part. + * added to the symbol. * - * @param aSetConvert - Set or clear the part alternate body style. + * @param aSetConvert - Set or clear the symbol alternate body style. * @param aDuplicatePins - Duplicate all pins from original body style if true. */ void SetConversion( bool aSetConvert, bool aDuplicatePins = true ); @@ -562,7 +563,7 @@ public: /** * Set or clear the pin name visibility flag. * - * @param aShow - True to make the part pin names visible. + * @param aShow - True to make the symbol pin names visible. */ void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; } bool ShowPinNames() const { return m_showPinNames; } @@ -570,7 +571,7 @@ public: /** * Set or clear the pin number visibility flag. * - * @param aShow - True to make the part pin numbers visible. + * @param aShow - True to make the symbol pin numbers visible. */ void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; } bool ShowPinNumbers() const { return m_showPinNumbers; } @@ -600,13 +601,13 @@ public: * 1 if this symbol is greater than \a aRhs * 0 if this symbol is the same as \a aRhs */ - int Compare( const LIB_PART& aRhs ) const; + int Compare( const LIB_SYMBOL& aRhs ) const; - bool operator==( const LIB_PART* aPart ) const { return this == aPart; } - bool operator==( const LIB_PART& aPart ) const { return Compare( aPart ) == 0; } - bool operator!=( const LIB_PART& aPart ) const { return Compare( aPart ) != 0; } + bool operator==( const LIB_SYMBOL* aSymbol ) const { return this == aSymbol; } + bool operator==( const LIB_SYMBOL& aSymbol ) const { return Compare( aSymbol ) == 0; } + bool operator!=( const LIB_SYMBOL& aSymbol ) const { return Compare( aSymbol ) != 0; } - const LIB_PART& operator=( const LIB_PART& aPart ); + const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol ); /** * Return a flattened symbol inheritance to the caller. @@ -615,7 +616,7 @@ public: * * @return a flattened symbol on the heap */ - std::unique_ptr< LIB_PART > Flatten() const; + std::unique_ptr< LIB_SYMBOL > Flatten() const; /** * Return a list of LIB_ITEM objects separated by unit and convert number. @@ -664,7 +665,7 @@ private: timestamp_t m_lastModDate; int m_unitCount; ///< Number of units (parts) per package. - bool m_unitsLocked; ///< True if part has multiple units and changing one + bool m_unitsLocked; ///< True if symbol has multiple units and changing one ///< unit does not automatically change another unit. int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to @@ -674,7 +675,7 @@ private: bool m_includeInBom; bool m_includeOnBoard; - LIBRENTRYOPTIONS m_options; ///< Special part features such as POWER or NORMAL.) + LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL.) LIB_ITEMS_CONTAINER m_drawings; @@ -683,13 +684,13 @@ private: wxString m_description; wxString m_keyWords; ///< Search keywords wxArrayString m_fpFilters; ///< List of suitable footprint names for the - ///< part (wild card names accepted). + ///< symbol (wild card names accepted). static int m_subpartIdSeparator; ///< the separator char between ///< the subpart id and the reference like U1A ///< ( m_subpartIdSeparator = 0 ) or U1.A or U1-A static int m_subpartFirstId; ///< the ASCII char value to calculate the subpart - ///< symbol id from the part number: only 'A', 'a' + ///< symbol id from the symbol number: only 'A', 'a' ///< or '1' can be used, other values have no sense. }; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index cd0b2fe447..084737ad04 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -42,7 +42,7 @@ #include // For some default values -LIB_TEXT::LIB_TEXT( LIB_PART* aParent ) : +LIB_TEXT::LIB_TEXT( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_TEXT_T, aParent ), EDA_TEXT( wxEmptyString ) { diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 1cf218279d..c879d37a69 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -39,7 +39,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT { public: - LIB_TEXT( LIB_PART* aParent ); + LIB_TEXT( LIB_SYMBOL* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index e238323b37..bdc612cc04 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -85,7 +85,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) for( auto aItem : screen->Items().OfType( SCH_SYMBOL_T ) ) { - LIB_PART* part = nullptr; + LIB_SYMBOL* libSymbol = nullptr; SCH_SYMBOL* symbol = static_cast( aItem ); try @@ -93,7 +93,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) if( archLib->FindPart( symbol->GetLibId() ) ) continue; - part = GetLibPart( symbol->GetLibId(), true ); + libSymbol = GetLibPart( symbol->GetLibId(), true ); } catch( const IO_ERROR& ) { @@ -109,15 +109,15 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) tmp = _( "Unexpected exception occurred." ); } - if( part ) + if( libSymbol ) { - std::unique_ptr flattenedPart = part->Flatten(); + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); // Use the full LIB_ID as the symbol name to prevent symbol name collisions. - flattenedPart->SetName( symbol->GetLibId().GetUniStringLibId() ); + flattenedSymbol->SetName( symbol->GetLibId().GetUniStringLibId() ); - // AddPart() does first clone the part before adding. - archLib->AddPart( flattenedPart.get() ); + // AddPart() does first clone the symbol before adding. + archLib->AddPart( flattenedSymbol.get() ); } else { diff --git a/eeschema/netlist_exporters/netlist_exporter_base.cpp b/eeschema/netlist_exporters/netlist_exporter_base.cpp index 8631084b8a..89592ed632 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_base.cpp @@ -217,11 +217,11 @@ void NETLIST_EXPORTER_BASE::eraseDuplicatePins() } -void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSymbol, - LIB_PART* aPart, SCH_SHEET_PATH* aSheetPath, +void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, + SCH_SHEET_PATH* aSheetPath, bool aKeepUnconnectedPins ) { - wxString ref = aSymbol->GetRef( aSheetPath ); + wxString ref = aSchSymbol->GetRef( aSheetPath ); wxString ref2; SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h index e79799d70e..be06cf5241 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.h +++ b/eeschema/netlist_exporters/netlist_exporter_base.h @@ -60,15 +60,15 @@ public: }; /** - * Used by std:set instantiation which uses #LIB_PART name as its key. + * Used by std:set instantiation which uses #LIB_SYMBOL name as its key. */ -struct LIB_PART_LESS_THAN +struct LIB_SYMBOL_LESS_THAN { - // a "less than" test on two LIB_PARTs (.m_name wxStrings) - bool operator()( LIB_PART* const& libpart1, LIB_PART* const& libpart2 ) const + // a "less than" test on two LIB_SYMBOLs (.m_name wxStrings) + bool operator()( LIB_SYMBOL* const& libsymbol1, LIB_SYMBOL* const& libsymbol2 ) const { // Use case specific GetName() wxString compare - return libpart1->GetLibId() < libpart2->GetLibId(); + return libsymbol1->GetLibId() < libsymbol2->GetLibId(); } }; @@ -96,12 +96,12 @@ protected: /// TODO(snh): Descope this object std::vector m_sortedSymbolPinList; - /// Used for "multiple parts per package" symbols to avoid processing a lib part more than + /// Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than /// once UNIQUE_STRINGS m_referencesAlreadyFound; - /// unique library parts used. LIB_PART items are sorted by names - std::set m_libParts; + /// unique library symbols used. LIB_SYMBOL items are sorted by names + std::set m_libParts; /// The schematic we're generating a netlist for SCHEMATIC_IFACE* m_schematic; @@ -137,7 +137,7 @@ protected: * * (This is a list of pins found in the whole schematic, for a single symbol.) These * duplicate pins were put in list because some pins (power pins...) are found more than - * once when in "multiple parts per package" symbols. For instance, a 74ls00 has 4 parts, + * once when in "multiple symbols per package" symbols. For instance, a 74ls00 has 4 symbols, * and therefore the VCC pin and GND pin appears 4 times in the list. * Note: this list *MUST* be sorted by pin number (.m_PinNum member value) * Also set the m_Flag member of "removed" NETLIST_OBJECT pin item to 1 @@ -145,7 +145,7 @@ protected: void eraseDuplicatePins(); /** - * Find all units for symbols with multiple parts per package. + * Find all units for symbols with multiple symbols per package. * * Search the entire design for all units of \a aSymbol based on matching reference * designator, and for each unit, add all its pins to the temporary sorted pin list, @@ -153,7 +153,7 @@ protected: * if aKeepUnconnectedPins = false, unconnected pins will be removed from list * but usually we need all pins in netlists. */ - void findAllUnitsOfSymbol( SCH_SYMBOL* aSymbol, LIB_PART* aPart, + void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, SCH_SHEET_PATH* aSheetPath, bool aKeepUnconnectedPins ); public: diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index f274a05bce..8e527eac9d 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -74,7 +74,7 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector& aSymbol if( aSymbols.empty() ) return; - // sort aSymbols by lib part. symbols will be grouped by same lib part. + // sort aSymbols by lib symbol. symbols will be grouped by same lib symbol. std::sort( aSymbols.begin(), aSymbols.end(), sort_by_libid ); } @@ -84,11 +84,11 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector& aSymbol * * @param aName - name to search for * @param aLibs - the loaded PART_LIBS - * @param aCached - whether we are looking for the cached part + * @param aCached - whether we are looking for the cached symbol */ -static LIB_PART* findSymbol( const wxString& aName, PART_LIBS* aLibs, bool aCached ) +static LIB_SYMBOL* findSymbol( const wxString& aName, PART_LIBS* aLibs, bool aCached ) { - LIB_PART *part = NULL; + LIB_SYMBOL *symbol = NULL; wxString new_name = LIB_ID::FixIllegalChars( aName ); for( PART_LIB& each_lib : *aLibs ) @@ -99,13 +99,13 @@ static LIB_PART* findSymbol( const wxString& aName, PART_LIBS* aLibs, bool aCach if( !aCached && each_lib.IsCache() ) continue; - part = each_lib.FindPart( new_name ); + symbol = each_lib.FindPart( new_name ); - if( part ) + if( symbol ) break; } - return part; + return symbol; } @@ -120,7 +120,7 @@ static wxFileName GetRescueLibraryFileName( SCHEMATIC* aSchematic ) RESCUE_CASE_CANDIDATE::RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, - LIB_PART* aLibCandidate, + LIB_SYMBOL* aLibCandidate, int aUnit, int aConvert ) { @@ -138,25 +138,25 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, typedef std::map candidate_map_t; candidate_map_t candidate_map; - // Remember the list of symbols is sorted by part name. + // Remember the list of symbols is sorted by symbol name. // So a search in libraries is made only once by group - LIB_PART* case_sensitive_match = nullptr; - std::vector case_insensitive_matches; + LIB_SYMBOL* case_sensitive_match = nullptr; + std::vector case_insensitive_matches; - wxString part_name; + wxString symbol_name; wxString search_name; - wxString last_part_name; + wxString last_symbol_name; for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) ) { - part_name = eachSymbol->GetLibId().GetLibItemName(); - search_name = LIB_ID::FixIllegalChars( part_name ); + symbol_name = eachSymbol->GetLibId().GetLibItemName(); + search_name = LIB_ID::FixIllegalChars( symbol_name ); - if( last_part_name != part_name ) + if( last_symbol_name != symbol_name ) { - // A new part name is found (a new group starts here). + // A new symbol name is found (a new group starts here). // Search the symbol names candidates only once for this group: - last_part_name = part_name; + last_symbol_name = symbol_name; case_insensitive_matches.clear(); LIB_ID id( wxEmptyString, search_name ); @@ -172,12 +172,12 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, if( case_sensitive_match || !( case_insensitive_matches.size() ) ) continue; - RESCUE_CASE_CANDIDATE candidate( part_name, case_insensitive_matches[0]->GetName(), + RESCUE_CASE_CANDIDATE candidate( symbol_name, case_insensitive_matches[0]->GetName(), case_insensitive_matches[0], eachSymbol->GetUnit(), eachSymbol->GetConvert() ); - candidate_map[part_name] = candidate; + candidate_map[symbol_name] = candidate; } // Now, dump the map into aCandidates @@ -217,8 +217,8 @@ bool RESCUE_CASE_CANDIDATE::PerformAction( RESCUER* aRescuer ) RESCUE_CACHE_CANDIDATE::RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, - LIB_PART* aCacheCandidate, - LIB_PART* aLibCandidate, + LIB_SYMBOL* aCacheCandidate, + LIB_SYMBOL* aLibCandidate, int aUnit, int aConvert ) { @@ -244,24 +244,24 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, typedef std::map candidate_map_t; candidate_map_t candidate_map; - // Remember the list of symbols is sorted by part name. + // Remember the list of symbols is sorted by symbol name. // So a search in libraries is made only once by group - LIB_PART* cache_match = nullptr; - LIB_PART* lib_match = nullptr; - wxString part_name; + LIB_SYMBOL* cache_match = nullptr; + LIB_SYMBOL* lib_match = nullptr; + wxString symbol_name; wxString search_name; - wxString old_part_name; + wxString old_symbol_name; for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) ) { - part_name = eachSymbol->GetLibId().GetLibItemName(); - search_name = LIB_ID::FixIllegalChars( part_name ); + symbol_name = eachSymbol->GetLibId().GetLibItemName(); + search_name = LIB_ID::FixIllegalChars( symbol_name ); - if( old_part_name != part_name ) + if( old_symbol_name != symbol_name ) { - // A new part name is found (a new group starts here). + // A new symbol name is found (a new group starts here). // Search the symbol names candidates only once for this group: - old_part_name = part_name; + old_symbol_name = symbol_name; cache_match = findSymbol( search_name, aRescuer.GetPrj()->SchLibs(), true ); lib_match = findSymbol( search_name, aRescuer.GetPrj()->SchLibs(), false ); @@ -278,11 +278,11 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, continue; // Check if the symbol has already been rescued. - RESCUE_CACHE_CANDIDATE candidate( part_name, search_name, cache_match, lib_match, + RESCUE_CACHE_CANDIDATE candidate( symbol_name, search_name, cache_match, lib_match, eachSymbol->GetUnit(), eachSymbol->GetConvert() ); - candidate_map[part_name] = candidate; + candidate_map[symbol_name] = candidate; } } @@ -314,13 +314,13 @@ wxString RESCUE_CACHE_CANDIDATE::GetActionDescription() const bool RESCUE_CACHE_CANDIDATE::PerformAction( RESCUER* aRescuer ) { - LIB_PART* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate; + LIB_SYMBOL* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate; wxCHECK_MSG( tmp, false, "Both cache and library symbols undefined." ); - std::unique_ptr new_part = tmp->Flatten(); - new_part->SetName( m_new_name ); - aRescuer->AddPart( new_part.get() ); + std::unique_ptr new_symbol = tmp->Flatten(); + new_symbol->SetName( m_new_name ); + aRescuer->AddPart( new_symbol.get() ); for( SCH_SYMBOL* eachSymbol : *aRescuer->GetSymbols() ) { @@ -342,8 +342,8 @@ bool RESCUE_CACHE_CANDIDATE::PerformAction( RESCUER* aRescuer ) RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ID& aRequestedId, const LIB_ID& aNewId, - LIB_PART* aCacheCandidate, - LIB_PART* aLibCandidate, + LIB_SYMBOL* aCacheCandidate, + LIB_SYMBOL* aLibCandidate, int aUnit, int aConvert ) : RESCUE_CANDIDATE() { @@ -374,27 +374,27 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( // Remember the list of symbols is sorted by LIB_ID. // So a search in libraries is made only once by group - LIB_PART* cache_match = nullptr; - LIB_PART* lib_match = nullptr; - LIB_ID old_part_id; + LIB_SYMBOL* cache_match = nullptr; + LIB_SYMBOL* lib_match = nullptr; + LIB_ID old_symbol_id; for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) ) { - const LIB_ID& part_id = eachSymbol->GetLibId(); + const LIB_ID& symbol_id = eachSymbol->GetLibId(); - if( old_part_id != part_id ) + if( old_symbol_id != symbol_id ) { - // A new part name is found (a new group starts here). + // A new symbol name is found (a new group starts here). // Search the symbol names candidates only once for this group: - old_part_id = part_id; + old_symbol_id = symbol_id; // Get the library symbol from the cache library. It will be a flattened // symbol by default (no inheritance). - cache_match = findSymbol( part_id.Format().wx_str(), aRescuer.GetPrj()->SchLibs(), + cache_match = findSymbol( symbol_id.Format().wx_str(), aRescuer.GetPrj()->SchLibs(), true ); // Get the library symbol from the symbol library table. - lib_match = SchGetLibPart( part_id, aRescuer.GetPrj()->SchSymbolLibTable() ); + lib_match = SchGetLibPart( symbol_id, aRescuer.GetPrj()->SchSymbolLibTable() ); if( !cache_match && !lib_match ) continue; @@ -417,7 +417,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( } // Test whether there is a conflict or if the symbol can only be found in the cache. - if( LIB_ID::HasIllegalChars( part_id.GetLibItemName() ) == -1 ) + if( LIB_ID::HasIllegalChars( symbol_id.GetLibItemName() ) == -1 ) { if( cache_match && lib_match && !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) ) @@ -428,7 +428,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( } // Fix illegal LIB_ID name characters. - wxString new_name = LIB_ID::FixIllegalChars( part_id.GetLibItemName() ); + wxString new_name = LIB_ID::FixIllegalChars( symbol_id.GetLibItemName() ); // Differentiate symbol name in the rescue library by appending the symbol library // table nickname to the symbol name to prevent name clashes in the rescue library. @@ -437,13 +437,13 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( // Spaces in the file name will break the symbol name because they are not // quoted in the symbol library file format. libNickname.Replace( " ", "-" ); - LIB_ID new_id( libNickname, new_name + "-" + part_id.GetLibNickname().wx_str() ); + LIB_ID new_id( libNickname, new_name + "-" + symbol_id.GetLibNickname().wx_str() ); - RESCUE_SYMBOL_LIB_TABLE_CANDIDATE candidate( part_id, new_id, cache_match, lib_match, + RESCUE_SYMBOL_LIB_TABLE_CANDIDATE candidate( symbol_id, new_id, cache_match, lib_match, eachSymbol->GetUnit(), eachSymbol->GetConvert() ); - candidate_map[part_id] = candidate; + candidate_map[symbol_id] = candidate; } } @@ -475,14 +475,14 @@ wxString RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription() const bool RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::PerformAction( RESCUER* aRescuer ) { - LIB_PART* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate; + LIB_SYMBOL* tmp = ( m_cache_candidate ) ? m_cache_candidate : m_lib_candidate; wxCHECK_MSG( tmp, false, "Both cache and library symbols undefined." ); - std::unique_ptr new_part = tmp->Flatten(); - new_part->SetLibId( m_new_id ); - new_part->SetName( m_new_id.GetLibItemName() ); - aRescuer->AddPart( new_part.get() ); + std::unique_ptr new_symbol = tmp->Flatten(); + new_symbol->SetLibId( m_new_id ); + new_symbol->SetName( m_new_id.GetLibItemName() ); + aRescuer->AddPart( new_symbol.get() ); for( SCH_SYMBOL* eachSymbol : *aRescuer->GetSymbols() ) { @@ -658,14 +658,14 @@ void LEGACY_RESCUER::OpenRescueLibrary() if( rescueLib ) { // For items in the rescue library, aliases are the root symbol. - std::vector< LIB_PART* > symbols; + std::vector< LIB_SYMBOL* > symbols; rescueLib->GetParts( symbols ); for( auto symbol : symbols ) { - // The LIB_PART copy constructor flattens derived symbols (formerly known as aliases). - m_rescue_lib->AddPart( new LIB_PART( *symbol, m_rescue_lib.get() ) ); + // The LIB_SYMBOL copy constructor flattens derived symbols (formerly known as aliases). + m_rescue_lib->AddPart( new LIB_SYMBOL( *symbol, m_rescue_lib.get() ) ); } } } @@ -752,12 +752,12 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) } -void LEGACY_RESCUER::AddPart( LIB_PART* aNewPart ) +void LEGACY_RESCUER::AddPart( LIB_SYMBOL* aNewSymbol ) { - wxCHECK_RET( aNewPart, "Invalid LIB_PART pointer." ); + wxCHECK_RET( aNewSymbol, "Invalid LIB_SYMBOL pointer." ); - aNewPart->SetLib( m_rescue_lib.get() ); - m_rescue_lib->AddPart( aNewPart ); + aNewSymbol->SetLib( m_rescue_lib.get() ); + m_rescue_lib->AddPart( aNewSymbol ); } @@ -849,18 +849,18 @@ bool SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary( wxWindow *aParent ) } -void SYMBOL_LIB_TABLE_RESCUER::AddPart( LIB_PART* aNewPart ) +void SYMBOL_LIB_TABLE_RESCUER::AddPart( LIB_SYMBOL* aNewSymbol ) { - wxCHECK_RET( aNewPart, "Invalid LIB_PART pointer." ); + wxCHECK_RET( aNewSymbol, "Invalid LIB_SYMBOL pointer." ); wxFileName fn = GetRescueLibraryFileName( m_schematic ); try { if( !m_prj->SchSymbolLibTable()->HasLibrary( fn.GetName() ) ) - m_pi->SaveSymbol( fn.GetFullPath(), new LIB_PART( *aNewPart ), m_properties.get() ); + m_pi->SaveSymbol( fn.GetFullPath(), new LIB_SYMBOL( *aNewSymbol ), m_properties.get() ); else - m_prj->SchSymbolLibTable()->SaveSymbol( fn.GetName(), new LIB_PART( *aNewPart ) ); + m_prj->SchSymbolLibTable()->SaveSymbol( fn.GetName(), new LIB_SYMBOL( *aNewSymbol ) ); } catch( ... /* IO_ERROR */ ) { diff --git a/eeschema/project_rescue.h b/eeschema/project_rescue.h index 72cdafd123..ad016d100d 100644 --- a/eeschema/project_rescue.h +++ b/eeschema/project_rescue.h @@ -47,7 +47,7 @@ #include -class LIB_PART; +class LIB_SYMBOL; class SCH_SYMBOL; class RESCUER; class SCH_EDIT_FRAME; @@ -82,13 +82,13 @@ public: * Get the part that can be loaded from the project cache, if possible, or * else NULL. */ - virtual LIB_PART* GetCacheCandidate() const { return NULL; } + virtual LIB_SYMBOL* GetCacheCandidate() const { return NULL; } /** * Get the part the would be loaded from the libraries, if possible, or else * NULL. */ - virtual LIB_PART* GetLibCandidate() const { return m_lib_candidate; } + virtual LIB_SYMBOL* GetLibCandidate() const { return m_lib_candidate; } int GetUnit() const { return m_unit; } @@ -107,11 +107,11 @@ public: virtual bool PerformAction( RESCUER* aRescuer ) = 0; protected: - wxString m_requested_name; - wxString m_new_name; - LIB_PART* m_lib_candidate; - int m_unit; - int m_convert; + wxString m_requested_name; + wxString m_new_name; + LIB_SYMBOL* m_lib_candidate; + int m_unit; + int m_convert; }; @@ -136,7 +136,7 @@ public: * @param aConvert is the body style of the rescued symbol. */ RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, - LIB_PART* aLibCandidate, int aUnit = 0, int aConvert = 0 ); + LIB_SYMBOL* aLibCandidate, int aUnit = 0, int aConvert = 0 ); RESCUE_CASE_CANDIDATE() { m_lib_candidate = NULL; } @@ -148,7 +148,7 @@ public: class RESCUE_CACHE_CANDIDATE: public RESCUE_CANDIDATE { - LIB_PART* m_cache_candidate; + LIB_SYMBOL* m_cache_candidate; public: /** @@ -170,12 +170,12 @@ public: * @param aConvert is the body style of the rescued symbol. */ RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, - LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate, + LIB_SYMBOL* aCacheCandidate, LIB_SYMBOL* aLibCandidate, int aUnit = 0, int aConvert = 0 ); RESCUE_CACHE_CANDIDATE(); - virtual LIB_PART* GetCacheCandidate() const override { return m_cache_candidate; } + virtual LIB_SYMBOL* GetCacheCandidate() const override { return m_cache_candidate; } virtual wxString GetActionDescription() const override; @@ -205,12 +205,12 @@ public: * @param aConvert is the body style of the rescued symbol. */ RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ID& aRequestedId, const LIB_ID& aNewId, - LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate, + LIB_SYMBOL* aCacheCandidate, LIB_SYMBOL* aLibCandidate, int aUnit = 0, int aConvert = 0 ); RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(); - virtual LIB_PART* GetCacheCandidate() const override { return m_cache_candidate; } + virtual LIB_SYMBOL* GetCacheCandidate() const override { return m_cache_candidate; } virtual wxString GetActionDescription() const override; @@ -219,7 +219,7 @@ public: private: LIB_ID m_requested_id; LIB_ID m_new_id; - LIB_PART* m_cache_candidate; + LIB_SYMBOL* m_cache_candidate; }; @@ -258,7 +258,7 @@ public: */ virtual void FindCandidates() = 0; - virtual void AddPart( LIB_PART* aNewPart ) = 0; + virtual void AddPart( LIB_SYMBOL* aNewSymbol ) = 0; /** * Display a dialog to allow the user to select rescues. @@ -350,7 +350,7 @@ public: virtual bool WriteRescueLibrary( wxWindow *aParent ) override; - virtual void AddPart( LIB_PART* aNewPart ) override; + virtual void AddPart( LIB_SYMBOL* aNewSymbol ) override; private: std::unique_ptr m_rescue_lib; @@ -376,7 +376,7 @@ public: virtual bool WriteRescueLibrary( wxWindow* aParent ) override; - virtual void AddPart( LIB_PART* aNewPart ) override; + virtual void AddPart( LIB_SYMBOL* aNewSymbol ) override; private: SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index de6eaaf82c..3e456ab53c 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -43,12 +43,12 @@ #include -LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib, - wxWindow* aParent, bool aShowErrorMsg ) +LIB_SYMBOL* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib, + wxWindow* aParent, bool aShowErrorMsg ) { wxCHECK_MSG( aLibTable, nullptr, "Invalid symbol library table." ); - LIB_PART* symbol = nullptr; + LIB_SYMBOL* symbol = nullptr; try { @@ -192,7 +192,8 @@ void SCH_BASE_FRAME::UpdateStatusBar() } -LIB_PART* SCH_BASE_FRAME::GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowErrorMsg ) +LIB_SYMBOL* SCH_BASE_FRAME::GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib, + bool aShowErrorMsg ) { PART_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL; diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index d9e82948db..9efb4fc93a 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -50,7 +50,7 @@ class PAGE_INFO; class TITLE_BLOCK; class SYMBOL_VIEWER_FRAME; class SYMBOL_EDIT_FRAME; -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class SCHLIB_FILTER; class LIB_ID; @@ -72,8 +72,8 @@ class SYMBOL_EDITOR_SETTINGS; * * @return The symbol found in the library or NULL if the symbol was not found. */ -LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, - PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL, +LIB_SYMBOL* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, + PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL, bool aShowErrorMsg = false ); /** @@ -177,10 +177,10 @@ 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_PART* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false, - bool aShowErrorMsg = false ); + LIB_SYMBOL* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false, + bool aShowErrorMsg = false ); - LIB_PART* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false ); + LIB_SYMBOL* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false ); /** * Call the library viewer to select symbol to import into schematic. diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index b78c0a6cbe..d6cc0b300b 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -105,10 +105,10 @@ SCH_DRAW_PANEL::~SCH_DRAW_PANEL() } -void SCH_DRAW_PANEL::DisplayComponent( LIB_PART* aComponent ) +void SCH_DRAW_PANEL::DisplayComponent( LIB_SYMBOL* aSymbol ) { GetView()->Clear(); - GetView()->DisplayComponent( aComponent ); + GetView()->DisplayComponent( aSymbol ); } diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 8d7cd682b4..516906e0f2 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -31,7 +31,7 @@ #include -class LIB_PART; +class LIB_SYMBOL; class SCH_SCREEN; @@ -44,7 +44,7 @@ public: ~SCH_DRAW_PANEL(); - void DisplayComponent( LIB_PART *aComponent ); + void DisplayComponent( LIB_SYMBOL *aSymbol ); void DisplaySheet( SCH_SCREEN *aScreen ); bool SwitchBackend( GAL_TYPE aGalType ) override; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 217fa5dfc2..fead0d2135 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1606,7 +1606,7 @@ void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent ) } -void SCH_EDIT_FRAME::SaveSymbolToSchematic( const LIB_PART& aSymbol ) +void SCH_EDIT_FRAME::SaveSymbolToSchematic( const LIB_SYMBOL& aSymbol ) { wxString msg; bool appendToUndo = false; @@ -1634,8 +1634,8 @@ void SCH_EDIT_FRAME::SaveSymbolToSchematic( const LIB_PART& aSymbol ) wxCHECK( symbol, /* void */ ); - // This needs to be done before the LIB_PART is changed to prevent stale library symbols in - // the schematic file. + // This needs to be done before the LIB_SYMBOL is changed to prevent stale library + // symbols in the schematic file. currentScreen->Remove( symbol ); if( !symbol->IsNew() ) diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index c682a7badc..09cbb02f81 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -817,13 +817,13 @@ public: void FocusOnItem( SCH_ITEM* aItem ); /** - * Update the #LIB_PART of the currently selected symbol. + * Update the #LIB_SYMBOL of the currently selected symbol. * * This is typically called from the symbol editor when editing symbols in place. * - * @param aSymbol is the #LIB_PART to update. + * @param aSymbol is the #LIB_SYMBOL to update. */ - void SaveSymbolToSchematic( const LIB_PART& aSymbol ); + void SaveSymbolToSchematic( const LIB_SYMBOL& aSymbol ); /** * Update the schematic's page reference map for all global labels, and refresh the labels diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index baf9909a8c..b0379368ba 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -182,7 +182,7 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const // For more than one part per package, we must add the part selection // A, B, ... or 1, 2, .. to the reference. if( parentSymbol->GetUnitCount() > 1 ) - text << LIB_PART::SubReference( parentSymbol->GetUnit() ); + text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() ); } } else if( m_parent && m_parent->Type() == SCH_SHEET_T ) @@ -362,7 +362,7 @@ bool SCH_FIELD::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) return true; if( parentSymbol->GetUnitCount() > 1 ) - text << LIB_PART::SubReference( parentSymbol->GetUnit() ); + text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() ); } } diff --git a/eeschema/sch_io_mgr.h b/eeschema/sch_io_mgr.h index 8d9516286b..bcca0332d6 100644 --- a/eeschema/sch_io_mgr.h +++ b/eeschema/sch_io_mgr.h @@ -35,7 +35,7 @@ class SCH_SCREEN; class SCH_PLUGIN; class SCHEMATIC; class KIWAY; -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class PROPERTIES; @@ -248,13 +248,13 @@ public: const PROPERTIES* aProperties = nullptr ); /** - * Populate a list of #LIB_PART alias names contained within the library \a aLibraryPath. + * Populate a list of #LIB_SYMBOL alias names contained within the library \a aLibraryPath. * - * @param aSymbolNameList is an array to populate with the #LIB_PART names associated with + * @param aSymbolNameList is an array to populate with the #LIB_SYMBOL names associated with * the library. * * @param aLibraryPath is a locator for the "library", usually a directory, file, - * or URL containing one or more #LIB_PART objects. + * or URL containing one or more #LIB_SYMBOL objects. * * @param aProperties is an associative array that can be used to tell the plugin anything * needed about how to perform with respect to \a aLibraryPath. The @@ -267,16 +267,16 @@ public: const PROPERTIES* aProperties = nullptr ); /** - * Populate a list of #LIB_PART aliases contained within the library \a aLibraryPath. + * Populate a list of #LIB_SYMBOL aliases contained within the library \a aLibraryPath. * * @note It is the responsibility of the caller to delete the returned object from the heap. * Failure to do this will result in memory leaks. * - * @param aSymbolList is an array to populate with the #LIB_PART pointers associated with + * @param aSymbolList is an array to populate with the #LIB_SYMBOL pointers associated with * the library. * * @param aLibraryPath is a locator for the "library", usually a directory, file, - * or URL containing one or more #LIB_PART objects. + * or URL containing one or more #LIB_SYMBOL objects. * * @param aProperties is an associative array that can be used to tell the plugin anything * needed about how to perform with respect to \a aLibraryPath. The @@ -285,18 +285,18 @@ public: * * @throw IO_ERROR if the library cannot be found, the part library cannot be loaded. */ - virtual void EnumerateSymbolLib( std::vector& aSymbolList, + virtual void EnumerateSymbolLib( std::vector& aSymbolList, const wxString& aLibraryPath, const PROPERTIES* aProperties = nullptr ); /** - * Load a #LIB_PART object having \a aPartName from the \a aLibraryPath containing + * Load a #LIB_SYMBOL object having \a aPartName from the \a aLibraryPath containing * a library format that this #SCH_PLUGIN knows about. * * @param aLibraryPath is a locator for the "library", usually a directory, file, * or URL containing several symbols. * - * @param aPartName is the name of the #LIB_PART to load. + * @param aPartName is the name of the #LIB_SYMBOL to load. * * @param aProperties is an associative array that can be used to tell the loader * implementation to do something special, because it can take @@ -310,13 +310,13 @@ public: * @throw IO_ERROR if the library cannot be found or read. No exception * is thrown in the case where aAliasName cannot be found. */ - virtual LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName, + virtual LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName, const PROPERTIES* aProperties = nullptr ); /** - * Write \a aSymbol to an existing library located at \a aLibraryPath. If a #LIB_PART + * Write \a aSymbol to an existing library located at \a aLibraryPath. If a #LIB_SYMBOL * by the same name already exists or there are any conflicting alias names, the new - * #LIB_PART will silently overwrite any existing aliases and/or part because libraries + * #LIB_SYMBOL will silently overwrite any existing aliases and/or part because libraries * cannot have duplicate alias names. It is the responsibility of the caller to check * the library for conflicts before saving. * @@ -324,7 +324,7 @@ public: * or URL containing several symbols. * * @param aSymbol is what to store in the library. The library is refreshed and the - * caller must update any #LIB_PART pointers that may have changed. + * caller must update any #LIB_SYMBOL pointers that may have changed. * * @param aProperties is an associative array that can be used to tell the * saver how to save the symbol, because it can take any number of @@ -334,17 +334,17 @@ public: * * @throw IO_ERROR if there is a problem saving. */ - virtual void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + virtual void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties = nullptr ); /** - * Delete the entire #LIB_PART associated with \a aAliasName from the library + * Delete the entire #LIB_SYMBOL associated with \a aAliasName from the library * \a aLibraryPath. * * @param aLibraryPath is a locator for the "library", usually a directory, file, * or URL containing several symbols. * - * @param aSymbolName is the name of a #LIB_PART associated with it's root #LIB_PART + * @param aSymbolName is the name of a #LIB_SYMBOL associated with it's root #LIB_SYMBOL * object to delete from the specified library. * * @param aProperties is an associative array that can be used to tell the library diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 7d1cb29b3c..b2b08791d5 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -119,7 +119,7 @@ EESCHEMA_SETTINGS* eeconfig() /** - * Used when a LIB_PART is not found in library to draw a dummy shape. + * Used when a LIB_SYMBOL is not found in library to draw a dummy shape. * This symbol is a 400 mils square with the text "??" * * DEF DUMMY U 0 40 Y Y 1 0 N @@ -131,29 +131,29 @@ EESCHEMA_SETTINGS* eeconfig() * ENDDRAW * ENDDEF */ -static LIB_PART* dummy() +static LIB_SYMBOL* dummy() { - static LIB_PART* part; + static LIB_SYMBOL* symbol; - if( !part ) + if( !symbol ) { - part = new LIB_PART( wxEmptyString ); + symbol = new LIB_SYMBOL( wxEmptyString ); - LIB_RECTANGLE* square = new LIB_RECTANGLE( part ); + LIB_RECTANGLE* square = new LIB_RECTANGLE( symbol ); square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) ); square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) ); - LIB_TEXT* text = new LIB_TEXT( part ); + LIB_TEXT* text = new LIB_TEXT( symbol ); text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) ); text->SetText( wxString( wxT( "??" ) ) ); - part->AddDrawItem( square ); - part->AddDrawItem( text ); + symbol->AddDrawItem( square ); + symbol->AddDrawItem( text ); } - return part; + return symbol; } @@ -211,7 +211,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) switch( item->Type() ) { - HANDLE_ITEM( LIB_PART_T, LIB_PART ); + HANDLE_ITEM( LIB_SYMBOL_T, LIB_SYMBOL ); HANDLE_ITEM( LIB_RECTANGLE_T, LIB_RECTANGLE ); HANDLE_ITEM( LIB_POLYLINE_T, LIB_POLYLINE ); HANDLE_ITEM( LIB_CIRCLE_T, LIB_CIRCLE ); @@ -269,7 +269,8 @@ float SCH_PAINTER::getShadowWidth() const // For best visuals the selection width must be a cross between the zoom level and the // default line width. - return (float) std::fabs( matrix.GetScale().x * 2.75 ) + Mils2iu( eeconfig()->m_Selection.thickness ); + return (float) std::fabs( matrix.GetScale().x * 2.75 ) + + Mils2iu( eeconfig()->m_Selection.thickness ); } @@ -412,7 +413,7 @@ void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, } -void SCH_PAINTER::draw( const LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert ) +void SCH_PAINTER::draw( const LIB_SYMBOL *aSymbol, int aLayer, bool aDrawFields, int aUnit, int aConvert ) { if( !aUnit ) aUnit = m_schSettings.m_ShowUnit; @@ -420,16 +421,16 @@ void SCH_PAINTER::draw( const LIB_PART *aPart, int aLayer, bool aDrawFields, int if( !aConvert ) aConvert = m_schSettings.m_ShowConvert; - std::unique_ptr< LIB_PART > tmpPart; - const LIB_PART* drawnPart = aPart; + std::unique_ptr< LIB_SYMBOL > tmpSymbol; + const LIB_SYMBOL* drawnSymbol = aSymbol; - if( aPart->IsAlias() ) + if( aSymbol->IsAlias() ) { - tmpPart = aPart->Flatten(); - drawnPart = tmpPart.get(); + tmpSymbol = aSymbol->Flatten(); + drawnSymbol = tmpSymbol.get(); } - for( const LIB_ITEM& item : drawnPart->GetDrawItems() ) + for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() ) { if( !aDrawFields && item.Type() == LIB_FIELD_T ) continue; @@ -948,11 +949,11 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( dangling ) drawPinDanglingSymbol( pos, drawingShadows ); - LIB_PART* libEntry = aPin->GetParent(); + LIB_SYMBOL* libEntry = aPin->GetParent(); // Draw the labels if( drawingShadows - && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() ) + && ( libEntry->Type() == LIB_SYMBOL_T || libEntry->IsSelected() ) && !eeconfig()->m_Selection.draw_selected_children ) { return; @@ -1388,7 +1389,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) } -static void orientPart( LIB_PART* part, int orientation ) +static void orientSymbol( LIB_SYMBOL* symbol, int orientation ) { struct ORIENT { @@ -1424,7 +1425,7 @@ static void orientPart( LIB_PART* part, int orientation ) } } - for( auto& item : part->GetDrawItems() ) + for( auto& item : symbol->GetDrawItems() ) { for( int i = 0; i < o.n_rots; i++ ) item.Rotate( wxPoint(0, 0 ), true ); @@ -1443,21 +1444,21 @@ void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer ) int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() ); int convert = aSymbol->GetConvert(); - // Use dummy part if the actual couldn't be found (or couldn't be locked). - LIB_PART* originalPart = aSymbol->GetPartRef() ? aSymbol->GetPartRef().get() : dummy(); + // Use dummy symbol if the actual couldn't be found (or couldn't be locked). + LIB_SYMBOL* originalSymbol = aSymbol->GetPartRef() ? aSymbol->GetPartRef().get() : dummy(); LIB_PINS originalPins; - originalPart->GetPins( originalPins, unit, convert ); + originalSymbol->GetPins( originalPins, unit, convert ); // Copy the source so we can re-orient and translate it. - LIB_PART tempPart( *originalPart ); + LIB_SYMBOL tempSymbol( *originalSymbol ); LIB_PINS tempPins; - tempPart.GetPins( tempPins, unit, convert ); + tempSymbol.GetPins( tempPins, unit, convert ); - tempPart.SetFlags( aSymbol->GetFlags() ); + tempSymbol.SetFlags( aSymbol->GetFlags() ); - orientPart( &tempPart, aSymbol->GetOrientation() ); + orientSymbol( &tempSymbol, aSymbol->GetOrientation() ); - for( auto& tempItem : tempPart.GetDrawItems() ) + for( auto& tempItem : tempSymbol.GetDrawItems() ) { tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aSymbol->GetPosition() ) ); @@ -1480,7 +1481,7 @@ void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer ) tempPin->SetFlags( IS_DANGLING ); } - draw( &tempPart, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() ); + draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() ); // The fields are SCH_SYMBOL-specific so don't need to be copied/oriented/translated for( const SCH_FIELD& field : aSymbol->GetFields() ) diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 852e3b8c13..248e5383e6 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -36,7 +36,7 @@ class LIB_RECTANGLE; class LIB_PIN; class LIB_CIRCLE; class LIB_ITEM; -class LIB_PART; +class LIB_SYMBOL; class LIB_POLYLINE; class LIB_ARC; class LIB_FIELD; @@ -153,7 +153,7 @@ private: void draw( const LIB_RECTANGLE* aRect, int aLayer ); void draw( LIB_PIN* aPin, int aLayer ); void draw( const LIB_CIRCLE* aCircle, int aLayer ); - void draw( const LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, + void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 ); void draw( const LIB_ARC* aArc, int aLayer ); void draw( const LIB_POLYLINE* aLine, int aLayer ); diff --git a/eeschema/sch_plugin.cpp b/eeschema/sch_plugin.cpp index 59ac10e5f1..d2d83ff4f5 100644 --- a/eeschema/sch_plugin.cpp +++ b/eeschema/sch_plugin.cpp @@ -73,7 +73,7 @@ void SCH_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList, } -void SCH_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, +void SCH_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, const wxString& aLibraryPath, const PROPERTIES* aProperties ) { @@ -82,7 +82,7 @@ void SCH_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, } -LIB_PART* SCH_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, +LIB_SYMBOL* SCH_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, const PROPERTIES* aProperties ) { // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface. @@ -91,7 +91,7 @@ LIB_PART* SCH_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& } -void SCH_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, +void SCH_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties ) { // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface. diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 037e011dcc..1a232b24c8 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -308,7 +308,8 @@ void SCH_ALTIUM_PLUGIN::ParseStorage( const CFB::CompoundFileReader& aReader ) if( reader.HasParsingError() ) THROW_IO_ERROR( "stream was not parsed correctly!" ); - // TODO pointhi: is it possible to have multiple headers in one Storage file? Otherwise throw IO Error. + // TODO pointhi: is it possible to have multiple headers in one Storage file? Otherwise + // throw IO Error. if( reader.GetRemainingBytes() != 0 ) wxLogError( wxString::Format( "Storage file was not fully parsed as %d bytes are remaining.", @@ -486,18 +487,18 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const CFB::CompoundFileReader& aReader if( reader.GetRemainingBytes() != 0 ) THROW_IO_ERROR( "stream is not fully parsed" ); - // assign LIB_PART -> COMPONENT + // assign LIB_SYMBOL -> COMPONENT for( auto component : m_components ) { - auto kpart = m_symbols.find( component.first ); + auto ksymbol = m_symbols.find( component.first ); - if( kpart == m_symbols.end() ) + if( ksymbol == m_symbols.end() ) THROW_IO_ERROR( "every component should have a symbol attached" ); - m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_PART( *( kpart->second ) ), + m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_SYMBOL( *( ksymbol->second ) ), m_properties.get() ); - component.second->SetLibSymbol( kpart->second ); + component.second->SetLibSymbol( ksymbol->second ); } // Handle title blocks @@ -563,11 +564,11 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex, elem.libreference ); LIB_ID libId = AltiumToKiCadLibID( getLibName(), name ); - LIB_PART* kpart = new LIB_PART( wxEmptyString ); - kpart->SetName( name ); - kpart->SetDescription( elem.componentdescription ); - kpart->SetLibId( libId ); - m_symbols.insert( { aIndex, kpart } ); + LIB_SYMBOL* ksymbol = new LIB_SYMBOL( wxEmptyString ); + ksymbol->SetName( name ); + ksymbol->SetDescription( elem.componentdescription ); + ksymbol->SetLibId( libId ); + m_symbols.insert( { aIndex, ksymbol } ); // each component has its own symbol for now SCH_SYMBOL* symbol = new SCH_SYMBOL(); @@ -575,7 +576,7 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex, symbol->SetPosition( elem.location + m_sheetOffset ); //component->SetOrientation( elem.orientation ); // TODO: keep it simple for now, and only set position symbol->SetLibId( libId ); - //component->SetLibSymbol( kpart ); // this has to be done after parsing the LIB_PART! + //component->SetLibSymbol( ksymbol ); // this has to be done after parsing the LIB_SYMBOL! symbol->SetUnit( elem.currentpartid ); @@ -1426,29 +1427,29 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map& aPr } -wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE aStyle, +wxPoint HelperGeneratePowerPortGraphics( LIB_SYMBOL* aKsymbol, ASCH_POWER_PORT_STYLE aStyle, REPORTER* aReporter ) { if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE || aStyle == ASCH_POWER_PORT_STYLE::ARROW ) { - LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line1 ); + LIB_POLYLINE* line1 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line1 ); line1->SetWidth( Mils2iu( 10 ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, Mils2iu( -50 ) } ); if( aStyle == ASCH_POWER_PORT_STYLE::CIRCLE ) { - LIB_CIRCLE* circle = new LIB_CIRCLE( aKPart ); - aKPart->AddDrawItem( circle ); + LIB_CIRCLE* circle = new LIB_CIRCLE( aKsymbol ); + aKsymbol->AddDrawItem( circle ); circle->SetWidth( Mils2iu( 5 ) ); circle->SetRadius( Mils2iu( 25 ) ); circle->SetPosition( { Mils2iu( 0 ), Mils2iu( -75 ) } ); } else { - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -25 ), Mils2iu( -50 ) } ); line2->AddPoint( { Mils2iu( 25 ), Mils2iu( -50 ) } ); @@ -1460,14 +1461,14 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE } else if( aStyle == ASCH_POWER_PORT_STYLE::WAVE ) { - LIB_POLYLINE* line = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line ); + LIB_POLYLINE* line = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line ); line->SetWidth( Mils2iu( 10 ) ); line->AddPoint( { 0, 0 } ); line->AddPoint( { 0, Mils2iu( -72 ) } ); - LIB_BEZIER* bezier = new LIB_BEZIER( aKPart ); - aKPart->AddDrawItem( bezier ); + LIB_BEZIER* bezier = new LIB_BEZIER( aKsymbol ); + aKsymbol->AddDrawItem( bezier ); bezier->SetWidth( Mils2iu( 5 ) ); bezier->AddPoint( { Mils2iu( 30 ), Mils2iu( -50 ) } ); bezier->AddPoint( { Mils2iu( 30 ), Mils2iu( -87 ) } ); @@ -1481,42 +1482,42 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE || aStyle == ASCH_POWER_PORT_STYLE::EARTH || aStyle == ASCH_POWER_PORT_STYLE::GOST_ARROW ) { - LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line1 ); + LIB_POLYLINE* line1 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line1 ); line1->SetWidth( Mils2iu( 10 ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, Mils2iu( -100 ) } ); if( aStyle == ASCH_POWER_PORT_STYLE::POWER_GROUND ) { - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -100 ), Mils2iu( -100 ) } ); line2->AddPoint( { Mils2iu( 100 ), Mils2iu( -100 ) } ); - LIB_POLYLINE* line3 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line3 ); + LIB_POLYLINE* line3 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line3 ); line3->SetWidth( Mils2iu( 10 ) ); line3->AddPoint( { Mils2iu( -70 ), Mils2iu( -130 ) } ); line3->AddPoint( { Mils2iu( 70 ), Mils2iu( -130 ) } ); - LIB_POLYLINE* line4 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line4 ); + LIB_POLYLINE* line4 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line4 ); line4->SetWidth( Mils2iu( 10 ) ); line4->AddPoint( { Mils2iu( -40 ), Mils2iu( -160 ) } ); line4->AddPoint( { Mils2iu( 40 ), Mils2iu( -160 ) } ); - LIB_POLYLINE* line5 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line5 ); + LIB_POLYLINE* line5 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line5 ); line5->SetWidth( Mils2iu( 10 ) ); line5->AddPoint( { Mils2iu( -10 ), Mils2iu( -190 ) } ); line5->AddPoint( { Mils2iu( 10 ), Mils2iu( -190 ) } ); } else if( aStyle == ASCH_POWER_PORT_STYLE::SIGNAL_GROUND ) { - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -100 ), Mils2iu( -100 ) } ); line2->AddPoint( { Mils2iu( 100 ), Mils2iu( -100 ) } ); @@ -1525,24 +1526,24 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE } else if( aStyle == ASCH_POWER_PORT_STYLE::EARTH ) { - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -150 ), Mils2iu( -200 ) } ); line2->AddPoint( { Mils2iu( -100 ), Mils2iu( -100 ) } ); line2->AddPoint( { Mils2iu( 100 ), Mils2iu( -100 ) } ); line2->AddPoint( { Mils2iu( 50 ), Mils2iu( -200 ) } ); - LIB_POLYLINE* line3 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line3 ); + LIB_POLYLINE* line3 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line3 ); line3->SetWidth( Mils2iu( 10 ) ); line3->AddPoint( { Mils2iu( 0 ), Mils2iu( -100 ) } ); line3->AddPoint( { Mils2iu( -50 ), Mils2iu( -200 ) } ); } else // ASCH_POWER_PORT_STYLE::GOST_ARROW { - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -25 ), Mils2iu( -50 ) } ); line2->AddPoint( { Mils2iu( 0 ), Mils2iu( -100 ) } ); @@ -1556,26 +1557,26 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE else if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND || aStyle == ASCH_POWER_PORT_STYLE::GOST_EARTH ) { - LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line1 ); + LIB_POLYLINE* line1 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line1 ); line1->SetWidth( Mils2iu( 10 ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, Mils2iu( -160 ) } ); - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -100 ), Mils2iu( -160 ) } ); line2->AddPoint( { Mils2iu( 100 ), Mils2iu( -160 ) } ); - LIB_POLYLINE* line3 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line3 ); + LIB_POLYLINE* line3 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line3 ); line3->SetWidth( Mils2iu( 10 ) ); line3->AddPoint( { Mils2iu( -60 ), Mils2iu( -200 ) } ); line3->AddPoint( { Mils2iu( 60 ), Mils2iu( -200 ) } ); - LIB_POLYLINE* line4 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line4 ); + LIB_POLYLINE* line4 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line4 ); line4->SetWidth( Mils2iu( 10 ) ); line4->AddPoint( { Mils2iu( -20 ), Mils2iu( -240 ) } ); line4->AddPoint( { Mils2iu( 20 ), Mils2iu( -240 ) } ); @@ -1583,8 +1584,8 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE if( aStyle == ASCH_POWER_PORT_STYLE::GOST_POWER_GROUND ) return { 0, Mils2iu( 300 ) }; - LIB_CIRCLE* circle = new LIB_CIRCLE( aKPart ); - aKPart->AddDrawItem( circle ); + LIB_CIRCLE* circle = new LIB_CIRCLE( aKsymbol ); + aKsymbol->AddDrawItem( circle ); circle->SetWidth( Mils2iu( 10 ) ); circle->SetRadius( Mils2iu( 120 ) ); circle->SetPosition( { Mils2iu( 0 ), Mils2iu( -160 ) } ); @@ -1593,14 +1594,14 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE } else if( aStyle == ASCH_POWER_PORT_STYLE::GOST_BAR ) { - LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line1 ); + LIB_POLYLINE* line1 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line1 ); line1->SetWidth( Mils2iu( 10 ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, Mils2iu( -200 ) } ); - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -100 ), Mils2iu( -200 ) } ); line2->AddPoint( { Mils2iu( 100 ), Mils2iu( -200 ) } ); @@ -1615,14 +1616,14 @@ wxPoint HelperGeneratePowerPortGraphics( LIB_PART* aKPart, ASCH_POWER_PORT_STYLE RPT_SEVERITY_WARNING ); } - LIB_POLYLINE* line1 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line1 ); + LIB_POLYLINE* line1 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line1 ); line1->SetWidth( Mils2iu( 10 ) ); line1->AddPoint( { 0, 0 } ); line1->AddPoint( { 0, Mils2iu( -100 ) } ); - LIB_POLYLINE* line2 = new LIB_POLYLINE( aKPart ); - aKPart->AddDrawItem( line2 ); + LIB_POLYLINE* line2 = new LIB_POLYLINE( aKsymbol ); + aKsymbol->AddDrawItem( line2 ); line2->SetWidth( Mils2iu( 10 ) ); line2->AddPoint( { Mils2iu( -50 ), Mils2iu( -100 ) } ); line2->AddPoint( { Mils2iu( 50 ), Mils2iu( -100 ) } ); @@ -1638,29 +1639,30 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map& aPro LIB_ID libId = AltiumToKiCadLibID( getLibName(), elem.text ); - LIB_PART* kpart = nullptr; + LIB_SYMBOL* ksymbol = nullptr; const auto& symbol = m_powerSymbols.find( elem.text ); if( symbol != m_powerSymbols.end() ) { - kpart = symbol->second; // cache hit + ksymbol = symbol->second; // cache hit } else { - kpart = new LIB_PART( wxEmptyString ); - kpart->SetPower(); - kpart->SetName( elem.text ); - kpart->GetReferenceField().SetText( "#PWR" ); - kpart->GetValueField().SetText( elem.text ); - kpart->GetValueField().SetVisible( true ); // TODO: why does this not work? - kpart->SetDescription( wxString::Format( _( "Power symbol creates a global label with name '%s'" ), - elem.text ) ); - kpart->SetKeyWords( "power-flag" ); - kpart->SetLibId( libId ); + ksymbol = new LIB_SYMBOL( wxEmptyString ); + ksymbol->SetPower(); + ksymbol->SetName( elem.text ); + ksymbol->GetReferenceField().SetText( "#PWR" ); + ksymbol->GetValueField().SetText( elem.text ); + ksymbol->GetValueField().SetVisible( true ); // TODO: why does this not work? + ksymbol->SetDescription( + wxString::Format( _( "Power symbol creates a global label with name '%s'" ), + elem.text ) ); + ksymbol->SetKeyWords( "power-flag" ); + ksymbol->SetLibId( libId ); // generate graphic - LIB_PIN* pin = new LIB_PIN( kpart ); - kpart->AddDrawItem( pin ); + LIB_PIN* pin = new LIB_PIN( ksymbol ); + ksymbol->AddDrawItem( pin ); pin->SetName( elem.text ); pin->SetPosition( { 0, 0 } ); @@ -1670,13 +1672,13 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map& aPro pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); pin->SetVisible( false ); - wxPoint valueFieldPos = HelperGeneratePowerPortGraphics( kpart, elem.style, m_reporter ); + wxPoint valueFieldPos = HelperGeneratePowerPortGraphics( ksymbol, elem.style, m_reporter ); - kpart->GetValueField().SetPosition( valueFieldPos ); + ksymbol->GetValueField().SetPosition( valueFieldPos ); - // this has to be done after parsing the LIB_PART! - m_pi->SaveSymbol( getLibFileName().GetFullPath(), kpart, m_properties.get() ); - m_powerSymbols.insert( { elem.text, kpart } ); + // this has to be done after parsing the LIB_SYMBOL! + m_pi->SaveSymbol( getLibFileName().GetFullPath(), ksymbol, m_properties.get() ); + m_powerSymbols.insert( { elem.text, ksymbol } ); } SCH_SHEET_PATH sheetpath; @@ -1687,13 +1689,13 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map& aPro component->SetRef( &sheetpath, "#PWR?" ); component->SetValue( elem.text ); component->SetLibId( libId ); - component->SetLibSymbol( new LIB_PART( *kpart ) ); + component->SetLibSymbol( new LIB_SYMBOL( *ksymbol ) ); SCH_FIELD* valueField = component->GetField( VALUE_FIELD ); // TODO: Why do I need to set those a second time? valueField->SetVisible( true ); - valueField->SetPosition( kpart->GetValueField().GetPosition() ); + valueField->SetPosition( ksymbol->GetValueField().GetPosition() ); component->SetPosition( elem.location + m_sheetOffset ); diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.h b/eeschema/sch_plugins/altium/sch_altium_plugin.h index be0ad79c58..146a61d343 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.h +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.h @@ -79,10 +79,10 @@ public: //void EnumerateSymbolLib( wxArrayString& aAliasNameList, const wxString& aLibraryPath, // const PROPERTIES* aProperties = NULL ) override; - //LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + //LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, // const PROPERTIES* aProperties = NULL ) override; - //void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + //void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, // const PROPERTIES* aProperties = NULL ) override; //void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName, @@ -157,9 +157,9 @@ private: std::unique_ptr m_altiumSheet; std::map m_components; std::map m_sheets; - std::map m_symbols; // every component has its unique symbol + std::map m_symbols; // every component has its unique symbol - std::map m_powerSymbols; + std::map m_powerSymbols; std::vector m_altiumStorage; std::map m_altiumComponents; diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index a9a4144f73..0da298e420 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -337,7 +337,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() if( part.Definition.GateSymbols.size() == 0 ) continue; - LIB_PART* kiPart = new LIB_PART( part.Name ); + LIB_SYMBOL* kiPart = new LIB_SYMBOL( part.Name ); kiPart->SetUnitCount( part.Definition.GateSymbols.size() ); bool ok = true; @@ -371,7 +371,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() { ( *m_plugin )->SaveSymbol( m_libraryFileName.GetFullPath(), kiPart ); - LIB_PART* loadedPart = + LIB_SYMBOL* loadedPart = ( *m_plugin )->LoadSymbol( m_libraryFileName.GetFullPath(), kiPart->GetName() ); m_partMap.insert( { partID, loadedPart } ); @@ -413,7 +413,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() sym.GateID = wxT( "A" ); // Assume Gate "A" if unspecified PART_GATE_ID partSymbolID = { sym.PartRef.RefID, sym.GateID }; - LIB_PART* kiPart = m_partMap.at( sym.PartRef.RefID ); + LIB_SYMBOL* kiPart = m_partMap.at( sym.PartRef.RefID ); bool copy = false; // The symbol definition in the part either does not exist for this gate number @@ -421,13 +421,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() if( m_partSymbolsMap.find( partSymbolID ) == m_partSymbolsMap.end() || m_partSymbolsMap.at( partSymbolID ) != sym.SymdefID ) { - kiPart = new LIB_PART( *kiPart ); // Make a copy + kiPart = new LIB_SYMBOL( *kiPart ); // Make a copy copy = true; const PART& part = Parts.PartDefinitions.at( sym.PartRef.RefID ); loadSymDefIntoLibrary( sym.SymdefID, &part, sym.GateID, kiPart ); } - LIB_PART* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator, + LIB_SYMBOL* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator, sym.ScaleRatioDenominator ); double symOrientDeciDeg = 0.0; @@ -526,7 +526,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() if( sym.SymbolVariant.Type == SYMBOLVARIANT::TYPE::GLOBALSIGNAL ) { SYMDEF_ID symID = sym.SymdefID; - LIB_PART* kiPart = nullptr; + LIB_SYMBOL* kiPart = nullptr; // In CADSTAR "GlobalSignal" is a special type of symbol which defines // a Power Symbol. The "Alternate" name defines the default net name of @@ -556,7 +556,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() { SYMDEF_SCM symbolDef = Library.SymbolDefinitions.at( symID ); - kiPart = new LIB_PART( libPartName ); + kiPart = new LIB_SYMBOL( libPartName ); kiPart->SetPower(); loadSymDefIntoLibrary( symID, nullptr, "A", kiPart ); @@ -589,8 +589,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() wxASSERT( kiPart->GetValueField().GetText() == symbolInstanceNetName ); } - LIB_PART* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator, - sym.ScaleRatioDenominator ); + LIB_SYMBOL* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator, + sym.ScaleRatioDenominator ); double returnedOrient = 0.0; SCH_SYMBOL* symbol = loadSchematicSymbol( sym, *scaledPart, returnedOrient ); @@ -788,7 +788,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() if( aNode.Contains( "BLKT" ) ) { NET_SCH::BLOCK_TERM blockTerm = net.BlockTerminals.at( aNode ); - BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID, blockTerm.TerminalID ); + BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID, + blockTerm.TerminalID ); if( m_sheetPinMap.find( blockPinID ) != m_sheetPinMap.end() ) @@ -1203,7 +1204,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables() void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdefID, - const PART* aCadstarPart, const GATE_ID& aGateID, LIB_PART* aPart ) + const PART* aCadstarPart, const GATE_ID& aGateID, LIB_SYMBOL* aSymbol ) { wxCHECK( Library.SymbolDefinitions.find( aSymdefID ) != Library.SymbolDefinitions.end(), ); @@ -1214,11 +1215,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef { FIGURE fig = figPair.second; - loadLibrarySymbolShapeVertices( fig.Shape.Vertices, symbol.Origin, aPart, gateNumber ); + loadLibrarySymbolShapeVertices( fig.Shape.Vertices, symbol.Origin, aSymbol, gateNumber ); for( CUTOUT c : fig.Shape.Cutouts ) { - loadLibrarySymbolShapeVertices( c.Vertices, symbol.Origin, aPart, gateNumber ); + loadLibrarySymbolShapeVertices( c.Vertices, symbol.Origin, aSymbol, gateNumber ); } } @@ -1229,7 +1230,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef TERMINAL term = termPair.second; wxString pinNum = wxString::Format( "%ld", term.ID ); wxString pinName = wxEmptyString; - LIB_PIN* pin = new LIB_PIN( aPart ); + LIB_PIN* pin = new LIB_PIN( aSymbol ); if( aCadstarPart ) { @@ -1265,17 +1266,17 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef pin->SetNumber( pinNum ); pin->SetName( pinName ); - if( aPart->IsPower() ) + if( aSymbol->IsPower() ) { pin->SetVisible( false ); pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); - pin->SetName( aPart->GetName() ); + pin->SetName( aSymbol->GetName() ); } - aPart->AddDrawItem( pin ); + aSymbol->AddDrawItem( pin ); } - fixUpLibraryPins( aPart, gateNumber ); + fixUpLibraryPins( aSymbol, gateNumber ); if(aCadstarPart) m_pinNumsMap.insert( { aCadstarPart->ID + aGateID, pinNumMap } ); @@ -1284,7 +1285,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef { TEXT csText = textPair.second; - LIB_TEXT* libtext = new LIB_TEXT( aPart ); + LIB_TEXT* libtext = new LIB_TEXT( aSymbol ); libtext->SetText( csText.Text ); libtext->SetUnit( gateNumber ); libtext->SetPosition( getKiCadLibraryPoint( csText.Position, symbol.Origin ) ); @@ -1319,7 +1320,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef // Multiline text not allowed in LIB_TEXT line->SetMultilineAllowed( false ); - aPart->AddDrawItem( line ); + aSymbol->AddDrawItem( line ); } delete libtext; @@ -1328,33 +1329,33 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef { // Multiline text not allowed in LIB_TEXT libtext->SetMultilineAllowed( false ); - aPart->AddDrawItem( libtext ); + aSymbol->AddDrawItem( libtext ); } } if( symbol.TextLocations.find( SYMBOL_NAME_ATTRID ) != symbol.TextLocations.end() ) { TEXT_LOCATION textLoc = symbol.TextLocations.at( SYMBOL_NAME_ATTRID ); - LIB_FIELD* field = &aPart->GetReferenceField(); + LIB_FIELD* field = &aSymbol->GetReferenceField(); applyToLibraryFieldAttribute( textLoc, symbol.Origin, field ); field->SetUnit( gateNumber ); } // Hide the value field for now (it might get unhidden if an attribute exists in the cadstar // design with the text "Value" - aPart->GetValueField().SetVisible( false ); + aSymbol->GetValueField().SetVisible( false ); if( symbol.TextLocations.find( PART_NAME_ATTRID ) != symbol.TextLocations.end() ) { TEXT_LOCATION textLoc = symbol.TextLocations.at( PART_NAME_ATTRID ); - LIB_FIELD* field = aPart->FindField( PartNameFieldName ); + LIB_FIELD* field = aSymbol->FindField( PartNameFieldName ); if( !field ) { - int fieldID = aPart->GetFieldCount(); - field = new LIB_FIELD( aPart, fieldID ); + int fieldID = aSymbol->GetFieldCount(); + field = new LIB_FIELD( aSymbol, fieldID ); field->SetName( PartNameFieldName ); - aPart->AddField( field ); + aSymbol->AddField( field ); } wxASSERT( field->GetName() == PartNameFieldName ); @@ -1383,24 +1384,25 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef { wxString attrName = getAttributeName( aAttributeVal.AttributeID ); - //Remove invalid field characters + // Remove invalid field characters aAttributeVal.Value.Replace( wxT( "\n" ), wxT( "\\n" ) ); aAttributeVal.Value.Replace( wxT( "\r" ), wxT( "\\r" ) ); aAttributeVal.Value.Replace( wxT( "\t" ), wxT( "\\t" ) ); - //TODO: Handle "links": In cadstar a field can be a "link" if its name starts with the - //characters "Link ". Need to figure out how to convert them to equivalent in KiCad + //TODO: Handle "links": In cadstar a field can be a "link" if its name starts + // with the characters "Link ". Need to figure out how to convert them to + // equivalent in KiCad. if( attrName == wxT( "(PartDefinitionNameStem)" ) ) { //Space not allowed in Reference field aAttributeVal.Value.Replace( wxT( " " ), "_" ); - aPart->GetReferenceField().SetText( aAttributeVal.Value ); + aSymbol->GetReferenceField().SetText( aAttributeVal.Value ); return; } else if( attrName == wxT( "(PartDescription)" ) ) { - aPart->SetDescription( aAttributeVal.Value ); + aSymbol->SetDescription( aAttributeVal.Value ); return; } else if( attrName == wxT( "(PartDefinitionReferenceName)" ) ) @@ -1414,14 +1416,14 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef return; } - LIB_FIELD* attrField = aPart->FindField( attrName ); + LIB_FIELD* attrField = aSymbol->FindField( attrName ); if( !attrField ) { - int fieldID = aPart->GetFieldCount(); - attrField = new LIB_FIELD( aPart, fieldID ); + int fieldID = aSymbol->GetFieldCount(); + attrField = new LIB_FIELD( aSymbol, fieldID ); attrField->SetName( attrName ); - aPart->AddField( attrField ); + aSymbol->AddField( attrField ); } wxASSERT( attrField->GetName() == attrName ); @@ -1478,25 +1480,25 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef wxArrayString fpFilters; fpFilters.Add( fpNameInLibrary ); - aPart->SetFPFilters( fpFilters ); + aSymbol->SetFPFilters( fpFilters ); // Assume that the PCB footprint library name will be the same as the schematic filename wxFileName schFilename( Filename ); wxString libName = schFilename.GetName(); - aPart->GetFootprintField().SetText( libName + wxT( ":" ) + fpNameInLibrary ); + aSymbol->GetFootprintField().SetText( libName + wxT( ":" ) + fpNameInLibrary ); } if( aCadstarPart && aCadstarPart->Definition.HidePinNames ) { - aPart->SetShowPinNames( false ); - aPart->SetShowPinNumbers( false ); + aSymbol->SetShowPinNames( false ); + aSymbol->SetShowPinNumbers( false ); } } void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( - const std::vector& aCadstarVertices, wxPoint aSymbolOrigin, LIB_PART* aPart, + const std::vector& aCadstarVertices, wxPoint aSymbolOrigin, LIB_SYMBOL* aSymbol, int aGateNumber ) { const VERTEX* prev = &aCadstarVertices.at( 0 ); @@ -1529,7 +1531,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( switch( cur->Type ) { case VERTEX_TYPE::POINT: - segment = new LIB_POLYLINE( aPart ); + segment = new LIB_POLYLINE( aSymbol ); ( (LIB_POLYLINE*) segment )->AddPoint( startPoint ); ( (LIB_POLYLINE*) segment )->AddPoint( endPoint ); break; @@ -1541,7 +1543,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( case VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE: case VERTEX_TYPE::ANTICLOCKWISE_ARC: - segment = new LIB_ARC( aPart ); + segment = new LIB_ARC( aSymbol ); ( (LIB_ARC*) segment )->SetPosition( centerPoint ); @@ -1561,7 +1563,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices( } segment->SetUnit( aGateNumber ); - aPart->AddDrawItem( segment ); + aSymbol->AddDrawItem( segment ); prev = cur; } @@ -1583,7 +1585,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyToLibraryFieldAttribute( SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCadstarSymbol, - const LIB_PART& aKiCadPart, + const LIB_SYMBOL& aKiCadPart, double& aComponentOrientationDeciDeg ) { LIB_ID libId( m_libraryFileName.GetName(), aKiCadPart.GetName() ); @@ -1890,10 +1892,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadGraphicStaightSegment( const wxPoint& aStar segment->SetLineStyle( getLineStyle( aCadstarLineCodeID ) ); //Apply transforms - wxPoint startPoint = applyTransform( aStartPoint, aMoveVector, aRotationAngleDeciDeg, aScalingFactor, - aTransformCentre, aMirrorInvert ); - wxPoint endPoint = applyTransform( aEndPoint, aMoveVector, aRotationAngleDeciDeg, aScalingFactor, - aTransformCentre, aMirrorInvert ); + wxPoint startPoint = applyTransform( aStartPoint, aMoveVector, aRotationAngleDeciDeg, + aScalingFactor, aTransformCentre, aMirrorInvert ); + wxPoint endPoint = applyTransform( aEndPoint, aMoveVector, aRotationAngleDeciDeg, + aScalingFactor, aTransformCentre, aMirrorInvert ); segment->SetStartPoint( startPoint ); segment->SetEndPoint( endPoint ); @@ -1998,9 +2000,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadFigure( const FIGURE& aCadstarFigure, void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( - LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize, const SCH_SHEET_PATH& aParentSheet ) + LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize, + const SCH_SHEET_PATH& aParentSheet ) { - wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), , "Sheet already loaded!" ); + wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), , + "Sheet already loaded!" ); SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition ); SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); @@ -2089,7 +2093,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( block.ID ) ); } - loadSheetAndChildSheets( block.AssocLayerID, blockExtents.first, blockExtents.second, aSheet ); + loadSheetAndChildSheets( block.AssocLayerID, blockExtents.first, blockExtents.second, + aSheet ); if( block.HasBlockLabel ) { @@ -2626,11 +2631,11 @@ SCH_TEXT* CADSTAR_SCH_ARCHIVE_LOADER::getKiCadSchText( const TEXT& aCadstarTextE } -LIB_PART* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_PART* aPart, - long long aScalingFactorNumerator, - long long aScalingFactorDenominator ) +LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSymbol, + long long aScalingFactorNumerator, + long long aScalingFactorDenominator ) { - LIB_PART* retval = new LIB_PART( *aPart ); + LIB_SYMBOL* retval = new LIB_SYMBOL( *aSymbol ); if( aScalingFactorNumerator == aScalingFactorDenominator ) return retval; // 1:1 scale, nothing to do @@ -2708,14 +2713,16 @@ LIB_PART* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_PART* aPart, } -void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_PART* aPartToFix, int aGateNumber ) +void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int aGateNumber ) { - // Store a list of segments that are not connected to other segments and are vertical or horizontal + // Store a list of segments that are not connected to other segments and are vertical or + // horizontal. std::map twoPointUniqueSegments; - LIB_ITEMS_CONTAINER::ITERATOR polylineiter = aPartToFix->GetDrawItems().begin( LIB_POLYLINE_T ); + LIB_ITEMS_CONTAINER::ITERATOR polylineiter = + aSymbolToFix->GetDrawItems().begin( LIB_POLYLINE_T ); - for( ; polylineiter != aPartToFix->GetDrawItems().end( LIB_POLYLINE_T ); ++polylineiter ) + for( ; polylineiter != aSymbolToFix->GetDrawItems().end( LIB_POLYLINE_T ); ++polylineiter ) { LIB_POLYLINE& polyline = static_cast( *polylineiter ); @@ -2757,8 +2764,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_PART* aPartToFix, int aGa } LIB_PINS pins; - aPartToFix->GetPins( pins, aGateNumber ); - + aSymbolToFix->GetPins( pins, aGateNumber ); for( auto& pin : pins ) { diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h index a7d11a8364..bd039a9899 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h @@ -38,7 +38,7 @@ class BUS_ALIAS; class EDA_TEXT; class LABEL_SPIN_STYLE; class LIB_FIELD; -class LIB_PART; +class LIB_SYMBOL; class SCH_SYMBOL; class SCH_ITEM; class SCH_FIELD; @@ -98,11 +98,11 @@ private: std::map m_sheetMap; ///< Map between Cadstar and KiCad Sheets std::map m_sheetPinMap; ///< Map between Cadstar and KiCad Sheets Pins - std::map m_partMap; ///< Map between Cadstar and KiCad Parts + std::map m_partMap; ///< Map between Cadstar and KiCad Parts std::map m_partSymbolsMap; ///< Map holding the symbols loaded so far /// for a particular PART_ID and GATE_ID std::map m_pinNumsMap; ///< Map of pin numbers in CADSTAR parts - std::map m_powerSymLibMap; ///< Map of KiCad Power Symbol Library items + std::map m_powerSymLibMap; ///< Map of KiCad Power Symbol Library items std::map m_powerSymMap; ///< Map between Cadstar and KiCad Power Symbols std::map @@ -134,16 +134,16 @@ private: //Helper Functions for loading library items void loadSymDefIntoLibrary( const SYMDEF_ID& aSymdefID, const PART* aCadstarPart, - const GATE_ID& aGateID, LIB_PART* aPart ); + const GATE_ID& aGateID, LIB_SYMBOL* aSymbol ); void loadLibrarySymbolShapeVertices( const std::vector& aCadstarVertices, - wxPoint aSymbolOrigin, LIB_PART* aPart, int aGateNumber ); + wxPoint aSymbolOrigin, LIB_SYMBOL* aSymbol, int aGateNumber ); void applyToLibraryFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc, wxPoint aSymbolOrigin, LIB_FIELD* aKiCadField ); //Helper Functions for loading symbols in schematic - SCH_SYMBOL* loadSchematicSymbol( const SYMBOL& aCadstarSymbol, const LIB_PART& aKiCadPart, + SCH_SYMBOL* loadSchematicSymbol( const SYMBOL& aCadstarSymbol, const LIB_SYMBOL& aKiCadPart, double& aComponentOrientationDeciDeg ); void loadSymbolFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc, @@ -211,10 +211,10 @@ private: //General Graphical manipulation functions - LIB_PART* getScaledLibPart( const LIB_PART* aPart, long long aScalingFactorNumerator, - long long aScalingFactorDenominator ); + LIB_SYMBOL* getScaledLibPart( const LIB_SYMBOL* aSymbol, long long aScalingFactorNumerator, + long long aScalingFactorDenominator ); - void fixUpLibraryPins( LIB_PART* aPartToFix, int aGateNumber ); + void fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int aGateNumber ); std::pair getFigureExtentsKiCad( const FIGURE& aCadstarFigure ); diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_plugin.h b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_plugin.h index 4326dad368..d3dc506b7d 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_plugin.h +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_plugin.h @@ -65,10 +65,10 @@ public: //void EnumerateSymbolLib( wxArrayString& aAliasNameList, const wxString& aLibraryPath, // const PROPERTIES* aProperties = NULL ) override; - //LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + //LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, // const PROPERTIES* aProperties = NULL ) override; - //void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + //void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, // const PROPERTIES* aProperties = NULL ) override; //void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName, diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index dfbda93838..14c63e93ac 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -1187,7 +1187,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) if( p != elib->package.end() ) package = p->second; - LIB_PART* part = + LIB_SYMBOL* part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), kisymbolname, m_properties.get() ); if( !part ) @@ -1349,11 +1349,11 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) // Save the pin positions SYMBOL_LIB_TABLE& schLibTable = *m_schematic->Prj().SchSymbolLibTable(); - LIB_PART* libSymbol = schLibTable.LoadSymbol( symbol->GetLibId() ); + LIB_SYMBOL* libSymbol = schLibTable.LoadSymbol( symbol->GetLibId() ); wxCHECK( libSymbol, /*void*/ ); - symbol->SetLibSymbol( new LIB_PART( *libSymbol ) ); + symbol->SetLibSymbol( new LIB_SYMBOL( *libSymbol ) ); std::vector pins; symbol->GetLibPins( pins ); @@ -1411,7 +1411,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( aEagleLibrary->package[symbolName] = edevice.package.Get(); // Create KiCad symbol. - unique_ptr kpart( new LIB_PART( symbolName ) ); + unique_ptr kpart( new LIB_SYMBOL( symbolName ) ); // Process each gate in the deviceset for this device. wxXmlNode* gateNode = getChildrenNodes( aDeviceSetChildren, "gates" ); @@ -1451,7 +1451,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxString name = fixSymbolName( kpart->GetName() ); kpart->SetName( name ); - m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_PART( *kpart.get() ), + m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_SYMBOL( *kpart.get() ), m_properties.get() ); aEagleLibrary->KiCadSymbols.insert( name, kpart.release() ); @@ -1465,7 +1465,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( } -bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aPart, +bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aSymbol, EDEVICE* aDevice, int aGateNumber, const wxString& aGateName ) { wxString symbolName = aSymbolNode->GetAttribute( "name" ); @@ -1484,12 +1484,12 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrAddDrawItem( loadSymbolCircle( aPart, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) ); } else if( nodeName == "pin" ) { EPIN ePin = EPIN( currentNode ); - std::unique_ptr pin( loadPin( aPart, currentNode, &ePin, aGateNumber ) ); + std::unique_ptr pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) ); pincount++; pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI ); @@ -1533,7 +1533,7 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrSetNumber( padname ); - aPart->AddDrawItem( apin ); + aSymbol->AddDrawItem( apin ); } break; @@ -1544,41 +1544,41 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrSetUnit( aGateNumber ); pin->SetNumber( wxString::Format( "%i", pincount ) ); - aPart->AddDrawItem( pin.release() ); + aSymbol->AddDrawItem( pin.release() ); } } else if( nodeName == "polygon" ) { - aPart->AddDrawItem( loadSymbolPolyLine( aPart, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) ); } else if( nodeName == "rectangle" ) { - aPart->AddDrawItem( loadSymbolRectangle( aPart, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) ); } else if( nodeName == "text" ) { - std::unique_ptr libtext( loadSymbolText( aPart, currentNode, aGateNumber ) ); + std::unique_ptr libtext( loadSymbolText( aSymbol, currentNode, aGateNumber ) ); if( libtext->GetText().Upper() == ">NAME" ) { - LIB_FIELD* field = aPart->GetFieldById( REFERENCE_FIELD ); + LIB_FIELD* field = aSymbol->GetFieldById( REFERENCE_FIELD ); loadFieldAttributes( field, libtext.get() ); foundName = true; } else if( libtext->GetText().Upper() == ">VALUE" ) { - LIB_FIELD* field = aPart->GetFieldById( VALUE_FIELD ); + LIB_FIELD* field = aSymbol->GetFieldById( VALUE_FIELD ); loadFieldAttributes( field, libtext.get() ); foundValue = true; } else { - aPart->AddDrawItem( libtext.release() ); + aSymbol->AddDrawItem( libtext.release() ); } } else if( nodeName == "wire" ) { - aPart->AddDrawItem( loadSymbolWire( aPart, currentNode, aGateNumber ) ); + aSymbol->AddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) ); } else if( nodeName == "frame" ) { @@ -1588,8 +1588,8 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrSetParent( aPart.get() ); - aPart->AddDrawItem( item ); + item->SetParent( aSymbol.get() ); + aSymbol->AddDrawItem( item ); } } @@ -1606,22 +1606,22 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrGetFieldById( REFERENCE_FIELD )->SetVisible( false ); + aSymbol->GetFieldById( REFERENCE_FIELD )->SetVisible( false ); if( foundValue == false ) - aPart->GetFieldById( VALUE_FIELD )->SetVisible( false ); + aSymbol->GetFieldById( VALUE_FIELD )->SetVisible( false ); return pincount == 1 ? ispower : false; } LIB_CIRCLE* SCH_EAGLE_PLUGIN::loadSymbolCircle( - std::unique_ptr& aPart, wxXmlNode* aCircleNode, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aCircleNode, int aGateNumber ) { // Parse the circle properties ECIRCLE c( aCircleNode ); - unique_ptr circle( new LIB_CIRCLE( aPart.get() ) ); + unique_ptr circle( new LIB_CIRCLE( aSymbol.get() ) ); circle->SetPosition( wxPoint( c.x.ToSchUnits(), c.y.ToSchUnits() ) ); circle->SetRadius( c.radius.ToSchUnits() ); @@ -1633,11 +1633,11 @@ LIB_CIRCLE* SCH_EAGLE_PLUGIN::loadSymbolCircle( LIB_RECTANGLE* SCH_EAGLE_PLUGIN::loadSymbolRectangle( - std::unique_ptr& aPart, wxXmlNode* aRectNode, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aRectNode, int aGateNumber ) { ERECT rect( aRectNode ); - unique_ptr rectangle( new LIB_RECTANGLE( aPart.get() ) ); + unique_ptr rectangle( new LIB_RECTANGLE( aSymbol.get() ) ); rectangle->SetPosition( wxPoint( rect.x1.ToSchUnits(), rect.y1.ToSchUnits() ) ); rectangle->SetEnd( wxPoint( rect.x2.ToSchUnits(), rect.y2.ToSchUnits() ) ); @@ -1652,7 +1652,7 @@ LIB_RECTANGLE* SCH_EAGLE_PLUGIN::loadSymbolRectangle( LIB_ITEM* SCH_EAGLE_PLUGIN::loadSymbolWire( - std::unique_ptr& aPart, wxXmlNode* aWireNode, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aWireNode, int aGateNumber ) { auto ewire = EWIRE( aWireNode ); @@ -1669,7 +1669,7 @@ LIB_ITEM* SCH_EAGLE_PLUGIN::loadSymbolWire( // if the wire is an arc if( ewire.curve ) { - std::unique_ptr arc = std::make_unique( aPart.get() ); + std::unique_ptr arc = std::make_unique( aSymbol.get() ); wxPoint center = ConvertArcCenter( begin, end, *ewire.curve * -1 ); double radius = sqrt( abs( ( ( center.x - begin.x ) * ( center.x - begin.x ) ) @@ -1724,7 +1724,7 @@ LIB_ITEM* SCH_EAGLE_PLUGIN::loadSymbolWire( } else { - std::unique_ptr polyLine = std::make_unique( aPart.get() ); + std::unique_ptr polyLine = std::make_unique( aSymbol.get() ); polyLine->AddPoint( begin ); polyLine->AddPoint( end ); @@ -1737,9 +1737,9 @@ LIB_ITEM* SCH_EAGLE_PLUGIN::loadSymbolWire( LIB_POLYLINE* SCH_EAGLE_PLUGIN::loadSymbolPolyLine( - std::unique_ptr& aPart, wxXmlNode* aPolygonNode, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aPolygonNode, int aGateNumber ) { - std::unique_ptr polyLine = std::make_unique( aPart.get() ); + std::unique_ptr polyLine = std::make_unique( aSymbol.get() ); EPOLYGON epoly( aPolygonNode ); wxXmlNode* vertex = aPolygonNode->GetChildren(); @@ -1765,9 +1765,9 @@ LIB_POLYLINE* SCH_EAGLE_PLUGIN::loadSymbolPolyLine( LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( - std::unique_ptr& aPart, wxXmlNode* aPin, EPIN* aEPin, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aPin, EPIN* aEPin, int aGateNumber ) { - std::unique_ptr pin = std::make_unique( aPart.get() ); + std::unique_ptr pin = std::make_unique( aSymbol.get() ); pin->SetPosition( wxPoint( aEPin->x.ToSchUnits(), aEPin->y.ToSchUnits() ) ); pin->SetName( aEPin->name ); pin->SetUnit( aGateNumber ); @@ -1862,9 +1862,9 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( - std::unique_ptr& aPart, wxXmlNode* aLibText, int aGateNumber ) + std::unique_ptr& aSymbol, wxXmlNode* aLibText, int aGateNumber ) { - std::unique_ptr libtext = std::make_unique( aPart.get() ); + std::unique_ptr libtext = std::make_unique( aSymbol.get() ); ETEXT etext( aLibText ); libtext->SetUnit( aGateNumber ); diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.h b/eeschema/sch_plugins/eagle/sch_eagle_plugin.h index c393e6ee0d..76d7a9d202 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.h +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.h @@ -49,7 +49,7 @@ class SCH_SYMBOL; class SCH_FIELD; class PROPERTIES; class SCH_EAGLE_PLUGIN_CACHE; -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class LIB_CIRCLE; class LIB_FIELD; @@ -63,7 +63,7 @@ class wxXmlNode; typedef struct EAGLE_LIBRARY { wxString name; - boost::ptr_map KiCadSymbols; + boost::ptr_map KiCadSymbols; std::unordered_map SymbolNodes; std::unordered_map GateUnit; std::unordered_map package; @@ -130,19 +130,19 @@ private: SCH_TEXT* loadPlainText( wxXmlNode* aSchText ); void loadFrame( wxXmlNode* aFrameNode, std::vector& aLines ); - bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aPart, + bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr& aSymbol, EDEVICE* aDevice, int aGateNumber, const wxString& aGateName ); - LIB_CIRCLE* loadSymbolCircle( std::unique_ptr& aPart, wxXmlNode* aCircleNode, + LIB_CIRCLE* loadSymbolCircle( std::unique_ptr& aSymbol, wxXmlNode* aCircleNode, int aGateNumber ); - LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr& aPart, wxXmlNode* aRectNode, + LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr& aSymbol, wxXmlNode* aRectNode, int aGateNumber ); - LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr& aPart, wxXmlNode* aPolygonNode, - int aGateNumber ); - LIB_ITEM* loadSymbolWire( std::unique_ptr& aPart, wxXmlNode* aWireNode, + LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr& aSymbol, + wxXmlNode* aPolygonNode, int aGateNumber ); + LIB_ITEM* loadSymbolWire( std::unique_ptr& aSymbol, wxXmlNode* aWireNode, int aGateNumber ); - LIB_PIN* loadPin( std::unique_ptr& aPart, wxXmlNode*, EPIN* epin, + LIB_PIN* loadPin( std::unique_ptr& aSymbol, wxXmlNode*, EPIN* epin, int aGateNumber ); - LIB_TEXT* loadSymbolText( std::unique_ptr& aPart, wxXmlNode* aLibText, + LIB_TEXT* loadSymbolText( std::unique_ptr& aSymbol, wxXmlNode* aLibText, int aGateNumber ); void loadFrame( wxXmlNode* aFrameNode, std::vector& aLines ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 02b76c7b6d..46b956e985 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -91,7 +91,7 @@ bool SCH_SEXPR_PARSER::IsTooRecent() const } -void SCH_SEXPR_PARSER::ParseLib( LIB_PART_MAP& aSymbolLibMap ) +void SCH_SEXPR_PARSER::ParseLib( LIB_SYMBOL_MAP& aSymbolLibMap ) { T token; @@ -110,7 +110,7 @@ void SCH_SEXPR_PARSER::ParseLib( LIB_PART_MAP& aSymbolLibMap ) { m_unit = 1; m_convert = 1; - LIB_PART* symbol = ParseSymbol( aSymbolLibMap, m_requiredVersion ); + LIB_SYMBOL* symbol = ParseSymbol( aSymbolLibMap, m_requiredVersion ); aSymbolLibMap[symbol->GetName()] = symbol; } else @@ -121,7 +121,7 @@ void SCH_SEXPR_PARSER::ParseLib( LIB_PART_MAP& aSymbolLibMap ) } -LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileVersion ) +LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aFileVersion ) { wxCHECK_MSG( CurTok() == T_symbol, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a symbol." ) ); @@ -132,7 +132,7 @@ LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileV wxString error; LIB_ITEM* item; LIB_FIELD* field; - std::unique_ptr symbol = std::make_unique( wxEmptyString ); + std::unique_ptr symbol = std::make_unique( wxEmptyString ); std::set fieldIDsRead; m_requiredVersion = aFileVersion; @@ -717,7 +717,7 @@ void SCH_SEXPR_PARSER::parseHeader( TSCHEMATIC_T::T aHeaderType, int aFileVersio } -void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr& aSymbol ) +void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr& aSymbol ) { wxCHECK_RET( CurTok() == T_pin_names, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + @@ -755,7 +755,7 @@ void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr& aSymbol ) } -LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol ) +LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol ) { wxCHECK_MSG( CurTok() == T_property, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a property." ) ); @@ -764,7 +764,8 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol ) wxString error; wxString name; wxString value; - std::unique_ptr field = std::make_unique( aSymbol.get(), MANDATORY_FIELDS ); + std::unique_ptr field = std::make_unique( aSymbol.get(), + MANDATORY_FIELDS ); T token = NextTok(); @@ -2134,7 +2135,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, case T_lib_symbols: { // Dummy map. No derived symbols are allowed in the library cache. - LIB_PART_MAP symbolLibMap; + LIB_SYMBOL_MAP symbolLibMap; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.h b/eeschema/sch_plugins/kicad/sch_sexpr_parser.h index e57482b796..04c498fb0b 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.h @@ -154,9 +154,9 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER void parseFill( FILL_PARAMS& aFill ); void parseEDA_TEXT( EDA_TEXT* aText ); - void parsePinNames( std::unique_ptr& aSymbol ); + void parsePinNames( std::unique_ptr& aSymbol ); - LIB_FIELD* parseProperty( std::unique_ptr& aSymbol ); + LIB_FIELD* parseProperty( std::unique_ptr& aSymbol ); LIB_ARC* parseArc(); LIB_BEZIER* parseBezier(); @@ -186,10 +186,10 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER public: SCH_SEXPR_PARSER( LINE_READER* aLineReader = nullptr ); - void ParseLib( LIB_PART_MAP& aSymbolLibMap ); + void ParseLib( LIB_SYMBOL_MAP& aSymbolLibMap ); - LIB_PART* ParseSymbol( LIB_PART_MAP& aSymbolLibMap, - int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION ); + LIB_SYMBOL* ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, + int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION ); LIB_ITEM* ParseDrawItem(); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 01b7a998ad..2f75e4959c 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -284,7 +284,7 @@ static void formatStroke( OUTPUTFORMATTER* aFormatter, int aNestLevel, /** - * A cache assistant for the part library portion of the #SCH_PLUGIN API, and only for the + * A cache assistant for the symbol library portion of the #SCH_PLUGIN API, and only for the * #SCH_SEXPR_PLUGIN, so therefore is private to this implementation file, i.e. not placed * into a header. */ @@ -295,13 +295,13 @@ class SCH_SEXPR_PLUGIN_CACHE wxString m_fileName; // Absolute path and file name. wxFileName m_libFileName; // Absolute path and file name is required here. wxDateTime m_fileModTime; - LIB_PART_MAP m_symbols; // Map of names of #LIB_PART pointers. + LIB_SYMBOL_MAP m_symbols; // Map of names of #LIB_SYMBOL pointers. bool m_isWritable; bool m_isModified; int m_versionMajor; SCH_LIB_TYPE m_libType; // Is this cache a symbol or symbol library. - LIB_PART* removeSymbol( LIB_PART* aAlias ); + LIB_SYMBOL* removeSymbol( LIB_SYMBOL* aAlias ); static void saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter, int aNestLevel ); @@ -319,7 +319,7 @@ class SCH_SEXPR_PLUGIN_CACHE int aNestLevel = 0 ); static void saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); - static void saveDcmInfoAsFields( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, + static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, int& aNextFreeFieldId, int aNestLevel ); friend SCH_SEXPR_PLUGIN; @@ -339,7 +339,7 @@ public: void Load(); - void AddSymbol( const LIB_PART* aPart ); + void AddSymbol( const LIB_SYMBOL* aSymbol ); void DeleteSymbol( const wxString& aName ); @@ -360,7 +360,7 @@ public: wxString GetFileName() const { return m_libFileName.GetFullPath(); } - static void SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, + static void SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0, const wxString& aLibName = wxEmptyString ); }; @@ -732,7 +732,7 @@ void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelect size_t i; SCH_ITEM* item; - std::map libSymbols; + std::map libSymbols; SCH_SCREEN* screen = aSelection->GetScreen(); for( i = 0; i < aSelection->GetSize(); ++i ) @@ -871,11 +871,11 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa static wxString delimiters( wxT( " " ) ); - wxString part_name = aSymbol->GetLibId().Format(); + wxString symbol_name = aSymbol->GetLibId().Format(); - if( part_name.size() ) + if( symbol_name.size() ) { - libName = toUTFTildaText( part_name ); + libName = toUTFTildaText( symbol_name ); } else { @@ -1369,7 +1369,7 @@ SCH_SEXPR_PLUGIN_CACHE::SCH_SEXPR_PLUGIN_CACHE( const wxString& aFullPathAndFile SCH_SEXPR_PLUGIN_CACHE::~SCH_SEXPR_PLUGIN_CACHE() { // When the cache is destroyed, all of the alias objects on the heap should be deleted. - for( LIB_PART_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it ) delete it->second; m_symbols.clear(); @@ -1414,30 +1414,30 @@ bool SCH_SEXPR_PLUGIN_CACHE::IsFileChanged() const } -LIB_PART* SCH_SEXPR_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) +LIB_SYMBOL* SCH_SEXPR_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) { - wxCHECK_MSG( aPart != NULL, NULL, "NULL pointer cannot be removed from library." ); + wxCHECK_MSG( aSymbol != NULL, NULL, "NULL pointer cannot be removed from library." ); - LIB_PART* firstChild = NULL; - LIB_PART_MAP::iterator it = m_symbols.find( aPart->GetName() ); + LIB_SYMBOL* firstChild = NULL; + LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbol->GetName() ); if( it == m_symbols.end() ) return NULL; // If the entry pointer doesn't match the name it is mapped to in the library, we // have done something terribly wrong. - wxCHECK_MSG( *it->second == aPart, NULL, - "Pointer mismatch while attempting to remove alias entry <" + aPart->GetName() + + wxCHECK_MSG( *it->second == aSymbol, NULL, + "Pointer mismatch while attempting to remove alias entry <" + aSymbol->GetName() + "> from library cache <" + m_libFileName.GetName() + ">." ); // If the symbol is a root symbol used by other symbols find the first alias that uses - // the root part and make it the new root. - if( aPart->IsRoot() ) + // the root symbol and make it the new root. + if( aSymbol->IsRoot() ) { for( auto entry : m_symbols ) { if( entry.second->IsAlias() - && entry.second->GetParent().lock() == aPart->SharedPtr() ) + && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) { firstChild = entry.second; break; @@ -1446,7 +1446,7 @@ LIB_PART* SCH_SEXPR_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) if( firstChild ) { - for( LIB_ITEM& drawItem : aPart->GetDrawItems() ) + for( LIB_ITEM& drawItem : aSymbol->GetDrawItems() ) { if( drawItem.Type() == LIB_FIELD_T ) { @@ -1465,32 +1465,32 @@ LIB_PART* SCH_SEXPR_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) for( auto entry : m_symbols ) { if( entry.second->IsAlias() - && entry.second->GetParent().lock() == aPart->SharedPtr() ) + && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) entry.second->SetParent( firstChild ); } } } m_symbols.erase( it ); - delete aPart; + delete aSymbol; m_isModified = true; ++m_modHash; return firstChild; } -void SCH_SEXPR_PLUGIN_CACHE::AddSymbol( const LIB_PART* aPart ) +void SCH_SEXPR_PLUGIN_CACHE::AddSymbol( const LIB_SYMBOL* aSymbol ) { - // aPart is cloned in PART_LIB::AddPart(). The cache takes ownership of aPart. - wxString name = aPart->GetName(); - LIB_PART_MAP::iterator it = m_symbols.find( name ); + // aSymbol is cloned in PART_LIB::AddPart(). The cache takes ownership of aSymbol. + wxString name = aSymbol->GetName(); + LIB_SYMBOL_MAP::iterator it = m_symbols.find( name ); if( it != m_symbols.end() ) { removeSymbol( it->second ); } - m_symbols[ name ] = const_cast< LIB_PART* >( aPart ); + m_symbols[ name ] = const_cast< LIB_SYMBOL* >( aSymbol ); m_isModified = true; ++m_modHash; } @@ -1557,7 +1557,7 @@ void SCH_SEXPR_PLUGIN_CACHE::Save() if( !alias.second->IsAlias() ) continue; - std::shared_ptr aliasParent = alias.second->GetParent().lock(); + std::shared_ptr aliasParent = alias.second->GetParent().lock(); if( aliasParent.get() != parent.second ) continue; @@ -1576,10 +1576,10 @@ void SCH_SEXPR_PLUGIN_CACHE::Save() } -void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, +void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, int aNestLevel, const wxString& aLibName ) { - wxCHECK_RET( aSymbol, "Invalid LIB_PART pointer." ); + wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." ); // The current locale must use period as the decimal point. wxCHECK2( wxLocale::GetInfo( wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER ) == ".", @@ -1683,7 +1683,7 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFo } else { - std::shared_ptr parent = aSymbol->GetParent().lock(); + std::shared_ptr parent = aSymbol->GetParent().lock(); wxASSERT( parent ); @@ -1703,10 +1703,10 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFo } -void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, +void SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, int& aNextFreeFieldId, int aNestLevel ) { - wxCHECK_RET( aSymbol, "Invalid LIB_PART pointer." ); + wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." ); if( !aSymbol->GetKeyWords().IsEmpty() ) { @@ -2057,26 +2057,27 @@ void SCH_SEXPR_PLUGIN_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormat void SCH_SEXPR_PLUGIN_CACHE::DeleteSymbol( const wxString& aSymbolName ) { - LIB_PART_MAP::iterator it = m_symbols.find( aSymbolName ); + LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName ); if( it == m_symbols.end() ) THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ), m_libFileName.GetFullName(), aSymbolName ) ); - LIB_PART* part = it->second; + LIB_SYMBOL* symbol = it->second; - if( part->IsRoot() ) + if( symbol->IsRoot() ) { - LIB_PART* rootPart = part; + LIB_SYMBOL* rootSymbol = symbol; // Remove the root symbol and all it's children. m_symbols.erase( it ); - LIB_PART_MAP::iterator it1 = m_symbols.begin(); + LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin(); while( it1 != m_symbols.end() ) { - if( it1->second->IsAlias() && it1->second->GetParent().lock() == rootPart->SharedPtr() ) + if( it1->second->IsAlias() + && it1->second->GetParent().lock() == rootSymbol->SharedPtr() ) { delete it1->second; it1 = m_symbols.erase( it1 ); @@ -2087,13 +2088,13 @@ void SCH_SEXPR_PLUGIN_CACHE::DeleteSymbol( const wxString& aSymbolName ) } } - delete rootPart; + delete rootSymbol; } else { // Just remove the alias. m_symbols.erase( it ); - delete part; + delete symbol; } ++m_modHash; @@ -2147,9 +2148,9 @@ void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( wxArrayString& aSymbolNameList, cacheLib( aLibraryPath, aProperties ); - const LIB_PART_MAP& symbols = m_cache->m_symbols; + const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols; - for( LIB_PART_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { if( !powerSymbolsOnly || it->second->IsPower() ) aSymbolNameList.Add( it->first ); @@ -2157,7 +2158,7 @@ void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( wxArrayString& aSymbolNameList, } -void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, +void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, const wxString& aLibraryPath, const PROPERTIES* aProperties ) { @@ -2168,9 +2169,9 @@ void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, cacheLib( aLibraryPath, aProperties ); - const LIB_PART_MAP& symbols = m_cache->m_symbols; + const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols; - for( LIB_PART_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { if( !powerSymbolsOnly || it->second->IsPower() ) aSymbolList.push_back( it->second ); @@ -2178,14 +2179,14 @@ void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, } -LIB_PART* SCH_SEXPR_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, - const PROPERTIES* aProperties ) +LIB_SYMBOL* SCH_SEXPR_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, + const PROPERTIES* aProperties ) { LOCALE_IO toggle; // toggles on, then off, the C locale. cacheLib( aLibraryPath, aProperties ); - LIB_PART_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName ); + LIB_SYMBOL_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName ); if( it == m_cache->m_symbols.end() ) return nullptr; @@ -2194,7 +2195,7 @@ LIB_PART* SCH_SEXPR_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxSt } -void SCH_SEXPR_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, +void SCH_SEXPR_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties ) { LOCALE_IO toggle; // toggles on, then off, the C locale. @@ -2310,10 +2311,10 @@ bool SCH_SEXPR_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath ) } -LIB_PART* SCH_SEXPR_PLUGIN::ParsePart( LINE_READER& aReader, int aFileVersion ) +LIB_SYMBOL* SCH_SEXPR_PLUGIN::ParsePart( LINE_READER& aReader, int aFileVersion ) { LOCALE_IO toggle; // toggles on, then off, the C locale. - LIB_PART_MAP map; + LIB_SYMBOL_MAP map; SCH_SEXPR_PARSER parser( &aReader ); parser.NeedLEFT(); @@ -2323,11 +2324,11 @@ LIB_PART* SCH_SEXPR_PLUGIN::ParsePart( LINE_READER& aReader, int aFileVersion ) } -void SCH_SEXPR_PLUGIN::FormatPart( LIB_PART* part, OUTPUTFORMATTER & formatter ) +void SCH_SEXPR_PLUGIN::FormatPart( LIB_SYMBOL* symbol, OUTPUTFORMATTER & formatter ) { LOCALE_IO toggle; // toggles on, then off, the C locale. - SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( part, formatter ); + SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( symbol, formatter ); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h index fbe85becfa..cc1d54062e 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h @@ -47,7 +47,7 @@ struct SYMBOL_INSTANCE_REFERENCE; class PROPERTIES; class EE_SELECTION; class SCH_SEXPR_PLUGIN_CACHE; -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class BUS_ALIAS; @@ -106,12 +106,12 @@ public: void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath, const PROPERTIES* aProperties = nullptr ) override; - void EnumerateSymbolLib( std::vector& aSymbolList, - const wxString& aLibraryPath, - const PROPERTIES* aProperties = nullptr ) override; - LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, - const PROPERTIES* aProperties = nullptr ) override; - void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + void EnumerateSymbolLib( std::vector& aSymbolList, + const wxString& aLibraryPath, + const PROPERTIES* aProperties = nullptr ) override; + LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + const PROPERTIES* aProperties = nullptr ) override; + void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties = nullptr ) override; void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, const PROPERTIES* aProperties = nullptr ) override; @@ -127,9 +127,9 @@ public: const wxString& GetError() const override { return m_error; } - static LIB_PART* ParsePart( LINE_READER& aReader, - int aVersion = SEXPR_SCHEMATIC_FILE_VERSION ); - static void FormatPart( LIB_PART* aPart, OUTPUTFORMATTER& aFormatter ); + static LIB_SYMBOL* ParsePart( LINE_READER& aReader, + int aVersion = SEXPR_SCHEMATIC_FILE_VERSION ); + static void FormatPart( LIB_SYMBOL* aPart, OUTPUTFORMATTER& aFormatter ); private: void loadHierarchy( SCH_SHEET* aSheet ); diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index cab55606b0..a33a4d63fe 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -79,7 +79,7 @@ #define Mils2Iu( x ) Mils2iu( x ) -// Must be the first line of part library document (.dcm) files. +// Must be the first line of symbol library document (.dcm) files. #define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" #define SCH_PARSE_ERROR( text, reader, pos ) \ @@ -473,7 +473,7 @@ static void parseQuotedString( wxString& aString, LINE_READER& aReader, /** - * A cache assistant for the part library portion of the #SCH_PLUGIN API, and only for the + * A cache assistant for the symbol library portion of the #SCH_PLUGIN API, and only for the * #SCH_LEGACY_PLUGIN, so therefore is private to this implementation file, i.e. not placed * into a header. */ @@ -483,7 +483,7 @@ class SCH_LEGACY_PLUGIN_CACHE wxString m_fileName; // Absolute path and file name. wxFileName m_libFileName; // Absolute path and file name is required here. wxDateTime m_fileModTime; - LIB_PART_MAP m_symbols; // Map of names of #LIB_PART pointers. + LIB_SYMBOL_MAP m_symbols; // Map of names of #LIB_SYMBOL pointers. bool m_isWritable; bool m_isModified; int m_versionMajor; @@ -491,27 +491,29 @@ class SCH_LEGACY_PLUGIN_CACHE SCH_LIB_TYPE m_libType; // Is this cache a symbol or symbol library. void loadHeader( FILE_LINE_READER& aReader ); - static void loadAliases( std::unique_ptr& aPart, LINE_READER& aReader, - LIB_PART_MAP* aMap = nullptr ); - static void loadField( std::unique_ptr& aPart, LINE_READER& aReader ); - static void loadDrawEntries( std::unique_ptr& aPart, LINE_READER& aReader, + static void loadAliases( std::unique_ptr& aSymbol, LINE_READER& aReader, + LIB_SYMBOL_MAP* aMap = nullptr ); + static void loadField( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static void loadDrawEntries( std::unique_ptr& aSymbol, + LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); - static void loadFootprintFilters( std::unique_ptr& aPart, + static void loadFootprintFilters( std::unique_ptr& aSymbol, LINE_READER& aReader ); void loadDocs(); - static LIB_ARC* loadArc( std::unique_ptr& aPart, LINE_READER& aReader ); - static LIB_CIRCLE* loadCircle( std::unique_ptr& aPart, LINE_READER& aReader ); - static LIB_TEXT* loadText( std::unique_ptr& aPart, LINE_READER& aReader, + static LIB_ARC* loadArc( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static LIB_CIRCLE* loadCircle( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static LIB_TEXT* loadText( std::unique_ptr& aSymbol, LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); - static LIB_RECTANGLE* loadRectangle( std::unique_ptr& aPart, + static LIB_RECTANGLE* loadRectangle( std::unique_ptr& aSymbol, LINE_READER& aReader ); - static LIB_PIN* loadPin( std::unique_ptr& aPart, LINE_READER& aReader ); - static LIB_POLYLINE* loadPolyLine( std::unique_ptr& aPart, LINE_READER& aReader ); - static LIB_BEZIER* loadBezier( std::unique_ptr& aPart, LINE_READER& aReader ); + static LIB_PIN* loadPin( std::unique_ptr& aSymbol, LINE_READER& aReader ); + static LIB_POLYLINE* loadPolyLine( std::unique_ptr& aSymbol, + LINE_READER& aReader ); + static LIB_BEZIER* loadBezier( std::unique_ptr& aSymbol, LINE_READER& aReader ); static FILL_TYPE parseFillMode( LINE_READER& aReader, const char* aLine, - const char** aOutput ); - LIB_PART* removeSymbol( LIB_PART* aAlias ); + const char** aOutput ); + LIB_SYMBOL* removeSymbol( LIB_SYMBOL* aAlias ); void saveDocFile(); static void saveArc( LIB_ARC* aArc, OUTPUTFORMATTER& aFormatter ); @@ -552,7 +554,7 @@ public: void Load(); - void AddSymbol( const LIB_PART* aPart ); + void AddSymbol( const LIB_SYMBOL* aSymbol ); void DeleteSymbol( const wxString& aName ); @@ -573,10 +575,10 @@ public: wxString GetFileName() const { return m_libFileName.GetFullPath(); } - static LIB_PART* LoadPart( LINE_READER& aReader, int aMajorVersion, int aMinorVersion, - LIB_PART_MAP* aMap = nullptr ); - static void SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, - LIB_PART_MAP* aMap = nullptr ); + static LIB_SYMBOL* LoadPart( LINE_READER& aReader, int aMajorVersion, int aMinorVersion, + LIB_SYMBOL_MAP* aMap = nullptr ); + static void SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, + LIB_SYMBOL_MAP* aMap = nullptr ); }; @@ -2023,11 +2025,11 @@ void SCH_LEGACY_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol ) name1 = toUTFTildaText( aSymbol->GetField( REFERENCE_FIELD )->GetText() ); } - wxString part_name = aSymbol->GetLibId().Format(); + wxString symbol_name = aSymbol->GetLibId().Format(); - if( part_name.size() ) + if( symbol_name.size() ) { - name2 = toUTFTildaText( part_name ); + name2 = toUTFTildaText( symbol_name ); } else { @@ -2088,7 +2090,7 @@ void SCH_LEGACY_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol ) saveField( &aSymbol->GetFields()[i] ); // User defined fields: - // The *policy* about which user defined fields are part of a symbol is now + // The *policy* about which user defined fields are symbol of a symbol is now // only in the dialog editors. No policy should be enforced here, simply // save all the user defined fields, they are present because a dialog editor // thought they should be. If you disagree, go fix the dialog editors. @@ -2472,30 +2474,30 @@ bool SCH_LEGACY_PLUGIN_CACHE::IsFileChanged() const } -LIB_PART* SCH_LEGACY_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) +LIB_SYMBOL* SCH_LEGACY_PLUGIN_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) { - wxCHECK_MSG( aPart != NULL, NULL, "NULL pointer cannot be removed from library." ); + wxCHECK_MSG( aSymbol != NULL, NULL, "NULL pointer cannot be removed from library." ); - LIB_PART* firstChild = NULL; - LIB_PART_MAP::iterator it = m_symbols.find( aPart->GetName() ); + LIB_SYMBOL* firstChild = NULL; + LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbol->GetName() ); if( it == m_symbols.end() ) return NULL; // If the entry pointer doesn't match the name it is mapped to in the library, we // have done something terribly wrong. - wxCHECK_MSG( *it->second == aPart, NULL, - "Pointer mismatch while attempting to remove alias entry <" + aPart->GetName() + + wxCHECK_MSG( *it->second == aSymbol, NULL, + "Pointer mismatch while attempting to remove alias entry <" + aSymbol->GetName() + "> from library cache <" + m_libFileName.GetName() + ">." ); // If the symbol is a root symbol used by other symbols find the first alias that uses - // the root part and make it the new root. - if( aPart->IsRoot() ) + // the root symbol and make it the new root. + if( aSymbol->IsRoot() ) { for( auto entry : m_symbols ) { if( entry.second->IsAlias() - && entry.second->GetParent().lock() == aPart->SharedPtr() ) + && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) { firstChild = entry.second; break; @@ -2504,7 +2506,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) if( firstChild ) { - for( LIB_ITEM& drawItem : aPart->GetDrawItems() ) + for( LIB_ITEM& drawItem : aSymbol->GetDrawItems() ) { if( drawItem.Type() == LIB_FIELD_T ) { @@ -2523,32 +2525,32 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::removeSymbol( LIB_PART* aPart ) for( auto entry : m_symbols ) { if( entry.second->IsAlias() - && entry.second->GetParent().lock() == aPart->SharedPtr() ) + && entry.second->GetParent().lock() == aSymbol->SharedPtr() ) entry.second->SetParent( firstChild ); } } } m_symbols.erase( it ); - delete aPart; + delete aSymbol; m_isModified = true; SCH_LEGACY_PLUGIN_CACHE::IncrementModifyHash(); return firstChild; } -void SCH_LEGACY_PLUGIN_CACHE::AddSymbol( const LIB_PART* aPart ) +void SCH_LEGACY_PLUGIN_CACHE::AddSymbol( const LIB_SYMBOL* aSymbol ) { - // aPart is cloned in PART_LIB::AddPart(). The cache takes ownership of aPart. - wxString name = aPart->GetName(); - LIB_PART_MAP::iterator it = m_symbols.find( name ); + // aSymbol is cloned in PART_LIB::AddPart(). The cache takes ownership of aSymbol. + wxString name = aSymbol->GetName(); + LIB_SYMBOL_MAP::iterator it = m_symbols.find( name ); if( it != m_symbols.end() ) { removeSymbol( it->second ); } - m_symbols[ name ] = const_cast< LIB_PART* >( aPart ); + m_symbols[ name ] = const_cast< LIB_SYMBOL* >( aSymbol ); m_isModified = true; SCH_LEGACY_PLUGIN_CACHE::IncrementModifyHash(); } @@ -2623,10 +2625,10 @@ void SCH_LEGACY_PLUGIN_CACHE::Load() if( strCompare( "DEF", line ) ) { - // Read one DEF/ENDDEF part entry from library: - LIB_PART* part = LoadPart( reader, m_versionMajor, m_versionMinor, &m_symbols ); + // Read one DEF/ENDDEF symbol entry from library: + LIB_SYMBOL* symbol = LoadPart( reader, m_versionMajor, m_versionMinor, &m_symbols ); - m_symbols[ part->GetName() ] = part; + m_symbols[ symbol->GetName() ] = symbol; } } @@ -2648,7 +2650,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDocs() wxString text; wxString aliasName; wxFileName fn = m_libFileName; - LIB_PART* symbol = NULL;; + LIB_SYMBOL* symbol = NULL;; fn.SetExt( DOC_EXT ); @@ -2685,7 +2687,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDocs() aliasName.Trim(); aliasName = LIB_ID::FixIllegalChars( aliasName ); - LIB_PART_MAP::iterator it = m_symbols.find( aliasName ); + LIB_SYMBOL_MAP::iterator it = m_symbols.find( aliasName ); if( it == m_symbols.end() ) wxLogWarning( "Symbol '%s' not found in library:\n\n" @@ -2765,8 +2767,8 @@ void SCH_LEGACY_PLUGIN_CACHE::loadHeader( FILE_LINE_READER& aReader ) } -LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVersion, - int aMinorVersion, LIB_PART_MAP* aMap ) +LIB_SYMBOL* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVersion, + int aMinorVersion, LIB_SYMBOL_MAP* aMap ) { const char* line = aReader.Line(); @@ -2785,7 +2787,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer SCH_PARSE_ERROR( "invalid symbol definition", aReader, line ); // Read DEF line: - std::unique_ptr part = std::make_unique( wxEmptyString ); + std::unique_ptr symbol = std::make_unique( wxEmptyString ); wxString name, prefix, tmp; @@ -2805,7 +2807,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer aReader.LineNumber(), pos ); pos += tmp.size() + 1; - part->SetPinNameOffset( Mils2Iu( (int)num ) ); + symbol->SetPinNameOffset( Mils2Iu( (int)num ) ); tmp = tokens.GetNextToken(); // Show pin numbers. @@ -2814,7 +2816,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer aReader.LineNumber(), pos ); pos += tmp.size() + 1; - part->SetShowPinNumbers( ( tmp == "N" ) ? false : true ); + symbol->SetShowPinNumbers( ( tmp == "N" ) ? false : true ); tmp = tokens.GetNextToken(); // Show pin names. @@ -2823,7 +2825,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer aReader.LineNumber(), pos ); pos += tmp.size() + 1; - part->SetShowPinNames( ( tmp == "N" ) ? false : true ); + symbol->SetShowPinNames( ( tmp == "N" ) ? false : true ); tmp = tokens.GetNextToken(); // Number of units. @@ -2832,33 +2834,33 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer aReader.LineNumber(), pos ); pos += tmp.size() + 1; - part->SetUnitCount( (int)num ); + symbol->SetUnitCount( (int)num ); // Ensure m_unitCount is >= 1. Could be read as 0 in old libraries. - if( part->GetUnitCount() < 1 ) - part->SetUnitCount( 1 ); + if( symbol->GetUnitCount() < 1 ) + symbol->SetUnitCount( 1 ); - // Copy part name and prefix. + // Copy symbol name and prefix. // The root alias is added to the alias list by SetName() which is called by SetText(). if( name.IsEmpty() ) { - part->SetName( "~" ); + symbol->SetName( "~" ); } else if( name[0] != '~' ) { - part->SetName( name ); + symbol->SetName( name ); } else { - part->SetName( name.Right( name.Length() - 1 ) ); - part->GetValueField().SetVisible( false ); + symbol->SetName( name.Right( name.Length() - 1 ) ); + symbol->GetValueField().SetVisible( false ); } // Don't set the library alias, this is determined by the symbol library table. - part->SetLibId( LIB_ID( wxEmptyString, part->GetName() ) ); + symbol->SetLibId( LIB_ID( wxEmptyString, symbol->GetName() ) ); - LIB_FIELD& reference = part->GetReferenceField(); + LIB_FIELD& reference = symbol->GetReferenceField(); if( prefix == "~" ) { @@ -2885,9 +2887,9 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer tmp = tokens.GetNextToken(); if( tmp == "L" ) - part->LockUnits( true ); + symbol->LockUnits( true ); else if( tmp == "F" || tmp == "0" ) - part->LockUnits( false ); + symbol->LockUnits( false ); else THROW_PARSE_ERROR( "expected L, F, or 0", aReader.GetSource(), aReader.Line(), aReader.LineNumber(), pos ); @@ -2901,9 +2903,9 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer tmp = tokens.GetNextToken(); if( tmp == "P" ) - part->SetPower(); + symbol->SetPower(); else if( tmp == "N" ) - part->SetNormal(); + symbol->SetNormal(); else THROW_PARSE_ERROR( "expected P or N", aReader.GetSource(), aReader.Line(), aReader.LineNumber(), pos ); @@ -2919,16 +2921,16 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer else if( strCompare( "Ti", line, &line ) ) // Modification date is ignored. continue; else if( strCompare( "ALIAS", line, &line ) ) // Aliases - loadAliases( part, aReader, aMap ); + loadAliases( symbol, aReader, aMap ); else if( *line == 'F' ) // Fields - loadField( part, aReader ); + loadField( symbol, aReader ); else if( strCompare( "DRAW", line, &line ) ) // Drawing objects. - loadDrawEntries( part, aReader, aMajorVersion, aMinorVersion ); + loadDrawEntries( symbol, aReader, aMajorVersion, aMinorVersion ); else if( strCompare( "$FPLIST", line, &line ) ) // Footprint filter list - loadFootprintFilters( part, aReader ); - else if( strCompare( "ENDDEF", line, &line ) ) // End of part description + loadFootprintFilters( symbol, aReader ); + else if( strCompare( "ENDDEF", line, &line ) ) // End of symbol description { - return part.release(); + return symbol.release(); } line = aReader.ReadLine(); @@ -2938,9 +2940,9 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer } -void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr& aPart, - LINE_READER& aReader, - LIB_PART_MAP* aMap ) +void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr& aSymbol, + LINE_READER& aReader, + LIB_SYMBOL_MAP* aMap ) { wxString newAliasName; const char* line = aReader.Line(); @@ -2957,17 +2959,17 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr& aPart, if( aMap ) { - LIB_PART* newPart = new LIB_PART( newAliasName ); + LIB_SYMBOL* newSymbol = new LIB_SYMBOL( newAliasName ); // Inherit the parent mandatory field attributes. for( int id = 0; id < MANDATORY_FIELDS; ++id ) { - LIB_FIELD* field = newPart->GetFieldById( id ); + LIB_FIELD* field = newSymbol->GetFieldById( id ); // the MANDATORY_FIELDS are exactly that in RAM. wxASSERT( field ); - LIB_FIELD* parentField = aPart->GetFieldById( id ); + LIB_FIELD* parentField = aSymbol->GetFieldById( id ); wxASSERT( parentField ); @@ -2976,20 +2978,20 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr& aPart, if( id == VALUE_FIELD ) field->SetText( newAliasName ); - field->SetParent( newPart ); + field->SetParent( newSymbol ); } - newPart->SetParent( aPart.get() ); + newSymbol->SetParent( aSymbol.get() ); // This will prevent duplicate aliases. - (*aMap)[ newPart->GetName() ] = newPart; + (*aMap)[ newSymbol->GetName() ] = newSymbol; } } } -void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, - LINE_READER& aReader ) +void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); @@ -3005,7 +3007,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, if( id >= 0 && id < MANDATORY_FIELDS ) { - field = aPart->GetFieldById( id ); + field = aSymbol->GetFieldById( id ); // this will fire only if somebody broke a constructor or editor. // MANDATORY_FIELDS are always present in ram resident symbols, no @@ -3014,8 +3016,8 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, } else { - field = new LIB_FIELD( aPart.get(), id ); - aPart->AddDrawItem( field, false ); + field = new LIB_FIELD( aSymbol.get(), id ); + aSymbol->AddDrawItem( field, false ); } // Skip to the first double quote. @@ -3124,10 +3126,10 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, // Plus assumptions are made in the field editors. field->m_name = TEMPLATE_FIELDNAME::GetDefaultFieldName( id ); - // Ensure the VALUE field = the part name (can be not the case + // Ensure the VALUE field = the symbol name (can be not the case // with malformed libraries: edited by hand, or converted from other tools) if( id == VALUE_FIELD ) - field->SetText( aPart->GetName() ); + field->SetText( aSymbol->GetName() ); } else { @@ -3136,10 +3138,10 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, } -void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr& aPart, - LINE_READER& aReader, - int aMajorVersion, - int aMinorVersion ) +void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr& aSymbol, + LINE_READER& aReader, + int aMajorVersion, + int aMinorVersion ) { const char* line = aReader.Line(); @@ -3151,38 +3153,39 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr& aPart, { if( strCompare( "ENDDRAW", line, &line ) ) { - aPart->GetDrawItems().sort(); + aSymbol->GetDrawItems().sort(); return; } switch( line[0] ) { case 'A': // Arc - aPart->AddDrawItem( loadArc( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadArc( aSymbol, aReader ), false ); break; case 'C': // Circle - aPart->AddDrawItem( loadCircle( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadCircle( aSymbol, aReader ), false ); break; case 'T': // Text - aPart->AddDrawItem( loadText( aPart, aReader, aMajorVersion, aMinorVersion ), false ); + aSymbol->AddDrawItem( loadText( aSymbol, aReader, aMajorVersion, + aMinorVersion ), false ); break; case 'S': // Square - aPart->AddDrawItem( loadRectangle( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadRectangle( aSymbol, aReader ), false ); break; case 'X': // Pin Description - aPart->AddDrawItem( loadPin( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadPin( aSymbol, aReader ), false ); break; case 'P': // Polyline - aPart->AddDrawItem( loadPolyLine( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadPolyLine( aSymbol, aReader ), false ); break; case 'B': // Bezier Curves - aPart->AddDrawItem( loadBezier( aPart, aReader ), false ); + aSymbol->AddDrawItem( loadBezier( aSymbol, aReader ), false ); break; case '#': // Comment @@ -3218,14 +3221,14 @@ FILL_TYPE SCH_LEGACY_PLUGIN_CACHE::parseFillMode( LINE_READER& aReader, const ch } -LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "A", line, &line ), NULL, "Invalid LIB_ARC definition" ); - LIB_ARC* arc = new LIB_ARC( aPart.get() ); + LIB_ARC* arc = new LIB_ARC( aSymbol.get() ); wxPoint center; @@ -3284,14 +3287,14 @@ LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aPart, } -LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "C", line, &line ), NULL, "Invalid LIB_CIRCLE definition" ); - LIB_CIRCLE* circle = new LIB_CIRCLE( aPart.get() ); + LIB_CIRCLE* circle = new LIB_CIRCLE( aSymbol.get() ); wxPoint center; @@ -3311,16 +3314,16 @@ LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr& aPar } -LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aPart, - LINE_READER& aReader, - int aMajorVersion, - int aMinorVersion ) +LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aSymbol, + LINE_READER& aReader, + int aMajorVersion, + int aMinorVersion ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "T", line, &line ), NULL, "Invalid LIB_TEXT definition" ); - LIB_TEXT* text = new LIB_TEXT( aPart.get() ); + LIB_TEXT* text = new LIB_TEXT( aSymbol.get() ); text->SetTextAngle( (double) parseInt( aReader, line, &line ) ); @@ -3404,14 +3407,14 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aPart, } -LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "S", line, &line ), NULL, "Invalid LIB_RECTANGLE definition" ); - LIB_RECTANGLE* rectangle = new LIB_RECTANGLE( aPart.get() ); + LIB_RECTANGLE* rectangle = new LIB_RECTANGLE( aSymbol.get() ); wxPoint pos; @@ -3436,8 +3439,8 @@ LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr } -LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); @@ -3567,7 +3570,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, } - LIB_PIN* pin = new LIB_PIN( aPart.get(), name, number, orientation, pinType, length, + LIB_PIN* pin = new LIB_PIN( aSymbol.get(), name, number, orientation, pinType, length, nameTextSize, numberTextSize, convert, position, unit ); // Optional @@ -3626,14 +3629,14 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, } -LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "P", line, &line ), NULL, "Invalid LIB_POLYLINE definition" ); - LIB_POLYLINE* polyLine = new LIB_POLYLINE( aPart.get() ); + LIB_POLYLINE* polyLine = new LIB_POLYLINE( aSymbol.get() ); int points = parseInt( aReader, line, &line ); polyLine->SetUnit( parseInt( aReader, line, &line ) ); @@ -3657,14 +3660,14 @@ LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr& } -LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr& aPart, - LINE_READER& aReader ) +LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "B", line, &line ), NULL, "Invalid LIB_BEZIER definition" ); - LIB_BEZIER* bezier = new LIB_BEZIER( aPart.get() ); + LIB_BEZIER* bezier = new LIB_BEZIER( aSymbol.get() ); int points = parseInt( aReader, line, &line ); bezier->SetUnit( parseInt( aReader, line, &line ) ); @@ -3688,8 +3691,8 @@ LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr& aPar } -void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr& aPart, - LINE_READER& aReader ) +void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr& aSymbol, + LINE_READER& aReader ) { const char* line = aReader.Line(); @@ -3703,7 +3706,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr& a { if( strCompare( "$ENDFPLIST", line, &line ) ) { - aPart->SetFPFilters( footprintFilters ); + aSymbol->SetFPFilters( footprintFilters ); return; } @@ -3730,7 +3733,7 @@ void SCH_LEGACY_PLUGIN_CACHE::Save( bool aSaveDocFile ) formatter->Print( 0, "%s %d.%d\n", LIBFILE_IDENT, LIB_VERSION_MAJOR, LIB_VERSION_MINOR ); formatter->Print( 0, "#encoding utf-8\n"); - for( LIB_PART_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); it++ ) + for( LIB_SYMBOL_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); it++ ) { if( !it->second->IsRoot() ) continue; @@ -3749,10 +3752,10 @@ void SCH_LEGACY_PLUGIN_CACHE::Save( bool aSaveDocFile ) } -void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFormatter, - LIB_PART_MAP* aMap ) +void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, + LIB_SYMBOL_MAP* aMap ) { - wxCHECK_RET( aSymbol && aSymbol->IsRoot(), "Invalid LIB_PART pointer." ); + wxCHECK_RET( aSymbol && aSymbol->IsRoot(), "Invalid LIB_SYMBOL pointer." ); // LIB_ALIAS objects are deprecated but we still need to gather up the derived symbols // and save their names for the old file format. @@ -3762,10 +3765,10 @@ void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aF { for( auto entry : *aMap ) { - LIB_PART* part = entry.second; + LIB_SYMBOL* symbol = entry.second; - if( part->IsAlias() && part->GetParent().lock() == aSymbol->SharedPtr() ) - aliasNames.Add( part->GetName() ); + if( symbol->IsAlias() && symbol->GetParent().lock() == aSymbol->SharedPtr() ) + aliasNames.Add( symbol->GetName() ); } } @@ -3822,7 +3825,6 @@ void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aF // User defined fields: // may have their own save policy so there is a separate loop for them. - int fieldId = MANDATORY_FIELDS; // really wish this would go away. for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i ) @@ -4079,7 +4081,8 @@ void SCH_LEGACY_PLUGIN_CACHE::saveRectangle( LIB_RECTANGLE* aRectangle, Iu2Mils( aRectangle->GetPosition().y ), Iu2Mils( aRectangle->GetEnd().x ), Iu2Mils( aRectangle->GetEnd().y ), aRectangle->GetUnit(), aRectangle->GetConvert(), - Iu2Mils( aRectangle->GetWidth() ), fill_tab[static_cast( aRectangle->GetFillMode() )] ); + Iu2Mils( aRectangle->GetWidth() ), + fill_tab[static_cast( aRectangle->GetFillMode() )] ); } @@ -4130,7 +4133,7 @@ void SCH_LEGACY_PLUGIN_CACHE::saveDocFile() formatter.Print( 0, "%s\n", DOCFILE_IDENT ); - for( LIB_PART_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::iterator it = m_symbols.begin(); it != m_symbols.end(); ++it ) { wxString description = it->second->GetDescription(); wxString keyWords = it->second->GetKeyWords(); @@ -4159,26 +4162,27 @@ void SCH_LEGACY_PLUGIN_CACHE::saveDocFile() void SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol( const wxString& aSymbolName ) { - LIB_PART_MAP::iterator it = m_symbols.find( aSymbolName ); + LIB_SYMBOL_MAP::iterator it = m_symbols.find( aSymbolName ); if( it == m_symbols.end() ) THROW_IO_ERROR( wxString::Format( _( "library %s does not contain a symbol named %s" ), m_libFileName.GetFullName(), aSymbolName ) ); - LIB_PART* part = it->second; + LIB_SYMBOL* symbol = it->second; - if( part->IsRoot() ) + if( symbol->IsRoot() ) { - LIB_PART* rootPart = part; + LIB_SYMBOL* rootSymbol = symbol; // Remove the root symbol and all it's children. m_symbols.erase( it ); - LIB_PART_MAP::iterator it1 = m_symbols.begin(); + LIB_SYMBOL_MAP::iterator it1 = m_symbols.begin(); while( it1 != m_symbols.end() ) { - if( it1->second->IsAlias() && it1->second->GetParent().lock() == rootPart->SharedPtr() ) + if( it1->second->IsAlias() + && it1->second->GetParent().lock() == rootSymbol->SharedPtr() ) { delete it1->second; it1 = m_symbols.erase( it1 ); @@ -4189,13 +4193,13 @@ void SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol( const wxString& aSymbolName ) } } - delete rootPart; + delete rootSymbol; } else { // Just remove the alias. m_symbols.erase( it ); - delete part; + delete symbol; } SCH_LEGACY_PLUGIN_CACHE::IncrementModifyHash(); @@ -4260,9 +4264,9 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( wxArrayString& aSymbolNameList, cacheLib( aLibraryPath, aProperties ); - const LIB_PART_MAP& symbols = m_cache->m_symbols; + const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols; - for( LIB_PART_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { if( !powerSymbolsOnly || it->second->IsPower() ) aSymbolNameList.Add( it->first ); @@ -4270,7 +4274,7 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( wxArrayString& aSymbolNameList, } -void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, +void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, const wxString& aLibraryPath, const PROPERTIES* aProperties ) { @@ -4281,9 +4285,9 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, cacheLib( aLibraryPath, aProperties ); - const LIB_PART_MAP& symbols = m_cache->m_symbols; + const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols; - for( LIB_PART_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) + for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { if( !powerSymbolsOnly || it->second->IsPower() ) aSymbolList.push_back( it->second ); @@ -4291,14 +4295,15 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector& aSymbolList, } -LIB_PART* SCH_LEGACY_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, - const PROPERTIES* aProperties ) +LIB_SYMBOL* SCH_LEGACY_PLUGIN::LoadSymbol( const wxString& aLibraryPath, + const wxString& aSymbolName, + const PROPERTIES* aProperties ) { LOCALE_IO toggle; // toggles on, then off, the C locale. cacheLib( aLibraryPath, aProperties ); - LIB_PART_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName ); + LIB_SYMBOL_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName ); if( it == m_cache->m_symbols.end() ) return nullptr; @@ -4307,7 +4312,7 @@ LIB_PART* SCH_LEGACY_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxS } -void SCH_LEGACY_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, +void SCH_LEGACY_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties ) { LOCALE_IO toggle; // toggles on, then off, the C locale. @@ -4422,16 +4427,16 @@ bool SCH_LEGACY_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath ) } -LIB_PART* SCH_LEGACY_PLUGIN::ParsePart( LINE_READER& reader, int aMajorVersion, - int aMinorVersion ) +LIB_SYMBOL* SCH_LEGACY_PLUGIN::ParsePart( LINE_READER& reader, int aMajorVersion, + int aMinorVersion ) { return SCH_LEGACY_PLUGIN_CACHE::LoadPart( reader, aMajorVersion, aMinorVersion ); } -void SCH_LEGACY_PLUGIN::FormatPart( LIB_PART* part, OUTPUTFORMATTER & formatter ) +void SCH_LEGACY_PLUGIN::FormatPart( LIB_SYMBOL* symbol, OUTPUTFORMATTER & formatter ) { - SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( part, formatter ); + SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( symbol, formatter ); } diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.h b/eeschema/sch_plugins/legacy/sch_legacy_plugin.h index d66eadf23b..f0b2e80bd4 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.h +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.h @@ -44,7 +44,7 @@ class SCH_FIELD; class PROPERTIES; class SELECTION; class SCH_LEGACY_PLUGIN_CACHE; -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class BUS_ALIAS; @@ -114,12 +114,12 @@ public: void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath, const PROPERTIES* aProperties = nullptr ) override; - void EnumerateSymbolLib( std::vector& aSymbolList, + void EnumerateSymbolLib( std::vector& aSymbolList, const wxString& aLibraryPath, const PROPERTIES* aProperties = nullptr ) override; - LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, + LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, const PROPERTIES* aProperties = nullptr ) override; - void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, + void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol, const PROPERTIES* aProperties = nullptr ) override; void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, const PROPERTIES* aProperties = nullptr ) override; @@ -135,8 +135,9 @@ public: const wxString& GetError() const override { return m_error; } - static LIB_PART* ParsePart( LINE_READER& aReader, int majorVersion = 0, int minorVersion = 0 ); - static void FormatPart( LIB_PART* aPart, OUTPUTFORMATTER& aFormatter ); + static LIB_SYMBOL* ParsePart( LINE_READER& aReader, int majorVersion = 0, + int minorVersion = 0 ); + static void FormatPart( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter ); private: void loadHierarchy( SCH_SHEET* aSheet ); diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index bc2e4c1760..98cbf17610 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -57,11 +57,11 @@ public: m_sheetNum = 0; } - SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_PART* aLibPart, const SCH_SHEET_PATH& aSheetPath ); + SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol, const SCH_SHEET_PATH& aSheetPath ); SCH_SYMBOL* GetSymbol() const { return m_rootSymbol; } - LIB_PART* GetLibPart() const { return m_libPart; } + LIB_SYMBOL* GetLibPart() const { return m_libPart; } const SCH_SHEET_PATH& GetSheetPath() const { return m_sheetPath; } @@ -107,7 +107,7 @@ public: wxString GetFullRef() { if( GetSymbol()->GetUnitCount() > 1 ) - return GetRef() + LIB_PART::SubReference( GetUnit() ); + return GetRef() + LIB_SYMBOL::SubReference( GetUnit() ); else return GetRef(); } @@ -170,7 +170,7 @@ private: /// Symbol reference prefix, without number (for IC1, this is IC) ) UTF8 m_ref; // it's private, use the accessors please SCH_SYMBOL* m_rootSymbol; ///< The symbol associated the reference object. - LIB_PART* m_libPart; ///< The source symbol from a library. + LIB_SYMBOL* m_libPart; ///< The source symbol from a library. wxPoint m_symbolPos; ///< The physical position of the symbol in schematic ///< used to annotate by X or Y position int m_unit; ///< The unit number for symbol with multiple parts diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 9ac1ba476b..bbd2517780 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -161,7 +161,7 @@ void SCH_SCREEN::Append( SCH_ITEM* aItem ) if( it == m_libSymbols.end() || !it->second ) { m_libSymbols[symbol->GetSchSymbolLibraryName()] = - new LIB_PART( *symbol->GetPartRef() ); + new LIB_SYMBOL( *symbol->GetPartRef() ); } else { @@ -169,7 +169,7 @@ void SCH_SCREEN::Append( SCH_ITEM* aItem ) // it was added to the schematic. If it has changed, then a new name // must be created for the library symbol list to prevent all of the // other schematic symbols referencing that library symbol from changing. - LIB_PART* foundSymbol = it->second; + LIB_SYMBOL* foundSymbol = it->second; foundSymbol->GetDrawItems().sort(); @@ -187,7 +187,7 @@ void SCH_SCREEN::Append( SCH_ITEM* aItem ) } symbol->SetSchSymbolLibraryName( newName ); - m_libSymbols[newName] = new LIB_PART( *symbol->GetPartRef() ); + m_libSymbols[newName] = new LIB_SYMBOL( *symbol->GetPartRef() ); } } } @@ -540,7 +540,7 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter ) wxCHECK_RET( Schematic(), "Cannot call SCH_SCREEN::UpdateSymbolLinks with no SCHEMATIC" ); wxString msg; - std::unique_ptr< LIB_PART > libSymbol; + std::unique_ptr< LIB_SYMBOL > libSymbol; std::vector symbols; SYMBOL_LIB_TABLE* libs = Schematic()->Prj().SchSymbolLibTable(); @@ -559,7 +559,7 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter ) for( auto symbol : symbols ) { - LIB_PART* tmp = nullptr; + LIB_SYMBOL* tmp = nullptr; libSymbol.reset(); // If the symbol is already in the internal library, map the symbol to it. @@ -578,7 +578,7 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter ) } // Internal library symbols are already flattened so just make a copy. - symbol->SetLibSymbol( new LIB_PART( *it->second ) ); + symbol->SetLibSymbol( new LIB_SYMBOL( *it->second ) ); continue; } @@ -658,7 +658,7 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter ) libSymbol->SetParent(); m_libSymbols.insert( { symbol->GetSchSymbolLibraryName(), - new LIB_PART( *libSymbol.get() ) } ); + new LIB_SYMBOL( *libSymbol.get() ) } ); if( aReporter ) { @@ -704,10 +704,10 @@ void SCH_SCREEN::UpdateLocalLibSymbolLinks() auto it = m_libSymbols.find( symbol->GetSchSymbolLibraryName() ); - LIB_PART* libSymbol = nullptr; + LIB_SYMBOL* libSymbol = nullptr; if( it != m_libSymbols.end() ) - libSymbol = new LIB_PART( *it->second ); + libSymbol = new LIB_SYMBOL( *it->second ); symbol->SetLibSymbol( libSymbol ); @@ -1048,7 +1048,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) const } -void SCH_SCREEN::AddLibSymbol( LIB_PART* aLibSymbol ) +void SCH_SCREEN::AddLibSymbol( LIB_SYMBOL* aLibSymbol ) { wxCHECK( aLibSymbol, /* void */ ); diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 5a4281450a..3b3e715c0a 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -53,7 +53,7 @@ class BUS_ALIAS; class EDA_ITEM; -class LIB_PART; +class LIB_SYMBOL; class LIB_PIN; class SCH_SYMBOL; class SCH_LINE; @@ -203,7 +203,7 @@ public: KICAD_T aType = SCH_LOCATE_ANY_T ) const; /** - * Initialize the #LIB_PART reference for each #SCH_SYMBOL found in this schematic + * Initialize the #LIB_SYMBOL reference for each #SCH_SYMBOL found in this schematic * from the project #SYMBOL_LIB_TABLE. * * Symbol library links are set using the symbol library table and will fall back to @@ -220,7 +220,7 @@ public: void UpdateSymbolLinks( REPORTER* aReporter = nullptr ); /** - * Initialize the #LIB_PART reference for each #SCH_SYMBOL found in this schematic + * Initialize the #LIB_SYMBOL reference for each #SCH_SYMBOL found in this schematic * with the local project library symbols. */ void UpdateLocalLibSymbolLinks(); @@ -410,13 +410,13 @@ public: SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 ) const; /** - * Fetch a list of unique #LIB_PART object pointers required to properly render each + * Fetch a list of unique #LIB_SYMBOL object pointers required to properly render each * #SCH_SYMBOL in this schematic. * - * @return The list of unique #LIB_PART object pointers. + * @return The list of unique #LIB_SYMBOL object pointers. */ - std::map& GetLibSymbols() { return m_libSymbols; } - const std::map& GetLibSymbols() const { return m_libSymbols; } + std::map& GetLibSymbols() { return m_libSymbols; } + const std::map& GetLibSymbols() const { return m_libSymbols; } /** * Add \a aLibSymbol to the library symbol map. @@ -425,9 +425,9 @@ public: * mapped, the existing symbol is replaced with \a aLibSymbol. The screen object takes * ownership of the pointer. * - * @param aLibSymbol A pointer the #LIB_PART to be added to the symbol map. + * @param aLibSymbol A pointer the #LIB_SYMBOL to be added to the symbol map. */ - void AddLibSymbol( LIB_PART* aLibSymbol ); + void AddLibSymbol( LIB_SYMBOL* aLibSymbol ); /** * Add a bus alias definition (and transfers ownership of the pointer). @@ -510,7 +510,7 @@ private: std::unordered_set< std::shared_ptr< BUS_ALIAS > > m_aliases; /// Library symbols required for this schematic. - std::map m_libSymbols; + std::map m_libSymbols; /** * The list of symbol instances loaded from the schematic file. @@ -601,7 +601,7 @@ public: void DeleteMarker( SCH_MARKER* aMarker ); /** - * Initialize the #LIB_PART reference for each #SCH_SYMBOL found in the full schematic. + * Initialize the #LIB_SYMBOL reference for each #SCH_SYMBOL found in the full schematic. * * @note This should only be called when the user specifically requests all library symbol * links to be update or when the legacy schematic is opened for the last time. All diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index b764325719..6e67e03bf8 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -317,11 +317,11 @@ void SCH_SHEET_PATH::AppendSymbol( SCH_REFERENCE_LIST& aReferences, SCH_SYMBOL* // affects power symbols. if( aIncludePowerSymbols || aSymbol->GetRef( this )[0] != wxT( '#' ) ) { - LIB_PART* part = aSymbol->GetPartRef().get(); + LIB_SYMBOL* symbol = aSymbol->GetPartRef().get(); - if( part || aForceIncludeOrphanSymbols ) + if( symbol || aForceIncludeOrphanSymbols ) { - SCH_REFERENCE schReference( aSymbol, part, *this ); + SCH_REFERENCE schReference( aSymbol, symbol, *this ); schReference.SetSheetNumber( m_virtualPageNumber ); aReferences.AddItem( schReference ); @@ -350,11 +350,11 @@ void SCH_SHEET_PATH::AppendMultiUnitSymbol( SCH_MULTI_UNIT_REFERENCE_MAP& aRefLi if( !aIncludePowerSymbols && aSymbol->GetRef( this )[0] == wxT( '#' ) ) return; - LIB_PART* part = aSymbol->GetPartRef().get(); + LIB_SYMBOL* symbol = aSymbol->GetPartRef().get(); - if( part && part->GetUnitCount() > 1 ) + if( symbol && symbol->GetUnitCount() > 1 ) { - SCH_REFERENCE schReference = SCH_REFERENCE( aSymbol, part, *this ); + SCH_REFERENCE schReference = SCH_REFERENCE( aSymbol, symbol, *this ); schReference.SetSheetNumber( m_virtualPageNumber ); wxString reference_str = schReference.GetRef(); @@ -716,11 +716,11 @@ void SCH_SHEET_LIST::AnnotatePowerSymbols() for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) { SCH_SYMBOL* symbol = static_cast( item ); - LIB_PART* part = symbol->GetPartRef().get(); + LIB_SYMBOL* libSymbol = symbol->GetPartRef().get(); - if( part && part->IsPower() ) + if( libSymbol && libSymbol->IsPower() ) { - SCH_REFERENCE schReference( symbol, part, sheet ); + SCH_REFERENCE schReference( symbol, libSymbol, sheet ); references.AddItem( schReference ); } } @@ -750,7 +750,6 @@ void SCH_SHEET_LIST::AnnotatePowerSymbols() references[ii].SetRef( curr_ref ); } - // Break full symbol reference into name (prefix) and number: // example: IC1 become IC, and 1 references.SplitReferences(); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index a3ade4eba8..4d952dcae3 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -55,7 +55,7 @@ std::string toUTFTildaText( const wxString& txt ) /** - * Used to draw a dummy shape when a LIB_PART is not found in library + * Used to draw a dummy shape when a LIB_SYMBOL is not found in library * * This symbol is a 400 mils square with the text "??" * DEF DUMMY U 0 40 Y Y 1 0 N @@ -67,29 +67,29 @@ std::string toUTFTildaText( const wxString& txt ) * ENDDRAW * ENDDEF */ -static LIB_PART* dummy() +static LIB_SYMBOL* dummy() { - static LIB_PART* part; + static LIB_SYMBOL* symbol; - if( !part ) + if( !symbol ) { - part = new LIB_PART( wxEmptyString ); + symbol = new LIB_SYMBOL( wxEmptyString ); - LIB_RECTANGLE* square = new LIB_RECTANGLE( part ); + LIB_RECTANGLE* square = new LIB_RECTANGLE( symbol ); square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) ); square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) ); - LIB_TEXT* text = new LIB_TEXT( part ); + LIB_TEXT* text = new LIB_TEXT( symbol ); text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) ); text->SetText( wxString( wxT( "??" ) ) ); - part->AddDrawItem( square ); - part->AddDrawItem( text ); + symbol->AddDrawItem( square ); + symbol->AddDrawItem( text ); } - return part; + return symbol; } @@ -100,8 +100,8 @@ SCH_SYMBOL::SCH_SYMBOL( const wxPoint& aPos, SCH_ITEM* aParent ) : } -SCH_SYMBOL::SCH_SYMBOL( const LIB_PART& aPart, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet, - int unit, int convert, const wxPoint& pos ) : +SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, + const SCH_SHEET_PATH* aSheet, int unit, int convert, const wxPoint& pos ) : SCH_ITEM( NULL, SCH_SYMBOL_T ) { Init( pos ); @@ -110,9 +110,9 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_PART& aPart, const LIB_ID& aLibId, const SCH_S m_convert = convert; m_lib_id = aLibId; - std::unique_ptr< LIB_PART > part; + std::unique_ptr< LIB_SYMBOL > part; - part = aPart.Flatten(); + part = aSymbol.Flatten(); part->SetParent(); SetLibSymbol( part.release() ); @@ -130,14 +130,14 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_PART& aPart, const LIB_ID& aLibId, const SCH_S SetRef( aSheet, UTIL::GetRefDesUnannotated( m_prefix ) ); // Inherit the include in bill of materials and board netlist settings from library symbol. - m_inBom = aPart.GetIncludeInBom(); - m_onBoard = aPart.GetIncludeOnBoard(); + m_inBom = aSymbol.GetIncludeInBom(); + m_onBoard = aSymbol.GetIncludeOnBoard(); } -SCH_SYMBOL::SCH_SYMBOL( const LIB_PART& aPart, const SCH_SHEET_PATH* aSheet, +SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel, const wxPoint& pos ) : - SCH_SYMBOL( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos ) + SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos ) { // Set any fields that were modified as part of the symbol selection for( const std::pair& i : aSel.Fields ) @@ -163,7 +163,7 @@ SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) : m_onBoard = aSymbol.m_onBoard; if( aSymbol.m_part ) - SetLibSymbol( new LIB_PART( *aSymbol.m_part.get() ) ); + SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part.get() ) ); const_cast( m_Uuid ) = aSymbol.m_Uuid; @@ -244,7 +244,7 @@ wxString SCH_SYMBOL::GetSchSymbolLibraryName() const } -void SCH_SYMBOL::SetLibSymbol( LIB_PART* aLibSymbol ) +void SCH_SYMBOL::SetLibSymbol( LIB_SYMBOL* aLibSymbol ) { wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr ); @@ -456,7 +456,7 @@ const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUni ref = UTIL::GetRefDesUnannotated( m_prefix ); if( aIncludeUnit && GetUnitCount() > 1 ) - ref += LIB_PART::SubReference( GetUnit() ); + ref += LIB_SYMBOL::SubReference( GetUnit() ); return ref; } @@ -887,10 +887,10 @@ void SCH_SYMBOL::SwapData( SCH_ITEM* aItem ) std::swap( m_lib_id, symbol->m_lib_id ); - LIB_PART* part = symbol->m_part.release(); + LIB_SYMBOL* libSymbol = symbol->m_part.release(); symbol->m_part.reset( m_part.release() ); symbol->UpdatePins(); - m_part.reset( part ); + m_part.reset( libSymbol ); UpdatePins(); std::swap( m_pos, symbol->m_pos ); @@ -997,7 +997,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const else unit = GetUnit(); - *token = LIB_PART::SubReference( unit ); + *token = LIB_SYMBOL::SubReference( unit ); return true; } @@ -1371,7 +1371,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList { msg = _( "Missing parent" ); - std::shared_ptr< LIB_PART > parent = m_part->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock(); if( parent ) msg = parent->GetName(); @@ -1745,7 +1745,7 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem ) m_lib_id = c->m_lib_id; - LIB_PART* libSymbol = c->m_part ? new LIB_PART( *c->m_part.get() ) : nullptr; + LIB_SYMBOL* libSymbol = c->m_part ? new LIB_SYMBOL( *c->m_part.get() ) : nullptr; m_part.reset( libSymbol ); m_pos = c->m_pos; diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 17aa138fb9..447fb4c614 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -54,7 +54,7 @@ struct PICKED_SYMBOL; class SCH_SCREEN; class LIB_ITEM; class LIB_PIN; -class LIB_PART; +class LIB_SYMBOL; class NETLIST_OBJECT_LIST; class PART_LIB; class PART_LIBS; @@ -66,7 +66,7 @@ class SYMBOL_LIB_TABLE; /// A container for several SCH_FIELD items typedef std::vector SCH_FIELDS; -typedef std::weak_ptr PART_REF; +typedef std::weak_ptr PART_REF; extern std::string toUTFTildaText( const wxString& txt ); @@ -91,10 +91,10 @@ public: * @param pos is the position of the symbol. * @param setNewItemFlag is used to set the symbol #IS_NEW and #IS_MOVING flags. */ - SCH_SYMBOL( const LIB_PART& aPart, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet, + SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet, int unit = 0, int convert = 0, const wxPoint& pos = wxPoint( 0, 0 ) ); - SCH_SYMBOL( const LIB_PART& aPart, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel, + SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel, const wxPoint& pos = wxPoint( 0, 0 ) ); /** @@ -161,26 +161,26 @@ public: wxString GetSchSymbolLibraryName() const; bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); } - std::unique_ptr< LIB_PART >& GetPartRef() { return m_part; } - const std::unique_ptr< LIB_PART >& GetPartRef() const { return m_part; } + std::unique_ptr< LIB_SYMBOL >& GetPartRef() { return m_part; } + const std::unique_ptr< LIB_SYMBOL >& GetPartRef() const { return m_part; } /** * Set this schematic symbol library symbol reference to \a aLibSymbol * * The schematic symbol object owns \a aLibSymbol and the pin list will be updated - * accordingly. The #LIB_PART object can be null to clear the library symbol link - * as well as the pin map. If the #LIB_PART object is not null, it must be a root + * accordingly. The #LIB_SYMBOL object can be null to clear the library symbol link + * as well as the pin map. If the #LIB_SYMBOL object is not null, it must be a root * symbol. Otherwise an assertion will be raised in debug builds and the library * symbol will be cleared. The new file format will no longer require a cache * library so all library symbols must be valid. * * @note This is the only way to publicly set the library symbol for a schematic - * symbol except for the ctors that take a LIB_PART reference. All previous + * symbol except for the ctors that take a LIB_SYMBOL reference. All previous * public resolvers have been deprecated. * * @param aLibSymbol is the library symbol to associate with this schematic symbol. */ - void SetLibSymbol( LIB_PART* aLibSymbol ); + void SetLibSymbol( LIB_SYMBOL* aLibSymbol ); /** * Return information about the aliased parts @@ -692,7 +692,7 @@ private: TRANSFORM m_transform; ///< The rotation/mirror transformation matrix. SCH_FIELDS m_fields; ///< Variable length list of fields. - std::unique_ptr< LIB_PART > m_part; // a flattened copy of the LIB_PART from + std::unique_ptr< LIB_SYMBOL > m_part; // a flattened copy of the LIB_SYMBOL from // the PROJECT's libraries. std::vector> m_pins; // a SCH_PIN for every LIB_PIN (all units) std::unordered_map m_pinMap; // library pin pointer to SCH_PIN's index diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index ada71c48d4..edda307924 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2018 CERN - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @author Maciej Suminski @@ -118,18 +118,18 @@ void SCH_VIEW::DisplaySheet( const SCH_SCREEN *aScreen ) } -void SCH_VIEW::DisplayComponent( LIB_PART* aPart ) +void SCH_VIEW::DisplayComponent( LIB_SYMBOL* aSymbol ) { Clear(); - if( !aPart ) + if( !aSymbol ) return; - std::shared_ptr< LIB_PART > parent; - LIB_PART* drawnPart = aPart; + std::shared_ptr< LIB_SYMBOL > parent; + LIB_SYMBOL* drawnSymbol = aSymbol; // Draw the mandatory fields for aliases and parent symbols. - for( LIB_ITEM& item : aPart->GetDrawItems() ) + for( LIB_ITEM& item : aSymbol->GetDrawItems() ) { if( item.Type() != LIB_FIELD_T ) continue; @@ -145,20 +145,20 @@ void SCH_VIEW::DisplayComponent( LIB_PART* aPart ) } // Draw the parent items if the symbol is inherited from another symbol. - if( aPart->IsAlias() ) + if( aSymbol->IsAlias() ) { - parent = aPart->GetParent().lock(); + parent = aSymbol->GetParent().lock(); wxCHECK( parent, /* void */ ); - drawnPart = parent.get(); + drawnSymbol = parent.get(); } - for( LIB_ITEM& item : drawnPart->GetDrawItems() ) + for( LIB_ITEM& item : drawnSymbol->GetDrawItems() ) { // Don't show parent symbol fields. Users may be confused by shown fields that can not // be edited. - if( aPart->IsAlias() && item.Type() == LIB_FIELD_T ) + if( aSymbol->IsAlias() && item.Type() == LIB_FIELD_T ) continue; Add( &item ); diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index adcc65e739..8ad41b6fdf 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +33,7 @@ class SCH_SHEET; class SCH_SCREEN; -class LIB_PART; +class LIB_SYMBOL; class LIB_PIN; class SCH_BASE_FRAME; class DS_PROXY_VIEW_ITEM; @@ -80,7 +80,7 @@ public: void Cleanup(); void DisplaySheet( const SCH_SCREEN* aScreen ); - void DisplayComponent( LIB_PART* aPart ); + void DisplayComponent( LIB_SYMBOL* aSymbol ); // Call it to set new draw area limits (max working and draw area size) void ResizeSheetWorkingArea( const SCH_SCREEN *aScreen ); diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index 198f6e9ae0..194b9becb7 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -205,12 +205,12 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_params.emplace_back( new PARAM( "spice_external_command", &m_SpiceCommandString, "spice \"%I\"" ) ); - // TODO(JE) should we keep these LIB_PART:: things around? + // TODO(JE) should we keep these LIB_SYMBOL:: things around? m_params.emplace_back( new PARAM( "subpart_id_separator", - LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); + LIB_SYMBOL::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); m_params.emplace_back( new PARAM( "subpart_first_id", - LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); + LIB_SYMBOL::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); m_NgspiceSimulatorSettings = std::make_shared( this, "ngspice" ); diff --git a/eeschema/symbol_async_loader.cpp b/eeschema/symbol_async_loader.cpp index 036de40a33..d0e4fa0347 100644 --- a/eeschema/symbol_async_loader.cpp +++ b/eeschema/symbol_async_loader.cpp @@ -28,7 +28,7 @@ SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER( const std::vector& aNicknames, SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols, - std::unordered_map>* aOutput, + std::unordered_map>* aOutput, PROGRESS_REPORTER* aReporter ) : m_nicknames( aNicknames ), m_table( aTable ), diff --git a/eeschema/symbol_async_loader.h b/eeschema/symbol_async_loader.h index 632986a0ec..7a1257b626 100644 --- a/eeschema/symbol_async_loader.h +++ b/eeschema/symbol_async_loader.h @@ -29,7 +29,7 @@ #include -class LIB_PART; +class LIB_SYMBOL; class PROGRESS_REPORTER; class SYMBOL_LIB_TABLE; @@ -47,7 +47,7 @@ public: */ SYMBOL_ASYNC_LOADER( const std::vector& aNicknames, SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols = false, - std::unordered_map>* aOutput = nullptr, + std::unordered_map>* aOutput = nullptr, PROGRESS_REPORTER* aReporter = nullptr ); ~SYMBOL_ASYNC_LOADER(); @@ -74,7 +74,7 @@ public: const wxString& GetErrors() const { return m_errors; } ///< Represents a pair of - typedef std::pair> LOADED_PAIR; + typedef std::pair> LOADED_PAIR; private: ///< Worker job that loads libraries and returns a list of pairs of @@ -90,7 +90,7 @@ private: bool m_onlyPowerSymbols; ///< Handle to map that will be filled with the loaded parts per library - std::unordered_map>* m_output; + std::unordered_map>* m_output; ///< Progress reporter (may be null) PROGRESS_REPORTER* m_reporter; diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 3779eafea2..693d472542 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -560,7 +560,7 @@ void SYMBOL_EDIT_FRAME::RebuildSymbolUnitsList() { for( int i = 0; i < m_my_part->GetUnitCount(); i++ ) { - wxString sub = LIB_PART::SubReference( i+1, false ); + wxString sub = LIB_SYMBOL::SubReference( i+1, false ); wxString unit = wxString::Format( _( "Unit %s" ), sub ); m_unitSelectBox->Append( unit ); } @@ -675,13 +675,13 @@ wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname ) } -void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart, bool aUpdateZoom ) +void SYMBOL_EDIT_FRAME::SetCurPart( LIB_SYMBOL* aSymbol, bool aUpdateZoom ) { m_toolManager->RunAction( EE_ACTIONS::clearSelection, true ); GetCanvas()->GetView()->Clear(); delete m_my_part; - m_my_part = aPart; + m_my_part = aSymbol; // select the current symbol in the tree widget if( !IsSymbolFromSchematic() && m_my_part ) @@ -695,7 +695,7 @@ void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart, bool aUpdateZoom ) Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName ); // Ensure synchronized pin edit can be enabled only symbols with interchangeable units - m_SyncPinEdit = aPart && aPart->IsRoot() && aPart->IsMulti() && !aPart->UnitsLocked(); + m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMulti() && !aSymbol->UnitsLocked(); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); @@ -858,13 +858,13 @@ LIB_ID SYMBOL_EDIT_FRAME::GetTreeLIBID( int* aUnit ) const } -LIB_PART* SYMBOL_EDIT_FRAME::getTargetPart() const +LIB_SYMBOL* SYMBOL_EDIT_FRAME::getTargetPart() const { LIB_ID libId = GetTreeLIBID(); if( libId.IsValid() ) { - LIB_PART* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() ); + LIB_SYMBOL* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() ); return alias; } @@ -1051,9 +1051,11 @@ void SYMBOL_EDIT_FRAME::storeCurrentPart() bool SYMBOL_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const { // This will return the root part of any alias - LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() ); - // Now we can compare the libId of the current part and the root part - return ( part && m_my_part && part->GetLibId() == m_my_part->GetLibId() ); + LIB_SYMBOL* symbol = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), + aLibId.GetLibNickname() ); + + // Now we can compare the libId of the current symbol and the root symbol + return ( symbol && m_my_part && symbol->GetLibId() == m_my_part->GetLibId() ); } @@ -1234,7 +1236,7 @@ bool SYMBOL_EDIT_FRAME::IsContentModified() const { wxCHECK( m_libMgr, false ); - // Test if the currently edited part is modified + // Test if the currently edited symbol is modified if( GetScreen() && GetScreen()->IsContentModified() && GetCurPart() ) return true; @@ -1274,8 +1276,8 @@ SELECTION& SYMBOL_EDIT_FRAME::GetCurrentSelection() void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) { - std::unique_ptr part = aSymbol->GetPartRef()->Flatten(); - wxCHECK( part, /* void */ ); + std::unique_ptr symbol = aSymbol->GetPartRef()->Flatten(); + wxCHECK( symbol, /* void */ ); std::vector fullSetOfFields; @@ -1283,7 +1285,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) { const SCH_FIELD& field = aSymbol->GetFields()[i]; wxPoint pos = field.GetPosition() - aSymbol->GetPosition(); - LIB_FIELD libField( part.get(), field.GetId() ); + LIB_FIELD libField( symbol.get(), field.GetId() ); if( i >= MANDATORY_FIELDS && !field.GetName( false ).IsEmpty() ) libField.SetName( field.GetName( false ) ); @@ -1295,21 +1297,21 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) fullSetOfFields.emplace_back( std::move( libField ) ); } - part->SetFields( fullSetOfFields ); + symbol->SetFields( fullSetOfFields ); if( m_my_part ) SetCurPart( nullptr, false ); m_isSymbolFromSchematic = true; - m_reference = part->GetFieldById( REFERENCE_FIELD )->GetText(); + m_reference = symbol->GetFieldById( REFERENCE_FIELD )->GetText(); m_unit = std::max( 1, aSymbol->GetUnit() ); m_convert = std::max( 1, aSymbol->GetConvert() ); - // The buffered screen for the part + // The buffered screen for the symbol SCH_SCREEN* tmpScreen = new SCH_SCREEN(); SetScreen( tmpScreen ); - SetCurPart( part.release(), true ); + SetCurPart( symbol.release(), true ); ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 95b896dade..f19c7fccee 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -36,7 +36,7 @@ class SCH_EDIT_FRAME; class SYMBOL_LIB_TABLE; -class LIB_PART; +class LIB_SYMBOL; class LIB_FIELD; class DIALOG_LIB_EDIT_TEXT; class SYMBOL_TREE_PANE; @@ -98,14 +98,14 @@ public: /** * Return the current part being edited or NULL if none selected. * - * This is a LIB_PART that I own, it is at best a copy of one in a library. + * This is a LIB_SYMBOL that I own, it is at best a copy of one in a library. */ - LIB_PART* GetCurPart() const { return m_my_part; } + LIB_SYMBOL* GetCurPart() const { return m_my_part; } /** - * Take ownership of aPart and notes that it is the one currently being edited. + * Take ownership of aSymbol and notes that it is the one currently being edited. */ - void SetCurPart( LIB_PART* aPart, bool aUpdateZoom ); + void SetCurPart( LIB_SYMBOL* aSymbol, bool aUpdateZoom ); SYMBOL_LIBRARY_MANAGER& GetLibManager(); @@ -159,7 +159,7 @@ public: void CopyPartToClipboard(); - void LoadPart( const wxString& aLibrary, const wxString& aPart, int Unit ); + void LoadPart( const wxString& aLibrary, const wxString& aSymbol, int Unit ); /** * Insert a duplicate part. @@ -420,14 +420,14 @@ private: /** * Create a copy of \a aLibEntry into memory. * - * @param aLibEntry A pointer to the LIB_PART object to an already loaded symbol. + * @param aLibEntry A pointer to the LIB_SYMBOL object to an already loaded symbol. * @param aLibrary the path to the library file that \a aLibEntry was loaded from. This is * for error messaging purposes only. * @param aUnit the initial unit to show. * @param aConvert the initial DeMorgan variant to show. * @return True if a copy of \a aLibEntry was successfully copied. */ - bool LoadOneLibraryPartAux( LIB_PART* aLibEntry, const wxString& aLibrary, int aUnit, + bool LoadOneLibraryPartAux( LIB_SYMBOL* aLibEntry, const wxString& aLibrary, int aUnit, int aConvert ); /** @@ -442,7 +442,7 @@ private: bool backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt ); ///< Return currently edited part. - LIB_PART* getTargetPart() const; + LIB_SYMBOL* getTargetPart() const; ///< Return either the library selected in the symbol tree, if context menu is active or ///< the library that is currently modified. @@ -465,8 +465,8 @@ private: ///< Return true if \a aLibId is an alias for the editor screen part. bool isCurrentPart( const LIB_ID& aLibId ) const; - ///< Rename LIB_PART aliases to avoid conflicts before adding a symbol to a library. - void ensureUniqueName( LIB_PART* aPart, const wxString& aLibrary ); + ///< Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library. + void ensureUniqueName( LIB_SYMBOL* aSymbol, const wxString& aLibrary ); enum TABLE_SCOPE { @@ -527,7 +527,7 @@ private: ///< Helper screen used when no part is loaded SCH_SCREEN* m_dummyScreen; - LIB_PART* m_my_part; // a part I own, it is not in any library, but a + LIB_SYMBOL* m_my_part; // a part I own, it is not in any library, but a // copy could be. wxComboBox* m_unitSelectBox; // a ComboBox to select a unit to edit (if the // part has multiple units) diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index c84f33ef22..23c6acf2cb 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -271,7 +271,7 @@ bool SYMBOL_EDIT_FRAME::LoadSymbol( const LIB_ID& aLibId, int aUnit, int aConver bool SYMBOL_EDIT_FRAME::LoadSymbolFromCurrentLib( const wxString& aAliasName, int aUnit, int aConvert ) { - LIB_PART* alias = nullptr; + LIB_SYMBOL* alias = nullptr; try { @@ -304,7 +304,7 @@ bool SYMBOL_EDIT_FRAME::LoadSymbolFromCurrentLib( const wxString& aAliasName, in } -bool SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& aLibrary, +bool SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux( LIB_SYMBOL* aEntry, const wxString& aLibrary, int aUnit, int aConvert ) { wxString msg, rootName; @@ -334,17 +334,17 @@ bool SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& rebuildMenuAndToolbar = true; } - LIB_PART* lib_part = m_libMgr->GetBufferedPart( aEntry->GetName(), aLibrary ); - wxCHECK( lib_part, false ); + LIB_SYMBOL* lib_symbol = m_libMgr->GetBufferedPart( aEntry->GetName(), aLibrary ); + wxCHECK( lib_symbol, false ); m_unit = aUnit > 0 ? aUnit : 1; m_convert = aConvert > 0 ? aConvert : 1; - // The buffered screen for the part - SCH_SCREEN* part_screen = m_libMgr->GetScreen( lib_part->GetName(), aLibrary ); + // The buffered screen for the symbol + SCH_SCREEN* part_screen = m_libMgr->GetScreen( lib_symbol->GetName(), aLibrary ); SetScreen( part_screen ); - SetCurPart( new LIB_PART( *lib_part ), true ); + SetCurPart( new LIB_SYMBOL( *lib_symbol ), true ); SetCurLib( aLibrary ); if( rebuildMenuAndToolbar ) @@ -406,6 +406,7 @@ void SYMBOL_EDIT_FRAME::CreateNewPart() } wxString name = dlg.GetName(); + // Currently, symbol names cannot include a space, that breaks libraries: name.Replace( " ", "_" ); @@ -418,56 +419,56 @@ void SYMBOL_EDIT_FRAME::CreateNewPart() return; } - LIB_PART new_part( name ); // do not create part on the heap, it will be buffered soon + LIB_SYMBOL new_symbol( name ); // do not create symbol on the heap, it will be buffered soon wxString parentSymbolName = dlg.GetParentSymbolName(); if( parentSymbolName.IsEmpty() ) { - new_part.GetReferenceField().SetText( dlg.GetReference() ); - new_part.SetUnitCount( dlg.GetUnitCount() ); + new_symbol.GetReferenceField().SetText( dlg.GetReference() ); + new_symbol.SetUnitCount( dlg.GetUnitCount() ); - // Initialize new_part.m_TextInside member: + // Initialize new_symbol.m_TextInside member: // if 0, pin text is outside the body (on the pin) // if > 0, pin text is inside the body - if( dlg.GetPinNameInside() ) { - new_part.SetPinNameOffset( dlg.GetPinTextPosition() ); + new_symbol.SetPinNameOffset( dlg.GetPinTextPosition() ); - if( new_part.GetPinNameOffset() == 0 ) - new_part.SetPinNameOffset( 1 ); + if( new_symbol.GetPinNameOffset() == 0 ) + new_symbol.SetPinNameOffset( 1 ); } else { - new_part.SetPinNameOffset( 0 ); + new_symbol.SetPinNameOffset( 0 ); } - ( dlg.GetPowerSymbol() ) ? new_part.SetPower() : new_part.SetNormal(); - new_part.SetShowPinNumbers( dlg.GetShowPinNumber() ); - new_part.SetShowPinNames( dlg.GetShowPinName() ); - new_part.LockUnits( dlg.GetLockItems() ); - new_part.SetIncludeInBom( dlg.GetIncludeInBom() ); - new_part.SetIncludeOnBoard( dlg.GetIncludeOnBoard() ); + ( dlg.GetPowerSymbol() ) ? new_symbol.SetPower() : new_symbol.SetNormal(); + new_symbol.SetShowPinNumbers( dlg.GetShowPinNumber() ); + new_symbol.SetShowPinNames( dlg.GetShowPinName() ); + new_symbol.LockUnits( dlg.GetLockItems() ); + new_symbol.SetIncludeInBom( dlg.GetIncludeInBom() ); + new_symbol.SetIncludeOnBoard( dlg.GetIncludeOnBoard() ); if( dlg.GetUnitCount() < 2 ) - new_part.LockUnits( false ); + new_symbol.LockUnits( false ); + + new_symbol.SetConversion( dlg.GetAlternateBodyStyle() ); - new_part.SetConversion( dlg.GetAlternateBodyStyle() ); // must be called after loadPart, that calls SetShowDeMorgan, but // because the symbol is empty,it looks like it has no alternate body SetShowDeMorgan( dlg.GetAlternateBodyStyle() ); } else { - LIB_PART* parent = m_libMgr->GetAlias( parentSymbolName, lib ); + LIB_SYMBOL* parent = m_libMgr->GetAlias( parentSymbolName, lib ); wxCHECK( parent, /* void */ ); - new_part.SetParent( parent ); + new_symbol.SetParent( parent ); // Inherit the parent mandatory field attributes. for( int id = 0; id < MANDATORY_FIELDS; ++id ) { - LIB_FIELD* field = new_part.GetFieldById( id ); + LIB_FIELD* field = new_symbol.GetFieldById( id ); // the MANDATORY_FIELDS are exactly that in RAM. wxCHECK( field, /* void */ ); @@ -497,11 +498,11 @@ void SYMBOL_EDIT_FRAME::CreateNewPart() break; } - field->SetParent( &new_part ); + field->SetParent( &new_symbol ); } } - m_libMgr->UpdatePart( &new_part, lib ); + m_libMgr->UpdatePart( &new_symbol, lib ); SyncLibraries( false ); LoadPart( name, lib, 1 ); } @@ -578,11 +579,11 @@ void SYMBOL_EDIT_FRAME::SaveSymbolAs() void SYMBOL_EDIT_FRAME::savePartAs() { - LIB_PART* part = getTargetPart(); + LIB_SYMBOL* symbol = getTargetPart(); - if( part ) + if( symbol ) { - LIB_ID old_lib_id = part->GetLibId(); + LIB_ID old_lib_id = symbol->GetLibId(); wxString old_name = old_lib_id.GetLibItemName(); wxString old_lib = old_lib_id.GetLibNickname(); @@ -641,8 +642,8 @@ void SYMBOL_EDIT_FRAME::savePartAs() // @todo Either check the selecteced library to see if the parent symbol name is in // the new library and/or copy the parent symbol as well. This is the lazy - // solution to ensure derived parts do not get orphaned. - if( part->IsAlias() && new_lib != old_lib ) + // solution to ensure derived symbols do not get orphaned. + if( symbol->IsAlias() && new_lib != old_lib ) { DisplayError( this, _( "Derived symbols must be saved in the same library as their " "parent symbol." ) ); @@ -670,12 +671,12 @@ void SYMBOL_EDIT_FRAME::savePartAs() return; } - LIB_PART new_part( *part ); - new_part.SetName( new_name ); + LIB_SYMBOL new_symbol( *symbol ); + new_symbol.SetName( new_name ); - m_libMgr->UpdatePart( &new_part, new_lib ); + m_libMgr->UpdatePart( &new_symbol, new_lib ); SyncLibraries( false ); - m_treePane->GetLibTree()->SelectLibId( LIB_ID( new_lib, new_part.GetName() ) ); + m_treePane->GetLibTree()->SelectLibId( LIB_ID( new_lib, new_symbol.GetName() ) ); LoadPart( new_name, new_lib, m_unit ); } } @@ -705,7 +706,7 @@ void SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName ) m_libMgr->UpdatePartAfterRename( m_my_part, *aOldName, lib ); } - // Reselect the renamed part + // Reselect the renamed symbol m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, m_my_part->GetName() ) ); } @@ -764,12 +765,13 @@ void SYMBOL_EDIT_FRAME::CopyPartToClipboard() { int dummyUnit; LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit ); - LIB_PART* part = m_libMgr->GetBufferedPart( libId.GetLibItemName(), libId.GetLibNickname() ); + LIB_SYMBOL* symbol = m_libMgr->GetBufferedPart( libId.GetLibItemName(), + libId.GetLibNickname() ); - if( !part ) + if( !symbol ) return; - std::unique_ptr< LIB_PART> tmp = part->Flatten(); + std::unique_ptr< LIB_SYMBOL> tmp = symbol->Flatten(); STRING_FORMATTER formatter; SCH_SEXPR_PLUGIN::FormatPart( tmp.get(), formatter ); @@ -797,8 +799,8 @@ void SYMBOL_EDIT_FRAME::DuplicatePart( bool aFromClipboard ) if( !m_libMgr->LibraryExists( lib ) ) return; - LIB_PART* srcPart = nullptr; - LIB_PART* newPart = nullptr; + LIB_SYMBOL* srcSymbol = nullptr; + LIB_SYMBOL* newSymbol = nullptr; if( aFromClipboard ) { @@ -818,7 +820,7 @@ void SYMBOL_EDIT_FRAME::DuplicatePart( bool aFromClipboard ) try { - newPart = SCH_SEXPR_PLUGIN::ParsePart( reader ); + newSymbol = SCH_SEXPR_PLUGIN::ParsePart( reader ); } catch( IO_ERROR& e ) { @@ -828,50 +830,50 @@ void SYMBOL_EDIT_FRAME::DuplicatePart( bool aFromClipboard ) } else { - srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib ); + srcSymbol = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib ); - wxCHECK( srcPart, /* void */ ); + wxCHECK( srcSymbol, /* void */ ); - newPart = new LIB_PART( *srcPart ); + newSymbol = new LIB_SYMBOL( *srcSymbol ); // Derive from same parent. - if( srcPart->IsAlias() ) + if( srcSymbol->IsAlias() ) { - std::shared_ptr< LIB_PART > srcParent = srcPart->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > srcParent = srcSymbol->GetParent().lock(); wxCHECK( srcParent, /* void */ ); - newPart->SetParent( srcParent.get() ); + newSymbol->SetParent( srcParent.get() ); } } - if( !newPart ) + if( !newSymbol ) return; - ensureUniqueName( newPart, lib ); - m_libMgr->UpdatePart( newPart, lib ); + ensureUniqueName( newSymbol, lib ); + m_libMgr->UpdatePart( newSymbol, lib ); - LoadOneLibraryPartAux( newPart, lib, GetUnit(), GetConvert() ); + LoadOneLibraryPartAux( newSymbol, lib, GetUnit(), GetConvert() ); SyncLibraries( false ); - m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newPart->GetName() ) ); + m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newSymbol->GetName() ) ); - delete newPart; + delete newSymbol; } -void SYMBOL_EDIT_FRAME::ensureUniqueName( LIB_PART* aPart, const wxString& aLibrary ) +void SYMBOL_EDIT_FRAME::ensureUniqueName( LIB_SYMBOL* aSymbol, const wxString& aLibrary ) { - wxCHECK( aPart, /* void */ ); + wxCHECK( aSymbol, /* void */ ); int i = 1; - wxString newName = aPart->GetName(); + wxString newName = aSymbol->GetName(); // Append a number to the name until the name is unique in the library. while( m_libMgr->PartExists( newName, aLibrary ) ) - newName.Printf( "%s_%d", aPart->GetName(), i++ ); + newName.Printf( "%s_%d", aSymbol->GetName(), i++ ); - aPart->SetName( newName ); + aSymbol->SetName( newName ); } @@ -945,7 +947,7 @@ void SYMBOL_EDIT_FRAME::RevertAll() void SYMBOL_EDIT_FRAME::LoadPart( const wxString& aAlias, const wxString& aLibrary, int aUnit ) { - LIB_PART* part = m_libMgr->GetBufferedPart( aAlias, aLibrary ); + LIB_SYMBOL* part = m_libMgr->GetBufferedPart( aAlias, aLibrary ); if( !part ) { @@ -1123,7 +1125,6 @@ bool SYMBOL_EDIT_FRAME::saveAllLibraries( bool aRequireConfirmation ) { // If saving under existing name fails then do a Save As..., and if that // fails then cancel close action. - if( !m_libMgr->IsLibraryReadOnly( libNickname ) ) { if( saveLibrary( libNickname, false ) ) diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index 0f8a4bb55f..bc369b2f54 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -88,7 +88,7 @@ void SYMBOL_EDIT_FRAME::ImportPart() } wxString symbolName = symbols[0]; - LIB_PART* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName ); + LIB_SYMBOL* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName ); if( m_libMgr->PartExists( symbols[0], libName ) ) { @@ -106,9 +106,9 @@ void SYMBOL_EDIT_FRAME::ImportPart() void SYMBOL_EDIT_FRAME::ExportPart() { wxString msg, title; - LIB_PART* part = getTargetPart(); + LIB_SYMBOL* symbol = getTargetPart(); - if( !part ) + if( !symbol ) { ShowInfoBarError( _( "There is no symbol selected to save." ) ); return; @@ -116,7 +116,7 @@ void SYMBOL_EDIT_FRAME::ExportPart() wxFileName fn; - fn.SetName( part->GetName().Lower() ); + fn.SetName( symbol->GetName().Lower() ); fn.SetExt( KiCadSymbolLibFileExtension ); wxFileDialog dlg( this, _( "Export Symbol" ), m_mruPath, fn.GetFullName(), @@ -128,7 +128,7 @@ void SYMBOL_EDIT_FRAME::ExportPart() fn = dlg.GetPath(); fn.MakeAbsolute(); - LIB_PART* old_part = NULL; + LIB_SYMBOL* old_symbol = NULL; SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() ); SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pluginType ) ); @@ -136,7 +136,7 @@ void SYMBOL_EDIT_FRAME::ExportPart() { try { - old_part = pi->LoadSymbol( fn.GetFullPath(), part->GetName() ); + old_symbol = pi->LoadSymbol( fn.GetFullPath(), symbol->GetName() ); } catch( const IO_ERROR& ioe ) { @@ -146,10 +146,10 @@ void SYMBOL_EDIT_FRAME::ExportPart() return; } - if( old_part ) + if( old_symbol ) { msg.Printf( _( "Symbol \"%s\" already exists in \"%s\"." ), - part->GetName(), + symbol->GetName(), fn.GetFullName() ); KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); @@ -176,8 +176,8 @@ void SYMBOL_EDIT_FRAME::ExportPart() // The flattened symbol is most likely what the user would want. As some point in // the future as more of the symbol library inheritance is implemented, this may have - // to be changes to save parts of inherited symbols. - pi->SaveSymbol( fn.GetFullPath(), part->Flatten().release() ); + // to be changes to save symbols of inherited symbols. + pi->SaveSymbol( fn.GetFullPath(), symbol->Flatten().release() ); } catch( const IO_ERROR& ioe ) { @@ -190,7 +190,7 @@ void SYMBOL_EDIT_FRAME::ExportPart() m_mruPath = fn.GetPath(); - msg.Printf( _( "Symbol \"%s\" saved in library \"%s\"" ), part->GetName(), fn.GetFullPath() ); + msg.Printf( _( "Symbol \"%s\" saved in library \"%s\"" ), symbol->GetName(), fn.GetFullPath() ); SetStatusText( msg ); // See if the user wants it added to a library table (global or project) diff --git a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp index c8e6c5a550..edeb8bf90a 100644 --- a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp +++ b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2021 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,10 +37,10 @@ void SYMBOL_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aUndoType if( !aItem ) return; - LIB_PART* copyItem; + LIB_SYMBOL* copyItem; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); - copyItem = new LIB_PART( * (LIB_PART*) aItem ); + copyItem = new LIB_SYMBOL( * (LIB_SYMBOL*) aItem ); // Clear current flags (which can be temporary set by a current edit command). copyItem->ClearTempFlags(); @@ -67,36 +67,36 @@ void SYMBOL_EDIT_FRAME::GetSymbolFromRedoList() PICKED_ITEMS_LIST* redoCommand = PopCommandFromRedoList(); ITEM_PICKER redoWrapper = redoCommand->PopItem(); delete redoCommand; - LIB_PART* part = (LIB_PART*) redoWrapper.GetItem(); - wxCHECK( part, /* void */ ); - part->ClearFlags( UR_TRANSIENT ); + LIB_SYMBOL* symbol = (LIB_SYMBOL*) redoWrapper.GetItem(); + wxCHECK( symbol, /* void */ ); + symbol->ClearFlags( UR_TRANSIENT ); UNDO_REDO undoRedoType = redoWrapper.GetStatus(); - // Store the current part in the undo buffer + // Store the current symbol in the undo buffer PICKED_ITEMS_LIST* undoCommand = new PICKED_ITEMS_LIST(); - LIB_PART* oldPart = m_my_part; - oldPart->SetFlags( UR_TRANSIENT ); - ITEM_PICKER undoWrapper( GetScreen(), oldPart, undoRedoType ); + LIB_SYMBOL* oldSymbol = m_my_part; + oldSymbol->SetFlags( UR_TRANSIENT ); + ITEM_PICKER undoWrapper( GetScreen(), oldSymbol, undoRedoType ); undoCommand->PushItem( undoWrapper ); PushCommandToUndoList( undoCommand ); - // Do not delete the previous part by calling SetCurPart( part ) - // which calls delete . - // is now put in undo list and is owned by this list - // Just set the current part to the part which come from the redo list - m_my_part = part; + // Do not delete the previous symbol by calling SetCurPart( symbol ) + // which calls delete . + // is now put in undo list and is owned by this list + // Just set the current symbol to the symbol which come from the redo list + m_my_part = symbol; if( undoRedoType == UNDO_REDO::LIB_RENAME ) { wxString lib = GetCurLib(); - m_libMgr->UpdatePartAfterRename( part, oldPart->GetName(), lib ); + m_libMgr->UpdatePartAfterRename( symbol, oldSymbol->GetName(), lib ); - // Reselect the renamed part - m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, part->GetName() ) ); + // Reselect the renamed symbol + m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) ); } RebuildSymbolUnitsList(); - SetShowDeMorgan( part->HasConversion() ); + SetShowDeMorgan( symbol->HasConversion() ); updateTitle(); RebuildView(); @@ -115,36 +115,36 @@ void SYMBOL_EDIT_FRAME::GetSymbolFromUndoList() PICKED_ITEMS_LIST* undoCommand = PopCommandFromUndoList(); ITEM_PICKER undoWrapper = undoCommand->PopItem(); delete undoCommand; - LIB_PART* part = (LIB_PART*) undoWrapper.GetItem(); - wxCHECK( part, /* void */ ); - part->ClearFlags( UR_TRANSIENT ); + LIB_SYMBOL* symbol = (LIB_SYMBOL*) undoWrapper.GetItem(); + wxCHECK( symbol, /* void */ ); + symbol->ClearFlags( UR_TRANSIENT ); UNDO_REDO undoRedoType = undoWrapper.GetStatus(); - // Store the current part in the redo buffer + // Store the current symbol in the redo buffer PICKED_ITEMS_LIST* redoCommand = new PICKED_ITEMS_LIST(); - LIB_PART* oldPart = m_my_part; - oldPart->SetFlags( UR_TRANSIENT ); - ITEM_PICKER redoWrapper( GetScreen(), oldPart, undoRedoType ); + LIB_SYMBOL* oldSymbol = m_my_part; + oldSymbol->SetFlags( UR_TRANSIENT ); + ITEM_PICKER redoWrapper( GetScreen(), oldSymbol, undoRedoType ); redoCommand->PushItem( redoWrapper ); PushCommandToRedoList( redoCommand ); - // Do not delete the previous part by calling SetCurPart( part ), - // which calls delete . - // is now put in redo list and is owned by this list. - // Just set the current part to the part which come from the undo list - m_my_part = part; + // Do not delete the previous symbol by calling SetCurPart( symbol ), + // which calls delete . + // is now put in redo list and is owned by this list. + // Just set the current symbol to the symbol which come from the undo list + m_my_part = symbol; if( undoRedoType == UNDO_REDO::LIB_RENAME ) { wxString lib = GetCurLib(); - m_libMgr->UpdatePartAfterRename( part, oldPart->GetName(), lib ); + m_libMgr->UpdatePartAfterRename( symbol, oldSymbol->GetName(), lib ); - // Reselect the renamed part - m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, part->GetName() ) ); + // Reselect the renamed symbol + m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) ); } RebuildSymbolUnitsList(); - SetShowDeMorgan( part->HasConversion() ); + SetShowDeMorgan( symbol->HasConversion() ); updateTitle(); RebuildView(); @@ -165,15 +165,15 @@ void SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo() ITEM_PICKER undoWrapper = undoCommand->PopItem(); delete undoCommand; - LIB_PART* part = (LIB_PART*) undoWrapper.GetItem(); - part->ClearFlags( UR_TRANSIENT ); - SetCurPart( part, false ); + LIB_SYMBOL* symbol = (LIB_SYMBOL*) undoWrapper.GetItem(); + symbol->ClearFlags( UR_TRANSIENT ); + SetCurPart( symbol, false ); EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); selTool->RebuildSelection(); RebuildSymbolUnitsList(); - SetShowDeMorgan( part->HasConversion() ); + SetShowDeMorgan( symbol->HasConversion() ); RebuildView(); } diff --git a/eeschema/symbol_editor/symbol_library_manager.cpp b/eeschema/symbol_editor/symbol_library_manager.cpp index 346d806f08..4274608e21 100644 --- a/eeschema/symbol_editor/symbol_library_manager.cpp +++ b/eeschema/symbol_editor/symbol_library_manager.cpp @@ -228,33 +228,34 @@ bool SYMBOL_LIBRARY_MANAGER::SaveLibrary( const wxString& aLibrary, const wxStri else { // Handle original library - for( LIB_PART* part : getOriginalParts( aLibrary ) ) + for( LIB_SYMBOL* symbol : getOriginalParts( aLibrary ) ) { - LIB_PART* newSymbol; + LIB_SYMBOL* newSymbol; - if( part->IsAlias() ) + if( symbol->IsAlias() ) { - std::shared_ptr< LIB_PART > oldParent = part->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > oldParent = symbol->GetParent().lock(); wxCHECK_MSG( oldParent, false, wxString::Format( "Derived symbol '%s' found with undefined parent.", - part->GetName() ) ); + symbol->GetName() ) ); - LIB_PART* libParent = pi->LoadSymbol( aLibrary, oldParent->GetName(), &properties ); + LIB_SYMBOL* libParent = pi->LoadSymbol( aLibrary, oldParent->GetName(), + &properties ); if( !libParent ) { - libParent = new LIB_PART( *oldParent.get() ); + libParent = new LIB_SYMBOL( *oldParent.get() ); pi->SaveSymbol( aLibrary, libParent, &properties ); } - newSymbol = new LIB_PART( *part ); + newSymbol = new LIB_SYMBOL( *symbol ); newSymbol->SetParent( libParent ); pi->SaveSymbol( aLibrary, newSymbol, &properties ); } - else if( !pi->LoadSymbol( aLibrary, part->GetName(), &properties ) ) + else if( !pi->LoadSymbol( aLibrary, symbol->GetName(), &properties ) ) { - pi->SaveSymbol( aLibrary, new LIB_PART( *part ), &properties ); + pi->SaveSymbol( aLibrary, new LIB_SYMBOL( *symbol ), &properties ); } } } @@ -290,8 +291,8 @@ bool SYMBOL_LIBRARY_MANAGER::IsPartModified( const wxString& aAlias, return false; const LIB_BUFFER& buf = libIt->second; - auto partBuf = buf.GetBuffer( aAlias ); - return partBuf ? partBuf->IsModified() : false; + auto symbolBuf = buf.GetBuffer( aAlias ); + return symbolBuf ? symbolBuf->IsModified() : false; } @@ -302,9 +303,9 @@ bool SYMBOL_LIBRARY_MANAGER::ClearLibraryModified( const wxString& aLibrary ) co if( libIt == m_libs.end() ) return false; - for( auto& partBuf : libIt->second.GetBuffers() ) + for( auto& symbolBuf : libIt->second.GetBuffers() ) { - SCH_SCREEN* screen = partBuf->GetScreen(); + SCH_SCREEN* screen = symbolBuf->GetScreen(); if( screen ) screen->SetContentModified( false ); @@ -322,10 +323,10 @@ bool SYMBOL_LIBRARY_MANAGER::ClearPartModified( const wxString& aAlias, if( libI == m_libs.end() ) return false; - auto partBuf = libI->second.GetBuffer( aAlias ); - wxCHECK( partBuf, false ); + auto symbolBuf = libI->second.GetBuffer( aAlias ); + wxCHECK( symbolBuf, false ); - partBuf->GetScreen()->SetContentModified( false ); + symbolBuf->GetScreen()->SetContentModified( false ); return true; } @@ -346,23 +347,23 @@ bool SYMBOL_LIBRARY_MANAGER::IsLibraryLoaded( const wxString& aLibrary ) const } -std::list SYMBOL_LIBRARY_MANAGER::GetAliases( const wxString& aLibrary ) const +std::list SYMBOL_LIBRARY_MANAGER::GetAliases( const wxString& aLibrary ) const { - std::list ret; + std::list ret; wxCHECK( LibraryExists( aLibrary ), ret ); auto libIt = m_libs.find( aLibrary ); if( libIt != m_libs.end() ) { - for( auto& partBuf : libIt->second.GetBuffers() ) + for( auto& symbolBuf : libIt->second.GetBuffers() ) { - ret.push_back( partBuf->GetPart() ); + ret.push_back( symbolBuf->GetPart() ); } } else { - std::vector aliases; + std::vector aliases; try { @@ -380,46 +381,46 @@ std::list SYMBOL_LIBRARY_MANAGER::GetAliases( const wxString& aLibrar } -LIB_PART* SYMBOL_LIBRARY_MANAGER::GetBufferedPart( const wxString& aAlias, +LIB_SYMBOL* SYMBOL_LIBRARY_MANAGER::GetBufferedPart( const wxString& aAlias, const wxString& aLibrary ) { wxCHECK( LibraryExists( aLibrary ), nullptr ); // try the library buffers first LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary ); - LIB_PART* bufferedPart = libBuf.GetPart( aAlias ); + LIB_SYMBOL* bufferedPart = libBuf.GetPart( aAlias ); - if( !bufferedPart ) // no buffer part found + if( !bufferedPart ) // no buffer symbol found { - // create a copy of the part + // create a copy of the symbol try { - LIB_PART* part = symTable()->LoadSymbol( aLibrary, aAlias ); + LIB_SYMBOL* symbol = symTable()->LoadSymbol( aLibrary, aAlias ); - if( part == nullptr ) + if( symbol == nullptr ) THROW_IO_ERROR( _( "Symbol not found." ) ); - LIB_PART* bufferedParent = nullptr; + LIB_SYMBOL* bufferedParent = nullptr; // Create parent symbols on demand so parent symbol can be set. - if( part->IsAlias() ) + if( symbol->IsAlias() ) { - std::shared_ptr< LIB_PART > parent = part->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > parent = symbol->GetParent().lock(); wxCHECK_MSG( parent, nullptr, wxString::Format( "Derived symbol '%s' found with undefined parent.", - part->GetName() ) ); + symbol->GetName() ) ); // Check if the parent symbol buffer has already be created. bufferedParent = libBuf.GetPart( parent->GetName() ); if( !bufferedParent ) { - bufferedParent = new LIB_PART( *parent.get() ); + bufferedParent = new LIB_SYMBOL( *parent.get() ); libBuf.CreateBuffer( bufferedParent, new SCH_SCREEN ); } } - bufferedPart = new LIB_PART( *part ); + bufferedPart = new LIB_SYMBOL( *symbol ); if( bufferedParent ) bufferedPart->SetParent( bufferedParent ); @@ -446,35 +447,35 @@ SCH_SCREEN* SYMBOL_LIBRARY_MANAGER::GetScreen( const wxString& aAlias, const wxS wxCHECK( it != m_libs.end(), nullptr ); LIB_BUFFER& buf = it->second; - auto partBuf = buf.GetBuffer( aAlias ); - return partBuf ? partBuf->GetScreen() : nullptr; + auto symbolBuf = buf.GetBuffer( aAlias ); + return symbolBuf ? symbolBuf->GetScreen() : nullptr; } -bool SYMBOL_LIBRARY_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibrary ) +bool SYMBOL_LIBRARY_MANAGER::UpdatePart( LIB_SYMBOL* aSymbol, const wxString& aLibrary ) { wxCHECK( LibraryExists( aLibrary ), false ); - wxCHECK( aPart, false ); + wxCHECK( aSymbol, false ); LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary ); - auto partBuf = libBuf.GetBuffer( aPart->GetName() ); + auto symbolBuf = libBuf.GetBuffer( aSymbol->GetName() ); - if( partBuf ) // Existing symbol. + if( symbolBuf ) // Existing symbol. { - LIB_PART* bufferedPart = const_cast< LIB_PART* >( partBuf->GetPart() ); + LIB_SYMBOL* bufferedPart = const_cast< LIB_SYMBOL* >( symbolBuf->GetPart() ); wxCHECK( bufferedPart, false ); - *bufferedPart = *aPart; - partBuf->GetScreen()->SetContentModified(); + *bufferedPart = *aSymbol; + symbolBuf->GetScreen()->SetContentModified(); } else // New symbol { - LIB_PART* partCopy = new LIB_PART( *aPart, nullptr ); + LIB_SYMBOL* symbolCopy = new LIB_SYMBOL( *aSymbol, nullptr ); - partCopy->SetLibId( LIB_ID( aLibrary, aPart->GetLibId().GetLibItemName() ) ); + symbolCopy->SetLibId( LIB_ID( aLibrary, aSymbol->GetLibId().GetLibItemName() ) ); SCH_SCREEN* screen = new SCH_SCREEN; - libBuf.CreateBuffer( partCopy, screen ); + libBuf.CreateBuffer( symbolCopy, screen ); screen->SetContentModified(); } @@ -482,15 +483,15 @@ bool SYMBOL_LIBRARY_MANAGER::UpdatePart( LIB_PART* aPart, const wxString& aLibra } -bool SYMBOL_LIBRARY_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxString& aOldName, +bool SYMBOL_LIBRARY_MANAGER::UpdatePartAfterRename( LIB_SYMBOL* aSymbol, const wxString& aOldName, const wxString& aLibrary ) { LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary ); - auto partBuf = libBuf.GetBuffer( aOldName ); + auto symbolBuf = libBuf.GetBuffer( aOldName ); - wxCHECK( partBuf, false ); + wxCHECK( symbolBuf, false ); - libBuf.UpdateBuffer( partBuf, aPart ); + libBuf.UpdateBuffer( symbolBuf, aSymbol ); m_frame.SyncLibraries( false ); return true; @@ -504,10 +505,10 @@ bool SYMBOL_LIBRARY_MANAGER::FlushPart( const wxString& aAlias, const wxString& if( it == m_libs.end() ) // no items to flush return true; - auto partBuf = it->second.GetBuffer( aAlias ); - wxCHECK( partBuf, false ); + auto symbolBuf = it->second.GetBuffer( aAlias ); + wxCHECK( symbolBuf, false ); - return it->second.SaveBuffer( partBuf, symTable() ); + return it->second.SaveBuffer( symbolBuf, symTable() ); } @@ -518,9 +519,9 @@ LIB_ID SYMBOL_LIBRARY_MANAGER::RevertPart( const wxString& aAlias, const wxStrin if( it == m_libs.end() ) // no items to flush return LIB_ID( aLibrary, aAlias ); - auto partBuf = it->second.GetBuffer( aAlias ); - wxCHECK( partBuf, LIB_ID( aLibrary, aAlias ) ); - LIB_PART original( *partBuf->GetOriginal() ); + auto symbolBuf = it->second.GetBuffer( aAlias ); + wxCHECK( symbolBuf, LIB_ID( aLibrary, aAlias ) ); + LIB_SYMBOL original( *symbolBuf->GetOriginal() ); if( original.GetName() != aAlias ) { @@ -528,7 +529,7 @@ LIB_ID SYMBOL_LIBRARY_MANAGER::RevertPart( const wxString& aAlias, const wxStrin } else { - partBuf->SetPart( new LIB_PART( original ) ); + symbolBuf->SetPart( new LIB_SYMBOL( original ) ); m_frame.SyncLibraries( false ); } @@ -579,19 +580,19 @@ bool SYMBOL_LIBRARY_MANAGER::RevertAll() bool SYMBOL_LIBRARY_MANAGER::RemovePart( const wxString& aAlias, const wxString& aLibrary ) { LIB_BUFFER& libBuf = getLibraryBuffer( aLibrary ); - auto partBuf = libBuf.GetBuffer( aAlias ); - wxCHECK( partBuf, false ); + auto symbolBuf = libBuf.GetBuffer( aAlias ); + wxCHECK( symbolBuf, false ); bool retv = true; - retv &= libBuf.DeleteBuffer( partBuf ); + retv &= libBuf.DeleteBuffer( symbolBuf ); m_frame.SyncLibraries( false ); return retv; } -LIB_PART* SYMBOL_LIBRARY_MANAGER::GetAlias( const wxString& aAlias, +LIB_SYMBOL* SYMBOL_LIBRARY_MANAGER::GetAlias( const wxString& aAlias, const wxString& aLibrary ) const { // Try the library buffers first @@ -599,14 +600,14 @@ LIB_PART* SYMBOL_LIBRARY_MANAGER::GetAlias( const wxString& aAlias, if( libIt != m_libs.end() ) { - LIB_PART* part = libIt->second.GetPart( aAlias ); + LIB_SYMBOL* symbol = libIt->second.GetPart( aAlias ); - if( part ) - return part; + if( symbol ) + return symbol; } - // Get the original part - LIB_PART* alias = nullptr; + // Get the original symbol + LIB_SYMBOL* alias = nullptr; try { @@ -625,7 +626,7 @@ LIB_PART* SYMBOL_LIBRARY_MANAGER::GetAlias( const wxString& aAlias, bool SYMBOL_LIBRARY_MANAGER::PartExists( const wxString& aAlias, const wxString& aLibrary ) const { auto libBufIt = m_libs.find( aLibrary ); - LIB_PART* alias = nullptr; + LIB_SYMBOL* alias = nullptr; if( libBufIt != m_libs.end() ) return !!libBufIt->second.GetBuffer( aAlias ); @@ -751,10 +752,10 @@ SYMBOL_LIB_TABLE* SYMBOL_LIBRARY_MANAGER::symTable() const } -std::set SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aLibrary ) +std::set SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aLibrary ) { - std::set parts; - wxCHECK( LibraryExists( aLibrary ), parts ); + std::set symbols; + wxCHECK( LibraryExists( aLibrary ), symbols ); try { @@ -763,8 +764,8 @@ std::set SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aL for( const auto& aliasName : aliases ) { - LIB_PART* alias = symTable()->LoadSymbol( aLibrary, aliasName ); - parts.insert( alias ); + LIB_SYMBOL* alias = symTable()->LoadSymbol( aLibrary, aliasName ); + symbols.insert( alias ); } } catch( const IO_ERROR& e ) @@ -772,7 +773,7 @@ std::set SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aL wxLogMessage( _( "Cannot enumerate library \"%s\" (%s)" ), aLibrary, e.What() ); } - return parts; + return symbols; } @@ -788,33 +789,33 @@ SYMBOL_LIBRARY_MANAGER::LIB_BUFFER& SYMBOL_LIBRARY_MANAGER::getLibraryBuffer( auto ret = m_libs.emplace( aLibrary, LIB_BUFFER( aLibrary ) ); LIB_BUFFER& buf = ret.first->second; - for( auto part : getOriginalParts( aLibrary ) ) + for( auto symbol : getOriginalParts( aLibrary ) ) { - LIB_PART* newSymbol; + LIB_SYMBOL* newSymbol; - if( part->IsAlias() ) + if( symbol->IsAlias() ) { - std::shared_ptr< LIB_PART > oldParent = part->GetParent().lock(); + std::shared_ptr< LIB_SYMBOL > oldParent = symbol->GetParent().lock(); wxCHECK_MSG( oldParent, buf, wxString::Format( "Derived symbol '%s' found with undefined parent.", - part->GetName() ) ); + symbol->GetName() ) ); - LIB_PART* libParent = buf.GetPart( oldParent->GetName() ); + LIB_SYMBOL* libParent = buf.GetPart( oldParent->GetName() ); if( !libParent ) { - libParent = new LIB_PART( *oldParent.get() ); + libParent = new LIB_SYMBOL( *oldParent.get() ); buf.CreateBuffer( libParent, new SCH_SCREEN ); } - newSymbol = new LIB_PART( *part ); + newSymbol = new LIB_SYMBOL( *symbol ); newSymbol->SetParent( libParent ); buf.CreateBuffer( newSymbol, new SCH_SCREEN ); } - else if( !buf.GetPart( part->GetName() ) ) + else if( !buf.GetPart( symbol->GetName() ) ) { - buf.CreateBuffer( new LIB_PART( *part ), new SCH_SCREEN ); + buf.CreateBuffer( new LIB_SYMBOL( *symbol ), new SCH_SCREEN ); } } @@ -822,12 +823,12 @@ SYMBOL_LIBRARY_MANAGER::LIB_BUFFER& SYMBOL_LIBRARY_MANAGER::getLibraryBuffer( } -SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PART_BUFFER( LIB_PART* aPart, +SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PART_BUFFER( LIB_SYMBOL* aSymbol, std::unique_ptr aScreen ) : m_screen( std::move( aScreen ) ), - m_part( aPart ) + m_part( aSymbol ) { - m_original = new LIB_PART( *aPart ); + m_original = new LIB_SYMBOL( *aSymbol ); } @@ -838,12 +839,12 @@ SYMBOL_LIBRARY_MANAGER::PART_BUFFER::~PART_BUFFER() } -void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetPart( LIB_PART* aPart ) +void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetPart( LIB_SYMBOL* aSymbol ) { - wxCHECK( m_part != aPart, /* void */ ); - wxASSERT( aPart ); + wxCHECK( m_part != aSymbol, /* void */ ); + wxASSERT( aSymbol ); delete m_part; - m_part = aPart; + m_part = aSymbol; // If the part moves libraries then the original moves with it if( m_original->GetLibId().GetLibNickname() != m_part->GetLibId().GetLibNickname() ) @@ -854,12 +855,12 @@ void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetPart( LIB_PART* aPart ) } -void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetOriginal( LIB_PART* aPart ) +void SYMBOL_LIBRARY_MANAGER::PART_BUFFER::SetOriginal( LIB_SYMBOL* aSymbol ) { - wxCHECK( m_original != aPart, /* void */ ); - wxASSERT( aPart ); + wxCHECK( m_original != aSymbol, /* void */ ); + wxASSERT( aSymbol ); delete m_original; - m_original = aPart; + m_original = aSymbol; // The original is not allowed to have a different library than its part if( m_original->GetLibId().GetLibNickname() != m_part->GetLibId().GetLibNickname() ) @@ -876,28 +877,28 @@ bool SYMBOL_LIBRARY_MANAGER::PART_BUFFER::IsModified() const } -LIB_PART* SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetPart( const wxString& aAlias ) const +LIB_SYMBOL* SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetPart( const wxString& aAlias ) const { auto buf = GetBuffer( aAlias ); if( !buf ) return nullptr; - LIB_PART* part = buf->GetPart(); + LIB_SYMBOL* symbol = buf->GetPart(); - wxCHECK( part, nullptr ); + wxCHECK( symbol, nullptr ); - return part; + return symbol; } -bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::CreateBuffer( LIB_PART* aCopy, SCH_SCREEN* aScreen ) +bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::CreateBuffer( LIB_SYMBOL* aCopy, SCH_SCREEN* aScreen ) { wxASSERT( aCopy ); wxASSERT( aCopy->GetLib() == nullptr ); std::unique_ptr screen( aScreen ); - auto partBuf = std::make_shared( aCopy, std::move( screen ) ); - m_parts.push_back( partBuf ); + auto symbolBuf = std::make_shared( aCopy, std::move( screen ) ); + m_parts.push_back( symbolBuf ); // Set the parent library name, // otherwise it is empty as no library has been given as the owner during object construction @@ -911,11 +912,11 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::CreateBuffer( LIB_PART* aCopy, SCH_SCRE bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( - SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aPartBuf, LIB_PART* aCopy ) + SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy ) { - wxCHECK( aCopy && aPartBuf, false ); + wxCHECK( aCopy && aSymbolBuf, false ); - LIB_PART* bufferedPart = aPartBuf->GetPart(); + LIB_SYMBOL* bufferedPart = aSymbolBuf->GetPart(); wxCHECK( bufferedPart, false ); @@ -927,16 +928,16 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( - SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aPartBuf ) + SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aSymbolBuf ) { - auto partBufIt = std::find( m_parts.begin(), m_parts.end(), aPartBuf ); + auto partBufIt = std::find( m_parts.begin(), m_parts.end(), aSymbolBuf ); wxCHECK( partBufIt != m_parts.end(), false ); bool retv = true; // Remove all derived symbols to prevent broken inheritance. - if( aPartBuf->GetPart()->IsRoot() && HasDerivedSymbols( aPartBuf->GetPart()->GetName() ) - && removeChildSymbols( aPartBuf ) == 0 ) + if( aSymbolBuf->GetPart()->IsRoot() && HasDerivedSymbols( aSymbolBuf->GetPart()->GetName() ) + && removeChildSymbols( aSymbolBuf ) == 0 ) { retv = false; } @@ -950,11 +951,11 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( - SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aPartBuf, SYMBOL_LIB_TABLE* aLibTable ) + SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable ) { - wxCHECK( aPartBuf, false ); - LIB_PART* part = aPartBuf->GetPart(); - LIB_PART* originalPart = aPartBuf->GetOriginal(); + wxCHECK( aSymbolBuf, false ); + LIB_SYMBOL* part = aSymbolBuf->GetPart(); + LIB_SYMBOL* originalPart = aSymbolBuf->GetOriginal(); wxCHECK( part && originalPart, false ); SYMBOL_LIB_TABLE::SAVE_T result; PROPERTIES properties; @@ -969,27 +970,27 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( if( part->IsAlias() ) { - LIB_PART* newCachedPart = new LIB_PART( *part ); - std::shared_ptr< LIB_PART > bufferedParent = part->GetParent().lock(); + LIB_SYMBOL* newCachedPart = new LIB_SYMBOL( *part ); + std::shared_ptr< LIB_SYMBOL > bufferedParent = part->GetParent().lock(); wxCHECK( bufferedParent, false ); - LIB_PART* cachedParent = aLibTable->LoadSymbol( m_libName, bufferedParent->GetName() ); + LIB_SYMBOL* cachedParent = aLibTable->LoadSymbol( m_libName, bufferedParent->GetName() ); if( !cachedParent ) { - cachedParent = new LIB_PART( *bufferedParent.get() ); + cachedParent = new LIB_SYMBOL( *bufferedParent.get() ); newCachedPart->SetParent( cachedParent ); result = aLibTable->SaveSymbol( m_libName, cachedParent ); wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false ); result = aLibTable->SaveSymbol( m_libName, newCachedPart ); wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false ); - LIB_PART* originalParent = new LIB_PART( *bufferedParent.get() ); - aPartBuf->SetOriginal( originalParent ); - originalPart = new LIB_PART( *part ); + LIB_SYMBOL* originalParent = new LIB_SYMBOL( *bufferedParent.get() ); + aSymbolBuf->SetOriginal( originalParent ); + originalPart = new LIB_SYMBOL( *part ); originalPart->SetParent( originalParent ); - aPartBuf->SetOriginal( originalPart ); + aSymbolBuf->SetOriginal( originalPart ); } else { @@ -1000,9 +1001,9 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR originalBufferedParent = GetBuffer( bufferedParent->GetName() ); wxCHECK( originalBufferedParent, false ); - originalPart = new LIB_PART( *part ); + originalPart = new LIB_SYMBOL( *part ); originalPart->SetParent( originalBufferedParent->GetPart() ); - aPartBuf->SetOriginal( originalPart ); + aSymbolBuf->SetOriginal( originalPart ); } } else @@ -1011,20 +1012,20 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( if( GetDerivedSymbolNames( part->GetName(), derivedSymbols ) == 0 ) { - result = aLibTable->SaveSymbol( m_libName, new LIB_PART( *part ) ); + result = aLibTable->SaveSymbol( m_libName, new LIB_SYMBOL( *part ) ); wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false ); - aPartBuf->SetOriginal( new LIB_PART( *part ) ); + aSymbolBuf->SetOriginal( new LIB_SYMBOL( *part ) ); } else { - LIB_PART* parentSymbol = new LIB_PART( *part ); + LIB_SYMBOL* parentSymbol = new LIB_SYMBOL( *part ); aLibTable->SaveSymbol( m_libName, parentSymbol ); for( auto entry : derivedSymbols ) { SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR symbol = GetBuffer( entry ); - LIB_PART* derivedSymbol = new LIB_PART( *symbol->GetPart() ); + LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetPart() ); derivedSymbol->SetParent( parentSymbol ); result = aLibTable->SaveSymbol( m_libName, derivedSymbol ); wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false ); @@ -1038,12 +1039,12 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( - SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aPartBuf, const wxString& aFileName, + SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aSymbolBuf, const wxString& aFileName, SCH_PLUGIN* aPlugin, bool aBuffer ) { - wxCHECK( aPartBuf, false ); - LIB_PART* part = aPartBuf->GetPart(); - LIB_PART* originalPart = aPartBuf->GetOriginal(); + wxCHECK( aSymbolBuf, false ); + LIB_SYMBOL* part = aSymbolBuf->GetPart(); + LIB_SYMBOL* originalPart = aSymbolBuf->GetOriginal(); wxCHECK( part && originalPart, false ); wxCHECK( !aFileName.IsEmpty(), false ); @@ -1062,12 +1063,12 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( if( part->IsAlias() ) { - LIB_PART* newCachedPart = new LIB_PART( *part ); - std::shared_ptr< LIB_PART > bufferedParent = part->GetParent().lock(); + LIB_SYMBOL* newCachedPart = new LIB_SYMBOL( *part ); + std::shared_ptr< LIB_SYMBOL > bufferedParent = part->GetParent().lock(); wxCHECK( bufferedParent, false ); - LIB_PART* cachedParent = nullptr; + LIB_SYMBOL* cachedParent = nullptr; try { @@ -1080,7 +1081,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( if( !cachedParent ) { - cachedParent = new LIB_PART( *bufferedParent.get() ); + cachedParent = new LIB_SYMBOL( *bufferedParent.get() ); newCachedPart->SetParent( cachedParent ); try @@ -1103,11 +1104,11 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( return false; } - LIB_PART* originalParent = new LIB_PART( *bufferedParent.get() ); - aPartBuf->SetOriginal( originalParent ); - originalPart = new LIB_PART( *part ); + LIB_SYMBOL* originalParent = new LIB_SYMBOL( *bufferedParent.get() ); + aSymbolBuf->SetOriginal( originalParent ); + originalPart = new LIB_SYMBOL( *part ); originalPart->SetParent( originalParent ); - aPartBuf->SetOriginal( originalPart ); + aSymbolBuf->SetOriginal( originalPart ); } else { @@ -1126,9 +1127,9 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR originalBufferedParent = GetBuffer( bufferedParent->GetName() ); wxCHECK( originalBufferedParent, false ); - originalPart = new LIB_PART( *part ); + originalPart = new LIB_SYMBOL( *part ); originalPart->SetParent( originalBufferedParent->GetPart() ); - aPartBuf->SetOriginal( originalPart ); + aSymbolBuf->SetOriginal( originalPart ); } } else @@ -1139,7 +1140,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( { try { - aPlugin->SaveSymbol( aFileName, new LIB_PART( *part ), + aPlugin->SaveSymbol( aFileName, new LIB_SYMBOL( *part ), aBuffer ? &properties : nullptr ); } catch( const IO_ERROR& ioe ) @@ -1148,11 +1149,11 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( return false; } - aPartBuf->SetOriginal( new LIB_PART( *part ) ); + aSymbolBuf->SetOriginal( new LIB_SYMBOL( *part ) ); } else { - LIB_PART* parentSymbol = new LIB_PART( *part ); + LIB_SYMBOL* parentSymbol = new LIB_SYMBOL( *part ); // Save the modified root symbol. try @@ -1165,18 +1166,18 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( return false; } - aPartBuf->SetOriginal( new LIB_PART( *part ) ); + aSymbolBuf->SetOriginal( new LIB_SYMBOL( *part ) ); // Save the derived symbols. for( auto entry : derivedSymbols ) { SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR symbol = GetBuffer( entry ); - LIB_PART* derivedSymbol = new LIB_PART( *symbol->GetPart() ); + LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetPart() ); derivedSymbol->SetParent( parentSymbol ); try { - aPlugin->SaveSymbol( aFileName, new LIB_PART( *derivedSymbol ), + aPlugin->SaveSymbol( aFileName, new LIB_SYMBOL( *derivedSymbol ), aBuffer ? &properties : nullptr ); } catch( const IO_ERROR& ioe ) @@ -1262,9 +1263,9 @@ size_t SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetDerivedSymbolNames( const wxString int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols( - SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aPartBuf ) + SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR aSymbolBuf ) { - wxCHECK( aPartBuf && aPartBuf->GetPart()->IsRoot(), 0 ); + wxCHECK( aSymbolBuf && aSymbolBuf->GetPart()->IsRoot(), 0 ); int cnt = 0; std::deque< SYMBOL_LIBRARY_MANAGER::PART_BUFFER::PTR >::iterator it = m_parts.begin(); @@ -1282,9 +1283,9 @@ int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols( wxCHECK2( parent, ++it; continue ); - if( parent->GetName() == aPartBuf->GetPart()->GetName() ) + if( parent->GetName() == aSymbolBuf->GetPart()->GetName() ) { - wxCHECK2( parent == aPartBuf->GetPart()->SharedPtr(), ++it; continue ); + wxCHECK2( parent == aSymbolBuf->GetPart()->SharedPtr(), ++it; continue ); m_deleted.emplace_back( *it ); it = m_parts.erase( it ); diff --git a/eeschema/symbol_editor/symbol_library_manager.h b/eeschema/symbol_editor/symbol_library_manager.h index cbeebfb3d4..7ea68e64c7 100644 --- a/eeschema/symbol_editor/symbol_library_manager.h +++ b/eeschema/symbol_editor/symbol_library_manager.h @@ -37,7 +37,7 @@ #include #include -class LIB_PART; +class LIB_SYMBOL; class PART_LIB; class PROGRESS_REPORTER; class SCH_PLUGIN; @@ -92,7 +92,7 @@ public: */ SYMBOL_LIB_TABLE_ROW* GetLibrary( const wxString& aLibrary ) const; - std::list GetAliases( const wxString& aLibrary ) const; + std::list GetAliases( const wxString& aLibrary ) const; /** * Create an empty library and adds it to the library table. The library file is created. @@ -115,13 +115,13 @@ public: * The library buffer creates a copy of the part. * It is required to save the library to use the updated part in the schematic editor. */ - bool UpdatePart( LIB_PART* aPart, const wxString& aLibrary ); + bool UpdatePart( LIB_SYMBOL* aSymbol, const wxString& aLibrary ); /** * Update the part buffer with a new version of the part when the name has changed. * The old library buffer will be deleted and a new one created with the new name. */ - bool UpdatePartAfterRename( LIB_PART* aPart, const wxString& oldAlias, + bool UpdatePartAfterRename( LIB_SYMBOL* aSymbol, const wxString& oldAlias, const wxString& aLibrary ); /** @@ -131,16 +131,16 @@ public: bool RemovePart( const wxString& aName, const wxString& aLibrary ); /** - * Return either an alias of a working LIB_PART copy, or alias of the original part if there + * Return either an alias of a working LIB_SYMBOL copy, or alias of the original part if there * is no working copy. */ - LIB_PART* GetAlias( const wxString& aAlias, const wxString& aLibrary ) const; + LIB_SYMBOL* GetAlias( const wxString& aAlias, const wxString& aLibrary ) const; /** * Return the part copy from the buffer. In case it does not exist yet, the copy is created. * #SYMBOL_LIBRARY_MANAGER retains the ownership. */ - LIB_PART* GetBufferedPart( const wxString& aAlias, const wxString& aLibrary ); + LIB_SYMBOL* GetBufferedPart( const wxString& aAlias, const wxString& aLibrary ); /** * Return the screen used to edit a specific part. #SYMBOL_LIBRARY_MANAGER retains the @@ -270,18 +270,18 @@ private: return static_cast( m_adapter.get() ); } - ///< Class to store a working copy of a LIB_PART object and editor context. + ///< Class to store a working copy of a LIB_SYMBOL object and editor context. class PART_BUFFER { public: - PART_BUFFER( LIB_PART* aPart = nullptr, std::unique_ptr aScreen = nullptr ); + PART_BUFFER( LIB_SYMBOL* aSymbol = nullptr, std::unique_ptr aScreen = nullptr ); ~PART_BUFFER(); - LIB_PART* GetPart() const { return m_part; } - void SetPart( LIB_PART* aPart ); + LIB_SYMBOL* GetPart() const { return m_part; } + void SetPart( LIB_SYMBOL* aSymbol ); - LIB_PART* GetOriginal() const { return m_original; } - void SetOriginal( LIB_PART* aPart ); + LIB_SYMBOL* GetOriginal() const { return m_original; } + void SetOriginal( LIB_SYMBOL* aSymbol ); bool IsModified() const; SCH_SCREEN* GetScreen() const { return m_screen.get(); } @@ -305,8 +305,8 @@ private: private: std::unique_ptr m_screen; - LIB_PART* m_part; // Working copy - LIB_PART* m_original; // Initial state of the part + LIB_SYMBOL* m_part; // Working copy + LIB_SYMBOL* m_original; // Initial state of the part }; @@ -335,16 +335,16 @@ private: int GetHash() const { return m_hash; } - ///< Return the working copy of a LIB_PART root object with specified alias. - LIB_PART* GetPart( const wxString& aAlias ) const; + ///< Return the working copy of a LIB_SYMBOL root object with specified alias. + LIB_SYMBOL* GetPart( const wxString& aAlias ) const; ///< Create a new buffer to store a part. LIB_BUFFER takes ownership of aCopy. - bool CreateBuffer( LIB_PART* aCopy, SCH_SCREEN* aScreen ); + bool CreateBuffer( LIB_SYMBOL* aCopy, SCH_SCREEN* aScreen ); ///< Update the buffered part with the contents of \a aCopy. - bool UpdateBuffer( PART_BUFFER::PTR aPartBuf, LIB_PART* aCopy ); + bool UpdateBuffer( PART_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy ); - bool DeleteBuffer( PART_BUFFER::PTR aPartBuf ); + bool DeleteBuffer( PART_BUFFER::PTR aSymbolBuf ); void ClearDeletedBuffer() { @@ -353,14 +353,14 @@ private: ///< Save stored modifications to Symbol Lib Table. It may result in saving the symbol ///< to disk as well, depending on the row properties. - bool SaveBuffer( PART_BUFFER::PTR aPartBuf, SYMBOL_LIB_TABLE* aLibTable ); + bool SaveBuffer( PART_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable ); ///< Save stored modifications using a plugin. aBuffer decides whether the changes ///< should be cached or stored directly to the disk (for SCH_LEGACY_PLUGIN). - bool SaveBuffer( PART_BUFFER::PTR aPartBuf, const wxString& aFileName, + bool SaveBuffer( PART_BUFFER::PTR aSymbolBuf, const wxString& aFileName, SCH_PLUGIN* aPlugin, bool aBuffer ); - ///< Return a part buffer with LIB_PART holding a particular alias + ///< Return a part buffer with LIB_SYMBOL holding a particular alias PART_BUFFER::PTR GetBuffer( const wxString& aAlias ) const; ///< Return all buffered parts @@ -399,7 +399,7 @@ private: * @param aParent is the #PART_BUFFER to check against. * @return the count of #PART_BUFFER objects removed from the library. */ - int removeChildSymbols( PART_BUFFER::PTR aPartBuf ); + int removeChildSymbols( PART_BUFFER::PTR aSymbolBuf ); std::deque m_parts; std::deque m_deleted; // Buffer for deleted parts until library is saved @@ -408,9 +408,9 @@ private: }; /** - * Return a set of #LIB_PART objects belonging to the original library. + * Return a set of #LIB_SYMBOL objects belonging to the original library. */ - std::set getOriginalParts( const wxString& aLibrary ); + std::set getOriginalParts( const wxString& aLibrary ); /** * Return an existing library buffer or creates one to using Symbol Library Table to get diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 2025217ae6..6b085e6fa7 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -109,6 +109,7 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) if( in->CurTok() != T_sym_lib_table ) { in->NeedLEFT(); + if( ( tok = in->NextTok() ) != T_sym_lib_table ) in->Expecting( T_sym_lib_table ); } @@ -317,7 +318,7 @@ SYMBOL_LIB_TABLE_ROW* SYMBOL_LIB_TABLE::FindRow( const wxString& aNickname, bool } -void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector& aSymbolList, +void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector& aSymbolList, const wxString& aNickname, bool aPowerSymbolsOnly ) { SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); @@ -339,47 +340,47 @@ void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector& aSymbolList, // Therefore footprints cannot know their own library nickname when residing in // a symbol library. // Only at this API layer can we tell the symbol about its actual library nickname. - for( LIB_PART* part : aSymbolList ) + for( LIB_SYMBOL* symbol : aSymbolList ) { - LIB_ID id = part->GetLibId(); + LIB_ID id = symbol->GetLibId(); id.SetLibNickname( row->GetNickName() ); - part->SetLibId( id ); + symbol->SetLibId( id ); } } -LIB_PART* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxString& aSymbolName ) +LIB_SYMBOL* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxString& aSymbolName ) { SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); if( !row || !row->plugin ) return nullptr; - LIB_PART* part = row->plugin->LoadSymbol( row->GetFullURI( true ), aSymbolName, - row->GetProperties() ); + LIB_SYMBOL* symbol = row->plugin->LoadSymbol( row->GetFullURI( true ), aSymbolName, + row->GetProperties() ); - if( part == nullptr ) - return part; + if( symbol == nullptr ) + return symbol; // The library cannot know its own name, because it might have been renamed or moved. // Therefore footprints cannot know their own library nickname when residing in // a symbol library. // Only at this API layer can we tell the symbol about its actual library nickname. - if( part ) + if( symbol ) { - LIB_ID id = part->GetLibId(); + LIB_ID id = symbol->GetLibId(); id.SetLibNickname( row->GetNickName() ); - part->SetLibId( id ); + symbol->SetLibId( id ); } - return part; + return symbol; } SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname, - const LIB_PART* aSymbol, bool aOverwrite ) + const LIB_SYMBOL* aSymbol, bool aOverwrite ) { const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true ); wxCHECK( row && row->plugin, SAVE_SKIPPED ); @@ -394,9 +395,9 @@ SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname wxString name = aSymbol->GetLibId().GetLibItemName(); - std::unique_ptr< LIB_PART > symbol( row->plugin->LoadSymbol( row->GetFullURI( true ), - name, - row->GetProperties() ) ); + std::unique_ptr< LIB_SYMBOL > symbol( row->plugin->LoadSymbol( row->GetFullURI( true ), + name, + row->GetProperties() ) ); if( symbol.get() ) return SAVE_SKIPPED; @@ -455,7 +456,7 @@ void SYMBOL_LIB_TABLE::CreateSymbolLib( const wxString& aNickname ) } -LIB_PART* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId ) +LIB_SYMBOL* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId ) { wxString nickname = aLibId.GetLibNickname(); wxString name = aLibId.GetLibItemName(); @@ -475,7 +476,7 @@ LIB_PART* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId { // FootprintLoad() returns NULL on not found, does not throw exception // unless there's an IO_ERROR. - LIB_PART* ret = LoadSymbol( nicks[i], name ); + LIB_SYMBOL* ret = LoadSymbol( nicks[i], name ); if( ret ) return ret; diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h index 879d8943d9..dd54fd7d4f 100644 --- a/eeschema/symbol_lib_table.h +++ b/eeschema/symbol_lib_table.h @@ -29,7 +29,7 @@ #include #include -//class LIB_PART; +//class LIB_SYMBOL; class SYMBOL_LIB_TABLE_GRID; class DIALOG_SYMBOL_LIB_TABLE; @@ -156,22 +156,22 @@ public: void EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames, bool aPowerSymbolsOnly = false ); - void LoadSymbolLib( std::vector& aAliasList, const wxString& aNickname, + void LoadSymbolLib( std::vector& aAliasList, const wxString& aNickname, bool aPowerSymbolsOnly = false ); /** - * Load a #LIB_PART having @a aName from the library given by @a aNickname. + * Load a #LIB_SYMBOL having @a aName from the library given by @a aNickname. * * @param aNickname is a locator for the "library", it is a "name" in #LIB_TABLE_ROW - * @param aName is the name of the #LIB_PART to load. + * @param aName is the name of the #LIB_SYMBOL to load. * @param aFlatten set to true to flatten derived parts. * @return the symbol alias if found or NULL if not found. * @throw IO_ERROR if the library cannot be found or read. No exception * is thrown in the case where \a aNickname cannot be found. */ - LIB_PART* LoadSymbol( const wxString& aNickname, const wxString& aName ); + LIB_SYMBOL* LoadSymbol( const wxString& aNickname, const wxString& aName ); - LIB_PART* LoadSymbol( const LIB_ID& aLibId ) + LIB_SYMBOL* LoadSymbol( const LIB_ID& aLibId ) { return LoadSymbol( aLibId.GetLibNickname(), aLibId.GetLibItemName() ); } @@ -188,8 +188,8 @@ public: /** * Write @a aSymbol to an existing library given by @a aNickname. * - * If a #LIB_PART by the same name already exists or there are any conflicting alias - * names, the new #LIB_PART will silently overwrite any existing aliases and/or part + * If a #LIB_SYMBOL by the same name already exists or there are any conflicting alias + * names, the new #LIB_SYMBOL will silently overwrite any existing aliases and/or part * because libraries cannot have duplicate alias names. It is the responsibility of * the caller to check the library for conflicts before saving. * @@ -201,7 +201,7 @@ public: * @return SAVE_T - SAVE_OK or SAVE_SKIPPED. If error saving, then IO_ERROR is thrown. * @throw IO_ERROR if there is a problem saving the symbol. */ - SAVE_T SaveSymbol( const wxString& aNickname, const LIB_PART* aSymbol, + SAVE_T SaveSymbol( const wxString& aNickname, const LIB_SYMBOL* aSymbol, bool aOverwrite = true ); /** @@ -239,7 +239,7 @@ public: //-------------------------------- /** - * Load a #LIB_PART having @a aFootprintId with possibly an empty library nickname. + * Load a #LIB_SYMBOL having @a aFootprintId with possibly an empty library nickname. * * @param aId the library nickname and name of the symbol to load. * @return the library symbol if found (the library owns it) or NULL if not found. @@ -247,7 +247,7 @@ public: * is thrown in the case where aId cannot be found. * @throw PARSE_ERROR if @a aId is not parsed OK. */ - LIB_PART* LoadSymbolWithOptionalNickname( const LIB_ID& aId ); + LIB_SYMBOL* LoadSymbolWithOptionalNickname( const LIB_ID& aId ); /** * Load the global symbol library table into \a aTable. diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index 20914647a7..04b07de21a 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -71,7 +71,7 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector& aNick // Disable KIID generation: not needed for library parts; sometimes very slow KIID::CreateNilUuids( true ); - std::unordered_map> loadedSymbols; + std::unordered_map> loadedSymbols; SYMBOL_ASYNC_LOADER loader( aNicknames, m_libs, GetFilter() == LIB_TREE_MODEL_ADAPTER::SYM_FILTER_POWER, @@ -113,7 +113,7 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector& aNick if( loadedSymbols.size() > 0 ) { - for( const std::pair>& pair : loadedSymbols ) + for( const std::pair>& pair : loadedSymbols ) { std::vector treeItems( pair.second.begin(), pair.second.end() ); DoAddLibrary( pair.first, m_libs->GetDescription( pair.first ), treeItems, false ); @@ -141,7 +141,7 @@ void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector& aNick void SYMBOL_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname ) { bool onlyPowerSymbols = ( GetFilter() == SYM_FILTER_POWER ); - std::vector symbols; + std::vector symbols; std::vector comp_list; try diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index 80d9ad06b8..7be81005f6 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -146,19 +146,19 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNo if( hashIt == m_libHashes.end() ) { // add a new library - for( LIB_PART* alias : m_libMgr->GetAliases( aLibNode.m_Name ) ) + for( LIB_SYMBOL* alias : m_libMgr->GetAliases( aLibNode.m_Name ) ) aLibNode.AddItem( alias ); } else if( hashIt->second != m_libMgr->GetLibraryHash( aLibNode.m_Name ) ) { // update an existing library - std::list aliases = m_libMgr->GetAliases( aLibNode.m_Name ); + std::list aliases = m_libMgr->GetAliases( aLibNode.m_Name ); // remove the common part from the aliases list for( auto nodeIt = aLibNode.m_Children.begin(); nodeIt != aLibNode.m_Children.end(); /**/ ) { auto aliasIt = std::find_if( aliases.begin(), aliases.end(), - [&] ( const LIB_PART* a ) + [&] ( const LIB_SYMBOL* a ) { return a->GetName() == (*nodeIt)->m_Name; } ); @@ -179,7 +179,7 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNo } // now the aliases list contains only new aliases that need to be added to the tree - for( LIB_PART* alias : aliases ) + for( LIB_SYMBOL* alias : aliases ) aLibNode.AddItem( alias ); } @@ -287,7 +287,7 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un if( aCol != 0 ) return false; - LIB_PART* curPart = m_frame->GetCurPart(); + LIB_SYMBOL* curSymbol = m_frame->GetCurPart(); switch( node->m_Type ) { @@ -296,7 +296,7 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un aAttr.SetBold( m_libMgr->IsLibraryModified( node->m_Name ) ); // mark the current library with background color - if( curPart && curPart->GetLibId().GetLibNickname() == node->m_LibId.GetLibNickname() ) + if( curSymbol && curSymbol->GetLibId().GetLibNickname() == node->m_LibId.GetLibNickname() ) { #ifdef __WXGTK__ // The native wxGTK+ impl ignores background colour, so set the text colour instead. @@ -317,7 +317,7 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un aAttr.SetItalic( !node->m_IsRoot ); // mark the current part with background color - if( curPart && curPart->GetLibId() == node->m_LibId ) + if( curSymbol && curSymbol->GetLibId() == node->m_LibId ) { #ifdef __WXGTK__ // The native wxGTK+ impl ignores background colour, so set the text colour instead. diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 05b1bb5617..5e86fb3296 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -275,7 +275,7 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() auto demorganCond = [this] ( const SELECTION& ) { - LIB_PART* symbol = GetSelectedSymbol(); + LIB_SYMBOL* symbol = GetSelectedSymbol(); return symbol && symbol->HasConversion(); }; @@ -295,7 +295,7 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() auto haveDatasheetCond = [this] ( const SELECTION& ) { - LIB_PART* symbol = GetSelectedSymbol(); + LIB_SYMBOL* symbol = GetSelectedSymbol(); return symbol && !symbol->GetDatasheetField().GetText().IsEmpty(); }; @@ -323,9 +323,9 @@ void SYMBOL_VIEWER_FRAME::SetUnitAndConvert( int aUnit, int aConvert ) } -LIB_PART* SYMBOL_VIEWER_FRAME::GetSelectedSymbol() const +LIB_SYMBOL* SYMBOL_VIEWER_FRAME::GetSelectedSymbol() const { - LIB_PART* symbol = nullptr; + LIB_SYMBOL* symbol = nullptr; if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() ) symbol = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName ); @@ -336,7 +336,7 @@ LIB_PART* SYMBOL_VIEWER_FRAME::GetSelectedSymbol() const void SYMBOL_VIEWER_FRAME::updatePreviewSymbol() { - LIB_PART* symbol = GetSelectedSymbol(); + LIB_SYMBOL* symbol = GetSelectedSymbol(); KIGFX::SCH_VIEW* view = GetCanvas()->GetView(); if( m_previewItem ) @@ -356,7 +356,7 @@ void SYMBOL_VIEWER_FRAME::updatePreviewSymbol() view->Add( m_previewItem ); wxString parentName; - std::shared_ptr parent = m_previewItem->GetParent().lock(); + std::shared_ptr parent = m_previewItem->GetParent().lock(); if( parent ) parentName = parent->GetName(); @@ -440,12 +440,12 @@ void SYMBOL_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv ) void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent ) { - LIB_PART* part = GetSelectedSymbol(); + LIB_SYMBOL* symbol = GetSelectedSymbol(); int unit_count = 1; - if( part ) - unit_count = std::max( part->GetUnitCount(), 1 ); + if( symbol ) + unit_count = std::max( symbol->GetUnitCount(), 1 ); m_unitChoice->Enable( unit_count > 1 ); @@ -778,17 +778,17 @@ void SYMBOL_VIEWER_FRAME::SetFilter( const SCHLIB_FILTER* aFilter ) const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const { - LIB_PART* part = GetSelectedSymbol(); + LIB_SYMBOL* symbol = GetSelectedSymbol(); - if( !part ) + if( !symbol ) { return BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) ); } else { - std::shared_ptr< LIB_PART > tmp; + std::shared_ptr< LIB_SYMBOL > tmp; - tmp = ( part->IsAlias() ) ? part->GetParent().lock() : part->SharedPtr(); + tmp = ( symbol->IsAlias() ) ? symbol->GetParent().lock() : symbol->SharedPtr(); wxCHECK( tmp, BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) ) ); @@ -825,7 +825,7 @@ void SYMBOL_VIEWER_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) const auto libNicknames = libs->GetLogicalLibs(); static_cast( adapter.get() )->AddLibraries( libNicknames, this ); - LIB_PART* current = GetSelectedSymbol(); + LIB_SYMBOL* current = GetSelectedSymbol(); LIB_ID id; int unit = 0; diff --git a/eeschema/symbol_viewer_frame.h b/eeschema/symbol_viewer_frame.h index b3d9555e76..a286a9c037 100644 --- a/eeschema/symbol_viewer_frame.h +++ b/eeschema/symbol_viewer_frame.h @@ -33,7 +33,7 @@ class wxListBox; class SCHLIB_FILTER; -class LIB_PART; +class LIB_SYMBOL; class SYMBOL_LIB_TABLE_ROW; @@ -135,7 +135,7 @@ public: int GetUnit() const { return m_unit; } int GetConvert() const { return m_convert; } - LIB_PART* GetSelectedSymbol() const; + LIB_SYMBOL* GetSelectedSymbol() const; const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override; @@ -189,7 +189,7 @@ private: */ bool m_selection_changed; - LIB_PART* m_previewItem; + LIB_SYMBOL* m_previewItem; DECLARE_EVENT_TABLE() }; diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index bb98f2201d..dfb84f86b1 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -64,7 +64,8 @@ bool EE_INSPECTION_TOOL::Init() selToolMenu.AddItem( EE_ACTIONS::excludeMarker, singleMarkerCondition, 100 ); - selToolMenu.AddItem( EE_ACTIONS::showDatasheet, EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 ); + selToolMenu.AddItem( EE_ACTIONS::showDatasheet, + EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 ); return true; } @@ -200,13 +201,13 @@ bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) { - LIB_PART* part = static_cast( m_frame )->GetCurPart(); + LIB_SYMBOL* symbol = static_cast( m_frame )->GetCurPart(); - if( !part ) + if( !symbol ) return 0; LIB_PINS pinList; - part->GetPins( pinList ); + symbol->GetPins( pinList ); // Sort pins by pin num, so 2 duplicate pins // (pins with the same number) will be consecutive in list @@ -240,9 +241,9 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) if( next->GetName() != "~" && !next->GetName().IsEmpty() ) nextName = " '" + next->GetName() + "'"; - if( part->HasConversion() && next->GetConvert() ) + if( symbol->HasConversion() && next->GetConvert() ) { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Duplicate pin %s %s at location (%.3f, %.3f)" " conflicts with pin %s%s at location (%.3f, %.3f)" @@ -271,7 +272,7 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) } else { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Duplicate pin %s %s at location (%.3f, %.3f)" " conflicts with pin %s%s at location (%.3f, %.3f)." ), @@ -311,14 +312,14 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) else pinName = "'" + pinName + "'"; - if( !part->IsPower() + if( !symbol->IsPower() && pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN && !pin->IsVisible() ) { // hidden power pin - if( part->HasConversion() && pin->GetConvert() ) + if( symbol->HasConversion() && pin->GetConvert() ) { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Hidden power pin %s %s at location (%.3f, %.3f)" " of converted." ), @@ -338,7 +339,7 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) } else { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Hidden power pin %s %s at location (%.3f, %.3f)." ), pin->GetNumber(), @@ -366,9 +367,9 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) || ( (pin->GetPosition().y % clamped_grid_size) != 0 ) ) { // pin is off grid - if( part->HasConversion() && pin->GetConvert() ) + if( symbol->HasConversion() && pin->GetConvert() ) { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Off grid pin %s %s at location (%.3f, %.3f)" " of converted." ), @@ -388,7 +389,7 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) } else { - if( part->GetUnitCount() <= 1 ) + if( symbol->GetUnitCount() <= 1 ) { msg.Printf( _( "Off grid pin %s %s at location (%.3f, %.3f)." ), pin->GetNumber(), @@ -462,16 +463,16 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent ) if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) { - LIB_PART* part = static_cast( m_frame )->GetCurPart(); + LIB_SYMBOL* symbol = static_cast( m_frame )->GetCurPart(); - if( !part ) + if( !symbol ) return 0; - datasheet = part->GetDatasheetField().GetText(); + datasheet = symbol->GetDatasheetField().GetText(); } else if( m_frame->IsType( FRAME_SCH_VIEWER ) || m_frame->IsType( FRAME_SCH_VIEWER_MODAL ) ) { - LIB_PART* entry = static_cast( m_frame )->GetSelectedSymbol(); + LIB_SYMBOL* entry = static_cast( m_frame )->GetSelectedSymbol(); if( !entry ) return 0; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index a056ef9056..bc2356df5d 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -772,12 +772,12 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a if( m_isSymbolEditor ) { - LIB_PART* part = static_cast( m_frame )->GetCurPart(); + LIB_SYMBOL* symbol = static_cast( m_frame )->GetCurPart(); - if( !part ) + if( !symbol ) return false; - aCollector.Collect( part->GetDrawItems(), aFilterList, (wxPoint) aWhere, m_unit, + aCollector.Collect( symbol->GetDrawItems(), aFilterList, (wxPoint) aWhere, m_unit, m_convert ); } else @@ -1508,7 +1508,7 @@ void EE_SELECTION_TOOL::RebuildSelection() if( m_isSymbolEditor ) { - LIB_PART* start = static_cast( m_frame )->GetCurPart(); + LIB_SYMBOL* start = static_cast( m_frame )->GetCurPart(); for( LIB_ITEM& item : start->GetDrawItems() ) { @@ -1723,7 +1723,7 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, bool checkVisibilityO return false; break; - case LIB_PART_T: // In symbol_editor we do not want to select the symbol itself. + case LIB_SYMBOL_T: // In symbol_editor we do not want to select the symbol itself. return false; case LIB_FIELD_T: // LIB_FIELD object can always be edited. @@ -1805,7 +1805,7 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr aGroup->Add( aItem ); // Highlight pins and fields. (All the other symbol children are currently only - // represented in the LIB_PART and will inherit the settings of the parent symbol.) + // represented in the LIB_SYMBOL and will inherit the settings of the parent symbol.) if( SCH_ITEM* sch_item = dynamic_cast( aItem ) ) { sch_item->RunOnChildren( @@ -1838,7 +1838,7 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* a aGroup->Remove( aItem ); // Unhighlight pins and fields. (All the other symbol children are currently only - // represented in the LIB_PART.) + // represented in the LIB_SYMBOL.) if( SCH_ITEM* sch_item = dynamic_cast( aItem ) ) { sch_item->RunOnChildren( diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index ac747beb97..ed9fb84255 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -259,13 +259,14 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) // thus can creating autopan issues. Warp the mouse to the canvas centre controls->WarpCursor( canvas_area.Centre(), false ); - LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr; + LIB_SYMBOL* libSymbol = sel.LibId.IsValid() ? + m_frame->GetLibPart( sel.LibId ) : nullptr; - if( !part ) + if( !libSymbol ) continue; wxPoint pos( cursorPos ); - symbol = new SCH_SYMBOL( *part, &m_frame->GetCurrentSheet(), sel, pos ); + symbol = new SCH_SYMBOL( *libSymbol, &m_frame->GetCurrentSheet(), sel, pos ); addSymbol( symbol ); // Update cursor now that we have a symbol @@ -377,7 +378,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - // Add all the drawable parts to preview + // Add all the drawable symbols to preview if( image ) { image->SetPosition( (wxPoint)cursorPos ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 1ce48ba310..9d312c7566 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -115,7 +115,7 @@ private: for( int ii = 0; ii < symbol->GetPartRef()->GetUnitCount(); ii++ ) { wxString num_unit; - num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) ); + num_unit.Printf( _( "Unit %s" ), LIB_SYMBOL::SubReference( ii + 1, false ) ); wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString, wxITEM_CHECK ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 153e470a02..33ab310fde 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -446,8 +446,8 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent ) : _( "Reached end of sheet." ); // Show the popup during the time period the user can wrap the search - m_frame->ShowFindReplaceStatus( msg + wxS( " " ) + _( "Find again to wrap around to the start." ), - 4000 ); + m_frame->ShowFindReplaceStatus( msg + wxS( " " ) + + _( "Find again to wrap around to the start." ), 4000 ); wrapAroundTimer.StartOnce( 4000 ); } @@ -1577,12 +1577,12 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) end = paste_screen->GetLibSymbols().end(); } - LIB_PART* libPart = nullptr; + LIB_SYMBOL* libSymbol = nullptr; if( it != end ) { - libPart = new LIB_PART( *it->second ); - symbol->SetLibSymbol( libPart ); + libSymbol = new LIB_SYMBOL( *it->second ); + symbol->SetLibSymbol( libSymbol ); } for( SCH_SHEET_PATH& instance : pasteInstances ) @@ -1600,10 +1600,11 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) for( SCH_SHEET_PATH& instance : pasteInstances ) { - // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant library - if( libPart && symbol->GetRef( &instance )[0] != wxT( '#' ) ) + // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant + // library. + if( libSymbol && symbol->GetRef( &instance )[0] != wxT( '#' ) ) { - SCH_REFERENCE schReference( symbol, libPart, instance ); + SCH_REFERENCE schReference( symbol, libSymbol, instance ); schReference.SetSheetNumber( instance.GetVirtualPageNumber() ); pastedSymbols[instance].AddItem( schReference ); } diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 8f4ba0ee4e..afbf254b5b 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -379,9 +379,9 @@ int SYMBOL_EDITOR_CONTROL::ExportView( const TOOL_EVENT& aEvent ) return 0; SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); - LIB_PART* part = editFrame->GetCurPart(); + LIB_SYMBOL* symbol = editFrame->GetCurPart(); - if( !part ) + if( !symbol ) { wxMessageBox( _( "No symbol to export" ) ); return 0; @@ -389,7 +389,7 @@ int SYMBOL_EDITOR_CONTROL::ExportView( const TOOL_EVENT& aEvent ) wxString file_ext = wxT( "png" ); wxString mask = wxT( "*." ) + file_ext; - wxFileName fn( part->GetName() ); + wxFileName fn( symbol->GetName() ); fn.SetExt( "png" ); wxString projectPath = wxPathOnly( m_frame->Prj().GetProjectFullName() ); @@ -419,9 +419,9 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) return 0; SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); - LIB_PART* part = editFrame->GetCurPart(); + LIB_SYMBOL* symbol = editFrame->GetCurPart(); - if( !part ) + if( !symbol ) { wxMessageBox( _( "No symbol to export" ) ); return 0; @@ -429,7 +429,7 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) wxString file_ext = wxT( "svg" ); wxString mask = wxT( "*." ) + file_ext; - wxFileName fn( part->GetName() ); + wxFileName fn( symbol->GetName() ); fn.SetExt( file_ext ); wxString pro_dir = wxPathOnly( m_frame->Prj().GetProjectFullName() ); @@ -442,7 +442,7 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) PAGE_INFO pageSave = editFrame->GetScreen()->GetPageSettings(); PAGE_INFO pageTemp = pageSave; - wxSize symbolSize = part->GetUnitBoundingBox( editFrame->GetUnit(), + wxSize symbolSize = symbol->GetUnitBoundingBox( editFrame->GetUnit(), editFrame->GetConvert() ).GetSize(); // Add a small margin to the plot bounding box @@ -460,20 +460,20 @@ int SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent ) { - LIB_PART* part = nullptr; - LIB_ID libId; - int unit, convert; + LIB_SYMBOL* libSymbol = nullptr; + LIB_ID libId; + int unit, convert; if( m_isSymbolEditor ) { SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); - part = editFrame->GetCurPart(); + libSymbol = editFrame->GetCurPart(); unit = editFrame->GetUnit(); convert = editFrame->GetConvert(); - if( part ) - libId = part->GetLibId(); + if( libSymbol ) + libId = libSymbol->GetLibId(); } else { @@ -488,16 +488,16 @@ int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent ) } else { - part = viewerFrame->GetSelectedSymbol(); - unit = viewerFrame->GetUnit(); - convert = viewerFrame->GetConvert(); + libSymbol = viewerFrame->GetSelectedSymbol(); + unit = viewerFrame->GetUnit(); + convert = viewerFrame->GetConvert(); - if( part ) - libId = part->GetLibId(); + if( libSymbol ) + libId = libSymbol->GetLibId(); } } - if( part ) + if( libSymbol ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false ); @@ -507,9 +507,9 @@ int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent ) return 0; } - wxCHECK( part->GetLibId().IsValid(), 0 ); + wxCHECK( libSymbol->GetLibId().IsValid(), 0 ); - SCH_SYMBOL* symbol = new SCH_SYMBOL( *part, libId, &schframe->GetCurrentSheet(), + SCH_SYMBOL* symbol = new SCH_SYMBOL( *libSymbol, libId, &schframe->GetCurrentSheet(), unit, convert ); symbol->SetParent( schframe->GetScreen() ); diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index b2eb8237e2..0a3f73a605 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -148,9 +148,9 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); - if( !part ) + if( !symbol ) continue; // First click creates... @@ -162,13 +162,13 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { case LIB_PIN_T: { - item = pinTool->CreatePin( wxPoint( cursorPos.x, -cursorPos.y ), part ); + item = pinTool->CreatePin( wxPoint( cursorPos.x, -cursorPos.y ), symbol ); g_lastPinWeakPtr = item; break; } case LIB_TEXT_T: { - LIB_TEXT* text = new LIB_TEXT( part ); + LIB_TEXT* text = new LIB_TEXT( symbol ); text->SetPosition( wxPoint( cursorPos.x, -cursorPos.y ) ); text->SetTextSize( wxSize( Mils2iu( settings->m_Defaults.text_size ), @@ -207,7 +207,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) // ... and second click places: else { - m_frame->SaveCopyInUndoList( part ); + m_frame->SaveCopyInUndoList( symbol ); switch( item->Type() ) { @@ -215,7 +215,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) pinTool->PlacePin( (LIB_PIN*) item ); break; case LIB_TEXT_T: - part->AddDrawItem( (LIB_TEXT*) item ); + symbol->AddDrawItem( (LIB_TEXT*) item ); break; default: wxFAIL_MSG( "TwoClickPlace(): unknown type" ); @@ -274,7 +274,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) m_frame->PushTool( tool ); Activate(); - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); LIB_ITEM* item = nullptr; // Prime the pump @@ -338,17 +338,17 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_LEFT ) && !item ) { - if( !part ) + if( !symbol ) continue; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); switch( type ) { - case LIB_ARC_T: item = new LIB_ARC( part ); break; - case LIB_CIRCLE_T: item = new LIB_CIRCLE( part ); break; - case LIB_POLYLINE_T: item = new LIB_POLYLINE( part ); break; - case LIB_RECTANGLE_T: item = new LIB_RECTANGLE( part ); break; + case LIB_ARC_T: item = new LIB_ARC( symbol ); break; + case LIB_CIRCLE_T: item = new LIB_CIRCLE( symbol ); break; + case LIB_POLYLINE_T: item = new LIB_POLYLINE( symbol ); break; + case LIB_RECTANGLE_T: item = new LIB_RECTANGLE( symbol ); break; default: break; // keep compiler quiet } @@ -377,8 +377,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) item->ClearEditFlags(); m_view->ClearPreview(); - m_frame->SaveCopyInUndoList( part ); - part->AddDrawItem( item ); + m_frame->SaveCopyInUndoList( symbol ); + symbol->AddDrawItem( item ); item = nullptr; m_frame->RebuildView(); @@ -453,15 +453,15 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); - if( !part ) + if( !symbol ) continue; VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() ); wxPoint offset( -cursorPos.x, cursorPos.y ); - part->SetOffset( offset ); + symbol->SetOffset( offset ); // Refresh the view without changing the viewport auto center = m_view->GetCenter(); @@ -489,14 +489,14 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent ) { SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool(); - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); LIB_PIN* sourcePin = nullptr; - if( !part ) + if( !symbol ) return 0; // See if we have a pin matching our weak ptr - for( LIB_PIN* test = part->GetNextPin(); test; test = part->GetNextPin( test ) ) + for( LIB_PIN* test = symbol->GetNextPin(); test; test = symbol->GetNextPin( test ) ) { if( (void*) test == g_lastPinWeakPtr ) sourcePin = test; diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 722f4c11b7..9193e271ee 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -238,7 +238,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) static KICAD_T nonFields[] = { - LIB_PART_T, + LIB_SYMBOL_T, LIB_ARC_T, LIB_CIRCLE_T, LIB_TEXT_T, @@ -252,8 +252,8 @@ static KICAD_T nonFields[] = int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); - auto items = m_selectionTool->RequestSelection( nonFields ).GetItems(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); + auto items = m_selectionTool->RequestSelection( nonFields ).GetItems(); if( items.empty() ) return 0; @@ -261,7 +261,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) // Don't leave a freed pointer in the selection m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - saveCopyInUndoList( part, UNDO_REDO::LIBEDIT ); + saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT ); std::set toDelete; @@ -278,19 +278,19 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) // in different units are also removed. But only one pin per unit (matching) if( m_frame->SynchronizePins() ) { - std::vector got_unit( part->GetUnitCount() ); + std::vector got_unit( symbol->GetUnitCount() ); got_unit[pin->GetUnit()] = true; int curr_convert = pin->GetConvert(); ELECTRICAL_PINTYPE etype = pin->GetType(); wxString name = pin->GetName(); - LIB_PIN* next_pin = part->GetNextPin(); + LIB_PIN* next_pin = symbol->GetNextPin(); while( next_pin != NULL ) { pin = next_pin; - next_pin = part->GetNextPin( pin ); + next_pin = symbol->GetNextPin( pin ); if( got_unit[pin->GetUnit()] ) continue; @@ -319,7 +319,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) } for( LIB_ITEM* item : toDelete ) - part->RemoveDrawItem( item ); + symbol->RemoveDrawItem( item ); m_frame->RebuildView(); m_frame->OnModify(); @@ -510,8 +510,8 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField ) if( aField == NULL ) return; - wxString caption; - LIB_PART* parent = aField->GetParent(); + wxString caption; + LIB_SYMBOL* parent = aField->GetParent(); wxCHECK( parent, /* void */ ); // Editing the symbol value field is equivalent to creating a new symbol based on the @@ -556,14 +556,14 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField ) void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties() { - LIB_PART* part = m_frame->GetCurPart(); - bool partLocked = part->UnitsLocked(); - wxString oldName = part->GetName(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); + bool partLocked = symbol->UnitsLocked(); + wxString oldName = symbol->GetName(); m_toolMgr->RunAction( ACTIONS::cancelInteractive, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - DIALOG_LIB_SYMBOL_PROPERTIES dlg( m_frame, part ); + DIALOG_LIB_SYMBOL_PROPERTIES dlg( m_frame, symbol ); // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal // frame. Therefore this dialog as a modal frame parent, MUST be run under @@ -576,33 +576,33 @@ void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties() // if m_UnitSelectionLocked has changed, set some edit options or defaults // to the best value - if( partLocked != part->UnitsLocked() ) + if( partLocked != symbol->UnitsLocked() ) { SYMBOL_EDITOR_DRAWING_TOOLS* tools = m_toolMgr->GetTool(); // Enable synchronized pin edit mode for symbols with interchangeable units - m_frame->m_SyncPinEdit = !part->UnitsLocked(); + m_frame->m_SyncPinEdit = !symbol->UnitsLocked(); // also set default edit options to the better value // Usually if units are locked, graphic items are specific to each unit // and if units are interchangeable, graphic items are common to units - tools->SetDrawSpecificUnit( part->UnitsLocked() ); + tools->SetDrawSpecificUnit( symbol->UnitsLocked() ); } } int SYMBOL_EDITOR_EDIT_TOOL::PinTable( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); - if( !part ) + if( !symbol ) return 0; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - saveCopyInUndoList( part, UNDO_REDO::LIBEDIT ); + saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT ); - DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part ); + DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, symbol ); if( dlg.ShowModal() == wxID_CANCEL ) return -1; @@ -616,18 +616,18 @@ int SYMBOL_EDITOR_EDIT_TOOL::PinTable( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_EDIT_TOOL::UpdateSymbolFields( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); - if( !part ) + if( !symbol ) return 0; - if( !part->IsAlias() ) + if( !symbol->IsAlias() ) { m_frame->ShowInfoBarError( _( "Symbol is not derived from another symbol." ) ); } else { - DIALOG_UPDATE_SYMBOL_FIELDS dlg( m_frame, part ); + DIALOG_UPDATE_SYMBOL_FIELDS dlg( m_frame, symbol ); if( dlg.ShowModal() == wxID_CANCEL ) return -1; @@ -672,13 +672,13 @@ int SYMBOL_EDITOR_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields ); - if( !part || !selection.GetSize() ) + if( !symbol || !selection.GetSize() ) return 0; - for( LIB_ITEM& item : part->GetDrawItems() ) + for( LIB_ITEM& item : symbol->GetDrawItems() ) { if( item.Type() == LIB_FIELD_T ) continue; @@ -689,14 +689,14 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) item.SetFlags( STRUCT_DELETED ); } - LIB_PART* partCopy = new LIB_PART( *part ); + LIB_SYMBOL* partCopy = new LIB_SYMBOL( *symbol ); STRING_FORMATTER formatter; SCH_SEXPR_PLUGIN::FormatPart( partCopy, formatter ); delete partCopy; - for( LIB_ITEM& item : part->GetDrawItems() ) + for( LIB_ITEM& item : symbol->GetDrawItems() ) item.ClearFlags( STRUCT_DELETED ); if( m_toolMgr->SaveClipboard( formatter.GetString() ) ) @@ -708,14 +708,14 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); - if( !part || part->IsAlias() ) + if( !symbol || symbol->IsAlias() ) return 0; std::string text_utf8 = m_toolMgr->GetClipboardUTF8(); STRING_LINE_READER reader( text_utf8, "Clipboard" ); - LIB_PART* newPart; + LIB_SYMBOL* newPart; try { @@ -723,8 +723,8 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) } catch( IO_ERROR& ) { - // If it's not a part then paste as text - newPart = new LIB_PART( "dummy_part" ); + // If it's not a symbol then paste as text + newPart = new LIB_SYMBOL( "dummy_part" ); LIB_TEXT* newText = new LIB_TEXT( newPart ); newText->SetText( wxString::FromUTF8( text_utf8.c_str() ) ); newPart->AddDrawItem( newText ); @@ -733,10 +733,10 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) if( !newPart ) return -1; - m_frame->SaveCopyInUndoList( part ); + m_frame->SaveCopyInUndoList( symbol ); m_selectionTool->ClearSelection(); - for( LIB_ITEM& item : part->GetDrawItems() ) + for( LIB_ITEM& item : symbol->GetDrawItems() ) item.ClearFlags( IS_NEW | IS_PASTED | SELECTED ); for( LIB_ITEM& item : newPart->GetDrawItems() ) @@ -745,13 +745,13 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) continue; LIB_ITEM* newItem = (LIB_ITEM*) item.Clone(); - newItem->SetParent( part ); + newItem->SetParent( symbol ); newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED ); newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 ); newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 ); - part->AddDrawItem( newItem ); + symbol->AddDrawItem( newItem ); getView()->Add( newItem ); } @@ -773,7 +773,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields ); if( selection.GetSize() == 0 ) @@ -795,10 +795,10 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone(); oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED ); newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED ); - newItem->SetParent( part ); + newItem->SetParent( symbol ); newItems.push_back( newItem ); - part->AddDrawItem( newItem ); + symbol->AddDrawItem( newItem ); getView()->Add( newItem ); } diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp index a682d58ab7..1638b7600e 100644 --- a/eeschema/tools/symbol_editor_move_tool.cpp +++ b/eeschema/tools/symbol_editor_move_tool.cpp @@ -154,12 +154,13 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( lib_item->Type() == LIB_PIN_T ) { LIB_PIN* cur_pin = static_cast( lib_item ); - LIB_PART* part = m_frame->GetCurPart(); - std::vector got_unit( part->GetUnitCount() ); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); + std::vector got_unit( symbol->GetUnitCount() ); got_unit[cur_pin->GetUnit()] = true; - for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) + for( LIB_PIN* pin = symbol->GetNextPin(); pin; + pin = symbol->GetNextPin( pin ) ) { if( !got_unit[pin->GetUnit()] && pin->GetPosition() == cur_pin->GetPosition() diff --git a/eeschema/tools/symbol_editor_pin_tool.cpp b/eeschema/tools/symbol_editor_pin_tool.cpp index 3639fb8154..426fe57c28 100644 --- a/eeschema/tools/symbol_editor_pin_tool.cpp +++ b/eeschema/tools/symbol_editor_pin_tool.cpp @@ -214,10 +214,10 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin ) { - LIB_PART* part = m_frame->GetCurPart(); - bool ask_for_pin = true; // Test for another pin in same position in other units + LIB_SYMBOL* symbol = m_frame->GetCurPart(); + bool ask_for_pin = true; // Test for another pin in same position in other units - for( LIB_PIN* test = part->GetNextPin(); test; test = part->GetNextPin( test ) ) + for( LIB_PIN* test = symbol->GetNextPin(); test; test = symbol->GetNextPin( test ) ) { if( test == aPin || aPin->GetPosition() != test->GetPosition() || test->GetEditFlags() ) continue; @@ -261,12 +261,12 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin ) if( m_frame->SynchronizePins() ) CreateImagePins( aPin ); - part->AddDrawItem( aPin ); + symbol->AddDrawItem( aPin ); aPin->ClearFlags( IS_NEW ); } // Put linked pins in new position, and clear flags - for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) + for( LIB_PIN* pin = symbol->GetNextPin(); pin; pin = symbol->GetNextPin( pin ) ) { if( ( pin->GetEditFlags() & IS_LINKED ) == 0 ) continue; @@ -285,11 +285,11 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin ) /* * Create a new pin. */ -LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_PART* aPart ) +LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol ) { - aPart->ClearTempFlags(); + aSymbol->ClearTempFlags(); - LIB_PIN* pin = new LIB_PIN( aPart ); + LIB_PIN* pin = new LIB_PIN( aSymbol ); pin->SetFlags( IS_NEW ); @@ -371,16 +371,16 @@ void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( LIB_PIN* aPin ) int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent ) { - LIB_PART* part = m_frame->GetCurPart(); + LIB_SYMBOL* symbol = m_frame->GetCurPart(); EE_SELECTION& selection = m_selectionTool->GetSelection(); LIB_PIN* sourcePin = dynamic_cast( selection.Front() ); if( !sourcePin ) return 0; - saveCopyInUndoList( part, UNDO_REDO::LIBEDIT ); + saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT ); - for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) + for( LIB_PIN* pin = symbol->GetNextPin(); pin; pin = symbol->GetNextPin( pin ) ) { if( pin == sourcePin ) continue; diff --git a/eeschema/tools/symbol_editor_pin_tool.h b/eeschema/tools/symbol_editor_pin_tool.h index a771ca485c..13937363d5 100644 --- a/eeschema/tools/symbol_editor_pin_tool.h +++ b/eeschema/tools/symbol_editor_pin_tool.h @@ -41,7 +41,7 @@ public: /// @copydoc TOOL_INTERACTIVE::Init() bool Init() override; - LIB_PIN* CreatePin( const VECTOR2I& aPosition, LIB_PART* aPart ); + LIB_PIN* CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol ); LIB_PIN* RepeatPin( const LIB_PIN* aSourcePin ); bool PlacePin( LIB_PIN* aPin ); diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index ae96bbbc25..ccf9903564 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -87,7 +87,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, m_statusSizer->Add( 0, 0, 1 ); // add a spacer m_statusPanel->SetSizer( m_statusSizer ); - // Give the status panel the same color scheme as the canvas so it isn't jarring when switched to + // Give the status panel the same color scheme as the canvas so it isn't jarring when + // switched to. m_statusPanel->SetBackgroundColour( backgroundColor.ToColour() ); m_statusPanel->SetForegroundColour( foregroundColor.ToColour() ); @@ -166,11 +167,11 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i { KIGFX::VIEW* view = m_preview->GetView(); auto settings = static_cast( view->GetPainter()->GetSettings() ); - std::unique_ptr< LIB_PART > symbol; + std::unique_ptr< LIB_SYMBOL > symbol; try { - LIB_PART* tmp = m_kiway.Prj().SchSymbolLibTable()->LoadSymbol( aSymbolID ); + LIB_SYMBOL* tmp = m_kiway.Prj().SchSymbolLibTable()->LoadSymbol( aSymbolID ); if( tmp ) symbol = tmp->Flatten(); @@ -224,7 +225,7 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i } -void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit, int aConvert ) +void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aConvert ) { KIGFX::VIEW* view = m_preview->GetView(); @@ -235,9 +236,9 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit, int aConver m_previewItem = nullptr; } - if( aPart ) + if( aSymbol ) { - m_previewItem = new LIB_PART( *aPart ); + m_previewItem = new LIB_SYMBOL( *aSymbol ); // For symbols having a De Morgan body style, use the first style auto settings = static_cast( view->GetPainter()->GetSettings() ); @@ -251,7 +252,7 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit, int aConver view->Add( m_previewItem ); // Get the symbole size, in internal units - m_itemBBox = aPart->GetUnitBoundingBox( settings->m_ShowUnit, settings->m_ShowConvert ); + m_itemBBox = aSymbol->GetUnitBoundingBox( settings->m_ShowUnit, settings->m_ShowConvert ); // Calculate the draw scale to fit the drawing area fitOnDrawArea(); diff --git a/eeschema/widgets/symbol_preview_widget.h b/eeschema/widgets/symbol_preview_widget.h index 1131546c56..9bddedce1a 100644 --- a/eeschema/widgets/symbol_preview_widget.h +++ b/eeschema/widgets/symbol_preview_widget.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -27,7 +27,7 @@ class LIB_ID; -class LIB_PART; +class LIB_SYMBOL; class wxStaticText; class wxSizer; @@ -58,7 +58,7 @@ public: */ void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, int aConvert = 0 ); - void DisplayPart( LIB_PART* aPart, int aUnit, int aConvert = 0 ); + void DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aConvert = 0 ); private: void onSize( wxSizeEvent& aEvent ); @@ -76,9 +76,9 @@ private: wxSizer* m_outerSizer; /** - * A local copy of the #LIB_PART to display on the canvas. + * A local copy of the #LIB_SYMBOL to display on the canvas. */ - LIB_PART* m_previewItem; + LIB_SYMBOL* m_previewItem; /// The bounding box of the current item BOX2I m_itemBBox; diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 110df7464b..c83523019e 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -173,7 +173,7 @@ enum KICAD_T * If you add a new draw item, type, please make sure you add it so the * sort order is logical. */ - LIB_PART_T, + LIB_SYMBOL_T, LIB_ALIAS_T, LIB_ARC_T, LIB_CIRCLE_T, diff --git a/qa/eeschema/test_lib_part.cpp b/qa/eeschema/test_lib_part.cpp index d6e1918707..531d9273dc 100644 --- a/qa/eeschema/test_lib_part.cpp +++ b/qa/eeschema/test_lib_part.cpp @@ -23,7 +23,7 @@ /** * @file - * Test suite for LIB_PART + * Test suite for LIB_SYMBOL */ #include @@ -35,23 +35,23 @@ #include "lib_field_test_utils.h" -class TEST_LIB_PART_FIXTURE +class TEST_LIB_SYMBOL_FIXTURE { public: - TEST_LIB_PART_FIXTURE() : + TEST_LIB_SYMBOL_FIXTURE() : m_part_no_data( "part_name", nullptr ) { } ///> Part with no extra data set - LIB_PART m_part_no_data; + LIB_SYMBOL m_part_no_data; }; /** * Declare the test suite */ -BOOST_FIXTURE_TEST_SUITE( LibPart, TEST_LIB_PART_FIXTURE ) +BOOST_FIXTURE_TEST_SUITE( LibPart, TEST_LIB_SYMBOL_FIXTURE ) /** @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE( DefaultProperties ) /** - * Check the drawings on a "blank" LIB_PART + * Check the drawings on a "blank" LIB_SYMBOL */ BOOST_AUTO_TEST_CASE( DefaultDrawings ) { @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE( DefaultFields ) /** - * Test adding fields to a LIB_PART + * Test adding fields to a LIB_SYMBOL */ BOOST_AUTO_TEST_CASE( AddedFields ) { @@ -157,14 +157,14 @@ BOOST_AUTO_TEST_CASE( AddedFields ) /** - * Test adding draw items to a LIB_PART + * Test adding draw items to a LIB_SYMBOL */ BOOST_AUTO_TEST_CASE( AddedDrawItems ) { } -struct TEST_LIB_PART_SUBREF_CASE +struct TEST_LIB_SYMBOL_SUBREF_CASE { int m_index; bool m_addSep; @@ -177,7 +177,7 @@ struct TEST_LIB_PART_SUBREF_CASE */ BOOST_AUTO_TEST_CASE( SubReference ) { - const std::vector cases = { + const std::vector cases = { { 1, false, @@ -223,12 +223,12 @@ BOOST_AUTO_TEST_CASE( SubReference ) BOOST_AUTO_TEST_CASE( Compare ) { // Identical root part to m_part_no_data sans time stamp. - LIB_PART testPart( "part_name" ); + LIB_SYMBOL testPart( "part_name" ); // Self comparison test. BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 ); - // Test for identical LIB_PART. + // Test for identical LIB_SYMBOL. BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 ); // Test name. @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE( Compare ) // Time stamp comparison tests. // Check to see if we broke the copy ctor. - LIB_PART* copy = new LIB_PART( testPart ); + LIB_SYMBOL* copy = new LIB_SYMBOL( testPart ); BOOST_CHECK( testPart.Compare( *copy ) == 0 ); } @@ -382,7 +382,7 @@ BOOST_AUTO_TEST_CASE( Compare ) */ BOOST_AUTO_TEST_CASE( GetUnitItems ) { - // There are no unit draw items in the empty LIB_PART object. + // There are no unit draw items in the empty LIB_SYMBOL object. BOOST_CHECK( m_part_no_data.GetUnitItems( 1, 1 ).size() == 0 ); // A single unique unit with 1 pin common to all units and all body styles. @@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE( GetUnitItems ) */ BOOST_AUTO_TEST_CASE( GetUnitDrawItems ) { - // There are no unit draw items in the empty LIB_PART object. + // There are no unit draw items in the empty LIB_SYMBOL object. BOOST_CHECK( m_part_no_data.GetUnitDrawItems().size() == 0 ); // A single unique unit with 1 pin common to all units and all body styles. @@ -444,9 +444,9 @@ BOOST_AUTO_TEST_CASE( GetUnitDrawItems ) */ BOOST_AUTO_TEST_CASE( Inheritance ) { - std::unique_ptr parent = std::make_unique( "parent" ); + std::unique_ptr parent = std::make_unique( "parent" ); BOOST_CHECK( parent->IsRoot() ); - std::unique_ptr child1 = std::make_unique( "child1", parent.get() ); + std::unique_ptr child1 = std::make_unique( "child1", parent.get() ); BOOST_CHECK( child1->IsAlias() ); PART_SPTR parentRef = child1->GetParent().lock(); BOOST_CHECK( parentRef ); @@ -467,7 +467,7 @@ BOOST_AUTO_TEST_CASE( Inheritance ) */ BOOST_AUTO_TEST_CASE( CopyConstructor ) { - std::shared_ptr copy = std::make_shared( m_part_no_data ); + std::shared_ptr copy = std::make_shared( m_part_no_data ); BOOST_CHECK( m_part_no_data == *copy.get() ); } diff --git a/qa/eeschema/test_sch_pin.cpp b/qa/eeschema/test_sch_pin.cpp index a9c4f1d2f4..8de7c922c6 100644 --- a/qa/eeschema/test_sch_pin.cpp +++ b/qa/eeschema/test_sch_pin.cpp @@ -35,7 +35,7 @@ class TEST_SCH_PIN_FIXTURE public: TEST_SCH_PIN_FIXTURE() { - m_parent_part = new LIB_PART( "parent_part", nullptr ); + m_parent_part = new LIB_SYMBOL( "parent_part", nullptr ); m_lib_pin = new LIB_PIN( m_parent_part ); m_parent_part->AddDrawItem( m_lib_pin ); @@ -61,7 +61,7 @@ public: delete m_parent_part; } - LIB_PART* m_parent_part; + LIB_SYMBOL* m_parent_part; LIB_PIN* m_lib_pin; SCH_SYMBOL* m_parent_symbol;