Undo commit -r 6457.

This commit is contained in:
Wayne Stambaugh 2016-02-15 15:16:54 -05:00
parent 8587488984
commit 1866b61a56
13 changed files with 142 additions and 174 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,6 @@
#include <general.h> #include <general.h>
#include <class_library.h> #include <class_library.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_sheet_path.h>
#include <libeditframe.h> #include <libeditframe.h>
#include <viewlib_frame.h> #include <viewlib_frame.h>
#include <eeschema_id.h> #include <eeschema_id.h>
@ -326,7 +325,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Update the unit number. */ /* Update the unit number. */
component->SetUnitSelection( m_CurrentSheet->Last(), unit ); component->SetUnitSelection( m_CurrentSheet, unit );
component->SetUnit( unit ); component->SetUnit( unit );
component->ClearFlags(); component->ClearFlags();
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit() 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 if( part->GetFootPrints().GetCount() != 0 ) // Put in list
{ {
cmpList.push_back( SCH_REFERENCE( comp, part, path->Last() ) ); cmpList.push_back( SCH_REFERENCE( comp, part, *path ) );
} }
} }

View File

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

View File

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

View File

@ -42,7 +42,6 @@
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <sch_component.h> #include <sch_component.h>
#include <class_netlist_object.h> #include <class_netlist_object.h>
#include <sch_reference_list.h>
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
@ -183,11 +182,6 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
SCH_SHEET_PIN* sheetPin; SCH_SHEET_PIN* sheetPin;
char* ptcar; char* ptcar;
if( IsRootSheet() )
m_number = 1;
else
m_number = GetRootSheet()->CountSheets();
SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() );
// sheets are added to the GetDrawItems() like other schematic components. // sheets are added to the GetDrawItems() like other schematic components.
@ -227,10 +221,8 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( ((char*)aLine)[0] == 'U' ) if( ((char*)aLine)[0] == 'U' )
{ {
sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp ); sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp );
if( m_TimeStamp == 0 ) // zero is not unique! if( m_TimeStamp == 0 ) // zero is not unique!
SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() );
continue; continue;
} }
@ -1358,39 +1350,6 @@ 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 ) SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{ {
wxLogDebug( wxT( "Sheet assignment operator." ) ); wxLogDebug( wxT( "Sheet assignment operator." ) );
@ -1425,19 +1384,10 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const 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.. // Don't waste time against comparing the same objects..
if( this == &aRhs ) if( this == &aRhs )
return 0; return false;
SCH_CONST_SHEETS lhsPath, rhsPath; SCH_CONST_SHEETS lhsPath, rhsPath;
@ -1445,21 +1395,20 @@ int SCH_SHEET::operator-( const SCH_SHEET& aRhs ) const
aRhs.GetPath( rhsPath ); aRhs.GetPath( rhsPath );
// Shorter paths are less than longer paths. // Shorter paths are less than longer paths.
int retv = lhsPath.size() - rhsPath.size(); if( lhsPath.size() < rhsPath.size() )
return true;
if( retv == 0 ) if( lhsPath.size() > rhsPath.size() )
return false;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
{ {
// Compare time stamps when path lengths are the same. if( lhsPath[i]->GetTimeStamp() < rhsPath[i]->GetTimeStamp() )
for( unsigned i = 0; i < lhsPath.size(); i++ ) return true;
{
retv = lhsPath[i]->GetTimeStamp() - rhsPath[i]->GetTimeStamp();
if( retv != 0 )
break;
}
} }
return retv; return false;
} }

View File

@ -44,7 +44,6 @@ class SCH_SHEET_PATH;
class DANGLING_END_ITEM; class DANGLING_END_ITEM;
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
class NETLIST_OBJECT_LIST; class NETLIST_OBJECT_LIST;
class SCH_REFERENCE_LIST;
#define MIN_SHEET_WIDTH 500 #define MIN_SHEET_WIDTH 500
@ -245,11 +244,6 @@ class SCH_SHEET : public SCH_ITEM
/// The size of the sheet. /// The size of the sheet.
wxSize m_size; 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: public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -575,8 +569,6 @@ public:
*/ */
bool operator<( const SCH_SHEET& aRhs ) const; bool operator<( const SCH_SHEET& aRhs ) const;
int operator-( const SCH_SHEET& aRhs ) const;
wxPoint GetPosition() const { return m_pos; } wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition ); void SetPosition( const wxPoint& aPosition );
@ -687,19 +679,6 @@ public:
*/ */
void UpdateAllScreenReferences(); 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) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override void Show( int nestLevel, std::ostream& os ) const; // override
#endif #endif

View File

@ -227,9 +227,43 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const
} }
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, {
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 )
{ {
// Find sheet path number // Find sheet path number
int sheetnumber = 1; // 1 = root int sheetnumber = 1; // 1 = root
@ -255,7 +289,7 @@ void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs,
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part && part->GetUnitCount() > 1 ) if( part && part->GetUnitCount() > 1 )
{ {
SCH_REFERENCE reference = SCH_REFERENCE( component, part, Last() ); SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
reference.SetSheetNumber( sheetnumber ); reference.SetSheetNumber( sheetnumber );
wxString reference_str = reference.GetRef(); wxString reference_str = reference.GetRef();
@ -595,20 +629,24 @@ 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, void SCH_SHEET_LIST::GetMultiUnitComponents( PART_LIBS* aLibs,
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols )
bool aIncludePowerSymbols )
{ {
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() ) for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
{ {
SCH_MULTI_UNIT_REFERENCE_MAP tempMap; SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
path->GetMultiUnitComponents( aLibs, tempMap ); path->GetMultiUnitComponents( aLibs, tempMap );
BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, tempMap ) BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, tempMap )
{ {
// Merge this list into the main one // Merge this list into the main one
unsigned n_refs = pair.second.GetCount(); unsigned n_refs = pair.second.GetCount();
for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef ) for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
{ {
aRefList[pair.first].AddItem( pair.second[thisRef] ); aRefList[pair.first].AddItem( pair.second[thisRef] );

View File

@ -1,10 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011-2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,7 +32,6 @@
#define CLASS_DRAWSHEET_PATH_H #define CLASS_DRAWSHEET_PATH_H
#include <base_struct.h> #include <base_struct.h>
#include <sch_reference_list.h>
/** Info about complex hierarchies handling: /** Info about complex hierarchies handling:
@ -84,12 +82,18 @@ class SCH_SCREEN;
class SCH_MARKER; class SCH_MARKER;
class SCH_SHEET; class SCH_SHEET;
class SCH_ITEM; class SCH_ITEM;
class SCH_REFERENCE_LIST;
class PART_LIBS; class PART_LIBS;
#define SHEET_NOT_FOUND -1 #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 * Class SCH_SHEET_PATH
* handles access to a sheet by way of a path. * handles access to a sheet by way of a path.
@ -211,6 +215,16 @@ public:
*/ */
bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false ); 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 * Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of * adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -220,7 +234,7 @@ public:
* @param aRefList Map of reference designators to reference lists * @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols : false to only get normal components. * @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 ); bool aIncludePowerSymbols = true );
/** /**
@ -400,6 +414,17 @@ public:
*/ */
SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true ); 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 * Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of * adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -409,8 +434,8 @@ public:
* @param aRefList Map of reference designators to reference lists * @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols Set to false to only get normal components. * @param aIncludePowerSymbols Set to 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 ); bool aIncludePowerSymbols = true );
/** /**
* Function FindNextItem * Function FindNextItem