KiCad PCB EDA Suite
ARRAY_GRID_OPTIONS Struct Reference

#include <array_options.h>

Inheritance diagram for ARRAY_GRID_OPTIONS:
ARRAY_OPTIONS

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_GRID_OPTIONS ()
 
TRANSFORM GetTransform (int aN, const VECTOR2I &aPos) const override
 Get the transform of the n-th point in the array. More...
 
int GetArraySize () const override
 The number of points in this array. More...
 
wxString GetItemNumber (int n) const override
 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...
 

Public Attributes

long m_nx
 
long m_ny
 
bool m_horizontalThenVertical
 
bool m_reverseNumberingAlternate
 
VECTOR2I m_delta
 
VECTOR2I m_offset
 
long m_stagger
 
bool m_stagger_rows
 
bool m_2dArrayNumbering
 
int m_numberingOffsetX
 
int m_numberingOffsetY
 
NUMBERING_TYPE_T m_priAxisNumType
 
NUMBERING_TYPE_T m_secAxisNumType
 

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...
 

Private Member Functions

VECTOR2I getGridCoords (int n) const
 

Detailed Description

Definition at line 159 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_GRID_OPTIONS()

ARRAY_GRID_OPTIONS::ARRAY_GRID_OPTIONS ( )
inline

Definition at line 161 of file array_options.h.

163  m_nx( 0 ),
164  m_ny( 0 ),
165  m_horizontalThenVertical( true ),
167  m_stagger( 0 ),
168  m_stagger_rows( true ),
169  m_2dArrayNumbering( false ),
170  m_numberingOffsetX( 0 ),
171  m_numberingOffsetY( 0 ),
174  {
175  }
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:57
NUMBERING_TYPE_T m_secAxisNumType
A grid (x*y) array.
Definition: array_options.h:39
bool m_reverseNumberingAlternate
Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...
Definition: array_options.h:46
NUMBERING_TYPE_T m_priAxisNumType

Member Function Documentation

◆ AlphabetFromNumberingScheme()

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

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 ARRAY_OPTIONS::NUMBERING_ALPHA_FULL, ARRAY_OPTIONS::NUMBERING_ALPHA_NO_IOSQXZ, ARRAY_OPTIONS::NUMBERING_HEX, and ARRAY_OPTIONS::NUMBERING_NUMERIC.

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

◆ GetArraySize()

int ARRAY_GRID_OPTIONS::GetArraySize ( ) const
overridevirtual

The number of points in this array.

Implements ARRAY_OPTIONS.

Definition at line 109 of file array_options.cpp.

110 {
111  return m_nx * m_ny;
112 }

References m_nx, and m_ny.

◆ getCoordinateNumber()

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

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 ARRAY_OPTIONS::AlphabetFromNumberingScheme(), and ARRAY_OPTIONS::SchemeNonUnitColsStartAt0().

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

◆ getGridCoords()

VECTOR2I ARRAY_GRID_OPTIONS::getGridCoords ( int  n) const
private

Definition at line 115 of file array_options.cpp.

116 {
117  const int axisSize = m_horizontalThenVertical ? m_nx : m_ny;
118 
119  int x = n % axisSize;
120  int y = n / axisSize;
121 
122  // reverse on this row/col?
123  if( m_reverseNumberingAlternate && ( y % 2 ) )
124  x = axisSize - x - 1;
125 
126  wxPoint coords( x, y );
127 
128  return coords;
129 }
bool m_reverseNumberingAlternate

References m_horizontalThenVertical, m_nx, m_ny, and m_reverseNumberingAlternate.

Referenced by GetItemNumber(), and GetTransform().

◆ GetItemNumber()

wxString ARRAY_GRID_OPTIONS::GetItemNumber ( int  n) const
overridevirtual

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

Implements ARRAY_OPTIONS.

Definition at line 162 of file array_options.cpp.

163 {
164  wxString itemNum;
165 
166  if( m_2dArrayNumbering )
167  {
168  VECTOR2I coords = getGridCoords( n );
169 
172  }
173  else
174  {
176  }
177 
178  return itemNum;
179 }
NUMBERING_TYPE_T m_secAxisNumType
static wxString getCoordinateNumber(int n, NUMBERING_TYPE_T type)
VECTOR2I getGridCoords(int n) const
NUMBERING_TYPE_T m_priAxisNumType

References ARRAY_OPTIONS::getCoordinateNumber(), getGridCoords(), m_2dArrayNumbering, m_numberingOffsetX, m_numberingOffsetY, m_priAxisNumType, m_secAxisNumType, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetNumberingOffset()

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

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 ARRAY_OPTIONS::AlphabetFromNumberingScheme(), i, ARRAY_OPTIONS::SchemeNonUnitColsStartAt0(), and str.

Referenced by validateNumberingTypeAndOffset().

◆ GetNumberingStartIsSpecified()

bool ARRAY_OPTIONS::GetNumberingStartIsSpecified ( ) const
inlineinherited
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 ARRAY_OPTIONS::m_numberingStartIsSpecified, and ARRAY_OPTIONS::m_shouldNumber.

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

◆ GetTransform()

ARRAY_OPTIONS::TRANSFORM ARRAY_GRID_OPTIONS::GetTransform ( int  aN,
const VECTOR2I aPos 
) const
overridevirtual

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)

Implements ARRAY_OPTIONS.

Definition at line 132 of file array_options.cpp.

133 {
134  VECTOR2I point;
135 
136  VECTOR2I coords = getGridCoords( n );
137 
138  // swap axes if needed
140  std::swap( coords.x, coords.y );
141 
142  point.x = coords.x * m_delta.x + coords.y * m_offset.x;
143  point.y = coords.y * m_delta.y + coords.x * m_offset.y;
144 
145  if( std::abs( m_stagger ) > 1 )
146  {
147  const int stagger = std::abs( m_stagger );
148  const bool sr = m_stagger_rows;
149  const int stagger_idx = ( ( sr ? coords.y : coords.x ) % stagger );
150 
151  VECTOR2I stagger_delta( ( sr ? m_delta.x : m_offset.x ), ( sr ? m_offset.y : m_delta.y ) );
152 
153  // Stagger to the left/up if the sign of the stagger is negative
154  point += stagger_delta * copysign( stagger_idx, m_stagger ) / stagger;
155  }
156 
157  // this is already relative to the first array entry
158  return { point, 0.0 };
159 }
#define abs(a)
Definition: auxiliary.h:84
VECTOR2I getGridCoords(int n) const

References abs, getGridCoords(), m_delta, m_horizontalThenVertical, m_offset, m_stagger, m_stagger_rows, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SchemeNonUnitColsStartAt0()

bool ARRAY_OPTIONS::SchemeNonUnitColsStartAt0 ( NUMBERING_TYPE_T  type)
staticinherited
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 ARRAY_OPTIONS::NUMBERING_ALPHA_FULL, and ARRAY_OPTIONS::NUMBERING_ALPHA_NO_IOSQXZ.

Referenced by ARRAY_OPTIONS::getCoordinateNumber(), and ARRAY_OPTIONS::GetNumberingOffset().

◆ SetNumberingStartIsSpecified()

void ARRAY_OPTIONS::SetNumberingStartIsSpecified ( bool  aIsSpecified)
inlineinherited

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 ARRAY_OPTIONS::m_numberingStartIsSpecified.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ SetShouldNumber()

void ARRAY_OPTIONS::SetShouldNumber ( bool  aShouldNumber)
inlineinherited

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 ARRAY_OPTIONS::m_shouldNumber.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

◆ ShouldNumberItems()

bool ARRAY_OPTIONS::ShouldNumberItems ( ) const
inlineinherited
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 ARRAY_OPTIONS::m_shouldNumber.

Referenced by ARRAY_CREATOR::Invoke().

Member Data Documentation

◆ m_2dArrayNumbering

bool ARRAY_GRID_OPTIONS::m_2dArrayNumbering

Definition at line 183 of file array_options.h.

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

◆ m_delta

VECTOR2I ARRAY_GRID_OPTIONS::m_delta

Definition at line 179 of file array_options.h.

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

◆ m_horizontalThenVertical

bool ARRAY_GRID_OPTIONS::m_horizontalThenVertical

◆ m_numberingOffsetX

int ARRAY_GRID_OPTIONS::m_numberingOffsetX

Definition at line 184 of file array_options.h.

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

◆ m_numberingOffsetY

int ARRAY_GRID_OPTIONS::m_numberingOffsetY

Definition at line 184 of file array_options.h.

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

◆ m_numberingStartIsSpecified

bool ARRAY_OPTIONS::m_numberingStartIsSpecified
protectedinherited

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 ARRAY_OPTIONS::GetNumberingStartIsSpecified(), and ARRAY_OPTIONS::SetNumberingStartIsSpecified().

◆ m_nx

long ARRAY_GRID_OPTIONS::m_nx

◆ m_ny

long ARRAY_GRID_OPTIONS::m_ny

◆ m_offset

VECTOR2I ARRAY_GRID_OPTIONS::m_offset

Definition at line 180 of file array_options.h.

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

◆ m_priAxisNumType

NUMBERING_TYPE_T ARRAY_GRID_OPTIONS::m_priAxisNumType

Definition at line 185 of file array_options.h.

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

◆ m_reverseNumberingAlternate

bool ARRAY_GRID_OPTIONS::m_reverseNumberingAlternate

Definition at line 178 of file array_options.h.

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

◆ m_secAxisNumType

NUMBERING_TYPE_T ARRAY_GRID_OPTIONS::m_secAxisNumType

Definition at line 185 of file array_options.h.

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

◆ m_shouldNumber

bool ARRAY_OPTIONS::m_shouldNumber
protectedinherited

True if this array numbers the new items.

Definition at line 151 of file array_options.h.

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

◆ m_stagger

long ARRAY_GRID_OPTIONS::m_stagger

Definition at line 181 of file array_options.h.

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

◆ m_stagger_rows

bool ARRAY_GRID_OPTIONS::m_stagger_rows

Definition at line 182 of file array_options.h.

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

◆ m_type

ARRAY_TYPE_T ARRAY_OPTIONS::m_type
protectedinherited

Definition at line 148 of file array_options.h.


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