2013-03-15 13:27:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
|
2021-02-09 16:35:43 +00:00
|
|
|
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-15 13:27:18 +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
|
|
|
|
*/
|
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew_footprint_wizards.cpp
|
2018-01-30 19:23:06 +00:00
|
|
|
* @brief Class and PYTHON_FOOTPRINT_WIZARD_LIST and PYTHON_FOOTPRINT_WIZARD_LIST
|
2012-05-05 20:18:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pcbnew_footprint_wizards.h"
|
2019-12-05 14:03:15 +00:00
|
|
|
#include <cstdio>
|
2013-05-01 17:32:36 +00:00
|
|
|
#include <macros.h>
|
2021-06-06 12:41:16 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2021-03-08 14:54:22 +00:00
|
|
|
#include "../../scripting/python_scripting.h"
|
2012-05-05 20:18:47 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD( PyObject* aWizard )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2021-02-09 16:35:43 +00:00
|
|
|
m_PyWizard = aWizard;
|
2012-09-24 16:03:03 +00:00
|
|
|
Py_XINCREF( aWizard );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2021-02-09 16:35:43 +00:00
|
|
|
Py_XDECREF( m_PyWizard );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aArglist )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-16 03:27:48 +00:00
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
PyErr_Clear();
|
2013-03-11 08:09:48 +00:00
|
|
|
// pFunc is a new reference to the desired method
|
2021-02-09 16:35:43 +00:00
|
|
|
PyObject* pFunc = PyObject_GetAttrString( m_PyWizard, aMethod );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( pFunc && PyCallable_Check( pFunc ) )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PyObject* result = PyObject_CallObject( pFunc, aArglist );
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( PyErr_Occurred() )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2015-09-02 13:55:36 +00:00
|
|
|
#if 1 // defined(DEBUG)
|
2013-03-17 01:14:46 +00:00
|
|
|
wxMessageBox( PyErrStringWithTraceback(),
|
2018-03-30 16:43:17 +00:00
|
|
|
_( "Exception on python footprint wizard code" ),
|
2013-03-15 16:35:24 +00:00
|
|
|
wxICON_ERROR | wxOK );
|
2015-09-02 13:55:36 +00:00
|
|
|
#endif
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_XDECREF( pFunc );
|
|
|
|
return result;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 00:02:14 +00:00
|
|
|
wxString msg = wxString::Format(_( "Method '%s' not found, or not callable" ), aMethod );
|
2018-03-30 16:43:17 +00:00
|
|
|
wxMessageBox( msg, _( "Unknown Method" ), wxICON_ERROR | wxOK );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( pFunc )
|
2014-03-27 17:45:05 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_XDECREF( pFunc );
|
2014-03-27 17:45:05 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod( const char* aMethod, PyObject* aArglist )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxString ret;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* result = CallMethod( aMethod, aArglist );
|
|
|
|
|
2018-10-17 08:35:27 +00:00
|
|
|
if( result == Py_None )
|
2018-10-11 20:37:09 +00:00
|
|
|
{
|
2018-08-15 11:45:14 +00:00
|
|
|
Py_DECREF( result );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-10-12 19:36:50 +00:00
|
|
|
ret = PyStringToWx( result );
|
|
|
|
Py_XDECREF( result );
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-09 23:04:08 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod( const char* aMethod,
|
|
|
|
PyObject* aArglist )
|
2012-05-09 23:04:08 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
wxString str_item;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* result = CallMethod( aMethod, aArglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-10 06:44:08 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
if( !PyList_Check( result ) )
|
|
|
|
{
|
|
|
|
Py_DECREF( result );
|
2021-07-19 23:56:05 +00:00
|
|
|
ret.Add( wxT( "PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
|
2013-03-15 16:35:24 +00:00
|
|
|
1 );
|
|
|
|
return ret;
|
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-17 01:14:46 +00:00
|
|
|
ret = PyArrayStringToWx( result );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
Py_DECREF( result );
|
2012-05-10 06:44:08 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 06:44:08 +00:00
|
|
|
return ret;
|
2012-05-09 23:04:08 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetName()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetName" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetImage()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetImage" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetDescription()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
return CallRetStrMethod( "GetDescription" );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
int ret = 0;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
// Time to call the callback
|
2021-07-19 23:56:05 +00:00
|
|
|
PyObject* result = CallMethod( "GetNumParameterPages", nullptr );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( result )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2018-08-03 13:23:32 +00:00
|
|
|
if( !PyLong_Check( result ) )
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = PyLong_AsLong( result );
|
2013-03-15 16:35:24 +00:00
|
|
|
Py_DECREF( result );
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxString ret;
|
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
// Time to call the callback
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
PyObject* result = CallMethod( "GetParameterPageName", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2018-10-17 08:35:27 +00:00
|
|
|
if( result == Py_None )
|
2018-10-11 20:37:09 +00:00
|
|
|
{
|
2018-08-15 11:45:14 +00:00
|
|
|
Py_DECREF( result );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-10-12 19:36:50 +00:00
|
|
|
ret = PyStringToWx( result );
|
|
|
|
Py_XDECREF( result );
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
ret = CallRetArrayStrMethod( "GetParameterNames", arglist );
|
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-09-02 13:55:36 +00:00
|
|
|
for( unsigned i = 0; i < ret.GetCount(); i++ )
|
2012-09-24 16:03:03 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
wxString rest;
|
|
|
|
wxString item = ret[i];
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( item.StartsWith( wxT( "*" ), &rest ) )
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
ret[i] = rest;
|
2012-07-22 22:23:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes( int aPage )
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
wxArrayString ret;
|
|
|
|
PyLOCK lock;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
ret = CallRetArrayStrMethod( "GetParameterTypes", arglist );
|
2013-03-11 08:09:48 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 06:44:08 +00:00
|
|
|
return ret;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 22:23:17 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterValues", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-10 08:53:05 +00:00
|
|
|
return ret;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterErrors( int aPage )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
|
|
|
|
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterErrors", arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-05 20:18:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterHints( int aPage )
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterHints", arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
Py_DECREF( arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
return ret;
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterDesignators( int aPage )
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
PyObject* arglist = Py_BuildValue( "(i)", aPage );
|
|
|
|
wxArrayString ret = CallRetArrayStrMethod( "GetParameterDesignators", arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
Py_DECREF( arglist );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
return ret;
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2012-07-31 21:00:33 +00:00
|
|
|
wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues( int aPage, wxArrayString& aValues )
|
2012-05-16 09:35:18 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
int len = aValues.size();
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyLOCK lock;
|
2013-03-11 08:09:48 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* py_list = PyList_New( len );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2015-09-02 13:55:36 +00:00
|
|
|
for( int i = 0; i < len; i++ )
|
2012-05-16 09:35:18 +00:00
|
|
|
{
|
2015-09-02 13:55:36 +00:00
|
|
|
wxString& str = aValues[i];
|
2018-08-03 13:23:32 +00:00
|
|
|
PyObject* py_str = PyUnicode_FromString( (const char*) str.mb_str() );
|
2012-07-31 21:00:33 +00:00
|
|
|
PyList_SetItem( py_list, i, py_str );
|
2012-05-16 09:35:18 +00:00
|
|
|
}
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
PyObject* arglist;
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-12 00:37:45 +00:00
|
|
|
arglist = Py_BuildValue( "(i,O)", aPage, py_list );
|
2013-03-15 16:35:24 +00:00
|
|
|
wxString res = CallRetStrMethod( "SetParameterValues", arglist );
|
2012-07-31 21:00:33 +00:00
|
|
|
Py_DECREF( arglist );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2012-05-16 09:35:18 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD::ResetParameters()
|
|
|
|
{
|
2017-01-03 17:04:35 +00:00
|
|
|
PyLOCK lock;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
CallMethod( "ResetWizard", nullptr );
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
2012-05-10 08:53:05 +00:00
|
|
|
|
2020-11-14 22:00:12 +00:00
|
|
|
// this is a SWIG function declaration -from footprint.i
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* PyFootprint_to_FOOTPRINT( PyObject* obj0 );
|
2013-03-11 08:09:48 +00:00
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* PYTHON_FOOTPRINT_WIZARD::GetFootprint( wxString * aMessages )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PyLOCK lock;
|
2012-07-31 21:00:33 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
PyObject* result = CallMethod( "GetFootprint", nullptr );
|
2015-09-05 12:10:54 +00:00
|
|
|
|
|
|
|
if( aMessages )
|
2021-07-19 23:56:05 +00:00
|
|
|
*aMessages = CallRetStrMethod( "GetBuildMessages", nullptr );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( !result )
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
PyObject* obj = PyObject_GetAttrString( result, "this" );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
2013-03-11 08:09:48 +00:00
|
|
|
if( PyErr_Occurred() )
|
2013-03-16 03:27:48 +00:00
|
|
|
{
|
2012-07-31 21:00:33 +00:00
|
|
|
PyErr_Print();
|
2013-03-16 03:27:48 +00:00
|
|
|
PyErr_Clear();
|
|
|
|
}
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = PyFootprint_to_FOOTPRINT( obj );
|
2012-08-01 12:50:21 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
return footprint;
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
void* PYTHON_FOOTPRINT_WIZARD::GetObject()
|
|
|
|
{
|
|
|
|
return (void*) m_PyWizard;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD_LIST::register_wizard( PyObject* aPyWizard )
|
2012-05-05 20:18:47 +00:00
|
|
|
{
|
2013-03-11 08:09:48 +00:00
|
|
|
PYTHON_FOOTPRINT_WIZARD* fw = new PYTHON_FOOTPRINT_WIZARD( aPyWizard );
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
fw->register_wizard();
|
2012-05-05 20:18:47 +00:00
|
|
|
}
|
2013-03-16 03:27:48 +00:00
|
|
|
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
void PYTHON_FOOTPRINT_WIZARD_LIST::deregister_wizard( PyObject* aPyWizard )
|
2013-03-16 03:27:48 +00:00
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
// deregister also destroys the previously created "PYTHON_FOOTPRINT_WIZARD object"
|
2018-01-30 19:23:06 +00:00
|
|
|
FOOTPRINT_WIZARD_LIST::deregister_object( (void*) aPyWizard );
|
2013-03-16 03:27:48 +00:00
|
|
|
}
|