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-11-01 00:57:57 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-12-08 23:56:55 +00:00
|
|
|
* Copyright (C) 2022 CERN
|
2023-03-23 17:26:32 +00:00
|
|
|
* Copyright (C) 2004-2023 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
|
|
|
|
*/
|
|
|
|
|
2017-02-24 16:09:27 +00:00
|
|
|
#include <algorithm>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <eda_base_frame.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#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 <wildcards_and_files_ext.h>
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <project/project_file.h>
|
2015-06-22 15:38:54 +00:00
|
|
|
#include <project_rescue.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2022-11-06 16:51:52 +00:00
|
|
|
#include <string_utf8_map.h>
|
2020-08-09 10:55:00 +00:00
|
|
|
#include <widgets/app_progress_dialog.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-06-15 13:24:55 +00:00
|
|
|
#include <symbol_library.h>
|
2020-10-05 18:38:40 +00:00
|
|
|
#include <sch_plugins/legacy/sch_legacy_plugin.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-06-03 12:11:15 +00:00
|
|
|
#include <wx/log.h>
|
2017-02-02 05:48:29 +00:00
|
|
|
#include <wx/progdlg.h>
|
2009-09-18 14:56:05 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2022-12-08 23:56:55 +00:00
|
|
|
#include "sim/sim_model.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB::SYMBOL_LIB( SCH_LIB_TYPE aType, const wxString& aFileName,
|
2022-02-07 20:40:21 +00:00
|
|
|
SCH_IO_MGR::SCH_FILE_T aPluginType ) :
|
2017-01-27 15:56:36 +00:00
|
|
|
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;
|
|
|
|
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
|
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 ) );
|
2022-11-06 16:51:52 +00:00
|
|
|
m_properties = std::make_unique<STRING_UTF8_MAP>();
|
2022-03-25 19:51:05 +00:00
|
|
|
m_mod_hash = 0;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB::~SYMBOL_LIB()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::Save( bool aSaveDocFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2022-02-07 20:40:21 +00:00
|
|
|
wxCHECK_RET( m_plugin != nullptr,
|
|
|
|
wxString::Format( wxT( "no plugin defined for library `%s`." ),
|
|
|
|
fileName.GetFullPath() ) );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2022-11-06 16:51:52 +00:00
|
|
|
STRING_UTF8_MAP props;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-01-27 15:56:36 +00:00
|
|
|
if( !aSaveDocFile )
|
2017-02-28 09:17:11 +00:00
|
|
|
props[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2017-02-28 09:17:11 +00:00
|
|
|
m_plugin->SaveLibrary( fileName.GetFullPath(), &props );
|
2017-02-13 18:47:18 +00:00
|
|
|
isModified = false;
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::Create( const wxString& aFileName )
|
2009-08-27 11:41:56 +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-02-28 09:17:11 +00:00
|
|
|
m_plugin->CreateSymbolLib( tmpFileName, m_properties.get() );
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
bool SYMBOL_LIB::IsCache() const
|
2017-02-28 09:17:11 +00:00
|
|
|
{
|
|
|
|
return m_properties->Exists( SCH_LEGACY_PLUGIN::PropNoDocFile );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::SetCache()
|
2017-02-28 09:17:11 +00:00
|
|
|
{
|
|
|
|
(*m_properties)[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
bool SYMBOL_LIB::IsBuffering() const
|
2017-02-28 09:17:11 +00:00
|
|
|
{
|
|
|
|
return m_properties->Exists( SCH_LEGACY_PLUGIN::PropBuffering );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::EnableBuffering( bool aEnable )
|
2017-02-28 09:17:11 +00:00
|
|
|
{
|
|
|
|
if( aEnable )
|
|
|
|
(*m_properties)[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
|
|
|
|
else
|
|
|
|
m_properties->Clear( SCH_LEGACY_PLUGIN::PropBuffering );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::GetSymbolNames( wxArrayString& aNames ) const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2017-02-28 10:06:04 +00:00
|
|
|
m_plugin->EnumerateSymbolLib( aNames, fileName.GetFullPath(), m_properties.get() );
|
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
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::GetSymbols( std::vector<LIB_SYMBOL*>& aSymbols ) const
|
2017-02-24 16:09:27 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
m_plugin->EnumerateSymbolLib( aSymbols, fileName.GetFullPath(), m_properties.get() );
|
2017-02-24 16:09:27 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
std::sort( aSymbols.begin(), aSymbols.end(),
|
2021-06-10 18:51:46 +00:00
|
|
|
[](LIB_SYMBOL *lhs, LIB_SYMBOL *rhs) -> bool
|
2021-08-18 21:16:17 +00:00
|
|
|
{
|
|
|
|
return lhs->GetName() < rhs->GetName();
|
|
|
|
} );
|
2017-02-24 16:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_LIB::FindSymbol( const wxString& aName ) const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* symbol = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() );
|
2017-03-09 23:33:39 +00:00
|
|
|
|
2022-12-08 23:56:55 +00:00
|
|
|
if( symbol )
|
|
|
|
{
|
|
|
|
// Set the library to this even though technically the legacy cache plugin owns the
|
|
|
|
// symbols. This allows the symbol library table conversion tool to determine the
|
|
|
|
// correct library where the symbol was found.
|
|
|
|
if( !symbol->GetLib() )
|
|
|
|
symbol->SetLib( const_cast<SYMBOL_LIB*>( this ) );
|
|
|
|
|
2022-12-14 13:00:25 +00:00
|
|
|
SIM_MODEL::MigrateSimModel<LIB_SYMBOL, LIB_FIELD>( *symbol, nullptr );
|
2022-12-08 23:56:55 +00:00
|
|
|
}
|
2017-12-07 23:01:03 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
return symbol;
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_LIB::FindSymbol( const LIB_ID& aLibId ) const
|
2017-12-07 23:01:03 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
return FindSymbol( aLibId.Format().wx_str() );
|
2017-12-07 23:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIB::AddSymbol( LIB_SYMBOL* aSymbol )
|
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.
|
2021-06-10 18:51:46 +00:00
|
|
|
m_plugin->SaveSymbol( fileName.GetFullPath(),
|
|
|
|
new LIB_SYMBOL( *aSymbol->SharedPtr().get(), this ),
|
2019-11-06 19:15:42 +00:00
|
|
|
m_properties.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.
|
2017-02-28 09:17:11 +00:00
|
|
|
if( IsBuffering() )
|
2017-01-27 15:56:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_LIB::RemoveSymbol( LIB_SYMBOL* aEntry )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
wxCHECK_MSG( aEntry != nullptr, nullptr, "NULL pointer cannot be removed from library." );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
m_plugin->DeleteSymbol( fileName.GetFullPath(), aEntry->GetName(), m_properties.get() );
|
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.
|
2017-02-28 09:17:11 +00:00
|
|
|
if( IsBuffering() )
|
2017-01-27 15:56:36 +00:00
|
|
|
isModified = true;
|
|
|
|
|
|
|
|
++m_mod_hash;
|
2021-06-10 18:51:46 +00:00
|
|
|
return nullptr;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_LIB::ReplaceSymbol( LIB_SYMBOL* aOldSymbol, LIB_SYMBOL* aNewSymbol )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
wxASSERT( aOldSymbol != nullptr );
|
|
|
|
wxASSERT( aNewSymbol != nullptr );
|
2017-01-27 15:56:36 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
m_plugin->DeleteSymbol( fileName.GetFullPath(), aOldSymbol->GetName(), m_properties.get() );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* my_part = new LIB_SYMBOL( *aNewSymbol, this );
|
2011-02-28 18:36:19 +00:00
|
|
|
|
2017-02-28 09:17:11 +00:00
|
|
|
m_plugin->SaveSymbol( fileName.GetFullPath(), my_part, m_properties.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.
|
2017-02-28 09:17:11 +00:00
|
|
|
if( IsBuffering() )
|
2017-01-27 15:56:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-09 08:36:58 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIB::LoadSymbolLibrary( const wxString& aFileName )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
std::unique_ptr<SYMBOL_LIB> lib = std::make_unique<SYMBOL_LIB>( SCH_LIB_TYPE::LT_EESCHEMA,
|
|
|
|
aFileName );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
std::vector<LIB_SYMBOL*> parts;
|
2017-03-10 19:53:09 +00:00
|
|
|
// This loads the library.
|
2021-06-15 12:31:28 +00:00
|
|
|
lib->GetSymbols( parts );
|
2016-08-18 23:23:10 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
// Now, set the LIB_SYMBOL m_library member but it will only be used
|
2017-03-10 19:53:09 +00:00
|
|
|
// when loading legacy libraries in the future. Once the symbols in the
|
2017-01-28 21:59:09 +00:00
|
|
|
// schematic have a full #LIB_ID, this will not get called.
|
2019-11-06 19:15:42 +00:00
|
|
|
for( size_t ii = 0; ii < parts.size(); ii++ )
|
2017-01-28 21:59:09 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* part = parts[ii];
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
part->SetLib( lib.get() );
|
2017-01-28 21:59:09 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_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
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIBS::AddLibrary( const wxString& aFileName )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* 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
|
|
|
|
|
|
|
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
|
|
|
|
2020-01-13 14:52:56 +00:00
|
|
|
try
|
|
|
|
{
|
2022-12-09 08:36:58 +00:00
|
|
|
lib = SYMBOL_LIB::LoadSymbolLibrary( aFileName );
|
2020-01-13 14:52:56 +00:00
|
|
|
push_back( lib );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2020-01-13 14:52:56 +00:00
|
|
|
return lib;
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIBS::AddLibrary( const wxString& aFileName, SYMBOL_LIBS::iterator& aIterator )
|
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 );
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_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
|
|
|
|
2020-01-13 14:52:56 +00:00
|
|
|
try
|
|
|
|
{
|
2022-12-09 08:36:58 +00:00
|
|
|
lib = SYMBOL_LIB::LoadSymbolLibrary( aFileName );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2020-01-13 14:52:56 +00:00
|
|
|
if( aIterator >= begin() && aIterator < end() )
|
|
|
|
insert( aIterator, lib );
|
|
|
|
else
|
|
|
|
push_back( lib );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2020-01-13 14:52:56 +00:00
|
|
|
return lib;
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
bool SYMBOL_LIBS::ReloadLibrary( const wxString &aFileName )
|
|
|
|
{
|
|
|
|
SYMBOL_LIB *lib;
|
|
|
|
wxFileName fn = aFileName;
|
|
|
|
|
|
|
|
// Check if the library already exists.
|
|
|
|
if( !( lib = FindLibrary( fn.GetName() ) ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Create a clone of the library pointer in case we need to re-add it
|
|
|
|
SYMBOL_LIB *cloneLib = lib;
|
|
|
|
|
|
|
|
// Try to find the iterator of the library
|
|
|
|
for( auto it = begin(); it != end(); ++it )
|
|
|
|
{
|
|
|
|
if( it->GetName() == fn.GetName() )
|
|
|
|
{
|
|
|
|
// Remove the old library and keep the pointer
|
|
|
|
lib = &*it;
|
|
|
|
release( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to reload the library
|
|
|
|
try
|
|
|
|
{
|
|
|
|
lib = SYMBOL_LIB::LoadSymbolLibrary( aFileName );
|
|
|
|
|
|
|
|
// If the library is successfully reloaded, add it back to the set.
|
|
|
|
push_back( lib );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
// If an exception occurs, ensure that the SYMBOL_LIBS remains unchanged
|
|
|
|
// by re-adding the old library back to the set.
|
|
|
|
push_back( cloneLib );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIBS::FindLibrary( const wxString& aName )
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++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
|
|
|
{
|
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
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
return nullptr;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIBS::GetCacheLibrary()
|
2017-09-01 20:42:20 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
|
2017-09-01 20:42:20 +00:00
|
|
|
{
|
|
|
|
if( it->IsCache() )
|
|
|
|
return &*it;
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
return nullptr;
|
2017-09-01 20:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* SYMBOL_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
|
2017-02-13 18:47:18 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
|
2017-02-13 18:47:18 +00:00
|
|
|
{
|
|
|
|
if( it->GetFullFileName() == aFullFileName )
|
|
|
|
return &*it;
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
return nullptr;
|
2017-02-13 18:47:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
wxArrayString SYMBOL_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;
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_LIBS::FindLibSymbol( const LIB_ID& aLibId, const wxString& aLibraryName )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* part = nullptr;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_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;
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
part = lib.FindSymbol( aLibId.GetLibItemName().wx_str() );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIBS::FindLibraryNearEntries( std::vector<LIB_SYMBOL*>& aCandidates,
|
|
|
|
const wxString& aEntryName,
|
|
|
|
const wxString& aLibraryName )
|
2014-09-14 15:43:18 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
for( SYMBOL_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;
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
wxArrayString partNames;
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
lib.GetSymbolNames( partNames );
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( partNames.IsEmpty() )
|
2016-10-14 23:26:48 +00:00
|
|
|
continue;
|
2014-09-14 15:43:18 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
for( size_t i = 0; i < partNames.size(); i++ )
|
2014-09-14 15:43:18 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
if( partNames[i].CmpNoCase( aEntryName ) == 0 )
|
2021-06-15 12:31:28 +00:00
|
|
|
aCandidates.push_back( lib.FindSymbol( partNames[i] ) );
|
2014-09-14 15:43:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2022-10-11 10:22:09 +00:00
|
|
|
void SYMBOL_LIBS::GetLibNamesAndPaths( PROJECT* aProject, wxString* aPaths, wxArrayString* aNames )
|
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
|
|
|
{
|
2022-10-11 10:22:09 +00:00
|
|
|
wxCHECK_RET( aProject, "Null PROJECT in GetLibNamesAndPaths" );
|
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
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
PROJECT_FILE& project = aProject->GetProjectFile();
|
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
|
|
|
|
2022-10-11 10:22:09 +00:00
|
|
|
if( aPaths )
|
|
|
|
*aPaths = project.m_LegacyLibDir;
|
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
|
|
|
|
2022-10-11 10:22:09 +00:00
|
|
|
if( aNames )
|
|
|
|
*aNames = project.m_LegacyLibNames;
|
|
|
|
}
|
2020-06-08 02:19:46 +00:00
|
|
|
|
2022-10-11 10:22:09 +00:00
|
|
|
|
|
|
|
void SYMBOL_LIBS::SetLibNamesAndPaths( PROJECT* aProject, const wxString& aPaths,
|
|
|
|
const wxArrayString& aNames )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( aProject, "Null PROJECT in SetLibNamesAndPaths" );
|
|
|
|
|
|
|
|
PROJECT_FILE& project = aProject->GetProjectFile();
|
|
|
|
|
|
|
|
project.m_LegacyLibDir = aPaths;
|
|
|
|
project.m_LegacyLibNames = aNames;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
const wxString SYMBOL_LIBS::CacheName( const wxString& aFullProjectFilename )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2018-03-20 22:44:04 +00:00
|
|
|
wxFileName name = aFullProjectFilename;
|
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
|
|
|
|
2018-03-20 22:44:04 +00:00
|
|
|
name.SetName( name.GetName() + "-cache" );
|
2020-05-15 13:25:11 +00:00
|
|
|
name.SetExt( LegacySymbolLibFileExtension );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2018-03-20 22:44:04 +00:00
|
|
|
if( name.FileExists() )
|
|
|
|
return name.GetFullPath();
|
2017-10-31 22:37:44 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
|
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;
|
2023-09-28 03:04:53 +00:00
|
|
|
SEARCH_STACK* lib_search = PROJECT_SCH::SchSearchS( aProject );
|
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-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;
|
|
|
|
|
2022-10-11 10:22:09 +00:00
|
|
|
GetLibNamesAndPaths( aProject, nullptr, &lib_names );
|
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-11-01 00:57:57 +00:00
|
|
|
// Post symbol library table, this should be empty. Only the cache library should get loaded.
|
2017-10-31 22:37:44 +00:00
|
|
|
if( !lib_names.empty() )
|
2017-02-02 05:48:29 +00:00
|
|
|
{
|
2020-08-09 10:55:00 +00:00
|
|
|
APP_PROGRESS_DIALOG lib_dialog( _( "Loading Symbol Libraries" ),
|
|
|
|
wxEmptyString,
|
|
|
|
lib_names.GetCount(),
|
2021-06-10 18:51:46 +00:00
|
|
|
nullptr,
|
2020-08-09 10:55:00 +00:00
|
|
|
false,
|
|
|
|
wxPD_APP_MODAL );
|
2017-02-02 05:48:29 +00:00
|
|
|
|
|
|
|
if( aShowProgress )
|
|
|
|
{
|
2017-10-31 22:37:44 +00:00
|
|
|
lib_dialog.Show();
|
2017-02-02 05:48:29 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 22:37:44 +00:00
|
|
|
for( unsigned i = 0; i < lib_names.GetCount(); ++i )
|
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-10-31 22:37:44 +00:00
|
|
|
if( aShowProgress )
|
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
|
|
|
{
|
2021-06-26 11:33:37 +00:00
|
|
|
lib_dialog.Update( i, wxString::Format( _( "Loading %s..." ), lib_names[i] ) );
|
2017-10-31 22:37:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// lib_names[] does not store the file extension. Set it.
|
|
|
|
// Remember lib_names[i] can contain a '.' in name, so using a wxFileName
|
|
|
|
// before adding the extension can create incorrect full filename
|
2020-05-15 13:25:11 +00:00
|
|
|
wxString fullname = lib_names[i] + "." + LegacySymbolLibFileExtension;
|
2017-10-31 22:37:44 +00:00
|
|
|
// Now the full name is set, we can use a wxFileName.
|
|
|
|
wxFileName fn( fullname );
|
|
|
|
|
|
|
|
// Skip if the file name is not valid..
|
|
|
|
if( !fn.IsOk() )
|
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;
|
2017-10-31 22:37:44 +00:00
|
|
|
|
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
|
|
|
filename = lib_search->FindValidPath( fn.GetFullPath() );
|
|
|
|
|
|
|
|
if( !filename )
|
|
|
|
{
|
|
|
|
libs_not_found += fn.GetFullPath();
|
|
|
|
libs_not_found += '\n';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // 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() )
|
|
|
|
fn.MakeAbsolute();
|
|
|
|
|
|
|
|
filename = fn.GetFullPath();
|
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-10-31 22:37:44 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
AddLibrary( filename );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
wxString msg;
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "Symbol library '%s' failed to load." ), filename );
|
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
|
|
|
|
2021-06-28 23:44:07 +00:00
|
|
|
wxLogError( msg + wxS( "\n" ) + ioe.What() );
|
2017-10-31 22:37:44 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the special cache library.
|
|
|
|
wxString cache_name = CacheName( aProject->GetProjectFullName() );
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* cache_lib;
|
2015-04-25 22:26:51 +00:00
|
|
|
|
2021-04-19 01:53:38 +00:00
|
|
|
if( !aProject->IsNullProject() && !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 )
|
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
wxString msg = wxString::Format( _( "Error loading symbol library '%s'." )
|
|
|
|
+ wxS( "\n%s" ),
|
|
|
|
cache_name,
|
|
|
|
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-10-31 22:37:44 +00:00
|
|
|
THROW_PARSE_ERROR( wxEmptyString, __func__, TO_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
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|