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
 
NUMBERING_TYPE_T m_priAxisNumType
 
NUMBERING_TYPE_T m_secAxisNumType
 
ARRAY_TYPE_T m_type
 

Static Protected Member Functions

static wxString getCoordinateNumber (int n, 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 279 of file dialog_create_array.h.

Constructor & Destructor Documentation

DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::ARRAY_GRID_OPTIONS ( )
inline

Definition at line 281 of file dialog_create_array.h.

281  :
283  m_nx( 0 ), m_ny( 0 ),
284  m_horizontalThenVertical( true ),
286  m_stagger( 0 ),
287  m_stagger_rows( true ),
288  m_2dArrayNumbering( false ),
289  m_numberingOffsetX( 0 ),
290  m_numberingOffsetY( 0 ),
293  {}
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,
NUMBERING_TYPE_T  type 
)
staticprotectedinherited

Definition at line 435 of file dialog_create_array.cpp.

References alphabetFromNumberingScheme(), and schemeNonUnitColsStartAt0().

437 {
438  wxString itemNum;
439  const wxString& alphabet = alphabetFromNumberingScheme( type );
440 
441  const bool nonUnitColsStartAt0 = schemeNonUnitColsStartAt0( type );
442 
443  bool firstRound = true;
444  int radix = alphabet.Length();
445 
446  do {
447  int modN = n % radix;
448 
449  if( nonUnitColsStartAt0 && !firstRound )
450  modN--; // Start the "tens/hundreds/etc column" at "Ax", not "Bx"
451 
452  itemNum.insert( 0, 1, alphabet[modN] );
453 
454  n /= radix;
455  firstRound = false;
456  } while( n );
457 
458  return itemNum;
459 }
static bool schemeNonUnitColsStartAt0(DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type)
static const wxString & alphabetFromNumberingScheme(DIALOG_CREATE_ARRAY::NUMBERING_TYPE_T type)
wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::getGridCoords ( int  n) const
private

Definition at line 478 of file dialog_create_array.cpp.

479 {
480  const int axisSize = m_horizontalThenVertical ? m_nx : m_ny;
481 
482  int x = n % axisSize;
483  int y = n / axisSize;
484 
485  // reverse on this row/col?
486  if( m_reverseNumberingAlternate && ( y % 2 ) )
487  x = axisSize - x - 1;
488 
489  wxPoint coords( x, y );
490 
491  return coords;
492 }
wxString DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::GetItemNumber ( int  n) const
overridevirtual

Implements DIALOG_CREATE_ARRAY::ARRAY_OPTIONS.

Definition at line 527 of file dialog_create_array.cpp.

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

528 {
529  wxString itemNum;
530 
531  if( m_2dArrayNumbering )
532  {
533  wxPoint coords = getGridCoords( n );
534 
537  }
538  else
539  {
541  }
542 
543  return itemNum;
544 }
static wxString getCoordinateNumber(int n, NUMBERING_TYPE_T type)
wxString DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::InterpolateNumberIntoString ( int  n,
const wxString &  pattern 
) const
virtualinherited

Definition at line 462 of file dialog_create_array.cpp.

464 {
465  wxString newStr( aPattern );
466  newStr.Replace( "%s", GetItemNumber( aN ), false );
467 
468  return newStr;
469 }
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 260 of file dialog_create_array.h.

References CONFIG_SAVE_RESTORE_WINDOW::CONFIG_CTRL_T::type.

Referenced by ARRAY_CREATOR::Invoke().

261  {
263  }
bool m_numberingStartIsSpecified
True if this array&#39;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 250 of file dialog_create_array.h.

Referenced by ARRAY_CREATOR::Invoke().

251  {
252  return m_shouldNumber;
253  }
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 495 of file dialog_create_array.cpp.

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

497 {
498  wxPoint point;
499 
500  wxPoint coords = getGridCoords( n );
501 
502  // swap axes if needed
504  std::swap( coords.x, coords.y );
505 
506  point.x = coords.x * m_delta.x + coords.y * m_offset.x;
507  point.y = coords.y * m_delta.y + coords.x * m_offset.y;
508 
509  if( std::abs( m_stagger ) > 1 )
510  {
511  const int stagger = std::abs( m_stagger );
512  const bool sr = m_stagger_rows;
513  const int stagger_idx = ( ( sr ? coords.y : coords.x ) % stagger );
514 
515  wxPoint stagger_delta( ( sr ? m_delta.x : m_offset.x ),
516  ( sr ? m_offset.y : m_delta.y ) );
517 
518  // Stagger to the left/up if the sign of the stagger is negative
519  point += stagger_delta * copysign( stagger_idx, m_stagger ) / stagger;
520  }
521 
522  // this is already relative to the first array entry
523  item->Move( point );
524 }
#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 301 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_delta

Definition at line 297 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_horizontalThenVertical

Definition at line 296 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetX

Definition at line 302 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetY

Definition at line 302 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

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 276 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_nx

Definition at line 295 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_ny

Definition at line 295 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_offset

Definition at line 298 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

NUMBERING_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_priAxisNumType

Definition at line 303 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_reverseNumberingAlternate

Definition at line 296 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

NUMBERING_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_secAxisNumType

Definition at line 303 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::m_shouldNumber
protectedinherited

True if this array numbers the new items.

Definition at line 272 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_stagger

Definition at line 299 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_stagger_rows

Definition at line 300 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

ARRAY_TYPE_T DIALOG_CREATE_ARRAY::ARRAY_OPTIONS::m_type
inherited

Definition at line 229 of file dialog_create_array.h.


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