KiCad PCB EDA Suite
DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS Struct Reference

#include <dialog_create_array.h>

Inheritance diagram for DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS:
DIALOG_CREATE_ARRAY::ARRAY_OPTIONS

Public Member Functions

 ARRAY_GRID_OPTIONS ()
 
void TransformItem (int n, BOARD_ITEM *item, const wxPoint &rotPoint) const override
 
int GetArraySize () const override
 
wxString GetItemNumber (int n) const override
 
virtual wxString InterpolateNumberIntoString (int n, const wxString &pattern) const
 
bool ShouldNumberItems () const
 
bool NumberingStartIsSpecified () const
 

Public Attributes

long m_nx
 
long m_ny
 
bool m_horizontalThenVertical
 
bool m_reverseNumberingAlternate
 
wxPoint m_delta
 
wxPoint m_offset
 
long m_stagger
 
bool m_stagger_rows
 
bool m_2dArrayNumbering
 
int m_numberingOffsetX
 
int m_numberingOffsetY
 
ARRAY_NUMBERING_TYPE_T m_priAxisNumType
 
ARRAY_NUMBERING_TYPE_T m_secAxisNumType
 
ARRAY_TYPE_T m_type
 

Static Protected Member Functions

static wxString getCoordinateNumber (int n, ARRAY_NUMBERING_TYPE_T type)
 

Protected Attributes

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

wxPoint getGridCoords (int n) const
 

Detailed Description

Definition at line 261 of file dialog_create_array.h.

Constructor & Destructor Documentation

DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::ARRAY_GRID_OPTIONS ( )
inline

Definition at line 263 of file dialog_create_array.h.

263  :
265  m_nx( 0 ), m_ny( 0 ),
266  m_horizontalThenVertical( true ),
268  m_stagger( 0 ),
269  m_stagger_rows( true ),
270  m_2dArrayNumbering( false ),
271  m_numberingOffsetX( 0 ),
272  m_numberingOffsetY( 0 ),
275  {}
Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...

Member Function Documentation

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::GetArraySize ( ) const
overridevirtual
wxString DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::getCoordinateNumber ( int  n,
ARRAY_NUMBERING_TYPE_T  type 
)
staticprotectedinherited

Definition at line 469 of file dialog_create_array.cpp.

References alphabetFromNumberingScheme(), and schemeNonUnitColsStartAt0().

471 {
472  wxString itemNum;
473  const wxString& alphabet = alphabetFromNumberingScheme( type );
474 
475  const bool nonUnitColsStartAt0 = schemeNonUnitColsStartAt0( type );
476 
477  bool firstRound = true;
478  int radix = alphabet.Length();
479 
480  do {
481  int modN = n % radix;
482 
483  if( nonUnitColsStartAt0 && !firstRound )
484  modN--; // Start the "tens/hundreds/etc column" at "Ax", not "Bx"
485 
486  itemNum.insert( 0, 1, alphabet[modN] );
487 
488  n /= radix;
489  firstRound = false;
490  } while( n );
491 
492  return itemNum;
493 }
static bool schemeNonUnitColsStartAt0(DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type)
static const wxString & alphabetFromNumberingScheme(DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T type)
wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::getGridCoords ( int  n) const
private

Definition at line 512 of file dialog_create_array.cpp.

513 {
514  const int axisSize = m_horizontalThenVertical ? m_nx : m_ny;
515 
516  int x = n % axisSize;
517  int y = n / axisSize;
518 
519  // reverse on this row/col?
520  if( m_reverseNumberingAlternate && ( y % 2 ) )
521  x = axisSize - x - 1;
522 
523  wxPoint coords( x, y );
524 
525  return coords;
526 }
wxString DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::GetItemNumber ( int  n) const
overridevirtual

Implements DIALOG_CREATE_ARRAY::ARRAY_OPTIONS.

Definition at line 561 of file dialog_create_array.cpp.

References wxPoint::x, and wxPoint::y.

562 {
563  wxString itemNum;
564 
565  if( m_2dArrayNumbering )
566  {
567  wxPoint coords = getGridCoords( n );
568 
571  }
572  else
573  {
575  }
576 
577  return itemNum;
578 }
static wxString getCoordinateNumber(int n, ARRAY_NUMBERING_TYPE_T type)
wxString DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::InterpolateNumberIntoString ( int  n,
const wxString &  pattern 
) const
virtualinherited

Definition at line 496 of file dialog_create_array.cpp.

498 {
499  wxString newStr( aPattern );
500  newStr.Replace( "%s", GetItemNumber( aN ), false );
501 
502  return newStr;
503 }
virtual wxString GetItemNumber(int n) const =0
bool DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::NumberingStartIsSpecified ( ) 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 242 of file dialog_create_array.h.

Referenced by ARRAY_CREATOR::Invoke().

243  {
245  }
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.
bool DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::ShouldNumberItems ( ) const
inlineinherited
Returns
are the items in this array numberred, or are all the items numbered the same

Definition at line 232 of file dialog_create_array.h.

Referenced by ARRAY_CREATOR::Invoke().

233  {
234  return m_shouldNumber;
235  }
bool m_shouldNumber
True if this array numbers the new items.
void DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::TransformItem ( int  n,
BOARD_ITEM item,
const wxPoint rotPoint 
) const
overridevirtual

Function GetArrayPositions Returns the set of points that represent the array in order, if that is important

TODO: Can/should this be done with some sort of iterator?

Implements DIALOG_CREATE_ARRAY::ARRAY_OPTIONS.

Definition at line 529 of file dialog_create_array.cpp.

References abs, BOARD_ITEM::Move(), wxPoint::x, and wxPoint::y.

531 {
532  wxPoint point;
533 
534  wxPoint coords = getGridCoords( n );
535 
536  // swap axes if needed
538  std::swap( coords.x, coords.y );
539 
540  point.x = coords.x * m_delta.x + coords.y * m_offset.x;
541  point.y = coords.y * m_delta.y + coords.x * m_offset.y;
542 
543  if( std::abs( m_stagger ) > 1 )
544  {
545  const int stagger = std::abs( m_stagger );
546  const bool sr = m_stagger_rows;
547  const int stagger_idx = ( ( sr ? coords.y : coords.x ) % stagger );
548 
549  wxPoint stagger_delta( ( sr ? m_delta.x : m_offset.x ),
550  ( sr ? m_offset.y : m_delta.y ) );
551 
552  // Stagger to the left/up if the sign of the stagger is negative
553  point += stagger_delta * copysign( stagger_idx, m_stagger ) / stagger;
554  }
555 
556  // this is already relative to the first array entry
557  item->Move( point );
558 }
#define abs(a)
Definition: auxiliary.h:84
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.

Member Data Documentation

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_2dArrayNumbering

Definition at line 283 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_delta

Definition at line 279 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_horizontalThenVertical

Definition at line 278 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetX

Definition at line 284 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetY

Definition at line 284 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

bool DIALOG_CREATE_ARRAY::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 258 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_nx

Definition at line 277 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_ny

Definition at line 277 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_offset

Definition at line 280 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

ARRAY_NUMBERING_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_priAxisNumType

Definition at line 285 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_reverseNumberingAlternate

Definition at line 278 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

ARRAY_NUMBERING_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_secAxisNumType

Definition at line 285 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

bool DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::m_shouldNumber
protectedinherited

True if this array numbers the new items.

Definition at line 254 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_stagger

Definition at line 281 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_stagger_rows

Definition at line 282 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::OnOkClick().

ARRAY_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::m_type
inherited

Definition at line 211 of file dialog_create_array.h.


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