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-2021 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 ),
47  m_shouldNumber( false ),
48  m_reannotateFootprints( false ),
50  {
51  }
52 
53  virtual ~ARRAY_OPTIONS(){};
54 
58  struct TRANSFORM
59  {
61  double m_rotation; // in degrees
62  };
63 
70  virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
71 
75  virtual int GetArraySize() const = 0;
76 
82  virtual wxString GetItemNumber( int n ) const = 0;
83 
88  bool ShouldNumberItems() const
89  {
90  return m_shouldNumber;
91  }
92 
93  void SetShouldNumber( bool aShouldNumber )
94  {
95  m_shouldNumber = aShouldNumber;
96  }
97 
103  {
104  return m_reannotateFootprints;
105  }
106 
107  void SetSShouldReannotateFootprints( bool aShouldReannotate )
108  {
109  m_reannotateFootprints = aShouldReannotate;
110  }
111 
118  {
120  }
121 
122  void SetNumberingStartIsSpecified( bool aIsSpecified )
123  {
124  m_numberingStartIsSpecified = aIsSpecified;
125  }
126 
127 protected:
128 
130 
133 
136 
140 };
141 
142 
144 {
147  m_nx( 0 ),
148  m_ny( 0 ),
149  m_horizontalThenVertical( true ),
151  m_stagger( 0 ),
152  m_stagger_rows( true ),
153  m_2dArrayNumbering( false )
154  {
155  }
156 
157  long m_nx, m_ny;
161  long m_stagger;
165 
166  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
167  int GetArraySize() const override;
168  wxString GetItemNumber( int n ) const override;
169 
170 private:
171  VECTOR2I getGridCoords( int n ) const;
172 };
173 
174 
176 {
179  m_nPts( 0 ),
180  m_angle( 0.0f ),
181  m_rotateItems( false )
182  {
183  }
184 
186  long m_nPts;
188  double m_angle;
192 
193  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
194  int GetArraySize() const override;
195  wxString GetItemNumber( int n ) const override;
196 };
197 
198 
199 #endif // PCBNEW_ARRAY_OPTIONS__H
Transform applied to an object by this array.
Definition: array_options.h:58
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:88
int GetArraySize() const override
The number of points in this array.
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:53
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
void SetSShouldReannotateFootprints(bool aShouldReannotate)
Class that contains information about a single array axis and the numbering of items along that axis.
Definition: array_axis.h:38
bool ShouldReannotateFootprints() const
bool m_reannotateFootprints
True if this array will rename any footprints to be unique.
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:93
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.