Fix SCH_SYMBOL's operator=.

Also cleans up a few loose ends from LIB_ITEM collapse.
This commit is contained in:
Jeff Young 2024-04-08 21:24:32 +01:00
parent 6c7946012c
commit e7493c7851
6 changed files with 32 additions and 46 deletions

View File

@ -169,23 +169,17 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol )
if( &aSymbol == this )
return aSymbol;
SCH_ITEM* newItem;
SYMBOL::operator=( aSymbol );
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_excludedFromSim = aSymbol.m_excludedFromSim;
m_excludedFromBOM = aSymbol.m_excludedFromBOM;
m_excludedFromBoard = aSymbol.m_excludedFromBoard;
m_lastModDate = aSymbol.m_lastModDate;
m_options = aSymbol.m_options;
m_libId = aSymbol.m_libId;
m_keyWords = aSymbol.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_lastModDate = aSymbol.m_lastModDate;
m_options = aSymbol.m_options;
m_libId = aSymbol.m_libId;
m_keyWords = aSymbol.m_keyWords;
m_unitDisplayNames.clear();
aSymbol.CopyUnitDisplayNames( m_unitDisplayNames );
@ -197,7 +191,7 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol )
if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
continue;
newItem = (SCH_ITEM*) oldItem.Clone();
SCH_ITEM* newItem = (SCH_ITEM*) oldItem.Clone();
newItem->SetParent( this );
m_drawings.push_back( newItem );
}

View File

@ -335,9 +335,6 @@ public:
return GetValueField().GetText();
}
int GetUnit() const override { return 0; }
int GetBodyStyle() const override { return 0; }
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
/**

View File

@ -231,10 +231,10 @@ public:
static wxString GetUnitDescription( int aUnit );
static wxString GetBodyStyleDescription( int aBodyStyle );
void SetUnit( int aUnit ) { m_unit = aUnit; }
virtual void SetUnit( int aUnit ) { m_unit = aUnit; }
int GetUnit() const { return m_unit; }
void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
virtual void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
int GetBodyStyle() const { return m_bodyStyle; }
void SetPrivate( bool aPrivate ) { m_private = aPrivate; }

View File

@ -2354,7 +2354,7 @@ bool SCH_SYMBOL::operator!=( const SCH_SYMBOL& aSymbol ) const
}
SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem )
SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_SYMBOL& aItem )
{
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
@ -2362,7 +2362,7 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem )
if( &aItem != this )
{
SCH_ITEM::operator=( aItem );
SYMBOL::operator=( aItem );
SCH_SYMBOL* c = (SCH_SYMBOL*) &aItem;
@ -2792,19 +2792,6 @@ static struct SCH_SYMBOL_DESC
&SCH_SYMBOL::GetShowPinNames ) )
.SetAvailableFunc( hasLibPart );
auto isMultiUnitSymbol =
[]( INSPECTABLE* aItem ) -> bool
{
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) )
return symbol->GetUnitCount() > 1;
return false;
};
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Unit" ),
&SCH_SYMBOL::SetUnit, &SCH_SYMBOL::GetUnit ) )
.SetAvailableFunc( isMultiUnitSymbol );
const wxString groupFields = _HKI( "Fields" );
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, wxString>( _HKI( "Reference" ),

View File

@ -252,9 +252,6 @@ public:
*/
wxString GetDatasheet() const;
int GetUnit() const override { return m_unit; }
void SetUnit( int aUnit ) { m_unit = aUnit; }
/**
* Updates the cache of SCH_PIN objects for each pin
*/
@ -274,8 +271,7 @@ public:
*/
wxString GetUnitDisplayName( int aUnit );
int GetBodyStyle() const override { return m_bodyStyle; }
void SetBodyStyle( int aBodyStyle );
void SetBodyStyle( int aBodyStyle ) override;
bool HasAlternateBodyStyle() const override;
@ -772,7 +768,7 @@ public:
bool operator==( const SCH_SYMBOL& aSymbol) const;
bool operator!=( const SCH_SYMBOL& aSymbol) const;
SCH_SYMBOL& operator=( const SCH_ITEM& aItem );
SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
bool IsReplaceable() const override { return true; }

View File

@ -65,6 +65,21 @@ public:
m_excludedFromBoard( base.m_excludedFromBoard )
{ };
SYMBOL& operator=( const SYMBOL& aItem )
{
SCH_ITEM::operator=( aItem );
m_pinNameOffset = aItem.m_pinNameOffset;
m_showPinNames = aItem.m_showPinNames;
m_showPinNumbers = aItem.m_showPinNumbers;
m_excludedFromSim = aItem.m_excludedFromSim;
m_excludedFromBOM = aItem.m_excludedFromBOM;
m_excludedFromBoard = aItem.m_excludedFromBoard;
return *this;
};
virtual ~SYMBOL() { };
virtual const LIB_ID& GetLibId() const = 0;
@ -97,9 +112,6 @@ public:
virtual const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
bool aAllowExtraText ) const = 0;
virtual int GetUnit() const = 0;
virtual int GetBodyStyle() const = 0;
/**
* Set the offset in mils of the pin name text from the pin symbol.
*