KiCad PCB EDA Suite
|
#include <cadstar_pcb_archive_plugin.h>
Public Member Functions | |
const wxString | PluginName () const override |
Return a brief hard coded name for this PLUGIN. More... | |
PLUGIN_FILE_DESC | GetBoardFileDesc () const override |
Returns board file description for the PLUGIN. More... | |
PLUGIN_FILE_DESC | GetFootprintLibDesc () const override |
Returns footprint library description for the PLUGIN. More... | |
PLUGIN_FILE_DESC | GetFootprintFileDesc () const override |
Returns footprint file description for the PLUGIN. More... | |
bool | CanReadBoard (const wxString &aFileName) const override |
Checks if this PLUGIN can read the specified board file. More... | |
bool | CanReadFootprintLib (const wxString &aFileName) const override |
Checks if this PLUGIN can read footprint library from specified file or directory. More... | |
bool | CanReadFootprint (const wxString &aFileName) const override |
Checks if this PLUGIN can read a footprint from specified file or directory. More... | |
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 a new BOARD or an existing one. More... | |
std::vector< FOOTPRINT * > | GetImportedCachedLibraryFootprints () override |
Return a container with the cached library footprints generated in the last call to Load. More... | |
void | RegisterLayerMappingCallback (LAYER_MAPPING_HANDLER aLayerMappingHandler) override |
Register a different handler to be called when mapping of Cadstar to KiCad layers occurs. More... | |
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. More... | |
bool | FootprintExists (const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override |
Check for the existence of a footprint. More... | |
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 PLUGIN knows about. More... | |
long long | GetLibraryTimestamp (const wxString &aLibraryPath) const override |
Generate a timestamp representing all the files in the library (including the library directory). More... | |
bool | IsFootprintLibWritable (const wxString &aLibraryPath) override |
CADSTAR Plugin is read-only. More... | |
CADSTAR_PCB_ARCHIVE_PLUGIN () | |
~CADSTAR_PCB_ARCHIVE_PLUGIN () | |
virtual void | SetQueryUserCallback (std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)> aCallback) |
Registers a KIDIALOG callback for collecting info from the user. More... | |
virtual void | SaveBoard (const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr) |
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file. More... | |
virtual void | PrefetchLib (const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) |
If possible, prefetches the specified library (e.g. More... | |
virtual FOOTPRINT * | ImportFootprint (const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties=nullptr) |
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut. More... | |
virtual const FOOTPRINT * | GetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) |
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More... | |
virtual void | FootprintSave (const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr) |
Write aFootprint to an existing library located at aLibraryPath. More... | |
virtual void | FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) |
Delete aFootprintName from the library at aLibraryPath. More... | |
virtual void | FootprintLibCreate (const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) |
Create a new empty footprint library at aLibraryPath empty. More... | |
virtual bool | FootprintLibDelete (const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) |
Delete an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More... | |
virtual void | FootprintLibOptions (STRING_UTF8_MAP *aListToAppendTo) const |
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More... | |
Static Public Member Functions | |
static std::map< wxString, PCB_LAYER_ID > | DefaultLayerMappingCallback (const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector) |
Return the automapped layers. More... | |
Static Protected Member Functions | |
static bool | fileStartsWithPrefix (const wxString &aFilePath, const wxString &aPrefix, bool aIgnoreWhitespace) |
static bool | fileStartsWithBinaryHeader (const wxString &aFilePath, const std::vector< uint8_t > &aHeader) |
Protected Attributes | |
LAYER_MAPPING_HANDLER | m_layer_mapping_handler |
Callback to get layer mapping. More... | |
Private Types | |
typedef std::map< const wxString, std::unique_ptr< FOOTPRINT > > | NAME_TO_FOOTPRINT_MAP |
Private Member Functions | |
void | clearLoadedFootprints () |
void | ensureLoadedLibrary (const wxString &aLibraryPath) |
bool | checkBoardHeader (const wxString &aFileName) const |
Private Attributes | |
std::map< wxString, NAME_TO_FOOTPRINT_MAP > | m_cache |
std::map< wxString, long long > | m_timestamps |
const STRING_UTF8_MAP * | m_props |
BOARD * | m_board |
std::vector< FOOTPRINT * > | m_loaded_footprints |
bool | m_show_layer_mapping_warnings |
Definition at line 38 of file cadstar_pcb_archive_plugin.h.
|
private |
Definition at line 105 of file cadstar_pcb_archive_plugin.h.
CADSTAR_PCB_ARCHIVE_PLUGIN::CADSTAR_PCB_ARCHIVE_PLUGIN | ( | ) |
Definition at line 57 of file cadstar_pcb_archive_plugin.cpp.
References DefaultLayerMappingCallback(), m_board, m_props, m_show_layer_mapping_warnings, and LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback().
CADSTAR_PCB_ARCHIVE_PLUGIN::~CADSTAR_PCB_ARCHIVE_PLUGIN | ( | ) |
Definition at line 67 of file cadstar_pcb_archive_plugin.cpp.
References clearLoadedFootprints().
|
overridevirtual |
Checks if this PLUGIN can read the specified board file.
If not overriden, extension check is used.
Reimplemented from PLUGIN.
Definition at line 146 of file cadstar_pcb_archive_plugin.cpp.
References PLUGIN::CanReadBoard(), and checkBoardHeader().
|
overridevirtual |
Checks if this PLUGIN can read a footprint from specified file or directory.
If not overriden, extension check is used.
Reimplemented from PLUGIN.
Definition at line 164 of file cadstar_pcb_archive_plugin.cpp.
References PLUGIN::CanReadFootprint(), and checkBoardHeader().
|
overridevirtual |
Checks if this PLUGIN can read footprint library from specified file or directory.
If not overriden, extension check is used.
Reimplemented from PLUGIN.
Definition at line 155 of file cadstar_pcb_archive_plugin.cpp.
References PLUGIN::CanReadFootprintLib(), and checkBoardHeader().
|
private |
Definition at line 140 of file cadstar_pcb_archive_plugin.cpp.
References PLUGIN::fileStartsWithPrefix().
Referenced by CanReadBoard(), CanReadFootprint(), and CanReadFootprintLib().
|
private |
Definition at line 73 of file cadstar_pcb_archive_plugin.cpp.
References m_loaded_footprints.
Referenced by LoadBoard(), and ~CADSTAR_PCB_ARCHIVE_PLUGIN().
|
static |
Return the automapped layers.
aInputLayerDescriptionVector |
Definition at line 34 of file cadstar_pcb_archive_plugin.cpp.
Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN().
|
private |
Definition at line 235 of file cadstar_pcb_archive_plugin.cpp.
References GetLibraryTimestamp(), CADSTAR_PCB_ARCHIVE_LOADER::LoadLibrary(), m_cache, LAYER_REMAPPABLE_PLUGIN::m_layer_mapping_handler, and m_timestamps.
Referenced by FootprintEnumerate(), FootprintExists(), and FootprintLoad().
|
staticprotectedinherited |
Definition at line 322 of file plugin.cpp.
Referenced by ALTIUM_DESIGNER_PLUGIN::checkFileHeader().
|
staticprotectedinherited |
Definition at line 297 of file plugin.cpp.
References text.
Referenced by PCAD_PLUGIN::CanReadBoard(), and checkBoardHeader().
|
virtualinherited |
Delete aFootprintName from the library at aLibraryPath.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprintName | is the name of a footprint to delete from the specified library. |
aProperties | is an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem finding the footprint or the library, or deleting it. |
Reimplemented in GPCB_PLUGIN, and PCB_PLUGIN.
Definition at line 236 of file plugin.cpp.
References NOT_IMPLEMENTED.
Referenced by FP_LIB_TABLE::FootprintDelete().
|
overridevirtual |
Return a list of footprint names contained within the library at aLibraryPath.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
aFootprintNames | is the array of available footprint names inside a library. |
aBestEfforts | if true, don't throw on errors, just return an empty list. |
IO_ERROR | if the library cannot be found, or footprint cannot be loaded. |
Reimplemented from PLUGIN.
Definition at line 173 of file cadstar_pcb_archive_plugin.cpp.
References ensureLoadedLibrary(), m_cache, and name.
|
overridevirtual |
Check for the existence of a footprint.
Reimplemented from PLUGIN.
Definition at line 188 of file cadstar_pcb_archive_plugin.cpp.
References ensureLoadedLibrary(), and m_cache.
|
virtualinherited |
Create a new empty footprint library at aLibraryPath empty.
It is an error to attempt to create an existing library or to attempt to create on a "read only" location.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aProperties | is an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem finding the library, or creating it. |
Reimplemented in PCB_PLUGIN.
Definition at line 244 of file plugin.cpp.
References NOT_IMPLEMENTED.
Referenced by PCB_BASE_EDIT_FRAME::createNewLibrary(), and FP_LIB_TABLE::FootprintLibCreate().
|
virtualinherited |
Delete an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.
aLibraryPath | is a locator for the "library", usually a directory or file which will contain footprints. |
aProperties | is an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem deleting an existing library. |
Reimplemented in GPCB_PLUGIN, PCB_PLUGIN, and LEGACY_PLUGIN.
Definition at line 251 of file plugin.cpp.
References NOT_IMPLEMENTED.
Referenced by PCB_BASE_EDIT_FRAME::createNewLibrary(), and FP_LIB_TABLE::FootprintLibDelete().
|
virtualinherited |
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Options are typically appended so that a derived PLUGIN can call its base class function by the same name first, thus inheriting options declared there. Some base class options could pertain to all Footprint*() functions in all derived PLUGINs.
aListToAppendTo | holds a tuple of
In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to PLUGIN, which has been avoided to date. |
Reimplemented in EAGLE_PLUGIN.
Definition at line 265 of file plugin.cpp.
References _.
Referenced by EAGLE_PLUGIN::FootprintLibOptions(), and FP_GRID_TRICKS::optionsEditor().
|
overridevirtual |
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprintName | is the name of the footprint to load. |
aProperties | is an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
aKeepUUID | = true to keep initial items UUID, false to set new UUID normally true if loaded in the footprint editor, false if loaded in the board editor. Make sense only in kicad_plugin |
IO_ERROR | if the library cannot be found or read. No exception is thrown in the case where aFootprintName cannot be found. |
Reimplemented from PLUGIN.
Definition at line 204 of file cadstar_pcb_archive_plugin.cpp.
References ensureLoadedLibrary(), and m_cache.
|
virtualinherited |
Write aFootprint to an existing library located at aLibraryPath.
If a footprint by the same name already exists, it is replaced.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprint | is what to store in the library. The caller continues to own the footprint after this call. |
aProperties | is an associative array that can be used to tell the saver how to save the footprint, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem saving. |
Reimplemented in PCB_PLUGIN.
Definition at line 228 of file plugin.cpp.
References NOT_IMPLEMENTED.
Referenced by PANEL_FP_LIB_TABLE::convertLibrary(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), FP_LIB_TABLE::FootprintSave(), PCB_EDIT_FRAME::OpenProjectFiles(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().
|
inlineoverridevirtual |
Returns board file description for the PLUGIN.
Reimplemented from PLUGIN.
Definition at line 43 of file cadstar_pcb_archive_plugin.h.
References _HKI.
Referenced by GetFootprintLibDesc().
|
virtualinherited |
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Reimplemented in GPCB_PLUGIN, and PCB_PLUGIN.
Definition at line 203 of file plugin.cpp.
References PLUGIN::FootprintLoad().
Referenced by PANEL_FP_LIB_TABLE::convertLibrary(), FP_LIB_TABLE::GetEnumeratedFootprint(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().
|
inlineoverridevirtual |
Returns footprint file description for the PLUGIN.
Reimplemented from PLUGIN.
Definition at line 50 of file cadstar_pcb_archive_plugin.h.
References GetFootprintLibDesc().
|
inlineoverridevirtual |
Returns footprint library description for the PLUGIN.
Reimplemented from PLUGIN.
Definition at line 48 of file cadstar_pcb_archive_plugin.h.
References GetBoardFileDesc().
Referenced by GetFootprintFileDesc().
|
overridevirtual |
Return a container with the cached library footprints generated in the last call to Load.
This function is intended to be used ONLY by the non-KiCad board importers for the purpose of obtaining the footprint library of the design and creating a project-specific library.
Reimplemented from PLUGIN.
Definition at line 84 of file cadstar_pcb_archive_plugin.cpp.
References m_loaded_footprints.
|
overridevirtual |
Generate a timestamp representing all the files in the library (including the library directory).
Timestamps should not be considered ordered, they either match or they don't.
Implements PLUGIN.
Definition at line 224 of file cadstar_pcb_archive_plugin.cpp.
Referenced by ensureLoadedLibrary().
|
virtualinherited |
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
If this is a footprint library, the first footprint should be loaded. The default implementation uses FootprintEnumerate and FootprintLoad to load first footprint.
aLibraryPath | is a path of the footprint file. |
aFootprintNameOut | is the name output of the loaded footprint. |
aProperties | is an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if the footprint cannot be found or read. |
Reimplemented in GPCB_PLUGIN, and PCB_PLUGIN.
Definition at line 181 of file plugin.cpp.
References _, PLUGIN::FootprintEnumerate(), and PLUGIN::FootprintLoad().
Referenced by FOOTPRINT_EDIT_FRAME::ImportFootprint().
|
inlineoverridevirtual |
CADSTAR Plugin is read-only.
Reimplemented from PLUGIN.
Definition at line 96 of file cadstar_pcb_archive_plugin.h.
|
overridevirtual |
Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one.
This may be used to load an entire new BOARD, or to augment an existing one if aAppendToMe is not NULL.
aFileName | is the name of the file to use as input and may be foreign in nature or native in nature. |
aAppendToMe | is an existing BOARD to append to, but if NULL then this means "do not append, rather load anew". |
aProperties | is an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
aProject | is the optional PROJECT object primarily used by third party importers. |
aProgressReporter | an optional progress reporter |
aLineCount | a line count (necessary if a progress reporter is supplied) |
IO_ERROR | if there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible. |
Reimplemented from PLUGIN.
Definition at line 97 of file cadstar_pcb_archive_plugin.cpp.
References UTF8::c_str(), clearLoadedFootprints(), BOARD::GetBoardEdgesBoundingBox(), BOX2< Vec >::GetHeight(), CADSTAR_PCB_ARCHIVE_LOADER::GetLoadedLibraryFootpints(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), CADSTAR_PCB_ARCHIVE_LOADER::Load(), m_board, LAYER_REMAPPABLE_PLUGIN::m_layer_mapping_handler, BOARD::m_LegacyDesignSettingsLoaded, BOARD::m_LegacyNetclassesLoaded, m_loaded_footprints, m_props, m_show_layer_mapping_warnings, BOARD::Move(), and STRING_UTF8_MAP::Value().
|
inlineoverridevirtual |
Return a brief hard coded name for this PLUGIN.
Implements PLUGIN.
Definition at line 41 of file cadstar_pcb_archive_plugin.h.
|
virtualinherited |
If possible, prefetches the specified library (e.g.
performing downloads). Does not parse. Threadsafe.
This is a no-op for libraries that cannot be prefetched. Plugins that cannot prefetch need not override this; a default no-op is provided.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is an error prefetching the library. |
Definition at line 176 of file plugin.cpp.
Referenced by FP_LIB_TABLE::PrefetchLib().
|
overridevirtual |
Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
aLayerMappingHandler |
Reimplemented from LAYER_REMAPPABLE_PLUGIN.
Definition at line 49 of file cadstar_pcb_archive_plugin.cpp.
References m_show_layer_mapping_warnings, and LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback().
|
virtualinherited |
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file.
aFileName | is the name of a file to save to on disk. |
aBoard | is the class BOARD in memory document tree from which to extract information when writing to aFileName. The caller continues to own the BOARD, and the plugin should refrain from modifying the BOARD if possible. |
aProperties | is an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it) and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem saving or exporting. |
Reimplemented in CLIPBOARD_IO, and PCB_PLUGIN.
Definition at line 161 of file plugin.cpp.
References NOT_IMPLEMENTED.
Referenced by IO_MGR::Save(), PCB_EDIT_FRAME::SavePcbCopy(), and PCB_EDIT_FRAME::SavePcbFile().
|
inlinevirtualinherited |
Registers a KIDIALOG callback for collecting info from the user.
Definition at line 313 of file io_mgr.h.
Referenced by PCB_CONTROL::AppendBoard(), and PCB_EDIT_FRAME::OpenProjectFiles().
|
private |
Definition at line 111 of file cadstar_pcb_archive_plugin.h.
Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN(), and LoadBoard().
|
private |
Definition at line 107 of file cadstar_pcb_archive_plugin.h.
Referenced by ensureLoadedLibrary(), FootprintEnumerate(), FootprintExists(), and FootprintLoad().
|
protectedinherited |
Callback to get layer mapping.
Definition at line 80 of file plugin_common_layer_mapping.h.
Referenced by ensureLoadedLibrary(), LoadBoard(), and LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback().
|
private |
Definition at line 112 of file cadstar_pcb_archive_plugin.h.
Referenced by clearLoadedFootprints(), GetImportedCachedLibraryFootprints(), and LoadBoard().
|
private |
Definition at line 110 of file cadstar_pcb_archive_plugin.h.
Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN(), and LoadBoard().
|
private |
Definition at line 113 of file cadstar_pcb_archive_plugin.h.
Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN(), LoadBoard(), and RegisterLayerMappingCallback().
|
private |
Definition at line 108 of file cadstar_pcb_archive_plugin.h.
Referenced by ensureLoadedLibrary().