From 0761a0bae5b33a722929b69962b1c9b9db54aba4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 12 Jan 2018 19:36:15 +0000 Subject: [PATCH 4/4] Simplify Exchange Footprints dialog and add Update mode. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.14.3 (Apple Git-98)" This is a multi-part message in MIME format. --------------2.14.3 (Apple Git-98) Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit This commit also adds a no-selection-mode, which allows the user to specify what gets update (through the various match modes). The no-selection-mode is accessed via the Edit menu, although it could also be applied to the context menu. Fixes: lp:1466857 * https://bugs.launchpad.net/kicad/+bug/1466857 --- .../dialogs/dialog_edit_module_for_BoardEditor.cpp | 6 + .../dialogs/dialog_edit_module_for_BoardEditor.h | 2 + .../dialog_edit_module_for_BoardEditor_base.cpp | 21 +- .../dialog_edit_module_for_BoardEditor_base.fbp | 309 ++- .../dialog_edit_module_for_BoardEditor_base.h | 13 +- pcbnew/dialogs/dialog_exchange_modules.cpp | 367 +-- pcbnew/dialogs/dialog_exchange_modules.h | 27 +- pcbnew/dialogs/dialog_exchange_modules_base.cpp | 247 +- pcbnew/dialogs/dialog_exchange_modules_base.fbp | 2497 +++++++++++++------- pcbnew/dialogs/dialog_exchange_modules_base.h | 69 +- pcbnew/edit.cpp | 22 +- pcbnew/editmod.cpp | 9 +- pcbnew/menubar_pcbframe.cpp | 10 + pcbnew/onrightclick.cpp | 3 + pcbnew/pcbframe.cpp | 6 +- pcbnew/pcbnew_id.h | 3 + pcbnew/tools/edit_tool.cpp | 29 +- pcbnew/tools/edit_tool.h | 4 +- pcbnew/tools/pcb_actions.h | 3 + pcbnew/wxPcbStruct.h | 2 +- 20 files changed, 2406 insertions(+), 1243 deletions(-) --------------2.14.3 (Apple Git-98) Content-Type: text/x-patch; name="0004-Simplify-Exchange-Footprints-dialog-and-add-Update-m.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0004-Simplify-Exchange-Footprints-dialog-and-add-Update-m.patch" diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index e599802a5..a3d6cebfb 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -240,6 +240,12 @@ void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event ) } +void DIALOG_MODULE_BOARD_EDITOR::UpdateModule( wxCommandEvent& event ) +{ + EndModal( PRM_EDITOR_WANT_UPDATE_FP ); +} + + void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event ) { EndModal( PRM_EDITOR_WANT_EXCHANGE_FP ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h index b35d85727..fe6ed58ea 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h @@ -55,6 +55,7 @@ public: enum FP_PRM_EDITOR_RETVALUE { PRM_EDITOR_ABORT, + PRM_EDITOR_WANT_UPDATE_FP, PRM_EDITOR_WANT_EXCHANGE_FP, PRM_EDITOR_EDIT_OK, PRM_EDITOR_WANT_MODEDIT @@ -86,6 +87,7 @@ private: BrowseAndAdd3DShapeFile(); } void GotoModuleEditor( wxCommandEvent& event ) override; + void UpdateModule( wxCommandEvent& event ) override; void ExchangeModule( wxCommandEvent& event ) override; void ModuleOrientEvent( wxCommandEvent& event ) override; void Cfg3DPath( wxCommandEvent& event ) override; diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp index b2da77f29..399dfbfb9 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -125,11 +125,20 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare m_PropRightSizer = new wxBoxSizer( wxVERTICAL ); - m_buttonExchange = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, _("Change Footprint(s)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PropRightSizer->Add( m_buttonExchange, 0, wxALL|wxEXPAND, 5 ); + m_buttonUpdate = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_UPDATE, _("Update Footprint from Library"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PropRightSizer->Add( m_buttonUpdate, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bSizer17; + bSizer17 = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonExchange = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, _("Change Footprint"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer17->Add( m_buttonExchange, 1, wxALL|wxEXPAND, 5 ); m_buttonModuleEditor = new wxButton( m_PanelProperties, ID_GOTO_MODULE_EDITOR, _("Footprint Editor"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PropRightSizer->Add( m_buttonModuleEditor, 0, wxALL|wxEXPAND, 5 ); + bSizer17->Add( m_buttonModuleEditor, 1, wxALL|wxEXPAND, 5 ); + + + m_PropRightSizer->Add( bSizer17, 1, wxALL|wxEXPAND, 0 ); wxBoxSizer* bSizerAttrib; bSizerAttrib = new wxBoxSizer( wxHORIZONTAL ); @@ -179,7 +188,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare sbSizerAP->Add( bSizerMoveOpt, 1, wxEXPAND, 5 ); - m_PropRightSizer->Add( sbSizerAP, 0, wxEXPAND|wxALL, 5 ); + m_PropRightSizer->Add( sbSizerAP, 0, wxEXPAND|wxALL, 0 ); wxStaticBoxSizer* sbSizerLocalProperties; sbSizerLocalProperties = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Local Settings") ), wxVERTICAL ); @@ -370,6 +379,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditReference ), NULL, this ); m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditValue ), NULL, this ); m_OrientCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ModuleOrientEvent ), NULL, this ); + m_buttonUpdate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::UpdateModule ), NULL, this ); m_buttonExchange->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ExchangeModule ), NULL, this ); m_buttonModuleEditor->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::GotoModuleEditor ), NULL, this ); m_3D_ShapeNameListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::On3DShapeNameSelected ), NULL, this ); @@ -387,6 +397,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::~DIALOG_MODULE_BOARD_EDITOR_BASE() m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditReference ), NULL, this ); m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditValue ), NULL, this ); m_OrientCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ModuleOrientEvent ), NULL, this ); + m_buttonUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::UpdateModule ), NULL, this ); m_buttonExchange->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ExchangeModule ), NULL, this ); m_buttonModuleEditor->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::GotoModuleEditor ), NULL, this ); m_3D_ShapeNameListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::On3DShapeNameSelected ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp index 998a07889..297a28eb7 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp @@ -1958,11 +1958,11 @@ - + 5 0 - + m_PropRightSizer wxVERTICAL @@ -1999,8 +1999,8 @@ 0 0 - ID_MODULE_PROPERTIES_EXCHANGE - Change Footprint(s) + ID_MODULE_PROPERTIES_UPDATE + Update Footprint from Library 0 @@ -2008,7 +2008,7 @@ 0 1 - m_buttonExchange + m_buttonUpdate 1 @@ -2029,7 +2029,7 @@ - ExchangeModule + UpdateModule @@ -2055,99 +2055,198 @@ - - 5 + + 0 wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_GOTO_MODULE_EDITOR - Footprint Editor - - 0 - - - 0 + 1 + - 1 - m_buttonModuleEditor - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - GotoModuleEditor - - - - - - - - - - - - - - - - - - - - - - - + bSizer17 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_MODULE_PROPERTIES_EXCHANGE + Change Footprint + + 0 + + + 0 + + 1 + m_buttonExchange + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + ExchangeModule + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_GOTO_MODULE_EDITOR + Footprint Editor + + 0 + + + 0 + + 1 + m_buttonModuleEditor + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + GotoModuleEditor + + + + + + + + + + + + + + + + + + + + + + + + + - + 5 wxEXPAND 0 - + bSizerAttrib wxHORIZONTAL @@ -2334,11 +2433,11 @@ - - 5 + + 0 wxEXPAND|wxALL 0 - + wxID_ANY Auto Place @@ -2347,11 +2446,11 @@ 1 none - + 5 wxEXPAND 1 - + bSizerRotOpt wxVERTICAL @@ -2549,11 +2648,11 @@ - + 5 wxEXPAND 1 - + bSizerMoveOpt wxVERTICAL @@ -2753,11 +2852,11 @@ - + 5 wxALL|wxEXPAND 0 - + wxID_ANY Local Settings @@ -2766,20 +2865,20 @@ 1 none - + 5 wxEXPAND 0 - + bSizer11 wxVERTICAL none - + 5 wxEXPAND 1 - + bSizer10 wxHORIZONTAL diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h index 09f5ec551..8e3063c7a 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -40,10 +40,11 @@ class TEXT_CTRL_EVAL; #define ID_NOTEBOOK 1000 #define ID_LISTBOX_ORIENT_SELECT 1001 -#define ID_MODULE_PROPERTIES_EXCHANGE 1002 -#define ID_GOTO_MODULE_EDITOR 1003 -#define ID_ADD_3D_SHAPE 1004 -#define ID_REMOVE_3D_SHAPE 1005 +#define ID_MODULE_PROPERTIES_UPDATE 1002 +#define ID_MODULE_PROPERTIES_EXCHANGE 1003 +#define ID_GOTO_MODULE_EDITOR 1004 +#define ID_ADD_3D_SHAPE 1005 +#define ID_REMOVE_3D_SHAPE 1006 /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_MODULE_BOARD_EDITOR_BASE @@ -76,6 +77,7 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public DIALOG_SHIM wxStaticText* m_YPosUnit; wxStaticText* m_TextSheetPath; wxTextCtrl* m_textCtrlSheetPath; + wxButton* m_buttonUpdate; wxButton* m_buttonExchange; wxButton* m_buttonModuleEditor; wxRadioBox* m_AttributsCtrl; @@ -119,6 +121,7 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public DIALOG_SHIM virtual void OnEditReference( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditValue( wxCommandEvent& event ) { event.Skip(); } virtual void ModuleOrientEvent( wxCommandEvent& event ) { event.Skip(); } + virtual void UpdateModule( wxCommandEvent& event ) { event.Skip(); } virtual void ExchangeModule( wxCommandEvent& event ) { event.Skip(); } virtual void GotoModuleEditor( wxCommandEvent& event ) { event.Skip(); } virtual void On3DShapeNameSelected( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_exchange_modules.cpp b/pcbnew/dialogs/dialog_exchange_modules.cpp index 712fac233..f71eb2977 100644 --- a/pcbnew/dialogs/dialog_exchange_modules.cpp +++ b/pcbnew/dialogs/dialog_exchange_modules.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -47,15 +48,21 @@ static bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName ); -int DIALOG_EXCHANGE_MODULE::m_selectionMode = 0; +int DIALOG_EXCHANGE_MODULE::m_matchModeForUpdate = wxID_MATCH_FP_ALL; +int DIALOG_EXCHANGE_MODULE::m_matchModeForExchange = wxID_MATCH_FP_REF; +int DIALOG_EXCHANGE_MODULE::m_matchModeForUpdateSelected = wxID_MATCH_FP_REF; +int DIALOG_EXCHANGE_MODULE::m_matchModeForExchangeSelected = wxID_MATCH_FP_REF; -DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* parent, MODULE* Module ) : +DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* parent, MODULE* Module, + bool updateMode ) : DIALOG_EXCHANGE_MODULE_BASE( parent ), m_commit( parent ) { m_parent = parent; m_currentModule = Module; - init(); + m_updateMode = updateMode; + + init( m_updateMode ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); Center(); @@ -64,97 +71,234 @@ DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* parent, MODULE* void DIALOG_EXCHANGE_MODULE::OnQuit( wxCommandEvent& event ) { - m_selectionMode = m_Selection->GetSelection(); Show( false ); EndQuasiModal( wxID_CANCEL ); } -void DIALOG_EXCHANGE_MODULE::init() +void DIALOG_EXCHANGE_MODULE::init( bool updateMode ) { SetFocus(); - m_CurrentFootprintFPID->AppendText( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); - m_NewFootprintFPID->AppendText( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); - m_CmpValue->AppendText( m_currentModule->GetValue() ); - m_CmpReference->AppendText( m_currentModule->GetReference() ); - m_Selection->SetString( 0, wxString::Format( - _( "Change footprint of \"%s\"" ), - GetChars( m_currentModule->GetReference() ) ) ); - wxString fpname = m_CurrentFootprintFPID->GetValue().AfterLast( ':' ); + // fetch title and mode strings out of the dialog (so they can be easily localized) + wxString title = updateMode ? m_updateModeTitle->GetLabel() : m_exchangeModeTitle->GetLabel(); + wxString verb = updateMode ? m_updateModeVerb->GetLabel() : m_exchangeModeVerb->GetLabel(); + wxString label; + m_localizationSizer->Show( false ); - if( fpname.IsEmpty() ) // Happens for old fp names - fpname = m_CurrentFootprintFPID->GetValue(); + SetTitle( title ); - m_Selection->SetString( 1, wxString::Format( - _( "Change footprints \"%s\"" ), - GetChars( fpname.Left( 12 ) ) ) ); + if( updateMode ) + { + label.Printf( m_matchAll->GetLabel(), verb ); + m_matchAll->SetLabel( label ); - m_Selection->SetSelection( m_selectionMode ); + m_middleSizer->Show( false ); + } + else + { + m_allSizer->Show( false ); - // Enable/disable widgets: - wxCommandEvent event; - OnSelectionClicked( event ); -} + if( m_currentModule ) + m_newID->AppendText( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); + m_newIDBrowseButton->SetBitmap( KiBitmap( library_browse_xpm ) ); + } + if( m_currentModule ) + { + m_specifiedRefSizer->Show( false ); -void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event ) -{ - m_selectionMode = m_Selection->GetSelection(); - bool result = false; + label.Printf( m_matchCurrentRef->GetLabel(), verb, m_currentModule->GetReference() ); + m_matchCurrentRef->SetLabel( label ); - m_MessageWindow->Clear(); - m_MessageWindow->Flush(); + m_specifiedValueSizer->Show( false ); - switch( m_Selection->GetSelection() ) + label.Printf( m_matchCurrentValue->GetLabel(), verb, m_currentModule->GetValue() ); + m_matchCurrentValue->SetLabel( label ); + } + else { - case 0: - result = changeCurrentFootprint(); - break; + m_currentRefSizer->Show( false ); - case 1: - result = changeSameFootprints( false ); - break; + label.Printf( m_matchSpecifiedRef->GetLabel(), verb ); + m_matchSpecifiedRef->SetLabel( label ); - case 2: - result = changeSameFootprints( true ); - break; + m_currentValueSizer->Show( false ); + + label.Printf( m_matchSpecifiedValue->GetLabel(), verb ); + m_matchSpecifiedValue->SetLabel( label ); + } - case 3: - result = changeAllFootprints(); + label.Printf( m_matchSpecifiedID->GetLabel(), verb ); + m_matchSpecifiedID->SetLabel( label ); + if( m_currentModule ) + m_specifiedID->AppendText( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); + m_specifiedIDBrowseButton->SetBitmap( KiBitmap( library_browse_xpm ) ); + + // initialize match-mode + wxCommandEvent event; + switch( getMatchMode() ) + { + case wxID_MATCH_FP_ALL: + if( m_currentModule ) + OnMatchRefClicked( event ); + else + OnMatchAllClicked( event ); + break; + case wxID_MATCH_FP_REF: + OnMatchRefClicked( event ); break; + case wxID_MATCH_FP_VAL: + OnMatchValueClicked( event ); + break; + case wxID_MATCH_FP_ID: + OnMatchIDClicked( event ); } +} - if( result ) + +int DIALOG_EXCHANGE_MODULE::getMatchMode() +{ + if( m_updateMode ) + return( m_currentModule ? m_matchModeForUpdateSelected : m_matchModeForUpdate ); + else + return( m_currentModule ? m_matchModeForExchangeSelected : m_matchModeForExchange ); +} + + +void DIALOG_EXCHANGE_MODULE::setMatchMode( int aMatchMode ) +{ + if( m_updateMode ) { - if( m_parent->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) - m_parent->Compile_Ratsnest( NULL, true ); + if( m_currentModule ) + m_matchModeForUpdateSelected = aMatchMode; + else + m_matchModeForUpdate = aMatchMode; + } + else + { + if( m_currentModule ) + m_matchModeForExchangeSelected = aMatchMode; + else + m_matchModeForExchange = aMatchMode; + } +} - m_parent->GetCanvas()->Refresh(); + +bool DIALOG_EXCHANGE_MODULE::isMatch( MODULE* aModule ) +{ + switch( getMatchMode() ) + { + case wxID_MATCH_FP_ALL: + return true; + case wxID_MATCH_FP_REF: + // currentModule case goes through changeCurrentFootprint, so we only have + // to handle specifiedRef case + return aModule->GetReference() == m_specifiedRef->GetValue(); + case wxID_MATCH_FP_VAL: + // currentValue must also check FPID so we don't get accidental matches that + // the user didn't intend + if( m_currentModule ) + return aModule->GetValue() == m_currentModule->GetValue() + && aModule->GetFPID() == m_currentModule->GetFPID(); + else + return aModule->GetValue() == m_specifiedValue->GetValue(); + case wxID_MATCH_FP_ID: + return aModule->GetFPID() == m_specifiedID->GetValue(); } + return false; // just to quiet compiler warnings.... +} - m_commit.Push( wxT( "Changed footprint" ) ); + +wxRadioButton* DIALOG_EXCHANGE_MODULE::getRadioButtonForMode() +{ + switch( getMatchMode() ) + { + case wxID_MATCH_FP_ALL: + return( m_matchAll ); + case wxID_MATCH_FP_REF: + return( m_matchCurrentRef->IsShown() ? m_matchCurrentRef : m_matchSpecifiedRef ); + case wxID_MATCH_FP_VAL: + return( m_matchCurrentValue->IsShown() ? m_matchCurrentValue : m_matchSpecifiedValue ); + case wxID_MATCH_FP_ID: + return( m_matchSpecifiedID ); + default: + return nullptr; + } +} + + +void DIALOG_EXCHANGE_MODULE::updateMatchModeRadioButtons() +{ + wxRadioButton* button = getRadioButtonForMode(); + + m_matchAll->SetValue( m_matchAll == button ); + m_matchCurrentRef->SetValue( m_matchCurrentRef == button ); + m_matchSpecifiedRef->SetValue( m_matchSpecifiedRef == button ); + m_matchCurrentValue->SetValue( m_matchCurrentValue == button ); + m_matchSpecifiedValue->SetValue( m_matchSpecifiedValue == button ); + m_matchSpecifiedID->SetValue(m_matchSpecifiedID == button ); +} + + +void DIALOG_EXCHANGE_MODULE::OnMatchAllClicked( wxCommandEvent& event ) +{ + setMatchMode( wxID_MATCH_FP_ALL ); + updateMatchModeRadioButtons(); + m_matchAll->SetFocus(); +} + +void DIALOG_EXCHANGE_MODULE::OnMatchRefClicked( wxCommandEvent& event ) +{ + setMatchMode( wxID_MATCH_FP_REF ); + updateMatchModeRadioButtons(); + + if( m_specifiedRef->IsShown() && event.GetEventObject() != m_specifiedRef ) + m_specifiedRef->SetFocus(); +} + + +void DIALOG_EXCHANGE_MODULE::OnMatchValueClicked( wxCommandEvent& event ) +{ + setMatchMode( wxID_MATCH_FP_VAL ); + updateMatchModeRadioButtons(); + + if( m_specifiedValue->IsShown() && event.GetEventObject() != m_specifiedValue ) + m_specifiedValue->SetFocus(); } -void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event ) +void DIALOG_EXCHANGE_MODULE::OnMatchIDClicked( wxCommandEvent& event ) { - bool enable = true; + setMatchMode( wxID_MATCH_FP_ID ); + updateMatchModeRadioButtons(); + + if( m_specifiedID->IsShown() && event.GetEventObject() != m_specifiedID ) + m_specifiedID->SetFocus(); +} - switch( m_Selection->GetSelection() ) + +void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event ) +{ + bool result = false; + + m_MessageWindow->Clear(); + m_MessageWindow->Flush(); + + if( getMatchMode() == wxID_MATCH_FP_REF && m_currentModule ) + result = changeCurrentFootprint(); + else + result = changeSameFootprints(); + + if( result ) { - case 0: - case 1: - case 2: - break; + if( m_parent->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) + m_parent->Compile_Ratsnest( NULL, true ); - case 3: - enable = false; - break; + m_parent->GetCanvas()->Refresh(); } - m_NewFootprintFPID->Enable( enable ); - m_Browsebutton->Enable( enable ); + m_commit.Push( wxT( "Changed footprint" ) ); } @@ -185,52 +329,31 @@ void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event ) bool DIALOG_EXCHANGE_MODULE::changeCurrentFootprint() { - wxString newmodulename = m_NewFootprintFPID->GetValue(); + if( m_updateMode ) + return change_1_Module( m_currentModule, m_currentModule->GetFPID(), true ); + + wxString newFPID = m_newID->GetValue(); - if( newmodulename == wxEmptyString ) + if( newFPID == wxEmptyString ) return false; - return change_1_Module( m_currentModule, newmodulename, true ); + return change_1_Module( m_currentModule, newFPID, true ); } -bool DIALOG_EXCHANGE_MODULE::changeSameFootprints( bool aUseValue ) +bool DIALOG_EXCHANGE_MODULE::changeSameFootprints() { - wxString msg; MODULE* Module; MODULE* PtBack; bool change = false; - wxString newmodulename = m_NewFootprintFPID->GetValue(); + wxString newFPID = m_newID->GetValue(); wxString value; - LIB_ID lib_reference; - bool check_module_value = false; int ShowErr = 3; // Post 3 error messages max. if( m_parent->GetBoard()->m_Modules == NULL ) return false; - if( newmodulename == wxEmptyString ) - return false; - - lib_reference = m_currentModule->GetFPID(); - - if( aUseValue ) - { - check_module_value = true; - value = m_currentModule->GetValue(); - msg.Printf( _( "Change footprint %s -> %s (for value = %s)?" ), - GetChars( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ), - GetChars( newmodulename ), - GetChars( m_currentModule->GetValue() ) ); - } - else - { - msg.Printf( _( "Change footprint %s -> %s ?" ), - GetChars( FROM_UTF8( lib_reference.Format().c_str() ) ), - GetChars( newmodulename ) ); - } - - if( !IsOK( this, msg ) ) + if( !m_updateMode && newFPID == wxEmptyString ) return false; /* The change is done from the last module because @@ -245,50 +368,16 @@ bool DIALOG_EXCHANGE_MODULE::changeSameFootprints( bool aUseValue ) { PtBack = Module->Back(); - if( lib_reference != Module->GetFPID() ) + if( !isMatch( Module ) ) continue; - if( check_module_value ) - { - if( value.CmpNoCase( Module->GetValue() ) != 0 ) - continue; - } + bool result; + if( m_updateMode ) + result = change_1_Module( Module, Module->GetFPID(), ShowErr ); + else + result = change_1_Module( Module, newFPID, ShowErr ); - if( change_1_Module( Module, newmodulename, ShowErr ) ) - change = true; - else if( ShowErr ) - ShowErr--; - } - - return change; -} - - -bool DIALOG_EXCHANGE_MODULE::changeAllFootprints() -{ - MODULE* Module, * PtBack; - bool change = false; - int ShowErr = 3; // Post 3 error max. - - if( m_parent->GetBoard()->m_Modules == NULL ) - return false; - - if( !IsOK( this, _( "Are you sure you want to change all footprints?" ) ) ) - return false; - - /* The change is done from the last module because the function - * change_1_Module () modifies the last module in the list - * - * note: for the first module in chain (the last here), Module->Back() - * points the board or is NULL - */ - Module = m_parent->GetBoard()->m_Modules.GetLast(); - - for( ; Module && ( Module->Type() == PCB_MODULE_T ); Module = PtBack ) - { - PtBack = Module->Back(); - - if( change_1_Module( Module, Module->GetFPID(), ShowErr ) ) + if( result ) change = true; else if( ShowErr ) ShowErr--; @@ -333,6 +422,8 @@ bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule, if( aModule == m_currentModule ) m_currentModule = newModule; + if( aModule == m_parent->GetCurItem() ) + m_parent->SetCurItem( newModule ); msg += ": OK"; reporter.Report( msg, REPORTER::RPT_ACTION ); @@ -382,19 +473,6 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, } -// Displays the list of available footprints in library name and select a footprint. -void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event ) -{ - wxString newname; - - newname = m_parent->SelectFootprint( m_parent, wxEmptyString, wxEmptyString, wxEmptyString, - Prj().PcbFootprintLibs() ); - - if( newname != wxEmptyString ) - m_NewFootprintFPID->SetValue( newname ); -} - - void DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint( wxCommandEvent& event ) { wxString newname; @@ -403,7 +481,10 @@ void DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint( wxCommandEvent& event ) if( frame->ShowModal( &newname, this ) ) { - m_NewFootprintFPID->SetValue( newname ); + if( event.GetEventObject() == m_newIDBrowseButton ) + m_newID->SetValue( newname ); + else + m_specifiedID->SetValue( newname ); } frame->Destroy(); diff --git a/pcbnew/dialogs/dialog_exchange_modules.h b/pcbnew/dialogs/dialog_exchange_modules.h index 7c225791b..083661764 100644 --- a/pcbnew/dialogs/dialog_exchange_modules.h +++ b/pcbnew/dialogs/dialog_exchange_modules.h @@ -37,24 +37,37 @@ class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE private: PCB_EDIT_FRAME* m_parent; MODULE* m_currentModule; - static int m_selectionMode; // Remember the last exchange option + bool m_updateMode; + static int m_matchModeForUpdate; // remember last match-mode + static int m_matchModeForExchange; // remember last match-mode + static int m_matchModeForUpdateSelected; // remember last match-mode + static int m_matchModeForExchangeSelected; // remember last match-mode public: - DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* aParent, MODULE* aModule ); + DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* aParent, MODULE* aModule, bool updateMode ); ~DIALOG_EXCHANGE_MODULE() { }; private: - void OnSelectionClicked( wxCommandEvent& event ) override; + void OnMatchAllClicked( wxCommandEvent& event ) override; + void OnMatchRefClicked( wxCommandEvent& event ) override; + void OnMatchValueClicked( wxCommandEvent& event ) override; + void OnMatchIDClicked( wxCommandEvent& event ) override; void OnOkClick( wxCommandEvent& event ) override; void OnQuit( wxCommandEvent& event ) override; - void BrowseAndSelectFootprint( wxCommandEvent& event ) override; void ViewAndSelectFootprint( wxCommandEvent& event ) override; void RebuildCmpList( wxCommandEvent& event ) override; - void init(); + void init( bool updateMode ); + + int getMatchMode(); + void setMatchMode( int aMatchMode ); + + wxRadioButton* getRadioButtonForMode(); + void updateMatchModeRadioButtons(); + + bool isMatch( MODULE* ); bool changeCurrentFootprint(); - bool changeSameFootprints( bool aUseValue); - bool changeAllFootprints(); + bool changeSameFootprints(); bool change_1_Module( MODULE* aModule, const LIB_ID& aNewFootprintFPID, bool eShowError ); diff --git a/pcbnew/dialogs/dialog_exchange_modules_base.cpp b/pcbnew/dialogs/dialog_exchange_modules_base.cpp index 27d02a642..d9f03fc99 100644 --- a/pcbnew/dialogs/dialog_exchange_modules_base.cpp +++ b/pcbnew/dialogs/dialog_exchange_modules_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -15,118 +15,227 @@ DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWi { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* mainSizer; + mainSizer = new wxBoxSizer( wxVERTICAL ); + + m_localizationSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_updateModeTitle = new wxStaticText( this, wxID_ANY, _("Update Footprints from Library"), wxDefaultPosition, wxDefaultSize, 0 ); + m_updateModeTitle->Wrap( -1 ); + m_localizationSizer->Add( m_updateModeTitle, 0, wxALL, 5 ); + + m_exchangeModeTitle = new wxStaticText( this, wxID_ANY, _("Change Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); + m_exchangeModeTitle->Wrap( -1 ); + m_localizationSizer->Add( m_exchangeModeTitle, 0, wxALL, 5 ); + + m_updateModeVerb = new wxStaticText( this, wxID_ANY, _("Update"), wxDefaultPosition, wxDefaultSize, 0 ); + m_updateModeVerb->Wrap( -1 ); + m_localizationSizer->Add( m_updateModeVerb, 0, wxALL, 5 ); + + m_exchangeModeVerb = new wxStaticText( this, wxID_ANY, _("Change"), wxDefaultPosition, wxDefaultSize, 0 ); + m_exchangeModeVerb->Wrap( -1 ); + m_localizationSizer->Add( m_exchangeModeVerb, 0, wxALL, 5 ); + + + mainSizer->Add( m_localizationSizer, 0, 0, 5 ); wxBoxSizer* bUpperSizer; - bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + bUpperSizer = new wxBoxSizer( wxVERTICAL ); + + m_allSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_matchAll = new wxRadioButton( this, wxID_MATCH_FP_ALL, _("%s all footprints on board"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchAll->SetValue( true ); + m_matchAll->SetMinSize( wxSize( -1,26 ) ); + + m_allSizer->Add( m_matchAll, 0, wxALL, 2 ); + + + bUpperSizer->Add( m_allSizer, 29, wxEXPAND, 5 ); + + m_currentRefSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_matchCurrentRef = new wxRadioButton( this, wxID_MATCH_FP_REF, _("%s current footprint (%s)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchCurrentRef->SetMinSize( wxSize( -1,26 ) ); + + m_currentRefSizer->Add( m_matchCurrentRef, 0, wxALL, 2 ); + + + bUpperSizer->Add( m_currentRefSizer, 31, wxEXPAND, 5 ); + + m_specifiedRefSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_matchSpecifiedRef = new wxRadioButton( this, wxID_MATCH_FP_REF, _("%s footprint with reference:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchSpecifiedRef->SetMinSize( wxSize( -1,26 ) ); + + m_specifiedRefSizer->Add( m_matchSpecifiedRef, 0, wxALL, 2 ); + + m_specifiedRef = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_specifiedRef->SetMinSize( wxSize( -1,24 ) ); + m_specifiedRef->SetMaxSize( wxSize( 80,-1 ) ); - wxBoxSizer* bLeftSizer; - bLeftSizer = new wxBoxSizer( wxVERTICAL ); + m_specifiedRefSizer->Add( m_specifiedRef, 0, wxALL, 3 ); - m_staticTextCmpVal = new wxStaticText( this, wxID_ANY, _("Footprint value"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextCmpVal->Wrap( -1 ); - bLeftSizer->Add( m_staticTextCmpVal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_CmpValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bLeftSizer->Add( m_CmpValue, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bUpperSizer->Add( m_specifiedRefSizer, 29, wxEXPAND, 5 ); - m_staticTexCmpRef = new wxStaticText( this, wxID_ANY, _("Footprint reference"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTexCmpRef->Wrap( -1 ); - bLeftSizer->Add( m_staticTexCmpRef, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_currentValueSizer = new wxBoxSizer( wxHORIZONTAL ); - m_CmpReference = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bLeftSizer->Add( m_CmpReference, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + m_matchCurrentValue = new wxRadioButton( this, wxID_MATCH_FP_VAL, _("%s footprints with matching value (%s)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchCurrentValue->SetMinSize( wxSize( -1,26 ) ); + m_currentValueSizer->Add( m_matchCurrentValue, 0, wxALL, 2 ); - bUpperSizer->Add( bLeftSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); - wxBoxSizer* bMiddleSizer; - bMiddleSizer = new wxBoxSizer( wxVERTICAL ); + bUpperSizer->Add( m_currentValueSizer, 31, wxEXPAND, 5 ); - wxString m_SelectionChoices[] = { _("Change footprint"), _("Change footprints"), _("Change footprints having same value"), _("Update all footprints of the board") }; - int m_SelectionNChoices = sizeof( m_SelectionChoices ) / sizeof( wxString ); - m_Selection = new wxRadioBox( this, ID_SELECTION_CLICKED, _("Options"), wxDefaultPosition, wxDefaultSize, m_SelectionNChoices, m_SelectionChoices, 1, wxRA_SPECIFY_COLS ); - m_Selection->SetSelection( 1 ); - bMiddleSizer->Add( m_Selection, 0, wxALL, 5 ); + m_specifiedValueSizer = new wxBoxSizer( wxHORIZONTAL ); + m_matchSpecifiedValue = new wxRadioButton( this, wxID_MATCH_FP_VAL, _("%s footprints with value:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchSpecifiedValue->SetMinSize( wxSize( -1,26 ) ); - bUpperSizer->Add( bMiddleSizer, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_specifiedValueSizer->Add( m_matchSpecifiedValue, 0, wxALL, 2 ); - wxBoxSizer* bRightSizer; - bRightSizer = new wxBoxSizer( wxVERTICAL ); + m_specifiedValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_specifiedValue->SetMinSize( wxSize( 160,24 ) ); - m_buttonCmpList = new wxButton( this, wxID_ANY, _("Export Footprint Association File"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizer->Add( m_buttonCmpList, 0, wxALL|wxEXPAND, 5 ); + m_specifiedValueSizer->Add( m_specifiedValue, 0, wxALL, 3 ); - m_Browsebutton = new wxButton( this, wxID_ANY, _("List Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizer->Add( m_Browsebutton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - m_buttonFPViewer = new wxButton( this, wxID_ANY, _("View Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizer->Add( m_buttonFPViewer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bUpperSizer->Add( m_specifiedValueSizer, 31, wxEXPAND, 5 ); + m_specifiedIDSizer = new wxBoxSizer( wxVERTICAL ); - bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_matchSpecifiedID = new wxRadioButton( this, wxID_MATCH_FP_ID, _("%s footprints with identifier:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_specifiedIDSizer->Add( m_matchSpecifiedID, 0, wxALL, 2 ); + wxBoxSizer* specifiedIDSizer; + specifiedIDSizer = new wxBoxSizer( wxHORIZONTAL ); - bMainSizer->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 ); + m_specifiedID = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_specifiedID->SetMinSize( wxSize( 500,24 ) ); - m_staticTextCurrFPID = new wxStaticText( this, wxID_ANY, _("Current footprint identifier"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextCurrFPID->Wrap( -1 ); - bMainSizer->Add( m_staticTextCurrFPID, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + specifiedIDSizer->Add( m_specifiedID, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2 ); - m_CurrentFootprintFPID = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bMainSizer->Add( m_CurrentFootprintFPID, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_specifiedIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + specifiedIDSizer->Add( m_specifiedIDBrowseButton, 0, wxALL, 0 ); - m_staticTextNewFPID = new wxStaticText( this, wxID_ANY, _("New footprint identifier"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextNewFPID->Wrap( -1 ); - bMainSizer->Add( m_staticTextNewFPID, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_NewFootprintFPID = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bMainSizer->Add( m_NewFootprintFPID, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_specifiedIDSizer->Add( specifiedIDSizer, 0, wxALIGN_TOP|wxEXPAND, 0 ); + + + bUpperSizer->Add( m_specifiedIDSizer, 45, wxEXPAND, 5 ); + + + mainSizer->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 ); + + m_middleSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticLine* staticline1; + staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + m_middleSizer->Add( staticline1, 0, wxEXPAND | wxALL, 0 ); + + wxStaticText* newIdLabel; + newIdLabel = new wxStaticText( this, wxID_ANY, _("New footprint identifier:"), wxDefaultPosition, wxDefaultSize, 0 ); + newIdLabel->Wrap( -1 ); + m_middleSizer->Add( newIdLabel, 0, wxALL, 2 ); + + wxBoxSizer* newIDSizer; + newIDSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_newID = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_newID->SetMinSize( wxSize( 500,24 ) ); + + newIDSizer->Add( m_newID, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2 ); + + m_newIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + newIDSizer->Add( m_newIDBrowseButton, 0, wxALL, 0 ); + + + m_middleSizer->Add( newIDSizer, 0, wxEXPAND, 0 ); + + + mainSizer->Add( m_middleSizer, 0, wxALL|wxEXPAND, 5 ); m_MessageWindow = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_MessageWindow->SetMinSize( wxSize( -1,300 ) ); - bMainSizer->Add( m_MessageWindow, 1, wxEXPAND | wxALL, 5 ); + mainSizer->Add( m_MessageWindow, 1, wxALL|wxEXPAND, 5 ); + + wxStaticLine* staticline2; + staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + mainSizer->Add( staticline2, 0, wxEXPAND | wxALL, 5 ); + + wxBoxSizer* bottomSizer; + bottomSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_exportButton = new wxButton( this, wxID_ANY, _("Export Footprint Associations"), wxDefaultPosition, wxDefaultSize, 0 ); + bottomSizer->Add( m_exportButton, 0, wxALL, 5 ); + + wxBoxSizer* paddingSizer; + paddingSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticText* padding1; + padding1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + padding1->Wrap( -1 ); + paddingSizer->Add( padding1, 1, wxALL, 5 ); - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); - wxBoxSizer* bSizerButts; - bSizerButts = new wxBoxSizer( wxHORIZONTAL ); + bottomSizer->Add( paddingSizer, 1, 0, 5 ); - m_Applybutton = new wxButton( this, wxID_OK, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButts->Add( m_Applybutton, 0, wxEXPAND|wxALL, 5 ); + m_applyButton = new wxButton( this, wxID_ANY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); + bottomSizer->Add( m_applyButton, 0, wxALL, 5 ); - m_Quitbutton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButts->Add( m_Quitbutton, 0, wxALL|wxEXPAND, 5 ); + m_closeButton = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bottomSizer->Add( m_closeButton, 0, wxALL, 5 ); - bMainSizer->Add( bSizerButts, 0, wxALIGN_RIGHT, 5 ); + mainSizer->Add( bottomSizer, 0, wxEXPAND, 5 ); - this->SetSizer( bMainSizer ); + this->SetSizer( mainSizer ); this->Layout(); - bMainSizer->Fit( this ); + mainSizer->Fit( this ); // Connect Events - m_Selection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this ); - m_buttonCmpList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this ); - m_Browsebutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this ); - m_buttonFPViewer->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); - m_Applybutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); - m_Quitbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); + m_matchAll->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchAllClicked ), NULL, this ); + m_matchCurrentRef->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_matchSpecifiedRef->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_specifiedRef->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_specifiedRef->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_matchCurrentValue->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_matchSpecifiedValue->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_specifiedValue->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_specifiedValue->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_matchSpecifiedID->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedID->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedID->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedIDBrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); + m_newIDBrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); + m_exportButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this ); + m_applyButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); + m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); } DIALOG_EXCHANGE_MODULE_BASE::~DIALOG_EXCHANGE_MODULE_BASE() { // Disconnect Events - m_Selection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this ); - m_buttonCmpList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this ); - m_Browsebutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this ); - m_buttonFPViewer->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); - m_Applybutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); - m_Quitbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); + m_matchAll->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchAllClicked ), NULL, this ); + m_matchCurrentRef->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_matchSpecifiedRef->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_specifiedRef->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_specifiedRef->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchRefClicked ), NULL, this ); + m_matchCurrentValue->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_matchSpecifiedValue->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_specifiedValue->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_specifiedValue->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchValueClicked ), NULL, this ); + m_matchSpecifiedID->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedID->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedID->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnMatchIDClicked ), NULL, this ); + m_specifiedIDBrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); + m_newIDBrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::ViewAndSelectFootprint ), NULL, this ); + m_exportButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::RebuildCmpList ), NULL, this ); + m_applyButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this ); + m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_exchange_modules_base.fbp b/pcbnew/dialogs/dialog_exchange_modules_base.fbp index ab2e08185..b7ad6b3d8 100644 --- a/pcbnew/dialogs/dialog_exchange_modules_base.fbp +++ b/pcbnew/dialogs/dialog_exchange_modules_base.fbp @@ -12,7 +12,7 @@ UTF-8 connect dialog_exchange_modules_base - 1000 + 4200 none 1 dialog_exchange_modules_base @@ -47,7 +47,7 @@ -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Change Footprint + %s @@ -90,492 +90,375 @@ - bMainSizer + mainSizer wxVERTICAL none 5 - wxALL|wxEXPAND + 0 - bUpperSizer + m_localizationSizer wxHORIZONTAL - none + protected 5 - wxALIGN_CENTER_VERTICAL - 1 - + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Update Footprints from Library + + 0 + + + 0 - bLeftSizer - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Footprint value - - 0 - - - 0 - - 1 - m_staticTextCmpVal - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_CmpValue - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Footprint reference - - 0 - - - 0 - - 1 - m_staticTexCmpRef - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_CmpReference - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + m_updateModeTitle + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALL 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Change Footprints + + 0 + + + 0 - bMiddleSizer - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Change footprint" "Change footprints" "Change footprints having same value" "Update all footprints of the board" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_SELECTION_CLICKED - Options - 1 - - 0 - - - 0 - - 1 - m_Selection - 1 - - - protected - 1 - - Resizable - 1 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - OnSelectionClicked - - - - - - - - + 1 + m_exchangeModeTitle + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Update + + 0 + + + 0 + + 1 + m_updateModeVerb + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_CENTER_VERTICAL + wxALL 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Change + + 0 + + + 0 + + 1 + m_exchangeModeVerb + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + bUpperSizer + wxVERTICAL + none + + 5 + wxEXPAND + 29 - bRightSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND + m_allSizer + wxHORIZONTAL + protected + + 2 + wxALL 0 - + 1 1 1 @@ -592,7 +475,6 @@ 1 1 - 0 0 Dock 0 @@ -603,16 +485,16 @@ 0 0 - wxID_ANY - Export Footprint Association File + wxID_MATCH_FP_ALL + %s all footprints on board 0 0 - + -1,26 1 - m_buttonCmpList + m_matchAll 1 @@ -623,17 +505,17 @@ 1 - + ; forward_declare 0 wxFILTER_NONE wxDefaultValidator + 1 - RebuildCmpList @@ -651,6 +533,7 @@ + OnMatchAllClicked @@ -659,11 +542,22 @@ - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + + + + 5 + wxEXPAND + 31 + + + m_currentRefSizer + wxHORIZONTAL + protected + + 2 + wxALL 0 - + 1 1 1 @@ -680,7 +574,6 @@ 1 1 - 0 0 Dock 0 @@ -691,16 +584,16 @@ 0 0 - wxID_ANY - List Footprints + wxID_MATCH_FP_REF + %s current footprint (%s) 0 0 - + -1,26 1 - m_Browsebutton + m_matchCurrentRef 1 @@ -711,17 +604,17 @@ 1 - + ; forward_declare 0 wxFILTER_NONE wxDefaultValidator + 0 - BrowseAndSelectFootprint @@ -739,6 +632,7 @@ + OnMatchRefClicked @@ -747,11 +641,22 @@ - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + + + + 5 + wxEXPAND + 29 + + + m_specifiedRefSizer + wxHORIZONTAL + protected + + 2 + wxALL 0 - + 1 1 1 @@ -768,7 +673,6 @@ 1 1 - 0 0 Dock 0 @@ -779,16 +683,16 @@ 0 0 - wxID_ANY - View Footprints + wxID_MATCH_FP_REF + %s footprint with reference: 0 0 - + -1,26 1 - m_buttonFPViewer + m_matchSpecifiedRef 1 @@ -799,17 +703,17 @@ 1 - + ; forward_declare 0 wxFILTER_NONE wxDefaultValidator + 0 - ViewAndSelectFootprint @@ -827,6 +731,7 @@ + OnMatchRefClicked @@ -835,361 +740,1057 @@ - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Current footprint identifier - - 0 - - - 0 - - 1 - m_staticTextCurrFPID - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_CurrentFootprintFPID - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - New footprint identifier - - 0 - - - 0 - - 1 - m_staticTextNewFPID - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_NewFootprintFPID - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 3 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + 80,-1 + + + 0 + -1,24 + 1 + m_specifiedRef + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnMatchRefClicked + OnMatchRefClicked + + + + + + + + + 5 + wxEXPAND + 31 + + + m_currentValueSizer + wxHORIZONTAL + protected + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_MATCH_FP_VAL + %s footprints with matching value (%s) + + 0 + + + 0 + -1,26 + 1 + m_matchCurrentValue + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnMatchValueClicked + + + + + + + + + + + + 5 + wxEXPAND + 31 + + + m_specifiedValueSizer + wxHORIZONTAL + protected + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_MATCH_FP_VAL + %s footprints with value: + + 0 + + + 0 + -1,26 + 1 + m_matchSpecifiedValue + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnMatchValueClicked + + + + + + + + + + 3 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 160,24 + 1 + m_specifiedValue + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnMatchValueClicked + OnMatchValueClicked + + + + + + + + + 5 + wxEXPAND + 45 + + + m_specifiedIDSizer + wxVERTICAL + protected + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_MATCH_FP_ID + %s footprints with identifier: + + 0 + + + 0 + -1,-1 + 1 + m_matchSpecifiedID + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnMatchIDClicked + + + + + + + + + + 0 + wxALIGN_TOP|wxEXPAND + 0 + + + specifiedIDSizer + wxHORIZONTAL + none + + 2 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 500,24 + 1 + m_specifiedID + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnMatchIDClicked + OnMatchIDClicked + + + + + + + 0 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + m_specifiedIDBrowseButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + ViewAndSelectFootprint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + m_middleSizer + wxVERTICAL + protected + + 0 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + staticline1 + 1 + + + none + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + New footprint identifier: + + 0 + + + 0 + + 1 + newIdLabel + 1 + + + none + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxEXPAND + 0 + + + newIDSizer + wxHORIZONTAL + none + + 2 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 500,24 + 1 + m_newID + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + m_newIDBrowseButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + ViewAndSelectFootprint + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxEXPAND | wxALL + wxALL|wxEXPAND 1 1 @@ -1306,11 +1907,11 @@ 0 1 - m_staticline1 + staticline2 1 - protected + none 1 Resizable @@ -1350,16 +1951,16 @@ 5 - wxALIGN_RIGHT + wxEXPAND 0 - bSizerButts + bottomSizer wxHORIZONTAL none 5 - wxEXPAND|wxALL + wxALL 0 1 @@ -1389,8 +1990,8 @@ 0 0 - wxID_OK - Apply + wxID_ANY + Export Footprint Associations 0 @@ -1398,7 +1999,7 @@ 0 1 - m_Applybutton + m_exportButton 1 @@ -1409,7 +2010,189 @@ 1 - + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + RebuildCmpList + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 1 + + + paddingSizer + wxHORIZONTAL + none + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + padding1 + 1 + + + none + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Apply + + 0 + + + 0 + + 1 + m_applyButton + 1 + + + private + 1 + + Resizable + 1 + + + ; forward_declare 0 @@ -1447,7 +2230,7 @@ 5 - wxALL|wxEXPAND + wxALL 0 1 @@ -1477,7 +2260,7 @@ 0 0 - wxID_CANCEL + wxID_ANY Close 0 @@ -1486,18 +2269,18 @@ 0 1 - m_Quitbutton + m_closeButton 1 - protected + private 1 Resizable 1 - + ; forward_declare 0 diff --git a/pcbnew/dialogs/dialog_exchange_modules_base.h b/pcbnew/dialogs/dialog_exchange_modules_base.h index 34275d531..473a8837c 100644 --- a/pcbnew/dialogs/dialog_exchange_modules_base.h +++ b/pcbnew/dialogs/dialog_exchange_modules_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,17 +20,24 @@ class WX_HTML_REPORT_PANEL; #include #include #include -#include #include -#include +#include +#include +#include +#include +#include +#include #include -#include #include +#include #include /////////////////////////////////////////////////////////////////////////// -#define ID_SELECTION_CLICKED 1000 +#define wxID_MATCH_FP_ALL 4200 +#define wxID_MATCH_FP_REF 4201 +#define wxID_MATCH_FP_VAL 4202 +#define wxID_MATCH_FP_ID 4203 /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_EXCHANGE_MODULE_BASE @@ -38,37 +45,51 @@ class WX_HTML_REPORT_PANEL; class DIALOG_EXCHANGE_MODULE_BASE : public DIALOG_SHIM { private: + wxButton* m_applyButton; + wxButton* m_closeButton; protected: - wxStaticText* m_staticTextCmpVal; - wxTextCtrl* m_CmpValue; - wxStaticText* m_staticTexCmpRef; - wxTextCtrl* m_CmpReference; - wxRadioBox* m_Selection; - wxButton* m_buttonCmpList; - wxButton* m_Browsebutton; - wxButton* m_buttonFPViewer; - wxStaticText* m_staticTextCurrFPID; - wxTextCtrl* m_CurrentFootprintFPID; - wxStaticText* m_staticTextNewFPID; - wxTextCtrl* m_NewFootprintFPID; + wxBoxSizer* m_localizationSizer; + wxStaticText* m_updateModeTitle; + wxStaticText* m_exchangeModeTitle; + wxStaticText* m_updateModeVerb; + wxStaticText* m_exchangeModeVerb; + wxBoxSizer* m_allSizer; + wxRadioButton* m_matchAll; + wxBoxSizer* m_currentRefSizer; + wxRadioButton* m_matchCurrentRef; + wxBoxSizer* m_specifiedRefSizer; + wxRadioButton* m_matchSpecifiedRef; + wxTextCtrl* m_specifiedRef; + wxBoxSizer* m_currentValueSizer; + wxRadioButton* m_matchCurrentValue; + wxBoxSizer* m_specifiedValueSizer; + wxRadioButton* m_matchSpecifiedValue; + wxTextCtrl* m_specifiedValue; + wxBoxSizer* m_specifiedIDSizer; + wxRadioButton* m_matchSpecifiedID; + wxTextCtrl* m_specifiedID; + wxBitmapButton* m_specifiedIDBrowseButton; + wxBoxSizer* m_middleSizer; + wxTextCtrl* m_newID; + wxBitmapButton* m_newIDBrowseButton; WX_HTML_REPORT_PANEL* m_MessageWindow; - wxStaticLine* m_staticline1; - wxButton* m_Applybutton; - wxButton* m_Quitbutton; + wxButton* m_exportButton; // Virtual event handlers, overide them in your derived class - virtual void OnSelectionClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void RebuildCmpList( wxCommandEvent& event ) { event.Skip(); } - virtual void BrowseAndSelectFootprint( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMatchAllClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMatchRefClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMatchValueClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMatchIDClicked( wxCommandEvent& event ) { event.Skip(); } virtual void ViewAndSelectFootprint( wxCommandEvent& event ) { event.Skip(); } + virtual void RebuildCmpList( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Change Footprint"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("%s"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EXCHANGE_MODULE_BASE(); }; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 3177df8c5..c0220364e 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -852,13 +852,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) Change_Side_Module( (MODULE*) GetCurItem(), &dc ); break; + case ID_POPUP_PCB_UPDATE_FOOTPRINTS: + if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T ) + break; + + InstallExchangeModuleFrame( (MODULE*) GetCurItem(), true ); + m_canvas->MoveCursorToCrossHair(); + break; + case ID_POPUP_PCB_EXCHANGE_FOOTPRINTS: - if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T ) + if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T ) break; - InstallExchangeModuleFrame( (MODULE*) GetCurItem() ); - // Warning: the current item can be deleted by exchange module - SetCurItem( NULL ); + InstallExchangeModuleFrame( (MODULE*) GetCurItem(), false ); m_canvas->MoveCursorToCrossHair(); break; @@ -1236,6 +1242,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) Clean_Pcb(); break; + case ID_MENU_PCB_UPDATE_FOOTPRINTS: + InstallExchangeModuleFrame( (MODULE*) nullptr, true ); + break; + + case ID_MENU_PCB_EXCHANGE_FOOTPRINTS: + InstallExchangeModuleFrame( (MODULE*) nullptr, false ); + break; + case ID_MENU_PCB_SWAP_LAYERS: Swap_Layers( event ); break; diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 8f0dfbb73..db432e66e 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -87,11 +87,14 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) editor->Raise(); // Iconize( false ); } + if( retvalue == DIALOG_MODULE_BOARD_EDITOR::PRM_EDITOR_WANT_UPDATE_FP ) + { + InstallExchangeModuleFrame( Module, true ); + } + if( retvalue == DIALOG_MODULE_BOARD_EDITOR::PRM_EDITOR_WANT_EXCHANGE_FP ) { - InstallExchangeModuleFrame( Module ); - // Warning: the current item can be deleted by exchange module - SetCurItem( NULL ); + InstallExchangeModuleFrame( Module, false ); } } diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index a91249734..68ab97d11 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -488,6 +488,16 @@ void prepareEditMenu( wxMenu* aParentMenu, bool aUseGal ) _( "Set text size and width of footprint fields" ), KiBitmap( reset_text_xpm ) ); + AddMenuItem( aParentMenu, ID_MENU_PCB_UPDATE_FOOTPRINTS, + _( "Update Footprints from Library" ), + _( "Update footprints to include any changes from the library" ), + KiBitmap( reload_xpm ) ); + + AddMenuItem( aParentMenu, ID_MENU_PCB_EXCHANGE_FOOTPRINTS, + _( "Change Footprints" ), + _( "Assign different footprints from the library" ), + KiBitmap( exchange_xpm ) ); + AddMenuItem( aParentMenu, ID_MENU_PCB_SWAP_LAYERS, _( "&Swap Layers" ), _( "Swap tracks on copper layers or drawings on other layers" ), diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index d39a67cd4..cbc47ff74 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -850,6 +850,9 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_CREATE_ARRAY, msg, KiBitmap( array_xpm ) ); + AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_UPDATE_FOOTPRINTS, + _( "Update Footprint" ), KiBitmap( reload_xpm ) ); + AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EXCHANGE_FOOTPRINTS, _( "Change Footprint" ), KiBitmap( exchange_xpm ) ); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 36c76a66f..dfae30fc6 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -173,6 +173,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_PCB_GLOBAL_DELETE, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_PCB_CLEAN, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_MENU_PCB_UPDATE_FOOTPRINTS, PCB_EDIT_FRAME::Process_Special_Functions ) + EVT_MENU( ID_MENU_PCB_EXCHANGE_FOOTPRINTS, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_PCB_RESET_TEXTMODULE_FIELDS_SIZES, PCB_EDIT_FRAME::OnResetModuleTextSizes ) @@ -1269,9 +1271,9 @@ void PCB_EDIT_FRAME::PythonPluginsReload() } -int PCB_EDIT_FRAME::InstallExchangeModuleFrame( MODULE* Module ) +int PCB_EDIT_FRAME::InstallExchangeModuleFrame( MODULE* Module, bool updateMode ) { - DIALOG_EXCHANGE_MODULE dialog( this, Module ); + DIALOG_EXCHANGE_MODULE dialog( this, Module, updateMode ); return dialog.ShowQuasiModal(); } diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 41184794e..02d35e49e 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -67,6 +67,7 @@ enum pcbnew_ids ID_POPUP_PCB_DELETE_MODULE, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE, + ID_POPUP_PCB_UPDATE_FOOTPRINTS, ID_POPUP_PCB_EXCHANGE_FOOTPRINTS, ID_POPUP_PCB_EDIT_PAD, @@ -266,6 +267,8 @@ enum pcbnew_ids ID_MENU_LIST_NETS, ID_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, ID_MENU_PCB_CLEAN, + ID_MENU_PCB_UPDATE_FOOTPRINTS, + ID_MENU_PCB_EXCHANGE_FOOTPRINTS, ID_MENU_PCB_SWAP_LAYERS, ID_MENU_PCB_RESET_TEXTMODULE_FIELDS_SIZES, diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 978eaa512..e3564f9b6 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -146,9 +146,14 @@ TOOL_ACTION PCB_ACTIONS::removeAlt( "pcbnew.InteractiveEdit.removeAlt", _( "Delete (Alternative)" ), _( "Deletes selected item(s)" ), delete_xpm, AF_NONE, (void*) REMOVE_FLAGS::ALT ); +TOOL_ACTION PCB_ACTIONS::updateFootprints( "pcbnew.InteractiveEdit.updateFootprints", + AS_GLOBAL, 0, + _( "Update Footprint" ), _( "Update the footprint from the library" ), + reload_xpm ); + TOOL_ACTION PCB_ACTIONS::exchangeFootprints( "pcbnew.InteractiveEdit.ExchangeFootprints", AS_GLOBAL, 0, - _( "Exchange Footprint" ), _( "Change the footprint used for modules" ), + _( "Change Footprint" ), _( "Assign a different footprint from the library" ), exchange_xpm ); TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", @@ -313,10 +318,9 @@ bool EDIT_TOOL::Init() menu.AddItem( PCB_ACTIONS::explodePadToShapes, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty ); // Footprint actions - menu.AddItem( PCB_ACTIONS::editFootprintInFpEditor, - singleModuleCondition ); - menu.AddItem( PCB_ACTIONS::exchangeFootprints, - singleModuleCondition ); + menu.AddItem( PCB_ACTIONS::editFootprintInFpEditor, singleModuleCondition ); + menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition ); + menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition ); return true; } @@ -1099,13 +1103,9 @@ int EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) { const auto& selection = m_selectionTool->RequestSelection(0, FootprintFilter); - if( selection.Empty() ) - return 0; - - MODULE* mod = selection.FirstOfKind (); + bool updateMode = aEvent.IsAction( &PCB_ACTIONS::updateFootprints ); - if( !mod ) - return 0; + MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind () ); frame()->SetCurItem( mod ); @@ -1115,14 +1115,10 @@ int EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) // invoke the exchange dialog process { - DIALOG_EXCHANGE_MODULE dialog( frame(), mod ); + DIALOG_EXCHANGE_MODULE dialog( frame(), mod, updateMode ); dialog.ShowQuasiModal(); } - // The current item can be deleted by exchange module, and the - // selection is emptied, so remove current item from frame info area - frame()->SetCurItem( nullptr ); - return 0; } @@ -1239,6 +1235,7 @@ void EDIT_TOOL::setTransitions() Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() ); Go( &EDIT_TOOL::editFootprintInFpEditor, PCB_ACTIONS::editFootprintInFpEditor.MakeEvent() ); + Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprints.MakeEvent() ); Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::exchangeFootprints.MakeEvent() ); Go( &EDIT_TOOL::MeasureTool, PCB_ACTIONS::measureTool.MakeEvent() ); Go( &EDIT_TOOL::copyToClipboard, PCB_ACTIONS::copyToClipboard.MakeEvent() ); diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 3a4cd7a20..ee3a15e85 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -128,8 +128,8 @@ public: /** * Function ExchangeFootprints() * - * Invoke the dialog used to change the footprints used for modules - * and update module footprints based on result + * Invoke the dialog used to update or exchange the footprints used for + * modules. The mode depends on the PCB_ACTIONS held by the TOOL_EVENT. */ int ExchangeFootprints( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 8926b8232..ce1601632 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -116,6 +116,9 @@ public: /// Activation of the duplication tool with incrementing (e.g. pad number) static TOOL_ACTION duplicateIncrement; + /// Update footprints to reflect any changes in the library + static TOOL_ACTION updateFootprints; + /// Exchange footprints of modules static TOOL_ACTION exchangeFootprints; diff --git a/pcbnew/wxPcbStruct.h b/pcbnew/wxPcbStruct.h index f34f7ed01..b594f0686 100644 --- a/pcbnew/wxPcbStruct.h +++ b/pcbnew/wxPcbStruct.h @@ -1134,7 +1134,7 @@ public: */ void Change_Side_Module( MODULE* Module, wxDC* DC ); - int InstallExchangeModuleFrame( MODULE* ExchangeModuleModule ); + int InstallExchangeModuleFrame( MODULE* ExchangeModuleModule, bool updateMode ); /** * Function Exchange_Module --------------2.14.3 (Apple Git-98)--