2012-12-28 20:52:12 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-28 10:00:48 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
|
2012-12-28 20:52:12 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
/**
|
|
|
|
* @file librairi.cpp
|
|
|
|
* @brief Manage module (footprint) libraries.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
#include <wx/ffile.h>
|
2015-09-25 19:38:09 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <filter_reader.h>
|
|
|
|
#include <macros.h>
|
2013-05-28 16:54:59 +00:00
|
|
|
#include <fp_lib_table.h>
|
2013-11-29 18:29:41 +00:00
|
|
|
#include <validators.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <module_editor_frame.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-10-22 20:41:26 +00:00
|
|
|
#include <kicad_plugin.h>
|
|
|
|
#include <legacy_plugin.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
#include <dialog_select_pretty_lib.h>
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
// unique, "file local" translations:
|
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
#define FMT_OK_OVERWRITE _( "Library '%s' exists, OK to replace ?" )
|
2014-07-23 10:48:30 +00:00
|
|
|
#define FMT_CREATE_LIB _( "Create New Library Folder (the .pretty folder is the library)" )
|
2013-11-27 06:04:04 +00:00
|
|
|
#define FMT_OK_DELETE _( "OK to delete module %s in library '%s'" )
|
2013-12-10 19:24:10 +00:00
|
|
|
#define FMT_IMPORT_MODULE _( "Import Footprint" )
|
2013-11-27 06:04:04 +00:00
|
|
|
#define FMT_FILE_NOT_FOUND _( "File '%s' not found" )
|
2013-12-10 19:24:10 +00:00
|
|
|
#define FMT_NOT_MODULE _( "Not a footprint file" )
|
2013-11-27 06:04:04 +00:00
|
|
|
#define FMT_MOD_NOT_FOUND _( "Unable to find or load footprint %s from lib path '%s'" )
|
|
|
|
#define FMT_BAD_PATH _( "Unable to find or load footprint from path '%s'" )
|
|
|
|
#define FMT_BAD_PATHS _( "The footprint library '%s' could not be found in any of the search paths." )
|
|
|
|
#define FMT_LIB_READ_ONLY _( "Library '%s' is read only, not writable" )
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2013-12-10 19:24:10 +00:00
|
|
|
#define FMT_EXPORT_MODULE _( "Export Footprint" )
|
|
|
|
#define FMT_SAVE_MODULE _( "Save Footprint" )
|
|
|
|
#define FMT_MOD_REF _( "Enter footprint name:" )
|
|
|
|
#define FMT_EXPORTED _( "Footprint exported to file '%s'" )
|
|
|
|
#define FMT_MOD_DELETED _( "Footprint %s deleted from library '%s'" )
|
|
|
|
#define FMT_MOD_CREATE _( "New Footprint" )
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2013-12-10 19:24:10 +00:00
|
|
|
#define FMT_MOD_EXISTS _( "Footprint %s already exists in library '%s'" )
|
|
|
|
#define FMT_NO_REF_ABORTED _( "No footprint name defined." )
|
2013-11-27 06:04:04 +00:00
|
|
|
#define FMT_SELECT_LIB _( "Select Library" )
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
static const wxString INFO_LEGACY_LIB_WARN_EDIT(
|
|
|
|
_( "Writing/modifying legacy libraries (.mod files) is not allowed\n"\
|
|
|
|
"Please save the current library to the new .pretty format\n"\
|
|
|
|
"and update your footprint lib table\n"\
|
|
|
|
"to save your footprint (a .kicad_mod file) in the .pretty library folder" ) );
|
|
|
|
|
|
|
|
static const wxString INFO_LEGACY_LIB_WARN_DELETE(
|
|
|
|
_( "Modifying legacy libraries (.mod files) is not allowed\n"\
|
|
|
|
"Please save the current library under the new .pretty format\n"\
|
2014-07-25 17:49:14 +00:00
|
|
|
"and update your footprint lib table\n"\
|
2014-07-23 10:28:48 +00:00
|
|
|
"before deleting a footprint" ) );
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
static const wxString ModLegacyExportFileWildcard( _( "Legacy foot print export files (*.emp)|*.emp" ) );
|
2012-11-19 16:19:38 +00:00
|
|
|
static const wxString ModImportFileWildcard( _( "GPcb foot print files (*)|*" ) );
|
|
|
|
|
|
|
|
|
2009-01-15 08:12:03 +00:00
|
|
|
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
// use the clipboard for this in the future?
|
2009-01-15 08:12:03 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
// Some day it might be useful save the last library type selected along with the path.
|
2012-12-28 20:52:12 +00:00
|
|
|
static int lastFilterIndex = 0;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString lastOpenedPathForLoading = m_mruPath;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxConfigBase* config = Kiface().KifaceSettings();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
if( config )
|
|
|
|
config->Read( EXPORT_IMPORT_LASTPATH_KEY, &lastOpenedPathForLoading );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString wildCard;
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wildCard << wxGetTranslation( KiCadFootprintLibFileWildcard ) << wxChar( '|' )
|
2014-07-23 10:28:48 +00:00
|
|
|
<< wxGetTranslation( ModLegacyExportFileWildcard ) << wxChar( '|' )
|
2012-12-28 20:52:12 +00:00
|
|
|
<< wxGetTranslation( ModImportFileWildcard ) << wxChar( '|' )
|
|
|
|
<< wxGetTranslation( GedaPcbFootprintLibFileWildcard );
|
2012-11-19 16:19:38 +00:00
|
|
|
|
|
|
|
wxFileDialog dlg( this, FMT_IMPORT_MODULE,
|
2012-04-17 01:35:43 +00:00
|
|
|
lastOpenedPathForLoading, wxEmptyString,
|
2012-11-19 16:19:38 +00:00
|
|
|
wildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
2012-12-28 20:52:12 +00:00
|
|
|
dlg.SetFilterIndex( lastFilterIndex );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-10-30 21:30:58 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-12-28 20:52:12 +00:00
|
|
|
lastFilterIndex = dlg.GetFilterIndex();
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
FILE* fp = wxFopen( dlg.GetPath(), wxT( "rt" ) );
|
2012-12-28 20:52:12 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
if( !fp )
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString msg = wxString::Format( FMT_FILE_NOT_FOUND, GetChars( dlg.GetPath() ) );
|
2007-10-30 21:30:58 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
if( config ) // Save file path
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
lastOpenedPathForLoading = wxPathOnly( dlg.GetPath() );
|
|
|
|
config->Write( EXPORT_IMPORT_LASTPATH_KEY, lastOpenedPathForLoading );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
wxString moduleName;
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-12-28 20:52:12 +00:00
|
|
|
bool isGeda = false;
|
|
|
|
bool isLegacy = false;
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
{
|
2012-12-28 20:52:12 +00:00
|
|
|
FILE_LINE_READER freader( fp, dlg.GetPath() ); // I own fp, and will close it.
|
|
|
|
WHITESPACE_FILTER_READER reader( freader ); // skip blank lines
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
reader.ReadLine();
|
|
|
|
char* line = reader.Line();
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
if( !strnicmp( line, "(module", 7 ) )
|
|
|
|
{
|
|
|
|
// isKicad = true;
|
|
|
|
}
|
|
|
|
else if( !strnicmp( line, FOOTPRINT_LIBRARY_HEADER, FOOTPRINT_LIBRARY_HEADER_CNT ) )
|
|
|
|
{
|
|
|
|
isLegacy = true;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
while( reader.ReadLine() )
|
|
|
|
{
|
|
|
|
if( !strnicmp( line, "$MODULE", 7 ) )
|
|
|
|
{
|
|
|
|
moduleName = FROM_UTF8( StrPurge( line + sizeof( "$MODULE" ) -1 ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !strnicmp( line, "Element", 7 ) )
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2012-10-22 20:41:26 +00:00
|
|
|
isGeda = true;
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
else
|
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
DisplayError( this, FMT_NOT_MODULE );
|
2008-04-17 16:25:29 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
// fp is closed here by ~FILE_LINE_READER()
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
MODULE* module;
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
if( isGeda )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2012-12-28 20:52:12 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
wxFileName fn = dlg.GetPath();
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::GEDA_PCB ) );
|
|
|
|
|
|
|
|
moduleName = fn.GetName();
|
|
|
|
module = pi->FootprintLoad( fn.GetPath(), moduleName );
|
2012-10-22 20:41:26 +00:00
|
|
|
|
2012-12-28 20:52:12 +00:00
|
|
|
if( !module )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format(
|
|
|
|
FMT_MOD_NOT_FOUND, GetChars( moduleName ), GetChars( fn.GetPath() ) );
|
|
|
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-12-28 20:52:12 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2012-10-22 20:41:26 +00:00
|
|
|
else if( isLegacy )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
module = pi->FootprintLoad( dlg.GetPath(), moduleName );
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
if( !module )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format(
|
2012-11-19 16:19:38 +00:00
|
|
|
FMT_MOD_NOT_FOUND, GetChars( moduleName ), GetChars( dlg.GetPath() ) );
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-10-22 20:41:26 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // if( isKicad )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// This technique was chosen to create an example of how reading
|
|
|
|
// the s-expression format from clipboard could be done.
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
wxString fcontents;
|
2012-11-14 07:15:59 +00:00
|
|
|
PCB_IO pcb_io;
|
2012-10-23 17:20:22 +00:00
|
|
|
wxFFile f( dlg.GetPath() );
|
2012-10-22 20:41:26 +00:00
|
|
|
|
|
|
|
if( !f.IsOpened() )
|
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString msg = wxString::Format( FMT_BAD_PATH, GetChars( dlg.GetPath() ) );
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
f.ReadAll( &fcontents );
|
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
module = dyn_cast<MODULE*>( pcb_io.Parse( fcontents ) );
|
2012-10-22 20:41:26 +00:00
|
|
|
|
|
|
|
if( !module )
|
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString msg = wxString::Format( FMT_BAD_PATH, GetChars( dlg.GetPath() ) );
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-17 01:35:43 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-04-17 01:35:43 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
// Insert footprint in list
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( module );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
// Display info :
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( module );
|
2011-09-16 14:13:02 +00:00
|
|
|
PlaceModule( module, NULL );
|
2014-07-22 07:50:40 +00:00
|
|
|
|
|
|
|
if( IsGalCanvasActive() )
|
|
|
|
module->SetPosition( wxPoint( 0, 0 ) );
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2011-12-10 05:33:24 +00:00
|
|
|
GetBoard()->BuildListOfNets();
|
2014-07-09 11:50:27 +00:00
|
|
|
updateView();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxConfigBase* config = Kiface().KifaceSettings();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
if( !aModule )
|
2007-10-30 21:30:58 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-02 02:17:07 +00:00
|
|
|
fn.SetName( aModule->GetFPID().GetFootprintName() );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString wildcard = wxGetTranslation( KiCadFootprintLibFileWildcard );
|
2008-03-12 11:49:16 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
fn.SetExt( KiCadFootprintFileExtension );
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
if( config )
|
|
|
|
{
|
|
|
|
wxString path;
|
2015-09-25 19:38:09 +00:00
|
|
|
config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path, m_mruPath );
|
2012-11-19 16:19:38 +00:00
|
|
|
fn.SetPath( path );
|
|
|
|
}
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wxFileDialog dlg( this, FMT_EXPORT_MODULE, fn.GetPath(), fn.GetFullName(),
|
2013-05-28 16:54:59 +00:00
|
|
|
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-15 19:53:41 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-10-30 21:30:58 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = dlg.GetPath();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-11-14 07:15:59 +00:00
|
|
|
if( config ) // Save file path
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2008-03-12 11:49:16 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
try
|
|
|
|
{
|
2012-10-22 20:41:26 +00:00
|
|
|
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
|
|
|
|
// as an example on how it could also be used to send it to the system clipboard.
|
|
|
|
|
2012-11-14 07:15:59 +00:00
|
|
|
PCB_IO pcb_io( CTL_FOR_LIBRARY );
|
2012-10-22 20:41:26 +00:00
|
|
|
|
|
|
|
/* This module should *already* be "normalized" in a way such that
|
|
|
|
orientation is zero, etc., since it came from module editor.
|
|
|
|
|
|
|
|
module->SetTimeStamp( 0 );
|
|
|
|
module->SetParent( 0 );
|
|
|
|
module->SetOrientation( 0 );
|
|
|
|
*/
|
|
|
|
|
|
|
|
pcb_io.Format( aModule );
|
|
|
|
|
|
|
|
FILE* fp = wxFopen( dlg.GetPath(), wxT( "wt" ) );
|
|
|
|
fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() );
|
|
|
|
fclose( fp );
|
2012-04-17 01:35:43 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-04-17 01:35:43 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return;
|
|
|
|
}
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString msg = wxString::Format( FMT_EXPORTED, GetChars( dlg.GetPath() ) );
|
2009-04-17 08:51:02 +00:00
|
|
|
DisplayInfoMessage( this, msg );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString libPath = aLibPath ? *aLibPath : getLibPath();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libPath );
|
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
// Legacy libraries are readable, but writing legacy format is not allowed
|
|
|
|
if( piType == IO_MGR::LEGACY )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
|
|
|
|
|
|
|
|
pi->FootprintSave( libPath, GetBoard()->m_Modules );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary()
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
2014-07-23 10:28:48 +00:00
|
|
|
// Kicad cannot write legacy format libraries, only .pretty new format
|
|
|
|
// because the legacy format cannot handle current features.
|
2015-09-26 06:46:25 +00:00
|
|
|
// The footprint library is actually a directory
|
2014-07-23 10:28:48 +00:00
|
|
|
wxString wildcard = wxGetTranslation( KiCadFootprintLibPathWildcard );
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2015-09-26 06:46:25 +00:00
|
|
|
// prompt user for footprint library name, ending by ".pretty"
|
|
|
|
// Because there are constraints for the directory name to create,
|
|
|
|
// (the name should have the extension ".pretty", and the folder cannot be inside
|
|
|
|
// a footprint library), we do not use the standard wxDirDialog.
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2014-12-11 12:00:59 +00:00
|
|
|
wxString initialPath = wxPathOnly( Prj().GetProjectFullName() );
|
|
|
|
DIALOG_SELECT_PRETTY_LIB dlg( this, initialPath );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2012-11-19 16:19:38 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
|
2015-09-26 06:46:25 +00:00
|
|
|
wxString libPath = dlg.GetFullPrettyLibName();
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2015-09-26 06:46:25 +00:00
|
|
|
// We can save fp libs only using IO_MGR::KICAD format (.pretty libraries)
|
2014-07-23 10:28:48 +00:00
|
|
|
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD;
|
2012-11-19 16:19:38 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
|
|
|
|
|
|
|
|
bool writable = false;
|
|
|
|
bool exists = false;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
writable = pi->IsFootprintLibWritable( libPath );
|
|
|
|
exists = true; // no exception was thrown, lib must exist.
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& )
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
|
|
|
// ignore, original values of 'writable' and 'exists' are accurate.
|
|
|
|
}
|
|
|
|
|
|
|
|
if( exists )
|
|
|
|
{
|
|
|
|
if( !writable )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( FMT_LIB_READ_ONLY, GetChars( libPath ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( FMT_OK_OVERWRITE, GetChars( libPath ) );
|
|
|
|
|
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
pi->FootprintLibDelete( libPath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pi->FootprintLibCreate( libPath );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
return libPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
wxString nickname = GetCurrentLib();
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
// Legacy libraries are readable, but modifying legacy format is not allowed
|
|
|
|
// So prompt the user if he try to delete a footprint from a legacy lib
|
|
|
|
wxString libfullname = Prj().PcbFootprintLibs()->FindRow(nickname)->GetFullURI();
|
|
|
|
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libfullname );
|
|
|
|
|
|
|
|
if( piType == IO_MGR::LEGACY )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_DELETE );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) )
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_( "Library '%s' is read only" ),
|
|
|
|
GetChars( nickname )
|
|
|
|
);
|
|
|
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString fpid_txt = PCB_BASE_FRAME::SelectFootprint( this, nickname,
|
2014-05-09 18:35:48 +00:00
|
|
|
wxEmptyString, wxEmptyString, Prj().PcbFootprintLibs() );
|
2013-11-27 06:04:04 +00:00
|
|
|
|
|
|
|
if( !fpid_txt )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
FPID fpid( fpid_txt );
|
2014-01-02 02:17:07 +00:00
|
|
|
wxString fpname = fpid.GetFootprintName();
|
2013-11-27 06:04:04 +00:00
|
|
|
|
|
|
|
// Confirmation
|
|
|
|
wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() );
|
|
|
|
|
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
Prj().PcbFootprintLibs()->FootprintDelete( nickname, fpname );
|
2013-11-27 06:04:04 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.Printf( FMT_MOD_DELETED, fpname.GetData(), nickname.GetData() );
|
|
|
|
|
|
|
|
SetStatusText( msg );
|
|
|
|
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-11-27 06:04:04 +00:00
|
|
|
if( GetBoard()->m_Modules == NULL )
|
|
|
|
{
|
2015-09-26 06:46:25 +00:00
|
|
|
DisplayInfoMessage( this, _( "No footprints to archive!" ) );
|
2013-11-27 06:04:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
wxString footprintName;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
if( !aStoreInNewLib )
|
|
|
|
{
|
|
|
|
// The footprints are saved in an existing .pretty library in the fp lib table
|
|
|
|
PROJECT& prj = Prj();
|
|
|
|
wxString last_nickname = prj.GetRString( PROJECT::PCB_LIB_NICKNAME );
|
|
|
|
wxString nickname = SelectLibrary( last_nickname );
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
if( !nickname ) // Aborted
|
|
|
|
return;
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
FP_LIB_TABLE* tbl = prj.PcbFootprintLibs();
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
for( MODULE* curr_fp = GetBoard()->m_Modules; curr_fp; curr_fp = curr_fp->Next() )
|
|
|
|
{
|
|
|
|
if( !curr_fp->GetFPID().GetFootprintName().empty() ) // Can happen with old boards.
|
|
|
|
tbl->FootprintSave( nickname, curr_fp, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
2015-09-28 08:46:00 +00:00
|
|
|
// The footprints are saved in a new .pretty library.
|
|
|
|
// If this library already exists, all previous footprints will be deleted
|
|
|
|
wxString libPath = CreateNewLibrary();
|
2013-11-27 06:04:04 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
if( libPath.IsEmpty() ) // Aborted
|
2013-11-27 06:04:04 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD;
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
|
2014-05-09 18:35:48 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
for( MODULE* curr_fp = GetBoard()->m_Modules; curr_fp; curr_fp = curr_fp->Next() )
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
2015-09-28 08:46:00 +00:00
|
|
|
try
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
2015-09-28 08:46:00 +00:00
|
|
|
if( !curr_fp->GetFPID().GetFootprintName().empty() ) // Can happen with old boards.
|
|
|
|
pi->FootprintSave( libPath, curr_fp );
|
2013-11-27 06:04:04 +00:00
|
|
|
}
|
2015-09-28 08:46:00 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
2015-09-28 08:46:00 +00:00
|
|
|
DisplayError( this, ioe.errorText );
|
2013-11-27 06:04:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( const wxString& aLibrary,
|
2011-03-01 19:26:17 +00:00
|
|
|
MODULE* aModule,
|
|
|
|
bool aOverwrite,
|
|
|
|
bool aDisplayDialog )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-07-05 12:46:14 +00:00
|
|
|
if( aModule == NULL )
|
|
|
|
return false;
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( aModule );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2014-07-23 10:28:48 +00:00
|
|
|
|
|
|
|
// Legacy libraries are readable, but modifying legacy format is not allowed
|
|
|
|
// So prompt the user if he try to add/replace a footprint in a legacy lib
|
|
|
|
wxString libfullname = Prj().PcbFootprintLibs()->FindRow( aLibrary )->GetFullURI();
|
|
|
|
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libfullname );
|
|
|
|
|
|
|
|
if( piType == IO_MGR::LEGACY )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
// Ask what to use as the footprint name in the library
|
2014-01-02 02:17:07 +00:00
|
|
|
wxString footprintName = aModule->GetFPID().GetFootprintName();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2009-01-15 08:12:03 +00:00
|
|
|
if( aDisplayDialog )
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "Name:" ), FMT_SAVE_MODULE, footprintName );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2012-04-17 01:35:43 +00:00
|
|
|
return false; // canceled by user
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
footprintName = dlg.GetValue();
|
|
|
|
footprintName.Trim( true );
|
|
|
|
footprintName.Trim( false );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
if( footprintName.IsEmpty() )
|
2011-07-08 07:12:28 +00:00
|
|
|
return false;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-12-10 11:18:42 +00:00
|
|
|
if( ! MODULE::IsLibNameValid( footprintName ) )
|
|
|
|
{
|
2013-11-27 06:04:04 +00:00
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_("Error:\none of invalid chars '%s' found\nin '%s'" ),
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
MODULE::StringLibNameInvalidChars( true ),
|
2013-11-27 06:04:04 +00:00
|
|
|
GetChars( footprintName ) );
|
2012-12-10 11:18:42 +00:00
|
|
|
|
|
|
|
DisplayError( NULL, msg );
|
2013-09-08 18:31:21 +00:00
|
|
|
return false;
|
2012-12-10 11:18:42 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 18:31:21 +00:00
|
|
|
aModule->SetFPID( FPID( footprintName ) );
|
2011-07-08 07:12:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure this footprint has a libname
|
2012-04-17 01:35:43 +00:00
|
|
|
if( footprintName.IsEmpty() )
|
2011-07-08 07:12:28 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
footprintName = wxT("noname");
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
aModule->SetFPID( FPID( footprintName ) );
|
2007-10-30 21:30:58 +00:00
|
|
|
}
|
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
bool module_exists = false;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
|
|
|
|
|
|
|
MODULE* m = tbl->FootprintLoad( aLibrary, footprintName );
|
2013-11-27 06:04:04 +00:00
|
|
|
|
|
|
|
if( m )
|
|
|
|
{
|
|
|
|
delete m;
|
|
|
|
|
|
|
|
module_exists = true;
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
// an existing footprint is found in current lib
|
|
|
|
if( aDisplayDialog )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( FMT_MOD_EXISTS,
|
|
|
|
footprintName.GetData(), aLibrary.GetData() );
|
|
|
|
|
|
|
|
SetStatusText( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aOverwrite )
|
|
|
|
{
|
|
|
|
// Do not save the given footprint: an old one exists
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this always overwrites any existing footprint, but should yell on its
|
|
|
|
// own if the library or footprint is not writable.
|
2014-05-09 18:35:48 +00:00
|
|
|
tbl->FootprintSave( aLibrary, aModule );
|
2011-10-16 08:02:36 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
DisplayError( this, ioe.errorText );
|
2011-02-22 20:59:16 +00:00
|
|
|
return false;
|
2007-10-30 21:30:58 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 08:12:03 +00:00
|
|
|
if( aDisplayDialog )
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2011-10-16 08:02:36 +00:00
|
|
|
wxString fmt = module_exists ?
|
2013-11-27 06:04:04 +00:00
|
|
|
_( "Component [%s] replaced in '%s'" ) :
|
|
|
|
_( "Component [%s] added in '%s'" );
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
wxString msg = wxString::Format( fmt, footprintName.GetData(), aLibrary.GetData() );
|
2011-02-11 20:48:13 +00:00
|
|
|
SetStatusText( msg );
|
2007-10-30 21:30:58 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 20:59:16 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
// Creates a new footprint at position 0,0 which contains the minimal items:
|
|
|
|
// the reference and the value.
|
|
|
|
// Value : initialized to the footprint name.
|
|
|
|
// put on fab layer (front side)
|
|
|
|
// Reference : initialized to a default value (REF**).
|
|
|
|
// put on silkscreen layer (front side)
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
wxString moduleName = aModuleName;
|
2010-07-20 18:11:34 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// Ask for the new module name
|
2010-07-20 18:11:34 +00:00
|
|
|
if( moduleName.IsEmpty() )
|
2007-10-30 21:30:58 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
|
2014-08-24 22:49:31 +00:00
|
|
|
dlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &moduleName ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2010-07-20 18:11:34 +00:00
|
|
|
return NULL; //Aborted by user
|
|
|
|
}
|
2011-09-26 20:32:56 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
moduleName.Trim( true );
|
|
|
|
moduleName.Trim( false );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-12-10 19:24:10 +00:00
|
|
|
if( moduleName.IsEmpty() )
|
2010-07-20 18:11:34 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
DisplayInfoMessage( this, FMT_NO_REF_ABORTED );
|
2010-07-20 18:11:34 +00:00
|
|
|
return NULL;
|
2007-10-30 21:30:58 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
// Creates the new module and add it to the head of the linked list of modules
|
2015-01-28 10:00:48 +00:00
|
|
|
MODULE* module = new MODULE( GetBoard() );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
GetBoard()->Add( module );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// Update parameters: timestamp ...
|
2012-11-19 16:19:38 +00:00
|
|
|
module->SetLastEditTime();
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
// Update its name in lib
|
2013-09-08 18:31:21 +00:00
|
|
|
module->SetFPID( FPID( moduleName ) );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
wxPoint default_pos;
|
2015-01-30 18:42:46 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
|
2015-01-28 10:00:48 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
// Update reference:
|
2015-01-30 18:42:46 +00:00
|
|
|
if( settings.m_RefDefaultText.IsEmpty() )
|
|
|
|
module->SetReference( moduleName );
|
|
|
|
else
|
|
|
|
module->SetReference( settings.m_RefDefaultText );
|
|
|
|
|
|
|
|
module->Reference().SetThickness( settings.m_ModuleTextWidth );
|
|
|
|
module->Reference().SetSize( settings.m_ModuleTextSize );
|
2015-01-28 10:00:48 +00:00
|
|
|
default_pos.y = GetDesignSettings().m_ModuleTextSize.y / 2;
|
|
|
|
module->Reference().SetPosition( default_pos );
|
2015-01-30 18:42:46 +00:00
|
|
|
module->Reference().SetLayer( ToLAYER_ID( settings.m_RefDefaultlayer ) );
|
|
|
|
module->Reference().SetVisible( settings.m_RefDefaultVisibility );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
// Set the value field to a default value
|
2015-01-30 18:42:46 +00:00
|
|
|
if( settings.m_ValueDefaultText.IsEmpty() )
|
|
|
|
module->SetValue( moduleName );
|
|
|
|
else
|
|
|
|
module->SetValue( settings.m_ValueDefaultText );
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
|
|
|
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
|
2015-01-28 10:00:48 +00:00
|
|
|
default_pos.y = -default_pos.y;
|
|
|
|
module->Value().SetPosition( default_pos );
|
2015-01-30 18:42:46 +00:00
|
|
|
module->Value().SetLayer( ToLAYER_ID( settings.m_ValueDefaultlayer ) );
|
|
|
|
module->Value().SetVisible( settings.m_ValueDefaultVisibility );
|
2008-11-10 20:45:24 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( module );
|
2012-11-19 16:19:38 +00:00
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
|
|
|
wxArrayString headers;
|
2013-11-18 16:04:23 +00:00
|
|
|
|
|
|
|
headers.Add( _( "Nickname" ) );
|
|
|
|
headers.Add( _( "Description" ) );
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
std::vector< wxArrayString > itemsToDisplay;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
std::vector< wxString > nicknames = fptbl->GetLogicalLibs();
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-11-18 16:04:23 +00:00
|
|
|
for( unsigned i = 0; i < nicknames.size(); i++ )
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
|
|
|
wxArrayString item;
|
2013-11-18 16:04:23 +00:00
|
|
|
|
|
|
|
item.Add( nicknames[i] );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
item.Add( fptbl->GetDescription( nicknames[i] ) );
|
2013-11-18 16:04:23 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
itemsToDisplay.push_back( item );
|
|
|
|
}
|
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
EDA_LIST_DIALOG dlg( this, FMT_SELECT_LIB, headers, itemsToDisplay, aNicknameExisting );
|
2013-05-28 16:54:59 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2013-11-27 06:04:04 +00:00
|
|
|
return wxEmptyString;
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-10-13 21:33:58 +00:00
|
|
|
wxString nickname = dlg.GetTextSelection();
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
wxLogDebug( wxT( "Chose footprint library '%s'." ), GetChars( nickname ) );
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
return nickname;
|
2013-05-28 16:54:59 +00:00
|
|
|
}
|