diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index d0bae72a91..1b2a27d232 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -6,7 +6,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * 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 @@ -35,18 +35,19 @@ #include #include -#include - void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly ) { if( aCurrentSheetOnly ) { - m_CurrentSheet->Last()->ClearAnnotation(); + SCH_SCREEN* screen = GetScreen(); + wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) ); + screen->ClearAnnotation( m_CurrentSheet ); } else { - m_CurrentSheet->Last()->GetRootSheet()->ClearAnnotation( true ); + SCH_SCREENS ScreenList; + ScreenList.ClearAnnotation(); } // Update the references for the sheet that is currently being displayed. diff --git a/eeschema/class_sch_screen.h b/eeschema/class_sch_screen.h index a13249098e..67c6451b1c 100644 --- a/eeschema/class_sch_screen.h +++ b/eeschema/class_sch_screen.h @@ -425,11 +425,11 @@ public: /** * Function ClearAnnotation - * clears the annotation for the components in \a aSheet on the screen. - * @param aSheet The sheet of the component annotation to clear. If NULL then - * the entire hierarchy is cleared for this screen. + * clears the annotation for the components in \a aSheetPath on the screen. + * @param aSheetPath The sheet path of the component annotation to clear. If NULL then + * the entire hierarchy is cleared. */ - void ClearAnnotation( SCH_SHEET* aSheet ); + void ClearAnnotation( SCH_SHEET_PATH* aSheetPath ); /** * Function GetHierarchicalItems @@ -549,6 +549,12 @@ public: SCH_SCREEN* GetNext(); SCH_SCREEN* GetScreen( unsigned int aIndex ) const; + /** + * Function ClearAnnotation + * clears the annotation for all components in the hierarchy. + */ + void ClearAnnotation(); + /** * Function SchematicCleanUp * merges and breaks wire segments in the entire schematic hierarchy. diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index b0c8f6a286..0aeaccc3d0 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -102,7 +102,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, uns field = comp->GetRef( path ); ret |= fprintf( f, " ( %s %s", - TO_UTF8( comp->GetPath( path->Last() ) ), + TO_UTF8( comp->GetPath( path ) ), TO_UTF8( footprint ) ); ret |= fprintf( f, " %s", TO_UTF8( field ) ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 1bec57f4f5..aaed3f31a3 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -432,21 +432,21 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, } -wxString SCH_COMPONENT::GetPath( const SCH_SHEET* aSheet ) const +wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const { - wxCHECK_MSG( aSheet != NULL, wxEmptyString, + wxCHECK_MSG( sheet != NULL, wxEmptyString, wxT( "Cannot get component path with invalid sheet object." ) ); wxString str; str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp ); - return aSheet->GetPath() + str; + return sheet->Path() + str; } const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet ) { - wxString path = GetPath( sheet->Last() ); + wxString path = GetPath( sheet ); wxString h_path, h_ref; wxStringTokenizer tokenizer; wxString separators( wxT( " " ) ); @@ -508,7 +508,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString ) void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) { - wxString path = GetPath( sheet->Last() ); + wxString path = GetPath( sheet ); bool notInArray = true; @@ -586,7 +586,7 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp ) int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) { - wxString path = GetPath( aSheet->Last() ); + wxString path = GetPath( aSheet ); wxString h_path, h_multi; wxStringTokenizer tokenizer; wxString separators( wxT( " " ) ); @@ -614,7 +614,7 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection ) { - wxString path = GetPath( aSheet->Last() ); + wxString path = GetPath( aSheet ); bool notInArray = true; @@ -751,7 +751,7 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem ) } -void SCH_COMPONENT::ClearAnnotation( SCH_SHEET* aSheet ) +void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) { bool keepMulti = false; wxArrayString reference_fields; @@ -774,7 +774,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET* aSheet ) } else { // This is a malformed reference: reinit this reference - m_prefix = defRef = wxT( "U" ); // Set to default ref prefix + m_prefix = defRef = wxT("U"); // Set to default ref prefix } defRef.Append( wxT( "?" ) ); @@ -783,22 +783,22 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET* aSheet ) // For components with units locked, // we cannot remove all annotations: part selection must be kept - // For all components: if aSheet is not NULL, + // For all components: if aSheetPath is not NULL, // remove annotation only for the given path - if( keepMulti || aSheet ) + if( keepMulti || aSheetPath ) { wxString NewHref; wxString path; - if( aSheet ) - path = GetPath( aSheet ); + if( aSheetPath ) + path = GetPath( aSheetPath ); for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) { // Break hierarchical reference in path, ref and multi selection: reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators ); - if( aSheet == NULL || reference_fields[0].Cmp( path ) == 0 ) + if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 ) { if( keepMulti ) // Get and keep part selection multi = reference_fields[2]; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 5b1535a0b5..7d64546615 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -244,10 +244,10 @@ public: /** * Function ClearAnnotation * clears exiting component annotation ( i.i IC23 changed to IC? and part reset to 1) - * @param aSheet: SCH_SHEET value: if NULL remove all annotations, - * else remove annotation relative to \a aSheet. + * @param aSheetPath: SCH_SHEET_PATH value: if NULL remove all annotations, + * else remove annotation relative to this sheetpath */ - void ClearAnnotation( SCH_SHEET* aSheet ); + void ClearAnnotation( SCH_SHEET_PATH* aSheetPath ); /** * Function SetTimeStamp @@ -391,8 +391,8 @@ public: void SwapData( SCH_ITEM* aItem ); - // returns a unique ID, in the form of a path determined by \a aSheet. - wxString GetPath( const SCH_SHEET* sheet ) const; + // returns a unique ID, in the form of a path. + wxString GetPath( const SCH_SHEET_PATH* sheet ) const; /** * Function IsReferenceStringValid (static) diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 95f9d94010..c2f8201979 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -755,7 +755,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) } -void SCH_SCREEN::ClearAnnotation( SCH_SHEET* aSheet ) +void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) { for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { @@ -763,7 +763,7 @@ void SCH_SCREEN::ClearAnnotation( SCH_SHEET* aSheet ) { SCH_COMPONENT* component = (SCH_COMPONENT*) item; - component->ClearAnnotation( aSheet ); + component->ClearAnnotation( aSheetPath ); // Clear the modified component flag set by component->ClearAnnotation // because we do not use it here and we should not leave this flag set, @@ -1431,6 +1431,13 @@ void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem ) } +void SCH_SCREENS::ClearAnnotation() +{ + for( size_t i = 0; i < m_screens.size(); i++ ) + m_screens[i]->ClearAnnotation( NULL ); +} + + void SCH_SCREENS::SchematicCleanUp() { for( size_t i = 0; i < m_screens.size(); i++ ) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index a8d657609a..f142113c4a 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1214,25 +1214,6 @@ wxString SCH_SHEET::GetHumanReadablePath() const } -void SCH_SHEET::ClearAnnotation( bool aIncludeSubSheets ) -{ - m_screen->ClearAnnotation( this ); - - if( aIncludeSubSheets ) - { - SCH_ITEM* item = m_screen->GetDrawItems(); - - while( item ) - { - if( item->Type() == SCH_SHEET_T ) - static_cast( item )->ClearAnnotation( aIncludeSubSheets ); - - item = item->Next(); - } - } -} - - 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 ce9f36422a..e5fe0bd429 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -633,8 +633,6 @@ public: */ wxString GetHumanReadablePath() const; - void ClearAnnotation( bool aIncludeSubSheets = false ); - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif