kicad/eeschema/libarch.cpp

63 lines
1.8 KiB
C++
Raw Normal View History

/*****************************************************/
/* libarch.cpp */
/* Module for generation of component archive files. */
/*****************************************************/
2007-05-06 16:03:28 +00:00
#include "fctsys.h"
#include "common.h"
#include "confirm.h"
2007-05-06 16:03:28 +00:00
#include "program.h"
#include "general.h"
#include "netlist.h"
#include "protos.h"
#include "class_library.h"
2007-05-06 16:03:28 +00:00
2007-05-06 16:03:28 +00:00
/*
* Creates a library that contains all components used in the schematic.
*
* return true if success
*/
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
2007-05-06 16:03:28 +00:00
{
wxString msg;
LIB_COMPONENT* Entry;
CMP_LIBRARY* libCache;
EDA_ScreenList ScreenList;
libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, ArchFullFileName );
libCache->SetCache();
/* examine all screens (not sheets) used and build the list of components
* found in lib complex hierarchies are not a problem because we just want
* to know used components in libraries
*/
for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )
{
for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem;
SchItem = SchItem->Next() )
{
if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue;
SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry ) // if NULL : component not found
libCache->AddComponent( Entry );
2008-09-18 17:10:54 +00:00
}
}
if( !libCache->Save( ArchFullFileName ) )
{
msg.Printf( _( "An error occurred attempting to save component \
library <%s>." ), GetChars( ArchFullFileName ) );
DisplayError( frame, msg );
return false;
}
return true;
}