KiCad PCB EDA Suite
ARRAY_OPTIONS Class Referenceabstract

Options that govern the setup of an "array" of multiple item. More...

#include <array_options.h>

Inheritance diagram for ARRAY_OPTIONS:
ARRAY_CIRCULAR_OPTIONS ARRAY_GRID_OPTIONS

Classes

struct  TRANSFORM
 Transform applied to an object by this array. More...
 

Public Types

enum  ARRAY_TYPE_T { ARRAY_GRID, ARRAY_CIRCULAR }
 
enum  NUMBERING_TYPE_T { NUMBERING_NUMERIC = 0, NUMBERING_HEX, NUMBERING_ALPHA_NO_IOSQXZ, NUMBERING_ALPHA_FULL }
 

Public Member Functions

 ARRAY_OPTIONS (ARRAY_TYPE_T aType)
 
virtual ~ARRAY_OPTIONS ()
 
virtual TRANSFORM GetTransform (int aN, const VECTOR2I &aPos) const =0
 Get the transform of the n-th point in the array. More...
 
virtual int GetArraySize () const =0
 The number of points in this array. More...
 
virtual wxString GetItemNumber (int n) const =0
 Get the position number (name) for the n'th array point. More...
 
bool ShouldNumberItems () const
 
void SetShouldNumber (bool aShouldNumber)
 
bool GetNumberingStartIsSpecified () const
 
void SetNumberingStartIsSpecified (bool aIsSpecified)
 

Static Public Member Functions

static const wxString & AlphabetFromNumberingScheme (NUMBERING_TYPE_T type)
 Get the alphabet for a particular numbering scheme. More...
 
static bool SchemeNonUnitColsStartAt0 (NUMBERING_TYPE_T type)
 
static bool GetNumberingOffset (const wxString &str, ARRAY_OPTIONS::NUMBERING_TYPE_T type, int &offsetToFill)
 Get the numbering offset for a given numbering string. More...
 

Static Protected Member Functions

static wxString getCoordinateNumber (int n, NUMBERING_TYPE_T type)
 

Protected Attributes

ARRAY_TYPE_T m_type
 
bool m_shouldNumber
 True if this array numbers the new items. More...
 
bool m_numberingStartIsSpecified
 True if this array's number starts from the preset point False if the array numbering starts from some externally provided point. More...
 

Detailed Description

Options that govern the setup of an "array" of multiple item.

The base ARRAY_OPTIONS do not encode a specific geometry or numbering method, this is done by derived classes.

Definition at line 34 of file array_options.h.

Member Enumeration Documentation

◆ ARRAY_TYPE_T

Enumerator
ARRAY_GRID 

A grid (x*y) array.

ARRAY_CIRCULAR 

A circular array.

Definition at line 37 of file array_options.h.

38  {
39  ARRAY_GRID,
41  };
A grid (x*y) array.
Definition: array_options.h:39

◆ NUMBERING_TYPE_T

Enumerator
NUMBERING_NUMERIC 

Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...

NUMBERING_HEX 
NUMBERING_ALPHA_NO_IOSQXZ 

Alphabet, excluding IOSQXZ

                            Per ASME Y14.35M-1997 sec. 5.2 (previously MIL-STD-100 sec. 406.5)
                            as these can be confused with numerals and are often not used
                            for pin numbering on BGAs, etc
NUMBERING_ALPHA_FULL 

Full 26-character alphabet.

Definition at line 44 of file array_options.h.

Constructor & Destructor Documentation

◆ ARRAY_OPTIONS()

ARRAY_OPTIONS::ARRAY_OPTIONS ( ARRAY_TYPE_T  aType)
inline

Definition at line 57 of file array_options.h.

58  : m_type( aType ), m_shouldNumber( false ), m_numberingStartIsSpecified( false )
59  {
60  }
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...
bool m_shouldNumber
True if this array numbers the new items.
ARRAY_TYPE_T m_type

◆ ~ARRAY_OPTIONS()

virtual ARRAY_OPTIONS::~ARRAY_OPTIONS ( )
inlinevirtual

Definition at line 62 of file array_options.h.

62 {};

Member Function Documentation

◆ AlphabetFromNumberingScheme()

const wxString & ARRAY_OPTIONS::AlphabetFromNumberingScheme ( NUMBERING_TYPE_T  type)
static

Get the alphabet for a particular numbering scheme.

Parameters
typethe numbering scheme
Returns
the alphabet (as a string)

Definition at line 28 of file array_options.cpp.

29 {
30  static const wxString alphaNumeric = "0123456789";
31  static const wxString alphaHex = "0123456789ABCDEF";
32  static const wxString alphaFull = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
33  static const wxString alphaNoIOSQXZ = "ABCDEFGHJKLMNPRTUVWY";
34 
35  switch( type )
36  {
37  default:
38  case NUMBERING_NUMERIC: return alphaNumeric;
39  case NUMBERING_HEX: return alphaHex;
40  case NUMBERING_ALPHA_NO_IOSQXZ: return alphaNoIOSQXZ;
41  case NUMBERING_ALPHA_FULL: return alphaFull;
42  }
43 }
Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...
Definition: array_options.h:46
Full 26-character alphabet.
Definition: array_options.h:54

References NUMBERING_ALPHA_FULL, NUMBERING_ALPHA_NO_IOSQXZ, NUMBERING_HEX, and NUMBERING_NUMERIC.

Referenced by getCoordinateNumber(), GetNumberingOffset(), and validateNumberingTypeAndOffset().

◆ GetArraySize()

virtual int ARRAY_OPTIONS::GetArraySize ( ) const
pure virtual

The number of points in this array.

Implemented in ARRAY_CIRCULAR_OPTIONS, and ARRAY_GRID_OPTIONS.

Referenced by ARRAY_CREATOR::Invoke().

◆ getCoordinateNumber()

wxString ARRAY_OPTIONS::getCoordinateNumber ( int  n,
NUMBERING_TYPE_T  type 
)
staticprotected

Definition at line 82 of file array_options.cpp.

83 {
84  wxString itemNum;
85  const wxString& alphabet = AlphabetFromNumberingScheme( type );
86 
87  const bool nonUnitColsStartAt0 = SchemeNonUnitColsStartAt0( type );
88 
89  bool firstRound = true;
90  int radix = alphabet.Length();
91 
92  do
93  {
94  int modN = n % radix;
95 
96  if( nonUnitColsStartAt0 && !firstRound )
97  modN--; // Start the "tens/hundreds/etc column" at "Ax", not "Bx"
98 
99  itemNum.insert( 0, 1, alphabet[modN] );
100 
101  n /= radix;
102  firstRound = false;
103  } while( n );
104 
105  return itemNum;
106 }
static bool SchemeNonUnitColsStartAt0(NUMBERING_TYPE_T type)
static const wxString & AlphabetFromNumberingScheme(NUMBERING_TYPE_T type)
Get the alphabet for a particular numbering scheme.

References AlphabetFromNumberingScheme(), and SchemeNonUnitColsStartAt0().

Referenced by ARRAY_GRID_OPTIONS::GetItemNumber(), and ARRAY_CIRCULAR_OPTIONS::GetItemNumber().

◆ GetItemNumber()

virtual wxString ARRAY_OPTIONS::GetItemNumber ( int  n) const
pure virtual

Get the position number (name) for the n'th array point.

Parameters
narray point index, from 0 to GetArraySize() - 1
Returns
the point's name

Implemented in ARRAY_CIRCULAR_OPTIONS, and ARRAY_GRID_OPTIONS.

Referenced by ARRAY_PAD_NAME_PROVIDER::getNextName().

◆ GetNumberingOffset()

bool ARRAY_OPTIONS::GetNumberingOffset ( const wxString &  str,
ARRAY_OPTIONS::NUMBERING_TYPE_T  type,
int &  offsetToFill 
)
static

Get the numbering offset for a given numbering string.

Parameters
stra numbering string, say "B" or "5"
typethe type this string should be
offsetToFillthe offset to set, if found
Returns
true if the string is a valid offset of this type

Definition at line 52 of file array_options.cpp.

54 {
55  const wxString& alphabet = ARRAY_OPTIONS::AlphabetFromNumberingScheme( type );
56 
57  int offset = 0;
58  const int radix = alphabet.length();
59 
60  for( unsigned i = 0; i < str.length(); i++ )
61  {
62  int chIndex = alphabet.Find( str[i], false );
63 
64  if( chIndex == wxNOT_FOUND )
65  return false;
66 
67  const bool start0 = ARRAY_OPTIONS::SchemeNonUnitColsStartAt0( type );
68 
69  // eg "AA" is actually index 27, not 26
70  if( start0 && i < str.length() - 1 )
71  chIndex++;
72 
73  offset *= radix;
74  offset += chIndex;
75  }
76 
77  offsetToFill = offset;
78  return true;
79 }
const string & str
Definition: json11.cpp:596
static bool SchemeNonUnitColsStartAt0(NUMBERING_TYPE_T type)
static const wxString & AlphabetFromNumberingScheme(NUMBERING_TYPE_T type)
Get the alphabet for a particular numbering scheme.
size_t i
Definition: json11.cpp:597

References AlphabetFromNumberingScheme(), i, SchemeNonUnitColsStartAt0(), and str.

Referenced by validateNumberingTypeAndOffset().

◆ GetNumberingStartIsSpecified()

bool ARRAY_OPTIONS::GetNumberingStartIsSpecified ( ) const
inline
Returns
is the numbering is enabled and should start at a point specified in these options or is it implicit according to the calling code?

Definition at line 135 of file array_options.h.

136  {
138  }
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...
bool m_shouldNumber
True if this array numbers the new items.

References m_numberingStartIsSpecified, and m_shouldNumber.

Referenced by ARRAY_PAD_NAME_PROVIDER::ARRAY_PAD_NAME_PROVIDER(), and DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ GetTransform()

virtual TRANSFORM ARRAY_OPTIONS::GetTransform ( int  aN,
const VECTOR2I aPos 
) const
pure virtual

Get the transform of the n-th point in the array.

Parameters
aNthe index of the array point (0 is the original point)
aPosthe existing item position
Returns
a transform (an offset and a rotation)

Implemented in ARRAY_CIRCULAR_OPTIONS, and ARRAY_GRID_OPTIONS.

Referenced by TransformItem().

◆ SchemeNonUnitColsStartAt0()

bool ARRAY_OPTIONS::SchemeNonUnitColsStartAt0 ( NUMBERING_TYPE_T  type)
static
Returns
False for schemes like 0,1...9,10 True for schemes like A,B..Z,AA (where the tens column starts with char 0)

Definition at line 46 of file array_options.cpp.

References NUMBERING_ALPHA_FULL, and NUMBERING_ALPHA_NO_IOSQXZ.

Referenced by getCoordinateNumber(), and GetNumberingOffset().

◆ SetNumberingStartIsSpecified()

void ARRAY_OPTIONS::SetNumberingStartIsSpecified ( bool  aIsSpecified)
inline

Definition at line 140 of file array_options.h.

141  {
142  m_numberingStartIsSpecified = aIsSpecified;
143  }
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...

References m_numberingStartIsSpecified.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ SetShouldNumber()

void ARRAY_OPTIONS::SetShouldNumber ( bool  aShouldNumber)
inline

Definition at line 125 of file array_options.h.

126  {
127  m_shouldNumber = aShouldNumber;
128  }
bool m_shouldNumber
True if this array numbers the new items.

References m_shouldNumber.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ ShouldNumberItems()

bool ARRAY_OPTIONS::ShouldNumberItems ( ) const
inline
Returns
are the items in this array numbered, or are all the items numbered the same?

Definition at line 120 of file array_options.h.

121  {
122  return m_shouldNumber;
123  }
bool m_shouldNumber
True if this array numbers the new items.

References m_shouldNumber.

Referenced by ARRAY_CREATOR::Invoke().

Member Data Documentation

◆ m_numberingStartIsSpecified

bool ARRAY_OPTIONS::m_numberingStartIsSpecified
protected

True if this array's number starts from the preset point False if the array numbering starts from some externally provided point.

Definition at line 155 of file array_options.h.

Referenced by GetNumberingStartIsSpecified(), and SetNumberingStartIsSpecified().

◆ m_shouldNumber

bool ARRAY_OPTIONS::m_shouldNumber
protected

True if this array numbers the new items.

Definition at line 151 of file array_options.h.

Referenced by GetNumberingStartIsSpecified(), SetShouldNumber(), and ShouldNumberItems().

◆ m_type

ARRAY_TYPE_T ARRAY_OPTIONS::m_type
protected

Definition at line 148 of file array_options.h.


The documentation for this class was generated from the following files: