From e47f0df068fe781925c4d96215fe3532a8a4d98f Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Fri, 24 Jun 2016 12:55:54 +0200 Subject: [PATCH] Cleanups * coding standard fixes * library part not library component (no such thing as a library component) * string concatenation fix * and an inline harmless debug/dump function --- eeschema/annotate.cpp | 10 +++++----- eeschema/component_references_lister.cpp | 21 ++++++++++---------- eeschema/sch_component.cpp | 3 ++- eeschema/sch_reference_list.h | 25 +++++++++++++++++++++--- eeschema/sch_sheet.h | 4 ++-- eeschema/sch_sheet_path.cpp | 7 ++++--- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index cfb776073e..5f626b571a 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -187,14 +187,14 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly ) { // build the screen list - SCH_SHEET_LIST SheetList( g_RootSheet ); - SCH_REFERENCE_LIST ComponentsList; + SCH_SHEET_LIST sheetList( g_RootSheet ); + SCH_REFERENCE_LIST componentsList; // Build the list of components if( !aOneSheetOnly ) - SheetList.GetComponents( Prj().SchLibs(), ComponentsList ); + sheetList.GetComponents( Prj().SchLibs(), componentsList ); else - m_CurrentSheet->GetComponents( Prj().SchLibs(), ComponentsList ); + m_CurrentSheet->GetComponents( Prj().SchLibs(), componentsList ); - return ComponentsList.CheckAnnotation( aMessageList ); + return componentsList.CheckAnnotation( aMessageList ); } diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 6796ef398a..596b3bd42a 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -373,7 +373,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, } // Annotation of one part per package components (trivial case). - if( componentFlatList[ii].GetLibComponent()->GetUnitCount() <= 1 ) + if( componentFlatList[ii].GetLibPart()->GetUnitCount() <= 1 ) { if( componentFlatList[ii].m_IsNew ) { @@ -392,7 +392,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, } // Annotation of multi-unit parts ( n units per part ) (complex case) - NumberOfUnits = componentFlatList[ii].GetLibComponent()->GetUnitCount(); + NumberOfUnits = componentFlatList[ii].GetLibPart()->GetUnitCount(); if( componentFlatList[ii].m_IsNew ) { @@ -540,7 +540,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) // Error if unit number selected does not exist ( greater than the number of // parts in the component ). This can happen if a component has changed in a // library after a previous annotation. - if( std::max( componentFlatList[ii].GetLibComponent()->GetUnitCount(), 1 ) + if( std::max( componentFlatList[ii].GetLibPart()->GetUnitCount(), 1 ) < componentFlatList[ii].m_Unit ) { if( componentFlatList[ii].m_NumRef >= 0 ) @@ -552,7 +552,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ), componentFlatList[ii].m_Unit, - componentFlatList[ii].GetLibComponent()->GetUnitCount() ); + componentFlatList[ii].GetLibPart()->GetUnitCount() ); if( aMessageList ) aMessageList->Add( msg ); @@ -609,8 +609,8 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) /* Test error if units are different but number of parts per package * too high (ex U3 ( 1 part) and we find U3B this is an error) */ - if( componentFlatList[ii].GetLibComponent()->GetUnitCount() - != componentFlatList[ii + 1].GetLibComponent()->GetUnitCount() ) + if( componentFlatList[ii].GetLibPart()->GetUnitCount() + != componentFlatList[ii + 1].GetLibPart()->GetUnitCount() ) { if( componentFlatList[ii].m_NumRef >= 0 ) tmp << componentFlatList[ii].m_NumRef; @@ -694,13 +694,13 @@ 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* aLibPart, SCH_SHEET_PATH& aSheetPath ) { - wxASSERT( aComponent != NULL && aLibComponent != NULL ); + wxASSERT( aComponent != NULL && aLibPart != NULL ); m_RootCmp = aComponent; - m_Entry = aLibComponent; + m_Entry = aLibPart; m_Unit = aComponent->GetUnitSelection( &aSheetPath ); m_SheetPath = aSheetPath; m_IsNew = false; @@ -712,7 +712,8 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComp if( aComponent->GetRef( &aSheetPath ).IsEmpty() ) aComponent->SetRef( &aSheetPath, wxT( "DefRef?" ) ); - SetRef( aComponent->GetRef( &aSheetPath ) ); + wxString ref = aComponent->GetRef( &aSheetPath ); + SetRef( ref ); m_NumRef = -1; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 46da61e11e..95e96b2226 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -529,7 +529,8 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) h_ref += wxT( " " ); tokenizer.GetNextToken(); // Skip old reference h_ref += tokenizer.GetNextToken(); // Add part selection - // Ann the part selection + + // Add the part selection m_PathsAndReferences[ii] = h_ref; notInArray = false; } diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index ea27cf43d5..29500b448c 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -66,7 +66,7 @@ class SCH_REFERENCE bool m_IsNew; ///< True if not yet annotated. int m_SheetNum; ///< The sheet number for the reference. time_t m_TimeStamp; ///< The time stamp for the reference. - EDA_TEXT* m_Value; ///< The component value of the refernce. It is the + EDA_TEXT* m_Value; ///< The component value of the reference. It is the ///< same for all instances. int m_NumRef; ///< The numeric part of the reference designator. int m_Flag; @@ -90,12 +90,12 @@ public: m_SheetNum = 0; } - SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent, + SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent, SCH_SHEET_PATH& aSheetPath ); SCH_COMPONENT* GetComp() const { return m_RootCmp; } - LIB_PART* GetLibComponent() const { return m_Entry; } + LIB_PART* GetLibPart() const { return m_Entry; } SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; } @@ -438,6 +438,25 @@ public: */ int GetLastReference( int aIndex, int aMinValue ); +#if defined(DEBUG) + void Show( const char* aPrefix = "" ) + { + printf( "%s\n", aPrefix ); + + for( unsigned i=0; iGetName() ) + ); + } + } +#endif + private: /* sort functions used to sort componentFlatList */ diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index e899f41e3d..2629ec0a3b 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -595,6 +595,6 @@ protected: }; -typedef std::vector< SCH_SHEET* > SCH_SHEETS; +typedef std::vector< SCH_SHEET* > SCH_SHEETS; // no ownership over contained SCH_SHEETs -#endif /* SCH_SHEEET_H */ +#endif // SCH_SHEEET_H diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index d4d8ff4de7..9938555722 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -207,7 +207,7 @@ void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ) refstr.RemoveLast(); if( !refstr.StartsWith( wxT( "#" ) ) ) - refstr = wxT( "#" ) + refstr; + refstr.insert( refstr.begin(), wxChar( '#' ) ); refstr << wxT( "0" ) << ref; component->SetRef( this, refstr ); @@ -237,7 +237,8 @@ void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aRefer if( part ) { - SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this ); + SCH_REFERENCE reference( component, part, *this ); + reference.SetSheetNumber( m_pageNumber ); aReferences.AddItem( reference ); } @@ -247,7 +248,7 @@ void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aRefer void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, - SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, + SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, bool aIncludePowerSymbols ) {