Add optional project parameter to PCB plugin load method.
The optional PROJECT parameter is primarily used for third party plugins that need to store project information loaded by the plugin.
This commit is contained in:
parent
bd7c3447e0
commit
06aa1506ee
|
@ -323,4 +323,4 @@ static struct EDA_ITEM_DESC
|
|||
}
|
||||
} _EDA_ITEM_DESC;
|
||||
|
||||
ENUM_TO_WXANY( KICAD_T );
|
||||
ENUM_TO_WXANY( KICAD_T );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -154,22 +154,23 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath
|
|||
}
|
||||
|
||||
|
||||
BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
|
||||
BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
// release the PLUGIN even if an exception is thrown.
|
||||
PLUGIN::RELEASER pi( PluginFind( aFileType ) );
|
||||
|
||||
if( (PLUGIN*) pi ) // test pi->plugin
|
||||
{
|
||||
return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual
|
||||
return pi->Load( aFileName, aAppendToMe, aProperties, aProject ); // virtual
|
||||
}
|
||||
|
||||
THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
|
||||
}
|
||||
|
||||
|
||||
void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
|
||||
void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
// release the PLUGIN even if an exception is thrown.
|
||||
PLUGIN::RELEASER pi( PluginFind( aFileType ) );
|
||||
|
@ -185,9 +186,12 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
|
|||
|
||||
// These text strings are "truth" for identifying the plugins. If you change the spellings,
|
||||
// you will obsolete library tables, so don't do it. Additions are OK.
|
||||
static IO_MGR::REGISTER_PLUGIN registerEaglePlugin( IO_MGR::EAGLE, wxT("Eagle"), []() -> PLUGIN* { return new EAGLE_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerKicadPlugin( IO_MGR::KICAD_SEXP, wxT("KiCad"), []() -> PLUGIN* { return new PCB_IO; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerPcadPlugin( IO_MGR::PCAD, wxT("P-Cad"), []() -> PLUGIN* { return new PCAD_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerEaglePlugin( IO_MGR::EAGLE, wxT("Eagle"),
|
||||
[]() -> PLUGIN* { return new EAGLE_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerKicadPlugin( IO_MGR::KICAD_SEXP,
|
||||
wxT("KiCad"), []() -> PLUGIN* { return new PCB_IO; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerPcadPlugin( IO_MGR::PCAD, wxT("P-Cad"),
|
||||
[]() -> PLUGIN* { return new PCAD_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerAltiumDesignerPlugin( IO_MGR::ALTIUM_DESIGNER,
|
||||
wxT( "Altium Designer" ), []() -> PLUGIN* { return new ALTIUM_DESIGNER_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerAltiumCircuitStudioPlugin( IO_MGR::ALTIUM_CIRCUIT_STUDIO,
|
||||
|
@ -198,5 +202,7 @@ static IO_MGR::REGISTER_PLUGIN registerAltiumCircuitMakerPlugin( IO_MGR::ALTIUM_
|
|||
[]() -> PLUGIN* { return new ALTIUM_CIRCUIT_MAKER_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerCadstarArchivePlugin( IO_MGR::CADSTAR_PCB_ARCHIVE,
|
||||
wxT( "CADSTAR PCB Archive" ), []() -> PLUGIN* { return new CADSTAR_PCB_ARCHIVE_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerLegacyPlugin( IO_MGR::LEGACY, wxT("Legacy"), []() -> PLUGIN* { return new LEGACY_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerGPCBPlugin( IO_MGR::GEDA_PCB, wxT("GEDA/Pcb"), []() -> PLUGIN* { return new GPCB_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerLegacyPlugin( IO_MGR::LEGACY, wxT("Legacy"),
|
||||
[]() -> PLUGIN* { return new LEGACY_PLUGIN; } );
|
||||
static IO_MGR::REGISTER_PLUGIN registerGPCBPlugin( IO_MGR::GEDA_PCB, wxT("GEDA/Pcb"),
|
||||
[]() -> PLUGIN* { return new GPCB_PLUGIN; } );
|
||||
|
|
469
pcbnew/io_mgr.h
469
pcbnew/io_mgr.h
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016-2017 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,20 +36,18 @@ class BOARD;
|
|||
class PLUGIN;
|
||||
class FOOTPRINT;
|
||||
class PROPERTIES;
|
||||
|
||||
class PROJECT;
|
||||
|
||||
/**
|
||||
* IO_MGR
|
||||
* is a factory which returns an instance of a PLUGIN.
|
||||
* A factory which returns an instance of a #PLUGIN.
|
||||
*/
|
||||
class IO_MGR
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum PCB_FILE_T
|
||||
* is a set of file types that the IO_MGR knows about, and for which there
|
||||
* has been a plugin written.
|
||||
* The set of file types that the IO_MGR knows about, and for which there has been a
|
||||
* plugin written.
|
||||
*/
|
||||
enum PCB_FILE_T
|
||||
{
|
||||
|
@ -70,8 +68,7 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* PLUGIN_REGISTRY
|
||||
* Holds a list of available plugins, created using a singleton REGISTER_PLUGIN object.
|
||||
* Hold a list of available plugins, created using a singleton REGISTER_PLUGIN object.
|
||||
* This way, plugins can be added link-time.
|
||||
*/
|
||||
class PLUGIN_REGISTRY
|
||||
|
@ -95,7 +92,8 @@ public:
|
|||
return self;
|
||||
}
|
||||
|
||||
void Register( PCB_FILE_T aType, const wxString& aName, std::function<PLUGIN*(void)> aCreateFunc )
|
||||
void Register( PCB_FILE_T aType, const wxString& aName,
|
||||
std::function<PLUGIN*(void)> aCreateFunc )
|
||||
{
|
||||
ENTRY ent;
|
||||
ent.m_type = aType;
|
||||
|
@ -113,6 +111,7 @@ public:
|
|||
return ent.m_createFunc();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -126,15 +125,18 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* REGISTER_PLUGIN
|
||||
* Registers a plugin. Declare as a static variable in an anonymous namespace.
|
||||
* @param aType: type of the plugin
|
||||
* @param aName: name of the file format
|
||||
* @param aCreateFunc: function that creates a new object for the plugin.
|
||||
* Register a plugin.
|
||||
*
|
||||
* Declare as a static variable in an anonymous namespace.
|
||||
*
|
||||
* @param aType type of the plugin
|
||||
* @param aName name of the file format
|
||||
* @param aCreateFunc function that creates a new object for the plugin.
|
||||
*/
|
||||
struct REGISTER_PLUGIN
|
||||
{
|
||||
REGISTER_PLUGIN( PCB_FILE_T aType, const wxString& aName, std::function<PLUGIN*(void)> aCreateFunc )
|
||||
REGISTER_PLUGIN( PCB_FILE_T aType, const wxString& aName,
|
||||
std::function<PLUGIN*(void)> aCreateFunc )
|
||||
{
|
||||
PLUGIN_REGISTRY::Instance()->Register( aType, aName, aCreateFunc );
|
||||
}
|
||||
|
@ -142,116 +144,111 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Function PluginFind
|
||||
* returns a PLUGIN which the caller can use to import, export, save, or load
|
||||
* design documents. The returned PLUGIN, may be reference counted, so please
|
||||
* call PluginRelease() when you are done using the returned PLUGIN. It may or
|
||||
* may not be code running from a DLL/DSO.
|
||||
* Return a #PLUGIN which the caller can use to import, export, save, or load
|
||||
* design documents.
|
||||
*
|
||||
* @param aFileType is from PCB_FILE_T and tells which plugin to find.
|
||||
* The returned #PLUGIN, may be reference counted, so please call PluginRelease() when you
|
||||
* are done using the returned #PLUGIN. It may or may not be code running from a DLL/DSO.
|
||||
*
|
||||
* @return PLUGIN* - the plugin corresponding to aFileType or NULL if not found.
|
||||
* Caller owns the returned object, and must call PluginRelease when done using it.
|
||||
* @note The caller owns the returned object and must call PluginRelease when done using it.
|
||||
*
|
||||
* @param aFileType is from #PCB_FILE_T and tells which plugin to find.
|
||||
* @return the plug in corresponding to \a aFileType or NULL if not found.
|
||||
*/
|
||||
static PLUGIN* PluginFind( PCB_FILE_T aFileType );
|
||||
|
||||
/**
|
||||
* Function PluginRelease
|
||||
* releases a PLUGIN back to the system, and may cause it to be unloaded from memory.
|
||||
* Release a #PLUGIN back to the system and may cause it to be unloaded from memory.
|
||||
*
|
||||
* @param aPlugin is the one to be released, and which is no longer usable
|
||||
* after calling this.
|
||||
* after calling this.
|
||||
*/
|
||||
static void PluginRelease( PLUGIN* aPlugin );
|
||||
|
||||
/**
|
||||
* Function ShowType
|
||||
* returns a brief name for a plugin, given aFileType enum.
|
||||
* Return a brief name for a plugin given \a aFileType enum.
|
||||
*/
|
||||
static const wxString ShowType( PCB_FILE_T aFileType );
|
||||
|
||||
/**
|
||||
* Function EnumFromStr
|
||||
* returns the PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.
|
||||
* Return the #PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.
|
||||
*/
|
||||
static PCB_FILE_T EnumFromStr( const wxString& aFileType );
|
||||
|
||||
/**
|
||||
* Function GetFileExtension
|
||||
* returns the file extension for \a aFileType.
|
||||
* Return the file extension for \a aFileType.
|
||||
*
|
||||
* @param aFileType The #PCB_FILE_T type.
|
||||
* @return A wxString object containing the file extension for \a aFileType or an empty
|
||||
* string if \a aFileType is invalid.
|
||||
* @return the file extension for \a aFileType or an empty string if \a aFileType is invalid.
|
||||
*/
|
||||
static const wxString GetFileExtension( PCB_FILE_T aFileType );
|
||||
|
||||
/**
|
||||
* Function GuessPluginTypeFromLibPath
|
||||
* returns a plugin type given a footprint library's libPath.
|
||||
* Return a plugin type given a footprint library's libPath.
|
||||
*/
|
||||
static PCB_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath );
|
||||
|
||||
/**
|
||||
* Function Load
|
||||
* finds the requested PLUGIN and if found, calls the PLUGIN->Load(..) funtion
|
||||
* on it using the arguments passed to this function. After the PLUGIN->Load()
|
||||
* function returns, the PLUGIN is Released() as part of this call.
|
||||
*
|
||||
* @param aFileType is the PCB_FILE_T of file to load.
|
||||
* Find the requested #PLUGIN and if found, calls the #PLUGIN::Load() function
|
||||
* on it using the arguments passed to this function. After the #PLUGIN::Load()
|
||||
* function returns, the #PLUGIN is Released() as part of this call.
|
||||
*
|
||||
* @param aFileType is the #PCB_FILE_T of file to load.
|
||||
* @param aFileName is the name of the file to load.
|
||||
*
|
||||
* @param aAppendToMe is an existing BOARD to append to, use NULL if fresh
|
||||
* board load is wanted.
|
||||
*
|
||||
* board load is wanted.
|
||||
* @param aProperties is an associative array that allows the caller to
|
||||
* pass additional tuning parameters to the PLUGIN.
|
||||
* pass additional tuning parameters to the PLUGIN.
|
||||
* @param aProject is the optional #PROJECT object primarily used by third party
|
||||
* importers.
|
||||
* @return the loaded #BOARD object. The caller owns it an it will never NULL because
|
||||
* exception thrown if error.
|
||||
*
|
||||
* @return BOARD* - caller owns it, never NULL because exception thrown if error.
|
||||
*
|
||||
* @throw IO_ERROR if the PLUGIN cannot be found, file cannot be found,
|
||||
* or file cannot be loaded.
|
||||
* @throw IO_ERROR if the #PLUGIN cannot be found, file cannot be found, or file cannot
|
||||
* be loaded.
|
||||
*/
|
||||
static BOARD* Load( PCB_FILE_T aFileType, const wxString& aFileName,
|
||||
BOARD* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
|
||||
BOARD* aAppendToMe = nullptr, const PROPERTIES* aProperties = nullptr,
|
||||
PROJECT* aProject = nullptr );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* will write either a full aBoard to a storage file in a format that this
|
||||
* implementation knows about, or it can be used to write a portion of
|
||||
* aBoard to a special kind of export file.
|
||||
*
|
||||
* @param aFileType is the PCB_FILE_T of file to save.
|
||||
* Write either a full \a aBoard to a storage file in a format that this implementation
|
||||
* knows about, or it can be used to write a portion of\a aBoard to a special kind of
|
||||
* export file.
|
||||
*
|
||||
* @param aFileType is the #PCB_FILE_T of file to save.
|
||||
* @param aFileName is the name of a file to save to on disk.
|
||||
* @param aBoard is the BOARD document (data tree) to save or export to disk.
|
||||
*
|
||||
* @param aBoard is the in memory document tree from which to extract information
|
||||
* when writing to \a aFileName. The caller continues to own the BOARD, and
|
||||
* the plugin should refrain from modifying the BOARD if possible.
|
||||
*
|
||||
* @param 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.
|
||||
* @param aBoard is the #BOARD document (data tree) to save or export to disk.
|
||||
* @param aBoard is the in memory document tree from which to extract information when
|
||||
* writing to \a aFileName. The caller continues to own the #BOARD, and
|
||||
* the plugin should refrain from modifying the #BOARD if possible.
|
||||
* @param 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.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||
*/
|
||||
static void Save( PCB_FILE_T aFileType, const wxString& aFileName,
|
||||
BOARD* aBoard, const PROPERTIES* aProperties = NULL );
|
||||
static void Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* PLUGIN
|
||||
* is a base class that BOARD loading and saving plugins should derive from.
|
||||
* Implementations can provide either Load() or Save() functions, or both.
|
||||
* PLUGINs throw exceptions, so it is best that you wrap your calls to these
|
||||
* functions in a try catch block. Plugins throw exceptions because it is illegal
|
||||
* for them to have any user interface calls in them whatsoever, i.e. no windowing
|
||||
* or screen printing at all.
|
||||
* A base class that #BOARD loading and saving plugins should derive from.
|
||||
*
|
||||
* Implementations can provide either Load() or Save() functions, or both. PLUGINs throw
|
||||
* exceptions, so it is best that you wrap your calls to these functions in a try catch block.
|
||||
* Plugins throw exceptions because it is illegal for them to have any user interface calls in
|
||||
* them whatsoever, i.e. no windowing or screen printing at all.
|
||||
*
|
||||
*The compiler writes the "zero argument" constructor for a PLUGIN automatically if you do
|
||||
* not provide one. If you decide you need to provide a zero argument constructor of your
|
||||
* own design, that is allowed. It must be public, and it is what the #IO_MGR uses. Parameters
|
||||
* may be passed into a PLUGIN via the #PROPERTIES variable for any of the public API functions
|
||||
* which take one.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* try
|
||||
|
@ -269,297 +266,261 @@ public:
|
|||
class PLUGIN
|
||||
{
|
||||
public:
|
||||
|
||||
//-----<PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
/**
|
||||
* Function PluginName
|
||||
* returns a brief hard coded name for this PLUGIN.
|
||||
* Return a brief hard coded name for this PLUGIN.
|
||||
*/
|
||||
virtual const wxString PluginName() const = 0;
|
||||
|
||||
/**
|
||||
* Function GetFileExtension
|
||||
* returns the file extension for the PLUGIN.
|
||||
* Returns the file extension for the PLUGIN.
|
||||
*/
|
||||
virtual const wxString GetFileExtension() const = 0;
|
||||
|
||||
/**
|
||||
* Function Load
|
||||
* loads 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 @a aAppendToMe is not NULL.
|
||||
* 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
|
||||
* @a aAppendToMe is not NULL.
|
||||
*
|
||||
* @param aFileName is the name of the file to use as input and may be foreign in
|
||||
* nature or native in nature.
|
||||
* nature or native in nature.
|
||||
* @param aAppendToMe is an existing BOARD to append to, but if NULL then this means
|
||||
* "do not append, rather load anew".
|
||||
* @param 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.
|
||||
* @param aProject is the optional #PROJECT object primarily used by third party
|
||||
* importers.
|
||||
* @return the successfully loaded board, or the same one as \a aAppendToMe if aAppendToMe
|
||||
* was not NULL, and caller owns it.
|
||||
*
|
||||
* @param aAppendToMe is an existing BOARD to append to, but if NULL then
|
||||
* this means "do not append, rather load anew".
|
||||
*
|
||||
* @param 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.
|
||||
*
|
||||
* @return BOARD* - the successfully loaded board, or the same one as aAppendToMe
|
||||
* if aAppendToMe was not NULL, and caller owns it.
|
||||
*
|
||||
* @throw 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.
|
||||
* @throw 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.
|
||||
*/
|
||||
virtual BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr );
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
* will write @a 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.
|
||||
* Write @a aBoard to a storage file in a format that this PLUGIN implementation knows
|
||||
* about or it can be used to write a portion of \a aBoard to a special kind of export
|
||||
* file.
|
||||
*
|
||||
* @param aFileName is the name of a file to save to on disk.
|
||||
*
|
||||
* @param aBoard is the class BOARD in memory document tree from which to
|
||||
* extract information when writing to \a aFileName. The caller continues to
|
||||
* own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
|
||||
*
|
||||
* @param 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.
|
||||
* @param aBoard is the class #BOARD in memory document tree from which to extract
|
||||
* information when writing to \a aFileName. The caller continues to
|
||||
* own the BOARD, and the plugin should refrain from modifying the BOARD
|
||||
* if possible.
|
||||
* @param 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.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||
*/
|
||||
virtual void Save( const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
|
||||
//-----<Footprint Stuff>-----------------------------
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Return a list of footprint names contained within the library at @a aLibraryPath.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
*
|
||||
* @param aProperties is an associative array that can be used to tell the
|
||||
* plugin anything needed about how to perform with respect to @a aLibraryPath.
|
||||
* The caller continues to own this object (plugin may not delete it), and
|
||||
* plugins should expect it to be optionally NULL.
|
||||
*
|
||||
* or URL containing several footprints.
|
||||
* @param aProperties is an associative array that can be used to tell the plugin
|
||||
* anything needed about how to perform with respect to @a aLibraryPath.
|
||||
* The caller continues to own this object (plugin may not delete it),
|
||||
* and plugins should expect it to be optionally NULL.
|
||||
* @param aFootprintNames is the array of available footprint names inside a library.
|
||||
*
|
||||
* @param aBestEfforts if true, don't throw on errors, just return an empty list.
|
||||
*
|
||||
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
||||
*/
|
||||
virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL );
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Timestamps should not be considered ordered, they either match or they don't.
|
||||
*/
|
||||
virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
|
||||
|
||||
/**
|
||||
* Function PrefetchLib
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* Plugins that cannot prefetch need not override this; a default no-op is provided.
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
*
|
||||
* @param aProperties is an associative array that can be used to tell the
|
||||
* plugin anything needed about how to perform with respect to @a aLibraryPath.
|
||||
* The caller continues to own this object (plugin may not delete it), and
|
||||
* plugins should expect it to be optionally NULL.
|
||||
* @param aProperties is an associative array that can be used to tell the plugin anything
|
||||
* needed about how to perform with respect to @a aLibraryPath. The
|
||||
* caller continues to own this object (plugin may not delete it), and
|
||||
* plugins should expect it to be optionally NULL.
|
||||
*
|
||||
* @throw IO_ERROR if there is an error prefetching the library.
|
||||
*/
|
||||
virtual void PrefetchLib( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintLoad
|
||||
* loads a footprint having @a aFootprintName from the @a aLibraryPath containing
|
||||
* a library format that this PLUGIN knows about.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
* Load a footprint having @a aFootprintName from the @a aLibraryPath containing a library
|
||||
* format that this PLUGIN knows about.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
* @param aFootprintName is the name of the footprint to load.
|
||||
* @param 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.
|
||||
* @return the #FOOTPRINT object if found caller owns it, else NULL if not found.
|
||||
*
|
||||
* @param 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.
|
||||
*
|
||||
* @return FOOTPRINT* - if found caller owns it, else NULL if not found.
|
||||
*
|
||||
* @throw IO_ERROR if the library cannot be found or read. No exception
|
||||
* is thrown in the case where aFootprintName cannot be found.
|
||||
* @throw IO_ERROR if the library cannot be found or read. No exception is thrown in
|
||||
* the case where \a aFootprintName cannot be found.
|
||||
*/
|
||||
virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function GetEnumeratedFootprint
|
||||
* a version of FootprintLoad() for use after FootprintEnumerate() for more efficient
|
||||
* A version of FootprintLoad() for use after FootprintEnumerate() for more efficient
|
||||
* cache management.
|
||||
*/
|
||||
virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintExists
|
||||
* check for the existence of a footprint.
|
||||
* Check for the existence of a footprint.
|
||||
*/
|
||||
virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintSave
|
||||
* will write @a aModule to an existing library located at @a aLibraryPath.
|
||||
* Write @a aFootprint to an existing library located at @a aLibraryPath.
|
||||
* If a footprint by the same name already exists, it is replaced.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
*
|
||||
* @param aFootprint is what to store in the library. The caller continues
|
||||
* to own the footprint after this call.
|
||||
*
|
||||
* @param 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.
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
* @param aFootprint is what to store in the library. The caller continues to own the
|
||||
* footprint after this call.
|
||||
* @param 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.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem saving.
|
||||
*/
|
||||
virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintDelete
|
||||
* deletes @a aFootprintName from the library at @a aLibraryPath.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
* Delete @a aFootprintName from the library at @a aLibraryPath.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
* @param aFootprintName is the name of a footprint to delete from the specified library.
|
||||
*
|
||||
* @param 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.
|
||||
* @param 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.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it.
|
||||
*/
|
||||
virtual void FootprintDelete( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
|
||||
virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintLibCreate
|
||||
* creates a new empty footprint library at @a aLibraryPath empty. It is an
|
||||
* error to attempt to create an existing library or to attempt to create
|
||||
* Create a new empty footprint library at @a aLibraryPath empty.
|
||||
*
|
||||
* It is an error to attempt to create an existing library or to attempt to create
|
||||
* on a "read only" location.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
*
|
||||
* @param 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.
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
* @param 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.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem finding the library, or creating it.
|
||||
*/
|
||||
virtual void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
|
||||
virtual void FootprintLibCreate( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function FootprintLibDelete
|
||||
* deletes an existing footprint library and returns true, or if library does not
|
||||
* 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.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory
|
||||
* or file which will contain footprints.
|
||||
*
|
||||
* @param 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.
|
||||
*
|
||||
* @return bool - true if library deleted, false if library did not exist.
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory or file which
|
||||
* will contain footprints.
|
||||
* @param 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.
|
||||
* @return true if library deleted, false if library did not exist.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem deleting an existing library.
|
||||
*/
|
||||
virtual bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
|
||||
virtual bool FootprintLibDelete( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Function IsFootprintLibWritable
|
||||
* returns true iff the library at @a aLibraryPath is writable. (Often
|
||||
* system libraries are read only because of where they are installed.)
|
||||
* Return true if the library at @a aLibraryPath is writable.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
* The system libraries are typically read only because of where they are installed..
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
*
|
||||
* @throw IO_ERROR if no library at aLibraryPath exists.
|
||||
*/
|
||||
virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
|
||||
|
||||
/**
|
||||
* Function FootprintLibOptions
|
||||
* appends supported PLUGIN options to @a 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.) Note that since aListToAppendTo is a PROPERTIES
|
||||
* object, all options will be unique and last guy wins.
|
||||
* Append supported PLUGIN options to @a 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.
|
||||
*
|
||||
* @note Since aListToAppendTo is a #PROPERTIES object, all options will be unique and
|
||||
* last guy wins.
|
||||
*
|
||||
* @param aListToAppendTo holds a tuple of
|
||||
* <dl>
|
||||
<dt>option</dt>
|
||||
<dd>This eventually is what shows up into the fp-lib-table "options"
|
||||
field, possibly combined with others.</dd>
|
||||
<dt>internationalized description</dt>
|
||||
<dd>The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS.
|
||||
* <dt>option</dt>
|
||||
* <dd>This eventually is what shows up into the fp-lib-table "options"
|
||||
* field, possibly combined with others.</dd>
|
||||
* <dt>internationalized description</dt>
|
||||
* <dd>The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS.
|
||||
* It may be multi-line and be quite explanatory of the option.</dd>
|
||||
</dl>
|
||||
* </dl>
|
||||
* <br>
|
||||
* In the future perhaps @a 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.
|
||||
* This would require a 3 column list, and introducing wx GUI knowledge to
|
||||
* PLUGIN, which has been avoided to date.
|
||||
*/
|
||||
virtual void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const;
|
||||
|
||||
//-----</PUBLIC PLUGIN API>------------------------------------------------
|
||||
|
||||
|
||||
/* The compiler writes the "zero argument" constructor for a PLUGIN
|
||||
automatically if you do not provide one. If you decide you need to
|
||||
provide a zero argument constructor of your own design, that is allowed.
|
||||
It must be public, and it is what the IO_MGR uses. Parameters may be
|
||||
passed into a PLUGIN via the PROPERTIES variable for any of the public
|
||||
API functions which take one.
|
||||
*/
|
||||
|
||||
virtual ~PLUGIN()
|
||||
{
|
||||
//printf( "~%s", __func__ );
|
||||
|
@ -568,9 +529,7 @@ public:
|
|||
|
||||
#ifndef SWIG
|
||||
/**
|
||||
* RELEASER
|
||||
* releases a PLUGIN in the context of a potential thrown exception, through
|
||||
* its destructor.
|
||||
* Releases a PLUGIN in the context of a potential thrown exception through its destructor.
|
||||
*/
|
||||
class RELEASER
|
||||
{
|
||||
|
|
|
@ -344,8 +344,8 @@ void CLIPBOARD_IO::Save( const wxString& aFileName, BOARD* aBoard,
|
|||
}
|
||||
|
||||
|
||||
BOARD* CLIPBOARD_IO::Load( const wxString& aFileName,
|
||||
BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* CLIPBOARD_IO::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
std::string result;
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ public:
|
|||
* Saves the entire board to the clipboard formatted using the PCB_IO formatting
|
||||
*/
|
||||
void Save( const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
/*
|
||||
* Writes all the settings of the BOARD* set by setBoard() and then adds all the
|
||||
* Write all the settings of the BOARD* set by setBoard() and then adds all the
|
||||
* BOARD_ITEMs found in selection formatted by PCB_IO to clipboard as sexpr text
|
||||
*/
|
||||
void SaveSelection( const PCB_SELECTION& selected, bool isFootprintEditor );
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
BOARD_ITEM* Parse();
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
|
||||
void SetBoard( BOARD* aBoard );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -30,10 +30,9 @@
|
|||
#define FMT_UNIMPLEMENTED "Plugin \"%s\" does not implement the \"%s\" function."
|
||||
|
||||
/**
|
||||
* Function not_implemented
|
||||
* throws an IO_ERROR and complains of an API function not being implemented.
|
||||
* Throw an #IO_ERROR and complains of an API function not being implemented.
|
||||
*
|
||||
* @param aPlugin is a PLUGIN instance
|
||||
* @param aPlugin is a #PLUGIN instance.
|
||||
* @param aCaller is the name of the unimplemented API function.
|
||||
*/
|
||||
static void not_implemented( PLUGIN* aPlugin, const char* aCaller )
|
||||
|
@ -44,10 +43,11 @@ static void not_implemented( PLUGIN* aPlugin, const char* aCaller )
|
|||
}
|
||||
|
||||
|
||||
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
||||
PROJECT* aProject )
|
||||
{
|
||||
not_implemented( this, __FUNCTION__ );
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString&
|
|||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
||||
not_implemented( this, __FUNCTION__ );
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -62,8 +63,8 @@ const wxString ALTIUM_CIRCUIT_MAKER_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
BOARD* ALTIUM_CIRCUIT_MAKER_PLUGIN::Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* ALTIUM_CIRCUIT_MAKER_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
m_props = aProperties;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -35,12 +36,10 @@
|
|||
class ALTIUM_CIRCUIT_MAKER_PLUGIN : public PLUGIN
|
||||
{
|
||||
public:
|
||||
// -----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties ) override;
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
||||
PROJECT* aProject = nullptr ) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
|
@ -50,8 +49,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
ALTIUM_CIRCUIT_MAKER_PLUGIN();
|
||||
~ALTIUM_CIRCUIT_MAKER_PLUGIN();
|
||||
|
||||
|
@ -60,4 +57,4 @@ private:
|
|||
BOARD* m_board;
|
||||
};
|
||||
|
||||
#endif // ALTIUM_CIRCUIT_MAKER_PLUGIN_H_
|
||||
#endif // ALTIUM_CIRCUIT_MAKER_PLUGIN_H_
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -62,8 +63,8 @@ const wxString ALTIUM_CIRCUIT_STUDIO_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
BOARD* ALTIUM_CIRCUIT_STUDIO_PLUGIN::Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* ALTIUM_CIRCUIT_STUDIO_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
m_props = aProperties;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -35,12 +36,10 @@
|
|||
class ALTIUM_CIRCUIT_STUDIO_PLUGIN : public PLUGIN
|
||||
{
|
||||
public:
|
||||
// -----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties ) override;
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
||||
PROJECT* aProject ) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
|
@ -50,8 +49,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
ALTIUM_CIRCUIT_STUDIO_PLUGIN();
|
||||
~ALTIUM_CIRCUIT_STUDIO_PLUGIN();
|
||||
|
||||
|
@ -60,4 +57,4 @@ private:
|
|||
BOARD* m_board;
|
||||
};
|
||||
|
||||
#endif // ALTIUM_CIRCUIT_STUDIO_PLUGIN_H_
|
||||
#endif // ALTIUM_CIRCUIT_STUDIO_PLUGIN_H_
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -62,8 +63,8 @@ const wxString ALTIUM_DESIGNER_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
BOARD* ALTIUM_DESIGNER_PLUGIN::Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* ALTIUM_DESIGNER_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
m_props = aProperties;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -23,7 +24,7 @@
|
|||
|
||||
/**
|
||||
* @file pcad_plugin.h
|
||||
* @brief Pcbnew PLUGIN for Altium *.PcbDoc format.
|
||||
* @brief Pcbnew #PLUGIN for Altium *.PcbDoc format.
|
||||
*/
|
||||
|
||||
#ifndef ALTIUM_DESIGNER_PLUGIN_H_
|
||||
|
@ -39,8 +40,8 @@ public:
|
|||
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties ) override;
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
||||
PROJECT* aProject = nullptr) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
|
@ -60,4 +61,4 @@ private:
|
|||
BOARD* m_board;
|
||||
};
|
||||
|
||||
#endif // ALTIUM_DESIGNER_PLUGIN_H_
|
||||
#endif // ALTIUM_DESIGNER_PLUGIN_H_
|
||||
|
|
|
@ -80,8 +80,8 @@ const wxString CADSTAR_PCB_ARCHIVE_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
BOARD* CADSTAR_PCB_ARCHIVE_PLUGIN::Load(
|
||||
const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* CADSTAR_PCB_ARCHIVE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
m_props = aProperties;
|
||||
m_board = aAppendToMe ? aAppendToMe : new BOARD();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
/**
|
||||
* @file cadstar_pcb_archive_plugin.h
|
||||
* @brief Pcbnew PLUGIN for CADSTAR PCB Archive (*.cpa) format: an ASCII format
|
||||
* @brief Pcbnew #PLUGIN for CADSTAR PCB Archive (*.cpa) format: an ASCII format
|
||||
* based on S-expressions.
|
||||
*/
|
||||
|
||||
|
@ -36,12 +36,10 @@
|
|||
class CADSTAR_PCB_ARCHIVE_PLUGIN : public PLUGIN, public LAYER_REMAPPABLE_PLUGIN
|
||||
{
|
||||
public:
|
||||
// -----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
|
@ -51,10 +49,9 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Default callback - just returns the automapped layers
|
||||
* Return the automapped layers.
|
||||
*
|
||||
* @param aInputLayerDescriptionVector
|
||||
* @return Auto-mapped layers
|
||||
*/
|
||||
|
@ -62,8 +59,8 @@ public:
|
|||
const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
|
||||
|
||||
/**
|
||||
* @brief Register a different handler to be called when mapping of Cadstar to KiCad
|
||||
* layers occurs
|
||||
* Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
|
||||
*
|
||||
* @param aLayerMappingHandler
|
||||
*/
|
||||
void RegisterLayerMappingCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler ) override;
|
||||
|
|
|
@ -307,7 +307,8 @@ wxSize inline EAGLE_PLUGIN::kicad_fontz( const ECOORD& d, int aTextThickness ) c
|
|||
}
|
||||
|
||||
|
||||
BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxXmlNode* doc;
|
||||
|
|
|
@ -47,13 +47,17 @@ typedef NET_MAP::const_iterator NET_MAP_CITER;
|
|||
/// subset of eagle.drawing.board.designrules in the XML document
|
||||
struct ERULES
|
||||
{
|
||||
int psElongationLong; ///< percent over 100%. 0-> not elongated, 100->twice as wide as is tall
|
||||
///< Goes into making a scaling factor for "long" pads.
|
||||
///< percent over 100%. 0-> not elongated, 100->twice as wide as is tall
|
||||
///< Goes into making a scaling factor for "long" pads.
|
||||
int psElongationLong;
|
||||
|
||||
int psElongationOffset; ///< the offset of the hole within the "long" pad.
|
||||
|
||||
double mvStopFrame; ///< solder mask, expressed as percentage of the smaller pad/via dimension
|
||||
double mvCreamFrame; ///< solderpaste mask, expressed as percentage of the smaller pad/via dimension
|
||||
///< solder mask, expressed as percentage of the smaller pad/via dimension
|
||||
double mvStopFrame;
|
||||
|
||||
///< solderpaste mask, expressed as percentage of the smaller pad/via dimension
|
||||
double mvCreamFrame;
|
||||
int mlMinStopFrame; ///< solder mask, minimum size (Eagle mils, here nanometers)
|
||||
int mlMaxStopFrame; ///< solder mask, maximum size (Eagle mils, here nanometers)
|
||||
int mlMinCreamFrame; ///< solder paste mask, minimum size (Eagle mils, here nanometers)
|
||||
|
@ -64,8 +68,12 @@ struct ERULES
|
|||
int psFirst; ///< Shape of the first pads
|
||||
|
||||
double srRoundness; ///< corner rounding ratio for SMD pads (percentage)
|
||||
int srMinRoundness; ///< corner rounding radius, minimum size (Eagle mils, here nanometers)
|
||||
int srMaxRoundness; ///< corner rounding radius, maximum size (Eagle mils, here nanometers)
|
||||
|
||||
///< corner rounding radius, minimum size (Eagle mils, here nanometers)
|
||||
int srMinRoundness;
|
||||
|
||||
///< corner rounding radius, maximum size (Eagle mils, here nanometers)
|
||||
int srMaxRoundness;
|
||||
|
||||
double rvPadTop; ///< top pad size as percent of drill size
|
||||
// double rvPadBottom; ///< bottom pad size as percent of drill size
|
||||
|
@ -112,28 +120,26 @@ struct ERULES
|
|||
void parse( wxXmlNode* aRules );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAGLE_PLUGIN
|
||||
* works with Eagle 6.x XML board files and footprints to implement the
|
||||
* Pcbnew PLUGIN API, or a portion of it.
|
||||
* Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API
|
||||
* or a portion of it.
|
||||
*/
|
||||
class EAGLE_PLUGIN : public PLUGIN, public LAYER_REMAPPABLE_PLUGIN
|
||||
{
|
||||
public:
|
||||
|
||||
//-----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = nullptr) override;
|
||||
|
||||
FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override
|
||||
{
|
||||
|
@ -147,27 +153,13 @@ public:
|
|||
|
||||
void FootprintLibOptions( PROPERTIES* aProperties ) const override;
|
||||
|
||||
/*
|
||||
void Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
|
||||
*/
|
||||
|
||||
//-----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
typedef int BIU;
|
||||
|
||||
EAGLE_PLUGIN();
|
||||
~EAGLE_PLUGIN();
|
||||
|
||||
/**
|
||||
* @brief Default callback - just returns the automapped layers
|
||||
* Return the automapped layers.
|
||||
*
|
||||
* The callback needs to have the context of the current board so it can
|
||||
* correctly determine copper layer mapping. Thus, it is not static and is
|
||||
|
@ -183,10 +175,10 @@ private:
|
|||
typedef std::vector<ELAYER> ELAYERS;
|
||||
typedef ELAYERS::const_iterator EITER;
|
||||
|
||||
int m_cu_map[17]; ///< map eagle to kicad, cu layers only.
|
||||
int m_cu_map[17]; ///< map eagle to KiCad, cu layers only.
|
||||
std::map<int, ELAYER> m_eagleLayers; ///< Eagle layer data stored by layer number
|
||||
std::map<wxString, int> m_eagleLayersIds; ///< Eagle layer ids stored by layer name
|
||||
std::map<wxString, PCB_LAYER_ID> m_layer_map; ///< Map of Eagle layers to KiCAD layers
|
||||
std::map<wxString, PCB_LAYER_ID> m_layer_map; ///< Map of Eagle layers to KiCad layers
|
||||
|
||||
ERULES* m_rules; ///< Eagle design rules.
|
||||
XPATH* m_xpath; ///< keeps track of what we are working on within
|
||||
|
@ -221,7 +213,7 @@ private:
|
|||
int kicad_y( const ECOORD& y ) const { return -y.ToPcbUnits(); }
|
||||
int kicad_x( const ECOORD& x ) const { return x.ToPcbUnits(); }
|
||||
|
||||
/// create a font size (fontz) from an eagle font size scalar and KiCAD font thickness
|
||||
/// create a font size (fontz) from an eagle font size scalar and KiCad font thickness
|
||||
wxSize kicad_fontz( const ECOORD& d, int aTextThickness ) const;
|
||||
|
||||
/// Generate mapping between Eagle na KiCAD layers
|
||||
|
@ -237,7 +229,7 @@ private:
|
|||
/// Get Eagle layer name by its number
|
||||
const wxString& eagle_layer_name( int aLayer ) const;
|
||||
|
||||
/// Get Eagle leayer number by its name
|
||||
/// Get Eagle layer number by its name
|
||||
int eagle_layer_id( const wxString& aLayerName ) const;
|
||||
|
||||
/// This PLUGIN only caches one footprint library, this determines which one.
|
||||
|
@ -255,22 +247,22 @@ private:
|
|||
void loadSignals( wxXmlNode* aSignals );
|
||||
|
||||
/**
|
||||
* Function loadLibrary
|
||||
* loads the Eagle "library" XML element, which can occur either under
|
||||
* a "libraries" element (if a *.brd file) or under a "drawing" element if a
|
||||
* *.lbr file.
|
||||
* Load the Eagle "library" XML element, which can occur either under a "libraries"
|
||||
* element (if a *.brd file) or under a "drawing" element if a *.lbr file.
|
||||
*
|
||||
* @param aLib is the portion of the loaded XML document tree that is the "library"
|
||||
* element.
|
||||
* element.
|
||||
* @param aLibName is a pointer to the library name or NULL. If NULL this means
|
||||
* we are loading a *.lbr not a *.brd file and the key used in m_templates is to exclude
|
||||
* the library name.
|
||||
* we are loading a *.lbr not a *.brd file and the key used in m_templates
|
||||
* is to exclude the library name.
|
||||
*/
|
||||
void loadLibrary( wxXmlNode* aLib, const wxString* aLibName );
|
||||
|
||||
void loadLibraries( wxXmlNode* aLibs );
|
||||
void loadElements( wxXmlNode* aElements );
|
||||
|
||||
/** Loads a copper or keepout polygon and adds it to the board.
|
||||
/**
|
||||
* Load a copper or keepout polygon and adds it to the board.
|
||||
*
|
||||
* @return The loaded zone or nullptr if was not processed.
|
||||
*/
|
||||
|
@ -287,8 +279,7 @@ private:
|
|||
void centerBoard();
|
||||
|
||||
/**
|
||||
* Function makeFootprint
|
||||
* creates a FOOTPRINT from an Eagle package.
|
||||
* Create a FOOTPRINT from an Eagle package.
|
||||
*/
|
||||
FOOTPRINT* makeFootprint( wxXmlNode* aPackage, const wxString& aPkgName );
|
||||
|
||||
|
@ -300,11 +291,9 @@ private:
|
|||
void packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const;
|
||||
|
||||
/**
|
||||
* Function packageHole
|
||||
* @parameter aFootprint - The KiCad footprint to which to assign the hole
|
||||
* @parameter aTree - The Eagle XML node that is of type "hole"
|
||||
* @parameter aCenter - If true, center the hole in the footprint and
|
||||
* offset the footprint position
|
||||
* @param aFootprint The KiCad footprint to which to assign the hole.
|
||||
* @param aTree The Eagle XML node that is of type "hole".
|
||||
* @param aCenter If true, center the hole in the footprint and offset the footprint position.
|
||||
*/
|
||||
void packageHole( FOOTPRINT* aFootprint, wxXmlNode* aTree, bool aCenter ) const;
|
||||
void packageSMD( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2020 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -38,20 +38,14 @@ class GPCB_FPL_CACHE;
|
|||
|
||||
|
||||
/**
|
||||
* GPCB_PLUGIN
|
||||
* is a PLUGIN derivation for saving and loading Geda PCB files.
|
||||
* A #PLUGIN derivation for saving and loading Geda PCB files.
|
||||
*
|
||||
* @note This class is not thread safe, but it is re-entrant multiple times in sequence.
|
||||
* @note Currently only reading GPCB footprint files is implemented.
|
||||
*/
|
||||
class GPCB_PLUGIN : public PLUGIN
|
||||
{
|
||||
friend class GPCB_FPL_CACHE;
|
||||
|
||||
public:
|
||||
|
||||
//-----<PLUGIN API>---------------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override
|
||||
{
|
||||
return wxT( "Geda PCB" );
|
||||
|
@ -63,20 +57,20 @@ public:
|
|||
}
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
bool FootprintLibDelete( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
|
||||
|
||||
|
@ -90,15 +84,6 @@ public:
|
|||
|
||||
~GPCB_PLUGIN();
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_error; ///< for throwing exceptions
|
||||
const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
GPCB_FPL_CACHE* m_cache; ///< Footprint library cache.
|
||||
int m_ctl;
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
|
||||
private:
|
||||
void validateCache( const wxString& aLibraryPath, bool checkModified = true );
|
||||
|
||||
|
@ -106,6 +91,16 @@ private:
|
|||
const PROPERTIES* aProperties, bool checkModified );
|
||||
|
||||
void init( const PROPERTIES* aProperties );
|
||||
|
||||
friend class GPCB_FPL_CACHE;
|
||||
|
||||
protected:
|
||||
wxString m_error; ///< for throwing exceptions
|
||||
const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
GPCB_FPL_CACHE* m_cache; ///< Footprint library cache.
|
||||
int m_ctl;
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
};
|
||||
|
||||
#endif // _GPCB_PLUGIN_H_
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
*
|
||||
* @param aFootprint if set, save only this footprint, otherwise, save the full library
|
||||
*/
|
||||
void Save( FOOTPRINT* aFootprint = NULL );
|
||||
void Save( FOOTPRINT* aFootprint = nullptr );
|
||||
|
||||
void Load();
|
||||
|
||||
|
@ -2081,7 +2081,8 @@ PCB_IO::~PCB_IO()
|
|||
}
|
||||
|
||||
|
||||
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
||||
PROJECT* aProject )
|
||||
{
|
||||
FILE_LINE_READER reader( aFileName );
|
||||
|
||||
|
@ -2135,8 +2136,8 @@ BOARD* PCB_IO::DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const PROPERTIE
|
|||
|
||||
void PCB_IO::init( const PROPERTIES* aProperties )
|
||||
{
|
||||
m_board = NULL;
|
||||
m_reader = NULL;
|
||||
m_board = nullptr;
|
||||
m_reader = nullptr;
|
||||
m_props = aProperties;
|
||||
}
|
||||
|
||||
|
@ -2275,7 +2276,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFoot
|
|||
return;
|
||||
|
||||
// Save throws its own IO_ERROR on failure, so no need to recreate here
|
||||
m_cache->Save( NULL );
|
||||
m_cache->Save( nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2466,7 +2467,7 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
|
|||
if( m_cache && !m_cache->IsPath( aLibraryPath ) )
|
||||
{
|
||||
delete m_cache;
|
||||
m_cache = NULL;
|
||||
m_cache = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -2477,7 +2478,7 @@ bool PCB_IO::IsFootprintLibWritable( const wxString& aLibraryPath )
|
|||
{
|
||||
LOCALE_IO toggle;
|
||||
|
||||
init( NULL );
|
||||
init( nullptr );
|
||||
|
||||
validateCache( aLibraryPath );
|
||||
|
||||
|
|
|
@ -99,11 +99,13 @@ class PCB_TEXT;
|
|||
#define CTL_OMIT_TSTAMPS (1 << 2) ///< Omit component time stamp (useless in library)
|
||||
#define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit FOOTPRINT initial comments
|
||||
#define CTL_OMIT_PATH (1 << 4) ///< Omit component sheet time stamp (useless in library)
|
||||
#define CTL_OMIT_AT (1 << 5) ///< Omit position and rotation
|
||||
// (always saved with potion 0,0 and rotation = 0 in library)
|
||||
#define CTL_OMIT_AT (1 << 5) ///< Omit position and rotation. (always saved
|
||||
///< with potion 0,0 and rotation = 0 in library).
|
||||
//#define CTL_OMIT_HIDE (1 << 6) // found and defined in eda_text.h
|
||||
#define CTL_OMIT_LIBNAME (1 << 7) ///< Omit lib alias when saving (used for board/not library)
|
||||
#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8) ///< Omit the version string from the (footprint ) sexpr group
|
||||
#define CTL_OMIT_LIBNAME (1 << 7) ///< Omit lib alias when saving (used for
|
||||
///< board/not library).
|
||||
#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8) ///< Omit the version string from the (footprint)
|
||||
///<sexpr group
|
||||
|
||||
// common combinations of the above:
|
||||
|
||||
|
@ -111,7 +113,8 @@ class PCB_TEXT;
|
|||
#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS) // (CTL_OMIT_NETS)
|
||||
|
||||
/// Format output for a footprint library instead of clipboard or BOARD
|
||||
#define CTL_FOR_LIBRARY (CTL_OMIT_NETS|CTL_OMIT_TSTAMPS|CTL_OMIT_PATH|CTL_OMIT_AT|CTL_OMIT_LIBNAME)
|
||||
#define CTL_FOR_LIBRARY \
|
||||
( CTL_OMIT_NETS | CTL_OMIT_TSTAMPS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
|
||||
|
||||
/// The zero arg constructor when PCB_IO is used for PLUGIN::Load() and PLUGIN::Save()ing
|
||||
/// a BOARD file underneath IO_MGR.
|
||||
|
@ -119,19 +122,13 @@ class PCB_TEXT;
|
|||
|
||||
|
||||
/**
|
||||
* PCB_IO
|
||||
* is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
|
||||
* A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
|
||||
*
|
||||
* @note This class is not thread safe, but it is re-entrant multiple times in sequence.
|
||||
*/
|
||||
class PCB_IO : public PLUGIN
|
||||
{
|
||||
friend class FP_CACHE;
|
||||
|
||||
public:
|
||||
|
||||
//-----<PLUGIN API>---------------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override
|
||||
{
|
||||
return wxT( "KiCad" );
|
||||
|
@ -147,44 +144,42 @@ public:
|
|||
}
|
||||
|
||||
virtual void Save( const wxString& aFileName, BOARD* aBoard,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
|
||||
BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const PROPERTIES* aProperties );
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
|
||||
|
||||
void FootprintLibCreate( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL) override;
|
||||
const PROPERTIES* aProperties = nullptr) override;
|
||||
|
||||
bool FootprintLibDelete( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
|
||||
|
||||
//-----</PLUGIN API>--------------------------------------------------------
|
||||
|
||||
PCB_IO( int aControlFlags = CTL_FOR_BOARD );
|
||||
|
||||
~PCB_IO();
|
||||
|
@ -213,24 +208,6 @@ public:
|
|||
BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_error; ///< for throwing exceptions
|
||||
BOARD* m_board; ///< which BOARD, no ownership here
|
||||
|
||||
const
|
||||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
FP_CACHE* m_cache; ///< Footprint library cache.
|
||||
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
|
||||
STRING_FORMATTER m_sf;
|
||||
OUTPUTFORMATTER* m_out; ///< output any Format()s to this, no ownership
|
||||
int m_ctl;
|
||||
PCB_PARSER* m_parser;
|
||||
NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes
|
||||
///< are stored with consecutive integers as net codes
|
||||
|
||||
void validateCache( const wxString& aLibraryPath, bool checkModified = true );
|
||||
|
||||
const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
|
@ -284,6 +261,26 @@ private:
|
|||
void formatLayer( const BOARD_ITEM* aItem ) const;
|
||||
|
||||
void formatLayers( LSET aLayerMask, int aNestLevel = 0 ) const;
|
||||
|
||||
friend class FP_CACHE;
|
||||
|
||||
protected:
|
||||
wxString m_error; ///< for throwing exceptions
|
||||
BOARD* m_board; ///< which BOARD, no ownership here
|
||||
|
||||
const
|
||||
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
|
||||
FP_CACHE* m_cache; ///< Footprint library cache.
|
||||
|
||||
LINE_READER* m_reader; ///< no ownership here.
|
||||
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
||||
|
||||
STRING_FORMATTER m_sf;
|
||||
OUTPUTFORMATTER* m_out; ///< output any Format()s to this, no ownership
|
||||
int m_ctl;
|
||||
PCB_PARSER* m_parser;
|
||||
NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes
|
||||
///< are stored with consecutive integers as net codes
|
||||
};
|
||||
|
||||
#endif // KICAD_PLUGIN_H_
|
||||
|
|
|
@ -344,8 +344,7 @@ LSET LEGACY_PLUGIN::leg_mask2new( int cu_count, unsigned aMask )
|
|||
|
||||
|
||||
/**
|
||||
* Function intParse
|
||||
* parses an ASCII integer string with possible leading whitespace into
|
||||
* Parse an ASCII integer string with possible leading whitespace into
|
||||
* an integer and updates the pointer at \a out if it is not NULL, just
|
||||
* like "man strtol()". I can use this without casting, and its name says
|
||||
* what I am doing.
|
||||
|
@ -357,8 +356,7 @@ static inline int intParse( const char* next, const char** out = NULL )
|
|||
}
|
||||
|
||||
/**
|
||||
* Function layerParse
|
||||
* Like intParse but returns a LAYER_NUM
|
||||
* Like #intParse but returns a LAYER_NUM.
|
||||
*/
|
||||
static inline LAYER_NUM layerParse( const char* next, const char** out = NULL )
|
||||
{
|
||||
|
@ -366,8 +364,7 @@ static inline LAYER_NUM layerParse( const char* next, const char** out = NULL )
|
|||
}
|
||||
|
||||
/**
|
||||
* Function hexParse
|
||||
* parses an ASCII hex integer string with possible leading whitespace into
|
||||
* Parse an ASCII hex integer string with possible leading whitespace into
|
||||
* a long integer and updates the pointer at \a out if it is not NULL, just
|
||||
* like "man strtol". I can use this without casting, and its name says
|
||||
* what I am doing.
|
||||
|
@ -380,7 +377,7 @@ static inline long hexParse( const char* next, const char** out = NULL )
|
|||
|
||||
|
||||
BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties )
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -54,8 +54,7 @@ struct LP_CACHE;
|
|||
|
||||
|
||||
/**
|
||||
* LEGACY_PLUGIN
|
||||
* is a PLUGIN derivation which could possibly be put into a DLL/DSO.
|
||||
* A #PLUGIN derivation which could possibly be put into a DLL/DSO.
|
||||
* As with any PLUGIN, there is no UI, i.e. windowing calls allowed.
|
||||
*/
|
||||
class LEGACY_PLUGIN : public PLUGIN
|
||||
|
@ -66,8 +65,6 @@ public:
|
|||
LEGACY_PLUGIN();
|
||||
~LEGACY_PLUGIN();
|
||||
|
||||
//-----<PLUGIN API>---------------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override
|
||||
{
|
||||
return wxT( "KiCad-Legacy" );
|
||||
|
@ -79,23 +76,21 @@ public:
|
|||
}
|
||||
|
||||
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
bool FootprintLibDelete( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr ) override;
|
||||
|
||||
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
|
||||
|
||||
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
|
||||
|
||||
//-----</PLUGIN API>--------------------------------------------------------
|
||||
|
||||
typedef int BIU;
|
||||
|
||||
void SetReader( LINE_READER* aReader ) { m_reader = aReader; }
|
||||
|
@ -117,37 +112,31 @@ protected:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function biuParse
|
||||
* parses an ASCII decimal floating point value and scales it into a BIU
|
||||
* according to the current value of diskToBui. This fuction is the complement of
|
||||
* fmtBIU(). One has to know what the other is doing.
|
||||
* Parse an ASCII decimal floating point value and scales it into a BIU according to the
|
||||
* current value of diskToBui.
|
||||
*
|
||||
* This fuction is the complement of #fmtBIU(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return BIU - the converted Board Internal Unit.
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a pointer to the
|
||||
* next unconsumed input text. See "man strtod" for more information.
|
||||
* @return the converted Board Internal Unit.
|
||||
*/
|
||||
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
|
||||
BIU biuParse( const char* aValue, const char** nptrptr = nullptr );
|
||||
|
||||
/**
|
||||
* Function degParse
|
||||
* parses an ASCII decimal floating point value which is certainly an angle. This
|
||||
* is a dedicated function for encapsulating support for the migration from
|
||||
* Parse an ASCII decimal floating point value which is certainly an angle.
|
||||
*
|
||||
* This is a dedicated function for encapsulating support for the migration from
|
||||
* tenths of degrees to degrees in floating point. This function is the complement of
|
||||
* fmtDEG(). One has to know what the other is doing.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
||||
*
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
||||
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
||||
*
|
||||
* @return double - the string converted to a primitive double type
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace.
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a pointer to the
|
||||
* next unconsumed input text. See "man strtod" for more information.
|
||||
* @return the string converted to a primitive double type
|
||||
*/
|
||||
double degParse( const char* aValue, const char** nptrptr = NULL );
|
||||
|
||||
//-----<load/parse functions>-----------------------------------------------
|
||||
double degParse( const char* aValue, const char** nptrptr = nullptr );
|
||||
|
||||
void checkVersion();
|
||||
|
||||
|
@ -170,8 +159,7 @@ protected:
|
|||
void loadFOOTPRINT( FOOTPRINT* aFootprint );
|
||||
|
||||
/**
|
||||
* Function loadTrackList
|
||||
* reads a list of segments (Tracks and Vias, or Segzones)
|
||||
* Read a list of segments (Tracks and Vias, or Segzones)
|
||||
*
|
||||
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or NOT_USED
|
||||
* to indicate oldschool zone segments (which are discarded).
|
||||
|
@ -182,8 +170,6 @@ protected:
|
|||
void loadDIMENSION(); // "$COTATION"
|
||||
void loadPCB_TARGET(); // "$PCB_TARGET"
|
||||
|
||||
//-----</ load/parse functions>---------------------------------------------
|
||||
|
||||
/// we only cache one footprint library for now, this determines which one.
|
||||
void cacheLib( const wxString& aLibraryPath );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -64,7 +64,8 @@ const wxString PCAD_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
|
||||
BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties, PROJECT* aProject )
|
||||
{
|
||||
wxXmlDocument xmlDoc;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Alexander Lunev <al.lunev@yahoo.com>
|
||||
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,14 +36,12 @@
|
|||
class PCAD_PLUGIN : public PLUGIN
|
||||
{
|
||||
public:
|
||||
|
||||
// -----<PUBLIC PLUGIN API>--------------------------------------------------
|
||||
|
||||
const wxString PluginName() const override;
|
||||
|
||||
BOARD* Load( const wxString& aFileName,
|
||||
BOARD* aAppendToMe,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = nullptr,
|
||||
PROJECT* aProject = nullptr ) override;
|
||||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
|
@ -53,8 +51,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -----</PUBLIC PLUGIN API>-------------------------------------------------
|
||||
|
||||
PCAD_PLUGIN();
|
||||
~PCAD_PLUGIN();
|
||||
|
||||
|
|
Loading…
Reference in New Issue