Commit fd486a11 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Prevent duplicate sheet names in schematic editor.

parent ebaf1454
...@@ -675,6 +675,23 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen ...@@ -675,6 +675,23 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
} }
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
{
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
if( item->Type() != SCH_SHEET_T )
continue;
SCH_SHEET* sheet = (SCH_SHEET*) item;
if( aName.CmpNoCase( sheet->m_SheetName ) == 0 )
return sheet;
}
return NULL;
}
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition ) SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
{ {
SCH_SHEET_PIN* sheetPin = NULL; SCH_SHEET_PIN* sheetPin = NULL;
......
...@@ -65,6 +65,16 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -65,6 +65,16 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
return false; return false;
} }
// Duplicate sheet names are not valid.
const SCH_SHEET* sheet = GetScreen()->GetSheet( dlg.GetSheetName() );
if( (sheet != NULL) && (sheet != aSheet) )
{
DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
GetChars( dlg.GetSheetName() ) ) );
return false;
}
wxString msg; wxString msg;
wxString tmp; wxString tmp;
bool loadFromFile = false; bool loadFromFile = false;
......
...@@ -305,6 +305,16 @@ public: ...@@ -305,6 +305,16 @@ public:
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL, LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
bool aEndPointOnly = false ) const; bool aEndPointOnly = false ) const;
/**
* Function GetSheet
* returns a sheet object pointer that is named \a aName.
*
* @note The screen hierarchy is not descened.
* @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 );
/** /**
* Function GetSheetLabel * Function GetSheetLabel
* test the screen if \a aPosition is a sheet label object. * test the screen if \a aPosition is a sheet label object.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment