mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-03-30 05:46:55 +00:00
Reduce cover types.
Also, don't use _ITEM for things that aren't EDA::ITEMs.
This commit is contained in:
parent
fea659a002
commit
bf34fe625c
@ -68,18 +68,16 @@ public:
|
||||
std::unique_ptr<MARKUP::NODE> root;
|
||||
};
|
||||
|
||||
typedef std::pair<wxString, ENTRY> CACHE_ENTRY;
|
||||
|
||||
MARKUP_CACHE( size_t aMaxSize ) :
|
||||
m_maxSize( aMaxSize )
|
||||
{
|
||||
}
|
||||
|
||||
ENTRY& Put( const CACHE_ENTRY::first_type& aQuery, ENTRY&& aResult )
|
||||
ENTRY& Put( const wxString& aQuery, ENTRY&& aResult )
|
||||
{
|
||||
auto it = m_cache.find( aQuery );
|
||||
|
||||
m_cacheMru.emplace_front( CACHE_ENTRY( aQuery, std::move( aResult ) ) );
|
||||
m_cacheMru.emplace_front( std::make_pair( aQuery, std::move( aResult ) ) );
|
||||
|
||||
if( it != m_cache.end() )
|
||||
{
|
||||
@ -100,7 +98,7 @@ public:
|
||||
return m_cacheMru.begin()->second;
|
||||
}
|
||||
|
||||
ENTRY* Get( const CACHE_ENTRY::first_type& aQuery )
|
||||
ENTRY* Get( const wxString& aQuery )
|
||||
{
|
||||
auto it = m_cache.find( aQuery );
|
||||
|
||||
@ -119,9 +117,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_maxSize;
|
||||
std::list<CACHE_ENTRY> m_cacheMru;
|
||||
std::unordered_map<wxString, std::list<CACHE_ENTRY>::iterator> m_cache;
|
||||
size_t m_maxSize;
|
||||
std::list<std::pair<wxString, ENTRY>> m_cacheMru;
|
||||
std::unordered_map<wxString, std::list<std::pair<wxString, ENTRY>>::iterator> m_cache;
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,23 +31,16 @@
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <project_rescue.h>
|
||||
#include <project_sch.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <schematic.h>
|
||||
#include <string_utils.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <project_sch.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
|
||||
|
||||
typedef std::pair<SCH_SYMBOL*, wxString> SYMBOL_NAME_PAIR;
|
||||
|
||||
|
||||
// Helper sort function, used in getSymbols, to sort a symbol list by lib_id
|
||||
static bool sort_by_libid( const SCH_SYMBOL* ref, SCH_SYMBOL* cmp )
|
||||
{
|
||||
@ -138,8 +131,7 @@ RESCUE_CASE_CANDIDATE::RESCUE_CASE_CANDIDATE( const wxString& aRequestedName,
|
||||
void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
|
||||
{
|
||||
typedef std::map<wxString, RESCUE_CASE_CANDIDATE> candidate_map_t;
|
||||
candidate_map_t candidate_map;
|
||||
std::map<wxString, RESCUE_CASE_CANDIDATE> candidate_map;
|
||||
|
||||
// Remember the list of symbols is sorted by symbol name.
|
||||
// So a search in libraries is made only once by group
|
||||
@ -169,16 +161,14 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
|
||||
// If the case sensitive match failed, try a case insensitive match.
|
||||
PROJECT_SCH::SchLibs( aRescuer.GetPrj() )
|
||||
->FindLibraryNearEntries( case_insensitive_matches,
|
||||
symbol_name );
|
||||
->FindLibraryNearEntries( case_insensitive_matches, symbol_name );
|
||||
|
||||
// If there are not case insensitive matches either, the symbol cannot be rescued.
|
||||
if( !case_insensitive_matches.size() )
|
||||
continue;
|
||||
|
||||
RESCUE_CASE_CANDIDATE candidate( symbol_name, case_insensitive_matches[0]->GetName(),
|
||||
case_insensitive_matches[0],
|
||||
eachSymbol->GetUnit(),
|
||||
case_insensitive_matches[0], eachSymbol->GetUnit(),
|
||||
eachSymbol->GetBodyStyle() );
|
||||
|
||||
candidate_map[symbol_name] = candidate;
|
||||
@ -186,10 +176,8 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
}
|
||||
|
||||
// Now, dump the map into aCandidates
|
||||
for( const candidate_map_t::value_type& each_pair : candidate_map )
|
||||
{
|
||||
aCandidates.push_back( new RESCUE_CASE_CANDIDATE( each_pair.second ) );
|
||||
}
|
||||
for( const auto& [ name, candidate ] : candidate_map )
|
||||
aCandidates.push_back( new RESCUE_CASE_CANDIDATE( candidate ) );
|
||||
}
|
||||
|
||||
|
||||
@ -252,8 +240,7 @@ RESCUE_CACHE_CANDIDATE::RESCUE_CACHE_CANDIDATE()
|
||||
void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
|
||||
{
|
||||
typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t;
|
||||
candidate_map_t candidate_map;
|
||||
std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map;
|
||||
|
||||
// Remember the list of symbols is sorted by symbol name.
|
||||
// So a search in libraries is made only once by group
|
||||
@ -280,18 +267,19 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
// the LIB_NICKNAME_LIB_SYMBOL_NAME case.
|
||||
if( !cache_match && eachSymbol->GetLibId().IsValid() )
|
||||
{
|
||||
wxString tmp;
|
||||
|
||||
tmp = eachSymbol->GetLibId().GetLibNickname().wx_str() + wxT( "_" ) +
|
||||
eachSymbol->GetLibId().GetLibItemName().wx_str();
|
||||
wxString tmp = wxString::Format( wxT( "%s-%s" ),
|
||||
eachSymbol->GetLibId().GetLibNickname().wx_str(),
|
||||
eachSymbol->GetLibId().GetLibItemName().wx_str() );
|
||||
cache_match = findSymbol( tmp, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), true );
|
||||
}
|
||||
|
||||
// Test whether there is a conflict or if the symbol can only be found in the cache
|
||||
// and the symbol name does not have any illegal characters.
|
||||
if( cache_match && lib_match &&
|
||||
!cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) )
|
||||
if( cache_match && lib_match
|
||||
&& !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !cache_match && lib_match )
|
||||
continue;
|
||||
@ -305,10 +293,8 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
}
|
||||
|
||||
// Now, dump the map into aCandidates
|
||||
for( const candidate_map_t::value_type& each_pair : candidate_map )
|
||||
{
|
||||
aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( each_pair.second ) );
|
||||
}
|
||||
for( const auto& [name, candidate] : candidate_map )
|
||||
aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( candidate ) );
|
||||
}
|
||||
|
||||
|
||||
@ -317,14 +303,23 @@ wxString RESCUE_CACHE_CANDIDATE::GetActionDescription() const
|
||||
wxString action;
|
||||
|
||||
if( !m_cache_candidate && !m_lib_candidate )
|
||||
{
|
||||
action.Printf( _( "Cannot rescue symbol %s which is not available in any library or "
|
||||
"the cache." ), m_requested_name );
|
||||
"the cache." ),
|
||||
m_requested_name );
|
||||
}
|
||||
else if( m_cache_candidate && !m_lib_candidate )
|
||||
{
|
||||
action.Printf( _( "Rescue symbol %s found only in cache library to %s." ),
|
||||
m_requested_name, m_new_name );
|
||||
m_requested_name,
|
||||
m_new_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
action.Printf( _( "Rescue modified symbol %s to %s" ),
|
||||
m_requested_name, m_new_name );
|
||||
m_requested_name,
|
||||
m_new_name );
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
@ -359,13 +354,12 @@ bool RESCUE_CACHE_CANDIDATE::PerformAction( RESCUER* aRescuer )
|
||||
}
|
||||
|
||||
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(
|
||||
const LIB_ID& aRequestedId,
|
||||
const LIB_ID& aNewId,
|
||||
LIB_SYMBOL* aCacheCandidate,
|
||||
LIB_SYMBOL* aLibCandidate,
|
||||
int aUnit,
|
||||
int aConvert ) : RESCUE_CANDIDATE()
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ID& aRequestedId,
|
||||
const LIB_ID& aNewId,
|
||||
LIB_SYMBOL* aCacheCandidate,
|
||||
LIB_SYMBOL* aLibCandidate,
|
||||
int aUnit, int aConvert ) :
|
||||
RESCUE_CANDIDATE()
|
||||
{
|
||||
m_requested_id = aRequestedId;
|
||||
m_requested_name = aRequestedId.Format().wx_str();
|
||||
@ -384,13 +378,10 @@ RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE()
|
||||
}
|
||||
|
||||
|
||||
void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
||||
RESCUER& aRescuer,
|
||||
boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
|
||||
void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
||||
boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
|
||||
{
|
||||
typedef std::map<LIB_ID, RESCUE_SYMBOL_LIB_TABLE_CANDIDATE> candidate_map_t;
|
||||
|
||||
candidate_map_t candidate_map;
|
||||
std::map<LIB_ID, RESCUE_SYMBOL_LIB_TABLE_CANDIDATE> candidate_map;
|
||||
|
||||
// Remember the list of symbols is sorted by LIB_ID.
|
||||
// So a search in libraries is made only once by group
|
||||
@ -421,8 +412,9 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
||||
// the LIB_NICKNAME_LIB_SYMBOL_NAME case.
|
||||
if( !cache_match )
|
||||
{
|
||||
symbolName = symbol_id.GetLibNickname().wx_str() + wxT( "_" ) +
|
||||
symbol_id.GetLibItemName().wx_str();
|
||||
symbolName.Printf( wxT( "%s-%s" ),
|
||||
symbol_id.GetLibNickname().wx_str(),
|
||||
symbol_id.GetLibItemName().wx_str() );
|
||||
cache_match = findSymbol( symbolName, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ),
|
||||
true );
|
||||
}
|
||||
@ -450,8 +442,8 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
||||
// Test whether there is a conflict or if the symbol can only be found in the cache.
|
||||
if( LIB_ID::HasIllegalChars( symbol_id.GetLibItemName() ) == -1 )
|
||||
{
|
||||
if( cache_match && lib_match &&
|
||||
!cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) )
|
||||
if( cache_match && lib_match
|
||||
&& !cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -468,8 +460,9 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
||||
// library.
|
||||
wxString libNickname = GetRescueLibraryFileName( aRescuer.Schematic() ).GetName();
|
||||
|
||||
LIB_ID new_id( libNickname, new_name + wxS( "-" ) +
|
||||
symbol_id.GetLibNickname().wx_str() );
|
||||
LIB_ID new_id( libNickname, wxString::Format( wxT( "%s-%s" ),
|
||||
new_name,
|
||||
symbol_id.GetLibNickname().wx_str() ) );
|
||||
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE candidate( symbol_id, new_id, cache_match, lib_match,
|
||||
eachSymbol->GetUnit(),
|
||||
@ -480,10 +473,8 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
||||
}
|
||||
|
||||
// Now, dump the map into aCandidates
|
||||
for( const candidate_map_t::value_type& each_pair : candidate_map )
|
||||
{
|
||||
aCandidates.push_back( new RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( each_pair.second ) );
|
||||
}
|
||||
for( const auto& [name, candidate] : candidate_map )
|
||||
aCandidates.push_back( new RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( candidate ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,13 +107,16 @@ static inline long parseInt( const wxString& aValue, double aScalar )
|
||||
* footprint portion of the PLUGIN API, and only for the #PCB_IO_KICAD_SEXPR plugin. It is
|
||||
* private to this implementation file so it is not placed into a header.
|
||||
*/
|
||||
class GPCB_FPL_CACHE_ITEM
|
||||
class GPCB_FPL_CACHE_ENTRY
|
||||
{
|
||||
public:
|
||||
GPCB_FPL_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
|
||||
GPCB_FPL_CACHE_ENTRY( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ) :
|
||||
m_filename( aFileName ),
|
||||
m_footprint( aFootprint )
|
||||
{ }
|
||||
|
||||
WX_FILENAME GetFileName() const { return m_filename; }
|
||||
FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
|
||||
WX_FILENAME GetFileName() const { return m_filename; }
|
||||
std::unique_ptr<FOOTPRINT>& GetFootprint() { return m_footprint; }
|
||||
|
||||
private:
|
||||
WX_FILENAME m_filename; ///< The full file name and path of the footprint to cache.
|
||||
@ -121,16 +124,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ) :
|
||||
m_filename( aFileName ),
|
||||
m_footprint( aFootprint )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
typedef boost::ptr_map< std::string, GPCB_FPL_CACHE_ITEM > FOOTPRINT_MAP;
|
||||
|
||||
|
||||
class GPCB_FPL_CACHE
|
||||
{
|
||||
public:
|
||||
@ -138,7 +131,7 @@ public:
|
||||
|
||||
wxString GetPath() const { return m_lib_path.GetPath(); }
|
||||
bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
|
||||
FOOTPRINT_MAP& GetFootprints() { return m_footprints; }
|
||||
boost::ptr_map<std::string, GPCB_FPL_CACHE_ENTRY>& GetFootprints() { return m_footprints; }
|
||||
|
||||
// Most all functions in this class throw IO_ERROR exceptions. There are no
|
||||
// error codes nor user interface calls from here, nor in any PLUGIN.
|
||||
@ -197,7 +190,9 @@ private:
|
||||
|
||||
PCB_IO_GEDA* m_owner; ///< Plugin object that owns the cache.
|
||||
wxFileName m_lib_path; ///< The path of the library.
|
||||
FOOTPRINT_MAP m_footprints; ///< Map of footprint file name to FOOTPRINT*.
|
||||
|
||||
boost::ptr_map<std::string, GPCB_FPL_CACHE_ENTRY> m_footprints; ///< Map of footprint filename
|
||||
///< to cache entries.
|
||||
|
||||
bool m_cache_dirty; ///< Stored separately because it's expensive to check
|
||||
///< m_cache_timestamp against all the files.
|
||||
@ -257,7 +252,7 @@ void GPCB_FPL_CACHE::Load()
|
||||
|
||||
// The footprint name is the file name without the extension.
|
||||
footprint->SetFPID( LIB_ID( wxEmptyString, fn.GetName() ) );
|
||||
m_footprints.insert( name, new GPCB_FPL_CACHE_ITEM( footprint, fn ) );
|
||||
m_footprints.insert( name, new GPCB_FPL_CACHE_ENTRY( footprint, fn ) );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
@ -277,7 +272,7 @@ void GPCB_FPL_CACHE::Remove( const wxString& aFootprintName )
|
||||
{
|
||||
std::string footprintName = TO_UTF8( aFootprintName );
|
||||
|
||||
FOOTPRINT_MAP::const_iterator it = m_footprints.find( footprintName );
|
||||
auto it = m_footprints.find( footprintName );
|
||||
|
||||
if( it == m_footprints.end() )
|
||||
{
|
||||
@ -913,14 +908,12 @@ const FOOTPRINT* PCB_IO_GEDA::getFootprint( const wxString& aLibraryPath,
|
||||
|
||||
validateCache( aLibraryPath, checkModified );
|
||||
|
||||
const FOOTPRINT_MAP& mods = m_cache->GetFootprints();
|
||||
auto it = m_cache->GetFootprints().find( TO_UTF8( aFootprintName ) );
|
||||
|
||||
FOOTPRINT_MAP::const_iterator it = mods.find( TO_UTF8( aFootprintName ) );
|
||||
|
||||
if( it == mods.end() )
|
||||
if( it == m_cache->GetFootprints().end() )
|
||||
return nullptr;
|
||||
|
||||
return it->second->GetFootprint();
|
||||
return it->second->GetFootprint().get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
||||
using namespace PCB_KEYS_T;
|
||||
|
||||
|
||||
FP_CACHE_ITEM::FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ) :
|
||||
FP_CACHE_ENTRY::FP_CACHE_ENTRY( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ) :
|
||||
m_filename( aFileName ),
|
||||
m_footprint( aFootprint )
|
||||
{ }
|
||||
@ -106,7 +106,7 @@ void FP_CACHE::Save( FOOTPRINT* aFootprintFilter )
|
||||
|
||||
for( auto it = m_footprints.begin(); it != m_footprints.end(); ++it )
|
||||
{
|
||||
FP_CACHE_ITEM* fpCacheEntry = it->second;
|
||||
FP_CACHE_ENTRY* fpCacheEntry = it->second;
|
||||
std::unique_ptr<FOOTPRINT>& footprint = fpCacheEntry->GetFootprint();
|
||||
|
||||
if( aFootprintFilter && footprint.get() != aFootprintFilter )
|
||||
@ -212,7 +212,7 @@ void FP_CACHE::Load()
|
||||
THROW_IO_ERROR( wxEmptyString ); // caught locally, just below...
|
||||
|
||||
footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
|
||||
m_footprints.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
|
||||
m_footprints.insert( fpName, new FP_CACHE_ENTRY( footprint, fn ) );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
@ -235,7 +235,7 @@ void FP_CACHE::Load()
|
||||
|
||||
void FP_CACHE::Remove( const wxString& aFootprintName )
|
||||
{
|
||||
FP_CACHE_FOOTPRINT_MAP::const_iterator it = m_footprints.find( aFootprintName );
|
||||
auto it = m_footprints.find( aFootprintName );
|
||||
|
||||
if( it == m_footprints.end() )
|
||||
{
|
||||
@ -265,9 +265,7 @@ void FP_CACHE::SetPath( const wxString& aPath )
|
||||
|
||||
|
||||
for( const auto& footprint : GetFootprints() )
|
||||
{
|
||||
footprint.second->SetFilePath( aPath );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2801,9 +2799,9 @@ void PCB_IO_KICAD_SEXPR::FootprintEnumerate( wxArrayString& aFootprintNames, con
|
||||
|
||||
|
||||
const FOOTPRINT* PCB_IO_KICAD_SEXPR::getFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
const std::map<std::string, UTF8>* aProperties,
|
||||
bool checkModified )
|
||||
const wxString& aFootprintName,
|
||||
const std::map<std::string, UTF8>* aProperties,
|
||||
bool checkModified )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
|
||||
@ -2818,10 +2816,9 @@ const FOOTPRINT* PCB_IO_KICAD_SEXPR::getFootprint( const wxString& aLibraryPath,
|
||||
// do nothing with the error
|
||||
}
|
||||
|
||||
FP_CACHE_FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
|
||||
auto it = footprints.find( aFootprintName );
|
||||
auto it = m_cache->GetFootprints().find( aFootprintName );
|
||||
|
||||
if( it == footprints.end() )
|
||||
if( it == m_cache->GetFootprints().end() )
|
||||
return nullptr;
|
||||
|
||||
return it->second->GetFootprint().get();
|
||||
@ -2935,7 +2932,6 @@ void PCB_IO_KICAD_SEXPR::FootprintSave( const wxString& aLibraryPath, const FOOT
|
||||
|
||||
wxString footprintName = aFootprint->GetFPID().GetLibItemName();
|
||||
|
||||
FP_CACHE_FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
|
||||
wxString fpName = aFootprint->GetFPID().GetLibItemName().wx_str();
|
||||
ReplaceIllegalFileNameChars( fpName, '_' );
|
||||
|
||||
@ -2959,12 +2955,12 @@ void PCB_IO_KICAD_SEXPR::FootprintSave( const wxString& aLibraryPath, const FOOT
|
||||
|
||||
wxString fullPath = fn.GetFullPath();
|
||||
wxString fullName = fn.GetFullName();
|
||||
FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
|
||||
auto it = m_cache->GetFootprints().find( footprintName );
|
||||
|
||||
if( it != footprints.end() )
|
||||
if( it != m_cache->GetFootprints().end() )
|
||||
{
|
||||
wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
|
||||
footprints.erase( footprintName );
|
||||
m_cache->GetFootprints().erase( footprintName );
|
||||
wxRemoveFile( fullPath );
|
||||
}
|
||||
|
||||
@ -2989,8 +2985,9 @@ void PCB_IO_KICAD_SEXPR::FootprintSave( const wxString& aLibraryPath, const FOOT
|
||||
footprint->SetParentGroup( nullptr );
|
||||
|
||||
wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
|
||||
footprints.insert( footprintName,
|
||||
new FP_CACHE_ITEM( footprint, WX_FILENAME( fn.GetPath(), fullName ) ) );
|
||||
m_cache->GetFootprints().insert( footprintName,
|
||||
new FP_CACHE_ENTRY( footprint,
|
||||
WX_FILENAME( fn.GetPath(), fullName ) ) );
|
||||
m_cache->Save( footprint );
|
||||
}
|
||||
|
||||
|
@ -203,32 +203,32 @@ class PCB_IO_KICAD_SEXPR; // forward decl
|
||||
* PLUGIN API, and only for the #PCB_PLUGIN plugin. It is private to this implementation file so
|
||||
* it is not placed into a header.
|
||||
*/
|
||||
class FP_CACHE_ITEM
|
||||
class FP_CACHE_ENTRY
|
||||
{
|
||||
WX_FILENAME m_filename;
|
||||
std::unique_ptr<FOOTPRINT> m_footprint;
|
||||
|
||||
public:
|
||||
FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
|
||||
FP_CACHE_ENTRY( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
|
||||
|
||||
const WX_FILENAME& GetFileName() const { return m_filename; }
|
||||
void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
|
||||
std::unique_ptr<FOOTPRINT>& GetFootprint() { return m_footprint; }
|
||||
};
|
||||
|
||||
typedef boost::ptr_map<wxString, FP_CACHE_ITEM> FP_CACHE_FOOTPRINT_MAP;
|
||||
|
||||
class FP_CACHE
|
||||
{
|
||||
PCB_IO_KICAD_SEXPR* m_owner; // Plugin object that owns the cache.
|
||||
wxFileName m_lib_path; // The path of the library.
|
||||
wxString m_lib_raw_path; // For quick comparisons.
|
||||
FP_CACHE_FOOTPRINT_MAP m_footprints; // Map of footprint filename to FOOTPRINT*.
|
||||
PCB_IO_KICAD_SEXPR* m_owner; // Plugin object that owns the cache.
|
||||
wxFileName m_lib_path; // The path of the library.
|
||||
wxString m_lib_raw_path; // For quick comparisons.
|
||||
|
||||
bool m_cache_dirty; // Stored separately because it's expensive to check
|
||||
// m_cache_timestamp against all the files.
|
||||
long long m_cache_timestamp; // A hash of the timestamps for all the footprint
|
||||
// files.
|
||||
boost::ptr_map<wxString, FP_CACHE_ENTRY> m_footprints; // Map of footprint filename to
|
||||
// cache entry.
|
||||
|
||||
bool m_cache_dirty; // Stored separately because it's expensive to check
|
||||
// m_cache_timestamp against all the files.
|
||||
long long m_cache_timestamp; // A hash of the timestamps for all the footprint
|
||||
// files.
|
||||
|
||||
public:
|
||||
FP_CACHE( PCB_IO_KICAD_SEXPR* aOwner, const wxString& aLibraryPath );
|
||||
@ -239,7 +239,7 @@ public:
|
||||
|
||||
bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
|
||||
|
||||
FP_CACHE_FOOTPRINT_MAP& GetFootprints() { return m_footprints; }
|
||||
boost::ptr_map<wxString, FP_CACHE_ENTRY>& GetFootprints() { return m_footprints; }
|
||||
|
||||
// Most all functions in this class throw IO_ERROR exceptions. There are no
|
||||
// error codes nor user interface calls from here, nor in any PLUGIN.
|
||||
@ -324,17 +324,20 @@ public:
|
||||
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
||||
|
||||
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
const std::map<std::string, UTF8>* aProperties = nullptr,
|
||||
PROJECT* aProject = nullptr ) override;
|
||||
|
||||
BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const std::map<std::string, UTF8>* aProperties,
|
||||
PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
|
||||
BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const std::map<std::string,
|
||||
UTF8>* aProperties, PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
||||
bool aBestEfforts, const std::map<std::string,
|
||||
UTF8>* aProperties = nullptr ) override;
|
||||
|
||||
const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
||||
const std::map<std::string,
|
||||
UTF8>* aProperties = nullptr ) override;
|
||||
|
||||
bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
||||
@ -392,7 +395,8 @@ protected:
|
||||
void validateCache( const wxString& aLibraryPath, bool checkModified = true );
|
||||
|
||||
const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const std::map<std::string, UTF8>* aProperties, bool checkModified );
|
||||
const std::map<std::string, UTF8>* aProperties,
|
||||
bool checkModified );
|
||||
|
||||
void init( const std::map<std::string, UTF8>* aProperties );
|
||||
|
||||
|
@ -1660,7 +1660,7 @@ int PCBNEW_JOBS_HANDLER::JobExportFpSvg( JOB* aJob )
|
||||
int exitCode = CLI::EXIT_CODES::OK;
|
||||
|
||||
// Just plot all the symbols we can
|
||||
FP_CACHE_FOOTPRINT_MAP& footprintMap = fpLib.GetFootprints();
|
||||
boost::ptr_map<wxString, FP_CACHE_ENTRY>& footprintMap = fpLib.GetFootprints();
|
||||
|
||||
bool singleFpPlotted = false;
|
||||
|
||||
@ -1682,6 +1682,7 @@ int PCBNEW_JOBS_HANDLER::JobExportFpSvg( JOB* aJob )
|
||||
}
|
||||
|
||||
exitCode = doFpExportSvg( svgJob, fp.get() );
|
||||
|
||||
if( exitCode != CLI::EXIT_CODES::OK )
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user