From 73dc53dc35155b8c8aabe18aceb75149db654e9a Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 15 Feb 2016 15:18:32 -0500 Subject: [PATCH] Undo commit -r 6413. --- eeschema/component_references_lister.cpp | 6 +-- .../dialog_edit_component_in_schematic.cpp | 3 +- eeschema/dialogs/dialog_erc.cpp | 4 +- eeschema/edit_component_in_schematic.cpp | 7 ++- eeschema/netlist.cpp | 4 +- eeschema/sch_component.cpp | 8 ++-- eeschema/sch_component.h | 2 +- eeschema/sch_field.cpp | 3 +- eeschema/sch_sheet.cpp | 38 --------------- eeschema/sch_sheet.h | 12 ----- eeschema/sch_sheet_path.cpp | 46 +++++++++++++++++++ eeschema/sch_sheet_path.h | 21 ++++++++- 12 files changed, 82 insertions(+), 72 deletions(-) diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 93ce5ab35e..6796ef398a 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -694,7 +694,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) } -SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent, +SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent, SCH_SHEET_PATH& aSheetPath ) { wxASSERT( aComponent != NULL && aLibComponent != NULL ); @@ -710,7 +710,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent m_SheetNum = 0; if( aComponent->GetRef( &aSheetPath ).IsEmpty() ) - aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) ); + aComponent->SetRef( &aSheetPath, wxT( "DefRef?" ) ); SetRef( aComponent->GetRef( &aSheetPath ) ); @@ -730,7 +730,7 @@ void SCH_REFERENCE::Annotate() else m_Ref = TO_UTF8( GetRef() << m_NumRef ); - m_RootCmp->SetRef( m_SheetPath.Last(), FROM_UTF8( m_Ref.c_str() ) ); + m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) ); m_RootCmp->SetUnit( m_Unit ); m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit ); } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 6aaf17a358..2e974e18d2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include @@ -459,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // Reference has a specific initialization, depending on the current active sheet // because for a given component, in a complex hierarchy, there are more than one // reference. - m_cmp->SetRef( m_parent->GetCurrentSheet().Last(), m_FieldsBuf[REFERENCE].GetText() ); + m_cmp->SetRef( &m_parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() ); m_parent->OnModify(); m_parent->GetScreen()->TestDanglingEnds(); diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index d7208aa2ba..87acb30d5f 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -455,8 +455,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->GetValue(); // Build the whole sheet list in hierarchy (sheet, not screen) - int refDes = 1; - g_RootSheet->AnnotatePowerSymbols( Prj().SchLibs(), &refDes ); + SCH_SHEET_LIST sheets; + sheets.AnnotatePowerSymbols( Prj().SchLibs() ); if( m_parent->CheckAnnotate( aMessagesList, false ) ) { diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 0d899b24dc..c9294a59cd 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2008-2015 Wayne Stambaugh - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2008-2013 Wayne Stambaugh + * Copyright (C) 2004-2013 KiCad Developers, see change_log.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 @@ -38,7 +38,6 @@ #include #include #include -#include #include @@ -102,7 +101,7 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField ) // Test if the reference string is valid: if( SCH_COMPONENT::IsReferenceStringValid( newtext ) ) { - component->SetRef( m_CurrentSheet->Last(), newtext ); + component->SetRef( m_CurrentSheet, newtext ); } else { diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index edcce6b089..ebc324570a 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -67,9 +67,9 @@ int TestDuplicateSheetNames( bool aCreateMarker ); bool SCH_EDIT_FRAME::prepareForNetlist() { - int refDes = 1; + SCH_SHEET_LIST sheets; - g_RootSheet->AnnotatePowerSymbols( Prj().SchLibs(), &refDes ); + sheets.AnnotatePowerSymbols( Prj().SchLibs() ); // Performs some controls: if( CheckAnnotate( NULL, 0 ) ) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 9077d89249..1bec57f4f5 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -186,7 +186,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit, // update the reference -- just the prefix for now. msg += wxT( "?" ); - SetRef( sheet->Last(), msg ); + SetRef( sheet, msg ); // Use the schematic component name instead of the library value field // name. @@ -473,7 +473,7 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet ) // all have the same component references, but perhaps this is best. if( !GetField( REFERENCE )->GetText().IsEmpty() ) { - SetRef( sheet->Last(), GetField( REFERENCE )->GetText() ); + SetRef( sheet, GetField( REFERENCE )->GetText() ); return GetField( REFERENCE )->GetText(); } @@ -506,9 +506,9 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString ) } -void SCH_COMPONENT::SetRef( const SCH_SHEET* aSheet, const wxString& ref ) +void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) { - wxString path = GetPath( aSheet ); + wxString path = GetPath( sheet->Last() ); bool notInArray = true; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index faa9f46535..5b1535a0b5 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -418,7 +418,7 @@ public: /** * Set the reference, for the given sheet path. */ - void SetRef( const SCH_SHEET* aSheet, const wxString& ref ); + void SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ); /** * Function AddHierarchicalReference diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 550d91de9c..38cbe18277 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include @@ -448,7 +447,7 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData ) isReplaced = EDA_ITEM::Replace( aSearchData, text ); if( isReplaced ) - component->SetRef( ((SCH_SHEET_PATH*) aAuxData)->Last(), text ); + component->SetRef( (SCH_SHEET_PATH*) aAuxData, text ); } else { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index e60adf26fe..8773625797 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -1295,43 +1294,6 @@ void SCH_SHEET::ClearModifyStatus() } -void SCH_SHEET::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ) -{ - int ref = 1; - - if( aReference ) - ref = *aReference; - - for( EDA_ITEM* item = m_screen->GetDrawItems(); item; item = item->Next() ) - { - if( item->Type() != SCH_COMPONENT_T ) - continue; - - SCH_COMPONENT* component = (SCH_COMPONENT*) item; - LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); - - if( !part || !part->IsPower() ) - continue; - - wxString refstr = component->GetPrefix(); - - //str will be "C?" or so after the ClearAnnotation call. - while( refstr.Last() == '?' ) - refstr.RemoveLast(); - - if( !refstr.StartsWith( wxT( "#" ) ) ) - refstr = wxT( "#" ) + refstr; - - refstr << wxT( "0" ) << ref; - component->SetRef( this, refstr ); - ref++; - } - - if( aReference ) - *aReference = ref; -} - - SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem ) { wxLogDebug( wxT( "Sheet assignment operator." ) ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 30114adb31..2d284cf118 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -35,7 +35,6 @@ #include -class PART_LIBS; class LINE_READER; class SCH_SCREEN; class SCH_SHEET; @@ -657,17 +656,6 @@ public: */ bool IsAutoSaveRequired(); - /** - * Function AnnotatePowerSymbols - * annotates the power symbols only starting at \a aReference in the sheet path. - * @param aLibs the library list to use - * @param aReference A pointer to the number for the reference designator of the - * first power symbol to be annotated. If the pointer is NULL - * the annotation starts at 1. The number is incremented for - * each power symbol in the sheet that is annotated. - */ - void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ); - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index e829924152..e43f2243bb 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -245,6 +245,43 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() } +void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ) +{ + int ref = 1; + + if( aReference ) + ref = *aReference; + + for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() ) + { + if( item->Type() != SCH_COMPONENT_T ) + continue; + + SCH_COMPONENT* component = (SCH_COMPONENT*) item; + LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); + + if( !part || !part->IsPower() ) + continue; + + wxString refstr = component->GetPrefix(); + + //str will be "C?" or so after the ClearAnnotation call. + while( refstr.Last() == '?' ) + refstr.RemoveLast(); + + if( !refstr.StartsWith( wxT( "#" ) ) ) + refstr = wxT( "#" ) + refstr; + + refstr << wxT( "0" ) << ref; + component->SetRef( this, refstr ); + ref++; + } + + if( aReference ) + *aReference = ref; +} + + void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) { // Search to sheet path number: @@ -647,6 +684,15 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) } +void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs ) +{ + int ref = 1; + + for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() ) + path->AnnotatePowerSymbols( aLibs, &ref ); +} + + void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) { diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 0c542086b3..30c6ee330a 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -226,6 +226,17 @@ public: */ void UpdateAllScreenReferences(); + /** + * Function AnnotatePowerSymbols + * annotates the power symbols only starting at \a aReference in the sheet path. + * @param aLibs the library list to use + * @param aReference A pointer to the number for the reference designator of the + * first power symbol to be annotated. If the pointer is NULL + * the annotation starts at 1. The number is incremented for + * each power symbol annotated. + */ + void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ); + /** * Function GetComponents * adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet. @@ -425,6 +436,13 @@ public: */ SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true ); + /** + * Function AnnotatePowerSymbols + * clear and annotates the entire hierarchy of the sheet path list. + * @param aLib the library list to use + */ + void AnnotatePowerSymbols( PART_LIBS* aLib ); + /** * Function GetComponents * adds a SCH_REFERENCE() object to \a aReferences for each component in the list @@ -433,8 +451,7 @@ public: * @param aReferences List of references to populate. * @param aIncludePowerSymbols Set to false to only get normal components. */ - void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, - bool aIncludePowerSymbols = true ); + void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true ); /** * Function GetMultiUnitComponents