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 470 of file dialog_create_array.cpp.

References alphabetFromNumberingScheme(), and schemeNonUnitColsStartAt0().

472 {
473  wxString itemNum;
474  const wxString& alphabet = alphabetFromNumberingScheme( type );
475 
476  const bool nonUnitColsStartAt0 = schemeNonUnitColsStartAt0( type );
477 
478  bool firstRound = true;
479  int radix = alphabet.Length();
480 
481  do {
482  int modN = n % radix;
483 
484  if( nonUnitColsStartAt0 && !firstRound )
485  modN--; // Start the "tens/hundreds/etc column" at "Ax", not "Bx"
486 
487  itemNum.insert( 0, 1, alphabet[modN] );
488 
489  n /= radix;
490  firstRound = false;
491  } while( n );
492 
493  return itemNum;
494 }
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 513 of file dialog_create_array.cpp.

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

Implements DIALOG_CREATE_ARRAY::ARRAY_OPTIONS.

Definition at line 562 of file dialog_create_array.cpp.

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

563 {
564  wxString itemNum;
565 
566  if( m_2dArrayNumbering )
567  {
568  wxPoint coords = getGridCoords( n );
569 
572  }
573  else
574  {
576  }
577 
578  return itemNum;
579 }
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 497 of file dialog_create_array.cpp.

499 {
500  wxString newStr( aPattern );
501  newStr.Replace( "%s", GetItemNumber( aN ), false );
502 
503  return newStr;
504 }
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 530 of file dialog_create_array.cpp.

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

532 {
533  wxPoint point;
534 
535  wxPoint coords = getGridCoords( n );
536 
537  // swap axes if needed
539  std::swap( coords.x, coords.y );
540 
541  point.x = coords.x * m_delta.x + coords.y * m_offset.x;
542  point.y = coords.y * m_delta.y + coords.x * m_offset.y;
543 
544  if( std::abs( m_stagger ) > 1 )
545  {
546  const int stagger = std::abs( m_stagger );
547  const bool sr = m_stagger_rows;
548  const int stagger_idx = ( ( sr ? coords.y : coords.x ) % stagger );
549 
550  wxPoint stagger_delta( ( sr ? m_delta.x : m_offset.x ),
551  ( sr ? m_offset.y : m_delta.y ) );
552 
553  // Stagger to the left/up if the sign of the stagger is negative
554  point += stagger_delta * copysign( stagger_idx, m_stagger ) / stagger;
555  }
556 
557  // this is already relative to the first array entry
558  item->Move( point );
559 }
#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: