Rename LIB_PART to LIB_SYMBOL.

This commit is contained in:
Wayne Stambaugh 2021-06-10 14:51:46 -04:00
parent 2af06a9d60
commit 71c183d7bb
120 changed files with 1692 additions and 1662 deletions

View File

@ -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" ) )

View File

@ -52,7 +52,7 @@ void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& 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" ),

View File

@ -84,7 +84,7 @@ PART_LIB::~PART_LIB()
void PART_LIB::Save( bool aSaveDocFile )
{
wxCHECK_RET( m_plugin != NULL, wxString::Format( "no plugin defined for library `%s`.",
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<LIB_PART*>& aSymbols ) const
void PART_LIB::GetParts( std::vector<LIB_SYMBOL*>& 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<PART_LIB> lib = std::make_unique<PART_LIB>( SCH_LIB_TYPE::LT_EESCHEMA, aFileName );
std::vector<LIB_PART*> parts;
std::vector<LIB_SYMBOL*> 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<LIB_PART*>& aCandidates,
void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_SYMBOL*>& 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 );

View File

@ -39,7 +39,7 @@
#include <sch_io_mgr.h>
#include <project.h>
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,8 +182,8 @@ 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 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<LIB_PART*>& aCandidates, const wxString& aEntryName,
void FindLibraryNearEntries( std::vector<LIB_SYMBOL*>& 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<LIB_PART*>& aPart) const;
void GetParts( std::vector<LIB_SYMBOL*>& 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.

View File

@ -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,13 +733,13 @@ 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
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 );

View File

@ -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<SCH_FIELD*> fields;
std::vector<LIB_FIELD*> libFields;
std::set<wxString> 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<LIB_PART> flattenedPart = libSymbol->Flatten();
std::unique_ptr<LIB_SYMBOL> 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<LIB_PART> flattenedPart = libSymbol->Flatten();
std::unique_ptr<LIB_SYMBOL> 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<LIB_PART> flattenedSymbol = libSymbol->Flatten();
std::unique_ptr<LIB_SYMBOL> 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 );

View File

@ -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() )
{

View File

@ -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;

View File

@ -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
{

View File

@ -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;
}

View File

@ -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 );

View File

@ -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() );

View File

@ -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

View File

@ -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();
}
}

View File

@ -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<LIB_FIELD>* m_fields;

View File

@ -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() );

View File

@ -30,7 +30,7 @@
#include <sch_pin.h>
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;

View File

@ -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

View File

@ -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)
@ -84,7 +84,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::updateFieldsList()
// Load non-mandatory fields from the parent part
std::vector<LIB_FIELD*> libFields;
std::set<wxString> fieldNames;
std::unique_ptr<LIB_PART> flattenedParent = m_symbol->GetParent().lock()->Flatten();
std::unique_ptr<LIB_SYMBOL> 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<LIB_PART> flattenedParent = m_symbol->GetParent().lock()->Flatten();
std::unique_ptr<LIB_SYMBOL> flattenedParent = m_symbol->GetParent().lock()->Flatten();
bool removeExtras = m_removeExtraBox->GetValue();
bool resetVis = m_resetFieldVisibilities->GetValue();

View File

@ -24,7 +24,7 @@
#include <dialog_update_symbol_fields_base.h>
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<wxString> m_updateFields;

View File

@ -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 ) );

View File

@ -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();

View File

@ -801,9 +801,9 @@ bool PANEL_SYM_LIB_TABLE::convertLibrary( const wxString& aLibrary, const wxStri
{
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<LIB_PART*> parts;
std::vector<LIB_PART*> newParts;
std::map<LIB_PART*, LIB_PART*> partMap;
std::vector<LIB_SYMBOL*> symbols;
std::vector<LIB_SYMBOL*> newSymbols;
std::map<LIB_SYMBOL*, LIB_SYMBOL*> 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( ... )

View File

@ -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.

View File

@ -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

View File

@ -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 );
@ -721,7 +721,7 @@ int ERC_TESTER::TestLibSymbolIssues()
}
wxString symbolName = symbol->GetLibId().GetLibItemName();
LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable );
LIB_SYMBOL* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable );
if( libSymbol == nullptr )
{
@ -736,7 +736,7 @@ int ERC_TESTER::TestLibSymbolIssues()
break;
}
std::unique_ptr<LIB_PART> flattenedSymbol = libSymbol->Flatten();
std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
if( *flattenedSymbol != *libSymbolInSchematic )
{

View File

@ -47,13 +47,13 @@ enum
template <class T>
FIELDS_GRID_TABLE<T>::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 ),

View File

@ -73,7 +73,7 @@ class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
{
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;

View File

@ -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<LIB_PART> parent = m_symbol->GetParent().lock();
std::shared_ptr<LIB_SYMBOL> parent = m_symbol->GetParent().lock();
// Append all of the unique parent fields if this is an alias.
if( parent )

View File

@ -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;

View File

@ -46,7 +46,6 @@
class wxFrame;
class wxDialog;
class LIB_PART;
class PART_LIBS;
class SCH_SYMBOL;
class SCH_TEXT;

View File

@ -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;

View File

@ -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.

View File

@ -35,7 +35,7 @@
#include <settings/color_settings.h>
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;

View File

@ -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.

View File

@ -36,7 +36,7 @@
#include <transform.h>
LIB_CIRCLE::LIB_CIRCLE( LIB_PART* aParent ) :
LIB_CIRCLE::LIB_CIRCLE( LIB_SYMBOL* aParent ) :
LIB_ITEM( LIB_CIRCLE_T, aParent )
{
m_Width = 0;

View File

@ -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.

View File

@ -40,7 +40,7 @@
#include <settings/color_settings.h>
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<const LIB_PART*>( m_parent );
const LIB_SYMBOL* parent = dynamic_cast<const LIB_SYMBOL*>( 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;
}

View File

@ -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.
* <p>
* If \a aData not NULL, \a aData must point a wxString which is used instead of
* the m_Text
* </p>
*/
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

View File

@ -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;
}

View File

@ -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:
/**

View File

@ -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 );

View File

@ -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;

View File

@ -36,7 +36,7 @@
#include <transform.h>
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;

View File

@ -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.

View File

@ -35,7 +35,7 @@
#include <transform.h>
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;

View File

@ -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.

View File

@ -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,7 +476,7 @@ wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
}
void LIB_PART::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
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
@ -543,7 +543,7 @@ void LIB_PART::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
}
void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset,
void LIB_SYMBOL::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset,
const TRANSFORM& aTransform ) const
{
wxASSERT( aPlotter != NULL );
@ -589,7 +589,7 @@ void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint&
}
void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
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,7 +737,7 @@ 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 LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames,
bool aTestType, bool aTestOrientation, bool aTestLength ) const
{
LIB_PINS thisPinList;
@ -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 <LIB_FIELD>& aFields )
void LIB_SYMBOL::SetFields( const std::vector <LIB_FIELD>& aFields )
{
deleteAllFields();
@ -904,7 +904,7 @@ void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
}
void LIB_PART::GetFields( std::vector<LIB_FIELD*>& aList )
void LIB_SYMBOL::GetFields( std::vector<LIB_FIELD*>& 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<LIB_FIELD*>& aList )
}
void LIB_PART::GetFields( std::vector<LIB_FIELD>& aList )
void LIB_SYMBOL::GetFields( std::vector<LIB_FIELD>& 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<LIB_FIELD>& 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,21 +1042,21 @@ 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,
LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aConvert,
KICAD_T aType, const wxPoint& aPoint )
{
for( LIB_ITEM& item : m_drawings )
@ -1076,7 +1076,7 @@ LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
}
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
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
@ -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_ITEM*> LIB_PART::GetUnitItems( int aUnit, int aConvert )
std::vector<LIB_ITEM*> LIB_SYMBOL::GetUnitItems( int aUnit, int aConvert )
{
std::vector<LIB_ITEM*> unitItems;
@ -1252,7 +1253,7 @@ std::vector<LIB_ITEM*> LIB_PART::GetUnitItems( int aUnit, int aConvert )
}
std::vector<struct PART_UNITS> LIB_PART::GetUnitDrawItems()
std::vector<struct PART_UNITS> LIB_SYMBOL::GetUnitDrawItems()
{
std::vector<struct PART_UNITS> units;
@ -1287,7 +1288,7 @@ std::vector<struct PART_UNITS> LIB_PART::GetUnitDrawItems()
}
std::vector<struct PART_UNITS> LIB_PART::GetUniqueUnits()
std::vector<struct PART_UNITS> LIB_SYMBOL::GetUniqueUnits()
{
int unitNum;
size_t i;

View File

@ -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<LIB_PART> PART_SPTR; ///< shared pointer to LIB_PART
typedef std::weak_ptr<LIB_PART> PART_REF; ///< weak pointer to LIB_PART
typedef std::shared_ptr<LIB_SYMBOL> PART_SPTR; ///< shared pointer to LIB_SYMBOL
typedef std::weak_ptr<LIB_SYMBOL> PART_REF; ///< weak pointer to LIB_SYMBOL
typedef MULTIVECTOR<LIB_ITEM, LIB_ARC_T, LIB_FIELD_T> 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<KIID&>( 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 <LIB_FIELD>& 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.
};

View File

@ -42,7 +42,7 @@
#include <default_values.h> // 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 )
{

View File

@ -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.

View File

@ -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<SCH_SYMBOL*>( 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<LIB_PART> flattenedPart = part->Flatten();
std::unique_ptr<LIB_SYMBOL> 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
{

View File

@ -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();

View File

@ -60,15 +60,15 @@ public:
};
/**
* Used by std:set<LIB_PART*> instantiation which uses #LIB_PART name as its key.
* Used by std:set<LIB_SYMBOL*> 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<PIN_INFO> 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<LIB_PART*, LIB_PART_LESS_THAN> m_libParts;
/// unique library symbols used. LIB_SYMBOL items are sorted by names
std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> 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:

View File

@ -74,7 +74,7 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector<SCH_SYMBOL*>& 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<SCH_SYMBOL*>& 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<wxString, RESCUE_CASE_CANDIDATE> 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<LIB_PART*> case_insensitive_matches;
LIB_SYMBOL* case_sensitive_match = nullptr;
std::vector<LIB_SYMBOL*> 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<wxString, RESCUE_CACHE_CANDIDATE> 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<LIB_PART> new_part = tmp->Flatten();
new_part->SetName( m_new_name );
aRescuer->AddPart( new_part.get() );
std::unique_ptr<LIB_SYMBOL> 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<LIB_PART> 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<LIB_SYMBOL> 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 */ )
{

View File

@ -47,7 +47,7 @@
#include <class_draw_panel_gal.h>
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; }
@ -109,7 +109,7 @@ public:
protected:
wxString m_requested_name;
wxString m_new_name;
LIB_PART* m_lib_candidate;
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<PART_LIB> 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;

View File

@ -43,12 +43,12 @@
#include <tools/ee_selection_tool.h>
LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
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;

View File

@ -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,7 +72,7 @@ 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,
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,
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.

View File

@ -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 );
}

View File

@ -31,7 +31,7 @@
#include <sch_view.h>
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;

View File

@ -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() )

View File

@ -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

View File

@ -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() );
}
}

View File

@ -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<LIB_PART*>& aSymbolList,
virtual void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& 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

View File

@ -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() )

View File

@ -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 );

View File

@ -73,7 +73,7 @@ void SCH_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
}
void SCH_PLUGIN::EnumerateSymbolLib( std::vector<LIB_PART*>& aSymbolList,
void SCH_PLUGIN::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
@ -82,7 +82,7 @@ void SCH_PLUGIN::EnumerateSymbolLib( std::vector<LIB_PART*>& 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.

View File

@ -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<wxString, wxString>& 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<wxString, wxString>& 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'" ),
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 ) );
kpart->SetKeyWords( "power-flag" );
kpart->SetLibId( libId );
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<wxString, wxString>& 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<wxString, wxString>& 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 );

View File

@ -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<ASCH_SHEET> m_altiumSheet;
std::map<int, SCH_SYMBOL*> m_components;
std::map<int, SCH_SHEET*> m_sheets;
std::map<int, LIB_PART*> m_symbols; // every component has its unique symbol
std::map<int, LIB_SYMBOL*> m_symbols; // every component has its unique symbol
std::map<wxString, LIB_PART*> m_powerSymbols;
std::map<wxString, LIB_SYMBOL*> m_powerSymbols;
std::vector<ASCH_STORAGE_FILE> m_altiumStorage;
std::map<int, ASCH_SYMBOL> m_altiumComponents;

View File

@ -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,7 +589,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
wxASSERT( kiPart->GetValueField().GetText() == symbolInstanceNetName );
}
LIB_PART* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator,
LIB_SYMBOL* scaledPart = getScaledLibPart( kiPart, sym.ScaleRatioNumerator,
sym.ScaleRatioDenominator );
double returnedOrient = 0.0;
@ -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<VERTEX>& aCadstarVertices, wxPoint aSymbolOrigin, LIB_PART* aPart,
const std::vector<VERTEX>& 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,
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<wxPoint, LIB_POLYLINE*> 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<LIB_POLYLINE&>( *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 )
{

View File

@ -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<LAYER_ID, SCH_SHEET*> m_sheetMap; ///< Map between Cadstar and KiCad Sheets
std::map<BLOCK_PIN_ID, SCH_HIERLABEL*>
m_sheetPinMap; ///< Map between Cadstar and KiCad Sheets Pins
std::map<PART_ID, LIB_PART*> m_partMap; ///< Map between Cadstar and KiCad Parts
std::map<PART_ID, LIB_SYMBOL*> m_partMap; ///< Map between Cadstar and KiCad Parts
std::map<PART_GATE_ID, SYMDEF_ID> m_partSymbolsMap; ///< Map holding the symbols loaded so far
/// for a particular PART_ID and GATE_ID
std::map<PART_ID, TERMINAL_TO_PINNUM_MAP> m_pinNumsMap; ///< Map of pin numbers in CADSTAR parts
std::map<wxString, LIB_PART*> m_powerSymLibMap; ///< Map of KiCad Power Symbol Library items
std::map<wxString, LIB_SYMBOL*> m_powerSymLibMap; ///< Map of KiCad Power Symbol Library items
std::map<SYMBOL_ID, SCH_SYMBOL*>
m_powerSymMap; ///< Map between Cadstar and KiCad Power Symbols
std::map<SYMBOL_ID, SCH_GLOBALLABEL*>
@ -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<VERTEX>& 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,
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<wxPoint, wxSize> getFigureExtentsKiCad( const FIGURE& aCadstarFigure );

View File

@ -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,

View File

@ -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<LIB_PIN*> 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<LIB_PART> kpart( new LIB_PART( symbolName ) );
unique_ptr<LIB_SYMBOL> 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<LIB_PART>& aPart,
bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& 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_ptr<LIB_P
if( nodeName == "circle" )
{
aPart->AddDrawItem( loadSymbolCircle( aPart, currentNode, aGateNumber ) );
aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) );
}
else if( nodeName == "pin" )
{
EPIN ePin = EPIN( currentNode );
std::unique_ptr<LIB_PIN> pin( loadPin( aPart, currentNode, &ePin, aGateNumber ) );
std::unique_ptr<LIB_PIN> 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_ptr<LIB_P
wxString padname( pads[i] );
apin->SetNumber( padname );
aPart->AddDrawItem( apin );
aSymbol->AddDrawItem( apin );
}
break;
@ -1544,41 +1544,41 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_P
{
pin->SetUnit( 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<LIB_TEXT> libtext( loadSymbolText( aPart, currentNode, aGateNumber ) );
std::unique_ptr<LIB_TEXT> 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_ptr<LIB_P
for( LIB_ITEM* item : frameItems )
{
item->SetParent( 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_ptr<LIB_P
}
if( foundName == false )
aPart->GetFieldById( 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<LIB_PART>& aPart, wxXmlNode* aCircleNode, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aCircleNode, int aGateNumber )
{
// Parse the circle properties
ECIRCLE c( aCircleNode );
unique_ptr<LIB_CIRCLE> circle( new LIB_CIRCLE( aPart.get() ) );
unique_ptr<LIB_CIRCLE> 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<LIB_PART>& aPart, wxXmlNode* aRectNode, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aRectNode, int aGateNumber )
{
ERECT rect( aRectNode );
unique_ptr<LIB_RECTANGLE> rectangle( new LIB_RECTANGLE( aPart.get() ) );
unique_ptr<LIB_RECTANGLE> 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<LIB_PART>& aPart, wxXmlNode* aWireNode, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& 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<LIB_ARC> arc = std::make_unique<LIB_ARC>( aPart.get() );
std::unique_ptr<LIB_ARC> arc = std::make_unique<LIB_ARC>( 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<LIB_POLYLINE> polyLine = std::make_unique<LIB_POLYLINE>( aPart.get() );
std::unique_ptr<LIB_POLYLINE> polyLine = std::make_unique<LIB_POLYLINE>( 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<LIB_PART>& aPart, wxXmlNode* aPolygonNode, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aPolygonNode, int aGateNumber )
{
std::unique_ptr<LIB_POLYLINE> polyLine = std::make_unique<LIB_POLYLINE>( aPart.get() );
std::unique_ptr<LIB_POLYLINE> polyLine = std::make_unique<LIB_POLYLINE>( 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<LIB_PART>& aPart, wxXmlNode* aPin, EPIN* aEPin, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aPin, EPIN* aEPin, int aGateNumber )
{
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( aPart.get() );
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( 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<LIB_PART>& aPart, wxXmlNode* aLibText, int aGateNumber )
std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aLibText, int aGateNumber )
{
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( aPart.get() );
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( aSymbol.get() );
ETEXT etext( aLibText );
libtext->SetUnit( aGateNumber );

View File

@ -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<wxString, LIB_PART> KiCadSymbols;
boost::ptr_map<wxString, LIB_SYMBOL> KiCadSymbols;
std::unordered_map<wxString, wxXmlNode*> SymbolNodes;
std::unordered_map<wxString, int> GateUnit;
std::unordered_map<wxString, wxString> package;
@ -130,19 +130,19 @@ private:
SCH_TEXT* loadPlainText( wxXmlNode* aSchText );
void loadFrame( wxXmlNode* aFrameNode, std::vector<SCH_LINE*>& aLines );
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_PART>& aPart,
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol,
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName );
LIB_CIRCLE* loadSymbolCircle( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aCircleNode,
LIB_CIRCLE* loadSymbolCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aCircleNode,
int aGateNumber );
LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aRectNode,
LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aRectNode,
int aGateNumber );
LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aPolygonNode,
LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol,
wxXmlNode* aPolygonNode, int aGateNumber );
LIB_ITEM* loadSymbolWire( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aWireNode,
int aGateNumber );
LIB_ITEM* loadSymbolWire( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aWireNode,
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
int aGateNumber );
LIB_PIN* loadPin( std::unique_ptr<LIB_PART>& aPart, wxXmlNode*, EPIN* epin,
int aGateNumber );
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aLibText,
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aLibText,
int aGateNumber );
void loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>& aLines );

View File

@ -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<LIB_PART> symbol = std::make_unique<LIB_PART>( wxEmptyString );
std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
std::set<int> 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<LIB_PART>& aSymbol )
void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol )
{
wxCHECK_RET( CurTok() == T_pin_names,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) +
@ -755,7 +755,7 @@ void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr<LIB_PART>& aSymbol )
}
LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_PART>& aSymbol )
LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& 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<LIB_PART>& aSymbol )
wxString error;
wxString name;
wxString value;
std::unique_ptr<LIB_FIELD> field = std::make_unique<LIB_FIELD>( aSymbol.get(), MANDATORY_FIELDS );
std::unique_ptr<LIB_FIELD> field = std::make_unique<LIB_FIELD>( 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() )
{

View File

@ -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<LIB_PART>& aSymbol );
void parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol );
LIB_FIELD* parseProperty( std::unique_ptr<LIB_PART>& aSymbol );
LIB_FIELD* parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol );
LIB_ARC* parseArc();
LIB_BEZIER* parseBezier();
@ -186,9 +186,9 @@ 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,
LIB_SYMBOL* ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap,
int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION );
LIB_ITEM* ParseDrawItem();

View File

@ -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<wxString, LIB_PART*> libSymbols;
std::map<wxString, LIB_SYMBOL*> 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<LIB_PART> aliasParent = alias.second->GetParent().lock();
std::shared_ptr<LIB_SYMBOL> 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<LIB_PART> parent = aSymbol->GetParent().lock();
std::shared_ptr<LIB_SYMBOL> 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<LIB_PART*>& aSymbolList,
void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
@ -2168,9 +2169,9 @@ void SCH_SEXPR_PLUGIN::EnumerateSymbolLib( std::vector<LIB_PART*>& 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<LIB_PART*>& aSymbolList,
}
LIB_PART* SCH_SEXPR_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
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 );
}

View File

@ -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<LIB_PART*>& aSymbolList,
void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& 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;
@ -127,9 +127,9 @@ public:
const wxString& GetError() const override { return m_error; }
static LIB_PART* ParsePart( LINE_READER& aReader,
static LIB_SYMBOL* ParsePart( LINE_READER& aReader,
int aVersion = SEXPR_SCHEMATIC_FILE_VERSION );
static void FormatPart( LIB_PART* aPart, OUTPUTFORMATTER& aFormatter );
static void FormatPart( LIB_SYMBOL* aPart, OUTPUTFORMATTER& aFormatter );
private:
void loadHierarchy( SCH_SHEET* aSheet );

View File

@ -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<LIB_PART>& aPart, LINE_READER& aReader,
LIB_PART_MAP* aMap = nullptr );
static void loadField( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static void loadDrawEntries( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader,
static void loadAliases( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader,
LIB_SYMBOL_MAP* aMap = nullptr );
static void loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static void loadDrawEntries( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader,
int aMajorVersion, int aMinorVersion );
static void loadFootprintFilters( std::unique_ptr<LIB_PART>& aPart,
static void loadFootprintFilters( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader );
void loadDocs();
static LIB_ARC* loadArc( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static LIB_CIRCLE* loadCircle( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static LIB_TEXT* loadText( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader,
static LIB_ARC* loadArc( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_CIRCLE* loadCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_TEXT* loadText( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader,
int aMajorVersion, int aMinorVersion );
static LIB_RECTANGLE* loadRectangle( std::unique_ptr<LIB_PART>& aPart,
static LIB_RECTANGLE* loadRectangle( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader );
static LIB_PIN* loadPin( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static LIB_POLYLINE* loadPolyLine( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static LIB_BEZIER* loadBezier( std::unique_ptr<LIB_PART>& aPart, LINE_READER& aReader );
static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_POLYLINE* loadPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader );
static LIB_BEZIER* loadBezier( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static FILL_TYPE parseFillMode( LINE_READER& aReader, const char* aLine,
const char** aOutput );
LIB_PART* removeSymbol( LIB_PART* aAlias );
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<LIB_PART> part = std::make_unique<LIB_PART>( wxEmptyString );
std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( 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<LIB_PART>& aPart,
void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader,
LIB_PART_MAP* aMap )
LIB_SYMBOL_MAP* aMap )
{
wxString newAliasName;
const char* line = aReader.Line();
@ -2957,17 +2959,17 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr<LIB_PART>& 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,19 +2978,19 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr<LIB_PART>& 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<LIB_PART>& aPart,
void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader )
{
const char* line = aReader.Line();
@ -3005,7 +3007,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_PART>& 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<LIB_PART>& 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<LIB_PART>& 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,7 +3138,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_PART>& aPart,
}
void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr<LIB_PART>& aPart,
void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader,
int aMajorVersion,
int aMinorVersion )
@ -3151,38 +3153,39 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDrawEntries( std::unique_ptr<LIB_PART>& 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<LIB_PART>& aPart,
LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr<LIB_SYMBOL>& 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<LIB_PART>& aPart,
}
LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr<LIB_PART>& aPart,
LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr<LIB_SYMBOL>& 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,7 +3314,7 @@ LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr<LIB_PART>& aPar
}
LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr<LIB_PART>& aPart,
LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader,
int aMajorVersion,
int aMinorVersion )
@ -3320,7 +3323,7 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr<LIB_PART>& aPart,
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<LIB_PART>& aPart,
}
LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr<LIB_PART>& aPart,
LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr<LIB_SYMBOL>& 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,7 +3439,7 @@ LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr<LIB_PART>
}
LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr<LIB_PART>& aPart,
LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader )
{
const char* line = aReader.Line();
@ -3567,7 +3570,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr<LIB_PART>& 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<LIB_PART>& aPart,
}
LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr<LIB_PART>& aPart,
LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr<LIB_SYMBOL>& 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_PART>&
}
LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr<LIB_PART>& aPart,
LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr<LIB_SYMBOL>& 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,7 +3691,7 @@ LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr<LIB_PART>& aPar
}
void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr<LIB_PART>& aPart,
void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader )
{
const char* line = aReader.Line();
@ -3703,7 +3706,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadFootprintFilters( std::unique_ptr<LIB_PART>& 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<int>( aRectangle->GetFillMode() )] );
Iu2Mils( aRectangle->GetWidth() ),
fill_tab[static_cast<int>( 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<LIB_PART*>& aSymbolList,
void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
@ -4281,9 +4285,9 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( std::vector<LIB_PART*>& 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<LIB_PART*>& aSymbolList,
}
LIB_PART* SCH_LEGACY_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
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,
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 );
}

View File

@ -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<LIB_PART*>& aSymbolList,
void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& 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 );

View File

@ -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

View File

@ -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<SCH_SYMBOL*> 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 */ );

View File

@ -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<wxString, LIB_PART*>& GetLibSymbols() { return m_libSymbols; }
const std::map<wxString, LIB_PART*>& GetLibSymbols() const { return m_libSymbols; }
std::map<wxString, LIB_SYMBOL*>& GetLibSymbols() { return m_libSymbols; }
const std::map<wxString, LIB_SYMBOL*>& 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<wxString, LIB_PART*> m_libSymbols;
std::map<wxString, LIB_SYMBOL*> 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

View File

@ -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<SCH_SYMBOL*>( 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();

View File

@ -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<int, wxString>& 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<KIID&>( 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;

View File

@ -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_FIELD> SCH_FIELDS;
typedef std::weak_ptr<LIB_PART> PART_REF;
typedef std::weak_ptr<LIB_SYMBOL> 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<std::unique_ptr<SCH_PIN>> m_pins; // a SCH_PIN for every LIB_PIN (all units)
std::unordered_map<LIB_PIN*, unsigned> m_pinMap; // library pin pointer to SCH_PIN's index

View File

@ -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 <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
@ -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 );

View File

@ -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 );

View File

@ -205,12 +205,12 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_params.emplace_back( new PARAM<wxString>( "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<int>( "subpart_id_separator",
LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) );
LIB_SYMBOL::SubpartIdSeparatorPtr(), 0, 0, 126 ) );
m_params.emplace_back( new PARAM<int>( "subpart_first_id",
LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) );
LIB_SYMBOL::SubpartFirstIdPtr(), 'A', '1', 'z' ) );
m_NgspiceSimulatorSettings =
std::make_shared<NGSPICE_SIMULATOR_SETTINGS>( this, "ngspice" );

View File

@ -28,7 +28,7 @@
SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER( const std::vector<wxString>& aNicknames,
SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols,
std::unordered_map<wxString, std::vector<LIB_PART*>>* aOutput,
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>>* aOutput,
PROGRESS_REPORTER* aReporter ) :
m_nicknames( aNicknames ),
m_table( aTable ),

View File

@ -29,7 +29,7 @@
#include <wx/string.h>
class LIB_PART;
class LIB_SYMBOL;
class PROGRESS_REPORTER;
class SYMBOL_LIB_TABLE;
@ -47,7 +47,7 @@ public:
*/
SYMBOL_ASYNC_LOADER( const std::vector<wxString>& aNicknames,
SYMBOL_LIB_TABLE* aTable, bool aOnlyPowerSymbols = false,
std::unordered_map<wxString, std::vector<LIB_PART*>>* aOutput = nullptr,
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>>* 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 <nickname, loaded parts list>
typedef std::pair<wxString, std::vector<LIB_PART*>> LOADED_PAIR;
typedef std::pair<wxString, std::vector<LIB_SYMBOL*>> LOADED_PAIR;
private:
///< Worker job that loads libraries and returns a list of pairs of <nickname, loaded parts>
@ -90,7 +90,7 @@ private:
bool m_onlyPowerSymbols;
///< Handle to map that will be filled with the loaded parts per library
std::unordered_map<wxString, std::vector<LIB_PART*>>* m_output;
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>>* m_output;
///< Progress reporter (may be null)
PROGRESS_REPORTER* m_reporter;

View File

@ -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<LIB_PART> part = aSymbol->GetPartRef()->Flatten();
wxCHECK( part, /* void */ );
std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetPartRef()->Flatten();
wxCHECK( symbol, /* void */ );
std::vector<LIB_FIELD> 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();

View File

@ -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)

View File

@ -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 ) )

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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)

View File

@ -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 <previous part>.
// <previous part> 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 <previous symbol>.
// <previous symbol> 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 <previous part>.
// <previous part> 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 <previous symbol>.
// <previous symbol> 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<EE_SELECTION_TOOL>();
selTool->RebuildSelection();
RebuildSymbolUnitsList();
SetShowDeMorgan( part->HasConversion() );
SetShowDeMorgan( symbol->HasConversion() );
RebuildView();
}

View File

@ -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<LIB_PART*> SYMBOL_LIBRARY_MANAGER::GetAliases( const wxString& aLibrary ) const
std::list<LIB_SYMBOL*> SYMBOL_LIBRARY_MANAGER::GetAliases( const wxString& aLibrary ) const
{
std::list<LIB_PART*> ret;
std::list<LIB_SYMBOL*> 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<LIB_PART*> aliases;
std::vector<LIB_SYMBOL*> aliases;
try
{
@ -380,46 +381,46 @@ std::list<LIB_PART*> 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<LIB_PART*> SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aLibrary )
std::set<LIB_SYMBOL*> SYMBOL_LIBRARY_MANAGER::getOriginalParts( const wxString& aLibrary )
{
std::set<LIB_PART*> parts;
wxCHECK( LibraryExists( aLibrary ), parts );
std::set<LIB_SYMBOL*> symbols;
wxCHECK( LibraryExists( aLibrary ), symbols );
try
{
@ -763,8 +764,8 @@ std::set<LIB_PART*> 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<LIB_PART*> 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<SCH_SCREEN> 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<SCH_SCREEN> screen( aScreen );
auto partBuf = std::make_shared<PART_BUFFER>( aCopy, std::move( screen ) );
m_parts.push_back( partBuf );
auto symbolBuf = std::make_shared<PART_BUFFER>( 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 );

View File

@ -37,7 +37,7 @@
#include <sch_io_mgr.h>
#include <sch_screen.h>
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<LIB_PART*> GetAliases( const wxString& aLibrary ) const;
std::list<LIB_SYMBOL*> 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<SYMBOL_TREE_SYNCHRONIZING_ADAPTER*>( 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<SCH_SCREEN> aScreen = nullptr );
PART_BUFFER( LIB_SYMBOL* aSymbol = nullptr, std::unique_ptr<SCH_SCREEN> 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<SCH_SCREEN> 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<PART_BUFFER::PTR> m_parts;
std::deque<PART_BUFFER::PTR> 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<LIB_PART*> getOriginalParts( const wxString& aLibrary );
std::set<LIB_SYMBOL*> getOriginalParts( const wxString& aLibrary );
/**
* Return an existing library buffer or creates one to using Symbol Library Table to get

View File

@ -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<LIB_PART*>& aSymbolList,
void SYMBOL_LIB_TABLE::LoadSymbolLib( std::vector<LIB_SYMBOL*>& 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<LIB_PART*>& 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,
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,7 +395,7 @@ 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 ),
std::unique_ptr< LIB_SYMBOL > symbol( row->plugin->LoadSymbol( row->GetFullURI( true ),
name,
row->GetProperties() ) );
@ -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;

View File

@ -29,7 +29,7 @@
#include <sch_io_mgr.h>
#include <lib_id.h>
//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<LIB_PART*>& aAliasList, const wxString& aNickname,
void LoadSymbolLib( std::vector<LIB_SYMBOL*>& 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:
//-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
/**
* 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.

Some files were not shown because too many files have changed in this diff Show More