Make PLUGIN::Footprint*() API functions take 'const' PROPERTIES*.

Add const PROPERTIES* to FootprintDelete().
Add {Get,Set}Properties() to FP_LIB_TABLE::ROW.
Touch up fp table dialog.
This commit is contained in:
Dick Hollenbeck 2013-09-25 14:17:06 -05:00
parent 4afae65110
commit f72394cc6b
22 changed files with 183 additions and 208 deletions

View File

@ -73,4 +73,11 @@ Dialogs:
within the dialog, but for testing purposes please do not exceed this dialog
size should the user have selected a font size of 13 points.
Quoting:
Filenames and paths should be emphasized with <> angle brackets. Anything
else should be emphasized with single quotes ''. e.g.:
<filename.kicad_pcb>
<longpath/subdir>
'FOOTPRINTNAME'
'anything else'

View File

@ -140,25 +140,22 @@ PCBNew
various zoom factors. I believe that a fixed distance in pixels might make
for a friendlier UI.
*) Check that the new load visibility BOARD settings is properly setting the toolbar
buttons like show grid or ratsnest. Add PCB_EDIT_FRAME::SetVisibleElements() so
toolbar crap is not known to a BOARD.
*) Finish removing global access requirements from PLUGINs, so that:
*) a BOARD is a fully self contained document description.
*) plugin developers do not have to access globals, since a plugin could
very well be a dynamically loaded DLL/DSO in the future.
One final problem remains is the BASE_SCREEN's grid origin. An easy
solution is to move just that one field into the BOARD.
*) Add ::Footprint*() functions to EAGLE_PLUGIN, so that Eagle footprint libraries
can be used in situ.
*) Add a library table for Pcbnew like that in the sweet library and get rid of the
damn search path strategy. This will enable concurrent usage of various types
of PLUGIN::Footprint*() functions. At least LEGACY and KICAD are both needed
concurrently.
*) Add a hot key to toggle the 45 degree constraint on and off so that it can be
changed when drawing a trace.
Dick's Final TODO List:
======================
*) write options dialog for fp table dialog.
*) Apply Fabrizio and Alexander's linux desktop patches after unifying them.
*) Get licensing cleaned up.
*) Re-arrange the repo architecture.
*) Merge KiCad GAL/TOM/ORSON if nobody else does.
*) lib_convert.py (i.e. convert) all footprint libraries to pretty format and move copy them to
github if nobody else does.
*) DLL-ization of pcbnew eeschema
*) Pass options, i.e. PROPERTIES to all PLUGIN::Footprint*() calls. Current code needs
to be based on NickNames, not Libpaths, so we have access to the FP_LIB_TABLE::ROWs.
User should not be prompted for a libpath for reading from it, he/she must pick from the
known list of nicknames. Possibly duplicate some of the PLUGIN:::Footprint*() api in ROW or
FP_LIB_TABLE. Again, limited to PLUGIN::Footprint*() calls, not Load() and Save().

View File

@ -133,6 +133,7 @@ set(PCB_COMMON_SRCS
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
../pcbnew/plugin.cpp
../pcbnew/eagle_plugin.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp

View File

@ -235,7 +235,6 @@ PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList )
++cp; // skip the escape
pair += *cp++; // add the separator
}
else if( *cp==OPT_SEP )
{
++cp; // skip the separator
@ -248,7 +247,7 @@ PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList )
// stash the pair
if( pair.size() )
{
// the first equals size established the end of the name
// first equals sign separates 'name' and 'value'.
size_t eqNdx = pair.find( '=' );
if( eqNdx != pair.npos )
{
@ -257,7 +256,7 @@ PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList )
props[name] = value;
}
else
props[pair] = "";
props[pair] = ""; // property is present, but with no value.
}
}

View File

@ -216,6 +216,24 @@ public:
*/
void SetDescr( const wxString& aDescr ) { description = aDescr; }
/**
* Function GetProperties
* returns the constant PROPERTIES for this library (ROW). These are
* the "options" in a table.
*/
const PROPERTIES* GetProperties() const { return properties; }
/**
* Function SetProperties
* sets this ROW's PROPERTIES by taking ownership of @a aProperties.
* @param aProperties ownership is given over to this ROW.
*/
void SetProperties( const PROPERTIES* aProperties )
{
delete properties;
properties = aProperties;
}
//-----</accessors>-----------------------------------------------------
/**
@ -236,6 +254,7 @@ public:
LIB_T type;
wxString options;
wxString description;
const
PROPERTIES* properties;
};

View File

@ -412,11 +412,10 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
{
wxString nick = model.GetValue( r, COL_NICKNAME ).Trim( false ).Trim();
wxString uri = model.GetValue( r, COL_URI ).Trim( false ).Trim();
wxString type = model.GetValue( r, COL_TYPE ).Trim( false ).Trim();
if( !nick || !uri || !type )
if( !nick || !uri )
{
// Delete the "empty" row, where empty means missing nick, uri, or type.
// Delete the "empty" row, where empty means missing nick or uri.
// This also updates the UI which could be slow, but there should only be a few
// rows to delete, unless the user fell asleep on the Add Row
// button.
@ -434,7 +433,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_auinotebook->SetSelection( &model == &m_global_model ? 0 : 1 );
}
// go to the bottom of the two rows, it is technically the duplicate:
// go to the problematic row
m_cur_grid->SelectBlock( r, 0, r, 0 );
m_cur_grid->MakeCellVisible( r, 0 );
@ -447,7 +446,6 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
// set the trimmed values back into the table so they get saved to disk.
model.SetValue( r, COL_NICKNAME, nick );
model.SetValue( r, COL_URI, uri );
model.SetValue( r, COL_TYPE, type );
++r; // this row was OK.
}
}
@ -460,9 +458,10 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
for( int r1 = 0; r1 < model.GetNumberRows() - 1; ++r1 )
{
wxString nick1 = model.GetValue( r1, COL_NICKNAME );
for( int r2=r1+1; r2 < model.GetNumberRows(); ++r2 )
{
wxString nick1 = model.GetValue( r1, COL_NICKNAME );
wxString nick2 = model.GetValue( r2, COL_NICKNAME );
if( nick1 == nick2 )
@ -478,7 +477,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_auinotebook->SetSelection( &model == &m_global_model ? 0 : 1 );
}
// go to the bottom of the two rows, it is technically the duplicate:
// go to the lower of the two rows, it is technically the duplicate:
m_cur_grid->SelectBlock( r2, 0, r2, 0 );
m_cur_grid->MakeCellVisible( r2, 0 );
@ -582,7 +581,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
void optionsEditor( wxMouseEvent& event )
{
// @todo: write the options editor, and pass the options to the Footprint*() calls.
D(printf("%s:%d\n", __func__, (int) m_cur_grid->GetNumberRows() );)
//D(printf("%s:%d\n", __func__, (int) m_cur_grid->GetNumberRows() );)
}
void onCancelButtonClick( wxCommandEvent& event )

View File

@ -1105,7 +1105,7 @@ wxSize inline EAGLE_PLUGIN::kicad_fontz( double d ) const
}
BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
PTREE doc;
@ -1188,7 +1188,7 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
}
void EAGLE_PLUGIN::init( PROPERTIES* aProperties )
void EAGLE_PLUGIN::init( const PROPERTIES* aProperties )
{
m_hole_count = 0;
@ -2800,7 +2800,7 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
}
wxArrayString EAGLE_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
wxArrayString EAGLE_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
init( aProperties );
@ -2815,7 +2815,7 @@ wxArrayString EAGLE_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PR
}
MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, PROPERTIES* aProperties )
MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties )
{
init( aProperties );
@ -2836,13 +2836,13 @@ MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStrin
/*
void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{
// Eagle lovers apply here.
}
void EAGLE_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
void EAGLE_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, const PROPERTIES* aProperties )
{
}
@ -2852,12 +2852,12 @@ void EAGLE_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString
}
void EAGLE_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
void EAGLE_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
}
bool EAGLE_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
bool EAGLE_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
}

View File

@ -82,13 +82,13 @@ public:
//-----<PUBLIC PLUGIN API>--------------------------------------------------
const wxString& PluginName() const;
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL );
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL );
const wxString& GetFileExtension() const;
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL);
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, PROPERTIES* aProperties = NULL );
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath )
{
@ -96,16 +96,15 @@ public:
}
/*
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL );
void Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, const PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
*/
//-----</PUBLIC PLUGIN API>-------------------------------------------------
@ -132,7 +131,7 @@ private:
///< lookup key is either libname.packagename or simply
///< packagename if FootprintLoad() or FootprintEnumberate()
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
BOARD* m_board; ///< which BOARD is being worked on, no ownership here
int m_min_trace; ///< smallest trace we find on Load(), in BIU.
@ -146,7 +145,7 @@ private:
wxDateTime m_mod_time;
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( PROPERTIES* aProperties );
void init( const PROPERTIES* aProperties );
void clear_cu_map();

View File

@ -805,7 +805,7 @@ GPCB_PLUGIN::~GPCB_PLUGIN()
}
void GPCB_PLUGIN::init( PROPERTIES* aProperties )
void GPCB_PLUGIN::init( const PROPERTIES* aProperties )
{
m_props = aProperties;
}
@ -824,7 +824,7 @@ void GPCB_PLUGIN::cacheLib( const wxString& aLibraryPath )
wxArrayString GPCB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath,
PROPERTIES* aProperties )
const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -846,7 +846,7 @@ wxArrayString GPCB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath,
MODULE* GPCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -868,11 +868,11 @@ MODULE* GPCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString
}
void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
init( NULL );
init( aProperties );
cacheLib( aLibraryPath );
@ -886,7 +886,7 @@ void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString&
}
bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
wxFileName fn;
fn.SetPath( aLibraryPath );

View File

@ -64,14 +64,14 @@ public:
return extension;
}
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL);
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath );
@ -86,7 +86,7 @@ public:
protected:
wxString m_error; ///< for throwing exceptions
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
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;
@ -97,7 +97,7 @@ private:
/// we only cache one footprint library for now, this determines which one.
void cacheLib( const wxString& aLibraryPath );
void init( PROPERTIES* aProperties );
void init( const PROPERTIES* aProperties );
};
#endif // _GPCB_PLUGIN_H_

View File

@ -54,9 +54,6 @@
// plugins coexisting.
// static LEGACY_PLUGIN kicad_plugin;
// static EAGLE_PLUGIN eagle_plugin;
PLUGIN* IO_MGR::PluginFind( PCB_FILE_T aFileType )
{
// This implementation is subject to change, any magic is allowed here.
@ -221,7 +218,7 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath
BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
// release the PLUGIN even if an exception is thrown.
PLUGIN::RELEASER pi = PluginFind( aFileType );
@ -235,7 +232,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
}
void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard, 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 );
@ -249,67 +246,3 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
THROW_IO_ERROR( wxString::Format( FMT_NOTFOUND, ShowType( aFileType ).GetData() ) );
}
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
}
void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
}
wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}

View File

@ -134,7 +134,7 @@ public:
* or file cannot be loaded.
*/
static BOARD* Load( PCB_FILE_T aFileType, const wxString& aFileName,
BOARD* aAppendToMe = NULL, PROPERTIES* aProperties = NULL );
BOARD* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
/**
* Function Save
@ -160,7 +160,7 @@ public:
* @throw IO_ERROR if there is a problem saving or exporting.
*/
static void Save( PCB_FILE_T aFileType, const wxString& aFileName,
BOARD* aBoard, PROPERTIES* aProperties = NULL );
BOARD* aBoard, const PROPERTIES* aProperties = NULL );
};
@ -231,7 +231,7 @@ public:
* input file if possible.
*/
virtual BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
/**
* Function Save
@ -254,7 +254,7 @@ public:
* @throw IO_ERROR if there is a problem saving or exporting.
*/
virtual void Save( const wxString& aFileName, BOARD* aBoard,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
//-----<Footprint Stuff>-----------------------------
@ -276,7 +276,7 @@ public:
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
*/
virtual wxArrayString FootprintEnumerate( const wxString& aLibraryPath,
PROPERTIES* aProperties = NULL);
const PROPERTIES* aProperties = NULL );
/**
* Function FootprintLoad
@ -300,7 +300,7 @@ public:
* is thrown in the case where aFootprintName cannot be found.
*/
virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
/**
* Function FootprintSave
@ -323,7 +323,7 @@ public:
* @throw IO_ERROR if there is a problem saving.
*/
virtual void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
/**
* Function FootprintDelete
@ -334,9 +334,16 @@ public:
*
* @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 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 footprint or the library, or deleting it.
*/
virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
virtual void FootprintDelete( const wxString& aLibraryPath,
const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
/**
* Function FootprintLibCreate
@ -355,7 +362,7 @@ public:
*
* @throw IO_ERROR if there is a problem finding the library, or creating it.
*/
virtual void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
virtual void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
/**
* Function FootprintLibDelete
@ -376,7 +383,7 @@ public:
*
* @throw IO_ERROR if there is a problem deleting an existing library.
*/
virtual bool FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
virtual bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
/**
* Function IsFootprintLibWritable

View File

@ -361,7 +361,7 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN
}
void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -1632,7 +1632,7 @@ PCB_IO::~PCB_IO()
}
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
FILE_LINE_READER reader( aFileName );
@ -1652,7 +1652,7 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
}
void PCB_IO::init( PROPERTIES* aProperties )
void PCB_IO::init( const PROPERTIES* aProperties )
{
m_board = NULL;
m_props = aProperties;
@ -1671,7 +1671,7 @@ void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintN
}
wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -1693,7 +1693,7 @@ wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, PROPERTI
MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -1716,7 +1716,7 @@ MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFo
void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties )
const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -1783,7 +1783,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
}
void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -1801,7 +1801,7 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
}
void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
if( wxDir::Exists( aLibraryPath ) )
{
@ -1819,7 +1819,7 @@ void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProp
}
bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
wxFileName fn;
fn.SetPath( aLibraryPath );

View File

@ -99,23 +99,23 @@ public:
}
void Save( const wxString& aFileName, BOARD* aBoard,
PROPERTIES* aProperties = NULL ); // overload
const PROPERTIES* aProperties = NULL ); // overload
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL );
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL );
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL);
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL);
bool FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath );
@ -156,7 +156,7 @@ protected:
wxString m_error; ///< for throwing exceptions
BOARD* m_board; ///< which BOARD, no ownership here
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
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.
@ -212,7 +212,7 @@ private:
/// we only cache one footprint library for now, this determines which one.
void cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName = wxEmptyString );
void init( PROPERTIES* aProperties );
void init( const PROPERTIES* aProperties );
};
#endif // KICAD_PLUGIN_H_

View File

@ -231,7 +231,7 @@ static inline long hexParse( const char* next, const char** out = NULL )
}
BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -2817,7 +2817,7 @@ double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr )
}
void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
void LEGACY_PLUGIN::init( const PROPERTIES* aProperties )
{
m_board = NULL;
m_props = aProperties;
@ -2838,7 +2838,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
//-----<BOARD Save Functions>---------------------------------------------------
void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -2858,17 +2858,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
m_fp = fp; // member function accessibility
#if 0 // old school, property "header" was not used by any other plugin.
if( m_props )
{
wxString header = (*m_props)["header"];
// save a file header, if caller provided one (with trailing \n hopefully).
fprintf( m_fp, "%s", TO_UTF8( header ) );
}
#else
wxString header = wxString::Format(
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s\n\n" ),
LEGACY_BOARD_FILE_VERSION, DateAndTime().GetData(),
@ -2876,7 +2865,6 @@ void LEGACY_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES*
// save a file header, if caller provided one (with trailing \n hopefully).
fprintf( m_fp, "%s", TO_UTF8( header ) );
#endif
SaveBOARD( aBoard );
}
@ -4225,7 +4213,7 @@ void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
}
wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -4246,8 +4234,8 @@ wxArrayString LEGACY_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, P
}
MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
const wxString& aFootprintName, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -4274,7 +4262,8 @@ MODULE* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStri
}
void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath,
const MODULE* aFootprint, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -4318,7 +4307,8 @@ void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* a
}
void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath,
const wxString& aFootprintName, const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
@ -4346,7 +4336,7 @@ void LEGACY_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin
}
void LEGACY_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
void LEGACY_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
if( wxFileExists( aLibraryPath ) )
{
@ -4366,7 +4356,7 @@ void LEGACY_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES
}
bool LEGACY_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
bool LEGACY_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
wxFileName fn = aLibraryPath;

View File

@ -76,23 +76,23 @@ public:
return extension;
}
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL );
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
void Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties = NULL );
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL);
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName );
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
void FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath );
@ -116,7 +116,7 @@ protected:
wxString m_error; ///< for throwing exceptions
BOARD* m_board; ///< which BOARD, no ownership here
PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
LINE_READER* m_reader; ///< no ownership here.
FILE* m_fp; ///< no ownership here.
@ -127,7 +127,7 @@ protected:
LP_CACHE* m_cache;
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( PROPERTIES* aProperties );
void init( const PROPERTIES* aProperties );
double biuToDisk; ///< convert from BIUs to disk engineering units
///< with this scale factor

View File

@ -619,7 +619,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath,
if( ! MODULE::IsLibNameValid( footprintName ) )
{
wxString msg;
msg.Printf( _("Error:\none of invalid chars <%s> found\nin <%s>" ),
msg.Printf( _("Error:\none of invalid chars '%s' found\nin '%s'" ),
MODULE::ReturnStringLibNameInvalidChars( true ),
GetChars( footprintName ) );

View File

@ -451,7 +451,7 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
return pi->FootprintLoad( libPath, footprintName );
return pi->FootprintLoad( libPath, footprintName, row->GetProperties() );
}

View File

@ -71,7 +71,7 @@ const wxString& PCAD_PLUGIN::GetFileExtension() const
}
BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
wxXmlDocument xmlDoc;

View File

@ -43,7 +43,7 @@ public:
BOARD* Load( const wxString& aFileName,
BOARD* aAppendToMe,
PROPERTIES* aProperties = NULL );
const PROPERTIES* aProperties = NULL );
const wxString& GetFileExtension() const;
@ -52,7 +52,7 @@ public:
PCAD_PLUGIN();
~PCAD_PLUGIN();
private:
PROPERTIES* m_props;
const PROPERTIES* m_props;
BOARD* m_board;
};

View File

@ -1,27 +1,48 @@
/*
* 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) 2011 KiCad Developers, see change_log.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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <io_mgr.h>
//#include <string>
#define FMT_UNIMPLEMENTED _( "Plugin '%s' does not implement the '%s' function." )
#define FMT_NOTFOUND _( "Plugin type '%s' is not found." )
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
}
void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData(), __FUNCTION__ ) );
}
wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties )
wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
@ -29,35 +50,35 @@ wxArrayString PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, PROPERTI
MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
PROPERTIES* aProperties )
const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, PROPERTIES* aProperties )
void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, PROPERTIES* aProperties )
void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );
}
bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties )
bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, PluginName().GetData() , __FUNCTION__ ) );

View File

@ -88,6 +88,7 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard,
aBoard->SynchronizeNetsAndNetClasses();
aBoard->SetCurrentNetClass( aBoard->m_NetClasses.GetDefault()->GetName() );
#if 0
wxString header;
PROPERTIES props;
@ -100,7 +101,9 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard,
props["header"] = header;
}
IO_MGR::Save( aFormat, aFileName, aBoard, &props );
#else
IO_MGR::Save( aFormat, aFileName, aBoard, NULL );
#endif
return true;
}