KiCad PCB EDA Suite
dialog_create_array.cpp File Reference
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <boost/algorithm/string/join.hpp>
#include <widgets/text_ctrl_eval.h>
#include <class_board.h>
#include <class_module.h>
#include "dialog_create_array.h"

Go to the source code of this file.

Classes

struct  CREATE_ARRAY_DIALOG_ENTRIES
 Struct containing the last-entered values for the dialog. More...
 

Functions

static bool validateNumberingTypeAndOffset (const wxTextCtrl &offsetEntry, const wxChoice &typeEntry, ARRAY_OPTIONS::NUMBERING_TYPE_T &type, int &offset, wxArrayString &errors)
 Validates and saves (if valid) the type and offset of an array axis numbering. More...
 
static bool validateLongEntry (const wxTextEntry &entry, long &dest, const wxString &description, wxArrayString &errors)
 Validate and save a long integer entry. More...
 

Variables

static CREATE_ARRAY_DIALOG_ENTRIES saved_array_options
 

Function Documentation

◆ validateLongEntry()

static bool validateLongEntry ( const wxTextEntry &  entry,
long &  dest,
const wxString &  description,
wxArrayString &  errors 
)
static

Validate and save a long integer entry.

Parameters
entrythe text entry to read from
destthe value destination
descriptiondescription of the field (used if the value is not OK)
errorsa list of errors to add any error to
Returns
valid

Definition at line 257 of file dialog_create_array.cpp.

259 {
260  bool ok = true;
261 
262  if( !entry.GetValue().ToLong( &dest ) )
263  {
264  wxString err;
265  err.Printf( _("Bad numeric value for %s: %s"), description, entry.GetValue() );
266  errors.Add( err );
267  ok = false;
268  }
269 
270  return ok;
271 }
string & err
Definition: json11.cpp:598

References err.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ validateNumberingTypeAndOffset()

static bool validateNumberingTypeAndOffset ( const wxTextCtrl &  offsetEntry,
const wxChoice &  typeEntry,
ARRAY_OPTIONS::NUMBERING_TYPE_T type,
int &  offset,
wxArrayString &  errors 
)
static

Validates and saves (if valid) the type and offset of an array axis numbering.

Parameters
offsetEntrythe entry of the offset (text)
typeEntrythe entry of the axis nmbering scheme (choice)
typethe destination of the type if valid
offsetthe destination of the offset if valid
errorserror string accumulator
Returns
if all valid

Definition at line 208 of file dialog_create_array.cpp.

212 {
213  const int typeVal = typeEntry.GetSelection();
214  // mind undefined casts to enums (should not be able to happen)
215  bool ok = typeVal <= ARRAY_OPTIONS::NUMBERING_TYPE_MAX;
216 
217  if( ok )
218  {
219  type = (ARRAY_OPTIONS::NUMBERING_TYPE_T) typeVal;
220  }
221  else
222  {
223  wxString err;
224  err.Printf( _("Unrecognized numbering scheme: %d"), typeVal );
225  errors.Add( err );
226  // we can't proceed - we don't know the numbering type
227  return false;
228  }
229 
230  const wxString text = offsetEntry.GetValue();
231  ok = ARRAY_OPTIONS::GetNumberingOffset( text, type, offset );
232 
233  if( !ok )
234  {
235  const wxString& alphabet = ARRAY_OPTIONS::AlphabetFromNumberingScheme( type );
236 
237  wxString err;
238  err.Printf( _( "Could not determine numbering start from \"%s\": "
239  "expected value consistent with alphabet \"%s\"" ),
240  text, alphabet );
241  errors.Add(err);
242  }
243 
244  return ok;
245 }
#define NUMBERING_TYPE_MAX
string & err
Definition: json11.cpp:598
static const wxString & AlphabetFromNumberingScheme(NUMBERING_TYPE_T type)
Get the alphabet for a particular numbering scheme.
static bool GetNumberingOffset(const wxString &str, ARRAY_OPTIONS::NUMBERING_TYPE_T type, int &offsetToFill)
Get the numbering offset for a given numbering string.

References ARRAY_OPTIONS::AlphabetFromNumberingScheme(), err, ARRAY_OPTIONS::GetNumberingOffset(), and NUMBERING_TYPE_MAX.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

Variable Documentation

◆ saved_array_options

CREATE_ARRAY_DIALOG_ENTRIES saved_array_options
static

Definition at line 95 of file dialog_create_array.cpp.

Referenced by DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY().