Move setting derived symbol field properties from parent symbol.
In order allow the new file format to support derived symbols with field properties that are different than the parent symbol, the code that copied the parent field properties to the derive symbol field properties had to moved out of LIB_PART::SetParent() into the legacy symbol library plugin and the symbol library editor add new symbol code to preserve the current behavior and not overwrite derived symbol field properties. This lays the ground work for allowing field properties of derived symbols to be different than their parent symbol.
This commit is contained in:
parent
57e35c9a60
commit
dd1a7627f8
|
@ -319,38 +319,10 @@ void LIB_PART::SetName( const wxString& aName )
|
||||||
void LIB_PART::SetParent( LIB_PART* aParent )
|
void LIB_PART::SetParent( LIB_PART* aParent )
|
||||||
{
|
{
|
||||||
if( aParent )
|
if( aParent )
|
||||||
{
|
|
||||||
m_parent = aParent->SharedPtr();
|
m_parent = aParent->SharedPtr();
|
||||||
|
|
||||||
// Inherit the parent mandatory field attributes.
|
|
||||||
for( int id=0; id<MANDATORY_FIELDS; ++id )
|
|
||||||
{
|
|
||||||
LIB_FIELD* field = GetField( id );
|
|
||||||
|
|
||||||
// the MANDATORY_FIELDS are exactly that in RAM.
|
|
||||||
wxASSERT( field );
|
|
||||||
|
|
||||||
LIB_FIELD* parentField = aParent->GetField( id );
|
|
||||||
|
|
||||||
wxASSERT( parentField );
|
|
||||||
|
|
||||||
wxString name = field->GetText();
|
|
||||||
|
|
||||||
*field = *parentField;
|
|
||||||
|
|
||||||
if( id == VALUE )
|
|
||||||
field->SetText( name );
|
|
||||||
else if( id == DATASHEET && !GetDocFileName().IsEmpty() )
|
|
||||||
field->SetText( GetDocFileName() );
|
|
||||||
|
|
||||||
field->SetParent( this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_parent.reset();
|
m_parent.reset();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr< LIB_PART > LIB_PART::Flatten() const
|
std::unique_ptr< LIB_PART > LIB_PART::Flatten() const
|
||||||
|
|
|
@ -360,6 +360,26 @@ void LIB_EDIT_FRAME::CreateNewPart()
|
||||||
LIB_PART* parent = m_libMgr->GetAlias( parentSymbolName, lib );
|
LIB_PART* parent = m_libMgr->GetAlias( parentSymbolName, lib );
|
||||||
wxCHECK( parent, /* void */ );
|
wxCHECK( parent, /* void */ );
|
||||||
new_part.SetParent( parent );
|
new_part.SetParent( parent );
|
||||||
|
|
||||||
|
// Inherit the parent mandatory field attributes.
|
||||||
|
for( int id=0; id<MANDATORY_FIELDS; ++id )
|
||||||
|
{
|
||||||
|
LIB_FIELD* field = new_part.GetField( id );
|
||||||
|
|
||||||
|
// the MANDATORY_FIELDS are exactly that in RAM.
|
||||||
|
wxCHECK( field, /* void */ );
|
||||||
|
|
||||||
|
LIB_FIELD* parentField = parent->GetField( id );
|
||||||
|
|
||||||
|
wxCHECK( parentField, /* void */ );
|
||||||
|
|
||||||
|
*field = *parentField;
|
||||||
|
|
||||||
|
if( id == VALUE )
|
||||||
|
field->SetText( name );
|
||||||
|
|
||||||
|
field->SetParent( &new_part );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_libMgr->UpdatePart( &new_part, lib );
|
m_libMgr->UpdatePart( &new_part, lib );
|
||||||
|
|
|
@ -2965,6 +2965,26 @@ void SCH_LEGACY_PLUGIN_CACHE::loadAliases( std::unique_ptr<LIB_PART>& aPart,
|
||||||
{
|
{
|
||||||
LIB_PART* newPart = new LIB_PART( newAliasName );
|
LIB_PART* newPart = new LIB_PART( newAliasName );
|
||||||
|
|
||||||
|
// Inherit the parent mandatory field attributes.
|
||||||
|
for( int id=0; id<MANDATORY_FIELDS; ++id )
|
||||||
|
{
|
||||||
|
LIB_FIELD* field = newPart->GetField( id );
|
||||||
|
|
||||||
|
// the MANDATORY_FIELDS are exactly that in RAM.
|
||||||
|
wxASSERT( field );
|
||||||
|
|
||||||
|
LIB_FIELD* parentField = aPart->GetField( id );
|
||||||
|
|
||||||
|
wxASSERT( parentField );
|
||||||
|
|
||||||
|
*field = *parentField;
|
||||||
|
|
||||||
|
if( id == VALUE )
|
||||||
|
field->SetText( newAliasName );
|
||||||
|
|
||||||
|
field->SetParent( newPart );
|
||||||
|
}
|
||||||
|
|
||||||
newPart->SetParent( aPart.get() );
|
newPart->SetParent( aPart.get() );
|
||||||
|
|
||||||
// This will prevent duplicate aliases.
|
// This will prevent duplicate aliases.
|
||||||
|
|
Loading…
Reference in New Issue