KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, 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
39{
40public:
42 {
45 };
46
48 m_type( aType ),
49 m_shouldNumber( false ),
50 m_arrangeSelection( false ),
51 m_reannotateFootprints( false ),
52 m_numberingStartIsSpecified( false )
53 {
54 }
55
56 virtual ~ARRAY_OPTIONS(){};
57
61 struct TRANSFORM
62 {
65 };
66
74 virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
75
79 virtual int GetArraySize() const = 0;
80
87 virtual wxString GetItemNumber( int n ) const = 0;
88
92 bool ShouldNumberItems() const
93 {
94 return m_shouldNumber;
95 }
96
97 void SetShouldNumber( bool aShouldNumber )
98 {
99 m_shouldNumber = aShouldNumber;
100 }
101
106 {
107 return m_arrangeSelection;
108 }
109
110 void SetShouldArrangeSelection( bool aShouldArrange )
111 {
112 m_arrangeSelection = aShouldArrange;
113 }
114
120 {
121 return m_reannotateFootprints;
122 }
123
124 void SetSShouldReannotateFootprints( bool aShouldReannotate )
125 {
126 m_reannotateFootprints = aShouldReannotate;
127 }
128
135 {
136 return m_shouldNumber && m_numberingStartIsSpecified;
137 }
138
139 void SetNumberingStartIsSpecified( bool aIsSpecified )
140 {
141 m_numberingStartIsSpecified = aIsSpecified;
142 }
143
144protected:
145
147
150
154
157
161};
162
163
165{
167 : ARRAY_OPTIONS( ARRAY_GRID ),
168 m_centred( false ),
169 m_nx( 0 ),
170 m_ny( 0 ),
171 m_horizontalThenVertical( true ),
172 m_reverseNumberingAlternate( false ),
173 m_stagger( 0 ),
174 m_stagger_rows( true ),
175 m_2dArrayNumbering( false )
176 {
177 }
178
179 // Are the grid positions relative to item (0, 0), or the grid center?
181 long m_nx, m_ny;
182 bool m_horizontalThenVertical, m_reverseNumberingAlternate;
189
190 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
191 int GetArraySize() const override;
192 wxString GetItemNumber( int n ) const override;
193
194private:
195 VECTOR2I gtItemPosRelativeToItem0( int n ) const;
196 VECTOR2I getGridCoords( int n ) const;
197};
198
199
201{
203 : ARRAY_OPTIONS( ARRAY_CIRCULAR ),
204 m_nPts( 0 ),
205 m_angle( ANGLE_0 ),
206 m_rotateItems( false )
207 {
208 }
209
211 long m_nPts;
212
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:40
Options that govern the setup of an "array" of multiple item.
Definition: array_options.h:39
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:92
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:97
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()
Definition: array_options.h:56
@ ARRAY_CIRCULAR
A circular array.
Definition: array_options.h:44
@ ARRAY_GRID
A grid (x*y) array.
Definition: array_options.h:43
void SetShouldArrangeSelection(bool aShouldArrange)
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:47
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:401
#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:62