Eeschema: implement loading of global symbol table.

Add global symbol library storage and access to SYMBOL_LIB_TABLE object.

Add code to Eeschema to load global symbol table on start up.
This commit is contained in:
Wayne Stambaugh 2016-11-24 12:57:53 -05:00
parent 5476e97bfa
commit 88df496168
3 changed files with 39 additions and 1 deletions

View File

@ -32,6 +32,7 @@
#include <pgm_base.h>
#include <kiface_i.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <eda_dde.h>
#include <schframe.h>
@ -44,6 +45,7 @@
#include <hotkeys.h>
#include <transform.h>
#include <wildcards_and_files_ext.h>
#include <symbol_lib_table.h>
#include <kiway.h>
#include <sim/sim_plot_frame.h>
@ -239,6 +241,34 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
wxConfigLoadSetups( KifaceSettings(), cfg_params() );
try
{
// The global table is not related to a specific project. All projects
// will use the same global table. So the KIFACE::OnKifaceStart() contract
// of avoiding anything project specific is not violated here.
if( !SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE::GetGlobalLibTable() ) )
{
DisplayInfoMessage( NULL, _(
"You have run Eeschema for the first time using the new symbol library table "
"method for finding symbols.\n\n"
"Eeschema has either copied the default table or created an empty table in the "
"kicad configuration folder.\n\n"
"You must first configure the library table to include all symbol libraries you "
"want to use.\n\n"
"See the \"Symbol Library Table\" section of Eeschema documentation for more "
"information." ) );
}
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"An error occurred attempting to load the global symbol library table:\n\n%s" ),
GetChars( ioe.What() )
);
DisplayError( NULL, msg );
return false;
}
return true;
}

View File

@ -40,6 +40,9 @@ using namespace LIB_TABLE_T;
static const wxChar global_tbl_name[] = wxT( "sym-lib-table" );
SYMBOL_LIB_TABLE SYMBOL_LIB_TABLE::m_globalLibTable; // There can be only one.
bool SYMBOL_LIB_TABLE_ROW::operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const
{
return LIB_TABLE_ROW::operator == ( aRow ) && type == aRow.type;
@ -386,7 +389,7 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable )
// template folder to the user's home configuration path.
wxString fileName = Kiface().KifaceSearch().FindValidPath( global_tbl_name );
// The fallback is to create an empty global footprint table for the user to populate.
// The fallback is to create an empty global symbol table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
SYMBOL_LIB_TABLE emptyTable;

View File

@ -289,6 +289,11 @@ public:
* set already in the environment.
*/
static const wxString GlobalPathEnvVariableName();
static SYMBOL_LIB_TABLE& GetGlobalLibTable() { return m_globalLibTable; }
private:
static SYMBOL_LIB_TABLE m_globalLibTable; // There can be only one.
};