From a60ed99510054d1cddc8f945fa26b37c0c120e2b Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 29 Sep 2022 15:16:54 -0400 Subject: [PATCH] Revert "Add project name to symbol instance data." This reverts commit 4b276b339aa2fc3942ba535ae4339b436be18867. --- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 75 +++++++------------ .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 40 +++------- eeschema/sch_plugins/kicad/sch_sexpr_plugin.h | 2 +- eeschema/sch_sheet_path.cpp | 9 --- eeschema/sch_sheet_path.h | 7 -- eeschema/schematic.keywords | 1 - eeschema/sheet.cpp | 5 +- 7 files changed, 42 insertions(+), 97 deletions(-) diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 95bb7e5f1b..b4e9f97696 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -2641,12 +2641,13 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() token = NextTok(); - if( token != T_project ) - Expecting( "project" ); + if( token != T_path ) + Expecting( "path" ); + + SYMBOL_INSTANCE_REFERENCE instance; NeedSYMBOL(); - - wxString projectName = FromUTF8(); + instance.m_Path = KIID_PATH( FromUTF8() ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -2655,54 +2656,36 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() token = NextTok(); - if( token != T_path ) - Expecting( "path" ); - - SYMBOL_INSTANCE_REFERENCE instance; - - instance.m_ProjectName = projectName; - - NeedSYMBOL(); - instance.m_Path = KIID_PATH( FromUTF8() ); - - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + switch( token ) { - if( token != T_LEFT ) - Expecting( T_LEFT ); + case T_reference: + NeedSYMBOL(); + instance.m_Reference = FromUTF8(); + NeedRIGHT(); + break; - token = NextTok(); + case T_unit: + instance.m_Unit = parseInt( "symbol unit" ); + NeedRIGHT(); + break; - switch( token ) - { - case T_reference: - NeedSYMBOL(); - instance.m_Reference = FromUTF8(); - NeedRIGHT(); - break; + case T_value: + NeedSYMBOL(); + instance.m_Value = FromUTF8(); + NeedRIGHT(); + break; - case T_unit: - instance.m_Unit = parseInt( "symbol unit" ); - NeedRIGHT(); - break; + case T_footprint: + NeedSYMBOL(); + instance.m_Footprint = FromUTF8(); + NeedRIGHT(); + break; - case T_value: - NeedSYMBOL(); - instance.m_Value = FromUTF8(); - NeedRIGHT(); - break; - - case T_footprint: - NeedSYMBOL(); - instance.m_Footprint = FromUTF8(); - NeedRIGHT(); - break; - - default: - Expecting( "reference, unit, value or footprint" ); - } - - symbol->AddHierarchicalReference( instance ); + default: + Expecting( "reference, unit, value or footprint" ); } + + symbol->AddHierarchicalReference( instance ); } } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 566ab4f4d3..17c529f3a2 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -811,40 +811,18 @@ 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; - - for( size_t i = 0; i < sortedInstances.size(); i++ ) + for( const SYMBOL_INSTANCE_REFERENCE& instance : aSymbol->GetInstanceReferences() ) { - if( lastProjectUuid != sortedInstances[i].m_Path[0] ) - { - wxString projectName; + wxString path = instance.m_Path.AsString(); - if( sortedInstances[i].m_Path[0] == m_schematic->RootScreen()->GetUuid() ) - projectName = m_schematic->Prj().GetProjectName(); - else - projectName = sortedInstances[i].m_ProjectName; - - lastProjectUuid = sortedInstances[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(); - - m_out->Print( aNestLevel + 3, "(path %s\n", + m_out->Print( aNestLevel + 2, "(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->Print( aNestLevel + 3, ")\n" ); - - if( i + 1 == sortedInstances.size() || lastProjectUuid != sortedInstances[i+1].m_Path[0] ) - m_out->Print( aNestLevel + 2, ")\n" ); // Closes `project`. + m_out->Print( aNestLevel + 3, "(reference %s) (unit %d) (value %s) (footprint %s)\n", + m_out->Quotew( instance.m_Reference ).c_str(), + instance.m_Unit, + m_out->Quotew( instance.m_Value ).c_str(), + m_out->Quotew( instance.m_Footprint ).c_str() ); + m_out->Print( aNestLevel + 2, ")\n" ); } m_out->Print( aNestLevel + 1, ")\n" ); // Closes `instances`. diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h index d02790f999..0094384ce9 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h @@ -5,7 +5,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 CERN - * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Wayne Stambaugh * diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 2c3b3e6141..75a3739e08 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -91,15 +91,6 @@ public: }; -bool SortSymbolInstancesByProjectUuid( const SYMBOL_INSTANCE_REFERENCE& aLhs, - const SYMBOL_INSTANCE_REFERENCE& aRhs ) -{ - wxCHECK2( !aLhs.m_Path.empty() && !aRhs.m_Path.empty(), false ); - - return aLhs.m_Path[0] < aRhs.m_Path[0]; -} - - namespace std { size_t hash::operator()( const SCH_SHEET_PATH& path ) const diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 3401f52396..9e98b581cf 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -51,16 +51,9 @@ struct SYMBOL_INSTANCE_REFERENCE // Things that can be back-annotated: wxString m_Value; wxString m_Footprint; - - // The project name associated with this instance. - wxString m_ProjectName; }; -extern bool SortSymbolInstancesByProjectUuid( const SYMBOL_INSTANCE_REFERENCE& aLhs, - const SYMBOL_INSTANCE_REFERENCE& aRhs ); - - /** * A simple container for sheet instance information. */ diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 3c5b4ab038..21778f53f6 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -103,7 +103,6 @@ power power_in power_out private -project property property_del pts diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 8cd04a40c9..d9cd06c6ab 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2022 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 @@ -238,7 +238,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier "lastest file version will resolve this issue.\n\n" "Do you wish to continue?" ); wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION ); + wxOK | wxCANCEL | wxCANCEL_DEFAULT | + wxCENTER | wxICON_QUESTION ); msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); if( msgDlg7.ShowModal() == wxID_CANCEL )