kicad/cvpcb/loadcmp.cpp

78 lines
2.0 KiB
C++
Raw Normal View History

/**
* @file cvpcb/loadcmp.cpp
*/
#include <fctsys.h>
#include <wxstruct.h>
#include <gr_basic.h>
#include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <macros.h>
#include <appl_wxstruct.h>
#include <pcbstruct.h>
#include <class_module.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
2012-04-17 02:58:03 +00:00
#include <io_mgr.h>
#include <wildcards_and_files_ext.h>
/* Read libraries to find a module.
* If this module is found, copy it into memory
*
* aFootprintName is the module name
* return - a pointer to the loaded module or NULL.
*/
2012-04-17 02:58:03 +00:00
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
2012-04-17 02:58:03 +00:00
try
{
2012-04-17 02:58:03 +00:00
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
2012-04-17 02:58:03 +00:00
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
{
2012-04-17 02:58:03 +00:00
wxFileName fn = parent->m_ModuleLibNames[i];
2012-04-17 02:58:03 +00:00
fn.SetExt( FootprintLibFileExtension );
2012-04-17 02:58:03 +00:00
wxString libPath = wxGetApp().FindLibraryPath( fn );
2012-04-17 02:58:03 +00:00
if( !libPath )
{
2012-04-17 02:58:03 +00:00
wxString msg = wxString::Format(
_("PCB foot print library file <%s> could not be found in the default search paths." ),
fn.GetFullName().GetData() );
2012-04-17 02:58:03 +00:00
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
continue;
2012-04-17 02:58:03 +00:00
}
2012-04-17 02:58:03 +00:00
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
2012-04-17 02:58:03 +00:00
if( footprint )
{
2012-05-01 10:43:16 +00:00
footprint->SetParent( GetBoard() );
2012-04-17 02:58:03 +00:00
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
}
2012-04-17 02:58:03 +00:00
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
2012-04-17 02:58:03 +00:00
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
2012-04-17 02:58:03 +00:00