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,10 +48,7 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard) ...@@ -48,10 +48,7 @@ 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
{ {
...@@ -113,20 +113,20 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() ...@@ -113,20 +113,20 @@ 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()
{ {
} }
...@@ -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 #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