Added SCH_COMPONENT * WinEDA_SchematicFrame::FindComponentByRef

for backanno.cpp, a better candidate for searching.
This commit is contained in:
bennett78 2008-05-08 20:34:39 +00:00
parent 4186aa8a6b
commit 0d3769b234
2 changed files with 37 additions and 13 deletions

View File

@ -17,13 +17,39 @@
#include "protos.h" #include "protos.h"
/**************************************************************/
SCH_COMPONENT * WinEDA_SchematicFrame::FindComponentByRef(
const wxString& reference )
/**************************************************************/
{
DrawSheetPath* sheet;
SCH_ITEM* DrawList = NULL;
EDA_SheetList SheetList( NULL );
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
DrawList = (SCH_ITEM*) sheet->LastDrawList();
for( ; (DrawList != NULL); DrawList = DrawList->Next() )
{
if( DrawList->Type() == TYPE_SCH_COMPONENT )
{
SCH_COMPONENT* pSch;
pSch = (SCH_COMPONENT*) DrawList;
if( reference.CmpNoCase( pSch->GetRef(sheet) ) == 0 )
return pSch;
}
}
}
return NULL;
}
/**************************************************************/ /**************************************************************/
bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* StuffFile ) bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* StuffFile )
/**************************************************************/ /**************************************************************/
{ {
int LineNum = 0; int LineNum = 0;
char* cp, Ref[256], FootPrint[256], Line[1024]; char* cp, Ref[256], FootPrint[256], Line[1024];
SCH_ITEM* DrawList = NULL;
SCH_COMPONENT* Cmp; SCH_COMPONENT* Cmp;
PartTextStruct* TextField; PartTextStruct* TextField;
@ -39,24 +65,20 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* StuffFile )
if( *cp == '"' ) if( *cp == '"' )
*cp = 0; *cp = 0;
// printf("'%s' '%s'\n", Ref, FootPrint);
wxString reference = CONV_FROM_UTF8( Ref ); wxString reference = CONV_FROM_UTF8( Ref );
DrawList = WinEDA_SchematicFrame::FindComponentAndItem( Cmp = WinEDA_SchematicFrame::FindComponentByRef( reference );
reference, TRUE, 2, wxEmptyString, false ); if( Cmp == NULL )
if( DrawList == NULL )
continue; continue;
if( DrawList->Type() == TYPE_SCH_COMPONENT ) #if defined(DEBUG)
{ printf( " %s %s\n", CONV_TO_UTF8(Cmp->m_Field[REFERENCE].m_Text),
Cmp = (SCH_COMPONENT*) DrawList; CONV_TO_UTF8(Cmp->m_Field[VALUE].m_Text) );
#endif
TextField = &Cmp->m_Field[FOOTPRINT]; TextField = &Cmp->m_Field[FOOTPRINT];
TextField->m_Text = CONV_FROM_UTF8( FootPrint ); TextField->m_Text = CONV_FROM_UTF8( FootPrint );
} }
} }
}
return true; return true;
} }

View File

@ -89,6 +89,8 @@ public:
bool bool
IncludePin ); IncludePin );
SCH_COMPONENT* FindComponentByRef( const wxString& reference );
SCH_ITEM* FindComponentAndItem( const wxString& component_reference, SCH_ITEM* FindComponentAndItem( const wxString& component_reference,
bool Find_in_hierarchy, bool Find_in_hierarchy,
int SearchType, int SearchType,