2007-11-02 17:17:44 +00:00
|
|
|
/*****************************************************************/
|
2009-08-19 19:34:03 +00:00
|
|
|
/* Functions to handle component library files : read functions */
|
2007-11-02 17:17:44 +00:00
|
|
|
/*****************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "macros.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "general.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-04 18:35:14 +00:00
|
|
|
#include "html_messagebox.h"
|
2009-07-13 06:20:18 +00:00
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/**
|
|
|
|
* Function LoadLibraries
|
|
|
|
*
|
2009-09-18 14:56:05 +00:00
|
|
|
* Clear all already loaded libraries and load all of the project libraries.
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::LoadLibraries( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
size_t ii;
|
2009-08-19 19:34:03 +00:00
|
|
|
wxFileName fn;
|
2009-09-18 14:56:05 +00:00
|
|
|
wxString msg, tmp, errMsg;
|
2009-08-19 19:34:03 +00:00
|
|
|
wxString libraries_not_found;
|
2009-10-05 19:17:32 +00:00
|
|
|
wxArrayString sortOrder;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
CMP_LIBRARY_LIST::iterator i = CMP_LIBRARY::GetLibraryList().begin();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/* Free the unwanted libraries but keep the cache library. */
|
|
|
|
while ( i < CMP_LIBRARY::GetLibraryList().end() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
if( i->IsCache() )
|
|
|
|
{
|
|
|
|
i++;
|
2007-08-24 15:10:46 +00:00
|
|
|
continue;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
if( m_ComponentLibFiles.Index( i->GetName(), false ) == wxNOT_FOUND )
|
|
|
|
i = CMP_LIBRARY::GetLibraryList().erase( i );
|
|
|
|
else
|
|
|
|
i++;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/* Load missing libraries. */
|
|
|
|
for( ii = 0; ii < m_ComponentLibFiles.GetCount(); ii++ )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
fn = m_ComponentLibFiles[ii];
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( CompLibFileExtension );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/* Skip if the file name is not valid.. */
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !fn.IsOk() )
|
2007-08-24 15:10:46 +00:00
|
|
|
continue;
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
tmp = wxGetApp().FindLibraryPath( fn );
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !tmp )
|
|
|
|
{
|
2009-08-19 19:34:03 +00:00
|
|
|
libraries_not_found += fn.GetName() + _( "\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp = fn.GetFullPath();
|
|
|
|
}
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2008-10-05 10:56:43 +00:00
|
|
|
// Loaded library statusbar message
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = _( "Library " ) + tmp;
|
2009-09-18 14:56:05 +00:00
|
|
|
fn = tmp;
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
if( CMP_LIBRARY::AddLibrary( fn, errMsg ) )
|
|
|
|
{
|
2008-10-05 10:56:43 +00:00
|
|
|
msg += _( " loaded" );
|
2009-10-05 19:17:32 +00:00
|
|
|
sortOrder.Add( fn.GetName() );
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
else
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
|
|
|
wxString prompt;
|
|
|
|
|
2010-11-01 18:33:44 +00:00
|
|
|
prompt.Printf( _( "Component library <%s> failed to load.\nError: %s" ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( fn.GetFullPath() ),
|
|
|
|
GetChars( errMsg ) );
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayError( this, prompt );
|
2008-10-05 10:56:43 +00:00
|
|
|
msg += _( " error!" );
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
2007-11-02 17:17:44 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
PrintMsg( msg );
|
2009-04-10 14:57:10 +00:00
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/* Print the libraries not found */
|
|
|
|
if( !libraries_not_found.IsEmpty() )
|
|
|
|
{
|
2011-09-04 18:35:14 +00:00
|
|
|
HTML_MESSAGE_BOX dialog( this, _("Files not found") );
|
2009-08-19 19:34:03 +00:00
|
|
|
dialog.MessageSet( _( "The following libraries could not be found:" ) );
|
|
|
|
dialog.ListSet( libraries_not_found );
|
|
|
|
libraries_not_found.empty();
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
2009-07-05 16:59:12 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/* Put the libraries in the correct order. */
|
2009-10-05 19:17:32 +00:00
|
|
|
CMP_LIBRARY::SetSortOrder( sortOrder );
|
2009-09-18 14:56:05 +00:00
|
|
|
CMP_LIBRARY::GetLibraryList().sort();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-11-07 20:06:07 +00:00
|
|
|
#if 0 // #ifdef __WXDEBUG__
|
|
|
|
wxLogDebug( wxT( "LoadLibraries() requested component library sort order:" ) );
|
2009-10-05 19:17:32 +00:00
|
|
|
|
|
|
|
for( size_t i = 0; i < sortOrder.GetCount(); i++ )
|
|
|
|
wxLogDebug( wxT( " " ) + sortOrder[i] );
|
|
|
|
|
2010-02-15 14:24:52 +00:00
|
|
|
wxLogDebug( wxT( "Real component library sort order:" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
for ( i = CMP_LIBRARY::GetLibraryList().begin();
|
|
|
|
i < CMP_LIBRARY::GetLibraryList().end(); i++ )
|
2009-10-05 19:17:32 +00:00
|
|
|
wxLogDebug( wxT( " " ) + i->GetName() );
|
2010-02-15 14:24:52 +00:00
|
|
|
wxLogDebug( wxT( "end LoadLibraries ()" ) );
|
2009-09-18 14:56:05 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|