Commit 9afc4a0d authored by Dick Hollenbeck's avatar Dick Hollenbeck

Remove g_LibraryNames and all supporting infrastructure from pcbnew. ...

Remove g_LibraryNames and all supporting infrastructure from pcbnew.  FP_LIB_TABLE is now local to major wxFrames.
parent 6617ce58
......@@ -434,51 +434,6 @@ public:
bool aRedraw,
bool aSaveForUndo );
// loading footprints
/**
* Function loadFootprintFromLibrary
* loads @a aFootprintName from @a aLibraryPath.
*
* @param aLibraryPath - the full filename or the short name of the library to read.
* if it is a short name, the file is searched in all library valid paths
* @param aFootprintName is the footprint to load
* @param aDisplayError = true to display an error message if any.
*
* @return MODULE* - new module, or NULL
*/
MODULE* loadFootprintFromLibrary( const wxString& aLibraryPath, const wxString& aFootprintName,
bool aDisplayError );
/**
* Function loadFootprintFromLibraries
* Explore the libraries list and
* loads @a aFootprintName from the first library it is found
* If found the module is added to the BOARD, just for good measure.
*
* @param aFootprintName is the footprint to load
* @param aDisplayError = true to display an error message if any.
*
* @return MODULE* - new module, or NULL
*/
MODULE* loadFootprintFromLibraries( const wxString& aFootprintName,
bool aDisplayError );
/**
* Function GetModuleLibrary
* scans active libraries to find and load @a aFootprintName.
* If found the module is added to the BOARD, just for good measure.
*
* @param aLibraryPath is the full/short name of the library.
* if empty, search in all libraries
* @param aFootprintName is the footprint to load
* @param aDisplayError = true to display an error message if any.
*
* @return a pointer to the new module, or NULL
*/
MODULE* GetModuleLibrary( const wxString& aLibraryPath, const wxString& aFootprintName,
bool aDisplayError );
/**
* Function SelectFootprint
* displays a list of modules found in all libraries or a given library
......
......@@ -345,7 +345,6 @@ public:
void SetRotationAngle( int aRotationAngle );
// Configurations:
void InstallConfigFrame();
void Process_Config( wxCommandEvent& event );
/**
......
......@@ -97,8 +97,6 @@ set( PCBNEW_DIALOGS
dialogs/dialog_non_copper_zones_properties_base.cpp
dialogs/dialog_pad_properties.cpp
dialogs/dialog_pad_properties_base.cpp
dialogs/dialog_pcbnew_config_libs_and_paths.cpp
dialogs/dialog_pcbnew_config_libs_and_paths_fbp.cpp
dialogs/dialog_plot_base.cpp
dialogs/dialog_plot.cpp
dialogs/dialog_print_for_modedit.cpp
......
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_pcbnew_config_libs_and_paths.h
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
#ifndef _DIALOG_PCBNEW_CONFIG_LIBS_H_
#define _DIALOG_PCBNEW_CONFIG_LIBS_H_
#include <dialog_pcbnew_config_libs_and_paths_fbp.h>
class DIALOG_PCBNEW_CONFIG_LIBS : public DIALOG_PCBNEW_CONFIG_LIBS_FBP
{
private:
wxConfig* m_Config;
bool m_LibListChanged;
bool m_LibPathChanged;
wxString m_UserLibDirBufferImg; // Copy of original g_UserLibDirBuffer
private:
// event handlers, overiding the fbp handlers
void Init();
void OnCloseWindow( wxCloseEvent& event );
void OnSaveCfgClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnAddOrInsertPath( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME * parent );
~DIALOG_PCBNEW_CONFIG_LIBS() {};
PCB_EDIT_FRAME* GetParent() { return (PCB_EDIT_FRAME*) wxDialog::GetParent(); }
};
#endif // _DIALOG_PCBNEW_CONFIG_LIBS_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_PCBNEW_CONFIG_LIBS_AND_PATHS_FBP_H__
#define __DIALOG_PCBNEW_CONFIG_LIBS_AND_PATHS_FBP_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/listbox.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PCBNEW_CONFIG_LIBS_FBP
///////////////////////////////////////////////////////////////////////////////
class DIALOG_PCBNEW_CONFIG_LIBS_FBP : public DIALOG_SHIM
{
private:
protected:
enum
{
ID_ADD_LIB = 1000,
ID_REMOVE_LIB,
wxID_BROWSE_MOD_DOC,
ID_LIB_PATH_SEL,
wxID_INSERT_PATH,
wxID_REMOVE_PATH
};
wxStaticText* m_staticTextLibs;
wxListBox* m_ListLibr;
wxButton* m_buttonAddLib;
wxButton* m_buttonIns;
wxButton* m_buttonRemoveLib;
wxButton* m_buttonUp;
wxButton* m_buttonDown;
wxStaticText* m_staticTextModulesDoc;
wxTextCtrl* m_TextHelpModulesFileName;
wxButton* m_buttonModDoc;
wxStaticText* m_staticTextPaths;
wxListBox* m_listUserPaths;
wxButton* m_buttonAddPath;
wxButton* m_buttonInsPath;
wxButton* m_buttonRemovePath;
wxStaticText* m_staticTextPathList;
wxListBox* m_DefaultLibraryPathslistBox;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnAddOrInsertLibClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveLibClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonUpClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonDownClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBrowseModDocFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddOrInsertPath( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveUserPath( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 530,540 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PCBNEW_CONFIG_LIBS_FBP();
};
#endif //__DIALOG_PCBNEW_CONFIG_LIBS_AND_PATHS_FBP_H__
......@@ -297,136 +297,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
}
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName,
bool aDisplayError )
{
if( aLibraryPath.IsEmpty() )
return loadFootprintFromLibraries( aFootprintName, aDisplayError );
else
return loadFootprintFromLibrary( aLibraryPath, aFootprintName, aDisplayError );
}
MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
const wxString& aFootprintName,
bool aDisplayError )
{
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
// Ensure the library name has the right extension
// (sometimes the name is given without ext)
wxString libname = aLibraryPath;
if( !libname.EndsWith( wxT(".") + LegacyFootprintLibPathExtension) )
libname << wxT(".") << LegacyFootprintLibPathExtension;
wxString libPath = wxGetApp().FindLibraryPath( libname );
if( libPath.IsEmpty() )
{
wxString msg = wxString::Format( _( "Library '%s' not found." ),
libname.GetData() );
DisplayError( NULL, msg );
return NULL;
}
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
if( !footprint )
{
if( aDisplayError )
{
wxString msg = wxString::Format(
_( "Footprint '%s' not found in library '%s'." ),
aFootprintName.GetData(),
libPath.GetData() );
DisplayError( NULL, msg );
}
return NULL;
}
SetStatusText( wxEmptyString );
return footprint;
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
}
}
MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
const wxString& aFootprintName, bool aDisplayError )
{
bool showed_error = false;
MODULE* footprint = NULL;
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{
wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii],
LegacyFootprintLibPathExtension );
wxString libPath = wxGetApp().FindLibraryPath( fn );
if( !libPath )
{
if( aDisplayError && !showed_error )
{
wxString msg = wxString::Format(
_( "PCB footprint library file '%s' not found in search paths." ),
fn.GetFullName().GetData() );
DisplayError( this, msg );
showed_error = true;
}
continue;
}
footprint = pi->FootprintLoad( libPath, aFootprintName );
if( footprint )
{
SetStatusText( wxEmptyString );
return footprint;
}
}
if( !footprint )
{
if( aDisplayError )
{
wxString msg = wxString::Format(
_( "Footprint %s not found in any library." ),
aFootprintName.GetData() );
DisplayError( NULL, msg );
}
return NULL;
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
return NULL;
}
/* attempts to load aFootprintId from the footprint library table.
* return the #MODULE if found or NULL if not found or error.
*/
MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId )
{
MODULE* module = NULL;
......
......@@ -776,7 +776,7 @@ const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
{
if( m_libraryName.IsEmpty() )
if( !m_libraryName )
return;
int selection = m_footprintList->FindString( m_footprintName );
......@@ -801,7 +801,8 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
// Delete the current footprint
GetBoard()->m_Modules.DeleteAll();
MODULE* footprint = GetModuleLibrary( GetSelectedLibraryFullName(), m_footprintName, true );
MODULE* footprint = m_footprintLibTable->FootprintLoad( m_libraryName, m_footprintName );
if( footprint )
GetBoard()->Add( footprint, ADD_APPEND );
......
......@@ -135,7 +135,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
/* Tom's hacks end */
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions )
EVT_MENU( ID_CONFIG_REQ, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config )
......
......@@ -81,8 +81,6 @@ wxPoint g_Offset_Module; /* Distance to offset module trace when movi
*/
wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" );
wxArrayString g_LibraryNames;
// wxWindow* DoPythonStuff(wxWindow* parent); // declaration
IMPLEMENT_APP( EDA_APP )
......
......@@ -69,8 +69,6 @@ extern int g_MagneticTrackOption;
extern wxPoint g_Offset_Module; /* Offset trace when moving footprint. */
extern wxArrayString g_LibraryNames; ///< List of footprint library file names to load.
enum MagneticPadOptionValues {
no_effect,
capture_cursor_in_track_tool,
......
......@@ -81,58 +81,53 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
InstallDialogLayerSetup();
break;
case ID_CONFIG_REQ:
InstallConfigFrame();
break;
case ID_PCB_LIB_TABLE_EDIT:
{
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
if( r & 1 )
{
try
{
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
m_globalFootprintTable->Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
if( r & 1 )
{
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
try
{
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
m_globalFootprintTable->Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
}
// If no board file is defined, do not save the project specific library table. It
// is kept in memory and created in the path when the new board is saved.
if( (r & 2) && !GetBoard()->GetFileName().IsEmpty() )
{
wxFileName fn = GetBoard()->GetFileName();
try
// If no board file is defined, do not save the project specific library table. It
// is kept in memory and created in the path when the new board is saved.
if( (r & 2) && !GetBoard()->GetFileName().IsEmpty() )
{
m_footprintLibTable->Save( fn );
tableChanged = true;
wxFileName fn = GetBoard()->GetFileName();
try
{
m_footprintLibTable->Save( fn );
tableChanged = true;
}
catch( IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred saving project specific footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
catch( IO_ERROR& ioe )
if( tableChanged && FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer() != NULL )
{
wxString msg;
msg.Printf( _( "Error occurred saving project specific footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer()->ReCreateLibraryList();
}
}
if( tableChanged && FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer() != NULL )
{
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer()->ReCreateLibraryList();
}
}
break;
case ID_PCB_MASK_CLEARANCE:
......@@ -225,9 +220,6 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
// Initialize default values.
g_LibraryNames.Clear();
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
// User library path takes precedent over default library search paths.
......@@ -325,16 +317,11 @@ PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters()
pca.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer,
GROUPLIB ) );
pca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&g_LibraryNames, GROUPLIB ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ), &g_UserLibDirBuffer, GROUPLIB ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
&m_lastNetListRead ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );
pca.push_back( new PARAM_CFG_BOOL( wxT( "UseCmpFile" ),
&m_useCmpFileForFpNames, true ) );
pca.push_back( new PARAM_CFG_BOOL( wxT( "UseCmpFile" ), &m_useCmpFileForFpNames, true ) );
GetBoard()->GetDesignSettings().AppendConfigs( &pca );
return pca;
......
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