2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file cvpcb/loadcmp.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#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>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbstruct.h>
|
|
|
|
#include <class_module.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <cvpcb.h>
|
|
|
|
#include <cvpcb_mainframe.h>
|
|
|
|
#include <class_DisplayFootprintsFrame.h>
|
2012-04-17 02:58:03 +00:00
|
|
|
#include <io_mgr.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2012-09-12 11:11:30 +00:00
|
|
|
/* Read libraries to find a module.
|
2011-02-22 20:59:16 +00:00
|
|
|
* If this module is found, copy it into memory
|
2009-04-05 20:49:15 +00:00
|
|
|
*
|
2012-09-12 11:11:30 +00:00
|
|
|
* aFootprintName is the module name
|
|
|
|
* return - a pointer to the loaded module or NULL.
|
2009-11-05 19:26:52 +00:00
|
|
|
*/
|
2012-04-17 02:58:03 +00:00
|
|
|
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
try
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
2012-04-17 02:58:03 +00:00
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
2012-04-17 02:58:03 +00:00
|
|
|
wxFileName fn = parent->m_ModuleLibNames[i];
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
fn.SetExt( LegacyFootprintLibPathExtension );
|
2011-01-14 17:43:30 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
wxString libPath = wxGetApp().FindLibraryPath( fn );
|
2011-01-14 17:43:30 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
if( !libPath )
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
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() );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
// @todo we should not be using wxMessageBox directly.
|
|
|
|
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
|
2009-01-05 05:21:35 +00:00
|
|
|
continue;
|
2012-04-17 02:58:03 +00:00
|
|
|
}
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
if( footprint )
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
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;
|
2009-01-05 05:21:35 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-17 02:58:03 +00:00
|
|
|
}
|
|
|
|
catch( IO_ERROR ioe )
|
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return NULL;
|
2009-01-05 05:21:35 +00:00
|
|
|
}
|
|
|
|
|
2012-04-17 02:58:03 +00:00
|
|
|
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
|
2009-01-05 05:21:35 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-17 02:58:03 +00:00
|
|
|
|