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 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 
35 {
36 public:
38  {
41  };
42 
43  // NOTE: do not change order relative to charSetDescriptions
45  {
55  };
56 
58  : m_type( aType ), m_shouldNumber( false ), m_numberingStartIsSpecified( false )
59  {
60  }
61 
62  virtual ~ARRAY_OPTIONS(){};
63 
69  static const wxString& AlphabetFromNumberingScheme( NUMBERING_TYPE_T type );
70 
75  static bool SchemeNonUnitColsStartAt0( NUMBERING_TYPE_T type );
76 
84  static bool GetNumberingOffset(
85  const wxString& str, ARRAY_OPTIONS::NUMBERING_TYPE_T type, int& offsetToFill );
86 
90  struct TRANSFORM
91  {
93  double m_rotation; // in degrees
94  };
95 
102  virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
103 
107  virtual int GetArraySize() const = 0;
108 
114  virtual wxString GetItemNumber( int n ) const = 0;
115 
120  bool ShouldNumberItems() const
121  {
122  return m_shouldNumber;
123  }
124 
125  void SetShouldNumber( bool aShouldNumber )
126  {
127  m_shouldNumber = aShouldNumber;
128  }
129 
136  {
138  }
139 
140  void SetNumberingStartIsSpecified( bool aIsSpecified )
141  {
142  m_numberingStartIsSpecified = aIsSpecified;
143  }
144 
145 protected:
146  static wxString getCoordinateNumber( int n, NUMBERING_TYPE_T type );
147 
149 
152 
156 };
157 
158 
160 {
163  m_nx( 0 ),
164  m_ny( 0 ),
165  m_horizontalThenVertical( true ),
167  m_stagger( 0 ),
168  m_stagger_rows( true ),
169  m_2dArrayNumbering( false ),
170  m_numberingOffsetX( 0 ),
171  m_numberingOffsetY( 0 ),
174  {
175  }
176 
177  long m_nx, m_ny;
181  long m_stagger;
186 
187  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
188  int GetArraySize() const override;
189  wxString GetItemNumber( int n ) const override;
190 
191 private:
192  VECTOR2I getGridCoords( int n ) const;
193 };
194 
195 
197 {
200  m_nPts( 0 ),
201  m_angle( 0.0f ),
202  m_rotateItems( false ),
204  m_numberingOffset( 0 )
205  {
206  }
207 
209  long m_nPts;
211  double m_angle;
216 
217  TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
218  int GetArraySize() const override;
219  wxString GetItemNumber( int n ) const override;
220 };
221 
222 
223 #endif // PCBNEW_ARRAY_OPTIONS__H
Transform applied to an object by this array.
Definition: array_options.h:90
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.
ARRAY_OPTIONS(ARRAY_TYPE_T aType)
Definition: array_options.h:57
bool ShouldNumberItems() const
int GetArraySize() const override
The number of points in this array.
NUMBERING_TYPE_T m_secAxisNumType
virtual ~ARRAY_OPTIONS()
Definition: array_options.h:62
virtual int GetArraySize() const =0
The number of points in this array.
const string & str
Definition: json11.cpp:596
wxString GetItemNumber(int n) const override
Get the position number (name) for the n'th array point.
bool m_numberingStartIsSpecified
True if this array's number starts from the preset point False if the array numbering starts from som...
long m_nPts
number of point in the array
A grid (x*y) array.
Definition: array_options.h:39
bool m_shouldNumber
True if this array numbers the new items.
Options that govern the setup of an "array" of multiple item.
Definition: array_options.h:34
virtual wxString GetItemNumber(int n) const =0
Get the position number (name) for the n'th array point.
NUMBERING_TYPE_T m_numberingType
bool m_reverseNumberingAlternate
Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...
Definition: array_options.h:46
static bool SchemeNonUnitColsStartAt0(NUMBERING_TYPE_T type)
static wxString getCoordinateNumber(int n, NUMBERING_TYPE_T type)
VECTOR2I getGridCoords(int n) const
static const wxString & AlphabetFromNumberingScheme(NUMBERING_TYPE_T type)
Get the alphabet for a particular numbering scheme.
static bool GetNumberingOffset(const wxString &str, ARRAY_OPTIONS::NUMBERING_TYPE_T type, int &offsetToFill)
Get the numbering offset for a given numbering string.
virtual TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const =0
Get the transform of the n-th point in the array.
NUMBERING_TYPE_T m_priAxisNumType
ARRAY_TYPE_T m_type
void SetShouldNumber(bool aShouldNumber)
TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const override
Get the transform of the n-th point in the array.
Full 26-character alphabet.
Definition: array_options.h:54
bool GetNumberingStartIsSpecified() const
void SetNumberingStartIsSpecified(bool aIsSpecified)
double 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.