PCB array tool: make it easier to skip renumbering entirely

This was already possible by setting a 0-sized step, but that's
a bit clunky - provide an obvious way to do it via a
"do/do not renumber at all" checkbox.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/20470
This commit is contained in:
John Beard 2025-04-23 00:00:00 +08:00
parent 1b1623885c
commit d2307fdcaa
4 changed files with 95 additions and 11 deletions

View File

@ -56,6 +56,8 @@ struct CREATE_ARRAY_DIALOG_ENTRIES
long m_GridStagger = 1; long m_GridStagger = 1;
bool m_GridStaggerRows = true; bool m_GridStaggerRows = true;
bool m_GridPositionCentreOnItems = true; bool m_GridPositionCentreOnItems = true;
bool m_GridRenumberPads = true;
long m_GridNumberingAxis = 0; // h then v long m_GridNumberingAxis = 0; // h then v
bool m_GridNumReverseAlt = false; bool m_GridNumReverseAlt = false;
long m_GridNumStartSet = 1; // use specified start long m_GridNumStartSet = 1; // use specified start
@ -174,6 +176,7 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParen
m_cfg_persister.Add( *m_rbCentreOnSource, s_arrayOptions.m_GridPositionCentreOnItems ); m_cfg_persister.Add( *m_rbCentreOnSource, s_arrayOptions.m_GridPositionCentreOnItems );
m_cfg_persister.Add( *m_cbRenumberPads, s_arrayOptions.m_GridRenumberPads );
m_cfg_persister.Add( *m_radioBoxGridNumberingAxis, s_arrayOptions.m_GridNumberingAxis ); m_cfg_persister.Add( *m_radioBoxGridNumberingAxis, s_arrayOptions.m_GridNumberingAxis );
m_cfg_persister.Add( *m_checkBoxGridReverseNumbering, s_arrayOptions.m_GridNumReverseAlt ); m_cfg_persister.Add( *m_checkBoxGridReverseNumbering, s_arrayOptions.m_GridNumReverseAlt );
@ -432,7 +435,7 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
newGrid->m_horizontalThenVertical = m_radioBoxGridNumberingAxis->GetSelection() == 0; newGrid->m_horizontalThenVertical = m_radioBoxGridNumberingAxis->GetSelection() == 0;
newGrid->m_reverseNumberingAlternate = m_checkBoxGridReverseNumbering->GetValue(); newGrid->m_reverseNumberingAlternate = m_checkBoxGridReverseNumbering->GetValue();
newGrid->SetShouldNumber( m_isFootprintEditor ); newGrid->SetShouldNumber( m_isFootprintEditor && m_cbRenumberPads->GetValue() );
if( m_isFootprintEditor ) if( m_isFootprintEditor )
{ {
@ -563,9 +566,16 @@ void DIALOG_CREATE_ARRAY::setControlEnablement()
m_gridPadNumberingPanel->Show( true ); m_gridPadNumberingPanel->Show( true );
m_circularPadNumberingPanel->Show( true ); m_circularPadNumberingPanel->Show( true );
// In no pad re-numbering, everything is disabled
bool renumber_pads = m_cbRenumberPads->GetValue();
m_radioBoxGridNumberingAxis->Enable( renumber_pads );
m_checkBoxGridReverseNumbering->Enable( renumber_pads );
m_rbGridStartNumberingOpt->Enable( renumber_pads );
// If we set the start number, we can set the other options, // If we set the start number, we can set the other options,
// otherwise it's a hardcoded linear array // otherwise it's a hardcoded linear array
const bool use_set_start_grid = m_rbGridStartNumberingOpt->GetSelection() == 1; const bool use_set_start_grid = renumber_pads && m_rbGridStartNumberingOpt->GetSelection() == 1;
m_radioBoxGridNumberingScheme->Enable( use_set_start_grid ); m_radioBoxGridNumberingScheme->Enable( use_set_start_grid );
m_labelPriAxisNumbering->Enable( use_set_start_grid ); m_labelPriAxisNumbering->Enable( use_set_start_grid );
@ -580,12 +590,14 @@ void DIALOG_CREATE_ARRAY::setControlEnablement()
// We can only set an offset if we're setting the start number // We can only set an offset if we're setting the start number
m_labelGridNumberingOffset->Enable( use_set_start_grid ); m_labelGridNumberingOffset->Enable( use_set_start_grid );
m_labelGridNumberingStep->Enable( use_set_start_grid );
m_entryGridPriNumberingOffset->Enable( use_set_start_grid ); m_entryGridPriNumberingOffset->Enable( use_set_start_grid );
m_entryGridPriNumberingStep->Enable( use_set_start_grid );
m_entryGridSecNumberingOffset->Enable( use_set_start_grid && num2d ); m_entryGridSecNumberingOffset->Enable( use_set_start_grid && num2d );
m_entryGridSecNumberingStep->Enable( use_set_start_grid && num2d ); m_entryGridSecNumberingStep->Enable( use_set_start_grid && num2d );
// disable the circular number offset in the same way // disable the circular number offset in the same way
const bool use_set_start_circ = m_rbCircStartNumberingOpt->GetSelection() == 1; const bool use_set_start_circ = renumber_pads && m_rbCircStartNumberingOpt->GetSelection() == 1;
m_entryCircNumberingStart->Enable( use_set_start_circ ); m_entryCircNumberingStart->Enable( use_set_start_circ );
} }
else else

View File

@ -194,6 +194,9 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID
m_gridPadNumberingSizer = new wxBoxSizer( wxVERTICAL ); m_gridPadNumberingSizer = new wxBoxSizer( wxVERTICAL );
m_cbRenumberPads = new wxCheckBox( m_gridPadNumberingPanel, wxID_ANY, _("Renumber pads"), wxDefaultPosition, wxDefaultSize, 0 );
m_gridPadNumberingSizer->Add( m_cbRenumberPads, 0, wxALL, 5 );
wxString m_radioBoxGridNumberingAxisChoices[] = { _("Horizontal, then vertical"), _("Vertical, then horizontal") }; wxString m_radioBoxGridNumberingAxisChoices[] = { _("Horizontal, then vertical"), _("Vertical, then horizontal") };
int m_radioBoxGridNumberingAxisNChoices = sizeof( m_radioBoxGridNumberingAxisChoices ) / sizeof( wxString ); int m_radioBoxGridNumberingAxisNChoices = sizeof( m_radioBoxGridNumberingAxisChoices ) / sizeof( wxString );
m_radioBoxGridNumberingAxis = new wxRadioBox( m_gridPadNumberingPanel, wxID_ANY, _("Numbering Direction"), wxDefaultPosition, wxDefaultSize, m_radioBoxGridNumberingAxisNChoices, m_radioBoxGridNumberingAxisChoices, 1, wxRA_SPECIFY_COLS ); m_radioBoxGridNumberingAxis = new wxRadioBox( m_gridPadNumberingPanel, wxID_ANY, _("Numbering Direction"), wxDefaultPosition, wxDefaultSize, m_radioBoxGridNumberingAxisNChoices, m_radioBoxGridNumberingAxisChoices, 1, wxRA_SPECIFY_COLS );
@ -537,6 +540,7 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID
m_entryOffsetX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryOffsetX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_entryOffsetY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryOffsetY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_entryStagger->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryStagger->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_cbRenumberPads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_rbGridStartNumberingOpt->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_rbGridStartNumberingOpt->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_radioBoxGridNumberingScheme->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_radioBoxGridNumberingScheme->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_choicePriAxisNumbering->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnAxisNumberingChange ), NULL, this ); m_choicePriAxisNumbering->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnAxisNumberingChange ), NULL, this );
@ -565,6 +569,7 @@ DIALOG_CREATE_ARRAY_BASE::~DIALOG_CREATE_ARRAY_BASE()
m_entryOffsetX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryOffsetX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_entryOffsetY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryOffsetY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_entryStagger->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_entryStagger->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_cbRenumberPads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_rbGridStartNumberingOpt->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_rbGridStartNumberingOpt->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_radioBoxGridNumberingScheme->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this ); m_radioBoxGridNumberingScheme->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
m_choicePriAxisNumbering->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnAxisNumberingChange ), NULL, this ); m_choicePriAxisNumbering->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnAxisNumberingChange ), NULL, this );

View File

@ -136,7 +136,7 @@
<property name="bitmap">Load From File; </property> <property name="bitmap">Load From File; </property>
<property name="label">Grid Array</property> <property name="label">Grid Array</property>
<property name="select">1</property> <property name="select">1</property>
<object class="wxPanel" expanded="false"> <object class="wxPanel" expanded="true">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
@ -188,7 +188,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property> <property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="false"> <object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerGridArray</property> <property name="name">bSizerGridArray</property>
<property name="orient">wxHORIZONTAL</property> <property name="orient">wxHORIZONTAL</property>
@ -1741,11 +1741,11 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="false"> <object class="sizeritem" expanded="true">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxPanel" expanded="false"> <object class="wxPanel" expanded="true">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
@ -1797,20 +1797,86 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property> <property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="false"> <object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizer15</property> <property name="name">bSizer15</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="false"> <object class="sizeritem" expanded="true">
<property name="border">10</property> <property name="border">10</property>
<property name="flag">wxEXPAND|wxLEFT</property> <property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="false"> <object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_gridPadNumberingSizer</property> <property name="name">m_gridPadNumberingSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</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="drag_accept_files">0</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">Renumber 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_cbRenumberPads</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">OnParameterChanged</event>
</object>
</object>
<object class="sizeritem" expanded="false"> <object class="sizeritem" expanded="false">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>

View File

@ -23,8 +23,8 @@ class TEXT_CTRL_EVAL;
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/radiobut.h> #include <wx/radiobut.h>
#include <wx/radiobox.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/radiobox.h>
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>
@ -72,6 +72,7 @@ class DIALOG_CREATE_ARRAY_BASE : public DIALOG_SHIM
wxRadioButton* m_rbCentreOnSource; wxRadioButton* m_rbCentreOnSource;
wxPanel* m_gridPadNumberingPanel; wxPanel* m_gridPadNumberingPanel;
wxBoxSizer* m_gridPadNumberingSizer; wxBoxSizer* m_gridPadNumberingSizer;
wxCheckBox* m_cbRenumberPads;
wxRadioBox* m_radioBoxGridNumberingAxis; wxRadioBox* m_radioBoxGridNumberingAxis;
wxCheckBox* m_checkBoxGridReverseNumbering; wxCheckBox* m_checkBoxGridReverseNumbering;
wxRadioBox* m_rbGridStartNumberingOpt; wxRadioBox* m_rbGridStartNumberingOpt;