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#include <array_axis.h>
29#include <geometry/eda_angle.h>
30
37{
38public:
40 {
43 };
44
46 m_type( aType ),
47 m_shouldNumber( false ),
50 {
51 }
52
53 virtual ~ARRAY_OPTIONS(){};
54
58 struct TRANSFORM
59 {
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 {
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
127protected:
128
130
133
136
140};
141
142
144{
147 m_nx( 0 ),
148 m_ny( 0 ),
151 m_stagger( 0 ),
152 m_stagger_rows( true ),
153 m_2dArrayNumbering( false )
154 {
155 }
156
157 long m_nx, m_ny;
165
166 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
167 int GetArraySize() const override;
168 wxString GetItemNumber( int n ) const override;
169
170private:
171 VECTOR2I getGridCoords( int n ) const;
172};
173
174
176{
179 m_nPts( 0 ),
180 m_angle( ANGLE_0 ),
181 m_rotateItems( false )
182 {
183 }
184
186 long m_nPts;
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
Class that contains information about a single array axis and the numbering of items along that axis.
Definition: array_axis.h:39
Options that govern the setup of an "array" of multiple item.
Definition: array_options.h:37
virtual int GetArraySize() const =0
The number of points in this array.
void SetSShouldReannotateFootprints(bool aShouldReannotate)
bool m_shouldNumber
True if this array numbers the new items.
bool ShouldNumberItems() const
Definition: array_options.h:88
virtual wxString GetItemNumber(int n) const =0
Get the position number (name) for the n'th array point.
virtual TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const =0
Get the transform of the n-th point in the array.
void SetShouldNumber(bool aShouldNumber)
Definition: array_options.h:93
bool ShouldReannotateFootprints() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
bool GetNumberingStartIsSpecified() const
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:53
@ ARRAY_CIRCULAR
A circular array.
Definition: array_options.h:42
@ ARRAY_GRID
A grid (x*y) array.
Definition: array_options.h:41
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:45
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...
ARRAY_TYPE_T m_type
bool m_reannotateFootprints
True if this array will rename any footprints to be unique.
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
long m_nPts
number of point in the array
EDA_ANGLE 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.
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.
VECTOR2I getGridCoords(int n) const
bool m_reverseNumberingAlternate
wxString GetItemNumber(int n) const override
Get the position number (name) for the n'th array point.
ARRAY_AXIS m_sec_axis
ARRAY_AXIS m_pri_axis
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.
Transform applied to an object by this array.
Definition: array_options.h:59