2019-01-24 18:15:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-10-24 19:59:19 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-01-24 18:15:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PCBNEW_ARRAY_OPTIONS__H
|
|
|
|
#define PCBNEW_ARRAY_OPTIONS__H
|
|
|
|
|
2023-09-10 18:41:18 +00:00
|
|
|
#include <kicommon.h>
|
2019-01-24 18:15:21 +00:00
|
|
|
#include <math/vector2d.h>
|
2019-05-15 10:47:45 +00:00
|
|
|
#include <array_axis.h>
|
2022-01-15 01:12:24 +00:00
|
|
|
#include <geometry/eda_angle.h>
|
2019-05-15 10:47:45 +00:00
|
|
|
|
2019-01-24 18:15:21 +00:00
|
|
|
/**
|
|
|
|
* Options that govern the setup of an "array" of multiple item.
|
|
|
|
* The base #ARRAY_OPTIONS do not encode a specific geometry or numbering
|
|
|
|
* method, this is done by derived classes.
|
|
|
|
*/
|
2023-09-10 18:41:18 +00:00
|
|
|
class KICOMMON_API ARRAY_OPTIONS
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum ARRAY_TYPE_T
|
|
|
|
{
|
|
|
|
ARRAY_GRID, ///< A grid (x*y) array
|
|
|
|
ARRAY_CIRCULAR, ///< A circular array
|
|
|
|
};
|
|
|
|
|
2021-10-29 14:43:40 +00:00
|
|
|
ARRAY_OPTIONS( ARRAY_TYPE_T aType ) :
|
|
|
|
m_type( aType ),
|
|
|
|
m_shouldNumber( false ),
|
|
|
|
m_reannotateFootprints( false ),
|
|
|
|
m_numberingStartIsSpecified( false )
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ARRAY_OPTIONS(){};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform applied to an object by this array
|
|
|
|
*/
|
|
|
|
struct TRANSFORM
|
|
|
|
{
|
2022-01-13 23:30:52 +00:00
|
|
|
VECTOR2I m_offset;
|
|
|
|
EDA_ANGLE m_rotation;
|
2019-01-24 18:15:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the transform of the n-th point in the array
|
|
|
|
* @param aN the index of the array point (0 is the original point)
|
|
|
|
* @param aPos the existing item position
|
|
|
|
* @return a transform (an offset and a rotation)
|
|
|
|
*/
|
|
|
|
virtual TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of points in this array
|
|
|
|
*/
|
|
|
|
virtual int GetArraySize() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the position number (name) for the n'th array point
|
|
|
|
* @param n array point index, from 0 to GetArraySize() - 1
|
|
|
|
* @return the point's name
|
|
|
|
*/
|
|
|
|
virtual wxString GetItemNumber( int n ) const = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @return are the items in this array numbered, or are all the
|
|
|
|
* items numbered the same?
|
|
|
|
*/
|
|
|
|
bool ShouldNumberItems() const
|
|
|
|
{
|
|
|
|
return m_shouldNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShouldNumber( bool aShouldNumber )
|
|
|
|
{
|
|
|
|
m_shouldNumber = aShouldNumber;
|
|
|
|
}
|
|
|
|
|
2021-10-24 19:59:19 +00:00
|
|
|
/*!
|
|
|
|
* @return are the footprints in this array reannotated to be unique (true), or do they
|
|
|
|
* keep the original annotation (false)?
|
|
|
|
*/
|
|
|
|
bool ShouldReannotateFootprints() const
|
|
|
|
{
|
|
|
|
return m_reannotateFootprints;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSShouldReannotateFootprints( bool aShouldReannotate )
|
|
|
|
{
|
|
|
|
m_reannotateFootprints = aShouldReannotate;
|
|
|
|
}
|
|
|
|
|
2019-01-24 18:15:21 +00:00
|
|
|
/*!
|
|
|
|
* @return is the numbering is enabled and should start at a point
|
|
|
|
* specified in these options or is it implicit according to the calling
|
|
|
|
* code?
|
|
|
|
*/
|
|
|
|
bool GetNumberingStartIsSpecified() const
|
|
|
|
{
|
|
|
|
return m_shouldNumber && m_numberingStartIsSpecified;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetNumberingStartIsSpecified( bool aIsSpecified )
|
|
|
|
{
|
|
|
|
m_numberingStartIsSpecified = aIsSpecified;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
ARRAY_TYPE_T m_type;
|
|
|
|
|
|
|
|
/// True if this array numbers the new items
|
|
|
|
bool m_shouldNumber;
|
|
|
|
|
2021-10-24 19:59:19 +00:00
|
|
|
/// True if this array will rename any footprints to be unique
|
|
|
|
bool m_reannotateFootprints;
|
|
|
|
|
2019-01-24 18:15:21 +00:00
|
|
|
/// True if this array's number starts from the preset point
|
|
|
|
/// False if the array numbering starts from some externally provided point
|
|
|
|
bool m_numberingStartIsSpecified;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-09-10 18:41:18 +00:00
|
|
|
struct KICOMMON_API ARRAY_GRID_OPTIONS : public ARRAY_OPTIONS
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
ARRAY_GRID_OPTIONS()
|
|
|
|
: ARRAY_OPTIONS( ARRAY_GRID ),
|
|
|
|
m_nx( 0 ),
|
|
|
|
m_ny( 0 ),
|
|
|
|
m_horizontalThenVertical( true ),
|
|
|
|
m_reverseNumberingAlternate( false ),
|
|
|
|
m_stagger( 0 ),
|
|
|
|
m_stagger_rows( true ),
|
2019-05-15 10:47:45 +00:00
|
|
|
m_2dArrayNumbering( false )
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
long m_nx, m_ny;
|
|
|
|
bool m_horizontalThenVertical, m_reverseNumberingAlternate;
|
|
|
|
VECTOR2I m_delta;
|
|
|
|
VECTOR2I m_offset;
|
|
|
|
long m_stagger;
|
|
|
|
bool m_stagger_rows;
|
|
|
|
bool m_2dArrayNumbering;
|
2019-05-15 10:47:45 +00:00
|
|
|
ARRAY_AXIS m_pri_axis, m_sec_axis;
|
2019-01-24 18:15:21 +00:00
|
|
|
|
|
|
|
TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
|
|
|
|
int GetArraySize() const override;
|
|
|
|
wxString GetItemNumber( int n ) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
VECTOR2I getGridCoords( int n ) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-09-10 18:41:18 +00:00
|
|
|
struct KICOMMON_API ARRAY_CIRCULAR_OPTIONS : public ARRAY_OPTIONS
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
ARRAY_CIRCULAR_OPTIONS()
|
|
|
|
: ARRAY_OPTIONS( ARRAY_CIRCULAR ),
|
|
|
|
m_nPts( 0 ),
|
2022-01-13 23:30:52 +00:00
|
|
|
m_angle( ANGLE_0 ),
|
2019-05-15 10:47:45 +00:00
|
|
|
m_rotateItems( false )
|
2019-01-24 18:15:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// number of point in the array
|
|
|
|
long m_nPts;
|
|
|
|
/// angle between points, or 0 for each point separated by this value (decideg)
|
2022-01-13 23:30:52 +00:00
|
|
|
EDA_ANGLE m_angle;
|
2019-01-24 18:15:21 +00:00
|
|
|
VECTOR2I m_centre;
|
|
|
|
bool m_rotateItems;
|
2019-05-15 10:47:45 +00:00
|
|
|
ARRAY_AXIS m_axis;
|
2019-01-24 18:15:21 +00:00
|
|
|
|
|
|
|
TRANSFORM GetTransform( int aN, const VECTOR2I& aPos ) const override;
|
|
|
|
int GetArraySize() const override;
|
|
|
|
wxString GetItemNumber( int n ) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-10-29 14:43:40 +00:00
|
|
|
#endif // PCBNEW_ARRAY_OPTIONS__H
|