Remove g_LibraryNames and all supporting infrastructure from pcbnew. FP_LIB_TABLE is now local to major wxFrames.

This commit is contained in:
Dick Hollenbeck 2014-01-27 01:23:02 -06:00
parent 6617ce58f3
commit 9afc4a0db6
14 changed files with 46 additions and 2793 deletions

View File

@ -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

View File

@ -345,7 +345,6 @@ public:
void SetRotationAngle( int aRotationAngle );
// Configurations:
void InstallConfigFrame();
void Process_Config( wxCommandEvent& event );
/**

View File

@ -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

View File

@ -1,442 +0,0 @@
/**
* @file ^pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2012 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
*/
/* Handle the Pcbnew library config (library list, and default lib path)
*/
#include <fctsys.h>
#include <wx/tokenzr.h>
#include <appl_wxstruct.h>
#include <confirm.h>
#include <gestfich.h>
#include <pcbnew.h>
#include <macros.h>
#include <wxPcbStruct.h>
#include <pcbcommon.h>
#include <wildcards_and_files_ext.h>
#include <dialog_pcbnew_config_libs_and_paths.h>
#include <wildcards_and_files_ext.h>
void PCB_EDIT_FRAME::InstallConfigFrame( )
{
DIALOG_PCBNEW_CONFIG_LIBS dialog( this );
dialog.ShowModal();
}
DIALOG_PCBNEW_CONFIG_LIBS::DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME* parent ):
DIALOG_PCBNEW_CONFIG_LIBS_FBP(parent)
{
m_Config = wxGetApp().GetCommonSettings();
Init( );
wxString title;
title.Printf( _( "from <%s>" ), GetChars( wxGetApp().GetCurrentOptionFile() ) );
SetTitle( title );
m_sdbSizer1OK->SetDefault();
if( GetSizer() )
GetSizer()->SetSizeHints( this );
}
void DIALOG_PCBNEW_CONFIG_LIBS::Init()
{
SetFocus();
m_LibListChanged = false;
m_LibPathChanged = false;
m_UserLibDirBufferImg = g_UserLibDirBuffer; // Save the original lib path
m_ListLibr->InsertItems( g_LibraryNames, 0 );
// Display current modules doc file:
m_Config->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
m_TextHelpModulesFileName->SetValue( g_DocModulesFileName );
// Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( Token.HasMoreTokens() )
{
wxString path = Token.GetNextToken();
if( wxFileName::DirExists( path ) )
m_listUserPaths->Append(path);
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii]);
}
// select the first path after the current path project
if ( libpaths.GetCount() > 1 )
m_DefaultLibraryPathslistBox->Select( 1 );
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnCancelClick( wxCommandEvent& event )
{
// Recreate the user lib path
if ( m_LibPathChanged )
{
for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString(ii) );
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1);
}
EndModal( wxID_CANCEL );
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnOkClick( wxCommandEvent& event )
{
m_Config->Write( wxT( "module_doc_file" ), m_TextHelpModulesFileName->GetValue() );
// Recreate the user lib path
if ( m_LibPathChanged )
{
g_UserLibDirBuffer.Empty();
for ( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii ++ )
{
if ( ii > 0 )
g_UserLibDirBuffer << wxT(";");
g_UserLibDirBuffer << m_listUserPaths->GetString(ii);
}
}
// Set new active library list if the lib list of if default path list was modified
if( m_LibListChanged || m_LibPathChanged )
{
// Recreate lib list
g_LibraryNames.Clear();
for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ )
g_LibraryNames.Add( m_ListLibr->GetString(ii) );
}
GetParent()->SaveProjectSettings( true );
EndModal( wxID_OK );
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnCloseWindow( wxCloseEvent& event )
{
EndModal( wxID_CANCEL );
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonUpClick( wxCommandEvent& event )
{
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1]);
}
m_ListLibr->Set(libnames);
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListLibr->SetSelection(jj-1);
}
m_LibListChanged = true;
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonDownClick( wxCommandEvent& event )
{
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
if ( selections.GetCount() <= 0 ) // No selection.
return;
// The last lib is selected. cannot move down it
if( selections.Last() == (int)(m_ListLibr->GetCount()-1) )
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1] );
}
m_ListLibr->Set(libnames);
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListLibr->SetSelection(jj+1);
}
m_LibListChanged = true;
}
/* Remove a library to the library list.
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveLibClick( wxCommandEvent& event )
{
wxArrayInt selections;
m_ListLibr->GetSelections( selections );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
m_ListLibr->Delete( selections[ii] );
m_LibListChanged = true;
}
}
/* Insert or add a library to the library list:
* The new library is put in list before (insert button) the selection,
* or added (add button) to end of list
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event )
{
int ii = 0;
wxString libfilename;
wxFileName fn;
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
ii = selections.GetCount();
if( ii > 0 )
ii = selections[0];
else
ii = 0;
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if ( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
wxFileDialog FilesDialog( this, _( "Footprint library files:" ), libpath,
wxEmptyString,
wxGetTranslation( LegacyFootprintLibPathWildcard ),
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
if( FilesDialog.ShowModal() != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
if ( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the
* path is a sub path of these default paths
*/
libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );
// Remove extension:
fn = libfilename;
fn.SetExt( wxEmptyString );
libfilename = fn.GetFullPath();
//Add or insert new library name, if not already in list
if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_LibListChanged = true;
if( event.GetId() == ID_ADD_LIB )
m_ListLibr->Append( libfilename );
else
m_ListLibr->Insert( libfilename, ii++ );
}
else
{
wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) +
_( "Library already in use" );
DisplayError( this, msg );
}
}
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertPath( wxCommandEvent& event )
{
wxString path = wxGetApp().ReturnLastVisitedLibraryPath();
bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
path, wxDD_DEFAULT_STYLE,
this, wxDefaultPosition );
if( !select )
return;
if( ! wxFileName::DirExists( path ) ) // Should not occurs
return;
// Add or insert path if not already in list
if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
{
int ipos = m_listUserPaths->GetCount();
if ( event.GetId() == wxID_INSERT_PATH )
{
if ( ipos )
ipos--;
int jj = m_listUserPaths->GetSelection();
if ( jj >= 0 )
ipos = jj;
}
// Ask the user if this is a relative path
int diag = wxMessageBox( _( "Use a relative path?" ),
_( "Path type" ),
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES )
{ // Make it relative
wxFileName fn = path;
fn.MakeRelativeTo( wxT( "." ) );
path = fn.GetPathWithSep() + fn.GetFullName();
}
m_listUserPaths->Insert(path, ipos);
m_LibPathChanged = true;
wxGetApp().InsertLibraryPath( path, ipos+1 );
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii]);
}
}
else
{
DisplayError( this, _( "Path already in use" ) );
}
wxGetApp().SaveLastVisitedLibraryPath( path );
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveUserPath( wxCommandEvent& event )
{
int ii = m_listUserPaths->GetSelection();
if ( ii < 0 )
ii = m_listUserPaths->GetCount()-1;
if ( ii >= 0 )
{
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
m_listUserPaths->Delete( ii );
m_LibPathChanged = true;
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
}
void DIALOG_PCBNEW_CONFIG_LIBS::OnBrowseModDocFile( wxCommandEvent& event )
{
wxString FullFileName;
wxString docpath, filename;
docpath = wxGetApp().ReturnLastVisitedLibraryPath(wxT( "doc" ));
wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
wxEmptyString, PdfFileWildcard, wxFD_DEFAULT_STYLE );
if( FilesDialog.ShowModal() != wxID_OK )
return;
FullFileName = FilesDialog.GetPath( );
/* If the path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is
* a sub path of these default paths
*/
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath(FullFileName);
m_TextHelpModulesFileName->SetValue( filename );
}

View File

@ -1,44 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// 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_

View File

@ -1,192 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_pcbnew_config_libs_and_paths_fbp.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( 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* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bLibsChoiceSizer;
bLibsChoiceSizer = new wxBoxSizer( wxVERTICAL );
m_staticTextLibs = new wxStaticText( this, wxID_ANY, _("Footprint library files"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextLibs->Wrap( -1 );
bLibsChoiceSizer->Add( m_staticTextLibs, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bLibsChoiceListSizer;
bLibsChoiceListSizer = new wxBoxSizer( wxHORIZONTAL );
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 400,90 ) );
bLibsChoiceListSizer->Add( m_ListLibr, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
m_buttonAddLib = new wxButton( this, ID_ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAddLib->SetToolTip( _("Add a new library after the selected library, and load it") );
bRightSizer->Add( m_buttonAddLib, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_buttonIns = new wxButton( this, wxID_ANY, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonIns->SetToolTip( _("Add a new library before the selected library, and load it") );
bRightSizer->Add( m_buttonIns, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonRemoveLib = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveLib->SetToolTip( _("Unload the selected library") );
bRightSizer->Add( m_buttonRemoveLib, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_buttonUp = new wxButton( this, wxID_ANY, _("Up"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonUp, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonDown = new wxButton( this, wxID_ANY, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonDown, 0, wxALL, 5 );
bLibsChoiceListSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bLibsChoiceSizer->Add( bLibsChoiceListSizer, 1, wxEXPAND, 5 );
bMainSizer->Add( bLibsChoiceSizer, 2, wxEXPAND, 5 );
wxBoxSizer* bModulesDocSizer;
bModulesDocSizer = new wxBoxSizer( wxVERTICAL );
m_staticTextModulesDoc = new wxStaticText( this, wxID_ANY, _("Footprint documentation file"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextModulesDoc->Wrap( -1 );
bModulesDocSizer->Add( m_staticTextModulesDoc, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerDoc;
bSizerDoc = new wxBoxSizer( wxHORIZONTAL );
m_TextHelpModulesFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TextHelpModulesFileName->SetMaxLength( 0 );
bSizerDoc->Add( m_TextHelpModulesFileName, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_buttonModDoc = new wxButton( this, wxID_BROWSE_MOD_DOC, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerDoc->Add( m_buttonModDoc, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
bModulesDocSizer->Add( bSizerDoc, 1, wxEXPAND, 5 );
bMainSizer->Add( bModulesDocSizer, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerPaths;
bSizerPaths = new wxBoxSizer( wxVERTICAL );
m_staticTextPaths = new wxStaticText( this, wxID_ANY, _("User defined search paths"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPaths->Wrap( -1 );
bSizerPaths->Add( m_staticTextPaths, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerPathsChoice;
bSizerPathsChoice = new wxBoxSizer( wxHORIZONTAL );
m_listUserPaths = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is higher than default KiCad paths.") );
bSizerPathsChoice->Add( m_listUserPaths, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bUserPathsButtonsSizer;
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonAddPath = new wxButton( this, ID_LIB_PATH_SEL, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonAddPath, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonInsPath = new wxButton( this, wxID_INSERT_PATH, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonInsPath, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
m_buttonRemovePath = new wxButton( this, wxID_REMOVE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL|wxBOTTOM, 5 );
bSizerPathsChoice->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
bSizerPaths->Add( bSizerPathsChoice, 1, wxEXPAND, 5 );
bMainSizer->Add( bSizerPaths, 1, wxEXPAND, 5 );
wxBoxSizer* bLibPathSizer;
bLibPathSizer = new wxBoxSizer( wxVERTICAL );
m_staticTextPathList = new wxStaticText( this, wxID_ANY, _("Current search path list"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPathList->Wrap( -1 );
bLibPathSizer->Add( m_staticTextPathList, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB );
m_DefaultLibraryPathslistBox->SetToolTip( _("System and user paths used to search and load library files and component doc files.\nSorted by decreasing priority order.") );
m_DefaultLibraryPathslistBox->SetMinSize( wxSize( -1,70 ) );
bLibPathSizer->Add( m_DefaultLibraryPathslistBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( bLibPathSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 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();
bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnCloseWindow ) );
m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveUserPath ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnOkClick ), NULL, this );
}
DIALOG_PCBNEW_CONFIG_LIBS_FBP::~DIALOG_PCBNEW_CONFIG_LIBS_FBP()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnCloseWindow ) );
m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveUserPath ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnOkClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,92 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// 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__

View File

@ -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;

View File

@ -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 );

View File

@ -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 )

View File

@ -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 )

View File

@ -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,

View File

@ -81,10 +81,6 @@ 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;
@ -132,7 +128,6 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
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;