KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <kicommon.h>
28#include <math/vector2d.h>
29#include <array_axis.h>
30#include <geometry/eda_angle.h>
31
38{
39public:
41 {
44 };
45
47 m_type( aType ),
48 m_shouldNumber( false ),
49 m_reannotateFootprints( false ),
50 m_numberingStartIsSpecified( false )
51 {
52 }
53
54 virtual ~ARRAY_OPTIONS(){};
55
59 struct TRANSFORM
60 {
63 };
64
71 virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
72
76 virtual int GetArraySize() const = 0;
77
83 virtual wxString GetItemNumber( int n ) const = 0;
84
89 bool ShouldNumberItems() const
90 {
91 return m_shouldNumber;
92 }
93
94 void SetShouldNumber( bool aShouldNumber )
95 {
96 m_shouldNumber = aShouldNumber;
97 }
98
104 {
105 return m_reannotateFootprints;
106 }
107
108 void SetSShouldReannotateFootprints( bool aShouldReannotate )
109 {
110 m_reannotateFootprints = aShouldReannotate;
111 }
112
119 {
120 return m_shouldNumber && m_numberingStartIsSpecified;
121 }
122
123 void SetNumberingStartIsSpecified( bool aIsSpecified )
124 {
125 m_numberingStartIsSpecified = aIsSpecified;
126 }
127
128protected:
129
131
134
137
141};
142
143
145{
147 : ARRAY_OPTIONS( ARRAY_GRID ),
148 m_nx( 0 ),
149 m_ny( 0 ),
150 m_horizontalThenVertical( true ),
151 m_reverseNumberingAlternate( false ),
152 m_stagger( 0 ),
153 m_stagger_rows( true ),
154 m_2dArrayNumbering( false )
155 {
156 }
157
158 long m_nx, m_ny;
159 bool m_horizontalThenVertical, m_reverseNumberingAlternate;
166
167 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
168 int GetArraySize() const override;
169 wxString GetItemNumber( int n ) const override;
170
171private:
172 VECTOR2I getGridCoords( int n ) const;
173};
174
175
177{
179 : ARRAY_OPTIONS( ARRAY_CIRCULAR ),
180 m_nPts( 0 ),
181 m_angle( ANGLE_0 ),
182 m_rotateItems( false )
183 {
184 }
185
187 long m_nPts;
193
194 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
195 int GetArraySize() const override;
196 wxString GetItemNumber( int n ) const override;
197};
198
199
200#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:40
Options that govern the setup of an "array" of multiple item.
Definition: array_options.h:38
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:89
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:94
bool ShouldReannotateFootprints() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
bool GetNumberingStartIsSpecified() const
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:54
@ ARRAY_CIRCULAR
A circular array.
Definition: array_options.h:43
@ ARRAY_GRID
A grid (x*y) array.
Definition: array_options.h:42
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:46
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:435
#define KICOMMON_API
Definition: kicommon.h:28
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)
ARRAY_AXIS m_pri_axis
Transform applied to an object by this array.
Definition: array_options.h:60