DIALOG_UNUSED_PAD_LAYERS: minor enhancement: pads and vias can be handled all at once

This commit is contained in:
jean-pierre charras 2022-09-03 10:41:14 +02:00
parent 112f089485
commit b791fff963
5 changed files with 189 additions and 90 deletions

View File

@ -32,12 +32,6 @@
#include <pcb_edit_frame.h>
#include <tools/pcb_selection_tool.h>
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<PCB_VIA*>( 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<FOOTPRINT*>( 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<PAD*>( 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() )
{

View File

@ -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__

View File

@ -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 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">dialog_unused_pad_layers_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">DIALOG_UNUSED_PAD_LAYERS_BASE</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -50,6 +52,7 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Remove Unused Pads</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -83,75 +86,153 @@
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;&amp;Vias&quot; &quot;&amp;Pads&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Scope</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_rbScope</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="name">sbSizerScope</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Vias</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbVias</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">syncImages</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Pads</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbPads</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">syncImages</event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>

View File

@ -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 <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
@ -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();
};