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, 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_reannotateFootprints( false ),
51 m_numberingStartIsSpecified( false )
52 {
53 }
54
55 virtual ~ARRAY_OPTIONS(){};
56
60 struct TRANSFORM
61 {
64 };
65
73 virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
74
78 virtual int GetArraySize() const = 0;
79
86 virtual wxString GetItemNumber( int n ) const = 0;
87
91 bool ShouldNumberItems() const
92 {
93 return m_shouldNumber;
94 }
95
96 void SetShouldNumber( bool aShouldNumber )
97 {
98 m_shouldNumber = aShouldNumber;
99 }
100
106 {
107 return m_reannotateFootprints;
108 }
109
110 void SetSShouldReannotateFootprints( bool aShouldReannotate )
111 {
112 m_reannotateFootprints = aShouldReannotate;
113 }
114
121 {
122 return m_shouldNumber && m_numberingStartIsSpecified;
123 }
124
125 void SetNumberingStartIsSpecified( bool aIsSpecified )
126 {
127 m_numberingStartIsSpecified = aIsSpecified;
128 }
129
130protected:
131
133
136
139
143};
144
145
147{
149 : ARRAY_OPTIONS( ARRAY_GRID ),
150 m_centred( false ),
151 m_nx( 0 ),
152 m_ny( 0 ),
153 m_horizontalThenVertical( true ),
154 m_reverseNumberingAlternate( false ),
155 m_stagger( 0 ),
156 m_stagger_rows( true ),
157 m_2dArrayNumbering( false )
158 {
159 }
160
161 // Are the grid positions relative to item (0, 0), or the grid center?
163 long m_nx, m_ny;
164 bool m_horizontalThenVertical, m_reverseNumberingAlternate;
171
172 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
173 int GetArraySize() const override;
174 wxString GetItemNumber( int n ) const override;
175
176private:
177 VECTOR2I gtItemPosRelativeToItem0( int n ) const;
178 VECTOR2I getGridCoords( int n ) const;
179};
180
181
183{
185 : ARRAY_OPTIONS( ARRAY_CIRCULAR ),
186 m_nPts( 0 ),
187 m_angle( ANGLE_0 ),
188 m_rotateItems( false )
189 {
190 }
191
193 long m_nPts;
194
200
201 TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
202 int GetArraySize() const override;
203 wxString GetItemNumber( int n ) const override;
204};
205
206
207#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:91
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:96
bool ShouldReannotateFootprints() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
bool GetNumberingStartIsSpecified() const
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:55
@ ARRAY_CIRCULAR
A circular array.
Definition: array_options.h:44
@ ARRAY_GRID
A grid (x*y) array.
Definition: array_options.h:43
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:61