Commit 474128a4 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

pcbnew scripting: fixed for coding style policy

parent f96d557e
...@@ -26,13 +26,13 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) ...@@ -26,13 +26,13 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName )
{ {
int max = GetSize(); int max = GetSize();
for( int i=0; i<max;i++ ) for( int i=0; i<max; i++ )
{ {
FOOTPRINT_WIZARD *wizard = GetWizard( i ); FOOTPRINT_WIZARD *wizard = GetWizard( i );
wxString name = wizard->GetName(); wxString name = wizard->GetName();
if ( name.Cmp(aName) ) if ( name.Cmp( aName ) )
return wizard; return wizard;
} }
...@@ -48,11 +48,8 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard) ...@@ -48,11 +48,8 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard)
{ {
wxString name = aWizard->GetName(); wxString name = aWizard->GetName();
m_FootprintWizards.push_back(aWizard); m_FootprintWizards.push_back( aWizard );
//printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() );
} }
......
...@@ -33,13 +33,13 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -33,13 +33,13 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( event.GetId() ) switch( event.GetId() )
{ {
case ID_FOOTPRINT_WIZARD_NEXT: case ID_FOOTPRINT_WIZARD_NEXT:
m_PageList->SetSelection(m_PageList->GetSelection()+1,true); m_PageList->SetSelection( m_PageList->GetSelection()+1, true );
break; break;
case ID_FOOTPRINT_WIZARD_PREVIOUS: case ID_FOOTPRINT_WIZARD_PREVIOUS:
page = m_PageList->GetSelection()-1; page = m_PageList->GetSelection()-1;
if (page<0) page=0; if (page<0) page=0;
m_PageList->SetSelection(page,true); m_PageList->SetSelection( page, true );
break; break;
default: default:
...@@ -95,13 +95,13 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() ...@@ -95,13 +95,13 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
MODULE *m = m_FootprintWizard->GetModule(); MODULE *m = m_FootprintWizard->GetModule();
if (m) if ( m )
{ {
/* Here we should make a copy of the object before adding to board*/ /* Here we should make a copy of the object before adding to board*/
m->SetParent((EDA_ITEM*)GetBoard()); m->SetParent((EDA_ITEM*)GetBoard());
GetBoard()->m_Modules.Append(m); GetBoard()->m_Modules.Append(m);
wxPoint p(0,0); wxPoint p( 0 , 0 );
m->SetPosition(p); m->SetPosition( p );
} }
else else
{ {
...@@ -112,21 +112,21 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() ...@@ -112,21 +112,21 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
{ {
DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard = DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard =
new DIALOG_FOOTPRINT_WIZARD_LIST(this); new DIALOG_FOOTPRINT_WIZARD_LIST( this );
selectWizard->ShowModal(); selectWizard->ShowModal();
m_FootprintWizard = selectWizard->GetWizard(); m_FootprintWizard = selectWizard->GetWizard();
if (m_FootprintWizard) if ( m_FootprintWizard )
{ {
m_wizardName = m_FootprintWizard->GetName(); m_wizardName = m_FootprintWizard->GetName();
m_wizardDescription = m_FootprintWizard->GetDescription(); m_wizardDescription = m_FootprintWizard->GetDescription();
} }
ReloadFootprint(); ReloadFootprint();
Zoom_Automatique(false); Zoom_Automatique( false );
DisplayWizardInfos(); DisplayWizardInfos();
ReCreatePageList(); ReCreatePageList();
ReCreateParameterList(); ReCreateParameterList();
...@@ -149,36 +149,36 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) ...@@ -149,36 +149,36 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
int page = m_PageList->GetSelection(); int page = m_PageList->GetSelection();
if (page<0) if ( page<0 )
return; return;
int n=m_ParameterGrid->GetNumberRows(); int n=m_ParameterGrid->GetNumberRows();
wxArrayString arr; wxArrayString arr;
wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page); wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page);
for (int i=0;i<n;i++) for ( int i=0; i<n; i++ )
{ {
wxString value = m_ParameterGrid->GetCellValue(i,1); wxString value = m_ParameterGrid->GetCellValue( i, 1 );
// if this parameter is expected to be an internal // if this parameter is expected to be an internal
// unit convert it back from the user format // unit convert it back from the user format
if (ptList[i]==wxT("IU")) if (ptList[i]==wxT("IU"))
{ {
double dValue; double dValue;
value.ToDouble(&dValue); value.ToDouble( &dValue );
// convert from mils to inches where it's needed // convert from mils to inches where it's needed
if (g_UserUnit==INCHES) dValue = dValue / 1000.0; if (g_UserUnit==INCHES) dValue = dValue / 1000.0;
dValue = From_User_Unit(g_UserUnit,dValue); dValue = From_User_Unit( g_UserUnit, dValue);
value.Printf(wxT("%lf"),dValue); value.Printf( wxT("%lf"), dValue );
} }
arr.Add(value); arr.Add( value );
} }
wxString res = m_FootprintWizard->SetParameterValues(page,arr); wxString res = m_FootprintWizard->SetParameterValues( page, arr );
ReloadFootprint(); ReloadFootprint();
DisplayWizardInfos(); DisplayWizardInfos();
......
...@@ -234,11 +234,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s ...@@ -234,11 +234,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
*/ */
if( m_PageListWindow ) if( m_PageListWindow )
{ {
wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow); wxAuiPaneInfo& pane = m_auimgr.GetPane( m_PageListWindow );
pane.MinSize( wxSize(m_PageListSize.x, -1)); pane.MinSize( wxSize( m_PageListSize.x, -1 ) );
} }
wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterGridWindow); wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterGridWindow );
pane.MinSize(wxSize(m_ParameterGridSize.x, -1)); pane.MinSize( wxSize( m_ParameterGridSize.x, -1 ) );
m_auimgr.Update(); m_auimgr.Update();
...@@ -358,10 +358,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() ...@@ -358,10 +358,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
m_PageList->Clear(); m_PageList->Clear();
int max_page = m_FootprintWizard->GetNumParameterPages(); int max_page = m_FootprintWizard->GetNumParameterPages();
for (int i=0;i<max_page;i++) for ( int i=0; i<max_page; i++)
{ {
wxString name = m_FootprintWizard->GetParameterPageName(i); wxString name = m_FootprintWizard->GetParameterPageName( i );
m_PageList->Append(name); m_PageList->Append( name );
} }
m_PageList->SetSelection( 0, true ); m_PageList->SetSelection( 0, true );
...@@ -414,44 +414,43 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() ...@@ -414,44 +414,43 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
// Dimension the wxGrid // Dimension the wxGrid
m_ParameterGrid->CreateGrid(fpList.size(),3); m_ParameterGrid->CreateGrid(fpList.size(),3);
for (unsigned int i=0;i<fpList.size();i++) for (unsigned int i=0; i<fpList.size(); i++)
{ {
wxString name,value,units; wxString name,value,units;
name = fpList[i]; name = fpList[i];
value = fvList[i]; value = fvList[i];
m_ParameterGrid->SetCellValue( i, 0, name); m_ParameterGrid->SetCellValue( i, 0, name );
m_ParameterGrid->SetReadOnly( i, 0 ); m_ParameterGrid->SetReadOnly( i, 0 );
if (ptList[i]==wxT("IU")) if ( ptList[i]==wxT( "IU" ) )
{ {
// We are handling internal units, so convert them to the current // We are handling internal units, so convert them to the current
// system selected units and store into value. // system selected units and store into value.
double dValue; double dValue;
value.ToDouble(&dValue); value.ToDouble( &dValue );
dValue = To_User_Unit(g_UserUnit,dValue); dValue = To_User_Unit( g_UserUnit, dValue );
if (g_UserUnit==INCHES) // we convert inches into mils for more detail if ( g_UserUnit==INCHES ) // we convert inches into mils for more detail
{ {
dValue = dValue*1000.0; dValue = dValue*1000.0;
units = wxT("mils"); units = wxT( "mils" );
} }
else if (g_UserUnit==MILLIMETRES) else if ( g_UserUnit==MILLIMETRES )
{ {
units = wxT("mm"); units = wxT( "mm" );
} }
value.Printf(wxT("%lf"),dValue); value.Printf( wxT( "%lf" ), dValue );
} }
else if (ptList[i]==wxT("UNITS")) // 1,2,3,4,5 ... N else if ( ptList[i]==wxT( "UNITS" ) ) // 1,2,3,4,5 ... N
{ {
units = wxT(""); units = wxT( "" );
} }
m_ParameterGrid->SetCellValue( i, 1 , value ); m_ParameterGrid->SetCellValue( i, 1 , value );
m_ParameterGrid->SetCellValue( i, 2 , units ); m_ParameterGrid->SetCellValue( i, 2 , units );
m_ParameterGrid->SetReadOnly( i, 2 ); m_ParameterGrid->SetReadOnly( i, 2 );
} }
...@@ -529,7 +528,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) ...@@ -529,7 +528,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
return; return;
bool footprintWizardsChanged=false; bool footprintWizardsChanged=false;
if (footprintWizardsChanged) if ( footprintWizardsChanged )
{ {
// If we are here, the library list has changed, rebuild it // If we are here, the library list has changed, rebuild it
ReCreatePageList(); ReCreatePageList();
...@@ -734,6 +733,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() ...@@ -734,6 +733,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
_( "Insert footprint in board" ) ); _( "Insert footprint in board" ) );
} }
#endif #endif
// after adding the buttons to the toolbar, must call Realize() to // after adding the buttons to the toolbar, must call Realize() to
// reflect the changes // reflect the changes
m_mainToolBar->Realize(); m_mainToolBar->Realize();
...@@ -745,4 +745,5 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() ...@@ -745,4 +745,5 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar() void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
{ {
} }
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD(PyObject *aWizard) PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD(PyObject *aWizard)
{ {
this->m_PyWizard= aWizard; this->m_PyWizard= aWizard;
Py_XINCREF(aWizard); Py_XINCREF( aWizard );
} }
PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD() PYTHON_FOOTPRINT_WIZARD::~PYTHON_FOOTPRINT_WIZARD()
{ {
Py_XDECREF(this->m_PyWizard); Py_XDECREF( this->m_PyWizard );
} }
PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist) PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aArglist)
...@@ -22,85 +22,86 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aAr ...@@ -22,85 +22,86 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aAr
PyObject *pFunc; PyObject *pFunc;
/* pFunc is a new reference to the desired method */ /* pFunc is a new reference to the desired method */
pFunc = PyObject_GetAttrString(this->m_PyWizard, aMethod); pFunc = PyObject_GetAttrString( this->m_PyWizard, aMethod );
if (pFunc && PyCallable_Check(pFunc)) if ( pFunc && PyCallable_Check( pFunc ) )
{ {
PyObject *result; PyObject *result;
result = PyObject_CallObject(pFunc, aArglist); result = PyObject_CallObject( pFunc, aArglist );
if (PyErr_Occurred()) if ( PyErr_Occurred() )
{ {
PyObject *t, *v, *b; PyObject *t, *v, *b;
PyErr_Fetch(&t, &v, &b); PyErr_Fetch( &t, &v, &b );
printf ("calling %s()\n",aMethod); printf ( "calling %s()\n", aMethod );
printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v))); printf ( "Exception: %s\n", PyString_AsString( PyObject_Str(v) ) );
printf (" : %s\n",PyString_AsString(PyObject_Str(b))); printf ( " : %s\n", PyString_AsString( PyObject_Str(b) ) );
} }
if (result) if ( result )
{ {
Py_XDECREF(pFunc); Py_XDECREF( pFunc );
return result; return result;
} }
} }
else else
{ {
printf("method not found, or not callable: %s\n",aMethod); printf( "method not found, or not callable: %s\n", aMethod );
} }
if (pFunc) Py_XDECREF(pFunc); if ( pFunc )
Py_XDECREF( pFunc );
return NULL; return NULL;
} }
wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArglist) wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod( const char* aMethod, PyObject *aArglist )
{ {
wxString ret; wxString ret;
ret.Clear(); ret.Clear();
PyObject *result = CallMethod(aMethod,aArglist); PyObject *result = CallMethod( aMethod, aArglist );
if (result) if ( result )
{ {
const char *str_res = PyString_AsString(result); const char *str_res = PyString_AsString( result );
ret = wxString::FromUTF8(str_res); ret = wxString::FromUTF8( str_res );
Py_DECREF(result); Py_DECREF( result );
} }
return ret; return ret;
} }
wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod
(const char *aMethod, PyObject *aArglist) ( const char *aMethod, PyObject *aArglist )
{ {
PyObject *result, *element; PyObject *result, *element;
wxArrayString ret; wxArrayString ret;
wxString str_item; wxString str_item;
result = CallMethod(aMethod,aArglist); result = CallMethod( aMethod, aArglist );
if (result) if ( result )
{ {
if (!PyList_Check(result)) if ( !PyList_Check(result) )
{ {
Py_DECREF(result); Py_DECREF( result );
ret.Add(wxT("PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, " ret.Add( wxT("PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, "
"result is not a list"),1); "result is not a list"),1 );
return ret; return ret;
} }
int list_size = PyList_Size(result); int list_size = PyList_Size( result );
for (int n=0;n<list_size;n++) for ( int n=0; n<list_size; n++ )
{ {
element = PyList_GetItem(result,n); element = PyList_GetItem( result, n );
const char *str_res = PyString_AsString(element); const char *str_res = PyString_AsString( element );
str_item = wxString::FromUTF8(str_res); str_item = wxString::FromUTF8( str_res );
ret.Add(str_item,1); ret.Add( str_item, 1 );
} }
Py_DECREF(result); Py_DECREF( result );
} }
...@@ -111,17 +112,17 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod ...@@ -111,17 +112,17 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod
wxString PYTHON_FOOTPRINT_WIZARD::GetName() wxString PYTHON_FOOTPRINT_WIZARD::GetName()
{ {
return CallRetStrMethod("GetName"); return CallRetStrMethod( "GetName" );
} }
wxString PYTHON_FOOTPRINT_WIZARD::GetImage() wxString PYTHON_FOOTPRINT_WIZARD::GetImage()
{ {
return CallRetStrMethod("GetImage"); return CallRetStrMethod( "GetImage" );
} }
wxString PYTHON_FOOTPRINT_WIZARD::GetDescription() wxString PYTHON_FOOTPRINT_WIZARD::GetDescription()
{ {
return CallRetStrMethod("GetDescription"); return CallRetStrMethod( "GetDescription" );
} }
int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages() int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
...@@ -130,52 +131,53 @@ int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages() ...@@ -130,52 +131,53 @@ int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
PyObject *result; PyObject *result;
/* Time to call the callback */ /* Time to call the callback */
result = CallMethod("GetNumParameterPages",NULL); result = CallMethod( "GetNumParameterPages" , NULL );
if (result) if (result)
{ {
if (!PyInt_Check(result)) return -1; if ( !PyInt_Check( result ) )
ret = PyInt_AsLong(result); return -1;
Py_DECREF(result); ret = PyInt_AsLong( result );
Py_DECREF( result );
} }
return ret; return ret;
} }
wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName(int aPage) wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName( int aPage )
{ {
wxString ret; wxString ret;
PyObject *arglist; PyObject *arglist;
PyObject *result; PyObject *result;
/* Time to call the callback */ /* Time to call the callback */
arglist = Py_BuildValue("(i)", aPage); arglist = Py_BuildValue( "(i)", aPage );
result = CallMethod("GetParameterPageName",arglist); result = CallMethod( "GetParameterPageName", arglist );
Py_DECREF(arglist); Py_DECREF( arglist );
if (result) if ( result )
{ {
const char *str_res = PyString_AsString(result); const char *str_res = PyString_AsString( result );
ret = wxString::FromUTF8(str_res); ret = wxString::FromUTF8( str_res );
Py_DECREF(result); Py_DECREF( result );
} }
return ret; return ret;
} }
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames( int aPage )
{ {
PyObject *arglist; PyObject *arglist;
wxArrayString ret; wxArrayString ret;
arglist = Py_BuildValue("(i)", aPage); arglist = Py_BuildValue( "(i)", aPage );
ret = CallRetArrayStrMethod("GetParameterNames",arglist); ret = CallRetArrayStrMethod( "GetParameterNames", arglist );
Py_DECREF(arglist); Py_DECREF( arglist );
for (unsigned i=0;i<ret.GetCount();i++) for ( unsigned i=0; i<ret.GetCount(); i++ )
{ {
wxString rest; wxString rest;
wxString item = ret[i]; wxString item = ret[i];
if (item.StartsWith(wxT("*"),&rest)) if ( item.StartsWith( wxT("*"), &rest ) )
{ {
ret[i]=rest; ret[i]=rest;
} }
...@@ -185,27 +187,27 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage) ...@@ -185,27 +187,27 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage)
return ret; return ret;
} }
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes( int aPage )
{ {
PyObject *arglist; PyObject *arglist;
wxArrayString ret; wxArrayString ret;
arglist = Py_BuildValue("(i)", aPage); arglist = Py_BuildValue( "(i)", aPage );
ret = CallRetArrayStrMethod("GetParameterNames",arglist); ret = CallRetArrayStrMethod( "GetParameterNames", arglist );
Py_DECREF(arglist); Py_DECREF(arglist);
for (unsigned i=0;i<ret.GetCount();i++) for ( unsigned i=0; i<ret.GetCount(); i++ )
{ {
wxString rest; wxString rest;
wxString item = ret[i]; wxString item = ret[i];
if (item.StartsWith(wxT("*"),&rest)) if ( item.StartsWith( wxT("*"), &rest ) )
{ {
ret[i]=wxT("UNITS"); /* units */ ret[i]=wxT( "UNITS" ); /* units */
} }
else else
{ {
ret[i]=wxT("IU"); /* internal units */ ret[i]=wxT( "IU" ); /* internal units */
} }
} }
...@@ -215,52 +217,50 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes(int aPage) ...@@ -215,52 +217,50 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterTypes(int aPage)
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterValues( int aPage )
{ {
PyObject *arglist; PyObject *arglist;
wxArrayString ret; wxArrayString ret;
arglist = Py_BuildValue("(i)", aPage); arglist = Py_BuildValue( "(i)", aPage );
ret = CallRetArrayStrMethod("GetParameterValues",arglist); ret = CallRetArrayStrMethod( "GetParameterValues", arglist );
Py_DECREF(arglist); Py_DECREF( arglist );
return ret; return ret;
} }
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterErrors(int aPage) wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterErrors( int aPage )
{ {
PyObject *arglist; PyObject *arglist;
wxArrayString ret; wxArrayString ret;
arglist = Py_BuildValue("(i)", aPage); arglist = Py_BuildValue( "(i)", aPage );
ret = CallRetArrayStrMethod("GetParameterErrors",arglist); ret = CallRetArrayStrMethod( "GetParameterErrors", arglist );
Py_DECREF(arglist); Py_DECREF( arglist );
return ret; return ret;
} }
wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues(int aPage,wxArrayString& aValues) wxString PYTHON_FOOTPRINT_WIZARD::SetParameterValues( int aPage, wxArrayString& aValues )
{ {
int len = aValues.size(); int len = aValues.size();
PyObject *py_list; PyObject *py_list;
py_list = PyList_New(len); py_list = PyList_New( len );
for (int i=0;i<len;i++) for ( int i=0; i<len ; i++ )
{ {
wxString str = aValues[i]; wxString str = aValues[i];
PyObject *py_str = PyString_FromString((const char*)str.mb_str()); PyObject *py_str = PyString_FromString( (const char*)str.mb_str() );
PyList_SetItem(py_list, i, py_str); PyList_SetItem( py_list, i, py_str );
} }
PyObject *arglist; PyObject *arglist;
arglist = Py_BuildValue("(i,O)", aPage,py_list); arglist = Py_BuildValue( "(i,O)", aPage, py_list );
wxString res = CallRetStrMethod("SetParameterValues",arglist); wxString res = CallRetStrMethod( "SetParameterValues", arglist );
Py_DECREF(arglist); Py_DECREF( arglist );
return res; return res;
} }
...@@ -271,24 +271,25 @@ MODULE *PyModule_to_MODULE(PyObject *obj0); ...@@ -271,24 +271,25 @@ MODULE *PyModule_to_MODULE(PyObject *obj0);
MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule() MODULE *PYTHON_FOOTPRINT_WIZARD::GetModule()
{ {
PyObject *result, *obj; PyObject *result, *obj;
result = CallMethod("GetModule",NULL); result = CallMethod( "GetModule", NULL );
if (!result) return NULL;
if (!result)
return NULL;
obj = PyObject_GetAttrString(result, "this");
if (PyErr_Occurred()) obj = PyObject_GetAttrString( result, "this" );
{
/*
PyObject *t, *v, *b;
PyErr_Fetch(&t, &v, &b);
printf ("calling GetModule()\n");
printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v)));
printf (" : %s\n",PyString_AsString(PyObject_Str(b)));
*/
PyErr_Print();
}
if (PyErr_Occurred())
{
/*
PyObject *t, *v, *b;
PyErr_Fetch(&t, &v, &b);
printf ("calling GetModule()\n");
printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v)));
printf (" : %s\n",PyString_AsString(PyObject_Str(b)));
*/
PyErr_Print();
}
return PyModule_to_MODULE(obj); return PyModule_to_MODULE(obj);
} }
...@@ -297,9 +298,9 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) ...@@ -297,9 +298,9 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard)
{ {
PYTHON_FOOTPRINT_WIZARD *fw; PYTHON_FOOTPRINT_WIZARD *fw;
fw = new PYTHON_FOOTPRINT_WIZARD(aPyWizard); fw = new PYTHON_FOOTPRINT_WIZARD( aPyWizard );
printf("Registered python footprint wizard '%s'\n", printf( "Registered python footprint wizard '%s'\n",
(const char*)fw->GetName().mb_str() (const char*)fw->GetName().mb_str()
); );
...@@ -308,7 +309,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) ...@@ -308,7 +309,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard)
fw->register_wizard(); fw->register_wizard();
#if 0 #if 0
/* just to test if it works correctly */ /* just to test if it works correctly */
int pages = fw->GetNumParameterPages(); int pages = fw->GetNumParameterPages();
...@@ -321,9 +321,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) ...@@ -321,9 +321,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard)
} }
#endif #endif
} }
...@@ -15,24 +15,24 @@ class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD ...@@ -15,24 +15,24 @@ class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD
{ {
PyObject *m_PyWizard; PyObject *m_PyWizard;
PyObject *CallMethod(const char *aMethod, PyObject *aArglist=NULL); PyObject *CallMethod( const char *aMethod, PyObject *aArglist=NULL );
wxString CallRetStrMethod(const char *aMethod, PyObject *aArglist=NULL); wxString CallRetStrMethod( const char *aMethod, PyObject *aArglist=NULL );
wxArrayString CallRetArrayStrMethod(const char *aMethod, wxArrayString CallRetArrayStrMethod( const char *aMethod,
PyObject *aArglist=NULL); PyObject *aArglist=NULL );
public: public:
PYTHON_FOOTPRINT_WIZARD(PyObject *wizard); PYTHON_FOOTPRINT_WIZARD( PyObject *wizard );
~PYTHON_FOOTPRINT_WIZARD(); ~PYTHON_FOOTPRINT_WIZARD();
wxString GetName(); wxString GetName();
wxString GetImage(); wxString GetImage();
wxString GetDescription(); wxString GetDescription();
int GetNumParameterPages(); int GetNumParameterPages();
wxString GetParameterPageName(int aPage); wxString GetParameterPageName( int aPage );
wxArrayString GetParameterNames(int aPage); wxArrayString GetParameterNames( int aPage );
wxArrayString GetParameterTypes(int aPage); wxArrayString GetParameterTypes( int aPage );
wxArrayString GetParameterValues(int aPage); wxArrayString GetParameterValues( int aPage );
wxArrayString GetParameterErrors(int aPage); wxArrayString GetParameterErrors( int aPage );
wxString SetParameterValues(int aPage,wxArrayString& aValues); //< must return "OK" or error description wxString SetParameterValues( int aPage, wxArrayString& aValues ); //< must return "OK" or error description
MODULE *GetModule(); MODULE *GetModule();
}; };
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
class PYTHON_FOOTPRINT_WIZARDS class PYTHON_FOOTPRINT_WIZARDS
{ {
public: public:
static void register_wizard(PyObject *aPyWizard); static void register_wizard( PyObject *aPyWizard );
}; };
......
...@@ -43,20 +43,22 @@ static PCB_EDIT_FRAME *PcbEditFrame=NULL; ...@@ -43,20 +43,22 @@ static PCB_EDIT_FRAME *PcbEditFrame=NULL;
BOARD *GetBoard() BOARD *GetBoard()
{ {
if (PcbEditFrame) return PcbEditFrame->GetBoard(); if (PcbEditFrame)
return PcbEditFrame->GetBoard();
else return NULL; else return NULL;
} }
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame) void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME *aPCBEdaFrame )
{ {
PcbEditFrame = aPCBEdaFrame; PcbEditFrame = aPCBEdaFrame;
} }
BOARD* LoadBoard(wxString& aFileName) BOARD* LoadBoard( wxString& aFileName )
{ {
if (aFileName.EndsWith(wxT(".kicad_brd"))) if ( aFileName.EndsWith( wxT( ".kicad_brd" ) ) )
return LoadBoard(aFileName,IO_MGR::KICAD); return LoadBoard(aFileName,IO_MGR::KICAD);
else if (aFileName.EndsWith(wxT(".brd"))) else if (aFileName.EndsWith(wxT(".brd")))
return LoadBoard(aFileName,IO_MGR::LEGACY); return LoadBoard(aFileName,IO_MGR::LEGACY);
...@@ -65,19 +67,18 @@ BOARD* LoadBoard(wxString& aFileName) ...@@ -65,19 +67,18 @@ BOARD* LoadBoard(wxString& aFileName)
} }
BOARD* LoadBoard(wxString& aFileName,IO_MGR::PCB_FILE_T aFormat) BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
{ {
return IO_MGR::Load(aFormat,aFileName); return IO_MGR::Load( aFormat, aFileName );
} }
bool SaveBoard(wxString& aFilename, BOARD* aBoard) bool SaveBoard( wxString& aFilename, BOARD* aBoard )
{ {
return SaveBoard(aFilename,aBoard,IO_MGR::KICAD); return SaveBoard( aFilename, aBoard,IO_MGR::KICAD );
} }
bool SaveBoard(wxString& aFileName, BOARD* aBoard, bool SaveBoard( wxString& aFileName, BOARD* aBoard,
IO_MGR::PCB_FILE_T aFormat) IO_MGR::PCB_FILE_T aFormat )
{ {
aBoard->m_Status_Pcb &= ~CONNEXION_OK; aBoard->m_Status_Pcb &= ~CONNEXION_OK;
aBoard->SynchronizeNetsAndNetClasses(); aBoard->SynchronizeNetsAndNetClasses();
...@@ -86,7 +87,7 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard, ...@@ -86,7 +87,7 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard,
wxString header; wxString header;
PROPERTIES props; PROPERTIES props;
if (aFormat==IO_MGR::LEGACY) if ( aFormat==IO_MGR::LEGACY )
{ {
header = wxString::Format( header = wxString::Format(
wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s scripting\n\n" ), wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s scripting\n\n" ),
......
...@@ -7,15 +7,16 @@ ...@@ -7,15 +7,16 @@
* we want plain pcbnew.<method_name> access from python */ * we want plain pcbnew.<method_name> access from python */
#ifndef SWIG #ifndef SWIG
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame); void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME *aPCBEdaFrame );
#endif #endif
BOARD *GetBoard(); BOARD *GetBoard();
BOARD* LoadBoard(wxString& aFileName, IO_MGR::PCB_FILE_T aFormat); BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat );
BOARD* LoadBoard(wxString& aFileName); BOARD* LoadBoard( wxString& aFileName );
bool SaveBoard(wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat);
bool SaveBoard(wxString& aFileName, BOARD* aBoard);
bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat );
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
#endif
\ No newline at end of file #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment