diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index d8607551f8..def2a82785 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -283,12 +283,17 @@ public: * puts up a dialog and allows the user to pick a library, for unspecified use. * * @param aNicknameExisting is the current choice to highlight - * * @return wxString - the library or wxEmptyString on abort. */ wxString SelectLibrary( const wxString& aNicknameExisting ); - MODULE* GetModuleByName(); + /** + * Function GetFootprintFromBoardByReference + * @return a reference to the footprint found by its refence + * on the curent board. the reference is entered by the user from + * a dialog (by awxTextCtlr, or a list of available references) + */ + MODULE* GetFootprintFromBoardByReference(); /** * Function OnModify diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index ff99a93764..23538d29e0 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -88,6 +88,7 @@ set( PCBNEW_DIALOGS dialogs/dialog_gen_module_position_file_base.cpp dialogs/dialog_general_options.cpp dialogs/dialog_general_options_BoardEditor_base.cpp + dialogs/dialog_get_footprint_by_name_base.cpp dialogs/dialog_global_edit_tracks_and_vias.cpp dialogs/dialog_global_edit_tracks_and_vias_base.cpp dialogs/dialog_global_modules_fields_edition.cpp diff --git a/pcbnew/dialogs/dialog_find_base.fbp b/pcbnew/dialogs/dialog_find_base.fbp index 3d827182df..7ce64bc569 100644 --- a/pcbnew/dialogs/dialog_find_base.fbp +++ b/pcbnew/dialogs/dialog_find_base.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -16,9 +16,9 @@ none 1 dialog_find - + . - + 1 1 1 @@ -27,67 +27,67 @@ 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + DIALOG_FIND_BASE - + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Find - - - - - - - - - - - - - + + + + + + + + + + + + + onClose - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + bSizerMain wxHORIZONTAL none @@ -96,7 +96,7 @@ wxEXPAND|wxTOP|wxBOTTOM 1 - + bSizerLeft wxVERTICAL none @@ -109,78 +109,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Search for: - + 0 - - + + 0 - + 1 m_staticText1 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -192,86 +192,86 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 0 - + 1 m_SearchTextCtrl 1 - - + + protected 1 - + Resizable 1 200,-1 - - + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -283,83 +283,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Do not warp mouse pointer - + 0 - - + + 0 - + 1 m_NoMouseWarpCheckBox 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -369,7 +369,7 @@ wxALL 0 - + bSizerRight wxVERTICAL none @@ -382,17 +382,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 1 0 @@ -400,65 +400,65 @@ 0 Left 1 - + 1 - + 0 0 wxID_ANY Find Item - + 0 - - + + 0 - + 1 m_button1 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + onButtonFindItemClick - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -470,17 +470,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -488,65 +488,65 @@ 0 Left 1 - + 1 - + 0 0 wxID_ANY Find Marker - + 0 - - + + 0 - + 1 m_button2 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + onButtonFindMarkerClick - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -558,17 +558,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -576,65 +576,65 @@ 0 Left 1 - + 1 - + 0 0 wxID_CANCEL Close - + 0 - - + + 0 - + 1 m_button3 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + onButtonCloseClick - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_get_footprint_by_name_base.cpp b/pcbnew/dialogs/dialog_get_footprint_by_name_base.cpp new file mode 100644 index 0000000000..3b5b5d43af --- /dev/null +++ b/pcbnew/dialogs/dialog_get_footprint_by_name_base.cpp @@ -0,0 +1,79 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_get_footprint_by_name_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_GET_FOOTPRINT_BY_NAME_BASE::DIALOG_GET_FOOTPRINT_BY_NAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerUpper; + bSizerUpper = new wxBoxSizer( wxHORIZONTAL ); + + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextRef = new wxStaticText( this, wxID_ANY, _("Reference:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextRef->Wrap( -1 ); + fgSizer1->Add( m_staticTextRef, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_SearchTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0 ); + m_SearchTextCtrl->SetMaxLength( 0 ); + fgSizer1->Add( m_SearchTextCtrl, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticTextRef1 = new wxStaticText( this, wxID_ANY, _("Available:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextRef1->Wrap( -1 ); + fgSizer1->Add( m_staticTextRef1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxArrayString m_choiceFpListChoices; + m_choiceFpList = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceFpListChoices, 0 ); + m_choiceFpList->SetSelection( 0 ); + fgSizer1->Add( m_choiceFpList, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizerUpper->Add( fgSizer1, 1, wxEXPAND, 5 ); + + + bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + this->SetSizer( bSizerMain ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::onClose ) ); + m_choiceFpList->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSelectFootprint ), NULL, this ); +} + +DIALOG_GET_FOOTPRINT_BY_NAME_BASE::~DIALOG_GET_FOOTPRINT_BY_NAME_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::onClose ) ); + m_choiceFpList->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSelectFootprint ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_get_footprint_by_name_base.fbp b/pcbnew/dialogs/dialog_get_footprint_by_name_base.fbp new file mode 100644 index 0000000000..ef7fa81e34 --- /dev/null +++ b/pcbnew/dialogs/dialog_get_footprint_by_name_base.fbp @@ -0,0 +1,580 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_get_footprint_by_name_base + 1000 + none + 1 + dialog_get_footprint_by_name + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_GET_FOOTPRINT_BY_NAME_BASE + + 341,176 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Search for footprint + + + + + + + + + + + + + + onClose + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizerUpper + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 2 + wxBOTH + + + 0 + + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reference: + + 0 + + + 0 + + 1 + m_staticTextRef + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_SearchTextCtrl + 1 + + + protected + 1 + + Resizable + 1 + 200,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Available: + + 0 + + + 0 + + 1 + m_staticTextRef1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choiceFpList + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnSelectFootprint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_get_footprint_by_name_base.h b/pcbnew/dialogs/dialog_get_footprint_by_name_base.h new file mode 100644 index 0000000000..f8e8aecd2e --- /dev/null +++ b/pcbnew/dialogs/dialog_get_footprint_by_name_base.h @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_GET_FOOTPRINT_BY_NAME_BASE_H__ +#define __DIALOG_GET_FOOTPRINT_BY_NAME_BASE_H__ + +#include +#include +#include +class DIALOG_SHIM; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_GET_FOOTPRINT_BY_NAME_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_GET_FOOTPRINT_BY_NAME_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxStaticText* m_staticTextRef; + wxTextCtrl* m_SearchTextCtrl; + wxStaticText* m_staticTextRef1; + wxChoice* m_choiceFpList; + wxStaticLine* m_staticline1; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void onClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnSelectFootprint( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_GET_FOOTPRINT_BY_NAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Search for footprint"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 341,176 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_GET_FOOTPRINT_BY_NAME_BASE(); + +}; + +#endif //__DIALOG_GET_FOOTPRINT_BY_NAME_BASE_H__ diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index aa8001d899..eae9b4cd75 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -703,7 +703,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it - SetCurItem( GetModuleByName() ); + SetCurItem( GetFootprintFromBoardByReference() ); module = (MODULE*) GetCurItem(); if( module == NULL ) diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index cb83e39b38..6258262074 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -56,14 +56,55 @@ static PICKED_ITEMS_LIST s_PickedList; /* a picked list to * and dragged tracks */ -/* Get a module name from user and return a pointer to the corresponding module +/* + * Get a footprint ref from user and return a pointer to the corresponding footprint + * + * DIALOG_GET_FOOTPRINT_BY_NAME is a helper dialog to select afootprint by its ref */ -MODULE* PCB_BASE_FRAME::GetModuleByName() -{ - wxString moduleName; - MODULE* module = NULL; +#include - wxTextEntryDialog dlg( this, _( "Reference:" ), _( "Search for footprint" ), moduleName ); +class DIALOG_GET_FOOTPRINT_BY_NAME: public DIALOG_GET_FOOTPRINT_BY_NAME_BASE +{ +public: + DIALOG_GET_FOOTPRINT_BY_NAME( PCB_BASE_FRAME* aParent, wxArrayString& aFpList ) : + DIALOG_GET_FOOTPRINT_BY_NAME_BASE( aParent ) + { + m_sdbSizerOK->SetDefault(); + m_choiceFpList->Append( aFpList ); + + // Dialog should not shrink beyond it's minimal size. + GetSizer()->SetSizeHints( this ); + } + + // returns the selected text (fp reference) + const wxString GetValue() + { + return m_SearchTextCtrl->GetValue(); + } + +private: + // Called when selecting an item from the item list + void OnSelectFootprint( wxCommandEvent& aEvent ) + { + if( m_choiceFpList->GetSelection() >= 0 ) + m_SearchTextCtrl->SetValue( + m_choiceFpList->GetString( m_choiceFpList->GetSelection() ).BeforeFirst( ' ' ) ); + } +}; + + +MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() +{ + wxString moduleName; + MODULE* module = NULL; + wxArrayString fplist; + + for( MODULE* fp = GetBoard()->m_Modules; fp; fp = fp->Next() ) + fplist.Add( fp->GetReference() + wxT(" ( ") + fp->GetValue() + wxT(" )") ); + + fplist.Sort(); + + DIALOG_GET_FOOTPRINT_BY_NAME dlg( this, fplist ); if( dlg.ShowModal() != wxID_OK ) return NULL; //Aborted by user diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index dc52429a4c..b31d933ac7 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -727,7 +727,7 @@ int SELECTION_TOOL::find( const TOOL_EVENT& aEvent ) int SELECTION_TOOL::findMove( const TOOL_EVENT& aEvent ) { - MODULE* module = m_frame->GetModuleByName(); + MODULE* module = m_frame->GetFootprintFromBoardByReference(); if( module ) {