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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PCBNEW_ARRAY_OPTIONS__H
21#define PCBNEW_ARRAY_OPTIONS__H
22
23#include <kicommon.h>
24#include <math/vector2d.h>
25#include <array_axis.h>
26#include <geometry/eda_angle.h>
27
35{
36public:
42
44 m_type( aType ),
45 m_shouldNumber( false ),
46 m_arrangeSelection( false ),
49 {
50 }
51
52 virtual ~ARRAY_OPTIONS(){};
53
62
70 virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
71
75 virtual int GetArraySize() const = 0;
76
83 virtual wxString GetItemNumber( int n ) const = 0;
84
88 bool ShouldNumberItems() const
89 {
90 return m_shouldNumber;
91 }
92
93 void SetShouldNumber( bool aShouldNumber )
94 {
95 m_shouldNumber = aShouldNumber;
96 }
97
102 {
103 return m_arrangeSelection;
104 }
105
106 void SetShouldArrangeSelection( bool aShouldArrange )
107 {
108 m_arrangeSelection = aShouldArrange;
109 }
110
116 {
118 }
119
120 void SetSShouldReannotateFootprints( bool aShouldReannotate )
121 {
122 m_reannotateFootprints = aShouldReannotate;
123 }
124
134
135 void SetNumberingStartIsSpecified( bool aIsSpecified )
136 {
137 m_numberingStartIsSpecified = aIsSpecified;
138 }
139
140protected:
141
143
146
150
153
157};
158
159
161{
164 m_centred( false ),
165 m_nx( 0 ),
166 m_ny( 0 ),
169 m_stagger( 0 ),
170 m_stagger_rows( true ),
171 m_2dArrayNumbering( false )
172 {
173 }
174
175 // Are the grid positions relative to item (0, 0), or the grid center?
177 long m_nx, m_ny;
185
186 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
187 int GetArraySize() const override;
188 wxString GetItemNumber( int n ) const override;
189
190private:
191 VECTOR2I gtItemPosRelativeToItem0( int n ) const;
192 VECTOR2I getGridCoords( int n ) const;
193};
194
195
197{
200 m_nPts( 0 ),
201 m_angle( ANGLE_0 ),
203 m_clockwise( false ),
204 m_rotateItems( false )
205 {
206 }
207
209 long m_nPts;
210
218
219 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
220 int GetArraySize() const override;
221 wxString GetItemNumber( int n ) const override;
222};
223
224
225#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:36
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
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)
bool ShouldReannotateFootprints() const
bool ShouldArrangeSelection() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
bool m_arrangeSelection
True if this array should arrange the selected items instead of creating an array of copies of the se...
bool GetNumberingStartIsSpecified() const
virtual ~ARRAY_OPTIONS()
@ ARRAY_CIRCULAR
A circular array.
@ ARRAY_GRID
A grid (x*y) array.
void SetShouldArrangeSelection(bool aShouldArrange)
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
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:411
#define KICOMMON_API
Definition kicommon.h:27
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
wxString GetItemNumber(int n) const override
Get the position number (name) for the n'th array point.
VECTOR2I gtItemPosRelativeToItem0(int n) const
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.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683