Eeschema: move is complex hierarchy and find next item from SCH_SHEET_PATH to SCH_SHEET.
* Add function to get a list pointers to this sheet and all of it's sub-sheets to SCH_SHEET. * Remove unused function SetFootprintField() from SCH_SHEET_PATH.
This commit is contained in:
parent
d18baf1487
commit
2aac71700b
|
@ -49,6 +49,7 @@ class SCH_SHEET_PIN;
|
|||
class SCH_LINE;
|
||||
class SCH_TEXT;
|
||||
class PLOTTER;
|
||||
class SCH_SHEET;
|
||||
|
||||
|
||||
enum SCH_LINE_TEST_T
|
||||
|
@ -500,13 +501,13 @@ public:
|
|||
* searches screen for a component with \a aReference and set the footprint field to
|
||||
* \a aFootPrint if found.
|
||||
*
|
||||
* @param aSheetPath The sheet path used to look up the reference designator.
|
||||
* @param aSheet The sheet 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_PATH* aSheetPath, const wxString& aReference,
|
||||
bool SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aReference,
|
||||
const wxString& aFootPrint, bool aSetVisible );
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
|
|||
if( event.GetFlags() & FR_CURRENT_SHEET_ONLY )
|
||||
{
|
||||
sheetFoundIn = m_CurrentSheet;
|
||||
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker, wrap );
|
||||
lastMarker = (SCH_MARKER*) m_CurrentSheet->Last()->FindNextItem( SCH_MARKER_T,
|
||||
lastMarker, wrap );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1103,7 +1103,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
|
||||
bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET* aSheet, const wxString& aReference,
|
||||
const wxString& aFootPrint, bool aSetVisible )
|
||||
{
|
||||
SCH_COMPONENT* component;
|
||||
|
@ -1116,7 +1116,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
|
|||
|
||||
component = (SCH_COMPONENT*) item;
|
||||
|
||||
if( aReference.CmpNoCase( component->GetRef( aSheetPath->Last() ) ) == 0 )
|
||||
if( aReference.CmpNoCase( component->GetRef( aSheet ) ) == 0 )
|
||||
{
|
||||
// Found: Init Footprint Field
|
||||
|
||||
|
@ -1125,6 +1125,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
|
|||
* it is probably not yet initialized
|
||||
*/
|
||||
SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
|
||||
|
||||
if( fpfield->GetText().IsEmpty()
|
||||
&& ( fpfield->GetTextPosition() == component->GetPosition() ) )
|
||||
{
|
||||
|
|
|
@ -811,6 +811,11 @@ 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
|
||||
|
@ -1161,6 +1166,27 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
|
|||
}
|
||||
|
||||
|
||||
unsigned SCH_SHEET::GetSheets( std::vector<const SCH_SHEET*>& 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();
|
||||
|
@ -1463,6 +1489,60 @@ void SCH_SHEET::GetMultiUnitComponents( PART_LIBS* aLibs,
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SHEET::IsComplexHierarchy() const
|
||||
{
|
||||
std::set<wxString> 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 )
|
||||
|
|
|
@ -589,6 +589,16 @@ 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<const SCH_SHEET*>& aSheetList ) const;
|
||||
|
||||
/**
|
||||
* Function GetRootSheet
|
||||
*
|
||||
|
@ -713,6 +723,30 @@ 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
|
||||
|
|
|
@ -227,39 +227,6 @@ 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;
|
||||
|
@ -293,18 +260,6 @@ 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!
|
||||
|
@ -645,40 +600,6 @@ 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
|
||||
{
|
||||
|
|
|
@ -208,31 +208,6 @@ 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.
|
||||
*
|
||||
|
@ -413,28 +388,6 @@ 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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue