From 70df15175b50254c8856964e51851fbec0e0e782 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Wed, 16 May 2012 11:35:18 +0200 Subject: [PATCH] Footprint wizard, plus fixes --- pcbnew/CMakeLists.txt | 1 + pcbnew/class_footprint_wizard.h | 1 + .../dialogs/dialog_footprint_wizard_list.cpp | 3 ++ pcbnew/footprint_wizard.cpp | 45 +++++++++---------- pcbnew/footprint_wizard_frame.cpp | 17 +------ pcbnew/footprint_wizard_frame.h | 4 +- pcbnew/scripting/module.i | 5 ++- pcbnew/scripting/pcbnew_footprint_wizards.cpp | 40 ++++++++++++++++- pcbnew/scripting/pcbnew_footprint_wizards.h | 4 +- .../scripting/plugins/fpc_footprint_wizard.py | 40 ++++++++++++++--- scripting/kicadplugins.i | 45 ++++++++++++++++--- 11 files changed, 145 insertions(+), 60 deletions(-) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 8ed2faa588..d8efdd592e 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -290,6 +290,7 @@ if (KICAD_SCRIPTING) DEPENDS ../scripting/dlist.i DEPENDS ../scripting/kicad.i DEPENDS ../scripting/wx.i + DEPENDS ../scripting/kicadplugins.i # DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i diff --git a/pcbnew/class_footprint_wizard.h b/pcbnew/class_footprint_wizard.h index 2972aa55c9..97b2a6c4d2 100644 --- a/pcbnew/class_footprint_wizard.h +++ b/pcbnew/class_footprint_wizard.h @@ -23,6 +23,7 @@ public: virtual wxString GetParameterPageName(int aPage)=0; virtual wxArrayString GetParameterNames(int aPage)=0; virtual wxArrayString GetParameterValues(int aPage)=0; + virtual wxArrayString GetParameterErrors(int aPage)=0; virtual wxString SetParameterValues(int aPage,wxArrayString& aValues)=0; virtual MODULE *GetModule()=0; void register_wizard(); diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index 798529aa39..53e8ab3c36 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -28,6 +28,9 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent ) m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(0); // Choose selection mode and insert the needed rows + + m_footprintWizardsGrid->SetColSize( 0, 0 ); // hide the preview for now + m_footprintWizardsGrid->SetSelectionMode(wxGrid::wxGridSelectRows); m_footprintWizardsGrid->InsertRows(0,n_wizards,true); diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 8bed4f1ed1..51a50c93b6 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -134,31 +134,28 @@ void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event ) * Function SelectCurrentFootprint * Selects the current footprint name and display it */ -void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxCommandEvent& event ) +void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { - /* - // will pick it from the wizard - MODULE * module = new MODULE(NULL); - if( module ) - { - module->SetPosition( wxPoint( 0, 0 ) ); - - // Only one fotprint allowed: remove the previous footprint (if exists) - if( oldmodule ) - { - GetBoard()->Remove( oldmodule ); - delete oldmodule; - } - m_footprintName = module->GetLibRef(); - module->ClearFlags(); - SetCurItem( NULL ); - - Zoom_Automatique( false ); - m_canvas->Refresh( ); - Update3D_Frame(); - m_FootprintList->SetStringSelection( m_footprintName ); - } - * */ + + int page = m_PageList->GetSelection(); + + if (page<0) + return; + + int n=m_ParameterGrid->GetNumberRows(); + wxArrayString arr; + + for (int i=0;iGetCellValue(i,1); + arr.Add(val); + } + + wxString res = m_FootprintWizard->SetParameterValues(page,arr); + + ReloadFootprint(); + DisplayWizardInfos(); + } diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index c309febdd7..9e612ea390 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -74,7 +74,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) /* listbox events */ EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) - EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid ) + EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) END_EVENT_TABLE() @@ -412,21 +412,6 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) } -void FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid( wxCommandEvent& event ) -{ - int n=m_ParameterGrid->GetNumberRows(); - - for (int i=0;i