2013-09-25 19:17:06 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2020-12-18 15:40:13 +00:00
|
|
|
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-09-25 19:17:06 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2013-09-21 07:30:23 +00:00
|
|
|
|
|
|
|
#include <io_mgr.h>
|
2016-07-06 09:22:56 +00:00
|
|
|
#include <properties.h>
|
2020-10-01 08:52:03 +00:00
|
|
|
#include <wx/translation.h>
|
2016-07-06 09:22:56 +00:00
|
|
|
|
2013-09-21 07:30:23 +00:00
|
|
|
|
2020-10-01 08:52:03 +00:00
|
|
|
#define FMT_UNIMPLEMENTED "Plugin \"%s\" does not implement the \"%s\" function."
|
2013-09-30 21:26:49 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 15:40:13 +00:00
|
|
|
* Throw an #IO_ERROR and complains of an API function not being implemented.
|
2013-09-30 21:26:49 +00:00
|
|
|
*
|
2020-12-18 15:40:13 +00:00
|
|
|
* @param aPlugin is a #PLUGIN instance.
|
2013-09-30 21:26:49 +00:00
|
|
|
* @param aCaller is the name of the unimplemented API function.
|
|
|
|
*/
|
|
|
|
static void not_implemented( PLUGIN* aPlugin, const char* aCaller )
|
|
|
|
{
|
|
|
|
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
|
2020-10-01 08:52:03 +00:00
|
|
|
aPlugin->PluginName(),
|
|
|
|
wxString::FromUTF8( aCaller ) ) );
|
2013-09-30 21:26:49 +00:00
|
|
|
}
|
2013-09-21 07:30:23 +00:00
|
|
|
|
|
|
|
|
2020-12-18 15:40:13 +00:00
|
|
|
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties,
|
|
|
|
PROJECT* aProject )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2020-12-18 15:40:13 +00:00
|
|
|
return nullptr;
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-31 21:55:51 +00:00
|
|
|
std::vector<FOOTPRINT*> PLUGIN::GetImportedCachedLibraryFootprints()
|
|
|
|
{
|
|
|
|
not_implemented( this, __FUNCTION__ );
|
|
|
|
return std::vector<FOOTPRINT*>();
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:17:06 +00:00
|
|
|
void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-11 20:20:44 +00:00
|
|
|
void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
2019-08-31 14:18:27 +00:00
|
|
|
bool aBestEfforts, const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
void PLUGIN::PrefetchLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
|
|
|
{
|
|
|
|
(void) aLibraryPath;
|
|
|
|
(void) aProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const FOOTPRINT* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
|
|
|
|
const wxString& aFootprintName,
|
|
|
|
const PROPERTIES* aProperties )
|
2018-02-23 12:21:06 +00:00
|
|
|
{
|
|
|
|
// default implementation
|
|
|
|
return FootprintLoad( aLibraryPath, aFootprintName, aProperties );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-11 21:59:14 +00:00
|
|
|
bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
|
|
const PROPERTIES* aProperties )
|
|
|
|
{
|
|
|
|
// default implementation
|
|
|
|
return FootprintLoad( aLibraryPath, aFootprintName, aProperties ) != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
|
|
const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2020-12-18 15:40:13 +00:00
|
|
|
return nullptr;
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
|
2018-07-30 13:18:37 +00:00
|
|
|
const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-30 13:18:37 +00:00
|
|
|
void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
|
|
const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-25 19:17:06 +00:00
|
|
|
void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-25 19:17:06 +00:00
|
|
|
bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
2013-09-21 07:30:23 +00:00
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
|
|
|
return false;
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
|
|
|
|
{
|
|
|
|
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
2013-09-30 21:26:49 +00:00
|
|
|
not_implemented( this, __FUNCTION__ );
|
|
|
|
return false;
|
2013-09-21 07:30:23 +00:00
|
|
|
}
|
2013-11-12 00:17:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
|
|
|
|
{
|
2013-11-19 20:38:29 +00:00
|
|
|
// disable all these in another couple of months, after everyone has seen them:
|
2013-11-12 20:49:17 +00:00
|
|
|
#if 1
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["debug_level"] = UTF8( _(
|
2013-11-19 20:38:29 +00:00
|
|
|
"Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-12 20:49:17 +00:00
|
|
|
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["read_filter_regex"] = UTF8( _(
|
2013-11-12 20:49:17 +00:00
|
|
|
"Regular expression <b>footprint name</b> filter."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-12 20:49:17 +00:00
|
|
|
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
|
2014-01-19 13:12:57 +00:00
|
|
|
"Enable transaction logging. The mere presence of this option turns on the "
|
|
|
|
"logging, no need to set a Value."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-19 20:38:29 +00:00
|
|
|
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["username"] = UTF8( _(
|
2013-11-19 20:38:29 +00:00
|
|
|
"User name for <b>login</b> to some special library server."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-19 20:38:29 +00:00
|
|
|
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["password"] = UTF8( _(
|
2013-11-19 20:38:29 +00:00
|
|
|
"Password for <b>login</b> to some special library server."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-12 20:49:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
// Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
|
|
|
|
// if and when implemented.
|
2014-01-02 02:17:07 +00:00
|
|
|
(*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
|
2013-11-12 20:49:17 +00:00
|
|
|
"Enter the python module which implements the PLUGIN::Footprint*() functions."
|
2014-01-02 02:17:07 +00:00
|
|
|
));
|
2013-11-12 20:49:17 +00:00
|
|
|
#endif
|
2013-11-12 00:17:27 +00:00
|
|
|
}
|
|
|
|
|