Skip to content

Commit d2307fd

Browse files
committed
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
1 parent 1b16238 commit d2307fd

File tree

4 files changed

+95
-11
lines changed

4 files changed

+95
-11
lines changed

pcbnew/dialogs/dialog_create_array.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct CREATE_ARRAY_DIALOG_ENTRIES
5656
long m_GridStagger = 1;
5757
bool m_GridStaggerRows = true;
5858
bool m_GridPositionCentreOnItems = true;
59+
60+
bool m_GridRenumberPads = true;
5961
long m_GridNumberingAxis = 0; // h then v
6062
bool m_GridNumReverseAlt = false;
6163
long m_GridNumStartSet = 1; // use specified start
@@ -174,6 +176,7 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParen
174176

175177
m_cfg_persister.Add( *m_rbCentreOnSource, s_arrayOptions.m_GridPositionCentreOnItems );
176178

179+
m_cfg_persister.Add( *m_cbRenumberPads, s_arrayOptions.m_GridRenumberPads );
177180
m_cfg_persister.Add( *m_radioBoxGridNumberingAxis, s_arrayOptions.m_GridNumberingAxis );
178181
m_cfg_persister.Add( *m_checkBoxGridReverseNumbering, s_arrayOptions.m_GridNumReverseAlt );
179182

@@ -432,7 +435,7 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow()
432435
newGrid->m_horizontalThenVertical = m_radioBoxGridNumberingAxis->GetSelection() == 0;
433436
newGrid->m_reverseNumberingAlternate = m_checkBoxGridReverseNumbering->GetValue();
434437

435-
newGrid->SetShouldNumber( m_isFootprintEditor );
438+
newGrid->SetShouldNumber( m_isFootprintEditor && m_cbRenumberPads->GetValue() );
436439

437440
if( m_isFootprintEditor )
438441
{
@@ -563,9 +566,16 @@ void DIALOG_CREATE_ARRAY::setControlEnablement()
563566
m_gridPadNumberingPanel->Show( true );
564567
m_circularPadNumberingPanel->Show( true );
565568

569+
// In no pad re-numbering, everything is disabled
570+
bool renumber_pads = m_cbRenumberPads->GetValue();
571+
572+
m_radioBoxGridNumberingAxis->Enable( renumber_pads );
573+
m_checkBoxGridReverseNumbering->Enable( renumber_pads );
574+
m_rbGridStartNumberingOpt->Enable( renumber_pads );
575+
566576
// If we set the start number, we can set the other options,
567577
// otherwise it's a hardcoded linear array
568-
const bool use_set_start_grid = m_rbGridStartNumberingOpt->GetSelection() == 1;
578+
const bool use_set_start_grid = renumber_pads && m_rbGridStartNumberingOpt->GetSelection() == 1;
569579

570580
m_radioBoxGridNumberingScheme->Enable( use_set_start_grid );
571581
m_labelPriAxisNumbering->Enable( use_set_start_grid );
@@ -580,12 +590,14 @@ void DIALOG_CREATE_ARRAY::setControlEnablement()
580590

581591
// We can only set an offset if we're setting the start number
582592
m_labelGridNumberingOffset->Enable( use_set_start_grid );
593+
m_labelGridNumberingStep->Enable( use_set_start_grid );
583594
m_entryGridPriNumberingOffset->Enable( use_set_start_grid );
595+
m_entryGridPriNumberingStep->Enable( use_set_start_grid );
584596
m_entryGridSecNumberingOffset->Enable( use_set_start_grid && num2d );
585597
m_entryGridSecNumberingStep->Enable( use_set_start_grid && num2d );
586598

587599
// disable the circular number offset in the same way
588-
const bool use_set_start_circ = m_rbCircStartNumberingOpt->GetSelection() == 1;
600+
const bool use_set_start_circ = renumber_pads && m_rbCircStartNumberingOpt->GetSelection() == 1;
589601
m_entryCircNumberingStart->Enable( use_set_start_circ );
590602
}
591603
else

pcbnew/dialogs/dialog_create_array_base.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID
194194

195195
m_gridPadNumberingSizer = new wxBoxSizer( wxVERTICAL );
196196

197+
m_cbRenumberPads = new wxCheckBox( m_gridPadNumberingPanel, wxID_ANY, _("Renumber pads"), wxDefaultPosition, wxDefaultSize, 0 );
198+
m_gridPadNumberingSizer->Add( m_cbRenumberPads, 0, wxALL, 5 );
199+
197200
wxString m_radioBoxGridNumberingAxisChoices[] = { _("Horizontal, then vertical"), _("Vertical, then horizontal") };
198201
int m_radioBoxGridNumberingAxisNChoices = sizeof( m_radioBoxGridNumberingAxisChoices ) / sizeof( wxString );
199202
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
537540
m_entryOffsetX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
538541
m_entryOffsetY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
539542
m_entryStagger->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
543+
m_cbRenumberPads->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
540544
m_rbGridStartNumberingOpt->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
541545
m_radioBoxGridNumberingScheme->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
542546
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()
565569
m_entryOffsetX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
566570
m_entryOffsetY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
567571
m_entryStagger->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
572+
m_cbRenumberPads->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
568573
m_rbGridStartNumberingOpt->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
569574
m_radioBoxGridNumberingScheme->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnParameterChanged ), NULL, this );
570575
m_choicePriAxisNumbering->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CREATE_ARRAY_BASE::OnAxisNumberingChange ), NULL, this );

pcbnew/dialogs/dialog_create_array_base.fbp

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<property name="bitmap">Load From File; </property>
137137
<property name="label">Grid Array</property>
138138
<property name="select">1</property>
139-
<object class="wxPanel" expanded="false">
139+
<object class="wxPanel" expanded="true">
140140
<property name="BottomDockable">1</property>
141141
<property name="LeftDockable">1</property>
142142
<property name="RightDockable">1</property>
@@ -188,7 +188,7 @@
188188
<property name="window_extra_style"></property>
189189
<property name="window_name"></property>
190190
<property name="window_style">wxTAB_TRAVERSAL</property>
191-
<object class="wxBoxSizer" expanded="false">
191+
<object class="wxBoxSizer" expanded="true">
192192
<property name="minimum_size"></property>
193193
<property name="name">bSizerGridArray</property>
194194
<property name="orient">wxHORIZONTAL</property>
@@ -1741,11 +1741,11 @@
17411741
</object>
17421742
</object>
17431743
</object>
1744-
<object class="sizeritem" expanded="false">
1744+
<object class="sizeritem" expanded="true">
17451745
<property name="border">5</property>
17461746
<property name="flag">wxEXPAND</property>
17471747
<property name="proportion">1</property>
1748-
<object class="wxPanel" expanded="false">
1748+
<object class="wxPanel" expanded="true">
17491749
<property name="BottomDockable">1</property>
17501750
<property name="LeftDockable">1</property>
17511751
<property name="RightDockable">1</property>
@@ -1797,20 +1797,86 @@
17971797
<property name="window_extra_style"></property>
17981798
<property name="window_name"></property>
17991799
<property name="window_style">wxTAB_TRAVERSAL</property>
1800-
<object class="wxBoxSizer" expanded="false">
1800+
<object class="wxBoxSizer" expanded="true">
18011801
<property name="minimum_size"></property>
18021802
<property name="name">bSizer15</property>
18031803
<property name="orient">wxVERTICAL</property>
18041804
<property name="permission">none</property>
1805-
<object class="sizeritem" expanded="false">
1805+
<object class="sizeritem" expanded="true">
18061806
<property name="border">10</property>
18071807
<property name="flag">wxEXPAND|wxLEFT</property>
18081808
<property name="proportion">1</property>
1809-
<object class="wxBoxSizer" expanded="false">
1809+
<object class="wxBoxSizer" expanded="true">
18101810
<property name="minimum_size"></property>
18111811
<property name="name">m_gridPadNumberingSizer</property>
18121812
<property name="orient">wxVERTICAL</property>
18131813
<property name="permission">protected</property>
1814+
<object class="sizeritem" expanded="true">
1815+
<property name="border">5</property>
1816+
<property name="flag">wxALL</property>
1817+
<property name="proportion">0</property>
1818+
<object class="wxCheckBox" expanded="true">
1819+
<property name="BottomDockable">1</property>
1820+
<property name="LeftDockable">1</property>
1821+
<property name="RightDockable">1</property>
1822+
<property name="TopDockable">1</property>
1823+
<property name="aui_layer">0</property>
1824+
<property name="aui_name"></property>
1825+
<property name="aui_position">0</property>
1826+
<property name="aui_row">0</property>
1827+
<property name="best_size"></property>
1828+
<property name="bg"></property>
1829+
<property name="caption"></property>
1830+
<property name="caption_visible">1</property>
1831+
<property name="center_pane">0</property>
1832+
<property name="checked">0</property>
1833+
<property name="close_button">1</property>
1834+
<property name="context_help"></property>
1835+
<property name="context_menu">1</property>
1836+
<property name="default_pane">0</property>
1837+
<property name="dock">Dock</property>
1838+
<property name="dock_fixed">0</property>
1839+
<property name="docking">Left</property>
1840+
<property name="drag_accept_files">0</property>
1841+
<property name="enabled">1</property>
1842+
<property name="fg"></property>
1843+
<property name="floatable">1</property>
1844+
<property name="font"></property>
1845+
<property name="gripper">0</property>
1846+
<property name="hidden">0</property>
1847+
<property name="id">wxID_ANY</property>
1848+
<property name="label">Renumber pads</property>
1849+
<property name="max_size"></property>
1850+
<property name="maximize_button">0</property>
1851+
<property name="maximum_size"></property>
1852+
<property name="min_size"></property>
1853+
<property name="minimize_button">0</property>
1854+
<property name="minimum_size"></property>
1855+
<property name="moveable">1</property>
1856+
<property name="name">m_cbRenumberPads</property>
1857+
<property name="pane_border">1</property>
1858+
<property name="pane_position"></property>
1859+
<property name="pane_size"></property>
1860+
<property name="permission">protected</property>
1861+
<property name="pin_button">1</property>
1862+
<property name="pos"></property>
1863+
<property name="resize">Resizable</property>
1864+
<property name="show">1</property>
1865+
<property name="size"></property>
1866+
<property name="style"></property>
1867+
<property name="subclass">; ; forward_declare</property>
1868+
<property name="toolbar_pane">0</property>
1869+
<property name="tooltip"></property>
1870+
<property name="validator_data_type"></property>
1871+
<property name="validator_style">wxFILTER_NONE</property>
1872+
<property name="validator_type">wxDefaultValidator</property>
1873+
<property name="validator_variable"></property>
1874+
<property name="window_extra_style"></property>
1875+
<property name="window_name"></property>
1876+
<property name="window_style"></property>
1877+
<event name="OnCheckBox">OnParameterChanged</event>
1878+
</object>
1879+
</object>
18141880
<object class="sizeritem" expanded="false">
18151881
<property name="border">5</property>
18161882
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>

pcbnew/dialogs/dialog_create_array_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class TEXT_CTRL_EVAL;
2323
#include <wx/sizer.h>
2424
#include <wx/statbox.h>
2525
#include <wx/radiobut.h>
26-
#include <wx/radiobox.h>
2726
#include <wx/checkbox.h>
27+
#include <wx/radiobox.h>
2828
#include <wx/choice.h>
2929
#include <wx/panel.h>
3030
#include <wx/bitmap.h>
@@ -72,6 +72,7 @@ class DIALOG_CREATE_ARRAY_BASE : public DIALOG_SHIM
7272
wxRadioButton* m_rbCentreOnSource;
7373
wxPanel* m_gridPadNumberingPanel;
7474
wxBoxSizer* m_gridPadNumberingSizer;
75+
wxCheckBox* m_cbRenumberPads;
7576
wxRadioBox* m_radioBoxGridNumberingAxis;
7677
wxCheckBox* m_checkBoxGridReverseNumbering;
7778
wxRadioBox* m_rbGridStartNumberingOpt;

0 commit comments

Comments
 (0)