Commit afd6f292 authored by Dick Hollenbeck's avatar Dick Hollenbeck

*) Switch over to FP_LIB_TABLE::Footprint*() functions.

*) Set environment variable KISYSMOD before loading FP_LIB_TABLE so that
   FP_LIB_TABLE::ROW::SetFullURI() can do substitution up front.
*) De-emphasize the lib path in some of the footprint frames but keep it
   so the footprint editor can export a current library to another.
   You can even export a GITHUB library to a pretty library for local 
   installation.
*) Start the PLUGIN options editor.
*) Enhance cursor positioning in DIALOG_FP_LIB_TABLE.
parent 7f648995
...@@ -49,16 +49,10 @@ option( KICAD_SCRIPTING_WXPYTHON ...@@ -49,16 +49,10 @@ option( KICAD_SCRIPTING_WXPYTHON
option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" ) option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" )
# BUILD_GITHUB_PLUGIN for MINGW is pretty demanding due to download_openssl.cmake and openssl's
# use of perl to drive its configure step. You might find it works in a cross builder say on linux.
# Dick is not personally supporting Windows any more with this exotic stuff. Some other windows
# developer will have to smooth out the build issues. So enable this for MINGW without my help but
# with my best wishes.
option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF ) option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
#Set version option (stable or testing) # Set version option (stable or testing)
if( KICAD_STABLE_VERSION) if( KICAD_STABLE_VERSION)
add_definitions( -DKICAD_STABLE_VERSION ) add_definitions( -DKICAD_STABLE_VERSION )
message( STATUS "Building stable version of KiCad" ) message( STATUS "Building stable version of KiCad" )
......
...@@ -56,4 +56,4 @@ ExternalProject_Add( avhttp ...@@ -56,4 +56,4 @@ ExternalProject_Add( avhttp
set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" ) set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" )
mark_as_advanced( AVHTTP_INCLUDE_DIR )
...@@ -42,6 +42,8 @@ if( BUILD_GITHUB_PLUGIN ) ...@@ -42,6 +42,8 @@ if( BUILD_GITHUB_PLUGIN )
# Chosen libraries are based on AVHTTP requirements, and possibly # Chosen libraries are based on AVHTTP requirements, and possibly
# unit_test_framework for its own worth. # unit_test_framework for its own worth.
set( BOOST_LIBS_BUILT set( BOOST_LIBS_BUILT
context
#coroutine
date_time date_time
#exception #exception
filesystem filesystem
...@@ -172,14 +174,17 @@ if( BUILD_GITHUB_PLUGIN ) ...@@ -172,14 +174,17 @@ if( BUILD_GITHUB_PLUGIN )
set( boost_libs "" ) set( boost_libs "" )
set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs ) set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs )
#message( STATUS "BOOST_ROOT:${BOOST_ROOT} boost_libs:${boost_libs}" )
set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" ) set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" )
set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" ) set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" )
mark_as_advanced( Boost_LIBRARIES Boost_INCLUDE_DIR )
#message( STATUS "BOOST_ROOT:${BOOST_ROOT} BOOST_LIBRARIES:${BOOST_LIBRARIES}" )
#message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" ) #message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" )
else( BUILD_GITHUB_PLUGIN ) else( BUILD_GITHUB_PLUGIN )
ExternalProject_Add( boost ExternalProject_Add( boost
PREFIX "${PREFIX}" PREFIX "${PREFIX}"
DOWNLOAD_DIR "${DOWNLOAD_DIR}" DOWNLOAD_DIR "${DOWNLOAD_DIR}"
......
...@@ -151,11 +151,5 @@ Dick's Final TODO List: ...@@ -151,11 +151,5 @@ Dick's Final TODO List:
*) Get licensing cleaned up. *) Get licensing cleaned up.
*) Re-arrange the repo architecture. *) Re-arrange the repo architecture.
*) Merge KiCad GAL/TOM/ORSON if nobody else does. *) Merge KiCad GAL/TOM/ORSON if nobody else does.
*) lib_convert.py (i.e. convert) all footprint libraries to pretty format and move copy them to *) DLL-ization of pcbnew & eeschema
github if nobody else does. http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
*) DLL-ization of pcbnew eeschema
*) Pass options, i.e. PROPERTIES to all PLUGIN::Footprint*() calls. Current code needs
to be based on NickNames, not Libpaths, so we have access to the FP_LIB_TABLE::ROWs.
User should not be prompted for a libpath for reading from it, he/she must pick from the
known list of nicknames. Possibly duplicate some of the PLUGIN:::Footprint*() api in ROW or
FP_LIB_TABLE. Again, limited to PLUGIN::Footprint*() calls, not Load() and Save().
...@@ -43,8 +43,9 @@ ...@@ -43,8 +43,9 @@
#include <class_module.h> #include <class_module.h>
#if !defined( USE_FP_LIB_TABLE )
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintLibNames )
{ {
bool retv = true; bool retv = true;
...@@ -58,10 +59,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -58,10 +59,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
// Parse Libraries Listed // Parse Libraries Listed
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) for( unsigned ii = 0; ii < aFootprintLibNames.GetCount(); ii++ )
{ {
// Footprint library file names can be fully qualified or file name only. // Footprint library file names can be fully qualified or file name only.
wxFileName filename = aFootprintsLibNames[ii]; wxFileName filename = aFootprintLibNames[ii];
if( !filename.FileExists() ) if( !filename.FileExists() )
{ {
...@@ -69,19 +70,19 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -69,19 +70,19 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
if( !filename.FileExists() ) if( !filename.FileExists() )
{ {
filename = wxFileName( wxEmptyString, aFootprintsLibNames[ii], filename = wxFileName( wxEmptyString, aFootprintLibNames[ii],
LegacyFootprintLibPathExtension ); LegacyFootprintLibPathExtension );
filename = wxGetApp().FindLibraryPath( filename.GetFullName() ); filename = wxGetApp().FindLibraryPath( filename.GetFullName() );
} }
} }
wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ), wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintLibNames[ii] ),
GetChars( filename.GetFullPath() ) ); GetChars( filename.GetFullPath() ) );
if( !filename.IsOk() || !filename.FileExists() ) if( !filename.IsOk() || !filename.FileExists() )
{ {
m_filesNotFound << aFootprintsLibNames[ii] << wxT( "\n" ); m_filesNotFound << aFootprintLibNames[ii] << wxT( "\n" );
retv = false; retv = false;
continue; continue;
} }
...@@ -131,8 +132,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -131,8 +132,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
return retv; return retv;
} }
#else
bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname )
{ {
bool retv = true; bool retv = true;
...@@ -141,44 +143,35 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) ...@@ -141,44 +143,35 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
m_filesInvalid.Empty(); m_filesInvalid.Empty();
m_List.clear(); m_List.clear();
std::vector< wxString > libNickNames = aTable.GetLogicalLibs(); std::vector< wxString > nicknames;
if( !aNickname )
// do all of them
nicknames = aTable->GetLogicalLibs();
else
nicknames.push_back( *aNickname );
// Parse Libraries Listed for( unsigned ii = 0; ii < nicknames.size(); ii++ )
for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
{ {
const FP_LIB_TABLE::ROW* row = aTable.FindRow( libNickNames[ii] ); const wxString& nickname = nicknames[ii];
wxCHECK2_MSG( row != NULL, retv = false; continue,
wxString::Format( wxT( "No library name <%s> found in footprint library "
"table." ), GetChars( libNickNames[ii] ) ) );
try try
{ {
PLUGIN* plugin = IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ); wxArrayString fpnames = aTable->FootprintEnumerate( nickname );
if( plugin == NULL )
{
m_filesNotFound << wxString::Format( _( "Cannot find plugin type '%s'." ),
GetChars( row->GetType() ) );
retv = false;
continue;
}
PLUGIN::RELEASER pi( plugin );
wxString path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() );
wxArrayString fpnames = pi->FootprintEnumerate( path );
for( unsigned i=0; i<fpnames.GetCount(); ++i ) for( unsigned i=0; i<fpnames.GetCount(); ++i )
{ {
std::auto_ptr<MODULE> m( pi->FootprintLoad( path, fpnames[i] ) ); std::auto_ptr<MODULE> m( aTable->FootprintLoad( nickname, fpnames[i] ) );
// we're loading what we enumerated, all must be there. // we're loading what we enumerated, all must be there.
wxASSERT( m.get() ); wxASSERT( m.get() );
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->SetLibraryName( libNickNames[ii] ); fpinfo->SetLibraryName( nickname );
fpinfo->SetLibraryPath( path );
//fpinfo->SetLibraryPath( path );
fpinfo->m_Module = fpnames[i]; fpinfo->m_Module = fpnames[i];
fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH );
fpinfo->m_KeyWord = m->GetKeywords(); fpinfo->m_KeyWord = m->GetKeywords();
...@@ -199,8 +192,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) ...@@ -199,8 +192,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
return retv; return retv;
} }
#endif // USE_FP_LIB_TABLE
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString & aFootprintName ) FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
{ {
BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List ) BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List )
{ {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <fpid.h> #include <fpid.h>
#include <fp_lib_table_lexer.h> #include <fp_lib_table_lexer.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <class_module.h>
using namespace FP_LIB_TABLE_T; using namespace FP_LIB_TABLE_T;
...@@ -97,7 +98,23 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& ...@@ -97,7 +98,23 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString&
{ {
const ROW* row = FindRow( aNickname ); const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin ); wxASSERT( (PLUGIN*) row->plugin );
return row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName, row->GetProperties() );
MODULE* ret = row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName, row->GetProperties() );
// The library cannot know its own name, because it might have been renamed or moved.
// Therefore footprints cannot know their own library nickname when residing in
// a footprint library.
// Only at this API layer can we tell the footprint about its actual library nickname.
if( ret )
{
// remove "const"-ness, I really do want to set nickname without
// having to copy the FPID and its two strings, twice each.
FPID& fpid = (FPID&) ret->GetFPID();
fpid.SetLibNickname( row->GetNickName() );
}
return ret;
} }
...@@ -296,58 +313,60 @@ void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR ) ...@@ -296,58 +313,60 @@ void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR )
PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList ) PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList )
{ {
const char* cp = &aOptionsList[0]; if( aOptionsList.size() )
const char* end = cp + aOptionsList.size();
PROPERTIES props;
std::string pair;
// Parse all name=value pairs
while( cp < end )
{ {
pair.clear(); const char* cp = &aOptionsList[0];
const char* end = cp + aOptionsList.size();
// Skip leading white space. PROPERTIES props;
while( cp < end && isspace( *cp ) ) std::string pair;
++cp;
// Find the end of pair/field // Parse all name=value pairs
while( cp < end ) while( cp < end )
{ {
if( *cp=='\\' && cp+1<end && cp[1]==OPT_SEP ) pair.clear();
{
++cp; // skip the escape // Skip leading white space.
pair += *cp++; // add the separator while( cp < end && isspace( *cp ) )
} ++cp;
else if( *cp==OPT_SEP )
// Find the end of pair/field
while( cp < end )
{ {
++cp; // skip the separator if( *cp=='\\' && cp+1<end && cp[1]==OPT_SEP )
break; // process the pair {
++cp; // skip the escape
pair += *cp++; // add the separator
}
else if( *cp==OPT_SEP )
{
++cp; // skip the separator
break; // process the pair
}
else
pair += *cp++;
} }
else
pair += *cp++;
}
// stash the pair // stash the pair
if( pair.size() ) if( pair.size() )
{
// first equals sign separates 'name' and 'value'.
size_t eqNdx = pair.find( '=' );
if( eqNdx != pair.npos )
{ {
std::string name = pair.substr( 0, eqNdx ); // first equals sign separates 'name' and 'value'.
std::string value = pair.substr( eqNdx + 1 ); size_t eqNdx = pair.find( '=' );
props[name] = value; if( eqNdx != pair.npos )
{
std::string name = pair.substr( 0, eqNdx );
std::string value = pair.substr( eqNdx + 1 );
props[name] = value;
}
else
props[pair] = ""; // property is present, but with no value.
} }
else
props[pair] = ""; // property is present, but with no value.
} }
}
if( props.size() ) if( props.size() )
return new PROPERTIES( props ); // the far less probable case return new PROPERTIES( props );
else }
return NULL; return NULL;
} }
...@@ -487,23 +506,20 @@ bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace ) ...@@ -487,23 +506,20 @@ bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace )
} }
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aLibraryNickName ) const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname )
throw( IO_ERROR ) throw( IO_ERROR )
{ {
ROW* row = findRow( aLibraryNickName ); ROW* row = findRow( aNickname );
if( !row ) if( !row )
{ {
wxString msg = wxString::Format( _( "lib table contains no logical lib '%s'" ), wxString msg = wxString::Format( _( "lib table contains no logical lib '%s'" ),
GetChars( aLibraryNickName ) ); GetChars( aNickname ) );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
#if 0 // enable this as soon as FP_LIB_TABLE::FindRow() is not being used outside
// this class, and FP_LIB_TABLE::Footprint*() functions are put into use.
if( !row->plugin ) if( !row->plugin )
row->setPlugin( IO_MGR::PluginFind( row->type ) ); row->setPlugin( IO_MGR::PluginFind( row->type ) );
#endif
return row; return row;
} }
......
...@@ -25,6 +25,8 @@ set( CVPCB_DIALOGS ...@@ -25,6 +25,8 @@ set( CVPCB_DIALOGS
dialogs/dialog_display_options_base.cpp dialogs/dialog_display_options_base.cpp
../pcbnew/dialogs/dialog_fp_lib_table.cpp ../pcbnew/dialogs/dialog_fp_lib_table.cpp
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp ../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
../pcbnew/dialogs/dialog_fp_plugin_options.cpp
../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp
) )
set( CVPCB_SRCS set( CVPCB_SRCS
......
...@@ -490,42 +490,13 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) ...@@ -490,42 +490,13 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
return NULL; return NULL;
} }
wxString libName = FROM_UTF8( fpid.GetLibNickname().c_str() ); std::string nickname = fpid.GetLibNickname();
std::string fpname = fpid.GetFootprintName();
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ), wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
fpid.GetFootprintName().c_str(), fpid.GetLibNickname().c_str() ); fpname.c_str(), nickname.c_str() );
const FP_LIB_TABLE::ROW* row; footprint = m_footprintLibTable->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
try
{
row = m_footprintLibTable->FindRow( libName );
if( row == NULL )
{
wxString msg;
msg.Printf( _( "No library named <%s> was found in the footprint library table." ),
fpid.GetLibNickname().c_str() );
DisplayInfoMessage( this, msg );
return NULL;
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() );
wxString libPath = row->GetFullURI();
libPath = FP_LIB_TABLE::ExpandSubstitutions( libPath );
wxLogDebug( wxT( "Loading footprint <%s> from library <%s>." ),
GetChars( footprintName ), GetChars( libPath ) );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
footprint = pi->FootprintLoad( libPath, footprintName );
#else #else
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent(); CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <cvpcb.h> #include <cvpcb.h>
#include <cvstruct.h> #include <cvstruct.h>
#include <invoke_pcb_dialog.h>
#include <dialog_cvpcb_config.h> #include <dialog_cvpcb_config.h>
#include <class_DisplayFootprintsFrame.h> #include <class_DisplayFootprintsFrame.h>
#include <cvpcb_id.h> #include <cvpcb_id.h>
...@@ -57,16 +58,6 @@ static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) ); ...@@ -57,16 +58,6 @@ static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) );
static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) ); static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
/**
* Function InvokePcbLibTableEditor
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
*
* @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal
* and/or the @a aProject table, respectively. If set, table was modified.
*/
int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject );
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList ) EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
...@@ -750,7 +741,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() ...@@ -750,7 +741,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
m_footprints.ReadFootprintFiles( m_ModuleLibNames ); m_footprints.ReadFootprintFiles( m_ModuleLibNames );
#else #else
if( m_footprintLibTable != NULL ) if( m_footprintLibTable != NULL )
m_footprints.ReadFootprintFiles( *m_footprintLibTable ); m_footprints.ReadFootprintFiles( m_footprintLibTable );
#endif #endif
// Display error messages, if any. // Display error messages, if any.
......
...@@ -126,28 +126,22 @@ public: ...@@ -126,28 +126,22 @@ public:
/** /**
* Function ReadFootprintFiles * Function ReadFootprintFiles
* Read the list of libraries (*.mod files) and populates m_List ( list of available
* modules in libs ).
* for each module, are stored
* the module name
* documentation string
* associated keywords
* library name
* Module description format:
* $MODULE c64acmd First line of module description
* Li c64acmd DIN connector Library reference
* Cd Europe 96 AC male vertical documentation string
* Kw PAD_CONN DIN associated keywords
* ...... other data (pads, outlines ..)
* $Endmodule
* *
* @param aFootprintsLibNames = an array string giving the list of libraries to load * @param aFootprintsLibNames = an array string giving the list of libraries to load
*/ */
bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames ); bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames );
bool ReadFootprintFiles( FP_LIB_TABLE& aTable ); /**
* Function ReadFootprintFiles
* reads all the footprints provided by the combination of aTable and aNickname.
* @param aTable defines all the libraries.
* @param aNickname is the library to read from, or if NULL means read all
* footprints from all known libraries.
*/
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL );
}; };
/// FOOTPRINT object list sort function. /// FOOTPRINT object list sort function.
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ) inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
{ {
......
...@@ -149,7 +149,7 @@ public: ...@@ -149,7 +149,7 @@ public:
properties = r.properties ? new PROPERTIES( *r.properties ) : NULL; properties = r.properties ? new PROPERTIES( *r.properties ) : NULL;
// do not copy the PLUGIN, it is lazily created. // do not copy the PLUGIN, it is lazily created.
// setPlugin( NULL ); setPlugin( NULL );
return *this; return *this;
} }
......
...@@ -32,12 +32,16 @@ ...@@ -32,12 +32,16 @@
// So boost seems best for all platforms. // So boost seems best for all platforms.
#if 0 // C++ #if 0 // C++ std::unordered_map, maybe in the future
#include <unordered_map> #include <unordered_map>
/// Map a C string to a wxString, used in PLUGINs. /// Map a C string to a wxString, used in PLUGINs.
typedef std::unordered_map< std::string, std::string > PROPERTIES; /// was typedef std::unordered_map< std::string, std::string > PROPERTIES;
class PROPERTIES : public std::unordered_map< std::string, std::string >
{
};
/// Map a C string to an integer. Used in DSNLEXER. /// Map a C string to an integer. Used in DSNLEXER.
typedef std::unordered_map< std::string, int > KEYWORD_MAP; typedef std::unordered_map< std::string, int > KEYWORD_MAP;
...@@ -57,7 +61,10 @@ typedef std::unordered_map< std::string, EDA_RECT > RECT_MAP; ...@@ -57,7 +61,10 @@ typedef std::unordered_map< std::string, EDA_RECT > RECT_MAP;
// see http://www.boost.org/doc/libs/1_49_0/doc/html/boost/unordered_map.html // see http://www.boost.org/doc/libs/1_49_0/doc/html/boost/unordered_map.html
/// Map a std::string to a wxString, used in PLUGINs. /// Map a std::string to a wxString, used in PLUGINs.
typedef boost::unordered_map< std::string, std::string > PROPERTIES; /// was typedef boost::unordered_map< std::string, std::string > PROPERTIES;
class PROPERTIES : public boost::unordered_map< std::string, std::string >
{
};
/// Equality test for "const char*" type used in very specialized KEYWORD_MAP below /// Equality test for "const char*" type used in very specialized KEYWORD_MAP below
......
...@@ -453,21 +453,25 @@ public: ...@@ -453,21 +453,25 @@ public:
/** /**
* Function SelectFootprint * Function SelectFootprint
* Display a list of modules found in active libraries or a given library * displays a list of modules found in all libraries or a given library
*
* @param aWindow = the current window ( parent window ) * @param aWindow = the current window ( parent window )
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename *
* == void, list all modules) * @param aLibraryName = library to list (if aLibraryFullFilename is empty, then list all modules).
* @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not * This is a nickname for the FP_LIB_TABLE build.
* used ) *
* @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used )
*
* @param aKeyWord = keyword list, to display a filtered list of module * @param aKeyWord = keyword list, to display a filtered list of module
* having one (or more) of these keywords in their * having one (or more) of these keywords in their
* keyword list ( aKeyWord = wxEmptyString if not used ) * keyword list ( aKeyWord = wxEmptyString if not used )
*
* @param aTable is the #FP_LIB_TABLE to search. * @param aTable is the #FP_LIB_TABLE to search.
* *
* @return wxEmptyString if abort or fails, or the selected module name if Ok * @return wxEmptyString if abort or fails, or the selected module name if Ok
*/ */
wxString SelectFootprint( EDA_DRAW_FRAME* aWindow, wxString SelectFootprint( EDA_DRAW_FRAME* aWindow,
const wxString& aLibraryFullFilename, const wxString& aLibraryName,
const wxString& aMask, const wxString& aMask,
const wxString& aKeyWord, const wxString& aKeyWord,
FP_LIB_TABLE* aTable ); FP_LIB_TABLE* aTable );
......
...@@ -1685,14 +1685,4 @@ public: ...@@ -1685,14 +1685,4 @@ public:
}; };
/**
* Function InvokePcbLibTableEditor
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
*
* @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal
* and/or the @a aProject table, respectively. If set, table was modified.
*/
int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject );
#endif // WXPCB_STRUCT_H_ #endif // WXPCB_STRUCT_H_
...@@ -58,6 +58,8 @@ set( PCBNEW_DIALOGS ...@@ -58,6 +58,8 @@ set( PCBNEW_DIALOGS
dialogs/dialog_find.cpp dialogs/dialog_find.cpp
dialogs/dialog_fp_lib_table_base.cpp dialogs/dialog_fp_lib_table_base.cpp
dialogs/dialog_fp_lib_table.cpp dialogs/dialog_fp_lib_table.cpp
dialogs/dialog_fp_plugin_options_base.cpp
dialogs/dialog_fp_plugin_options.cpp
dialogs/dialog_freeroute_exchange.cpp dialogs/dialog_freeroute_exchange.cpp
dialogs/dialog_freeroute_exchange_base.cpp dialogs/dialog_freeroute_exchange_base.cpp
dialogs/dialog_gendrill.cpp dialogs/dialog_gendrill.cpp
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -27,16 +26,11 @@ ...@@ -27,16 +26,11 @@
/* TODO: /* TODO:
*) Grab text from any pending ChoiceEditor when OK button pressed. *) Grab text from any pending ChoiceEditor when OK button pressed.
*) After any change to uri, reparse the environment variables.
*) Test wxRE_ADVANCED on Windows.
*/ */
#include <fctsys.h>
#include <dialog_fp_lib_table_base.h>
#include <fp_lib_table.h>
#include <fp_lib_table_lexer.h>
#include <wx/grid.h> #include <wx/grid.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
...@@ -44,6 +38,12 @@ ...@@ -44,6 +38,12 @@
#include <wx/regex.h> #include <wx/regex.h>
#include <set> #include <set>
#include <fctsys.h>
#include <dialog_fp_lib_table_base.h>
#include <fp_lib_table.h>
#include <fp_lib_table_lexer.h>
#include <invoke_pcb_dialog.h>
/// grid column order is established by this sequence /// grid column order is established by this sequence
enum COL_ORDER enum COL_ORDER
...@@ -411,6 +411,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -411,6 +411,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
} }
// go to the problematic row // go to the problematic row
m_cur_grid->SetGridCursor( r, 0 );
m_cur_grid->SelectBlock( r, 0, r, 0 ); m_cur_grid->SelectBlock( r, 0, r, 0 );
m_cur_grid->MakeCellVisible( r, 0 ); m_cur_grid->MakeCellVisible( r, 0 );
...@@ -455,6 +456,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -455,6 +456,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
} }
// go to the lower of the two rows, it is technically the duplicate: // go to the lower of the two rows, it is technically the duplicate:
m_cur_grid->SetGridCursor( r2, 0 );
m_cur_grid->SelectBlock( r2, 0, r2, 0 ); m_cur_grid->SelectBlock( r2, 0, r2, 0 );
m_cur_grid->MakeCellVisible( r2, 0 ); m_cur_grid->MakeCellVisible( r2, 0 );
...@@ -508,15 +510,20 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -508,15 +510,20 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
{ {
int last_row = m_cur_grid->GetNumberRows() - 1; int last_row = m_cur_grid->GetNumberRows() - 1;
m_cur_grid->SelectBlock( last_row, 0, last_row, 0 );
m_cur_grid->MakeCellVisible( last_row, 0 ); m_cur_grid->MakeCellVisible( last_row, 0 );
m_cur_grid->SetGridCursor( last_row, 0 );
} }
} }
void deleteRowHandler( wxMouseEvent& event ) void deleteRowHandler( wxMouseEvent& event )
{ {
int curRow = getCursorRow(); int rowCount = m_cur_grid->GetNumberRows();
int curRow = getCursorRow();
m_cur_grid->DeleteRows( curRow ); m_cur_grid->DeleteRows( curRow );
if( curRow && curRow == rowCount - 1 )
m_cur_grid->SetGridCursor( curRow-1, getCursorCol() );
} }
void moveUpHandler( wxMouseEvent& event ) void moveUpHandler( wxMouseEvent& event )
...@@ -582,8 +589,18 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -582,8 +589,18 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
void optionsEditor( wxMouseEvent& event ) void optionsEditor( wxMouseEvent& event )
{ {
// @todo: write the options editor, and pass the options to the Footprint*() calls. FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) m_cur_grid->GetTable();
//D(printf("%s:%d\n", __func__, (int) m_cur_grid->GetNumberRows() );)
int curRow = getCursorRow();
ROW& row = tbl->rows[curRow];
wxString result;
const wxString& options = row.GetOptions();
InvokePluginOptionsEditor( this, row.GetNickName(), options, &result );
if( options != result )
row.SetOptions( result );
} }
void onCancelButtonClick( wxCommandEvent& event ) void onCancelButtonClick( wxCommandEvent& event )
...@@ -591,6 +608,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -591,6 +608,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
EndModal( 0 ); EndModal( 0 );
} }
void onCancelButtonClick( wxCloseEvent& event )
{
EndModal( 0 );
}
void onOKButtonClick( wxCommandEvent& event ) void onOKButtonClick( wxCommandEvent& event )
{ {
int dialogRet = 0; int dialogRet = 0;
...@@ -617,6 +639,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -617,6 +639,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
} }
} }
void onGridCmdSelectCell( wxGridEvent& event )
{
event.Skip();
}
void onGridCellLeftClick( wxGridEvent& event ) void onGridCellLeftClick( wxGridEvent& event )
{ {
event.Skip(); event.Skip();
...@@ -710,7 +737,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -710,7 +737,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
wxGrid* m_cur_grid; ///< changed based on tab choice wxGrid* m_cur_grid; ///< changed based on tab choice
public: public:
DIALOG_FP_LIB_TABLE( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : DIALOG_FP_LIB_TABLE( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) :
DIALOG_FP_LIB_TABLE_BASE( aParent ), DIALOG_FP_LIB_TABLE_BASE( aParent ),
m_global( aGlobal ), m_global( aGlobal ),
m_project( aProject ), m_project( aProject ),
...@@ -900,7 +927,7 @@ void DIALOG_FP_LIB_TABLE::paste() ...@@ -900,7 +927,7 @@ void DIALOG_FP_LIB_TABLE::paste()
} }
int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) int InvokePcbLibTableEditor( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject )
{ {
DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject ); DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject );
......
...@@ -190,6 +190,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID ...@@ -190,6 +190,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ) );
this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) );
m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
m_global_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this ); m_global_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this );
...@@ -214,6 +215,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID ...@@ -214,6 +215,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE() DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ) );
this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) );
m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
m_global_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this ); m_global_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this );
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="event_handler">impl_virtual</property> <property name="event_handler">decl_pure_virtual</property>
<property name="extra_style"></property> <property name="extra_style"></property>
<property name="fg"></property> <property name="fg"></property>
<property name="font"></property> <property name="font"></property>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<property name="name">DIALOG_FP_LIB_TABLE_BASE</property> <property name="name">DIALOG_FP_LIB_TABLE_BASE</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">900,600</property> <property name="size">900,600</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</property> <property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">PCB Library Tables</property> <property name="title">PCB Library Tables</property>
<property name="tooltip"></property> <property name="tooltip"></property>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<event name="OnAuiPaneRestore"></event> <event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event> <event name="OnAuiRender"></event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnClose"></event> <event name="OnClose">onCancelButtonClick</event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnHibernate"></event> <event name="OnHibernate"></event>
...@@ -1105,11 +1105,11 @@ ...@@ -1105,11 +1105,11 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="0"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Path Substitutions</property> <property name="label">Path Substitutions</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
...@@ -1262,11 +1262,11 @@ ...@@ -1262,11 +1262,11 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_bottom_sizer</property> <property name="name">m_bottom_sizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
......
...@@ -57,24 +57,25 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM ...@@ -57,24 +57,25 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void onKeyDown( wxKeyEvent& event ) { event.Skip(); } virtual void onCancelButtonClick( wxCloseEvent& event ) = 0;
virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); } virtual void onKeyDown( wxKeyEvent& event ) = 0;
virtual void onGridCellLeftClick( wxGridEvent& event ) { event.Skip(); } virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0;
virtual void onGridCellLeftDClick( wxGridEvent& event ) { event.Skip(); } virtual void onGridCellLeftClick( wxGridEvent& event ) = 0;
virtual void onGridCellRightClick( wxGridEvent& event ) { event.Skip(); } virtual void onGridCellLeftDClick( wxGridEvent& event ) = 0;
virtual void onGridCmdSelectCell( wxGridEvent& event ) { event.Skip(); } virtual void onGridCellRightClick( wxGridEvent& event ) = 0;
virtual void appendRowHandler( wxMouseEvent& event ) { event.Skip(); } virtual void onGridCmdSelectCell( wxGridEvent& event ) = 0;
virtual void deleteRowHandler( wxMouseEvent& event ) { event.Skip(); } virtual void appendRowHandler( wxMouseEvent& event ) = 0;
virtual void moveUpHandler( wxMouseEvent& event ) { event.Skip(); } virtual void deleteRowHandler( wxMouseEvent& event ) = 0;
virtual void moveDownHandler( wxMouseEvent& event ) { event.Skip(); } virtual void moveUpHandler( wxMouseEvent& event ) = 0;
virtual void optionsEditor( wxMouseEvent& event ) { event.Skip(); } virtual void moveDownHandler( wxMouseEvent& event ) = 0;
virtual void onCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void optionsEditor( wxMouseEvent& event ) = 0;
virtual void onOKButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void onCancelButtonClick( wxCommandEvent& event ) = 0;
virtual void onOKButtonClick( wxCommandEvent& event ) = 0;
public: public:
DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 900,600 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 900,600 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
~DIALOG_FP_LIB_TABLE_BASE(); ~DIALOG_FP_LIB_TABLE_BASE();
}; };
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <invoke_pcb_dialog.h>
#include <dialog_fp_plugin_options_base.h>
#include <fp_lib_table.h>
class DIALOG_FP_PLUGIN_OPTIONS : public DIALOG_FP_PLUGIN_OPTIONS_BASE
{
public:
DIALOG_FP_PLUGIN_OPTIONS( wxTopLevelWindow* aParent,
const wxString& aNickname, const wxString& aOptions, wxString* aResult ) :
DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ),
m_callers_options( aOptions ),
m_options( aOptions ),
m_result( aResult )
{
wxString title = wxString::Format(
_( "Options for Library '%s'" ), GetChars( aNickname ) );
SetTitle( title );
}
private:
const wxString& m_callers_options;
wxString m_options;
wxString* m_result;
//-----<event handlers>------------------------------------------------------
void onAddRow( wxCommandEvent& event )
{
}
void onDeleteRow( wxCommandEvent& event )
{
}
void onMoveUp( wxCommandEvent& event )
{
}
void onMoveDown( wxCommandEvent& event )
{
}
void onCancelButtonClick( wxCommandEvent& event )
{
*m_result = m_callers_options; // no change
EndModal( 0 );
}
void onCancelButtonClick( wxCloseEvent& event )
{
*m_result = m_callers_options; // no change
EndModal( 0 );
}
void onOKButtonClick( wxCommandEvent& event )
{
*m_result = m_options; // change from edits
EndModal( 1 );
}
//-----</event handlers>-----------------------------------------------------
};
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller,
const wxString& aNickname, const wxString& aOptions, wxString* aResult )
{
DIALOG_FP_PLUGIN_OPTIONS dlg( aCaller, aNickname, aOptions, aResult );
dlg.ShowModal();
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_fp_plugin_options_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* m_horizontal_sizer;
m_horizontal_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options:") ), wxVERTICAL );
m_grid1 = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid1->CreateGrid( 5, 2 );
m_grid1->EnableEditing( true );
m_grid1->EnableGridLines( true );
m_grid1->EnableDragGridSize( false );
m_grid1->SetMargins( 0, 0 );
// Columns
m_grid1->EnableDragColMove( false );
m_grid1->EnableDragColSize( true );
m_grid1->SetColLabelSize( 30 );
m_grid1->SetColLabelValue( 0, _("Option") );
m_grid1->SetColLabelValue( 1, _("Value") );
m_grid1->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_grid1->EnableDragRowSize( false );
m_grid1->SetRowLabelSize( 80 );
m_grid1->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_grid1->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
sbSizer1->Add( m_grid1, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
m_add_row = new wxButton( this, wxID_ANY, _("Add Row"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_add_row, 0, wxALL, 5 );
m_delete_row = new wxButton( this, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_delete_row, 0, wxALL, 5 );
m_move_up = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_move_up, 0, wxALL, 5 );
m_move_down = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_move_down, 0, wxALL, 5 );
sbSizer1->Add( bSizer6, 0, wxALIGN_CENTER, 5 );
m_horizontal_sizer->Add( sbSizer1, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
m_button1 = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_button1, 0, wxALIGN_CENTER|wxALL, 5 );
m_horizontal_sizer->Add( bSizer3, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer3;
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxHORIZONTAL );
m_listCtrl1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL );
sbSizer3->Add( m_listCtrl1, 1, wxEXPAND, 5 );
m_horizontal_sizer->Add( sbSizer3, 1, wxEXPAND, 5 );
bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizer4->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizer4 );
this->Layout();
bSizer4->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) );
m_add_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this );
m_delete_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
m_move_down->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
}
DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) );
m_add_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this );
m_delete_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
m_move_down->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_FP_PLUGIN_OPTIONS_BASE_H__
#define __DIALOG_FP_PLUGIN_OPTIONS_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/listctrl.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_FP_PLUGIN_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM
{
private:
protected:
wxGrid* m_grid1;
wxButton* m_add_row;
wxButton* m_delete_row;
wxButton* m_move_up;
wxButton* m_move_down;
wxButton* m_button1;
wxListCtrl* m_listCtrl1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void onCancelButtonClick( wxCloseEvent& event ) = 0;
virtual void onAddRow( wxCommandEvent& event ) = 0;
virtual void onDeleteRow( wxCommandEvent& event ) = 0;
virtual void onMoveUp( wxCommandEvent& event ) = 0;
virtual void onMoveDown( wxCommandEvent& event ) = 0;
virtual void onCancelButtonClick( wxCommandEvent& event ) = 0;
virtual void onOKButtonClick( wxCommandEvent& event ) = 0;
public:
DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
~DIALOG_FP_PLUGIN_OPTIONS_BASE();
};
#endif //__DIALOG_FP_PLUGIN_OPTIONS_BASE_H__
...@@ -73,7 +73,3 @@ endif() ...@@ -73,7 +73,3 @@ endif()
add_dependencies( github_plugin boost ) add_dependencies( github_plugin boost )
add_dependencies( github_plugin avhttp ) add_dependencies( github_plugin avhttp )
#target_link_libraries( github_plugin ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES})
...@@ -41,31 +41,39 @@ ...@@ -41,31 +41,39 @@
#define INVOKE_A_DIALOG_H_ #define INVOKE_A_DIALOG_H_
class wxFrame; class wxTopLevelWindow;
class wxDialog;
class wxPoint; class wxPoint;
class wxSize; class wxSize;
class wxRealPoint; //class wxRealPoint;
class wxString;
// Often this is not used in the prototypes, since wxFrame is good enough and would // Often this is not used in the prototypes, since wxFrame is good enough and would
// represent maximum information hiding. // represent maximum information hiding.
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
class FP_LIB_TABLE;
/* template: junk it after some are added: /**
* Function InvokePcbLibTableEditor
/// Create and show DIALOG_ANNOTATE and return whatever * shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
/// DIALOG_ANNOTATE::ShowModal() returns. *
int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller ); * @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal
* and/or the @a aProject table, respectively. If set, table was modified.
*/
int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject );
/// Create the modeless DIALOG_ERC and show it, return something to /**
/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h * Function InvokePluginOptionsEditor
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ); * calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set can be edited.
*
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @param aNickname is the footprint library whose options are being edited.
* @param aOptionsIn is the options string on calling into this function.
* @param aResult is where to put the result of the editing.
*/
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller,
const wxString& aNickname, const wxString& aOptions, wxString* aResult );
/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever
/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns.
int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller );
*/
#endif // INVOKE_A_DIALOG_H_ #endif // INVOKE_A_DIALOG_H_
...@@ -655,7 +655,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, ...@@ -655,7 +655,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath,
if( aDisplayDialog ) if( aDisplayDialog )
{ {
wxString msg = wxString::Format( FMT_MOD_EXISTS, wxString msg = wxString::Format( FMT_MOD_EXISTS,
footprintName.GetData(), aLibPath.GetData() ); footprintName.GetData(), aLibPath.GetData() );
SetStatusText( msg ); SetStatusText( msg );
} }
...@@ -821,14 +821,12 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() ...@@ -821,14 +821,12 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library()
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;
setLibNickName( dlg.GetTextSelection() ); wxString nickname = dlg.GetTextSelection();
wxString uri = m_footprintLibTable->FindRow( dlg.GetTextSelection() )->GetFullURI();
wxString fileName = FP_LIB_TABLE::ExpandSubstitutions( uri );
wxLogDebug( wxT( "Loading footprint library <%s> with uri <%s> from <%s>." ), setLibNickName( nickname );
GetChars( dlg.GetTextSelection() ), GetChars( uri ), GetChars( fileName ) );
wxLogDebug( wxT( "Chose footprint library <%s>." ), GetChars( nickname ) );
setLibPath( fileName );
updateTitle(); updateTitle();
} }
......
...@@ -432,31 +432,15 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId ) ...@@ -432,31 +432,15 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
wxCHECK_MSG( m_footprintLibTable != NULL, NULL, wxCHECK_MSG( m_footprintLibTable != NULL, NULL,
wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) ); wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
wxString libName = FROM_UTF8( aFootprintId.GetLibNickname().c_str() ); wxString nickname = FROM_UTF8( aFootprintId.GetLibNickname().c_str() );
wxString fpname = FROM_UTF8( aFootprintId.GetFootprintName().c_str() );
const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( libName ); return m_footprintLibTable->FootprintLoad( nickname, fpname );
if( row == NULL )
{
wxString msg;
msg.Printf( _( "No library named <%s> was found in the footprint library table." ),
aFootprintId.GetLibNickname().c_str() );
THROW_IO_ERROR( msg );
}
wxString footprintName = FROM_UTF8( aFootprintId.GetFootprintName().c_str() );
wxString libPath = row->GetFullURI();
libPath = FP_LIB_TABLE::ExpandSubstitutions( libPath );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
return pi->FootprintLoad( libPath, footprintName, row->GetProperties() );
} }
wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
const wxString& aLibraryFullFilename, const wxString& aLibraryName,
const wxString& aMask, const wxString& aMask,
const wxString& aKeyWord, const wxString& aKeyWord,
FP_LIB_TABLE* aTable ) FP_LIB_TABLE* aTable )
...@@ -468,15 +452,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, ...@@ -468,15 +452,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
FP_LIB_TABLE libTable; FP_LIB_TABLE libTable;
std::vector< wxArrayString > rows; std::vector< wxArrayString > rows;
#if !defined( USE_FP_LIB_TABLE ) #if !defined( USE_FP_LIB_TABLE )
if( aLibraryFullFilename.IsEmpty() )
if( aLibraryName.IsEmpty() )
{ {
libraries = g_LibraryNames; libraries = g_LibraryNames;
} }
else else
{ {
libraries.Add( aLibraryFullFilename ); libraries.Add( aLibraryName );
} }
if( libraries.IsEmpty() ) if( libraries.IsEmpty() )
...@@ -486,35 +470,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, ...@@ -486,35 +470,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
} }
MList.ReadFootprintFiles( libraries ); MList.ReadFootprintFiles( libraries );
#else
wxASSERT( aTable != NULL );
if( aLibraryFullFilename.IsEmpty() )
{
std::vector< wxString > libNames = aTable->GetLogicalLibs();
for( unsigned i = 0; i < libNames.size(); i++ ) #else
{
FP_LIB_TABLE::ROW row = *aTable->FindRow( libNames[i] );
libTable.InsertRow( row );
}
}
else
{
FP_LIB_TABLE::ROW row = *aTable->FindRow( aLibraryFullFilename );
libTable.InsertRow( row );
}
if( libTable.IsEmpty() ) wxASSERT( aTable != NULL );
{
DisplayError( aWindow, _( "No footprint libraries were specified." ) );
return wxEmptyString;
}
if( !MList.ReadFootprintFiles( libTable ) ) if( !MList.ReadFootprintFiles( aTable, !aLibraryName ? NULL : &aLibraryName ) )
{ {
msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ), msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ),
GetChars( aLibraryFullFilename ) ); GetChars( aLibraryName ) );
if( !MList.m_filesNotFound.IsEmpty() ) if( !MList.m_filesNotFound.IsEmpty() )
msg += _( "Files not found:\n\n" ) + MList.m_filesNotFound; msg += _( "Files not found:\n\n" ) + MList.m_filesNotFound;
...@@ -591,6 +555,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, ...@@ -591,6 +555,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
headers.Add( _( "Library" ) ); headers.Add( _( "Library" ) );
msg.Printf( _( "Modules [%d items]" ), (int) rows.size() ); msg.Printf( _( "Modules [%d items]" ), (int) rows.size() );
EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, OldName, DisplayCmpDoc ); EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, OldName, DisplayCmpDoc );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
......
...@@ -434,7 +434,6 @@ protected: ...@@ -434,7 +434,6 @@ protected:
// @todo these will eventually have to be made instance variables. // @todo these will eventually have to be made instance variables.
static wxString m_lib_nick_name; static wxString m_lib_nick_name;
static wxString m_lib_path;
/// The library nickName is a short string, for now the same as the library path /// The library nickName is a short string, for now the same as the library path
/// but without path and without extension. After library table support it becomes /// but without path and without extension. After library table support it becomes
...@@ -442,9 +441,18 @@ protected: ...@@ -442,9 +441,18 @@ protected:
wxString getLibNickName() const { return m_lib_nick_name; } wxString getLibNickName() const { return m_lib_nick_name; }
void setLibNickName( const wxString& aLibNickName ) { m_lib_nick_name = aLibNickName; } void setLibNickName( const wxString& aLibNickName ) { m_lib_nick_name = aLibNickName; }
static wxString m_lib_path;
#if !defined(USE_FP_LIB_TABLE)
void setLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; }
/// The libPath is the full string used in the PLUGIN::Footprint*() calls. /// The libPath is the full string used in the PLUGIN::Footprint*() calls.
wxString getLibPath() const { return m_lib_path; } wxString getLibPath() const { return m_lib_path; }
void setLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; }
#else
/// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
wxString getLibPath();
#endif
}; };
#endif // MODULE_EDITOR_FRAME_H_ #endif // MODULE_EDITOR_FRAME_H_
...@@ -256,6 +256,20 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME() ...@@ -256,6 +256,20 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
m_Pcb = 0; m_Pcb = 0;
} }
#if defined(USE_FP_LIB_TABLE)
wxString FOOTPRINT_EDIT_FRAME::getLibPath()
{
try
{
const FP_LIB_TABLE::ROW* row = GetFootprintLibraryTable()->FindRow( m_lib_nick_name );
return row->GetFullURI( true );
}
catch( IO_ERROR ioe )
{
return wxEmptyString;
}
}
#endif
const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName() const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName()
{ {
......
...@@ -393,23 +393,14 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() ...@@ -393,23 +393,14 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
wxArrayString libsList; wxArrayString libsList;
#if !defined( USE_FP_LIB_TABLE ) #if !defined( USE_FP_LIB_TABLE )
libsList.Add( m_libraryName ); libsList.Add( m_libraryName );
libLoaded = fp_info_list.ReadFootprintFiles( libsList ); libLoaded = fp_info_list.ReadFootprintFiles( libsList );
#else #else
const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( m_libraryName );
if( row == NULL ) libLoaded = fp_info_list.ReadFootprintFiles( m_footprintLibTable, &m_libraryName );
{
wxString msg;
msg.Format( _( "Footprint library table entry <%s> not found." ),
GetChars( m_libraryName ) );
DisplayError( this, msg );
return;
}
FP_LIB_TABLE tmp;
tmp.InsertRow( *row );
libLoaded = fp_info_list.ReadFootprintFiles( tmp );
#endif #endif
if( !libLoaded ) if( !libLoaded )
......
...@@ -184,6 +184,11 @@ bool EDA_APP::OnInit() ...@@ -184,6 +184,11 @@ bool EDA_APP::OnInit()
* display the real hotkeys in menus or tool tips */ * display the real hotkeys in menus or tool tips */
ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr ); ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr );
#if defined( USE_FP_LIB_TABLE )
// Set any environment variables before loading FP_LIB_TABLE
SetFootprintLibTablePath();
#endif
frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
#ifdef KICAD_SCRIPTING #ifdef KICAD_SCRIPTING
...@@ -206,10 +211,6 @@ bool EDA_APP::OnInit() ...@@ -206,10 +211,6 @@ bool EDA_APP::OnInit()
// Some will be overwritten after loading the board file // Some will be overwritten after loading the board file
frame->LoadProjectSettings( fn.GetFullPath() ); frame->LoadProjectSettings( fn.GetFullPath() );
#if defined( USE_FP_LIB_TABLE )
SetFootprintLibTablePath();
#endif
/* Load file specified in the command line. */ /* Load file specified in the command line. */
if( fn.IsOk() ) if( fn.IsOk() )
{ {
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <module_editor_frame.h> #include <module_editor_frame.h>
#include <modview_frame.h> #include <modview_frame.h>
#include <invoke_pcb_dialog.h>
#include <dialog_mask_clearance.h> #include <dialog_mask_clearance.h>
#include <dialog_general_options.h> #include <dialog_general_options.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment