2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-11-14 12:12:33 +00:00
|
|
|
* Copyright (C) 2004-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-01-27 15:56:36 +00:00
|
|
|
* Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-31 20:49:48 +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-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file class_library.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
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
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <eda_doc.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <richio.h>
|
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
|
|
|
#include <config_params.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
2015-06-22 15:38:54 +00:00
|
|
|
#include <project_rescue.h>
|
2017-01-27 15:56:36 +00:00
|
|
|
#include <properties.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <class_library.h>
|
2016-08-18 23:23:10 +00:00
|
|
|
#include <sch_legacy_plugin.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-02-02 05:48:29 +00:00
|
|
|
#include <wx/progdlg.h>
|
2009-09-18 14:56:05 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2009-10-08 13:19:28 +00:00
|
|
|
#include <wx/regex.h>
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2016-04-22 10:44:08 +00:00
|
|
|
#define DUPLICATE_NAME_MSG \
|
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
|
|
|
_( "Library '%s' has duplicate entry name '%s'.\n" \
|
|
|
|
"This may cause some unexpected behavior when loading components into a schematic." )
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
PART_LIB::PART_LIB( int aType, const wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aPluginType ) :
|
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
|
|
|
// start @ != 0 so each additional library added
|
|
|
|
// is immediately detectable, zero would not be.
|
2017-01-27 15:56:36 +00:00
|
|
|
m_mod_hash( PART_LIBS::s_modify_generation ),
|
|
|
|
m_pluginType( aPluginType )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-09-09 17:37:25 +00:00
|
|
|
type = aType;
|
2009-12-15 21:11:05 +00:00
|
|
|
isModified = false;
|
|
|
|
timeStamp = 0;
|
|
|
|
isCache = false;
|
|
|
|
timeStamp = wxDateTime::Now();
|
2015-02-25 19:43:37 +00:00
|
|
|
versionMajor = 0; // Will be updated after reading the lib file
|
|
|
|
versionMinor = 0; // Will be updated after reading the lib file
|
2017-01-27 15:56:36 +00:00
|
|
|
m_buffering = false;
|
2009-12-15 21:11:05 +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
|
|
|
fileName = aFileName;
|
|
|
|
|
|
|
|
if( !fileName.IsOk() )
|
2016-10-24 23:18:50 +00:00
|
|
|
fileName = "unnamed.lib";
|
2017-01-27 15:56:36 +00:00
|
|
|
|
|
|
|
m_plugin.reset( SCH_IO_MGR::FindPlugin( m_pluginType ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +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
|
|
|
PART_LIB::~PART_LIB()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::Save( bool aSaveDocFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
wxCHECK_RET( m_plugin != NULL, wxString::Format( "no plugin defined for library `%s`.",
|
|
|
|
fileName.GetFullPath() ) );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
std::unique_ptr< PROPERTIES > props;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !aSaveDocFile )
|
2015-04-16 15:26:51 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
props.reset( new PROPERTIES );
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->SaveLibrary( fileName.GetFullPath(), props.get() );
|
2017-02-13 18:47:18 +00:00
|
|
|
isModified = false;
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::Create( const wxString& aFileName )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
std::unique_ptr< PROPERTIES > props;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache )
|
2014-01-29 18:02:02 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
props.reset( new PROPERTIES );
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2014-01-29 18:02:02 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
wxString tmpFileName = fileName.GetFullPath();
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !aFileName.IsEmpty() )
|
|
|
|
tmpFileName = aFileName;
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->CreateSymbolLib( tmpFileName, props.get() );
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::SetPluginType( SCH_IO_MGR::SCH_FILE_T aPluginType )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
if( m_pluginType != aPluginType )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
m_pluginType = aPluginType;
|
|
|
|
m_plugin.reset( SCH_IO_MGR::FindPlugin( m_pluginType ) );
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::GetAliasNames( wxArrayString& aNames )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->EnumerateSymbolLib( aNames, fileName.GetFullPath() );
|
2010-02-13 13:16:09 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
aNames.Sort();
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
wxArrayString aliases;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
for( size_t i = 0; i < aliases.GetCount(); i++ )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aliases[i] );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
wxCHECK2_MSG( alias != NULL, continue,
|
|
|
|
wxString::Format( "alias '%s' not found in symbol library '%s'",
|
|
|
|
aliases[i], fileName.GetFullPath() ) );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_PART* root = alias->GetPart();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !root || !root->IsPower() )
|
|
|
|
continue;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
aNames.Add( aliases[i] );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
aNames.Sort();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-02-13 18:47:18 +00:00
|
|
|
std::unique_ptr< PROPERTIES > props;
|
|
|
|
|
|
|
|
if( isCache || m_buffering )
|
|
|
|
{
|
|
|
|
props.reset( new PROPERTIES );
|
|
|
|
|
|
|
|
if( isCache )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
|
|
|
|
|
|
|
if( m_buffering )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_plugin->LoadSymbol( fileName.GetFullPath(), aName, props.get() );
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_PART* PART_LIB::FindPart( const wxString& aName )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_ALIAS* alias = FindAlias( aName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( alias != NULL )
|
|
|
|
return alias->GetPart();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
return NULL;
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
bool PART_LIB::HasPowerParts()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
// return true if at least one power part is found in lib
|
|
|
|
wxArrayString aliases;
|
|
|
|
|
|
|
|
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
for( size_t i = 0; i < aliases.GetCount(); i++ )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aliases[i] );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
wxCHECK2_MSG( alias != NULL, continue,
|
|
|
|
wxString::Format( "alias '%s' not found in symbol library '%s'",
|
|
|
|
aliases[i], fileName.GetFullPath() ) );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_PART* root = alias->GetPart();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !root || root->IsPower() )
|
2011-10-07 14:41:30 +00:00
|
|
|
return true;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
void PART_LIB::AddPart( LIB_PART* aPart )
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
std::unique_ptr< PROPERTIES > props;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache || m_buffering )
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
props.reset( new PROPERTIES );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( m_buffering )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
2009-09-02 18:12:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
// add a clone, not the caller's copy, the plugin take ownership of the new symbol.
|
|
|
|
m_plugin->SaveSymbol( fileName.GetFullPath(), new LIB_PART( *aPart, this ), props.get() );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
// If we are not buffering, the library file is updated immediately when the plugin
|
|
|
|
// SaveSymbol() function is called.
|
|
|
|
if( m_buffering )
|
|
|
|
isModified = true;
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
++m_mod_hash;
|
2009-09-02 18:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_ALIAS* PART_LIB::RemoveAlias( LIB_ALIAS* aEntry )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
wxCHECK_MSG( aEntry != NULL, NULL, "NULL pointer cannot be removed from library." );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
std::unique_ptr< PROPERTIES > props;
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache || m_buffering )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
props.reset( new PROPERTIES );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( m_buffering )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
2011-11-01 15:06:26 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->DeleteAlias( fileName.GetFullPath(), aEntry->GetName(), props.get() );
|
|
|
|
|
|
|
|
// If we are not buffering, the library file is updated immediately when the plugin
|
|
|
|
// SaveSymbol() function is called.
|
|
|
|
if( m_buffering )
|
|
|
|
isModified = true;
|
|
|
|
|
|
|
|
++m_mod_hash;
|
|
|
|
return NULL;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_PART* PART_LIB::ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
wxASSERT( aOldPart != NULL );
|
|
|
|
wxASSERT( aNewPart != NULL );
|
|
|
|
|
|
|
|
std::unique_ptr< PROPERTIES > props;
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache || m_buffering )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
props.reset( new PROPERTIES );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( isCache )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( m_buffering )
|
|
|
|
(*props.get())[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
2011-11-11 20:10:24 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->DeleteSymbol( fileName.GetFullPath(), aOldPart->GetName(), props.get() );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
LIB_PART* my_part = new LIB_PART( *aNewPart, this );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
m_plugin->SaveSymbol( fileName.GetFullPath(), my_part, props.get() );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
// If we are not buffering, the library file is updated immediately when the plugin
|
|
|
|
// SaveSymbol() function is called.
|
|
|
|
if( m_buffering )
|
|
|
|
isModified = true;
|
2011-11-01 15:06:26 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
++m_mod_hash;
|
|
|
|
return my_part;
|
2009-09-02 18:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2016-06-07 15:33:12 +00:00
|
|
|
std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2016-08-18 23:23:10 +00:00
|
|
|
wxArrayString tmp;
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
// This loads the library although we could probably do lazy loading.
|
2017-01-28 21:59:09 +00:00
|
|
|
lib->GetAliasNames( tmp );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2017-01-28 21:59:09 +00:00
|
|
|
// This not them most efficient way to set the LIB_PART m_library member but it will
|
|
|
|
// only be used when loading legacy libraries in the future. Once the symbols in the
|
|
|
|
// schematic have a full #LIB_ID, this will not get called.
|
|
|
|
for( size_t i = 0; i < tmp.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* alias = lib->FindAlias( tmp[i] );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2017-01-28 21:59:09 +00:00
|
|
|
if( alias && alias->GetPart() )
|
|
|
|
alias->GetPart()->SetLib( lib.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
PART_LIB* ret = lib.release();
|
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
|
|
|
return ret;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName ) throw( IO_ERROR, boost::bad_pointer )
|
2009-09-18 14:56:05 +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
|
|
|
PART_LIB* lib;
|
|
|
|
|
|
|
|
wxFileName fn = aFileName;
|
|
|
|
// Don't reload the library if it is already loaded.
|
|
|
|
lib = FindLibrary( fn.GetName() );
|
2016-08-18 23:23:10 +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
|
|
|
if( lib )
|
|
|
|
return lib;
|
2009-09-18 14:56:05 +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
|
|
|
lib = PART_LIB::LoadLibrary( aFileName );
|
2009-09-18 14:56:05 +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
|
|
|
push_back( lib );
|
2009-09-18 14:56:05 +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
|
|
|
return lib;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-28 20:50:35 +00:00
|
|
|
PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator )
|
|
|
|
throw( IO_ERROR, boost::bad_pointer )
|
2009-09-18 14:56:05 +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
|
|
|
// Don't reload the library if it is already loaded.
|
|
|
|
wxFileName fn( aFileName );
|
|
|
|
PART_LIB* lib = FindLibrary( fn.GetName() );
|
2009-09-18 14:56:05 +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
|
|
|
if( lib )
|
|
|
|
return lib;
|
2009-09-18 14:56:05 +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
|
|
|
lib = PART_LIB::LoadLibrary( aFileName );
|
2009-09-18 14:56:05 +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
|
|
|
if( aIterator >= begin() && aIterator < end() )
|
|
|
|
insert( aIterator, lib );
|
2009-09-18 14:56:05 +00:00
|
|
|
else
|
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
|
|
|
push_back( lib );
|
2009-09-18 14:56:05 +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
|
|
|
return lib;
|
2009-09-18 14:56:05 +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
|
|
|
PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
|
2009-12-22 20:08:56 +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
|
|
|
for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
|
|
|
|
{
|
2014-08-19 17:26:20 +00:00
|
|
|
if( it->GetName() == aName )
|
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
|
|
|
return &*it;
|
|
|
|
}
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2017-02-13 18:47:18 +00:00
|
|
|
PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
|
|
|
|
{
|
|
|
|
for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
|
|
|
|
{
|
|
|
|
if( it->GetFullFileName() == aFullFileName )
|
|
|
|
return &*it;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
wxArrayString PART_LIBS::GetLibraryNames( bool aSorted )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2013-01-24 17:46:37 +00:00
|
|
|
wxArrayString cacheNames;
|
2009-09-18 14:56:05 +00:00
|
|
|
wxArrayString names;
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( PART_LIB& lib : *this )
|
2009-09-18 14:56:05 +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
|
|
|
if( lib.IsCache() && aSorted )
|
2013-01-24 17:46:37 +00:00
|
|
|
cacheNames.Add( lib.GetName() );
|
2009-09-18 14:56:05 +00:00
|
|
|
else
|
|
|
|
names.Add( lib.GetName() );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Even sorted, the cache library is always at the end of the list.
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aSorted )
|
2009-09-18 14:56:05 +00:00
|
|
|
names.Sort();
|
|
|
|
|
2013-01-24 17:46:37 +00:00
|
|
|
for( unsigned int i = 0; i<cacheNames.Count(); i++ )
|
|
|
|
names.Add( cacheNames.Item( i ) );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-31 01:31:19 +00:00
|
|
|
LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName )
|
2009-09-18 14:56:05 +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
|
|
|
LIB_PART* part = NULL;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( PART_LIB& lib : *this )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
|
2009-09-18 14:56:05 +00:00
|
|
|
continue;
|
|
|
|
|
2017-01-31 01:31:19 +00:00
|
|
|
part = lib.FindPart( aLibId.GetLibItemName() );
|
2009-09-18 14:56:05 +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
|
|
|
if( part )
|
2009-09-18 14:56:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
return part;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-31 01:31:19 +00:00
|
|
|
LIB_ALIAS* PART_LIBS::FindLibraryAlias( const LIB_ID& aLibId, const wxString& aLibraryName )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
LIB_ALIAS* entry = NULL;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( PART_LIB& lib : *this )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
|
2009-09-18 14:56:05 +00:00
|
|
|
continue;
|
|
|
|
|
2017-01-31 01:31:19 +00:00
|
|
|
entry = lib.FindAlias( aLibId.GetLibItemName() );
|
2009-09-18 14:56:05 +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
|
|
|
if( entry )
|
2009-09-18 14:56:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2015-04-25 22:26:51 +00:00
|
|
|
|
2014-09-14 15:43:18 +00:00
|
|
|
/* searches all libraries in the list for an entry, using a case insensitive comparison.
|
|
|
|
* Used to find an entry, when the normal (case sensitive) search fails.
|
|
|
|
*/
|
2014-09-17 16:04:04 +00:00
|
|
|
void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_ALIAS*>& aCandidates,
|
|
|
|
const wxString& aEntryName,
|
|
|
|
const wxString& aLibraryName )
|
2014-09-14 15:43:18 +00:00
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( PART_LIB& lib : *this )
|
2014-09-14 15:43:18 +00:00
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
|
2014-09-14 15:43:18 +00:00
|
|
|
continue;
|
|
|
|
|
2016-10-14 23:26:48 +00:00
|
|
|
wxArrayString aliasNames;
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2016-10-14 23:26:48 +00:00
|
|
|
lib.GetAliasNames( aliasNames );
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2016-10-14 23:26:48 +00:00
|
|
|
if( aliasNames.IsEmpty() )
|
|
|
|
continue;
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2016-10-14 23:26:48 +00:00
|
|
|
for( size_t i = 0; i < aliasNames.size(); i++ )
|
2014-09-14 15:43:18 +00:00
|
|
|
{
|
2016-10-14 23:26:48 +00:00
|
|
|
if( aliasNames[i].CmpNoCase( aEntryName ) == 0 )
|
|
|
|
aCandidates.push_back( lib.FindAlias( aliasNames[i] ) );
|
2014-09-14 15:43:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +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
|
|
|
int PART_LIBS::s_modify_generation = 1; // starts at 1 and goes up
|
|
|
|
|
|
|
|
|
|
|
|
int PART_LIBS::GetModifyHash()
|
|
|
|
{
|
|
|
|
int hash = 0;
|
|
|
|
|
|
|
|
for( PART_LIBS::const_iterator it = begin(); it != end(); ++it )
|
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
hash += it->GetModHash();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
|
2015-02-17 18:47:21 +00:00
|
|
|
wxString* aPaths, wxArrayString* aNames )
|
|
|
|
throw( IO_ERROR, boost::bad_pointer )
|
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 pro = aProject->GetProjectFullName();
|
|
|
|
|
|
|
|
PARAM_CFG_ARRAY ca;
|
|
|
|
|
|
|
|
if( aPaths )
|
2016-10-24 23:18:50 +00:00
|
|
|
ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
|
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
|
|
|
|
|
|
|
if( aNames )
|
|
|
|
ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
|
|
|
|
|
|
|
|
if( doSave )
|
|
|
|
{
|
|
|
|
aProject->ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, ca );
|
|
|
|
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _(
|
|
|
|
"Unable save project's '%s' file" ),
|
|
|
|
GetChars( pro )
|
|
|
|
);
|
|
|
|
THROW_IO_ERROR( msg );
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !aProject->ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, ca ) )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _(
|
|
|
|
"Unable to load project's '%s' file" ),
|
|
|
|
GetChars( pro )
|
|
|
|
);
|
|
|
|
THROW_IO_ERROR( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
|
2009-09-18 14:56:05 +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
|
|
|
/* until apr 2009 the project cache lib was named: <root_name>.cache.lib,
|
|
|
|
* and after: <root_name>-cache.lib. So if the <name>-cache.lib is not found,
|
|
|
|
* the old file will be renamed and returned.
|
|
|
|
*/
|
|
|
|
wxFileName new_name = aFullProjectFilename;
|
|
|
|
|
2016-10-24 23:18:50 +00:00
|
|
|
new_name.SetName( new_name.GetName() + "-cache" );
|
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
|
|
|
new_name.SetExt( SchematicLibraryFileExtension );
|
2009-09-18 14:56:05 +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
|
|
|
if( new_name.FileExists() )
|
|
|
|
return new_name.GetFullPath();
|
|
|
|
else
|
2009-09-18 14:56:05 +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
|
|
|
wxFileName old_name = aFullProjectFilename;
|
2016-10-24 23:18:50 +00:00
|
|
|
old_name.SetExt( "cache.lib" );
|
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
|
|
|
|
|
|
|
if( old_name.FileExists() )
|
|
|
|
{
|
|
|
|
wxRenameFile( old_name.GetFullPath(), new_name.GetFullPath() );
|
|
|
|
return new_name.GetFullPath();
|
|
|
|
}
|
2009-09-18 14:56:05 +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
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-12 01:14:45 +00:00
|
|
|
void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
|
|
|
|
throw( IO_ERROR, boost::bad_pointer )
|
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 filename;
|
|
|
|
wxString libs_not_found;
|
|
|
|
SEARCH_STACK* lib_search = aProject->SchSearchS();
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
#if defined(DEBUG) && 0
|
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
|
|
|
lib_search->Show( __func__ );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxArrayString lib_names;
|
|
|
|
|
|
|
|
LibNamesAndPaths( aProject, false, NULL, &lib_names );
|
|
|
|
|
|
|
|
// If the list is empty, force loading the standard power symbol library.
|
|
|
|
if( !lib_names.GetCount() )
|
2016-10-24 23:18:50 +00:00
|
|
|
lib_names.Add( "power" );
|
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
|
|
|
|
|
|
|
wxASSERT( !size() ); // expect to load into "this" empty container.
|
|
|
|
|
2017-02-18 00:31:47 +00:00
|
|
|
wxProgressDialog lib_dialog( _( "Loading Symbol Libraries" ),
|
2017-02-02 05:48:29 +00:00
|
|
|
wxEmptyString,
|
|
|
|
lib_names.GetCount(),
|
|
|
|
NULL,
|
|
|
|
wxPD_APP_MODAL );
|
|
|
|
|
|
|
|
if( aShowProgress )
|
|
|
|
{
|
|
|
|
lib_dialog.Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString progress_message;
|
|
|
|
|
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
|
|
|
for( unsigned i = 0; i < lib_names.GetCount(); ++i )
|
|
|
|
{
|
2017-02-02 05:48:29 +00:00
|
|
|
if( aShowProgress )
|
|
|
|
{
|
|
|
|
lib_dialog.Update( i, _( "Loading " + lib_names[i] ) );
|
|
|
|
}
|
|
|
|
|
2016-11-14 12:12:33 +00:00
|
|
|
wxFileName fn = lib_names[i];
|
|
|
|
// lib_names[] does not store the file extension. Set it:
|
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
|
|
|
fn.SetExt( SchematicLibraryFileExtension );
|
2016-11-14 12:12:33 +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
|
|
|
// Skip if the file name is not valid..
|
|
|
|
if( !fn.IsOk() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
|
|
|
filename = lib_search->FindValidPath( fn.GetFullPath() );
|
|
|
|
|
|
|
|
if( !filename )
|
|
|
|
{
|
2016-11-14 12:12:33 +00:00
|
|
|
libs_not_found += fn.GetFullPath();
|
2016-10-24 23:18:50 +00:00
|
|
|
libs_not_found += '\n';
|
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
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-11-10 16:47:53 +00:00
|
|
|
{ // ensure the lib filename has a absolute path.
|
|
|
|
// If the lib has no absolute path, and is found in the cwd by fn.FileExists(),
|
|
|
|
// make a full absolute path, to avoid issues with load library functions which
|
|
|
|
// expects an absolute path.
|
|
|
|
if( !fn.IsAbsolute() )
|
2016-11-14 12:12:33 +00:00
|
|
|
fn.MakeAbsolute();
|
2016-11-10 16:47:53 +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
|
|
|
filename = fn.GetFullPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
AddLibrary( filename );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2017-01-27 15:56:36 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Part library '%s' failed to load. Error:\n %s" ),
|
|
|
|
GetChars( filename ), GetChars( ioe.What() ) );
|
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
|
|
|
|
2016-09-23 18:15:41 +00:00
|
|
|
wxLogError( msg );
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-02 05:48:29 +00:00
|
|
|
if( aShowProgress )
|
|
|
|
{
|
|
|
|
lib_dialog.Destroy();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// add the special cache library.
|
|
|
|
wxString cache_name = CacheName( aProject->GetProjectFullName() );
|
2015-04-25 22:26:51 +00:00
|
|
|
PART_LIB* cache_lib;
|
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !cache_name.IsEmpty() )
|
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
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-04-25 22:26:51 +00:00
|
|
|
cache_lib = AddLibrary( cache_name );
|
2016-08-18 23:23:10 +00:00
|
|
|
|
2015-04-25 22:26:51 +00:00
|
|
|
if( cache_lib )
|
|
|
|
cache_lib->SetCache();
|
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
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _(
|
|
|
|
"Part library '%s' failed to load.\nError: %s" ),
|
|
|
|
GetChars( cache_name ),
|
2016-09-14 22:36:45 +00:00
|
|
|
GetChars( ioe.What() )
|
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
|
|
|
);
|
|
|
|
|
|
|
|
THROW_IO_ERROR( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the libraries not found
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !libs_not_found.IsEmpty() )
|
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
|
|
|
{
|
|
|
|
// Use a different exception type so catch()er can route to proper use
|
|
|
|
// of the HTML_MESSAGE_BOX.
|
2017-01-27 15:56:36 +00:00
|
|
|
THROW_PARSE_ERROR( wxEmptyString, UTF8( __func__ ), UTF8( libs_not_found ), 0, 0 );
|
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
|
|
|
}
|
|
|
|
|
2017-02-16 01:28:36 +00:00
|
|
|
#if defined(DEBUG) && 1
|
2014-08-19 17:26:20 +00:00
|
|
|
printf( "%s: lib_names:\n", __func__ );
|
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
|
|
|
|
|
|
|
for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
|
|
|
|
printf( " %s\n", TO_UTF8( it->GetName() ) );
|
|
|
|
#endif
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|