From 6ade8c25e1bfb6d0eb6d591a17c995e70a4dbc24 Mon Sep 17 00:00:00 2001 From: John Beard Date: Wed, 15 May 2019 17:21:12 +0100 Subject: [PATCH] Pcbnew: allow alphabetic numbering in n circular grids Add controls to the dialog and wire up to the axis numbering scheme, same as the grid axes. Fixes: lp:1814923 * https://bugs.launchpad.net/kicad/+bug/1814923 --- pcbnew/dialogs/dialog_create_array.cpp | 19 ++- pcbnew/dialogs/dialog_create_array_base.cpp | 11 +- pcbnew/dialogs/dialog_create_array_base.fbp | 131 +++++++++++++++++++- pcbnew/dialogs/dialog_create_array_base.h | 4 +- 4 files changed, 149 insertions(+), 16 deletions(-) diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index 70ba1c5754..701fa644fc 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -89,6 +89,7 @@ struct CREATE_ARRAY_DIALOG_ENTRIES long m_circAngle; long m_circCount; long m_circNumberingStartSet; + long m_gridCircNumScheme; wxString m_circNumberingOffset; bool m_circRotate; long m_arrayTypeTab; @@ -153,10 +154,12 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( m_choicePriAxisNumbering->Append( label, clientData ); m_choiceSecAxisNumbering->Append( label, clientData ); + m_choiceCircNumbering->Append( label, clientData ); } m_choicePriAxisNumbering->SetSelection( 0 ); m_choiceSecAxisNumbering->SetSelection( 0 ); + m_choiceCircNumbering->SetSelection( 0 ); m_circAngle.SetUnits( EDA_UNITS_T::DEGREES ); @@ -195,6 +198,7 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( m_cfg_persister.Add( *m_entryRotateItemsCb, saved_array_options.m_circRotate ); m_cfg_persister.Add( *m_rbCircStartNumberingOpt, saved_array_options.m_circNumberingStartSet ); + m_cfg_persister.Add( *m_choiceCircNumbering, saved_array_options.m_gridCircNumScheme ); m_cfg_persister.Add( *m_entryCircNumberingStart, saved_array_options.m_circNumberingOffset ); m_cfg_persister.Add( *m_gridTypeNotebook, saved_array_options.m_arrayTypeTab ); @@ -377,22 +381,13 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() if( newCirc->GetNumberingStartIsSpecified() ) { - newCirc->m_axis.SetAxisType( ARRAY_AXIS::NUMBERING_NUMERIC ); - - long offset; - - ok = ok - && validateLongEntry( - *m_entryCircNumberingStart, offset, _( "numbering start" ), errors ); - - if( ok ) - { - newCirc->m_axis.SetOffset( offset ); - } + ok = ok && validateNumberingTypeAndOffset( *m_entryCircNumberingStart, + *m_choiceCircNumbering, newCirc->m_axis, errors ); } else { // artificial linear numeric scheme from 1 + newCirc->m_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC ); newCirc->m_axis.SetOffset( 1 ); // Start at "1" } } diff --git a/pcbnew/dialogs/dialog_create_array_base.cpp b/pcbnew/dialogs/dialog_create_array_base.cpp index 42d06370a5..231fc0f144 100644 --- a/pcbnew/dialogs/dialog_create_array_base.cpp +++ b/pcbnew/dialogs/dialog_create_array_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 10 2018) +// C++ code generated with wxFormBuilder (version Mar 28 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -267,6 +267,15 @@ DIALOG_CREATE_ARRAY_BASE::DIALOG_CREATE_ARRAY_BASE( wxWindow* parent, wxWindowID m_rbCircStartNumberingOpt->SetSelection( 0 ); m_circPadNumberingSizer->Add( m_rbCircStartNumberingOpt, 0, wxALL|wxEXPAND, 5 ); + m_labelCircNumbering = new wxStaticText( m_circPadNumberingSizer->GetStaticBox(), wxID_ANY, _("Pad Numbering:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelCircNumbering->Wrap( -1 ); + m_circPadNumberingSizer->Add( m_labelCircNumbering, 0, wxALL, 5 ); + + wxArrayString m_choiceCircNumberingChoices; + m_choiceCircNumbering = new wxChoice( m_circPadNumberingSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCircNumberingChoices, 0 ); + m_choiceCircNumbering->SetSelection( 0 ); + m_circPadNumberingSizer->Add( m_choiceCircNumbering, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxHORIZONTAL ); diff --git a/pcbnew/dialogs/dialog_create_array_base.fbp b/pcbnew/dialogs/dialog_create_array_base.fbp index 3a0820ab4b..2b9c4d9bb1 100644 --- a/pcbnew/dialogs/dialog_create_array_base.fbp +++ b/pcbnew/dialogs/dialog_create_array_base.fbp @@ -14,6 +14,7 @@ dialog_create_array_base 1000 none + 1 DIALOG_CREATE_ARRAY_BASE @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -1452,11 +1454,11 @@ 0 - + 5 wxALL|wxEXPAND 0 - + m_gridPadNumberingSizer wxVERTICAL @@ -3389,6 +3391,131 @@ OnParameterChanged + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Pad Numbering: + 0 + + 0 + + + 0 + + 1 + m_labelCircNumbering + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 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 + + 1 + m_choiceCircNumbering + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + 5 wxEXPAND diff --git a/pcbnew/dialogs/dialog_create_array_base.h b/pcbnew/dialogs/dialog_create_array_base.h index 7fbd089ffd..ed1418b4ec 100644 --- a/pcbnew/dialogs/dialog_create_array_base.h +++ b/pcbnew/dialogs/dialog_create_array_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 10 2018) +// C++ code generated with wxFormBuilder (version Mar 28 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -98,6 +98,8 @@ class DIALOG_CREATE_ARRAY_BASE : public DIALOG_SHIM wxCheckBox* m_entryRotateItemsCb; wxStaticBoxSizer* m_circPadNumberingSizer; wxRadioBox* m_rbCircStartNumberingOpt; + wxStaticText* m_labelCircNumbering; + wxChoice* m_choiceCircNumbering; wxStaticText* m_labelCircNumStart; wxTextCtrl* m_entryCircNumberingStart; wxStdDialogButtonSizer* m_stdButtons;