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

References alphabetFromNumberingScheme(), and schemeNonUnitColsStartAt0().

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

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

Implements DIALOG_CREATE_ARRAY::ARRAY_OPTIONS.

Definition at line 563 of file dialog_create_array.cpp.

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

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

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

References CONFIG_SAVE_RESTORE_WINDOW::CONFIG_CTRL_T::type.

Referenced by ARRAY_CREATOR::Invoke().

243  {
245  }
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 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 531 of file dialog_create_array.cpp.

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

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

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_delta

Definition at line 279 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_horizontalThenVertical

Definition at line 278 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetX

Definition at line 284 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

int DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_numberingOffsetY

Definition at line 284 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 258 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_nx

Definition at line 277 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_ny

Definition at line 277 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

wxPoint DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_offset

Definition at line 280 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

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::TransferDataFromWindow().

bool DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_reverseNumberingAlternate

Definition at line 278 of file dialog_create_array.h.

Referenced by DIALOG_CREATE_ARRAY::TransferDataFromWindow().

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::TransferDataFromWindow().

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::TransferDataFromWindow().

long DIALOG_CREATE_ARRAY::ARRAY_GRID_OPTIONS::m_stagger

Definition at line 281 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 282 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 211 of file dialog_create_array.h.


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