Loading eeschema/sch_screen.cpp +3 −5 Original line number Original line Diff line number Diff line Loading @@ -216,8 +216,6 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) */ */ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) { { wxASSERT( aCanvas != NULL ); SCH_ITEM* DrawList, * TstDrawList; SCH_ITEM* DrawList, * TstDrawList; bool Modify = FALSE; bool Modify = FALSE; Loading Loading @@ -674,11 +672,11 @@ bool SCH_SCREEN::TestDanglingEnds( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) { { item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } if( item->IsDangling() ) if( item->IsDangling() ) hasDanglingEnds = true; hasDanglingEnds = true; } } } return hasDanglingEnds; return hasDanglingEnds; } } Loading eeschema/sch_sheet.cpp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,8 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : SCH_SHEET::~SCH_SHEET() SCH_SHEET::~SCH_SHEET() { { wxLogDebug( wxT( "Destroying sheet " ) + m_SheetName ); // also, look at the associated sheet & its reference count // also, look at the associated sheet & its reference count // perhaps it should be deleted also. // perhaps it should be deleted also. if( m_AssociatedScreen ) if( m_AssociatedScreen ) Loading eeschema/sch_sheet_path.cpp +174 −78 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ // Purpose: member functions for SCH_SHEET_PATH // Purpose: member functions for SCH_SHEET_PATH // header = sch_sheet_path.h // header = sch_sheet_path.h // Author: jean-pierre Charras // Author: jean-pierre Charras // Modified by: Wayne Stambaugh // Modified by: // License: License GNU // License: License GNU ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// Loading @@ -25,43 +25,44 @@ #include "dialogs/dialog_schematic_find.h" #include "dialogs/dialog_schematic_find.h" /**********************************************/ /* class to handle a series of sheets *********/ /* a 'path' so to speak.. *********************/ /**********************************************/ SCH_SHEET_PATH::SCH_SHEET_PATH() SCH_SHEET_PATH::SCH_SHEET_PATH() { { } for( int i = 0; i<DSLSZ; i++ ) m_sheets[i] = NULL; SCH_SHEET_PATH::~SCH_SHEET_PATH() { // The sheets are not owned by the sheet path object so don't allow them to be destroyed. Clear(); } m_numSheets = 0; void SCH_SHEET_PATH::Clear() { while( !m_sheets.empty() ) m_sheets.pop_back().release(); } } /** * Function BuildSheetPathInfoFromSheetPathValue * Fill this with data to access to the hierarchical sheet known by its path * aPath * @param aPath = path of the sheet to reach (in non human readable format) * @return true if success else false */ bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound ) bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound ) { { if( aFound ) if( aFound ) return true; return true; if( GetSheetCount() == 0 ) if( GetSheetsCount() == 0 ) Push( g_RootSheet ); Push( g_RootSheet ); if( aPath == Path() ) if( aPath == Path() ) return true; return true; SCH_ITEM* item = LastDrawList(); SCH_ITEM* schitem = LastDrawList(); while( item && GetSheetCount() < NB_MAX_SHEET ) while( schitem && GetSheetsCount() < NB_MAX_SHEET ) { { if( item->Type() == SCH_SHEET_T ) if( schitem->Type() == SCH_SHEET_T ) { { SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) schitem; Push( sheet ); Push( sheet ); if( aPath == Path() ) if( aPath == Path() ) Loading @@ -72,29 +73,34 @@ bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath Pop(); Pop(); } } schitem = schitem->Next(); item = item->Next(); } } return false; return false; } } /** * Function Cmp * Compare if this is the same sheet path as aSheetPathToTest * @param aSheetPathToTest = sheet path to compare * @return -1 if different, 0 if same */ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const { { if( m_sheets.size() > aSheetPathToTest.GetSheetCount() ) if( m_numSheets > aSheetPathToTest.m_numSheets ) return 1; return 1; if( m_sheets.size() < aSheetPathToTest.GetSheetCount() ) if( m_numSheets < aSheetPathToTest.m_numSheets ) return -1; return -1; // Same number of sheets, use time stamps. //otherwise, same number of sheets. for( unsigned i = 0; i < GetSheetCount(); i++ ) for( unsigned i = 0; i<m_numSheets; i++ ) { { if( m_sheets[i].m_TimeStamp > aSheetPathToTest.m_sheets[i].m_TimeStamp ) if( m_sheets[i]->m_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp ) return 1; return 1; if( m_sheets[i].m_TimeStamp < aSheetPathToTest.m_sheets[i].m_TimeStamp ) if( m_sheets[i]->m_TimeStamp < aSheetPathToTest.m_sheets[i]->m_TimeStamp ) return -1; return -1; } } Loading @@ -102,15 +108,24 @@ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const } } /** * Function Last * returns a pointer to the last sheet of the list * One can see the others sheet as the "path" to reach this last sheet */ SCH_SHEET* SCH_SHEET_PATH::Last() SCH_SHEET* SCH_SHEET_PATH::Last() { { if( !m_sheets.empty() ) if( m_numSheets ) return &m_sheets[ m_sheets.size() - 1 ]; return m_sheets[m_numSheets - 1]; return NULL; return NULL; } } /** * Function LastScreen * @return the SCH_SCREEN relative to the last sheet in list */ SCH_SCREEN* SCH_SHEET_PATH::LastScreen() SCH_SCREEN* SCH_SHEET_PATH::LastScreen() { { SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last(); Loading @@ -122,12 +137,17 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen() } } /** * Function LastScreen * @return a pointer to the first schematic item handled by the * SCH_SCREEN relative to the last sheet in list */ SCH_ITEM* SCH_SHEET_PATH::LastDrawList() SCH_ITEM* SCH_SHEET_PATH::LastDrawList() { { SCH_SCREEN* screen = LastScreen(); SCH_SHEET* lastSheet = Last(); if( screen ) if( lastSheet && lastSheet->GetScreen() ) return screen->GetDrawItems(); return lastSheet->GetScreen()->GetDrawItems(); return NULL; return NULL; } } Loading @@ -137,37 +157,66 @@ SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() { { SCH_ITEM* item = NULL; SCH_ITEM* item = NULL; if( !m_sheets.empty() && m_sheets[0].GetScreen() ) if( m_numSheets && m_sheets[0]->GetScreen() ) item = m_sheets[0].GetScreen()->GetDrawItems(); item = m_sheets[0]->GetScreen()->GetDrawItems(); /* @fixme - These lists really should be one of the boost pointer containers. This * is a brain dead hack to allow reverse iteration of EDA_ITEM linked * list. */ SCH_ITEM* lastItem = NULL; while( item != NULL ) { lastItem = item; item = item->Next(); } return item; return lastItem; } } void SCH_SHEET_PATH::Push( SCH_SHEET* aSheet ) void SCH_SHEET_PATH::Push( SCH_SHEET* aSheet ) { { if( m_sheets.size() >= MAX_SHEET_PATH_DEPTH ) if( m_numSheets > DSLSZ ) { { wxLogWarning( _( "Schematic sheets can only be nested %d levels deep. Not adding sheet %s" ), wxString msg; MAX_SHEET_PATH_DEPTH, GetChars( aSheet->m_SheetName ) ); msg.Printf( _( "Schematic sheets can only be nested %d levels deep." ), DSLSZ ); return; wxMessageBox( msg ); } } m_sheets.push_back( aSheet ); if( m_numSheets < DSLSZ ) { m_sheets[m_numSheets] = aSheet; m_numSheets++; } } } /** * Function Pop * retrieves (pop) the last entered sheet and remove it from list * @return a SCH_SHEET* pointer to the removed sheet in list */ SCH_SHEET* SCH_SHEET_PATH::Pop() SCH_SHEET* SCH_SHEET_PATH::Pop() { { if( m_sheets.empty() ) if( m_numSheets > 0 ) return NULL; { m_numSheets--; return m_sheets[m_numSheets]; } // The sheet must be released from the end of the container otherwise it will be destroyed. return NULL; return m_sheets.pop_back().release(); } } wxString SCH_SHEET_PATH::Path() const /** * Function Path * the path uses the time stamps which do not changes even when editing sheet * parameters * a path is something like / (root) or /34005677 or /34005677/00AE4523 */ wxString SCH_SHEET_PATH::Path() { { wxString s, t; wxString s, t; Loading @@ -176,9 +225,9 @@ wxString SCH_SHEET_PATH::Path() const // start at 1 to avoid the root sheet, // start at 1 to avoid the root sheet, // which does not need to be added to the path // which does not need to be added to the path // it's timestamp changes anyway. // it's timestamp changes anyway. for( unsigned i = 1; i < m_sheets.size(); i++ ) for( unsigned i = 1; i < m_numSheets; i++ ) { { t.Printf( _( "%8.8lX/" ), m_sheets[i].m_TimeStamp ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); s = s + t; s = s + t; } } Loading @@ -186,6 +235,13 @@ wxString SCH_SHEET_PATH::Path() const } } /** * Function PathHumanReadable * Return the sheet path in a readable form, i.e. * as a path made from sheet names. * (the "normal" path uses the time stamps which do not changes even when * editing sheet parameters) */ wxString SCH_SHEET_PATH::PathHumanReadable() const wxString SCH_SHEET_PATH::PathHumanReadable() const { { wxString s, t; wxString s, t; Loading @@ -193,9 +249,9 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const s = wxT( "/" ); s = wxT( "/" ); // start at 1 to avoid the root sheet, as above. // start at 1 to avoid the root sheet, as above. for( unsigned i = 1; i< m_sheets.size(); i++ ) for( unsigned i = 1; i< m_numSheets; i++ ) { { s = s + m_sheets[i].m_SheetName + wxT( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" ); } } return s; return s; Loading Loading @@ -257,12 +313,12 @@ void SCH_SHEET_PATH::AnnotatePowerSymbols( int* aReference ) } } void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) { { // Search to sheet path number: // Search to sheet path number: int sheetnumber = 1; // 1 = root int sheetnumber = 1; // 1 = root SCH_SHEET_LIST sheetList; SCH_SHEET_LIST sheetList; for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path != NULL; for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path != NULL; path = sheetList.GetNext(), sheetnumber++ ) path = sheetList.GetNext(), sheetnumber++ ) if( Cmp(*path) == 0 ) if( Cmp(*path) == 0 ) Loading Loading @@ -392,14 +448,34 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData, } } bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) { m_numSheets = d1.m_numSheets; unsigned i; for( i = 0; i < m_numSheets; i++ ) { m_sheets[i] = d1.m_sheets[i]; } for( ; i < DSLSZ; i++ ) { m_sheets[i] = 0; } return true; } bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const { { if( m_sheets.size() != d1.m_sheets.size() ) if( m_numSheets != d1.m_numSheets ) return false; return false; for( unsigned i = 0; i < m_sheets.size(); i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( &m_sheets[i] != &d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return false; return false; } } Loading @@ -407,11 +483,38 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const } } bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const { if( m_numSheets != d1.m_numSheets ) return true; for( unsigned i = 0; i < m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) { /* printf( "micompare this:'%s' d1:'%s'\n", CONV_TO_UTF8( PathHumanReadable() ), CONV_TO_UTF8( d1.PathHumanReadable() ) ); */ return true; } } return false; } /*********************************************************************/ /*********************************************************************/ /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ /*********************************************************************/ /*********************************************************************/ /* The constructor: build the list of sheets from aSheet. * If aSheet == NULL (default) build the whole list of sheets in hierarchy * So usually call it with no param. */ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) { { m_index = 0; m_index = 0; Loading @@ -425,6 +528,10 @@ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) } } /** * Function GetFirst * @return the first item (sheet) in m_List and prepare calls to GetNext() */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() { { m_index = 0; m_index = 0; Loading @@ -436,6 +543,11 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() } } /** * Function GetNext * @return the next item (sheet) in m_List or NULL if no more item in sheet * list */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetNext() SCH_SHEET_PATH* SCH_SHEET_LIST::GetNext() { { if( m_index < GetCount() ) if( m_index < GetCount() ) Loading Loading @@ -467,6 +579,12 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetPrevious() } } /** * Function GetSheet * @return the item (sheet) in aIndex position in m_List or NULL if less than * index items * @param aIndex = index in sheet list to get the sheet */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) { { if( aIndex < GetCount() ) if( aIndex < GetCount() ) Loading @@ -476,28 +594,6 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) } } bool SCH_SHEET_LIST::IsModified() { for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() ) { if( sheet->LastScreen() && sheet->LastScreen()->IsModify() ) return true; } return false; } void SCH_SHEET_LIST::ClearModifyStatus() { for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() ) { if( sheet->LastScreen() ) sheet->LastScreen()->ClrModify(); } } void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) { { if( m_List == NULL ) if( m_List == NULL ) Loading Loading
eeschema/sch_screen.cpp +3 −5 Original line number Original line Diff line number Diff line Loading @@ -216,8 +216,6 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) */ */ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) { { wxASSERT( aCanvas != NULL ); SCH_ITEM* DrawList, * TstDrawList; SCH_ITEM* DrawList, * TstDrawList; bool Modify = FALSE; bool Modify = FALSE; Loading Loading @@ -674,11 +672,11 @@ bool SCH_SCREEN::TestDanglingEnds( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) { { item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } if( item->IsDangling() ) if( item->IsDangling() ) hasDanglingEnds = true; hasDanglingEnds = true; } } } return hasDanglingEnds; return hasDanglingEnds; } } Loading
eeschema/sch_sheet.cpp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,8 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : SCH_SHEET::~SCH_SHEET() SCH_SHEET::~SCH_SHEET() { { wxLogDebug( wxT( "Destroying sheet " ) + m_SheetName ); // also, look at the associated sheet & its reference count // also, look at the associated sheet & its reference count // perhaps it should be deleted also. // perhaps it should be deleted also. if( m_AssociatedScreen ) if( m_AssociatedScreen ) Loading
eeschema/sch_sheet_path.cpp +174 −78 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ // Purpose: member functions for SCH_SHEET_PATH // Purpose: member functions for SCH_SHEET_PATH // header = sch_sheet_path.h // header = sch_sheet_path.h // Author: jean-pierre Charras // Author: jean-pierre Charras // Modified by: Wayne Stambaugh // Modified by: // License: License GNU // License: License GNU ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// Loading @@ -25,43 +25,44 @@ #include "dialogs/dialog_schematic_find.h" #include "dialogs/dialog_schematic_find.h" /**********************************************/ /* class to handle a series of sheets *********/ /* a 'path' so to speak.. *********************/ /**********************************************/ SCH_SHEET_PATH::SCH_SHEET_PATH() SCH_SHEET_PATH::SCH_SHEET_PATH() { { } for( int i = 0; i<DSLSZ; i++ ) m_sheets[i] = NULL; SCH_SHEET_PATH::~SCH_SHEET_PATH() { // The sheets are not owned by the sheet path object so don't allow them to be destroyed. Clear(); } m_numSheets = 0; void SCH_SHEET_PATH::Clear() { while( !m_sheets.empty() ) m_sheets.pop_back().release(); } } /** * Function BuildSheetPathInfoFromSheetPathValue * Fill this with data to access to the hierarchical sheet known by its path * aPath * @param aPath = path of the sheet to reach (in non human readable format) * @return true if success else false */ bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound ) bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound ) { { if( aFound ) if( aFound ) return true; return true; if( GetSheetCount() == 0 ) if( GetSheetsCount() == 0 ) Push( g_RootSheet ); Push( g_RootSheet ); if( aPath == Path() ) if( aPath == Path() ) return true; return true; SCH_ITEM* item = LastDrawList(); SCH_ITEM* schitem = LastDrawList(); while( item && GetSheetCount() < NB_MAX_SHEET ) while( schitem && GetSheetsCount() < NB_MAX_SHEET ) { { if( item->Type() == SCH_SHEET_T ) if( schitem->Type() == SCH_SHEET_T ) { { SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) schitem; Push( sheet ); Push( sheet ); if( aPath == Path() ) if( aPath == Path() ) Loading @@ -72,29 +73,34 @@ bool SCH_SHEET_PATH::BuildSheetPathInfoFromSheetPathValue( const wxString& aPath Pop(); Pop(); } } schitem = schitem->Next(); item = item->Next(); } } return false; return false; } } /** * Function Cmp * Compare if this is the same sheet path as aSheetPathToTest * @param aSheetPathToTest = sheet path to compare * @return -1 if different, 0 if same */ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const { { if( m_sheets.size() > aSheetPathToTest.GetSheetCount() ) if( m_numSheets > aSheetPathToTest.m_numSheets ) return 1; return 1; if( m_sheets.size() < aSheetPathToTest.GetSheetCount() ) if( m_numSheets < aSheetPathToTest.m_numSheets ) return -1; return -1; // Same number of sheets, use time stamps. //otherwise, same number of sheets. for( unsigned i = 0; i < GetSheetCount(); i++ ) for( unsigned i = 0; i<m_numSheets; i++ ) { { if( m_sheets[i].m_TimeStamp > aSheetPathToTest.m_sheets[i].m_TimeStamp ) if( m_sheets[i]->m_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp ) return 1; return 1; if( m_sheets[i].m_TimeStamp < aSheetPathToTest.m_sheets[i].m_TimeStamp ) if( m_sheets[i]->m_TimeStamp < aSheetPathToTest.m_sheets[i]->m_TimeStamp ) return -1; return -1; } } Loading @@ -102,15 +108,24 @@ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const } } /** * Function Last * returns a pointer to the last sheet of the list * One can see the others sheet as the "path" to reach this last sheet */ SCH_SHEET* SCH_SHEET_PATH::Last() SCH_SHEET* SCH_SHEET_PATH::Last() { { if( !m_sheets.empty() ) if( m_numSheets ) return &m_sheets[ m_sheets.size() - 1 ]; return m_sheets[m_numSheets - 1]; return NULL; return NULL; } } /** * Function LastScreen * @return the SCH_SCREEN relative to the last sheet in list */ SCH_SCREEN* SCH_SHEET_PATH::LastScreen() SCH_SCREEN* SCH_SHEET_PATH::LastScreen() { { SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last(); Loading @@ -122,12 +137,17 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen() } } /** * Function LastScreen * @return a pointer to the first schematic item handled by the * SCH_SCREEN relative to the last sheet in list */ SCH_ITEM* SCH_SHEET_PATH::LastDrawList() SCH_ITEM* SCH_SHEET_PATH::LastDrawList() { { SCH_SCREEN* screen = LastScreen(); SCH_SHEET* lastSheet = Last(); if( screen ) if( lastSheet && lastSheet->GetScreen() ) return screen->GetDrawItems(); return lastSheet->GetScreen()->GetDrawItems(); return NULL; return NULL; } } Loading @@ -137,37 +157,66 @@ SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() { { SCH_ITEM* item = NULL; SCH_ITEM* item = NULL; if( !m_sheets.empty() && m_sheets[0].GetScreen() ) if( m_numSheets && m_sheets[0]->GetScreen() ) item = m_sheets[0].GetScreen()->GetDrawItems(); item = m_sheets[0]->GetScreen()->GetDrawItems(); /* @fixme - These lists really should be one of the boost pointer containers. This * is a brain dead hack to allow reverse iteration of EDA_ITEM linked * list. */ SCH_ITEM* lastItem = NULL; while( item != NULL ) { lastItem = item; item = item->Next(); } return item; return lastItem; } } void SCH_SHEET_PATH::Push( SCH_SHEET* aSheet ) void SCH_SHEET_PATH::Push( SCH_SHEET* aSheet ) { { if( m_sheets.size() >= MAX_SHEET_PATH_DEPTH ) if( m_numSheets > DSLSZ ) { { wxLogWarning( _( "Schematic sheets can only be nested %d levels deep. Not adding sheet %s" ), wxString msg; MAX_SHEET_PATH_DEPTH, GetChars( aSheet->m_SheetName ) ); msg.Printf( _( "Schematic sheets can only be nested %d levels deep." ), DSLSZ ); return; wxMessageBox( msg ); } } m_sheets.push_back( aSheet ); if( m_numSheets < DSLSZ ) { m_sheets[m_numSheets] = aSheet; m_numSheets++; } } } /** * Function Pop * retrieves (pop) the last entered sheet and remove it from list * @return a SCH_SHEET* pointer to the removed sheet in list */ SCH_SHEET* SCH_SHEET_PATH::Pop() SCH_SHEET* SCH_SHEET_PATH::Pop() { { if( m_sheets.empty() ) if( m_numSheets > 0 ) return NULL; { m_numSheets--; return m_sheets[m_numSheets]; } // The sheet must be released from the end of the container otherwise it will be destroyed. return NULL; return m_sheets.pop_back().release(); } } wxString SCH_SHEET_PATH::Path() const /** * Function Path * the path uses the time stamps which do not changes even when editing sheet * parameters * a path is something like / (root) or /34005677 or /34005677/00AE4523 */ wxString SCH_SHEET_PATH::Path() { { wxString s, t; wxString s, t; Loading @@ -176,9 +225,9 @@ wxString SCH_SHEET_PATH::Path() const // start at 1 to avoid the root sheet, // start at 1 to avoid the root sheet, // which does not need to be added to the path // which does not need to be added to the path // it's timestamp changes anyway. // it's timestamp changes anyway. for( unsigned i = 1; i < m_sheets.size(); i++ ) for( unsigned i = 1; i < m_numSheets; i++ ) { { t.Printf( _( "%8.8lX/" ), m_sheets[i].m_TimeStamp ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); s = s + t; s = s + t; } } Loading @@ -186,6 +235,13 @@ wxString SCH_SHEET_PATH::Path() const } } /** * Function PathHumanReadable * Return the sheet path in a readable form, i.e. * as a path made from sheet names. * (the "normal" path uses the time stamps which do not changes even when * editing sheet parameters) */ wxString SCH_SHEET_PATH::PathHumanReadable() const wxString SCH_SHEET_PATH::PathHumanReadable() const { { wxString s, t; wxString s, t; Loading @@ -193,9 +249,9 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const s = wxT( "/" ); s = wxT( "/" ); // start at 1 to avoid the root sheet, as above. // start at 1 to avoid the root sheet, as above. for( unsigned i = 1; i< m_sheets.size(); i++ ) for( unsigned i = 1; i< m_numSheets; i++ ) { { s = s + m_sheets[i].m_SheetName + wxT( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" ); } } return s; return s; Loading Loading @@ -257,12 +313,12 @@ void SCH_SHEET_PATH::AnnotatePowerSymbols( int* aReference ) } } void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) { { // Search to sheet path number: // Search to sheet path number: int sheetnumber = 1; // 1 = root int sheetnumber = 1; // 1 = root SCH_SHEET_LIST sheetList; SCH_SHEET_LIST sheetList; for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path != NULL; for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path != NULL; path = sheetList.GetNext(), sheetnumber++ ) path = sheetList.GetNext(), sheetnumber++ ) if( Cmp(*path) == 0 ) if( Cmp(*path) == 0 ) Loading Loading @@ -392,14 +448,34 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData, } } bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) { m_numSheets = d1.m_numSheets; unsigned i; for( i = 0; i < m_numSheets; i++ ) { m_sheets[i] = d1.m_sheets[i]; } for( ; i < DSLSZ; i++ ) { m_sheets[i] = 0; } return true; } bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const { { if( m_sheets.size() != d1.m_sheets.size() ) if( m_numSheets != d1.m_numSheets ) return false; return false; for( unsigned i = 0; i < m_sheets.size(); i++ ) for( unsigned i = 0; i < m_numSheets; i++ ) { { if( &m_sheets[i] != &d1.m_sheets[i] ) if( m_sheets[i] != d1.m_sheets[i] ) return false; return false; } } Loading @@ -407,11 +483,38 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const } } bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const { if( m_numSheets != d1.m_numSheets ) return true; for( unsigned i = 0; i < m_numSheets; i++ ) { if( m_sheets[i] != d1.m_sheets[i] ) { /* printf( "micompare this:'%s' d1:'%s'\n", CONV_TO_UTF8( PathHumanReadable() ), CONV_TO_UTF8( d1.PathHumanReadable() ) ); */ return true; } } return false; } /*********************************************************************/ /*********************************************************************/ /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ /*********************************************************************/ /*********************************************************************/ /* The constructor: build the list of sheets from aSheet. * If aSheet == NULL (default) build the whole list of sheets in hierarchy * So usually call it with no param. */ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) { { m_index = 0; m_index = 0; Loading @@ -425,6 +528,10 @@ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet ) } } /** * Function GetFirst * @return the first item (sheet) in m_List and prepare calls to GetNext() */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() { { m_index = 0; m_index = 0; Loading @@ -436,6 +543,11 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetFirst() } } /** * Function GetNext * @return the next item (sheet) in m_List or NULL if no more item in sheet * list */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetNext() SCH_SHEET_PATH* SCH_SHEET_LIST::GetNext() { { if( m_index < GetCount() ) if( m_index < GetCount() ) Loading Loading @@ -467,6 +579,12 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetPrevious() } } /** * Function GetSheet * @return the item (sheet) in aIndex position in m_List or NULL if less than * index items * @param aIndex = index in sheet list to get the sheet */ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) { { if( aIndex < GetCount() ) if( aIndex < GetCount() ) Loading @@ -476,28 +594,6 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( int aIndex ) } } bool SCH_SHEET_LIST::IsModified() { for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() ) { if( sheet->LastScreen() && sheet->LastScreen()->IsModify() ) return true; } return false; } void SCH_SHEET_LIST::ClearModifyStatus() { for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() ) { if( sheet->LastScreen() ) sheet->LastScreen()->ClrModify(); } } void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) { { if( m_List == NULL ) if( m_List == NULL ) Loading