diff --git a/eeschema/class_sch_screen.h b/eeschema/class_sch_screen.h index 180f925775..a13249098e 100644 --- a/eeschema/class_sch_screen.h +++ b/eeschema/class_sch_screen.h @@ -49,7 +49,6 @@ class SCH_SHEET_PIN; class SCH_LINE; class SCH_TEXT; class PLOTTER; -class SCH_SHEET; enum SCH_LINE_TEST_T @@ -501,13 +500,13 @@ public: * searches screen for a component with \a aReference and set the footprint field to * \a aFootPrint if found. * - * @param aSheet The sheet used to look up the reference designator. + * @param aSheetPath The sheet path used to look up the reference designator. * @param aReference The reference designator of the component. * @param aFootPrint The value to set the footprint field. * @param aSetVisible The value to set the field visibility flag. * @return True if \a aReference was found otherwise false. */ - bool SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aReference, + bool SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference, const wxString& aFootPrint, bool aSetVisible ); /** diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 032dd87ad2..f239ad5727 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -71,8 +71,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) if( event.GetFlags() & FR_CURRENT_SHEET_ONLY ) { sheetFoundIn = m_CurrentSheet; - lastMarker = (SCH_MARKER*) m_CurrentSheet->Last()->FindNextItem( SCH_MARKER_T, - lastMarker, wrap ); + lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker, wrap ); } else { diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 8ea1d3f5d8..1a24d4a24e 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1103,7 +1103,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) } -bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aReference, +bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference, const wxString& aFootPrint, bool aSetVisible ) { SCH_COMPONENT* component; @@ -1116,7 +1116,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aRefe component = (SCH_COMPONENT*) item; - if( aReference.CmpNoCase( component->GetRef( aSheet ) ) == 0 ) + if( aReference.CmpNoCase( component->GetRef( aSheetPath->Last() ) ) == 0 ) { // Found: Init Footprint Field @@ -1125,7 +1125,6 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aRefe * it is probably not yet initialized */ SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); - if( fpfield->GetText().IsEmpty() && ( fpfield->GetTextPosition() == component->GetPosition() ) ) { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 85549a19a6..c87cf98b71 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -811,11 +811,6 @@ void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Path" ), GetHumanReadablePath(), DARKMAGENTA ) ); - if( IsRootSheet() ) - aList.push_back( MSG_PANEL_ITEM( _( "Hierarchy Type" ), - IsComplexHierarchy() ? _( "Complex" ) : _( "Simple" ), - GREEN ) ); - #if 1 // Set to 1 to display the sheet time stamp (mainly for test) aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), GetPath(), BLUE ) ); #endif @@ -1166,27 +1161,6 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) } -unsigned SCH_SHEET::GetSheets( std::vector& aSheetList ) const -{ - // Sheet pointers must be unique. - wxASSERT( find( aSheetList.begin(), aSheetList.end(), this ) == aSheetList.end() ); - - aSheetList.push_back( this ); - - const SCH_ITEM* item = m_screen->GetDrawItems(); - - while( item ) - { - if( item->Type() == SCH_SHEET_T ) - ( (SCH_SHEET*) item )->GetSheets( aSheetList ); - - item = item->Next(); - } - - return aSheetList.size(); -} - - SCH_SHEET* SCH_SHEET::GetRootSheet() { EDA_ITEM* parent = GetParent(); @@ -1489,60 +1463,6 @@ void SCH_SHEET::GetMultiUnitComponents( PART_LIBS* aLibs, } -bool SCH_SHEET::IsComplexHierarchy() const -{ - std::set fileNames; - std::vector< const SCH_SHEET* > sheets; - - unsigned count = GetSheets( sheets ); - - for( unsigned i = 0; i < count; i++ ) - { - if( fileNames.find( sheets[i]->m_fileName ) != fileNames.end() ) - return true; - - fileNames.insert( sheets[i]->m_fileName ); - } - - return false; -} - - -SCH_ITEM* SCH_SHEET::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const -{ - wxCHECK( m_screen != NULL, NULL ); - - bool hasWrapped = false; - bool firstItemFound = false; - SCH_ITEM* drawItem = m_screen->GetDrawItems(); - - while( drawItem ) - { - if( drawItem->Type() == aType ) - { - if( !aLastItem || firstItemFound ) - { - return drawItem; - } - else if( !firstItemFound && drawItem == aLastItem ) - { - firstItemFound = true; - } - } - - drawItem = drawItem->Next(); - - if( !drawItem && aLastItem && aWrap && !hasWrapped ) - { - hasWrapped = true; - drawItem = m_screen->GetDrawItems(); - } - } - - return NULL; -} - - bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const { if( (*this - aRhs) < 0 ) diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index ccb4c7e674..e3ff3beddb 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -589,16 +589,6 @@ public: EDA_ITEM* Clone() const; - /** - * Function GetSheets - * - * add the point to #SCH_SHEET and all of it's sub-sheets to \a aSheetList. - * - * @param aSheetList is a reference to a set containing the #SCH_SHEET pointers. - * @return the number of #SCH_SHEET object pointers in \a aSheetList. - */ - unsigned GetSheets( std::vector& aSheetList ) const; - /** * Function GetRootSheet * @@ -723,30 +713,6 @@ public: void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, bool aIncludePowerSymbols = true ); - /** - * Function IsComplexHierarchy - * searches all of the sheets for duplicate files names which indicates a complex - * hierarchy. - * - * Typically this function would be called from the root sheet. However, it is possible - * to test only the sub-hierarchy from any #SCH_SHEET object. - * - * @return true if the #SCH_SHEET is a complex hierarchy. - */ - bool IsComplexHierarchy() const; - - /** - * Find the next schematic item in this sheet object. - * - * @param aType - The type of schematic item object to search for. - * @param aLastItem - Start search from aLastItem. If no aLastItem, search from - * the beginning of the list. - * @param aWrap - Wrap around the end of the list to find the next item if aLastItem - * is defined. - * @return - The next schematic item if found. Otherwise, NULL is returned. - */ - SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const; - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index f20056d26e..b310482883 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -227,6 +227,39 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const } +SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const +{ + bool hasWrapped = false; + bool firstItemFound = false; + SCH_ITEM* drawItem = LastDrawList(); + + while( drawItem ) + { + if( drawItem->Type() == aType ) + { + if( !aLastItem || firstItemFound ) + { + return drawItem; + } + else if( !firstItemFound && drawItem == aLastItem ) + { + firstItemFound = true; + } + } + + drawItem = drawItem->Next(); + + if( !drawItem && aLastItem && aWrap && !hasWrapped ) + { + hasWrapped = true; + drawItem = LastDrawList(); + } + } + + return NULL; +} + + SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const { bool hasWrapped = false; @@ -260,6 +293,18 @@ SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, } +bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint, + bool aSetVisible ) +{ + SCH_SCREEN* screen = LastScreen(); + + if( screen == NULL ) + return false; + + return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible ); +} + + SCH_SHEET_PATH& SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) { if( this == &d1 ) // Self assignment is bad! @@ -600,6 +645,40 @@ SCH_ITEM* SCH_SHEET_LIST::FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aShe } +bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference, + const wxString& aFootPrint, bool aSetVisible ) +{ + bool found = false; + + for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() ) + found = path->SetComponentFootprint( aReference, aFootPrint, aSetVisible ); + + return found; +} + + +bool SCH_SHEET_LIST::IsComplexHierarchy() const +{ + wxString fileName; + + for( int i = 0; i < m_count; i++ ) + { + fileName = m_list[i].Last()->GetFileName(); + + for( int j = 0; j < m_count; j++ ) + { + if( i == j ) + continue; + + if( fileName == m_list[j].Last()->GetFileName() ) + return true; + } + } + + return false; +} + + bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy, const wxString& aDestFileName ) const { diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index be3e11a87a..862a5c9fa6 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -208,6 +208,31 @@ public: */ bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false ); + /** + * Function SetFootprintField + * searches last sheet in the path for a component with \a aReference and set the footprint + * field to \a aFootPrint if found. + * + * @param aReference The reference designator of the component. + * @param aFootPrint The value to set the footprint field. + * @param aSetVisible The value to set the field visibility flag. + * @return True if \a aReference was found otherwise false. + */ + bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint, + bool aSetVisible ); + + /** + * Find the next schematic item in this sheet object. + * + * @param aType - The type of schematic item object to search for. + * @param aLastItem - Start search from aLastItem. If no aLastItem, search from + * the beginning of the list. + * @param aWrap - Wrap around the end of the list to find the next item if aLastItem + * is defined. + * @return - The next schematic item if found. Otherwise, NULL is returned. + */ + SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const; + /** * Find the previous schematic item in this sheet path object. * @@ -388,6 +413,28 @@ public: SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL, SCH_ITEM* aLastItem = NULL, bool aWrap = true ); + /** + * Function SetFootprintField + * searches all the sheets for a component with \a aReference and set the footprint + * field to \a aFootPrint if found. + * + * @param aReference The reference designator of the component. + * @param aFootPrint The value to set the footprint field. + * @param aSetVisible The value to set the field visibility flag. + * @return True if \a aReference was found otherwise false. + */ + bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint, + bool aSetVisible ); + + /** + * Function IsComplexHierarchy + * searches all of the sheets for duplicate files names which indicates a complex + * hierarchy. + * + * @return true if the #SCH_SHEET_LIST is a complex hierarchy. + */ + bool IsComplexHierarchy() const; + /** * Function TestForRecursion *