36 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
38 std::map<wxString, PCB_LAYER_ID> retval;
43 retval.insert( { layerDesc.Name, layerDesc.AutoMapLayer } );
87 std::vector<FOOTPRINT*> retval;
91 retval.push_back(
static_cast<FOOTPRINT*
>( fp->Clone() ) );
116 if( aProperties->
Value(
"page_width", &page_width )
117 && aProperties->
Value(
"page_height", &page_height ) )
121 int w = atoi( page_width.
c_str() );
122 int h = atoi( page_height.
c_str() );
124 int desired_x = ( w - bbbox.
GetWidth() ) / 2;
125 int desired_y = ( h - bbbox.
GetHeight() ) / 2;
175 const wxString& aLibraryPath,
181 if( !
m_cache.count( aLibraryPath ) )
184 for(
const auto& [
name, fp] :
m_cache.at( aLibraryPath ) )
185 aFootprintNames.Add(
name );
190 const wxString& aFootprintName,
195 if( !
m_cache.count( aLibraryPath ) )
198 if( !
m_cache.at( aLibraryPath ).count( aFootprintName ) )
206 const wxString& aFootprintName,
212 if( !
m_cache.count( aLibraryPath ) )
215 if( !
m_cache.at( aLibraryPath ).count( aFootprintName ) )
218 if( !
m_cache.at( aLibraryPath ).at( aFootprintName ) )
221 return static_cast<FOOTPRINT*
>(
m_cache.at( aLibraryPath ).at( aFootprintName )->Duplicate() );
227 wxFileName fn( aLibraryPath );
229 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
230 return fn.GetModificationTime().GetValue().GetValue();
232 return wxDateTime( 0.0 ).GetValue().GetValue();
238 if(
m_cache.count( aLibraryPath ) )
250 std::vector<std::unique_ptr<FOOTPRINT>> footprints = csLoader.
LoadLibrary();
252 for( std::unique_ptr<FOOTPRINT>& fp : footprints )
254 footprintMap.insert( { fp->GetFPID().GetLibItemName().wx_str(), std::move( fp ) } );
257 m_cache.insert( { aLibraryPath, std::move( footprintMap ) } );
Loads a cpa file into a KiCad BOARD object.
Pcbnew PLUGIN for CADSTAR PCB Archive (*.cpa) format: an ASCII format based on S-expressions.
Information pertinent to a Pcbnew printed circuit board.
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
void Move(const VECTOR2I &aMoveVector) override
Move this object.
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
coord_type GetHeight() const
coord_type GetWidth() const
void Load(BOARD *aBoard, PROJECT *aProject)
Loads a CADSTAR PCB Archive file into the KiCad BOARD object given.
std::vector< FOOTPRINT * > GetLoadedLibraryFootpints() const
Return a copy of the loaded library footprints (caller owns the objects)
std::vector< std::unique_ptr< FOOTPRINT > > LoadLibrary()
Parse a CADSTAR PCB Archive and load the footprints contained within.
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Check for the existence of a footprint.
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PLUGIN can read the specified board file.
void ensureLoadedLibrary(const wxString &aLibraryPath)
std::map< wxString, long long > m_timestamps
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
CADSTAR_PCB_ARCHIVE_PLUGIN()
std::map< wxString, NAME_TO_FOOTPRINT_MAP > m_cache
static std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler) override
Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
bool m_show_layer_mapping_warnings
~CADSTAR_PCB_ARCHIVE_PLUGIN()
bool checkBoardHeader(const wxString &aFileName) const
const STRING_UTF8_MAP * m_props
std::vector< FOOTPRINT * > m_loaded_footprints
void clearLoadedFootprints()
std::map< const wxString, std::unique_ptr< FOOTPRINT > > NAME_TO_FOOTPRINT_MAP
bool CanReadFootprint(const wxString &aFileName) const override
Checks if this PLUGIN can read a footprint from specified file or directory.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
bool CanReadFootprintLib(const wxString &aFileName) const override
Checks if this PLUGIN can read footprint library from specified file or directory.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
virtual void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
virtual bool CanReadFootprintLib(const wxString &aFileName) const
Checks if this PLUGIN can read footprint library from specified file or directory.
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PLUGIN can read a footprint from specified file or directory.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PLUGIN can read the specified board file.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
A name/value tuple with unique names and optional values.
bool Value(const char *aName, UTF8 *aFetchedValue=nullptr) const
Fetch a property by aName and returns true if that property was found, else false.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const char * c_str() const
bool fileStartsWithPrefix(const wxString &aFilePath, const wxString &aPrefix, bool aIgnoreWhitespace)
Check if a file starts with a defined string.
std::function< std::map< wxString, PCB_LAYER_ID >(const std::vector< INPUT_LAYER_DESC > &)> LAYER_MAPPING_HANDLER
Pointer to a function that takes a map of source and KiCad layers and returns a re-mapped version.