Update symbol default prefixes after updating instance data.
Also moves the sim model fixups after the instance data updating as it uses the prefixes.
This commit is contained in:
parent
69448afb47
commit
b9287968d6
|
@ -87,18 +87,19 @@ static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFil
|
|||
SCH_SCREENS screens( schematic->Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST sheets = schematic->GetSheets();
|
||||
|
||||
// Restore all of the loaded symbol instances from the root sheet screen.
|
||||
sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
|
||||
|
||||
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
sheets.AnnotatePowerSymbols();
|
||||
|
||||
// NOTE: This is required for multi-unit symbols to be correct
|
||||
|
|
|
@ -139,18 +139,19 @@ SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH
|
|||
SCH_SCREENS screens( schematic->Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221002 )
|
||||
sheetList.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances());
|
||||
|
||||
sheetList.UpdateSheetInstanceData( schematic->RootScreen()->GetSheetInstances());
|
||||
|
||||
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
sheetList.AnnotatePowerSymbols();
|
||||
|
||||
schematic->ConnectionGraph()->Reset();
|
||||
|
|
|
@ -447,19 +447,20 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
}
|
||||
|
||||
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
|
||||
{
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
// Restore all of the loaded symbol and sheet instances from the root sheet.
|
||||
if( Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221002 )
|
||||
sheetList.UpdateSymbolInstanceData( Schematic().RootScreen()->GetSymbolInstances());
|
||||
|
||||
if( Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221110 )
|
||||
sheetList.UpdateSheetInstanceData( Schematic().RootScreen()->GetSheetInstances());
|
||||
|
||||
if( Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
}
|
||||
|
||||
Schematic().ConnectionGraph()->Reset();
|
||||
|
|
|
@ -2829,38 +2829,14 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
|
|||
field->SetId( nextAvailableId );
|
||||
}
|
||||
|
||||
// Set the default symbol reference prefix.
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
{
|
||||
wxString refDesignator = field->GetText();
|
||||
|
||||
refDesignator.Replace( "~", " " );
|
||||
|
||||
wxString prefix = refDesignator;
|
||||
|
||||
while( prefix.Length() )
|
||||
{
|
||||
if( ( prefix.Last() < '0' || prefix.Last() > '9' ) && prefix.Last() != '?' )
|
||||
break;
|
||||
|
||||
prefix.RemoveLast();
|
||||
}
|
||||
|
||||
// Avoid a prefix containing trailing/leading spaces
|
||||
prefix.Trim( true );
|
||||
prefix.Trim( false );
|
||||
|
||||
if( prefix.IsEmpty() )
|
||||
symbol->SetPrefix( wxString( "U" ) );
|
||||
else
|
||||
symbol->SetPrefix( prefix );
|
||||
}
|
||||
|
||||
if( symbol->GetFieldById( field->GetId() ) )
|
||||
*symbol->GetFieldById( field->GetId() ) = *field;
|
||||
else
|
||||
symbol->AddField( *field );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
symbol->UpdatePrefix();
|
||||
|
||||
m_fieldIDsRead.insert( field->GetId() );
|
||||
|
||||
delete field;
|
||||
|
|
|
@ -1123,6 +1123,7 @@ void SCH_SHEET_LIST::UpdateSymbolInstanceData(
|
|||
symbol->GetField( REFERENCE_FIELD )->SetText( it->m_Reference );
|
||||
symbol->SetValueFieldText( it->m_Value );
|
||||
symbol->SetFootprintFieldText( it->m_Footprint );
|
||||
symbol->UpdatePrefix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -713,6 +713,31 @@ bool SCH_SYMBOL::IsAnnotated( const SCH_SHEET_PATH* aSheet )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::UpdatePrefix()
|
||||
{
|
||||
wxString refDesignator = GetField( REFERENCE_FIELD )->GetText();
|
||||
|
||||
refDesignator.Replace( "~", " " );
|
||||
|
||||
wxString prefix = refDesignator;
|
||||
|
||||
while( prefix.Length() )
|
||||
{
|
||||
if( ( prefix.Last() < '0' || prefix.Last() > '9' ) && prefix.Last() != '?' )
|
||||
break;
|
||||
|
||||
prefix.RemoveLast();
|
||||
}
|
||||
|
||||
// Avoid a prefix containing trailing/leading spaces
|
||||
prefix.Trim( true );
|
||||
prefix.Trim( false );
|
||||
|
||||
if( !prefix.IsEmpty() )
|
||||
SetPrefix( prefix );
|
||||
}
|
||||
|
||||
|
||||
int SCH_SYMBOL::GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const
|
||||
{
|
||||
KIID_PATH path = aSheet->Path();
|
||||
|
|
|
@ -274,6 +274,11 @@ public:
|
|||
|
||||
void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
|
||||
|
||||
/**
|
||||
* Set the prefix based on the current reference designator.
|
||||
*/
|
||||
void UpdatePrefix();
|
||||
|
||||
TRANSFORM& GetTransform() { return m_transform; }
|
||||
const TRANSFORM& GetTransform() const { return m_transform; }
|
||||
|
||||
|
|
|
@ -140,19 +140,20 @@ void LoadSchematic( SETTINGS_MANAGER& aSettingsManager, const wxString& aRelPath
|
|||
SCH_SCREENS screens( aSchematic->Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST sheets = aSchematic->GetSheets();
|
||||
|
||||
// Restore all of the loaded symbol instances from the root sheet screen.
|
||||
sheets.UpdateSymbolInstanceData( aSchematic->RootScreen()->GetSymbolInstances() );
|
||||
sheets.UpdateSheetInstanceData( aSchematic->RootScreen()->GetSheetInstances() );
|
||||
|
||||
if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
sheets.AnnotatePowerSymbols();
|
||||
|
||||
// NOTE: This is required for multi-unit symbols to be correct
|
||||
|
|
|
@ -87,13 +87,8 @@ void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic( const wxString& aBaseName )
|
|||
SCH_SCREENS screens( m_schematic.Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.GetSheets();
|
||||
|
||||
// Restore all of the loaded symbol instances from the root sheet screen.
|
||||
|
@ -103,6 +98,12 @@ void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic( const wxString& aBaseName )
|
|||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221110 )
|
||||
sheets.UpdateSheetInstanceData( m_schematic.RootScreen()->GetSheetInstances());
|
||||
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
sheets.AnnotatePowerSymbols();
|
||||
|
||||
// NOTE: This is required for multi-unit symbols to be correct
|
||||
|
|
Loading…
Reference in New Issue