From b791fff963e47b898b4ea797186aa0f2a19cdde4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 3 Sep 2022 10:41:14 +0200 Subject: [PATCH] DIALOG_UNUSED_PAD_LAYERS: minor enhancement: pads and vias can be handled all at once --- pcbnew/dialogs/dialog_unused_pad_layers.cpp | 27 +-- pcbnew/dialogs/dialog_unused_pad_layers.h | 12 +- .../dialogs/dialog_unused_pad_layers_base.cpp | 24 ++- .../dialogs/dialog_unused_pad_layers_base.fbp | 203 ++++++++++++------ .../dialogs/dialog_unused_pad_layers_base.h | 13 +- 5 files changed, 189 insertions(+), 90 deletions(-) diff --git a/pcbnew/dialogs/dialog_unused_pad_layers.cpp b/pcbnew/dialogs/dialog_unused_pad_layers.cpp index df1acde3a3..feccf31824 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers.cpp +++ b/pcbnew/dialogs/dialog_unused_pad_layers.cpp @@ -32,12 +32,6 @@ #include #include -enum SCOPE : int -{ - SCOPE_VIAS = 0, - SCOPE_PADS = 1 -}; - enum PAD_ACTION : int { @@ -63,12 +57,14 @@ DIALOG_UNUSED_PAD_LAYERS::DIALOG_UNUSED_PAD_LAYERS( PCB_BASE_FRAME* aParent, SetupStandardButtons(); + updateImage(); + // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); } -void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent ) +void DIALOG_UNUSED_PAD_LAYERS::updateImage() { if( m_rbAction->GetSelection() == PAD_ACTION_RESET ) m_image->SetBitmap( KiBitmap( BITMAPS::pads_reset_unused ) ); @@ -79,6 +75,12 @@ void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent ) } +void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent ) +{ + updateImage(); +} + + bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow() { if( m_cbSelectedOnly->IsChecked() ) @@ -87,14 +89,14 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow() { m_commit.Modify( item ); - if( item->Type() == PCB_VIA_T && m_rbScope->GetSelection() == SCOPE_VIAS ) + if( item->Type() == PCB_VIA_T && m_cbVias->IsChecked() ) { PCB_VIA* via = static_cast( item ); via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE ); via->SetKeepTopBottom( m_cbPreservePads->IsChecked() ); } - if( item->Type() == PCB_FOOTPRINT_T && m_rbScope->GetSelection() == SCOPE_PADS ) + if( item->Type() == PCB_FOOTPRINT_T && m_cbPads->IsChecked() ) { FOOTPRINT* footprint = static_cast( item ); @@ -105,7 +107,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow() } } - if( item->Type() == PCB_PAD_T && m_rbScope->GetSelection() == SCOPE_PADS ) + if( item->Type() == PCB_PAD_T && m_cbPads->IsChecked() ) { PAD* pad = static_cast( item ); @@ -116,7 +118,7 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow() } else { - if( m_rbScope->GetSelection() == SCOPE_PADS ) + if( m_cbPads->IsChecked() ) { for( FOOTPRINT* footprint : m_frame->GetBoard()->Footprints() ) { @@ -129,7 +131,8 @@ bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow() } } } - else + + if( m_cbVias->IsChecked() ) { for( PCB_TRACK* item : m_frame->GetBoard()->Tracks() ) { diff --git a/pcbnew/dialogs/dialog_unused_pad_layers.h b/pcbnew/dialogs/dialog_unused_pad_layers.h index 96d2b0e6f6..4c5e5d45eb 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers.h +++ b/pcbnew/dialogs/dialog_unused_pad_layers.h @@ -41,13 +41,15 @@ public: private: bool TransferDataFromWindow() override; - bool AcceptOptions(); + bool AcceptOptions(); + void updateImage(); - void syncImages( wxCommandEvent& aEvent ) override; - PCB_BASE_FRAME* m_frame; - const PCB_SELECTION& m_items; // List of items to be modified. - COMMIT& m_commit; // An undo record to add any changes to. + void syncImages( wxCommandEvent& aEvent ) override; + + PCB_BASE_FRAME* m_frame; + const PCB_SELECTION& m_items; // List of items to be modified. + COMMIT& m_commit; // An undo record to add any changes to. }; #endif // __dialog_remove_unused_pads__ diff --git a/pcbnew/dialogs/dialog_unused_pad_layers_base.cpp b/pcbnew/dialogs/dialog_unused_pad_layers_base.cpp index 3e96cc8ee6..c0a62f5066 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers_base.cpp +++ b/pcbnew/dialogs/dialog_unused_pad_layers_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -23,17 +23,23 @@ DIALOG_UNUSED_PAD_LAYERS_BASE::DIALOG_UNUSED_PAD_LAYERS_BASE( wxWindow* parent, fgSizerProps->SetFlexibleDirection( wxVERTICAL ); fgSizerProps->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - wxString m_rbScopeChoices[] = { _("&Vias"), _("&Pads") }; - int m_rbScopeNChoices = sizeof( m_rbScopeChoices ) / sizeof( wxString ); - m_rbScope = new wxRadioBox( this, wxID_ANY, _("Scope"), wxDefaultPosition, wxDefaultSize, m_rbScopeNChoices, m_rbScopeChoices, 1, wxRA_SPECIFY_COLS ); - m_rbScope->SetSelection( 0 ); - fgSizerProps->Add( m_rbScope, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + wxStaticBoxSizer* sbSizerScope; + sbSizerScope = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scope") ), wxVERTICAL ); + + m_cbVias = new wxCheckBox( sbSizerScope->GetStaticBox(), wxID_ANY, _("Vias"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerScope->Add( m_cbVias, 0, wxALL, 5 ); + + m_cbPads = new wxCheckBox( sbSizerScope->GetStaticBox(), wxID_ANY, _("Pads"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerScope->Add( m_cbPads, 0, wxALL, 5 ); + + + fgSizerProps->Add( sbSizerScope, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); wxString m_rbActionChoices[] = { _("&Remove unused layers"), _("Res&tore unused layers") }; int m_rbActionNChoices = sizeof( m_rbActionChoices ) / sizeof( wxString ); m_rbAction = new wxRadioBox( this, wxID_ANY, _("Action"), wxDefaultPosition, wxDefaultSize, m_rbActionNChoices, m_rbActionChoices, 1, wxRA_SPECIFY_COLS ); m_rbAction->SetSelection( 1 ); - fgSizerProps->Add( m_rbAction, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + fgSizerProps->Add( m_rbAction, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); m_cbSelectedOnly = new wxCheckBox( this, wxID_ANY, _("&Selection only"), wxDefaultPosition, wxDefaultSize, 0 ); fgSizerProps->Add( m_cbSelectedOnly, 0, wxEXPAND|wxLEFT, 10 ); @@ -82,6 +88,8 @@ DIALOG_UNUSED_PAD_LAYERS_BASE::DIALOG_UNUSED_PAD_LAYERS_BASE( wxWindow* parent, this->Centre( wxBOTH ); // Connect Events + m_cbVias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); + m_cbPads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); m_rbAction->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); m_cbPreservePads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); } @@ -89,6 +97,8 @@ DIALOG_UNUSED_PAD_LAYERS_BASE::DIALOG_UNUSED_PAD_LAYERS_BASE( wxWindow* parent, DIALOG_UNUSED_PAD_LAYERS_BASE::~DIALOG_UNUSED_PAD_LAYERS_BASE() { // Disconnect Events + m_cbVias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); + m_cbPads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); m_rbAction->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); m_cbPreservePads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UNUSED_PAD_LAYERS_BASE::syncImages ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_unused_pad_layers_base.fbp b/pcbnew/dialogs/dialog_unused_pad_layers_base.fbp index 575684b5c2..256ef0d654 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers_base.fbp +++ b/pcbnew/dialogs/dialog_unused_pad_layers_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_unused_pad_layers_base 1000 none + 1 DIALOG_UNUSED_PAD_LAYERS_BASE @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -50,6 +52,7 @@ DIALOG_SHIM; dialog_shim.h Remove Unused Pads + 0 @@ -83,75 +86,153 @@ none 0 0 - + 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + wxEXPAND|wxALIGN_CENTER_VERTICAL 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "&Vias" "&Pads" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxID_ANY Scope - 1 - - 0 - - - 0 - 1 - m_rbScope - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - + sbSizerScope + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Vias + + 0 + + + 0 + + 1 + m_cbVias + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + syncImages + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pads + + 0 + + + 0 + + 1 + m_cbPads + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + syncImages + + 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL 1 1 diff --git a/pcbnew/dialogs/dialog_unused_pad_layers_base.h b/pcbnew/dialogs/dialog_unused_pad_layers_base.h index 0b948edd2d..105b9aab66 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers_base.h +++ b/pcbnew/dialogs/dialog_unused_pad_layers_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -12,13 +12,14 @@ #include #include "dialog_shim.h" #include -#include +#include #include #include #include #include -#include #include +#include +#include #include #include #include @@ -39,7 +40,8 @@ class DIALOG_UNUSED_PAD_LAYERS_BASE : public DIALOG_SHIM protected: wxBoxSizer* m_MainSizer; - wxRadioBox* m_rbScope; + wxCheckBox* m_cbVias; + wxCheckBox* m_cbPads; wxRadioBox* m_rbAction; wxCheckBox* m_cbSelectedOnly; wxCheckBox* m_cbPreservePads; @@ -49,13 +51,14 @@ class DIALOG_UNUSED_PAD_LAYERS_BASE : public DIALOG_SHIM wxButton* m_StdButtonsOK; wxButton* m_StdButtonsCancel; - // Virtual event handlers, overide them in your derived class + // Virtual event handlers, override them in your derived class virtual void syncImages( wxCommandEvent& event ) { event.Skip(); } public: DIALOG_UNUSED_PAD_LAYERS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Remove Unused Pads"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_UNUSED_PAD_LAYERS_BASE(); };