Remove obsolete code requiring unique sheet names.

This commit is contained in:
Jeff Young 2020-02-20 22:52:01 +00:00
parent e1d59337d1
commit 490f39a671
8 changed files with 3 additions and 179 deletions

View File

@ -111,17 +111,6 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow()
return false;
}
// Duplicate sheet names are not valid.
SCH_SHEET_LIST hierarchy( g_RootSheet );
const SCH_SHEET* sheet = hierarchy.FindSheetByName( GetSheetName() );
if( sheet && (sheet != m_sheet) )
{
DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
GetSheetName() ) );
return false;
}
m_sheet->SetShowFileName( m_filenameVisible->GetValue() );
m_sheet->SetFileNameSize( m_filenameTextSize.GetValue() );
m_sheet->SetShowSheetName( m_sheetnameVisible->GetValue() );

View File

@ -535,6 +535,7 @@ bool SCH_EDIT_FRAME::SaveProject()
CreateArchiveLibraryCacheFile();
// Save the sheet name map to the project file
wxString configFile = Prj().GetProjectFullName();
wxConfigBase* config = new wxFileConfig( wxEmptyString, wxEmptyString, configFile );
int index = 1;

View File

@ -696,20 +696,6 @@ LIB_PIN* SCH_SCREEN::GetPin(
}
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
{
for( auto item : Items().OfType( SCH_SHEET_T ) )
{
auto sheet = static_cast<SCH_SHEET*>( item );
if( aName.CmpNoCase( sheet->GetName() ) == 0 )
return sheet;
}
return NULL;
}
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
{
SCH_SHEET_PIN* sheetPin = nullptr;

View File

@ -362,15 +362,6 @@ public:
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
bool aEndPointOnly = false );
/**
* Returns a sheet object pointer that is named \a aName.
*
* @note The screen hierarchy is not descend.
* @param aName is the case insensitive name of the sheet.
* @return A pointer to the SCH_SHEET object found or NULL.
*/
SCH_SHEET* GetSheet( const wxString& aName );
/**
* Test the screen if \a aPosition is a sheet label object.
*

View File

@ -306,30 +306,6 @@ bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName,
}
int SCH_SHEET_PATH::FindSheet( const wxString& aFileName ) const
{
for( unsigned i = 0; i < size(); i++ )
{
if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
return (int)i;
}
return SHEET_NOT_FOUND;
}
SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName )
{
for( unsigned i = 0; i < size(); i++ )
{
if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
return at( i );
}
return NULL;
}
/********************************************************************/
/* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
/********************************************************************/
@ -342,22 +318,6 @@ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet )
}
SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString& aPath, bool aHumanReadable )
{
wxString sheetPath;
for( unsigned i = 0; i < size(); i++ )
{
sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
if( sheetPath == aPath )
return &at( i );
}
return NULL;
}
void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
{
wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
@ -592,20 +552,6 @@ bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
}
SCH_SHEET* SCH_SHEET_LIST::FindSheetByName( const wxString& aSheetName )
{
for( unsigned i = 0; i < size(); i++ )
{
SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
if( sheet )
return sheet;
}
return NULL;
}
SCH_SHEET_PATH* SCH_SHEET_LIST::FindSheetForScreen( SCH_SCREEN* aScreen )
{
for( SCH_SHEET_PATH& sheetpath : *this )

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -87,9 +87,6 @@ class SCH_ITEM;
class SCH_REFERENCE_LIST;
#define SHEET_NOT_FOUND -1
/**
* Type SCH_MULTI_UNIT_REFERENCE_MAP
* is used to create a map of reference designators for multi-unit parts.
@ -169,11 +166,6 @@ public:
return const_cast< SCH_SHEET* >( retv );
}
SCH_SHEET* GetSheet( unsigned aIndex )
{
return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
}
/**
* Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest
@ -286,28 +278,6 @@ public:
*/
bool TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName ) const;
int FindSheet( const wxString& aFileName ) const;
/**
* Function FindSheetByName
*
* searches the #SCH_SHEET_PATH for a sheet named \a aSheetName.
*
* @param aSheetName is the name of the sheet to find.
* @return a pointer to the sheet named \a aSheetName if found or NULL if not found.
*/
SCH_SHEET* FindSheetByName( const wxString& aSheetName );
/**
* Function FindSheetByPageNumber
*
* searches the #SCH_SHEET_LIST for a sheet with \a aPageNumber.
*
* @param aPageNumber is the number of the sheet to find.
* @return a pointer to a #SCH_SHEET object page \a aPageNumber if found or NULL if not found.
*/
SCH_SHEET* FindSheetByPageNumber( int aPageNumber );
bool operator==( const SCH_SHEET_PATH& d1 ) const;
bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
@ -328,9 +298,6 @@ namespace std
typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;
typedef SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER;
typedef SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER;
typedef SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER;
/**
@ -361,18 +328,6 @@ public:
~SCH_SHEET_LIST() {}
/**
* Function GetSheetByPath
* returns a sheet matching the path name in \a aPath.
*
* @param aPath A wxString object containing path of the sheet to get.
* @param aHumanReadable True uses the human readable path for comparison.
* False uses the timestamp generated path.
* @return The sheet that matches \a aPath or NULL if no sheet matching
* \a aPath is found.
*/
SCH_SHEET_PATH* GetSheetByPath( const wxString& aPath, bool aHumanReadable = true );
/**
* Function IsModified
* checks the entire hierarchy for any modifications.
@ -453,16 +408,6 @@ public:
bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
const wxString& aDestFileName ) const;
/**
* Function FindSheetByName
*
* searches the entire #SCH_SHEET_LIST for a sheet named \a aSheetName.
*
* @param aSheetName is the name of the sheet to find.
* @return a pointer to the sheet named \a aSheetName if found or NULL if not found.
*/
SCH_SHEET* FindSheetByName( const wxString& aSheetName );
/**
* Function FindSheetForScreen
*

View File

@ -445,41 +445,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
}
}
// Check for duplicate sheet names in the current page.
wxArrayString duplicateSheetNames;
for( auto item : currentScreen->Items().OfType( SCH_SHEET_T ) )
{
auto sheet = static_cast<SCH_SHEET*>( item );
if( newSheet->GetScreen()->GetSheet( sheet->GetName() ) )
duplicateSheetNames.Add( sheet->GetName() );
}
if( !duplicateSheetNames.IsEmpty() )
{
msg.Printf( "Duplicate sheet names exist on the current page. Do you want to "
"automatically rename the duplicate sheet names?" );
if( !IsOK( this, msg ) )
return false;
}
// Rename all duplicate sheet names.
SCH_SCREEN* newScreen = newSheet->GetScreen();
wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
for( const auto& duplicateName : duplicateSheetNames )
{
SCH_SHEET* renamedSheet = newScreen->GetSheet( duplicateName );
wxCHECK2_MSG( renamedSheet, continue,
"Sheet " + duplicateName + " not found in imported schematic." );
const_cast<UUID&>( renamedSheet->m_Uuid ) = UUID();
renamedSheet->SetName( wxString::Format( "Sheet%s", renamedSheet->m_Uuid.AsString() ) );
}
// Set all sheets loaded into the correct sheet file paths.
for( auto aItem : currentScreen->Items().OfType( SCH_SHEET_T ) )
@ -747,7 +715,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
aSheet->SetName( dlg.GetSheetName() );
if( aSheet->GetName().IsEmpty() )
aSheet->SetName( wxString::Format( wxT( "Sheet%s" ), aSheet->m_Uuid.AsString() ) );
aSheet->SetName( wxT( "Untitled Sheet" ) );
if( aClearAnnotationNewItems )
*aClearAnnotationNewItems = clearAnnotation;

View File

@ -73,8 +73,6 @@ BOOST_AUTO_TEST_CASE( Default )
{
BOOST_CHECK_EQUAL( m_csheet.GetPosition(), wxPoint( 0, 0 ) );
BOOST_CHECK_PREDICATE( KI_TEST::EndsInTimestamp, ( m_csheet.GetName().ToStdString() ) );
// it is it's own root sheet
BOOST_CHECK_EQUAL( m_sheet.GetRootSheet(), &m_sheet );
BOOST_CHECK_EQUAL( m_sheet.CountSheets(), 1 );