2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-02-02 17:39:59 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2015-02-22 21:25:29 +00:00
|
|
|
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
|
2011-10-19 20:32:21 +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-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file backanno.cpp
|
|
|
|
* @brief Functions for backannotating footprint information.
|
|
|
|
*/
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.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 <kiface_i.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <build_version.h>
|
2013-02-02 17:39:59 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <sch_sheet_path.h>
|
|
|
|
#include <sch_component.h>
|
2015-02-21 08:11:58 +00:00
|
|
|
#include <sch_reference_list.h>
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2014-07-07 04:12:04 +00:00
|
|
|
#include <dsnlexer.h>
|
|
|
|
#include <ptree.h>
|
|
|
|
#include <boost/property_tree/ptree.hpp>
|
2014-08-28 23:44:28 +00:00
|
|
|
#include <wx/choicdlg.h>
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2008-05-08 20:34:39 +00:00
|
|
|
|
2015-02-22 21:25:29 +00:00
|
|
|
void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences )
|
|
|
|
throw( IO_ERROR, boost::bad_pointer )
|
2014-07-07 04:12:04 +00:00
|
|
|
{
|
|
|
|
// Build a flat list of components in schematic:
|
|
|
|
SCH_REFERENCE_LIST refs;
|
|
|
|
SCH_SHEET_LIST sheets;
|
|
|
|
bool isChanged = false;
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
sheets.GetComponents( Prj().SchLibs(), refs, false );
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
|
2014-07-07 04:12:04 +00:00
|
|
|
PTREE doc;
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Scan( &doc, &lexer );
|
2014-07-07 04:12:04 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG) && 0
|
2014-07-07 19:49:14 +00:00
|
|
|
STRING_FORMATTER sf;
|
|
|
|
Format( &sf, 0, 0, doc );
|
|
|
|
printf( "%s: '%s'\n", __func__, sf.GetString().c_str() );
|
2014-07-07 04:12:04 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
CPTREE& back_anno = doc.get_child( "back_annotation" );
|
2014-07-28 09:24:15 +00:00
|
|
|
wxString footprint;
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
|
|
|
|
{
|
|
|
|
wxASSERT( ref->first == "ref" );
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
wxString reference = (UTF8&) ref->second.front().first;
|
2014-07-28 09:24:15 +00:00
|
|
|
|
|
|
|
// Ensure the "fpid" node contains a footprint name,
|
|
|
|
// and get it if exists
|
|
|
|
if( ref->second.get_child( "fpid" ).size() )
|
|
|
|
{
|
|
|
|
wxString tmp = (UTF8&) ref->second.get_child( "fpid" ).front().first;
|
|
|
|
footprint = tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
footprint.Empty();
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
// DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); )
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// Search the component in the flat list
|
|
|
|
for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
|
2014-07-07 04:12:04 +00:00
|
|
|
{
|
2014-07-07 19:49:14 +00:00
|
|
|
if( Cmp_KEEPCASE( reference, refs[ii].GetRef() ) == 0 )
|
2014-07-07 04:12:04 +00:00
|
|
|
{
|
2014-07-07 19:49:14 +00:00
|
|
|
// We have found a candidate.
|
|
|
|
// Note: it can be not unique (multiple parts per package)
|
|
|
|
// So we *do not* stop the search here
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
SCH_COMPONENT* component = refs[ii].GetComp();
|
2014-07-07 19:49:14 +00:00
|
|
|
SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
|
|
|
|
const wxString& oldfp = fpfield->GetText();
|
|
|
|
|
|
|
|
if( !oldfp && fpfield->IsVisible() )
|
|
|
|
{
|
|
|
|
fpfield->SetVisible( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// DBG( printf("%s: ref:%s fpid:%s\n", __func__, TO_UTF8( refs[ii].GetRef() ), TO_UTF8( footprint ) );)
|
|
|
|
if( oldfp != footprint )
|
|
|
|
isChanged = true;
|
|
|
|
|
|
|
|
fpfield->SetText( footprint );
|
2014-07-07 04:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-07 19:49:14 +00:00
|
|
|
catch( const PTREE_ERROR& ex )
|
|
|
|
{
|
|
|
|
// remap the exception to something the caller is likely to understand.
|
|
|
|
THROW_IO_ERROR( ex.what() );
|
|
|
|
}
|
2014-07-07 04:12:04 +00:00
|
|
|
|
|
|
|
if( isChanged )
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename,
|
2014-08-28 23:44:28 +00:00
|
|
|
bool aForceVisibilityState,
|
|
|
|
bool aVisibilityState )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-08-05 19:53:42 +00:00
|
|
|
// Build a flat list of components in schematic:
|
2014-07-07 04:12:04 +00:00
|
|
|
SCH_REFERENCE_LIST referencesList;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
SCH_SHEET_LIST sheetList;
|
2014-07-07 04:12:04 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
sheetList.GetComponents( Prj().SchLibs(), referencesList, false );
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );
|
2014-08-28 23:44:28 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
if( cmpFile == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// cmpFileReader dtor will close cmpFile
|
|
|
|
FILE_LINE_READER cmpFileReader( cmpFile, aFullFilename );
|
|
|
|
|
|
|
|
// Now, for each component found in file,
|
2011-08-19 13:08:24 +00:00
|
|
|
// replace footprint field value by the new value:
|
2013-02-02 17:39:59 +00:00
|
|
|
wxString reference;
|
|
|
|
wxString footprint;
|
|
|
|
wxString buffer;
|
|
|
|
wxString value;
|
|
|
|
|
|
|
|
while( cmpFileReader.ReadLine() )
|
2008-05-07 23:41:05 +00:00
|
|
|
{
|
2013-02-02 17:39:59 +00:00
|
|
|
buffer = FROM_UTF8( cmpFileReader.Line() );
|
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
|
2013-02-02 17:39:59 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Begin component description.
|
|
|
|
reference.Empty();
|
|
|
|
footprint.Empty();
|
|
|
|
|
|
|
|
while( cmpFileReader.ReadLine() )
|
2008-05-07 23:41:05 +00:00
|
|
|
{
|
2013-02-02 17:39:59 +00:00
|
|
|
buffer = FROM_UTF8( cmpFileReader.Line() );
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( buffer.StartsWith( wxT( "EndCmp" ) ) )
|
2013-02-02 17:39:59 +00:00
|
|
|
break;
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
// store string value, stored between '=' and ';' delimiters.
|
|
|
|
value = buffer.AfterFirst( '=' );
|
2014-07-07 04:12:04 +00:00
|
|
|
value = value.BeforeLast( ';' );
|
2013-02-02 17:39:59 +00:00
|
|
|
value.Trim(true);
|
|
|
|
value.Trim(false);
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( buffer.StartsWith( wxT( "Reference" ) ) )
|
2011-08-05 19:53:42 +00:00
|
|
|
{
|
2013-02-02 17:39:59 +00:00
|
|
|
reference = value;
|
|
|
|
}
|
2014-08-28 23:44:28 +00:00
|
|
|
else if( buffer.StartsWith( wxT( "IdModule =" ) ) )
|
2013-02-02 17:39:59 +00:00
|
|
|
{
|
|
|
|
footprint = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
// A block is read: initialize the footprint field of the corresponding component
|
2013-02-02 17:39:59 +00:00
|
|
|
// if the footprint name is not empty
|
|
|
|
if( reference.IsEmpty() )
|
|
|
|
continue;
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
// Search the component in the flat list
|
2014-07-07 04:12:04 +00:00
|
|
|
for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ )
|
2013-02-02 17:39:59 +00:00
|
|
|
{
|
2014-07-07 04:12:04 +00:00
|
|
|
if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 )
|
2013-02-02 17:39:59 +00:00
|
|
|
{
|
|
|
|
// We have found a candidate.
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Note: it can be not unique (multiple units per part)
|
2013-02-02 17:39:59 +00:00
|
|
|
// So we *do not* stop the search here
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
SCH_COMPONENT* component = referencesList[ii].GetComp();
|
2014-07-07 04:12:04 +00:00
|
|
|
SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
fpfield->SetText( footprint );
|
2013-02-02 17:39:59 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( aForceVisibilityState )
|
2013-02-11 18:50:55 +00:00
|
|
|
{
|
2014-08-28 23:44:28 +00:00
|
|
|
component->GetField( FOOTPRINT )->SetVisible( aVisibilityState );
|
2011-08-05 19:53:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-07 23:41:05 +00:00
|
|
|
}
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2008-05-07 15:08:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString path = wxPathOnly( Prj().GetProjectFullName() );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
wxFileDialog dlg( this, _( "Load Component Footprint Link File" ),
|
2013-02-11 18:50:55 +00:00
|
|
|
path, wxEmptyString,
|
2013-02-02 17:39:59 +00:00
|
|
|
ComponentFileExtensionWildcard,
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-05-16 09:21:01 +00:00
|
|
|
return false;
|
|
|
|
|
2013-02-11 18:50:55 +00:00
|
|
|
wxString filename = dlg.GetPath();
|
* 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
|
|
|
wxString title = wxT( "Eeschema " ) + GetBuildVersion() + wxT( ' ' ) + filename;
|
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
SetTitle( title );
|
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
wxArrayString choices;
|
|
|
|
choices.Add( _( "Keep existing footprint field visibility" ) );
|
|
|
|
choices.Add( _( "Show all footprint fields" ) );
|
|
|
|
choices.Add( _( "Hide all footprint fields" ) );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
wxSingleChoiceDialog choiceDlg( this, _( "Select the footprint field visibility setting." ),
|
|
|
|
_( "Change Visibility" ), choices );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
2013-02-11 18:50:55 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( choiceDlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return false;
|
2013-02-11 18:50:55 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
bool forceVisibility = (choiceDlg.GetSelection() != 0 );
|
|
|
|
bool visibilityState = (choiceDlg.GetSelection() == 1 );
|
2011-03-28 18:23:01 +00:00
|
|
|
|
2014-08-28 23:44:28 +00:00
|
|
|
if( !ProcessCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) )
|
2008-05-07 23:41:05 +00:00
|
|
|
{
|
2014-08-28 23:44:28 +00:00
|
|
|
wxString msg = wxString::Format( _( "Failed to open component-footprint link file '%s'" ),
|
|
|
|
filename.GetData() );
|
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2013-02-11 18:50:55 +00:00
|
|
|
OnModify();
|
2011-03-28 18:23:01 +00:00
|
|
|
return true;
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|