Eeschema: move get components from SCH_SHEET_PATH to SCH_SHEET.

* Add sheet number that is set by schematic file load order.  This duplicates
  the previous SCH_SHEET_PATH behavior.
* Uncouple SCH_REFERENCE and SCH_REFERENCE_LIST from SCH_SHEET_PATH.
* Add - operator to SCH_SHEET for comparison purposes.  This duplicates the
  behavior of SCH_SHEET_PATH::Cmp().
This commit is contained in:
Wayne Stambaugh 2016-01-12 21:31:34 -05:00
parent b09c88042b
commit cdba425bad
13 changed files with 174 additions and 142 deletions

View File

@ -33,9 +33,9 @@
#include <confirm.h>
#include <schframe.h>
#include <sch_reference_list.h>
#include <class_library.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
@ -111,11 +111,11 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
// Build component list
if( aAnnotateSchematic )
{
sheets.GetComponents( Prj().SchLibs(), references );
g_RootSheet->GetComponents( Prj().SchLibs(), references );
}
else
{
m_CurrentSheet->GetComponents( Prj().SchLibs(), references );
m_CurrentSheet->Last()->GetComponents( Prj().SchLibs(), references, true, false );
}
// Break full components reference in name (prefix) and number:
@ -186,14 +186,13 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
{
// build the screen list
SCH_SHEET_LIST SheetList;
SCH_REFERENCE_LIST ComponentsList;
// Build the list of components
if( !aOneSheetOnly )
SheetList.GetComponents( Prj().SchLibs(), ComponentsList );
g_RootSheet->GetComponents( Prj().SchLibs(), ComponentsList );
else
m_CurrentSheet->GetComponents( Prj().SchLibs(), ComponentsList );
m_CurrentSheet->Last()->GetComponents( Prj().SchLibs(), ComponentsList, true, false );
return ComponentsList.CheckAnnotation( aMessageList );
}

View File

@ -38,9 +38,10 @@
#include <wildcards_and_files_ext.h>
#include <general.h>
#include <sch_sheet_path.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_reference_list.h>
#include <sch_sheet_path.h>
#include <dsnlexer.h>
#include <ptree.h>
@ -53,10 +54,9 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
{
// Build a flat list of components in schematic:
SCH_REFERENCE_LIST refs;
SCH_SHEET_LIST sheets;
bool isChanged = false;
sheets.GetComponents( Prj().SchLibs(), refs, false );
g_RootSheet->GetComponents( Prj().SchLibs(), refs, false );
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
PTREE doc;
@ -135,9 +135,8 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
{
// Build a flat list of components in schematic:
SCH_REFERENCE_LIST referencesList;
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( Prj().SchLibs(), referencesList, false );
g_RootSheet->GetComponents( Prj().SchLibs(), referencesList, false );
FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );

View File

@ -36,8 +36,9 @@
#include <fctsys.h>
#include <kicad_string.h>
#include <schframe.h>
#include <sch_reference_list.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_reference_list.h>
#include <boost/foreach.hpp>
@ -69,6 +70,7 @@ bool SCH_REFERENCE_LIST::sortByXPosition( const SCH_REFERENCE& item1,
return ii < 0;
}
bool SCH_REFERENCE_LIST::sortByYPosition( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
@ -132,7 +134,9 @@ bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1,
bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
wxCHECK( item1.m_Sheet != NULL && item2.m_Sheet != NULL, false );
int ii = *item1.m_Sheet - *item2.m_Sheet;
if( ii == 0 )
ii = item1.m_TimeStamp - item2.m_TimeStamp;
@ -140,6 +144,7 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
return ii < 0;
}
int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit )
{
int NumRef;
@ -286,7 +291,7 @@ int SCH_REFERENCE_LIST::CreateFirstFreeRefId( std::vector<int>& aIdList, int aFi
void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap )
SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap )
{
if ( componentFlatList.size() == 0 )
return;
@ -332,9 +337,11 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
// Check whether this component is in aLockedUnitMap.
SCH_REFERENCE_LIST* lockedList = NULL;
BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, aLockedUnitMap )
{
unsigned n_refs = pair.second.GetCount();
for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
{
SCH_REFERENCE &thisRef = pair.second[thisRefI];
@ -414,22 +421,29 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
if( lockedList != NULL )
{
unsigned n_refs = lockedList->GetCount();
for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
{
SCH_REFERENCE &thisRef = (*lockedList)[thisRefI];
if( thisRef.IsSameInstance( componentFlatList[ii] ) )
{
// This is the component we're currently annotating. Hold the unit!
componentFlatList[ii].m_Unit = thisRef.m_Unit;
}
if( thisRef.CompareValue( componentFlatList[ii] ) != 0 ) continue;
if( thisRef.CompareLibName( componentFlatList[ii] ) != 0 ) continue;
if( thisRef.CompareValue( componentFlatList[ii] ) != 0 )
continue;
if( thisRef.CompareLibName( componentFlatList[ii] ) != 0 )
continue;
// Find the matching component
for( unsigned jj = ii + 1; jj < componentFlatList.size(); jj++ )
{
if( ! thisRef.IsSameInstance( componentFlatList[jj] ) ) continue;
if( ! thisRef.IsSameInstance( componentFlatList[jj] ) )
continue;
componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef;
componentFlatList[jj].m_Unit = thisRef.m_Unit;
componentFlatList[jj].m_IsNew = false;
@ -438,13 +452,12 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
}
}
}
else
{
/* search for others units of this component.
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
for( Unit = 1; Unit <= NumberOfUnits; Unit++ )
{
if( componentFlatList[ii].m_Unit == Unit )
@ -498,7 +511,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
SortByRefAndValue();
// Spiit reference designators into name (prefix) and number: IC1 becomes IC, and 1.
// Split reference designators into name (prefix) and number: IC1 becomes IC, and 1.
SplitReferences();
// count not yet annotated items or annotation error.
@ -668,14 +681,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
for( int ii = 0; ( ii < imax ) && ( error < 4 ); ii++ )
{
if( ( componentFlatList[ii].m_TimeStamp != componentFlatList[ii + 1].m_TimeStamp )
|| ( componentFlatList[ii].GetSheetPath() != componentFlatList[ii + 1].GetSheetPath() ) )
|| ( componentFlatList[ii].GetSheet() != componentFlatList[ii + 1].GetSheet() ) )
continue;
// Same time stamp found.
wxString full_path;
full_path.Printf( wxT( "%s%8.8X" ),
GetChars( componentFlatList[ii].GetSheetPath().Path() ),
GetChars( componentFlatList[ii].GetSheet()->GetPath() ),
componentFlatList[ii].m_TimeStamp );
msg.Printf( _( "Duplicate time stamp (%s) for %s%d and %s%d" ),
@ -695,24 +708,24 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET_PATH& aSheetPath )
SCH_SHEET* aSheet )
{
wxASSERT( aComponent != NULL && aLibComponent != NULL );
m_RootCmp = aComponent;
m_Entry = aLibComponent;
m_Unit = aComponent->GetUnitSelection( aSheetPath.Last() );
m_SheetPath = aSheetPath;
m_Unit = aComponent->GetUnitSelection( aSheet );
m_Sheet = aSheet;
m_IsNew = false;
m_Flag = 0;
m_TimeStamp = aComponent->GetTimeStamp();
m_CmpPos = aComponent->GetPosition();
m_SheetNum = 0;
if( aComponent->GetRef( aSheetPath.Last() ).IsEmpty() )
aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) );
if( aComponent->GetRef( aSheet ).IsEmpty() )
aComponent->SetRef( aSheet, wxT( "DefRef?" ) );
SetRef( aComponent->GetRef( aSheetPath.Last() ) );
SetRef( aComponent->GetRef( aSheet ) );
m_NumRef = -1;
@ -730,9 +743,9 @@ void SCH_REFERENCE::Annotate()
else
m_Ref = TO_UTF8( GetRef() << m_NumRef );
m_RootCmp->SetRef( m_SheetPath.Last(), FROM_UTF8( m_Ref.c_str() ) );
m_RootCmp->SetRef( m_Sheet, FROM_UTF8( m_Ref.c_str() ) );
m_RootCmp->SetUnit( m_Unit );
m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit );
m_RootCmp->SetUnitSelection( m_Sheet, m_Unit );
}
@ -766,7 +779,7 @@ void SCH_REFERENCE::Split()
{
while( ll >= 0 )
{
if( (refText[ll] <= ' ' ) || isdigit( refText[ll] ) )
if( ( refText[ll] <= ' ' ) || isdigit( refText[ll] ) )
ll--;
else
{

View File

@ -340,7 +340,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{
int unit_selection = unitChoice->GetCurrentSelection() + 1;
m_cmp->SetUnitSelection( &m_parent->GetCurrentSheet(), unit_selection );
m_cmp->SetUnitSelection( m_parent->GetCurrentSheet().Last(), unit_selection );
m_cmp->SetUnit( unit_selection );
}

View File

@ -41,6 +41,7 @@
#include <general.h>
#include <class_library.h>
#include <sch_component.h>
#include <sch_sheet_path.h>
#include <libeditframe.h>
#include <viewlib_frame.h>
#include <eeschema_id.h>
@ -325,7 +326,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Update the unit number. */
component->SetUnitSelection( m_CurrentSheet, unit );
component->SetUnitSelection( m_CurrentSheet->Last(), unit );
component->SetUnit( unit );
component->ClearFlags();
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()

View File

@ -87,7 +87,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, uns
{
if( part->GetFootPrints().GetCount() != 0 ) // Put in list
{
cmpList.push_back( SCH_REFERENCE( comp, part, *path ) );
cmpList.push_back( SCH_REFERENCE( comp, part, path->Last() ) );
}
}

View File

@ -606,9 +606,9 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET* aSheet )
}
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection )
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET* aSheet, int aUnitSelection )
{
wxString path = GetPath( aSheet->Last() );
wxString path = GetPath( aSheet );
bool notInArray = true;

View File

@ -432,11 +432,11 @@ public:
const wxString& aRef,
int aMulti );
// returns the unit selection, for the given sheet path.
// returns the unit selection, for the given sheet.
int GetUnitSelection( SCH_SHEET* aSheet );
// Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection );
// Set the unit selection, for the given sheet.
void SetUnitSelection( SCH_SHEET* aSheet, int aUnitSelection );
// Geometric transforms (used in block operations):

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 1992-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see authors.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -35,15 +35,15 @@
#include <macros.h>
#include <class_libentry.h>
#include <sch_sheet_path.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_text.h>
#include <map>
class SCH_REFERENCE;
class SCH_REFERENCE_LIST;
/**
* Class SCH_REFERENCE
* is used as a helper to define a component's reference designator in a schematic. This
@ -62,11 +62,11 @@ class SCH_REFERENCE
///< used to annotate by X or Y position
int m_Unit; ///< The unit number for components with multiple parts
///< per package.
SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference.
SCH_SHEET* m_Sheet; ///< The sheet for this reference.
bool m_IsNew; ///< True if not yet annotated.
int m_SheetNum; ///< The sheet number for the reference.
time_t m_TimeStamp; ///< The time stamp for the reference.
EDA_TEXT* m_Value; ///< The component value of the refernce. It is the
EDA_TEXT* m_Value; ///< The component value of the reference. It is the
///< same for all instances.
int m_NumRef; ///< The numeric part of the reference designator.
int m_Flag;
@ -77,7 +77,7 @@ class SCH_REFERENCE
public:
SCH_REFERENCE() :
m_SheetPath()
m_Sheet()
{
m_RootCmp = NULL;
m_Entry = NULL;
@ -90,14 +90,14 @@ public:
m_SheetNum = 0;
}
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET_PATH& aSheetPath );
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET* aSheet );
SCH_COMPONENT* GetComp() const { return m_RootCmp; }
LIB_PART* GetLibComponent() const { return m_Entry; }
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
SCH_SHEET* GetSheet() const { return m_Sheet; }
int GetUnit() const { return m_Unit; }
@ -131,10 +131,12 @@ public:
{
return m_Ref;
}
void SetRefStr( const std::string& aReference )
{
m_Ref = aReference;
}
const char* GetRefStr() const
{
return m_Ref.c_str();
@ -162,7 +164,7 @@ public:
*/
bool IsSameInstance( const SCH_REFERENCE& other ) const
{
return GetComp() == other.GetComp() && GetSheetPath().Path() == other.GetSheetPath().Path();
return GetComp() == other.GetComp() && GetSheet()->GetPath() == other.GetSheet()->GetPath();
}
bool IsUnitsLocked()
@ -296,7 +298,8 @@ public:
* referenced U201 to U351, and items in sheet 3 start from U352
* </p>
*/
void Annotate( bool aUseSheetNum, int aSheetIntervalId, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap );
void Annotate( bool aUseSheetNum, int aSheetIntervalId,
std::map<wxString, SCH_REFERENCE_LIST>& aLockedUnitMap );
/**
* Function CheckAnnotation
@ -466,4 +469,12 @@ private:
int CreateFirstFreeRefId( std::vector<int>& aIdList, int aFirstValue );
};
/**
* Type SCH_MULTI_UNIT_REFERENCE_MAP
* is used to create a map of reference designators for multi-unit parts.
*/
typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
#endif // _SCH_REFERENCE_LIST_H_

View File

@ -42,6 +42,7 @@
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <class_netlist_object.h>
#include <sch_reference_list.h>
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
@ -182,6 +183,11 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
SCH_SHEET_PIN* sheetPin;
char* ptcar;
if( IsRootSheet() )
m_number = 1;
else
m_number = GetRootSheet()->CountSheets();
SetTimeStamp( GetNewTimeStamp() );
// sheets are added to the GetDrawItems() like other schematic components.
@ -221,8 +227,10 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( ((char*)aLine)[0] == 'U' )
{
sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp );
if( m_TimeStamp == 0 ) // zero is not unique!
SetTimeStamp( GetNewTimeStamp() );
continue;
}
@ -1350,6 +1358,39 @@ void SCH_SHEET::UpdateAllScreenReferences()
}
void SCH_SHEET::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols, bool aIncludeSubSheets )
{
for( SCH_ITEM* item = m_screen->GetDrawItems(); item; item = item->Next() )
{
if( item->Type() == SCH_SHEET_T && aIncludeSubSheets )
{
((SCH_SHEET*)item)->GetComponents( aLibs, aReferences, aIncludePowerSymbols,
aIncludeSubSheets );
}
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
// Skip pseudo components, which have a reference starting with #. This mainly
// affects power symbols.
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, this );
reference.SetSheetNumber( m_number );
aReferences.AddItem( reference );
}
}
}
}
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxLogDebug( wxT( "Sheet assignment operator." ) );
@ -1384,10 +1425,19 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
{
if( (*this - aRhs) < 0 )
return true;
return false;
}
int SCH_SHEET::operator-( const SCH_SHEET& aRhs ) const
{
// Don't waste time against comparing the same objects..
if( this == &aRhs )
return false;
return 0;
SCH_CONST_SHEETS lhsPath, rhsPath;
@ -1395,20 +1445,21 @@ bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
aRhs.GetPath( rhsPath );
// Shorter paths are less than longer paths.
if( lhsPath.size() < rhsPath.size() )
return true;
int retv = lhsPath.size() - rhsPath.size();
if( lhsPath.size() > rhsPath.size() )
return false;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
if( retv == 0 )
{
if( lhsPath[i]->GetTimeStamp() < rhsPath[i]->GetTimeStamp() )
return true;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
{
retv = lhsPath[i]->GetTimeStamp() - rhsPath[i]->GetTimeStamp();
if( retv != 0 )
break;
}
}
return false;
return retv;
}

View File

@ -44,6 +44,7 @@ class SCH_SHEET_PATH;
class DANGLING_END_ITEM;
class SCH_EDIT_FRAME;
class NETLIST_OBJECT_LIST;
class SCH_REFERENCE_LIST;
#define MIN_SHEET_WIDTH 500
@ -244,6 +245,11 @@ class SCH_SHEET : public SCH_ITEM
/// The size of the sheet.
wxSize m_size;
/// The sheet number ordered by file load.
// @todo: At some point this should really be a sheet number assigned by the user rather
// than assigned in the order the sheets were parsed and loaded.
int m_number;
public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -569,6 +575,8 @@ public:
*/
bool operator<( const SCH_SHEET& aRhs ) const;
int operator-( const SCH_SHEET& aRhs ) const;
wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition );
@ -679,6 +687,19 @@ public:
*/
void UpdateAllScreenReferences();
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
*
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols : false to only get normal components.
* @param aIncludeSubSheets true includes components of all sub-sheets and false includes
* only the components in this sheet.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true, bool aIncludeSubSheets = true );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override
#endif

View File

@ -227,43 +227,9 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const
}
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
{
// Search to sheet path number:
int sheetnumber = 1; // 1 = root
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext(), sheetnumber++ )
{
if( Cmp( *path ) == 0 )
break;
}
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
{
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
// Skip pseudo components, which have a reference starting with #. This mainly
// affects power symbols.
if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
reference.SetSheetNumber( sheetnumber );
aReferences.AddItem( reference );
}
}
}
}
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
bool aIncludePowerSymbols )
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs,
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols )
{
// Find sheet path number
int sheetnumber = 1; // 1 = root
@ -289,7 +255,7 @@ void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_RE
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part && part->GetUnitCount() > 1 )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
SCH_REFERENCE reference = SCH_REFERENCE( component, part, Last() );
reference.SetSheetNumber( sheetnumber );
wxString reference_str = reference.GetRef();
@ -629,24 +595,20 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
}
void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols )
{
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
path->GetComponents( aLibs, aReferences, aIncludePowerSymbols );
}
void SCH_SHEET_LIST::GetMultiUnitComponents( PART_LIBS* aLibs,
SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols )
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols )
{
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
{
SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
path->GetMultiUnitComponents( aLibs, tempMap );
BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, tempMap )
{
// Merge this list into the main one
unsigned n_refs = pair.second.GetCount();
for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
{
aRefList[pair.first].AddItem( pair.second[thisRef] );

View File

@ -1,9 +1,10 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 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
@ -32,6 +33,7 @@
#define CLASS_DRAWSHEET_PATH_H
#include <base_struct.h>
#include <sch_reference_list.h>
/** Info about complex hierarchies handling:
@ -82,18 +84,12 @@ class SCH_SCREEN;
class SCH_MARKER;
class SCH_SHEET;
class SCH_ITEM;
class SCH_REFERENCE_LIST;
class PART_LIBS;
#define SHEET_NOT_FOUND -1
/**
* Type SCH_MULTI_UNIT_REFERENCE_MAP
* is used to create a map of reference designators for multi-unit parts.
*/
typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
/**
* Class SCH_SHEET_PATH
* handles access to a sheet by way of a path.
@ -215,16 +211,6 @@ public:
*/
bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false );
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols : false to only get normal components.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true );
/**
* Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -234,7 +220,7 @@ public:
* @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols : false to only get normal components.
*/
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols = true );
/**
@ -414,17 +400,6 @@ public:
*/
SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the list
* of sheets.
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols Set to false to only get normal components.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true );
/**
* Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -434,8 +409,8 @@ public:
* @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols Set to false to only get normal components.
*/
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
bool aIncludePowerSymbols = true );
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols = true );
/**
* Function FindNextItem