diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 485072124c..8bed4f1ed1 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -27,6 +27,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) { wxString msg; + int page; switch( event.GetId() ) { @@ -35,7 +36,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_FOOTPRINT_WIZARD_PREVIOUS: - int page = m_PageList->GetSelection()-1; + page = m_PageList->GetSelection()-1; if (page<0) page=0; m_PageList->SetSelection(page,true); break; diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index ec3004c02a..c309febdd7 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -42,6 +42,7 @@ #include #include "footprint_wizard_frame.h" #include +#include #include #include @@ -73,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::ClickOnParameterList ) + EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) END_EVENT_TABLE() @@ -111,15 +112,15 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s // Give an icon wxIcon icon; - icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); + icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) ); SetIcon( icon ); m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_FootprintWizard = NULL; m_PageList= NULL; - m_ParameterList = NULL; + m_ParameterGrid = NULL; m_PageListWindow = NULL; - m_ParameterListWindow = NULL; + m_ParameterGridWindow = NULL; m_Semaphore = semaphore; m_wizardName.Empty(); @@ -160,22 +161,21 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s 0, NULL, wxLB_HSCROLL ); // Creates the component window display - m_ParameterListSize.y = size.y; + m_ParameterGridSize.y = size.y; win_pos.x = m_PageListSize.x; - m_ParameterListWindow = new wxSashLayoutWindow( this, + m_ParameterGridWindow = new wxSashLayoutWindow( this, ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, win_pos, wxDefaultSize, wxCLIP_CHILDREN | wxSW_3D, wxT( "ParameterList" ) ); - m_ParameterListWindow->SetOrientation( wxLAYOUT_VERTICAL ); - - m_ParameterListWindow->SetSashVisible( wxSASH_RIGHT, true ); - m_ParameterListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); - m_ParameterList = new wxListBox( m_ParameterListWindow, ID_FOOTPRINT_WIZARD_PARAMETER_LIST, - wxPoint( 0, 0 ), wxDefaultSize, - 0, NULL, wxLB_HSCROLL ); + m_ParameterGridWindow->SetOrientation( wxLAYOUT_VERTICAL ); + m_ParameterGridWindow->SetSashVisible( wxSASH_RIGHT, true ); + m_ParameterGridWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); + m_ParameterGrid = new wxGrid(m_ParameterGridWindow,ID_FOOTPRINT_WIZARD_PARAMETER_LIST, + wxPoint(0,0),wxDefaultSize); + ReCreatePageList(); DisplayWizardInfos(); @@ -211,8 +211,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s Left().Row( 0 )); // Manage the list of parameters) - m_auimgr.AddPane( m_ParameterListWindow, - wxAuiPaneInfo( info ).Name( wxT( "m_ParameterList" ) ). + m_auimgr.AddPane( m_ParameterGridWindow, + wxAuiPaneInfo( info ).Name( wxT( "m_ParameterGrid" ) ). Left().Row( 1 ) ); // Manage the draw panel @@ -231,8 +231,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow); pane.MinSize( wxSize(m_PageListSize.x, -1)); } - wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterListWindow); - pane.MinSize(wxSize(m_ParameterListSize.x, -1)); + wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterGridWindow); + pane.MinSize(wxSize(m_ParameterGridSize.x, -1)); m_auimgr.Update(); @@ -283,7 +283,7 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) return; m_PageListSize.y = GetClientSize().y - m_MsgFrameHeight; - m_ParameterListSize.y = m_PageListSize.y; + m_ParameterGridSize.y = m_PageListSize.y; switch( event.GetId() ) { @@ -299,9 +299,9 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) case ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW: { - wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterListWindow ); - m_ParameterListSize.x = event.GetDragRect().width; - pane.MinSize( m_ParameterListSize ); + wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterGridWindow ); + m_ParameterGridSize.x = event.GetDragRect().width; + pane.MinSize( m_ParameterGridSize ); m_auimgr.Update(); } break; @@ -352,7 +352,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() { - if( m_ParameterList == NULL ) + if( m_ParameterGrid == NULL ) return; if (m_FootprintWizard == NULL ) @@ -363,13 +363,38 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() if (page<0) return; - m_ParameterList->Clear(); + m_ParameterGrid->ClearGrid(); + + + // Columns + m_ParameterGrid->AutoSizeColumns(); + m_ParameterGrid->SetColLabelSize( 20 ); + m_ParameterGrid->SetColLabelValue( 0, _("Parameter") ); + m_ParameterGrid->SetColLabelValue( 1, _("Value") ); + m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); + + + // Rows + m_ParameterGrid->AutoSizeRows(); + m_ParameterGrid->EnableDragRowSize( true ); + m_ParameterGrid->SetRowLabelSize( 1 ); + m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + wxArrayString fpList = m_FootprintWizard->GetParameterNames(page); + wxArrayString fvList = m_FootprintWizard->GetParameterValues(page); + + m_ParameterGrid->CreateGrid(fpList.size(),2); + + for (unsigned int i=0;iSetCellValue( i, 0, fpList[i] ); + m_ParameterGrid->SetReadOnly( i, 0 ); + m_ParameterGrid->SetCellValue( i, 1 , fvList[i] ); + } + m_ParameterGrid->AutoSizeColumns(); - m_ParameterList->Append( fpList ); - m_ParameterList->SetSelection( 0, true ); - } @@ -387,15 +412,14 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) } -void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event ) +void FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid( wxCommandEvent& event ) { - int ii = m_ParameterList->GetSelection(); - - if( ii < 0 ) - return; - - wxString name = m_ParameterList->GetString( ii ); - + int n=m_ParameterGrid->GetNumberRows(); + + for (int i=0;iRead( PARTLIST_WIDTH_KEY , &m_PageListSize.x ); - cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterListSize.x ); + cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterGridSize.x ); // Set parameters to a reasonable value. if ( m_PageListSize.x > m_FrameSize.x/2 ) m_PageListSize.x = m_FrameSize.x/2; - if ( m_ParameterListSize.x > m_FrameSize.x/2 ) - m_ParameterListSize.x = m_FrameSize.x/2; + if ( m_ParameterGridSize.x > m_FrameSize.x/2 ) + m_ParameterGridSize.x = m_FrameSize.x/2; } @@ -444,7 +468,7 @@ void FOOTPRINT_WIZARD_FRAME::SaveSettings() if ( m_PageListSize.x ) cfg->Write( PARTLIST_WIDTH_KEY, m_PageListSize.x ); - cfg->Write( PARAMLIST_WIDTH_KEY, m_ParameterListSize.x ); + cfg->Write( PARAMLIST_WIDTH_KEY, m_ParameterGridSize.x ); } diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index f544151d27..47747518f9 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -36,6 +36,7 @@ class wxSashLayoutWindow; class wxListBox; class wxSemaphore; +class wxGrid; /** @@ -50,9 +51,9 @@ private: wxSize m_PageListSize; // size of the window // List of components in the selected library - wxSashLayoutWindow* m_ParameterListWindow; - wxListBox* m_ParameterList; // The list of parameters - wxSize m_ParameterListSize; // size of the window + wxSashLayoutWindow* m_ParameterGridWindow; + wxGrid* m_ParameterGrid; // The list of parameters + wxSize m_ParameterGridSize; // size of the window // Flags wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog @@ -103,7 +104,7 @@ private: void ReCreateVToolbar(); void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void ClickOnPageList( wxCommandEvent& event ); - void ClickOnParameterList( wxCommandEvent& event ); + void ClickOnParameterGrid( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); diff --git a/pcbnew/scripting/plugins/fpc_footprint_wizard.py b/pcbnew/scripting/plugins/fpc_footprint_wizard.py index a7a9c88ad5..2ae147c34c 100644 --- a/pcbnew/scripting/plugins/fpc_footprint_wizard.py +++ b/pcbnew/scripting/plugins/fpc_footprint_wizard.py @@ -17,6 +17,14 @@ class FPCFootprintWizard(FootprintWizardPlugin): } + def GetParameterValues(self,page_n): + name = self.GetParameterPageName(page_n) + values = self.parameters[name].values() + str_values = map( lambda x: str(x) , values) + + print values,str_values + return str_values + def smdRectPad(self,module,size,pos,name): pad = D_PAD(module) # print "smdRectPad( size=",size,"pos=",pos,"name=",name,")" @@ -70,10 +78,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): module.Add(pad_s1) e = EDGE_MODULE(module) - e.SetStart0(wxPointMM(-1,0)) - e.SetStart(wxPointMM(-1,0)) - e.SetEnd0(wxPointMM(0,0)) - e.SetEnd(wxPointMM(0,0)) + e.SetStartEnd(wxPointMM(-1,0),wxPointMM(0,0)) e.SetWidth(FromMM(0.2)) e.SetLayer(EDGE_LAYER) e.SetShape(S_SEGMENT) diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index 5f1147604b..99d34b94ca 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -84,14 +84,11 @@ class FootprintWizardPlugin(KiCadPlugin): def GetParameterNames(self,page_n): name = self.GetParameterPageName(page_n) return self.parameters[name].keys() - - def GetParameterValues(self,page_n): - name = self.GetParameterPageName(page_n) - return self.parameters[name].keys() def GetParameterValues(self,page_n): name = self.GetParameterPageName(page_n) - return self.parameters[name].values() + values = self.parameters[name].values() + return map( lambda x: str(x) , values) def SetParameterValues(self,page_n,values):