diff --git a/pcbnew/class_footprint_wizard.cpp b/pcbnew/class_footprint_wizard.cpp index 3bc232b882..66d4c0b260 100644 --- a/pcbnew/class_footprint_wizard.cpp +++ b/pcbnew/class_footprint_wizard.cpp @@ -26,13 +26,13 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) { int max = GetSize(); - for( int i=0; iGetName(); - if ( name.Cmp(aName) ) + if ( name.Cmp( aName ) ) return wizard; } @@ -48,11 +48,8 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard) { wxString name = aWizard->GetName(); - m_FootprintWizards.push_back(aWizard); - - //printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() ); - - + m_FootprintWizards.push_back( aWizard ); + } diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 6e2df7d7ae..0cb7f42dd5 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -33,13 +33,13 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) switch( event.GetId() ) { case ID_FOOTPRINT_WIZARD_NEXT: - m_PageList->SetSelection(m_PageList->GetSelection()+1,true); + m_PageList->SetSelection( m_PageList->GetSelection()+1, true ); break; case ID_FOOTPRINT_WIZARD_PREVIOUS: page = m_PageList->GetSelection()-1; if (page<0) page=0; - m_PageList->SetSelection(page,true); + m_PageList->SetSelection( page, true ); break; default: @@ -95,13 +95,13 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); MODULE *m = m_FootprintWizard->GetModule(); - if (m) + if ( m ) { /* Here we should make a copy of the object before adding to board*/ m->SetParent((EDA_ITEM*)GetBoard()); GetBoard()->m_Modules.Append(m); - wxPoint p(0,0); - m->SetPosition(p); + wxPoint p( 0 , 0 ); + m->SetPosition( p ); } else { @@ -112,21 +112,21 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() { - DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard = - new DIALOG_FOOTPRINT_WIZARD_LIST(this); + DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard = + new DIALOG_FOOTPRINT_WIZARD_LIST( this ); selectWizard->ShowModal(); m_FootprintWizard = selectWizard->GetWizard(); - if (m_FootprintWizard) + if ( m_FootprintWizard ) { m_wizardName = m_FootprintWizard->GetName(); m_wizardDescription = m_FootprintWizard->GetDescription(); } ReloadFootprint(); - Zoom_Automatique(false); + Zoom_Automatique( false ); DisplayWizardInfos(); ReCreatePageList(); ReCreateParameterList(); @@ -149,36 +149,36 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) int page = m_PageList->GetSelection(); - if (page<0) + if ( page<0 ) return; int n=m_ParameterGrid->GetNumberRows(); wxArrayString arr; wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page); - for (int i=0;iGetCellValue(i,1); + wxString value = m_ParameterGrid->GetCellValue( i, 1 ); // if this parameter is expected to be an internal // unit convert it back from the user format if (ptList[i]==wxT("IU")) { double dValue; - value.ToDouble(&dValue); + value.ToDouble( &dValue ); // convert from mils to inches where it's needed 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(); DisplayWizardInfos(); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index c0a1d9401b..a408dea6a6 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -234,11 +234,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s */ if( m_PageListWindow ) { - wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow); - pane.MinSize( wxSize(m_PageListSize.x, -1)); + wxAuiPaneInfo& pane = m_auimgr.GetPane( m_PageListWindow ); + pane.MinSize( wxSize( m_PageListSize.x, -1 ) ); } - wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterGridWindow); - pane.MinSize(wxSize(m_ParameterGridSize.x, -1)); + wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterGridWindow ); + pane.MinSize( wxSize( m_ParameterGridSize.x, -1 ) ); m_auimgr.Update(); @@ -358,10 +358,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() m_PageList->Clear(); int max_page = m_FootprintWizard->GetNumParameterPages(); - for (int i=0;iGetParameterPageName(i); - m_PageList->Append(name); + wxString name = m_FootprintWizard->GetParameterPageName( i ); + m_PageList->Append( name ); } m_PageList->SetSelection( 0, true ); @@ -414,44 +414,43 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() // Dimension the wxGrid m_ParameterGrid->CreateGrid(fpList.size(),3); - for (unsigned int i=0;iSetCellValue( i, 0, name); + m_ParameterGrid->SetCellValue( i, 0, name ); 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 // system selected units and store into value. 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; - 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, 2 , units ); m_ParameterGrid->SetReadOnly( i, 2 ); } @@ -529,7 +528,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) return; bool footprintWizardsChanged=false; - if (footprintWizardsChanged) + if ( footprintWizardsChanged ) { // If we are here, the library list has changed, rebuild it ReCreatePageList(); @@ -734,6 +733,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() _( "Insert footprint in board" ) ); } #endif + // after adding the buttons to the toolbar, must call Realize() to // reflect the changes m_mainToolBar->Realize(); @@ -745,4 +745,5 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar() { + } diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.cpp b/pcbnew/scripting/pcbnew_footprint_wizards.cpp index 87494a53c0..3dd77c0305 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.cpp +++ b/pcbnew/scripting/pcbnew_footprint_wizards.cpp @@ -9,12 +9,12 @@ PYTHON_FOOTPRINT_WIZARD::PYTHON_FOOTPRINT_WIZARD(PyObject *aWizard) { this->m_PyWizard= aWizard; - Py_XINCREF(aWizard); + Py_XINCREF( aWizard ); } 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) @@ -22,85 +22,86 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod(const char* aMethod, PyObject *aAr PyObject *pFunc; /* 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; - result = PyObject_CallObject(pFunc, aArglist); + result = PyObject_CallObject( pFunc, aArglist ); - if (PyErr_Occurred()) + if ( PyErr_Occurred() ) { PyObject *t, *v, *b; - PyErr_Fetch(&t, &v, &b); - printf ("calling %s()\n",aMethod); - printf ("Exception: %s\n",PyString_AsString(PyObject_Str(v))); - printf (" : %s\n",PyString_AsString(PyObject_Str(b))); + PyErr_Fetch( &t, &v, &b ); + printf ( "calling %s()\n", aMethod ); + printf ( "Exception: %s\n", PyString_AsString( PyObject_Str(v) ) ); + printf ( " : %s\n", PyString_AsString( PyObject_Str(b) ) ); } - if (result) + if ( result ) { - Py_XDECREF(pFunc); - return result; + Py_XDECREF( pFunc ); + return result; } } 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; } -wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject *aArglist) +wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod( const char* aMethod, PyObject *aArglist ) { wxString ret; ret.Clear(); - PyObject *result = CallMethod(aMethod,aArglist); - if (result) + PyObject *result = CallMethod( aMethod, aArglist ); + if ( result ) { - const char *str_res = PyString_AsString(result); - ret = wxString::FromUTF8(str_res); - Py_DECREF(result); + const char *str_res = PyString_AsString( result ); + ret = wxString::FromUTF8( str_res ); + Py_DECREF( result ); } return ret; } wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod - (const char *aMethod, PyObject *aArglist) + ( const char *aMethod, PyObject *aArglist ) { PyObject *result, *element; wxArrayString ret; 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); - ret.Add(wxT("PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, " - "result is not a list"),1); + Py_DECREF( result ); + ret.Add( wxT("PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, " + "result is not a list"),1 ); return ret; } - int list_size = PyList_Size(result); + int list_size = PyList_Size( result ); - for (int n=0;nGetName().mb_str() ); @@ -308,7 +309,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) fw->register_wizard(); - #if 0 /* just to test if it works correctly */ int pages = fw->GetNumParameterPages(); @@ -321,9 +321,6 @@ void PYTHON_FOOTPRINT_WIZARDS::register_wizard(PyObject* aPyWizard) } #endif - } - - diff --git a/pcbnew/scripting/pcbnew_footprint_wizards.h b/pcbnew/scripting/pcbnew_footprint_wizards.h index bc543be513..0799e5feb0 100644 --- a/pcbnew/scripting/pcbnew_footprint_wizards.h +++ b/pcbnew/scripting/pcbnew_footprint_wizards.h @@ -15,24 +15,24 @@ class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD { PyObject *m_PyWizard; - PyObject *CallMethod(const char *aMethod, PyObject *aArglist=NULL); - wxString CallRetStrMethod(const char *aMethod, PyObject *aArglist=NULL); - wxArrayString CallRetArrayStrMethod(const char *aMethod, - PyObject *aArglist=NULL); + PyObject *CallMethod( const char *aMethod, PyObject *aArglist=NULL ); + wxString CallRetStrMethod( const char *aMethod, PyObject *aArglist=NULL ); + wxArrayString CallRetArrayStrMethod( const char *aMethod, + PyObject *aArglist=NULL ); public: - PYTHON_FOOTPRINT_WIZARD(PyObject *wizard); + PYTHON_FOOTPRINT_WIZARD( PyObject *wizard ); ~PYTHON_FOOTPRINT_WIZARD(); wxString GetName(); wxString GetImage(); wxString GetDescription(); int GetNumParameterPages(); - wxString GetParameterPageName(int aPage); - wxArrayString GetParameterNames(int aPage); - wxArrayString GetParameterTypes(int aPage); - wxArrayString GetParameterValues(int aPage); - wxArrayString GetParameterErrors(int aPage); - wxString SetParameterValues(int aPage,wxArrayString& aValues); //< must return "OK" or error description + wxString GetParameterPageName( int aPage ); + wxArrayString GetParameterNames( int aPage ); + wxArrayString GetParameterTypes( int aPage ); + wxArrayString GetParameterValues( int aPage ); + wxArrayString GetParameterErrors( int aPage ); + wxString SetParameterValues( int aPage, wxArrayString& aValues ); //< must return "OK" or error description MODULE *GetModule(); }; @@ -40,7 +40,7 @@ public: class PYTHON_FOOTPRINT_WIZARDS { public: - static void register_wizard(PyObject *aPyWizard); + static void register_wizard( PyObject *aPyWizard ); }; diff --git a/pcbnew/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/scripting/pcbnew_scripting_helpers.cpp index 7e483514f6..b6f62364ad 100644 --- a/pcbnew/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/scripting/pcbnew_scripting_helpers.cpp @@ -43,20 +43,22 @@ static PCB_EDIT_FRAME *PcbEditFrame=NULL; BOARD *GetBoard() { - if (PcbEditFrame) return PcbEditFrame->GetBoard(); + if (PcbEditFrame) + return PcbEditFrame->GetBoard(); else return NULL; } -void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame) +void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME *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); + else if (aFileName.EndsWith(wxT(".brd"))) return LoadBoard(aFileName,IO_MGR::LEGACY); @@ -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, - IO_MGR::PCB_FILE_T aFormat) +bool SaveBoard( wxString& aFileName, BOARD* aBoard, + IO_MGR::PCB_FILE_T aFormat ) { aBoard->m_Status_Pcb &= ~CONNEXION_OK; aBoard->SynchronizeNetsAndNetClasses(); @@ -86,7 +87,7 @@ bool SaveBoard(wxString& aFileName, BOARD* aBoard, wxString header; PROPERTIES props; - if (aFormat==IO_MGR::LEGACY) + if ( aFormat==IO_MGR::LEGACY ) { header = wxString::Format( wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s scripting\n\n" ), diff --git a/pcbnew/scripting/pcbnew_scripting_helpers.h b/pcbnew/scripting/pcbnew_scripting_helpers.h index 5c50bca017..be6ee28b2e 100644 --- a/pcbnew/scripting/pcbnew_scripting_helpers.h +++ b/pcbnew/scripting/pcbnew_scripting_helpers.h @@ -7,15 +7,16 @@ * we want plain pcbnew. access from python */ #ifndef SWIG -void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPCBEdaFrame); +void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME *aPCBEdaFrame ); #endif BOARD *GetBoard(); -BOARD* LoadBoard(wxString& aFileName, IO_MGR::PCB_FILE_T aFormat); -BOARD* LoadBoard(wxString& aFileName); -bool SaveBoard(wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat); -bool SaveBoard(wxString& aFileName, BOARD* aBoard); +BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat ); +BOARD* LoadBoard( wxString& aFileName ); + +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