mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Pcbnew footprint library table work in progress.
* Add code for loading, modifying, and saving the global and project footprint library tables. * Add code to load MODULE objects using the footprint library table to the footprint viewer. * Add static methods to FP_LIB_TABLE to support loading footprint library tables.
This commit is contained in:
parent
6b0980d964
commit
c9be8bfdd4
@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <wx/config.h> // wxExpandEnvVars()
|
#include <wx/config.h> // wxExpandEnvVars()
|
||||||
|
#include <wx/filename.h>
|
||||||
|
#include <wx/stdpaths.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <io_mgr.h>
|
|
||||||
|
|
||||||
#include <fp_lib_table_lexer.h>
|
#include <fp_lib_table_lexer.h>
|
||||||
#include <fp_lib_table.h>
|
#include <fp_lib_table.h>
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ PLUGIN* FP_LIB_TABLE::PluginFind( const wxString& aLibraryNickName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const wxString FP_LIB_TABLE::ExpandSubtitutions( const wxString aString )
|
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString aString )
|
||||||
{
|
{
|
||||||
// We reserve the right to do this another way, by providing our own member
|
// We reserve the right to do this another way, by providing our own member
|
||||||
// function.
|
// function.
|
||||||
@ -310,6 +310,48 @@ const wxString FP_LIB_TABLE::ExpandSubtitutions( const wxString aString )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
|
||||||
|
{
|
||||||
|
wxFileName fn = GetGlobalTableFileName();
|
||||||
|
|
||||||
|
wxLogDebug( wxT( "Loading global footprint table file: %s" ), GetChars( fn.GetFullPath() ) );
|
||||||
|
|
||||||
|
if( !fn.FileExists() )
|
||||||
|
{
|
||||||
|
/// @todo call some script to create initial global footprint table.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FILE_LINE_READER reader( fn.GetFullPath() );
|
||||||
|
FP_LIB_TABLE_LEXER lexer( &reader );
|
||||||
|
|
||||||
|
aTable.Parse( &lexer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString FP_LIB_TABLE::GetGlobalTableFileName()
|
||||||
|
{
|
||||||
|
wxFileName fn;
|
||||||
|
|
||||||
|
fn.SetPath( wxStandardPaths::Get().GetUserConfigDir() );
|
||||||
|
|
||||||
|
#if defined( __WINDOWS__ )
|
||||||
|
fn.AppendDir( wxT( "kicad" ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fn.SetName( GetFileName() );
|
||||||
|
|
||||||
|
return fn.GetFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString FP_LIB_TABLE::GetFileName()
|
||||||
|
{
|
||||||
|
return wxString( wxT( ".fp-lib-table" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 // don't know that this is needed yet
|
#if 0 // don't know that this is needed yet
|
||||||
MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId )
|
MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId )
|
||||||
throw( IO_ERROR )
|
throw( IO_ERROR )
|
||||||
|
@ -59,7 +59,6 @@ class wxHtmlHelpController;
|
|||||||
*/
|
*/
|
||||||
class EDA_APP : public wxApp
|
class EDA_APP : public wxApp
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Used mainly to handle default paths libs m_Id = APP_EESCHEMA_T, APP_PCBNEW_T ...
|
/// Used mainly to handle default paths libs m_Id = APP_EESCHEMA_T, APP_PCBNEW_T ...
|
||||||
EDA_APP_T m_Id;
|
EDA_APP_T m_Id;
|
||||||
@ -416,6 +415,7 @@ public:
|
|||||||
bool LockFile( const wxString& fileName );
|
bool LockFile( const wxString& fileName );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use wxGetApp() to access EDA_APP. It is not necessary to keep copies
|
* Use wxGetApp() to access EDA_APP. It is not necessary to keep copies
|
||||||
* of the application pointer all over the place or worse yet in a global
|
* of the application pointer all over the place or worse yet in a global
|
||||||
|
@ -355,6 +355,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
const ROW* FindRow( const wxString& aNickName ) throw( IO_ERROR );
|
const ROW* FindRow( const wxString& aNickName ) throw( IO_ERROR );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function IsEmpty
|
||||||
|
* @return true if the footprint library table is empty.
|
||||||
|
*/
|
||||||
|
bool IsEmpty() const { return rows.empty(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ExpandEnvSubsitutions
|
* Function ExpandEnvSubsitutions
|
||||||
@ -363,13 +368,31 @@ public:
|
|||||||
* This enables (fp_lib_table)s to have platform dependent environment
|
* This enables (fp_lib_table)s to have platform dependent environment
|
||||||
* variables in them, allowing for a uniform table across platforms.
|
* variables in them, allowing for a uniform table across platforms.
|
||||||
*/
|
*/
|
||||||
static const wxString ExpandSubtitutions( const wxString aString );
|
static const wxString ExpandSubstitutions( const wxString aString );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function IsEmpty
|
* Function LoadGlobalTable
|
||||||
* @return true if the footprint library table is empty.
|
* loads the global footprint library table into \a aTable.
|
||||||
|
*
|
||||||
|
* This probably should be move into the application object when KiCad is changed
|
||||||
|
* to a single process application. This is the least painful solution for the
|
||||||
|
* time being.
|
||||||
|
*
|
||||||
|
* @param aTable the #FP_LIB_TABLE object to load.
|
||||||
*/
|
*/
|
||||||
bool IsEmpty() const { return rows.empty(); }
|
static void LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetGlobalTableFileName
|
||||||
|
* @return the platform specific global footprint library path and file name.
|
||||||
|
*/
|
||||||
|
static wxString GetGlobalTableFileName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetFootprintTableFileName
|
||||||
|
* @return the footprint library file name.
|
||||||
|
*/
|
||||||
|
static wxString GetFileName();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
* Function GetFootprintName
|
* Function GetFootprintName
|
||||||
* returns the footprint name, i.e. footprintName.
|
* returns the footprint name, i.e. footprintName.
|
||||||
*/
|
*/
|
||||||
const std::string& GetFootprintName() const;
|
const std::string& GetFootprintName() const { return footprint; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetFootprintName
|
* Function SetFootprintName
|
||||||
|
@ -54,6 +54,8 @@ class GENERAL_COLLECTORS_GUIDE;
|
|||||||
class BOARD_DESIGN_SETTINGS;
|
class BOARD_DESIGN_SETTINGS;
|
||||||
class ZONE_SETTINGS;
|
class ZONE_SETTINGS;
|
||||||
class PCB_PLOT_PARAMS;
|
class PCB_PLOT_PARAMS;
|
||||||
|
class FP_LIB_TABLE;
|
||||||
|
class FPID;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,6 +85,11 @@ protected:
|
|||||||
BOARD* m_Pcb;
|
BOARD* m_Pcb;
|
||||||
GENERAL_COLLECTOR* m_Collector;
|
GENERAL_COLLECTOR* m_Collector;
|
||||||
|
|
||||||
|
/// The project footprint library table. This is a combination of the project
|
||||||
|
/// footprint library table and the global footprint table. This is the one to
|
||||||
|
/// use when finding a #MODULE.
|
||||||
|
FP_LIB_TABLE* m_footprintLibTable;
|
||||||
|
|
||||||
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
|
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
|
||||||
/// main window.
|
/// main window.
|
||||||
wxAuiToolBar* m_auxiliaryToolBar;
|
wxAuiToolBar* m_auxiliaryToolBar;
|
||||||
@ -93,15 +100,15 @@ protected:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function loadFootprint
|
* Function loadFootprint
|
||||||
* attempts to load \a aFootprintName from the list of libraries.
|
* attempts to load \a aFootprintId from the footprint library table.
|
||||||
*
|
*
|
||||||
* @param aFootprintName is the name of component footprint to load.
|
* @param aFootprintId is the #FPID of component footprint to load.
|
||||||
* @return the #MODULE if found or NULL if \a aFootprintName not found in any of the
|
* @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
|
||||||
* libraries.
|
* libraries in #m_footprintLibTable.
|
||||||
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
|
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
|
||||||
* occurs while reading footprint library files.
|
* occurs while reading footprint library files.
|
||||||
*/
|
*/
|
||||||
MODULE* loadFootprint( const wxString& aFootprintName )
|
MODULE* loadFootprint( const FPID& aFootprintId )
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -442,25 +449,29 @@ public:
|
|||||||
* @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.
|
||||||
*
|
*
|
||||||
* @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& aLibraryFullFilename,
|
||||||
const wxString& aMask,
|
const wxString& aMask,
|
||||||
const wxString& aKeyWord );
|
const wxString& aKeyWord,
|
||||||
|
FP_LIB_TABLE* aTable );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Load_Module_From_Library
|
* Function LoadModuleFromLibrary
|
||||||
* opens a dialog to select a footprint, and loads it into current board.
|
* opens a dialog to select a footprint, and loads it into current board.
|
||||||
*
|
*
|
||||||
* @param aLibrary = the library name to use, or empty string to search
|
* @param aLibrary = the library name to use, or empty string to search
|
||||||
* in all loaded libraries
|
* in all loaded libraries
|
||||||
|
* @param aTable is the #FP_LIB_TABLE containing the avaiable footprint libraries.
|
||||||
* @param aUseFootprintViewer = true to show the option
|
* @param aUseFootprintViewer = true to show the option
|
||||||
* allowing the footprint selection by the footprint viewer
|
* allowing the footprint selection by the footprint viewer
|
||||||
* @param aDC (can be NULL ) = the current Device Context, to draw the new footprint
|
* @param aDC (can be NULL ) = the current Device Context, to draw the new footprint
|
||||||
*/
|
*/
|
||||||
MODULE* Load_Module_From_Library( const wxString& aLibrary,
|
MODULE* LoadModuleFromLibrary( const wxString& aLibrary,
|
||||||
|
FP_LIB_TABLE* aTable,
|
||||||
bool aUseFootprintViewer = true,
|
bool aUseFootprintViewer = true,
|
||||||
wxDC* aDC = NULL );
|
wxDC* aDC = NULL );
|
||||||
|
|
||||||
@ -471,6 +482,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxString SelectFootprintFromLibBrowser( void );
|
wxString SelectFootprintFromLibBrowser( void );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetFootprintLibraryTable
|
||||||
|
* @return the project #FP_LIB_TABLE so programs can find footprints.
|
||||||
|
*/
|
||||||
|
FP_LIB_TABLE* GetFootprintLibraryTable() { return m_footprintLibTable; }
|
||||||
|
|
||||||
|
void SetFootprintLibraryTable( FP_LIB_TABLE* aTable ) { m_footprintLibTable = aTable; }
|
||||||
|
|
||||||
// ratsnest functions
|
// ratsnest functions
|
||||||
/**
|
/**
|
||||||
* Function Compile_Ratsnest
|
* Function Compile_Ratsnest
|
||||||
|
@ -63,6 +63,7 @@ class NETLIST;
|
|||||||
class REPORTER;
|
class REPORTER;
|
||||||
class PARSE_ERROR;
|
class PARSE_ERROR;
|
||||||
class IO_ERROR;
|
class IO_ERROR;
|
||||||
|
class FP_LIB_TABLE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +85,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
|
|||||||
/// The auxiliary right vertical tool bar used to access the microwave tools.
|
/// The auxiliary right vertical tool bar used to access the microwave tools.
|
||||||
wxAuiToolBar* m_microWaveToolBar;
|
wxAuiToolBar* m_microWaveToolBar;
|
||||||
|
|
||||||
|
/// The global footprint library table.
|
||||||
|
FP_LIB_TABLE* m_globalFootprintTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function loadFootprints
|
* Function loadFootprints
|
||||||
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
|
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
|
||||||
@ -198,6 +202,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone );
|
void duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function loadFootprintLibTable
|
||||||
|
* deletes the existing #FP_LIB_TABLE and creates a new one when a new project is loaded.
|
||||||
|
*/
|
||||||
|
void loadFootprintLibTable();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
|
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
|
||||||
wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
|
wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
|
||||||
@ -1659,12 +1669,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class FP_LIB_TABLE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function InvokePcbLibTableEditor
|
* Function InvokePcbLibTableEditor
|
||||||
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
|
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
|
||||||
|
@ -218,7 +218,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||||||
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
|
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
|
||||||
if( viewer == NULL )
|
if( viewer == NULL )
|
||||||
{
|
{
|
||||||
viewer = new FOOTPRINT_VIEWER_FRAME( this, NULL );
|
viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, NULL );
|
||||||
viewer->Show( true );
|
viewer->Show( true );
|
||||||
viewer->Zoom_Automatique( false );
|
viewer->Zoom_Automatique( false );
|
||||||
}
|
}
|
||||||
|
@ -463,9 +463,11 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
|
|||||||
|
|
||||||
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||||
{
|
{
|
||||||
|
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent();
|
||||||
wxString libPath = getLibPath();
|
wxString libPath = getLibPath();
|
||||||
wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath,
|
wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath,
|
||||||
wxEmptyString, wxEmptyString );
|
wxEmptyString, wxEmptyString,
|
||||||
|
parent->GetFootprintLibraryTable() );
|
||||||
|
|
||||||
if( !footprintName )
|
if( !footprintName )
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include <gr_basic.h>
|
#include <gr_basic.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <pcbcommon.h>
|
#include <pcbcommon.h>
|
||||||
|
#include <fp_lib_table.h>
|
||||||
|
#include <fpid.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
@ -123,7 +125,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
|||||||
if( viewer )
|
if( viewer )
|
||||||
viewer->Destroy();
|
viewer->Destroy();
|
||||||
|
|
||||||
viewer = new FOOTPRINT_VIEWER_FRAME( this, &semaphore,
|
viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, &semaphore,
|
||||||
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
|
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
|
||||||
|
|
||||||
// Show the library viewer frame until it is closed
|
// Show the library viewer frame until it is closed
|
||||||
@ -147,7 +149,8 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
|
||||||
|
FP_LIB_TABLE* aTable,
|
||||||
bool aUseFootprintViewer,
|
bool aUseFootprintViewer,
|
||||||
wxDC* aDC )
|
wxDC* aDC )
|
||||||
{
|
{
|
||||||
@ -195,7 +198,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
|||||||
{
|
{
|
||||||
allowWildSeach = false;
|
allowWildSeach = false;
|
||||||
keys = moduleName;
|
keys = moduleName;
|
||||||
moduleName = SelectFootprint( this, libName, wxEmptyString, keys );
|
moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() ) // Cancel command
|
if( moduleName.IsEmpty() ) // Cancel command
|
||||||
{
|
{
|
||||||
@ -207,7 +210,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
|||||||
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
|
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
|
||||||
{
|
{
|
||||||
allowWildSeach = false;
|
allowWildSeach = false;
|
||||||
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString );
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() )
|
if( moduleName.IsEmpty() )
|
||||||
{
|
{
|
||||||
@ -225,7 +228,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
|||||||
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
|
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
|
||||||
moduleName = wildname;
|
moduleName = wildname;
|
||||||
|
|
||||||
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString );
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() )
|
if( moduleName.IsEmpty() )
|
||||||
{
|
{
|
||||||
@ -390,38 +393,40 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE* PCB_BASE_FRAME::loadFootprint( const wxString& aFootprintName )
|
MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
{
|
{
|
||||||
wxString libPath;
|
wxCHECK_MSG( m_footprintLibTable != NULL, NULL,
|
||||||
wxFileName fn;
|
wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
|
||||||
MODULE* footprint;
|
|
||||||
|
|
||||||
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
wxString libName = FROM_UTF8( aFootprintId.GetLibNickname().c_str() );
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( libName );
|
||||||
|
|
||||||
|
if( row == NULL )
|
||||||
{
|
{
|
||||||
fn = wxFileName( wxEmptyString, g_LibraryNames[ii], LegacyFootprintLibPathExtension );
|
wxString msg;
|
||||||
|
msg.Printf( _( "No library named <%s> was found in the footprint library table." ),
|
||||||
libPath = wxGetApp().FindLibraryPath( fn );
|
aFootprintId.GetLibNickname().c_str() );
|
||||||
|
THROW_IO_ERROR( msg );
|
||||||
if( !libPath )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
footprint = pi->FootprintLoad( libPath, aFootprintName );
|
|
||||||
|
|
||||||
if( footprint )
|
|
||||||
return footprint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
||||||
const wxString& aLibraryFullFilename,
|
const wxString& aLibraryFullFilename,
|
||||||
const wxString& aMask,
|
const wxString& aMask,
|
||||||
const wxString& aKeyWord )
|
const wxString& aKeyWord,
|
||||||
|
FP_LIB_TABLE* aTable )
|
||||||
{
|
{
|
||||||
static wxString OldName; // Save the name of the last module loaded.
|
static wxString OldName; // Save the name of the last module loaded.
|
||||||
wxString CmpName;
|
wxString CmpName;
|
||||||
@ -431,9 +436,26 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
|||||||
|
|
||||||
|
|
||||||
if( aLibraryFullFilename.IsEmpty() )
|
if( aLibraryFullFilename.IsEmpty() )
|
||||||
|
{
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
libraries = g_LibraryNames;
|
libraries = g_LibraryNames;
|
||||||
|
#else
|
||||||
|
wxASSERT( aTable != NULL );
|
||||||
|
|
||||||
|
std::vector< wxString > libNames = aTable->GetLogicalLibs();
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < libNames.size(); i++ )
|
||||||
|
{
|
||||||
|
wxString uri = aTable->FindRow( libNames[i] )->GetFullURI();
|
||||||
|
uri = FP_LIB_TABLE::ExpandSubstitutions( uri );
|
||||||
|
libraries.Add( uri );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
libraries.Add( aLibraryFullFilename );
|
libraries.Add( aLibraryFullFilename );
|
||||||
|
}
|
||||||
|
|
||||||
if( libraries.IsEmpty() )
|
if( libraries.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -234,9 +234,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||||||
case ID_OPEN_MODULE_VIEWER:
|
case ID_OPEN_MODULE_VIEWER:
|
||||||
{
|
{
|
||||||
FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
|
FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
|
||||||
|
|
||||||
if( viewer == NULL )
|
if( viewer == NULL )
|
||||||
{
|
{
|
||||||
viewer = new FOOTPRINT_VIEWER_FRAME( this, NULL );
|
viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, NULL );
|
||||||
viewer->Show( true );
|
viewer->Show( true );
|
||||||
viewer->Zoom_Automatique( false );
|
viewer->Zoom_Automatique( false );
|
||||||
}
|
}
|
||||||
@ -459,6 +460,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||||||
|
|
||||||
case ID_MODEDIT_LOAD_MODULE:
|
case ID_MODEDIT_LOAD_MODULE:
|
||||||
{
|
{
|
||||||
|
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent();
|
||||||
wxString libPath = getLibPath(); // might be empty
|
wxString libPath = getLibPath(); // might be empty
|
||||||
|
|
||||||
wxLogDebug( wxT( "Loading module from library " ) + libPath );
|
wxLogDebug( wxT( "Loading module from library " ) + libPath );
|
||||||
@ -467,7 +469,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
Clear_Pcb( true );
|
Clear_Pcb( true );
|
||||||
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
|
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||||
Load_Module_From_Library( libPath, true );
|
LoadModuleFromLibrary( libPath, parent->GetFootprintLibraryTable(), true );
|
||||||
redraw = true;
|
redraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,11 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
|
|||||||
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
|
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent();
|
||||||
wxString libname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
|
wxString libname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
|
||||||
MODULE* oldmodule = GetBoard()->m_Modules;
|
MODULE* oldmodule = GetBoard()->m_Modules;
|
||||||
MODULE * module = Load_Module_From_Library( libname, false );
|
MODULE* module = LoadModuleFromLibrary( libname, parent->GetFootprintLibraryTable(),
|
||||||
|
false );
|
||||||
|
|
||||||
if( module )
|
if( module )
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#include <pcbcommon.h>
|
#include <pcbcommon.h>
|
||||||
#include <msgpanel.h>
|
#include <msgpanel.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
#include <fp_lib_table.h>
|
||||||
|
#include <fpid.h>
|
||||||
|
#include <confirm.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
@ -113,13 +116,18 @@ static wxAcceleratorEntry accels[] =
|
|||||||
|
|
||||||
#define FOOTPRINT_VIEWER_FRAME_NAME wxT( "ModViewFrame" )
|
#define FOOTPRINT_VIEWER_FRAME_NAME wxT( "ModViewFrame" )
|
||||||
|
|
||||||
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent,
|
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
|
||||||
wxSemaphore* semaphore, long style ) :
|
FP_LIB_TABLE* aTable,
|
||||||
PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME_TYPE, _( "Footprint Library Browser" ),
|
wxSemaphore* aSemaphore,
|
||||||
wxDefaultPosition, wxDefaultSize, style, GetFootprintViewerFrameName() )
|
long aStyle ) :
|
||||||
|
PCB_BASE_FRAME( aParent, MODULE_VIEWER_FRAME_TYPE, _( "Footprint Library Browser" ),
|
||||||
|
wxDefaultPosition, wxDefaultSize, aStyle, GetFootprintViewerFrameName() )
|
||||||
{
|
{
|
||||||
|
wxASSERT( aTable != NULL );
|
||||||
|
|
||||||
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
|
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
|
||||||
|
|
||||||
|
m_footprintLibTable = aTable;
|
||||||
m_FrameName = GetFootprintViewerFrameName();
|
m_FrameName = GetFootprintViewerFrameName();
|
||||||
m_configPath = wxT( "FootprintViewer" );
|
m_configPath = wxT( "FootprintViewer" );
|
||||||
m_showAxis = true; // true to draw axis.
|
m_showAxis = true; // true to draw axis.
|
||||||
@ -134,7 +142,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent,
|
|||||||
m_LibList = NULL;
|
m_LibList = NULL;
|
||||||
m_LibListWindow = NULL;
|
m_LibListWindow = NULL;
|
||||||
m_FootprintListWindow = NULL;
|
m_FootprintListWindow = NULL;
|
||||||
m_Semaphore = semaphore;
|
m_Semaphore = aSemaphore;
|
||||||
m_selectedFootprintName.Empty();
|
m_selectedFootprintName.Empty();
|
||||||
|
|
||||||
if( m_Semaphore )
|
if( m_Semaphore )
|
||||||
@ -194,8 +202,17 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent,
|
|||||||
|
|
||||||
// If a footprint was previsiously loaded, reload it
|
// If a footprint was previsiously loaded, reload it
|
||||||
if( !m_libraryName.IsEmpty() && !m_footprintName.IsEmpty() )
|
if( !m_libraryName.IsEmpty() && !m_footprintName.IsEmpty() )
|
||||||
|
{
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension,
|
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension,
|
||||||
m_footprintName, false );
|
m_footprintName, false );
|
||||||
|
#else
|
||||||
|
FPID id;
|
||||||
|
id.SetLibNickname( TO_UTF8( m_libraryName ) );
|
||||||
|
id.SetFootprintName( TO_UTF8( m_footprintName ) );
|
||||||
|
GetBoard()->Add( loadFootprint( id ) );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( m_canvas )
|
if( m_canvas )
|
||||||
@ -249,6 +266,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent,
|
|||||||
wxAuiPaneInfo& pane = m_auimgr.GetPane( m_LibListWindow );
|
wxAuiPaneInfo& pane = m_auimgr.GetPane( m_LibListWindow );
|
||||||
pane.MinSize( wxSize( m_LibListSize.x, -1 ) );
|
pane.MinSize( wxSize( m_LibListSize.x, -1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAuiPaneInfo& pane = m_auimgr.GetPane( m_FootprintListWindow );
|
wxAuiPaneInfo& pane = m_auimgr.GetPane( m_FootprintListWindow );
|
||||||
pane.MinSize( wxSize( m_FootprintListSize.x, -1 ) );
|
pane.MinSize( wxSize( m_FootprintListSize.x, -1 ) );
|
||||||
|
|
||||||
@ -359,10 +377,18 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_LibList->Clear();
|
m_LibList->Clear();
|
||||||
|
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
m_LibList->Append( g_LibraryNames[ii] );
|
m_LibList->Append( g_LibraryNames[ii] );
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
std::vector< wxString > libName = m_footprintLibTable->GetLogicalLibs();
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < libName.size(); ii++ )
|
||||||
|
m_LibList->Append( libName[ii] );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Search for a previous selection:
|
// Search for a previous selection:
|
||||||
int index = m_LibList->FindString( m_libraryName );
|
int index = m_LibList->FindString( m_libraryName );
|
||||||
@ -400,7 +426,21 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString libsList;
|
wxArrayString libsList;
|
||||||
|
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
libsList.Add( m_libraryName );
|
libsList.Add( m_libraryName );
|
||||||
|
#else
|
||||||
|
wxString uri = m_footprintLibTable->FindRow( m_libraryName )->GetFullURI();
|
||||||
|
|
||||||
|
if( uri.IsEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
uri = FP_LIB_TABLE::ExpandSubstitutions( uri );
|
||||||
|
wxLogDebug( wxT( "Footprint library <%s> selected." ), GetChars( uri ) );
|
||||||
|
|
||||||
|
libsList.Add( uri );
|
||||||
|
#endif
|
||||||
|
|
||||||
FOOTPRINT_LIST fp_info_list;
|
FOOTPRINT_LIST fp_info_list;
|
||||||
fp_info_list.ReadFootprintFiles( libsList );
|
fp_info_list.ReadFootprintFiles( libsList );
|
||||||
|
|
||||||
@ -455,8 +495,28 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
|
|||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
// Delete the current footprint
|
// Delete the current footprint
|
||||||
GetBoard()->m_Modules.DeleteAll();
|
GetBoard()->m_Modules.DeleteAll();
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension,
|
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension,
|
||||||
m_footprintName, true );
|
m_footprintName, true );
|
||||||
|
#else
|
||||||
|
FPID id;
|
||||||
|
id.SetLibNickname( TO_UTF8( m_libraryName ) );
|
||||||
|
id.SetFootprintName( TO_UTF8( m_footprintName ) );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GetBoard()->Add( loadFootprint( id ) );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n"
|
||||||
|
"Error %s." ), GetChars( m_footprintName ), GetChars( m_libraryName ),
|
||||||
|
GetChars( ioe.errorText ) );
|
||||||
|
DisplayError( this, msg );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DisplayLibInfos();
|
DisplayLibInfos();
|
||||||
Zoom_Automatique( false );
|
Zoom_Automatique( false );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
@ -464,6 +524,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
|
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
if( m_Semaphore )
|
if( m_Semaphore )
|
||||||
@ -478,6 +539,7 @@ void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
|
void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int ii = m_FootprintList->GetSelection();
|
int ii = m_FootprintList->GetSelection();
|
||||||
@ -549,11 +611,13 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
|
|||||||
if( g_LibraryNames.GetCount() == m_LibList->GetCount() )
|
if( g_LibraryNames.GetCount() == m_LibList->GetCount() )
|
||||||
{
|
{
|
||||||
unsigned ii;
|
unsigned ii;
|
||||||
|
|
||||||
for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
if( m_LibList->GetString(ii) != g_LibraryNames[ii] )
|
if( m_LibList->GetString(ii) != g_LibraryNames[ii] )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ii == g_LibraryNames.GetCount() )
|
if( ii == g_LibraryNames.GetCount() )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -677,11 +741,7 @@ void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
|
|||||||
m_Draw3DFrame->Show( true );
|
m_Draw3DFrame->Show( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Update3D_Frame
|
|
||||||
* must be called after a footprint selection
|
|
||||||
* Updates the 3D view and 3D frame title.
|
|
||||||
*/
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
|
void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
|
||||||
{
|
{
|
||||||
if( m_Draw3DFrame == NULL )
|
if( m_Draw3DFrame == NULL )
|
||||||
@ -694,14 +754,15 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
|
|||||||
if( aForceReloadFootprint )
|
if( aForceReloadFootprint )
|
||||||
{
|
{
|
||||||
m_Draw3DFrame->ReloadRequest();
|
m_Draw3DFrame->ReloadRequest();
|
||||||
|
|
||||||
// Force 3D screen refresh immediately
|
// Force 3D screen refresh immediately
|
||||||
if( GetBoard()->m_Modules )
|
if( GetBoard()->m_Modules )
|
||||||
m_Draw3DFrame->NewDisplay();
|
m_Draw3DFrame->NewDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_COLOR_T FOOTPRINT_VIEWER_FRAME::GetGridColor() const
|
EDA_COLOR_T FOOTPRINT_VIEWER_FRAME::GetGridColor() const
|
||||||
{
|
{
|
||||||
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
|
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
class wxSashLayoutWindow;
|
class wxSashLayoutWindow;
|
||||||
class wxListBox;
|
class wxListBox;
|
||||||
class wxSemaphore;
|
class wxSemaphore;
|
||||||
|
class FP_LIB_TABLE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,8 +65,9 @@ protected:
|
|||||||
// the selected footprint is here
|
// the selected footprint is here
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL,
|
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, FP_LIB_TABLE* aTable,
|
||||||
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
|
wxSemaphore* aSemaphore = NULL,
|
||||||
|
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
|
||||||
|
|
||||||
~FOOTPRINT_VIEWER_FRAME();
|
~FOOTPRINT_VIEWER_FRAME();
|
||||||
|
|
||||||
|
@ -347,7 +347,8 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||||||
if( (DrawStruct == NULL) || (DrawStruct->GetFlags() == 0) )
|
if( (DrawStruct == NULL) || (DrawStruct->GetFlags() == 0) )
|
||||||
{
|
{
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
DrawStruct = (BOARD_ITEM*) Load_Module_From_Library( wxEmptyString, true, aDC );
|
DrawStruct = (BOARD_ITEM*) LoadModuleFromLibrary( wxEmptyString, m_footprintLibTable,
|
||||||
|
true, aDC );
|
||||||
SetCurItem( DrawStruct );
|
SetCurItem( DrawStruct );
|
||||||
|
|
||||||
if( DrawStruct )
|
if( DrawStruct )
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <3d_viewer.h>
|
#include <3d_viewer.h>
|
||||||
#include <msgpanel.h>
|
#include <msgpanel.h>
|
||||||
|
#include <fp_lib_table.h>
|
||||||
|
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <protos.h>
|
#include <protos.h>
|
||||||
@ -56,6 +57,7 @@
|
|||||||
#include <dialog_plot.h>
|
#include <dialog_plot.h>
|
||||||
#include <convert_from_iu.h>
|
#include <convert_from_iu.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
|
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
|
||||||
#include <python_scripting.h>
|
#include <python_scripting.h>
|
||||||
#endif
|
#endif
|
||||||
@ -291,9 +293,13 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
|
|||||||
m_RecordingMacros = -1;
|
m_RecordingMacros = -1;
|
||||||
m_microWaveToolBar = NULL;
|
m_microWaveToolBar = NULL;
|
||||||
m_useCmpFileForFpNames = true;
|
m_useCmpFileForFpNames = true;
|
||||||
|
m_footprintLibTable = NULL;
|
||||||
|
m_globalFootprintTable = NULL;
|
||||||
|
|
||||||
#ifdef KICAD_SCRIPTING_WXPYTHON
|
#ifdef KICAD_SCRIPTING_WXPYTHON
|
||||||
m_pythonPanel = NULL;
|
m_pythonPanel = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for ( int i = 0; i < 10; i++ )
|
for ( int i = 0; i < 10; i++ )
|
||||||
m_Macros[i].m_Record.clear();
|
m_Macros[i].m_Record.clear();
|
||||||
|
|
||||||
@ -447,6 +453,7 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
|
|||||||
m_Macros[i].m_Record.clear();
|
m_Macros[i].m_Record.clear();
|
||||||
|
|
||||||
delete m_drc;
|
delete m_drc;
|
||||||
|
delete m_globalFootprintTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include <wx/file.h>
|
#include <wx/file.h>
|
||||||
#include <wx/snglinst.h>
|
#include <wx/snglinst.h>
|
||||||
|
#include <wx/dir.h>
|
||||||
|
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <protos.h>
|
#include <protos.h>
|
||||||
@ -188,9 +189,28 @@ bool EDA_APP::OnInit()
|
|||||||
frame->LoadProjectSettings( fn.GetFullPath() );
|
frame->LoadProjectSettings( fn.GetFullPath() );
|
||||||
|
|
||||||
// Set the KISYSMOD environment variable for the current process if it is not already
|
// Set the KISYSMOD environment variable for the current process if it is not already
|
||||||
// defined. This is required to expand the global footprint library table paths.
|
// defined in the user's environment. This is required to expand the global footprint
|
||||||
|
// library table paths.
|
||||||
if( !wxGetEnv( wxT( "KISYSMOD" ), &msg ) && !GetLibraryPathList().IsEmpty() )
|
if( !wxGetEnv( wxT( "KISYSMOD" ), &msg ) && !GetLibraryPathList().IsEmpty() )
|
||||||
wxSetEnv( wxT( "KISYSMOD" ), GetLibraryPathList()[0] );
|
{
|
||||||
|
unsigned modFileCount = 0;
|
||||||
|
wxString bestPath;
|
||||||
|
wxArrayString tmp;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < GetLibraryPathList().GetCount(); i++ )
|
||||||
|
{
|
||||||
|
unsigned cnt = wxDir::GetAllFiles( GetLibraryPathList()[i], &tmp, wxT( "*.mod" ) );
|
||||||
|
|
||||||
|
if( cnt > modFileCount )
|
||||||
|
{
|
||||||
|
modFileCount = cnt;
|
||||||
|
bestPath = GetLibraryPathList()[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxLogDebug( wxT( "Setting $KISYSMOD=\"%s\"." ), GetChars( bestPath ) );
|
||||||
|
wxSetEnv( wxT( "KISYSMOD" ), bestPath );
|
||||||
|
}
|
||||||
|
|
||||||
/* Load file specified in the command line. */
|
/* Load file specified in the command line. */
|
||||||
if( fn.IsOk() )
|
if( fn.IsOk() )
|
||||||
|
@ -41,12 +41,10 @@
|
|||||||
#include <plot_common.h>
|
#include <plot_common.h>
|
||||||
#include <worksheet.h>
|
#include <worksheet.h>
|
||||||
#include <dialog_hotkeys_editor.h>
|
#include <dialog_hotkeys_editor.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
|
||||||
#include <fp_lib_table.h>
|
#include <fp_lib_table.h>
|
||||||
|
|
||||||
#include <fp_lib_table_lexer.h>
|
#include <fp_lib_table_lexer.h>
|
||||||
|
|
||||||
|
#include <class_board.h>
|
||||||
#include <pcbplot.h>
|
#include <pcbplot.h>
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
@ -85,72 +83,27 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||||||
|
|
||||||
case ID_PCB_LIB_TABLE_EDIT:
|
case ID_PCB_LIB_TABLE_EDIT:
|
||||||
{
|
{
|
||||||
// scaffolding: dummy up some data into tables, until actual load/save are in place.
|
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
|
||||||
FP_LIB_TABLE gbl;
|
|
||||||
FP_LIB_TABLE prj;
|
|
||||||
|
|
||||||
FP_LIB_TABLE_LEXER glex(
|
|
||||||
"(fp_lib_table\n"
|
|
||||||
" (lib (name passives)(descr \"R/C Lib\")(type KiCad)(uri ${KISYSMODS}/passives.pretty))\n"
|
|
||||||
" (lib (name micros)(descr \"Small stuff\")(type Legacy)(uri ${KISYSMODS}/passives.mod)(options \"op1=2\"))\n"
|
|
||||||
" (lib (name chips)(descr \"Potatoe chips\")(type Eagle)(uri /opt/eagle-6.2.0/lbr/con-amp-micromatch.lbr))\n"
|
|
||||||
")", wxT( "gbl" ) );
|
|
||||||
|
|
||||||
FP_LIB_TABLE_LEXER plex(
|
|
||||||
"(fp_lib_table\n"
|
|
||||||
" (lib (name passives)(descr \"Demo Lib\")(type KiCad)(uri ${KIUSRMODS}/passives.pretty))\n"
|
|
||||||
" (lib (name micros)(descr \"Small stuff\")(type Legacy)(uri ${KIUSRMODS}/micros.mod)(options \"op1=2\"))\n"
|
|
||||||
" (lib (name chips)(descr \"Potatoe chips\")(type Eagle)(uri /opt/eagle-6.2.0/lbr/con-amp-micromatch.lbr))\n"
|
|
||||||
")", wxT( "prj" ) );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
gbl.Parse( &glex );
|
|
||||||
prj.Parse( &plex );
|
|
||||||
}
|
|
||||||
/* PARSE_ERROR is an IO_ERROR, handle them the same for now.
|
|
||||||
catch( PARSE_ERROR pe )
|
|
||||||
{
|
|
||||||
DisplayError( this, pe.errorText );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
catch( IO_ERROR ioe )
|
|
||||||
{
|
|
||||||
DisplayError( this, ioe.errorText );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int r = InvokePcbLibTableEditor( this, &gbl, &prj );
|
|
||||||
|
|
||||||
if( r & 1 )
|
if( r & 1 )
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
|
||||||
printf( "changed global:\n" );
|
m_globalFootprintTable->Format( &sf, 0 );
|
||||||
|
|
||||||
STRING_FORMATTER sf;
|
|
||||||
|
|
||||||
gbl.Format( &sf, 0 );
|
|
||||||
|
|
||||||
printf( "%s\n", sf.GetString().c_str() );
|
|
||||||
#endif
|
|
||||||
// save global table to disk and apply it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( r & 2 )
|
if( r & 2 )
|
||||||
{
|
{
|
||||||
#if defined(DEBUG)
|
wxFileName fn = GetBoard()->GetFileName();
|
||||||
printf( "changed project:\n" );
|
fn.SetName( FP_LIB_TABLE::GetFileName() );
|
||||||
|
fn.SetExt( wxEmptyString );
|
||||||
|
|
||||||
STRING_FORMATTER sf;
|
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
|
||||||
|
m_footprintLibTable->Format( &sf, 0 );
|
||||||
|
|
||||||
prj.Format( &sf, 0 );
|
|
||||||
|
|
||||||
printf( "%s\n", sf.GetString().c_str() );
|
|
||||||
#endif
|
|
||||||
// save project table to disk and apply it
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_PCB_MASK_CLEARANCE:
|
case ID_PCB_MASK_CLEARANCE:
|
||||||
@ -268,6 +221,8 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
|
|||||||
SetElementVisibility( RATSNEST_VISIBLE, showRats );
|
SetElementVisibility( RATSNEST_VISIBLE, showRats );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
loadFootprintLibTable();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,3 +534,48 @@ void PCB_EDIT_FRAME::ReadMacros()
|
|||||||
macrosNode = (XNODE*) macrosNode->GetNext();
|
macrosNode = (XNODE*) macrosNode->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_EDIT_FRAME::loadFootprintLibTable()
|
||||||
|
{
|
||||||
|
if( m_globalFootprintTable == NULL )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_globalFootprintTable = new FP_LIB_TABLE();
|
||||||
|
FP_LIB_TABLE::LoadGlobalTable( *m_globalFootprintTable );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf( _( "An error occurred attempting to load the global footprint library "
|
||||||
|
"table:\n\n%s" ), GetChars( ioe.errorText ) );
|
||||||
|
DisplayError( this, msg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_footprintLibTable;
|
||||||
|
|
||||||
|
wxFileName fn = GetBoard()->GetFileName();
|
||||||
|
fn.SetName( FP_LIB_TABLE::GetFileName() );
|
||||||
|
fn.SetExt( wxEmptyString );
|
||||||
|
|
||||||
|
// Check if a project footprint table is defined and load it. If no project footprint
|
||||||
|
// table is defined, then the global library table is the footprint library table.
|
||||||
|
|
||||||
|
m_footprintLibTable = new FP_LIB_TABLE( m_globalFootprintTable );
|
||||||
|
|
||||||
|
if( fn.FileExists() )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FILE_LINE_READER reader( fn.GetFullPath() );
|
||||||
|
FP_LIB_TABLE_LEXER lexer( &reader );
|
||||||
|
m_footprintLibTable->Parse( &lexer );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR ioe )
|
||||||
|
{
|
||||||
|
DisplayError( this, ioe.errorText );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -589,7 +589,8 @@ void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
|
|||||||
{
|
{
|
||||||
wxString newname;
|
wxString newname;
|
||||||
|
|
||||||
newname = m_Parent->SelectFootprint( m_Parent, wxEmptyString, wxEmptyString, wxEmptyString );
|
newname = m_Parent->SelectFootprint( m_Parent, wxEmptyString, wxEmptyString, wxEmptyString,
|
||||||
|
m_Parent->GetFootprintLibraryTable() );
|
||||||
|
|
||||||
if( newname != wxEmptyString )
|
if( newname != wxEmptyString )
|
||||||
m_NewModule->SetValue( newname );
|
m_NewModule->SetValue( newname );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user