KiCad PCB EDA Suite
array_options.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef PCBNEW_ARRAY_OPTIONS__H
25 #define PCBNEW_ARRAY_OPTIONS__H
26 
27 #include <math/vector2d.h>
28 
29 #include <array_axis.h>
30 
37 {
38 public:
40  {
43  };
44 
46  : m_type( aType ), m_shouldNumber( false ), m_numberingStartIsSpecified( false )
47  {
48  }
49 
50  virtual ~ARRAY_OPTIONS(){};
51 
55  struct TRANSFORM
56  {
58  double m_rotation; // in degrees
59  };
60 
67  virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
68 
72  virtual int GetArraySize() const = 0;
73 
79  virtual wxString GetItemNumber( int n ) const = 0;
80 
85  bool ShouldNumberItems() const
86  {
87  return m_shouldNumber;
88  }
89 
90  void SetShouldNumber( bool aShouldNumber )
91  {
92  m_shouldNumber = aShouldNumber;
93  }
94 
101  {
103  }
104 
105  void SetNumberingStartIsSpecified( bool aIsSpecified )
106  {
107  m_numberingStartIsSpecified = aIsSpecified;
108  }
109 
110 protected:
111 
113 
116 
120 };
121 
122 
124 {
127  m_nx( 0 ),
128  m_ny( 0 ),
129  m_horizontalThenVertical( true ),
131  m_stagger( 0 ),
132  m_stagger_rows( true ),
133  m_2dArrayNumbering( false )
134  {
135  }
136 
137  long m_nx, m_ny;
141  long m_stagger;
145 
146  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
147  int GetArraySize() const override;
148  wxString GetItemNumber( int n ) const override;
149 
150 private:
151  VECTOR2I getGridCoords( int n ) const;
152 };
153 
154 
156 {
159  m_nPts( 0 ),
160  m_angle( 0.0f ),
161  m_rotateItems( false )
162  {
163  }
164 
166  long m_nPts;
168  double m_angle;
172 
173  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
174  int GetArraySize() const override;
175  wxString GetItemNumber( int n ) const override;
176 };
177 
178 
179 #endif // PCBNEW_ARRAY_OPTIONS__H
Transform applied to an object by this array.
Definition: array_options.h:55
int GetArraySize() const override
The number of points in this array.
TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const override
Get the transform of the n-th point in the array.
ARRAY_AXIS m_pri_axis
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:45
bool ShouldNumberItems() const
Definition: array_options.h:85
int GetArraySize() const override
The number of points in this array.
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:50
virtual int GetArraySize() const =0
The number of points in this array.
wxString GetItemNumber(int n) const override
Get the position number (name) for the n'th array point.
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...
long m_nPts
number of point in the array
A grid (x*y) array.
Definition: array_options.h:41
bool m_shouldNumber
True if this array numbers the new items.
Options that govern the setup of an "array" of multiple item.
Definition: array_options.h:36
virtual wxString GetItemNumber(int n) const =0
Get the position number (name) for the n'th array point.
bool m_reverseNumberingAlternate
Class that contains information about a single array axis and the numbering of items along that axis.
Definition: array_axis.h:38
ARRAY_AXIS m_sec_axis
VECTOR2I getGridCoords(int n) const
virtual TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const =0
Get the transform of the n-th point in the array.
ARRAY_TYPE_T m_type
void SetShouldNumber(bool aShouldNumber)
Definition: array_options.h:90
TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const override
Get the transform of the n-th point in the array.
bool GetNumberingStartIsSpecified() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
double m_angle
angle between points, or 0 for each point separated by this value (decideg)
wxString GetItemNumber(int n) const override
Get the position number (name) for the n'th array point.