From a11c40197f608e1bf5844a04d2ee0f385ba96309 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 4 Oct 2022 07:45:22 -0400 Subject: [PATCH] Expunge default symbol instance from schematic file format. Now that importing hierarchical sheets "properly" imports instance data, the default symbol instance setting doesn't have any meaning. --- eeschema/dialogs/dialog_sheet_properties.cpp | 12 ---- eeschema/dialogs/dialog_symbol_properties.cpp | 12 ---- .../dialogs/dialog_symbol_properties_base.cpp | 5 -- .../dialogs/dialog_symbol_properties_base.fbp | 67 ------------------- .../dialogs/dialog_symbol_properties_base.h | 1 - eeschema/files-io.cpp | 9 --- eeschema/sch_file_versions.h | 3 +- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 1 - .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 65 +++++++----------- eeschema/sch_screen.cpp | 56 +--------------- eeschema/sch_screen.h | 14 ---- eeschema/sch_sheet_path.cpp | 13 ---- eeschema/sch_sheet_path.h | 5 -- eeschema/sch_symbol.cpp | 35 ++-------- eeschema/sch_symbol.h | 20 +----- eeschema/sheet.cpp | 6 -- 16 files changed, 35 insertions(+), 289 deletions(-) diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 5f3a0bd3b9..0b281aeaec 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -381,18 +381,6 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow() if( m_sheet->IsNew() ) { m_sheet->AddInstance( instance ); - - if( filename_changed ) - { - // Set the symbol instance data to the default for all new sheets and sub-sheets. - SCH_SHEET_LIST newInstances( m_sheet ); - - for( SCH_SHEET_PATH& newInstance : newInstances ) - { - instance = m_frame->GetCurrentSheet() + newInstance; - instance.SetSymbolInstancesToDefault(); - } - } } m_sheet->SetPageNumber( instance, m_pageNumberTextCtrl->GetValue() ); diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index faa3d9f3dd..d433cb5c6b 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -797,18 +797,6 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() } } - if( m_cbMakeDefaultInstance->IsChecked() ) - { - SYMBOL_INSTANCE_REFERENCE defaultInstance; - - defaultInstance.m_Unit = unit_selection; - defaultInstance.m_Reference = m_fields->at( REFERENCE_FIELD ).GetText(); - defaultInstance.m_Value = m_fields->at( VALUE_FIELD ).GetText(); - defaultInstance.m_Footprint = m_fields->at( FOOTPRINT_FIELD ).GetText(); - - m_symbol->SetDefaultInstance( defaultInstance ); - } - currentScreen->Append( m_symbol ); GetParent()->TestDanglingEnds(); GetParent()->UpdateItem( m_symbol, false, true ); diff --git a/eeschema/dialogs/dialog_symbol_properties_base.cpp b/eeschema/dialogs/dialog_symbol_properties_base.cpp index a2946502f9..b97a13bc87 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_symbol_properties_base.cpp @@ -143,11 +143,6 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, gbSizer1->Add( m_cbAlternateSymbol, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); - m_cbMakeDefaultInstance = new wxCheckBox( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Default for all sheet instances"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cbMakeDefaultInstance->SetToolTip( _("Check to make the unit and reference, value, and\nfootprint fields the default for all sheet instances\nof this symbol") ); - - gbSizer1->Add( m_cbMakeDefaultInstance, wxGBPosition( 2, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - m_orientationLabel = new wxStaticText( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Angle:"), wxDefaultPosition, wxDefaultSize, 0 ); m_orientationLabel->Wrap( -1 ); gbSizer1->Add( m_orientationLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); diff --git a/eeschema/dialogs/dialog_symbol_properties_base.fbp b/eeschema/dialogs/dialog_symbol_properties_base.fbp index 25cf7af2a7..d2c26e5f37 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_symbol_properties_base.fbp @@ -848,73 +848,6 @@ OnCheckBox - - 5 - 2 - 0 - wxBOTTOM|wxLEFT|wxRIGHT - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Default for all sheet instances - - 0 - - - 0 - - 1 - m_cbMakeDefaultInstance - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Check to make the unit and reference, value, and footprint fields the default for all sheet instances of this symbol - - wxFILTER_NONE - wxDefaultValidator - - - - - - 5 1 diff --git a/eeschema/dialogs/dialog_symbol_properties_base.h b/eeschema/dialogs/dialog_symbol_properties_base.h index 1cba52db50..90f36d0edb 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_symbol_properties_base.h @@ -56,7 +56,6 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_unitLabel; wxChoice* m_unitChoice; wxCheckBox* m_cbAlternateSymbol; - wxCheckBox* m_cbMakeDefaultInstance; wxStaticText* m_orientationLabel; wxChoice* m_orientationCtrl; wxStaticText* m_mirrorLabel; diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 568380d7ca..033fe46ff7 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -452,15 +452,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in sheetList.UpdateSymbolInstances( Schematic().RootScreen()->GetSymbolInstances() ); sheetList.UpdateSheetInstances( Schematic().RootScreen()->GetSheetInstances() ); - - for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() ) - { - if( screen->GetFileFormatVersionAtLoad() <= 20220622 ) - { - if( screen->AllSymbolDefaultInstancesNotSet() ) - screen->SetAllSymbolDefaultInstances(); - } - } } Schematic().ConnectionGraph()->Reset(); diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 8e34202e9a..c41231869f 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -89,4 +89,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20220904 // Do not autoplace field option //#define SEXPR_SCHEMATIC_FILE_VERSION 20220914 // Add support for DNP //#define SEXPR_SCHEMATIC_FILE_VERSION 20220929 // Don't save property ID -#define SEXPR_SCHEMATIC_FILE_VERSION 20221002 // Move instance data back into symbol definition. +//#define SEXPR_SCHEMATIC_FILE_VERSION 20221002 // Move instance data back into symbol definition. +#define SEXPR_SCHEMATIC_FILE_VERSION 20221004 // Move instance data back into symbol definition. diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index c0dcb25444..e4c09b5e7f 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -2678,7 +2678,6 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() } } - symbol->SetDefaultInstance( defaultInstance ); break; } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index f2e9fc43bb..228fc3ae62 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -653,6 +653,9 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa { wxCHECK_RET( aSymbol != nullptr && m_out != nullptr, "" ); + // Sort symbol instance data to minimize file churn. + aSymbol->SortInstances( SortSymbolInstancesByProjectUuid ); + std::string libName; wxString symbol_name = aSymbol->GetLibId().Format(); @@ -732,24 +735,6 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) ); - // On the first save, if the default instance is not set, use the first instance data as - // the default. - if( aSymbol->GetDefaultInstance().m_Reference == wxEmptyString && - aSymbol->GetDefaultInstance().m_Unit == -1 && - aSymbol->GetDefaultInstance().m_Value == wxEmptyString && - aSymbol->GetDefaultInstance().m_Footprint == wxEmptyString ) - { - if( !aSymbol->GetInstanceReferences().empty() ) - aSymbol->SetDefaultInstance( aSymbol->GetInstanceReferences()[0] ); - } - - m_out->Print( aNestLevel + 1, - "(default_instance (reference %s) (unit %d) (value %s) (footprint %s))\n", - m_out->Quotew( aSymbol->GetDefaultInstance().m_Reference ).c_str(), - aSymbol->GetDefaultInstance().m_Unit, - m_out->Quotew( aSymbol->GetDefaultInstance().m_Value ).c_str(), - m_out->Quotew( aSymbol->GetDefaultInstance().m_Footprint ).c_str() ); - m_nextFreeFieldId = MANDATORY_FIELDS; for( SCH_FIELD& field : aSymbol->GetFields() ) @@ -757,21 +742,21 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa int id = field.GetId(); wxString value = field.GetText(); - if( !aForClipboard ) + if( !aForClipboard && aSymbol->GetInstanceReferences().size() ) { // The instance fields are always set to the default instance regardless of the // sheet instance to prevent file churn. if( id == REFERENCE_FIELD ) { - field.SetText( aSymbol->GetDefaultInstance().m_Reference ); + field.SetText( aSymbol->GetInstanceReferences()[0].m_Reference ); } else if( id == VALUE_FIELD ) { - field.SetText( aSymbol->GetDefaultInstance().m_Value ); + field.SetText( aSymbol->GetInstanceReferences()[0].m_Value ); } else if( id == FOOTPRINT_FIELD ) { - field.SetText( aSymbol->GetDefaultInstance().m_Footprint ); + field.SetText( aSymbol->GetInstanceReferences()[0].m_Footprint ); } } @@ -811,14 +796,10 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa m_out->Print( aNestLevel + 1, "(instances\n" ); - // Sort symbol instance data to minimize file churn. - std::vector< SYMBOL_INSTANCE_REFERENCE > sortedInstances( aSymbol->GetInstanceReferences() ); - std::sort( sortedInstances.begin(), sortedInstances.end(), SortSymbolInstancesByProjectUuid ); - KIID lastProjectUuid; SCH_SHEET_LIST fullHierarchy = m_schematic->GetSheets(); - for( size_t i = 0; i < sortedInstances.size(); i++ ) + for( size_t i = 0; i < aSymbol->GetInstanceReferences().size(); i++ ) { // If the instance data is part of this design but no longer has an associated sheet // path, don't save it. This prevents large amounts of orphaned instance data for the @@ -826,42 +807,42 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa // // Keep all instance data when copying to the clipboard. It may be needed on paste. if( !aForClipboard - && ( sortedInstances[i].m_Path[0] == m_schematic->RootScreen()->GetUuid() ) - && !fullHierarchy.GetSheetPathByKIIDPath( sortedInstances[i].m_Path ) ) + && ( aSymbol->GetInstanceReferences()[i].m_Path[0] == m_schematic->RootScreen()->GetUuid() ) + && !fullHierarchy.GetSheetPathByKIIDPath( aSymbol->GetInstanceReferences()[i].m_Path ) ) { - if( ( i + 1 == sortedInstances.size() ) - || lastProjectUuid != sortedInstances[i+1].m_Path[0] ) + if( ( i + 1 == aSymbol->GetInstanceReferences().size() ) + || lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] ) m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`. continue; } - if( lastProjectUuid != sortedInstances[i].m_Path[0] ) + if( lastProjectUuid != aSymbol->GetInstanceReferences()[i].m_Path[0] ) { wxString projectName; - if( sortedInstances[i].m_Path[0] == m_schematic->RootScreen()->GetUuid() ) + if( aSymbol->GetInstanceReferences()[i].m_Path[0] == m_schematic->RootScreen()->GetUuid() ) projectName = m_schematic->Prj().GetProjectName(); else - projectName = sortedInstances[i].m_ProjectName; + projectName = aSymbol->GetInstanceReferences()[i].m_ProjectName; - lastProjectUuid = sortedInstances[i].m_Path[0]; + lastProjectUuid = aSymbol->GetInstanceReferences()[i].m_Path[0]; m_out->Print( aNestLevel + 2, "(project %s\n", m_out->Quotew( projectName ).c_str() ); } - wxString path = sortedInstances[i].m_Path.AsString(); + wxString path = aSymbol->GetInstanceReferences()[i].m_Path.AsString(); m_out->Print( aNestLevel + 3, "(path %s\n", m_out->Quotew( path ).c_str() ); m_out->Print( aNestLevel + 4, "(reference %s) (unit %d) (value %s) (footprint %s)\n", - m_out->Quotew( sortedInstances[i].m_Reference ).c_str(), - sortedInstances[i].m_Unit, - m_out->Quotew( sortedInstances[i].m_Value ).c_str(), - m_out->Quotew( sortedInstances[i].m_Footprint ).c_str() ); + m_out->Quotew( aSymbol->GetInstanceReferences()[i].m_Reference ).c_str(), + aSymbol->GetInstanceReferences()[i].m_Unit, + m_out->Quotew( aSymbol->GetInstanceReferences()[i].m_Value ).c_str(), + m_out->Quotew( aSymbol->GetInstanceReferences()[i].m_Footprint ).c_str() ); m_out->Print( aNestLevel + 3, ")\n" ); - if( ( i + 1 == sortedInstances.size() ) - || lastProjectUuid != sortedInstances[i+1].m_Path[0] ) + if( ( i + 1 == aSymbol->GetInstanceReferences().size() ) + || lastProjectUuid != aSymbol->GetInstanceReferences()[i+1].m_Path[0] ) m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`. } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 66a61d7f3b..4ae0d49a1b 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1441,46 +1441,6 @@ void SCH_SCREEN::SetLegacySymbolInstanceData() } -bool SCH_SCREEN::AllSymbolDefaultInstancesNotSet() -{ - for( SCH_ITEM* item : Items().OfType( SCH_SYMBOL_T ) ) - { - SCH_SYMBOL* symbol = static_cast( item ); - - wxCHECK2( symbol, continue ); - - SYMBOL_INSTANCE_REFERENCE symbolDefaultReference = symbol->GetDefaultInstance(); - - const std::unique_ptr& libSymbol = symbol->GetLibSymbolRef(); - - if( !libSymbol ) - continue; - - if( symbolDefaultReference.m_Unit != 1 || - symbolDefaultReference.m_Reference != symbol->GetPrefix() || - symbolDefaultReference.m_Value != libSymbol->GetValueField().GetText() || - symbolDefaultReference.m_Footprint != libSymbol->GetFootprintField().GetText() ) - return false; - } - - return true; -} - - -void SCH_SCREEN::SetAllSymbolDefaultInstances() -{ - for( SCH_ITEM* item : Items().OfType( SCH_SYMBOL_T ) ) - { - SCH_SYMBOL* symbol = static_cast( item ); - - wxCHECK2( symbol, continue ); - - if( !symbol->GetInstanceReferences().empty() ) - symbol->SetDefaultInstance( symbol->GetInstanceReferences()[0] ); - } -} - - #if defined(DEBUG) void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const { @@ -1864,7 +1824,7 @@ void SCH_SCREENS::BuildClientSheetPathList() { SCH_SCREEN* used_screen = sheetpath.LastScreen(); - // SEarch for the used_screen in list and add this unique sheet path: + // Search for the used_screen in list and add this unique sheet path: for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() ) { if( used_screen == curr_screen ) @@ -1879,20 +1839,6 @@ void SCH_SCREENS::BuildClientSheetPathList() void SCH_SCREENS::SetLegacySymbolInstanceData() { - for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() ) screen->SetLegacySymbolInstanceData(); } - - -void SCH_SCREENS::SetAllSymbolDefaultInstances() -{ - for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() ) - { - if( screen->GetFileFormatVersionAtLoad() <= 20220622 ) - { - if( screen->AllSymbolDefaultInstancesNotSet() ) - screen->SetAllSymbolDefaultInstances(); - } - } -} diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index e3bd72aa30..74ed079c96 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -509,13 +509,6 @@ public: */ bool AllSymbolDefaultInstancesNotSet(); - /** - * Set symbol default instances to the first instance in the instance list. - * - * @warning The schematic symbol instance data must be loaded before this method is called. - */ - void SetAllSymbolDefaultInstances(); - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override; #endif @@ -739,13 +732,6 @@ public: */ void SetLegacySymbolInstanceData(); - /** - * Set symbol default instances to the first instance in the instance list. - * - * @warning The schematic symbol instance data must be loaded before this method is called. - */ - void SetAllSymbolDefaultInstances(); - private: void addScreenToList( SCH_SCREEN* aScreen, SCH_SHEET* aSheet ); void buildScreenList( SCH_SHEET* aSheet); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index e5b6c5f2a0..d4c4e35c84 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -414,19 +414,6 @@ void SCH_SHEET_PATH::AppendMultiUnitSymbol( SCH_MULTI_UNIT_REFERENCE_MAP& aRefLi } -void SCH_SHEET_PATH::SetSymbolInstancesToDefault() -{ - for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) - { - SCH_SYMBOL* symbol = static_cast( item ); - - wxCHECK2( symbol, continue ); - - symbol->SetInstanceToDefault( *this ); - } -} - - bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const { return m_current_hash == d1.GetCurrentHash(); diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 031fe050af..a1c84c2597 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -339,11 +339,6 @@ public: void GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols = true ) const; - /** - * Set all of the symbol instances in this sheet instance to the default symbol instance data. - */ - void SetSymbolInstancesToDefault(); - /** * Test the SCH_SHEET_PATH file names to check adding the sheet stored in the file * \a aSrcFileName to the sheet stored in file \a aDestFileName will cause a sheet diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 9f0a4d4636..d78a3b3339 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -132,9 +132,6 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, m_prefix = UTIL::GetRefDesPrefix( m_part->GetReferenceField().GetText() ); - // Set initial default symbol instance data from library symbol and initial unit. - m_defaultInstance.m_Unit = -1; - if( aSheet ) { SetRef( aSheet, UTIL::GetRefDesUnannotated( m_prefix ) ); @@ -199,7 +196,6 @@ SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) : m_fieldsAutoplaced = aSymbol.m_fieldsAutoplaced; m_schLibSymbolName = aSymbol.m_schLibSymbolName; - m_defaultInstance = aSymbol.m_defaultInstance; } @@ -522,6 +518,13 @@ void SCH_SYMBOL::RemoveInstance( const SCH_SHEET_PATH& aInstancePath ) } +void SCH_SYMBOL::SortInstances( bool (*aSortFunction)( const SYMBOL_INSTANCE_REFERENCE& aLhs, + const SYMBOL_INSTANCE_REFERENCE& aRhs ) ) +{ + std::sort( m_instanceReferences.begin(), m_instanceReferences.end(), aSortFunction ); +} + + void SCH_SYMBOL::AddHierarchicalReference( const KIID_PATH& aPath, const wxString& aRef, int aUnit, const wxString& aValue, const wxString& aFootprint ) @@ -1144,7 +1147,6 @@ void SCH_SYMBOL::SwapData( SCH_ITEM* aItem ) std::swap( m_instanceReferences, symbol->m_instanceReferences ); std::swap( m_schLibSymbolName, symbol->m_schLibSymbolName ); - std::swap( m_defaultInstance, symbol->m_defaultInstance ); } @@ -2042,7 +2044,6 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem ) m_transform = c->m_transform; m_instanceReferences = c->m_instanceReferences; - m_defaultInstance = c->m_defaultInstance; m_fields = c->m_fields; // std::vector's assignment operator @@ -2255,25 +2256,3 @@ bool SCH_SYMBOL::IsPointClickableAnchor( const VECTOR2I& aPos ) const return false; } - - -void SCH_SYMBOL::SetInstanceToDefault( const SCH_SHEET_PATH& aInstance ) -{ - KIID_PATH path = aInstance.Path(); - - for( SYMBOL_INSTANCE_REFERENCE& instance: m_instanceReferences ) - { - if( instance.m_Path == path ) - { - instance.m_Reference = m_defaultInstance.m_Reference; - instance.m_Unit = m_defaultInstance.m_Unit; - instance.m_Value = m_defaultInstance.m_Value; - instance.m_Footprint = m_defaultInstance.m_Footprint; - return; - } - } - - // It's a new instance so add it. - AddHierarchicalReference( path, m_defaultInstance.m_Reference, m_defaultInstance.m_Unit, - m_defaultInstance.m_Value, m_defaultInstance.m_Footprint ); -} diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 84db210365..0d66e4080b 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -144,16 +144,10 @@ public: bool GetInstance( SYMBOL_INSTANCE_REFERENCE& aInstance, const KIID_PATH& aSheetPath ) const; - void SetDefaultInstance( const SYMBOL_INSTANCE_REFERENCE& aInstance ) - { - m_defaultInstance = aInstance; - } - void RemoveInstance( const SCH_SHEET_PATH& aInstancePath ); - const SYMBOL_INSTANCE_REFERENCE& GetDefaultInstance() const { return m_defaultInstance; } - - void SetInstanceToDefault( const SCH_SHEET_PATH& aInstance ); + void SortInstances( bool ( *aSortFunction )( const SYMBOL_INSTANCE_REFERENCE& aLhs, + const SYMBOL_INSTANCE_REFERENCE& aRhs ) ); void ViewGetLayers( int aLayers[], int& aCount ) const override; @@ -802,16 +796,6 @@ private: // Defines the hierarchical path and reference of the symbol. This allows support // for multiple references to a single sub-sheet. std::vector m_instanceReferences; - - /** - * The default instance data for this symbol. - * - * This allows for setting the default data across all instances of this symbol. This - * means that any reuse of the symbol in the current schematic will initially use the - * default instance data. @see SYMBOL_INSTANCE_REFERENCE definition for the allowable - * instance settings. - */ - SYMBOL_INSTANCE_REFERENCE m_defaultInstance; }; #endif /* __SYMBOL_H__ */ diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index b60bd8fba5..d39cf10a34 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -493,12 +493,6 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier // instances. sheetHierarchy.UpdateSymbolInstances( newScreen->GetSymbolInstances() ); } - else - { - // Otherwise, fall back to the default instance data which still exists in this - // schematic file version. - newScreens.SetAllSymbolDefaultInstances(); - } } // Attempt to create new symbol instances using the instance data loaded above.