37 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
39 std::map<wxString, PCB_LAYER_ID> retval;
44 retval.insert( { layerDesc.Name, layerDesc.AutoMapLayer } );
84 std::vector<FOOTPRINT*> retval;
88 retval.push_back(
static_cast<FOOTPRINT*
>( fp->Clone() ) );
96 const std::map<std::string, UTF8>* aProperties,
PROJECT* aProject )
114 if(
auto it = aProperties->find(
"page_width" ); it != aProperties->end() )
115 page_width = it->second;
117 if(
auto it = aProperties->find(
"page_height" ); it != aProperties->end() )
118 page_height = it->second;
120 if( !page_width.
empty() && !page_height.
empty() )
124 int w = atoi( page_width.
c_str() );
125 int h = atoi( page_height.
c_str() );
127 int desired_x = ( w - bbbox.
GetWidth() ) / 2;
128 int desired_y = ( h - bbbox.
GetHeight() ) / 2;
178 const wxString& aLibraryPath,
180 const std::map<std::string, UTF8>* aProperties )
184 if( !
m_cache.count( aLibraryPath ) )
187 for(
const auto& [
name, fp] :
m_cache.at( aLibraryPath ) )
188 aFootprintNames.Add(
name );
193 const wxString& aFootprintName,
194 const std::map<std::string, UTF8>* aProperties )
198 if( !
m_cache.count( aLibraryPath ) )
201 if( !
m_cache.at( aLibraryPath ).count( aFootprintName ) )
209 const wxString& aFootprintName,
211 const std::map<std::string, UTF8>* aProperties )
215 if( !
m_cache.count( aLibraryPath ) )
218 if( !
m_cache.at( aLibraryPath ).count( aFootprintName ) )
221 if( !
m_cache.at( aLibraryPath ).at( aFootprintName ) )
224 return static_cast<FOOTPRINT*
>(
m_cache.at( aLibraryPath ).at( aFootprintName )->Duplicate() );
230 wxFileName fn( aLibraryPath );
232 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
233 return fn.GetModificationTime().GetValue().GetValue();
235 return wxDateTime( 0.0 ).GetValue().GetValue();
243 if(
m_cache.count( aLibraryPath ) )
255 std::vector<std::unique_ptr<FOOTPRINT>> footprints = csLoader.
LoadLibrary();
257 for( std::unique_ptr<FOOTPRINT>& fp : footprints )
259 footprintMap.insert( { fp->GetFPID().GetLibItemName().wx_str(), std::move( fp ) } );
262 m_cache.insert( { aLibraryPath, std::move( footprintMap ) } );
Loads a cpa file into a KiCad BOARD object.
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.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr size_type GetHeight() 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.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
virtual void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
void ensureLoadedLibrary(const wxString &aLibraryPath)
std::map< const wxString, std::unique_ptr< FOOTPRINT > > NAME_TO_FOOTPRINT_MAP
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
static std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
bool m_show_layer_mapping_warnings
void clearLoadedFootprints()
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler) override
Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
std::map< wxString, NAME_TO_FOOTPRINT_MAP > m_cache
bool CanReadFootprint(const wxString &aFileName) const override
Checks if this PCB_IO can read a footprint from specified file or directory.
bool checkBoardHeader(const wxString &aFileName) const
std::map< wxString, long long > m_timestamps
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
std::vector< FOOTPRINT * > m_loaded_footprints
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
~PCB_IO_CADSTAR_ARCHIVE()
A base class that BOARD loading and saving plugins should derive from.
BOARD * m_board
The board BOARD being worked on, no ownership here.
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PCB_IO can read a footprint from specified file or directory.
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Container for project specific data.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const char * c_str() const
static REPORTER & GetInstance()
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
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.
VECTOR2< int32_t > VECTOR2I