2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-05-02 08:31:10 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +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
|
|
|
|
*/
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
#ifndef PAD_H
|
|
|
|
#define PAD_H
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-12-28 21:02:06 +00:00
|
|
|
#include <mutex>
|
2020-11-12 22:30:02 +00:00
|
|
|
#include <zones.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_connected_item.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <convert_to_biu.h>
|
2018-12-12 14:28:59 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2020-07-22 23:05:22 +00:00
|
|
|
#include <geometry/shape_compound.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <pad_shapes.h>
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
class PCB_SHAPE;
|
2020-01-12 18:40:50 +00:00
|
|
|
class PARAM_CFG;
|
2020-06-22 19:35:09 +00:00
|
|
|
class SHAPE;
|
|
|
|
class SHAPE_SEGMENT;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
enum CUST_PAD_SHAPE_IN_ZONE
|
|
|
|
{
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE_OUTLINE,
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
|
|
|
|
};
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class LINE_READER;
|
2011-09-17 15:31:21 +00:00
|
|
|
class EDA_3D_CANVAS;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-10-04 23:34:59 +00:00
|
|
|
class FP_SHAPE;
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class VIEW;
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD : public BOARD_CONNECTED_ITEM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-13 15:15:52 +00:00
|
|
|
PAD( FOOTPRINT* parent );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-07-24 16:02:56 +00:00
|
|
|
// Copy constructor & operator= are needed because the list of basic shapes
|
|
|
|
// must be duplicated in copy.
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD( const PAD& aPad );
|
|
|
|
PAD& operator=( const PAD &aOther );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/*
|
|
|
|
* Default layers used for pads, according to the pad type.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* This is default values only, they can be changed for a given pad.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2021-01-27 22:15:38 +00:00
|
|
|
static LSET PTHMask(); ///< layer set for a through hole pad
|
2014-07-02 13:08:28 +00:00
|
|
|
static LSET SMDMask(); ///< layer set for a SMD pad on Front layer
|
|
|
|
static LSET ConnSMDMask(); ///< layer set for a SMD pad on Front layer
|
|
|
|
///< used for edge board connectors
|
|
|
|
static LSET UnplatedHoleMask(); ///< layer set for a mechanical unplated through hole pad
|
2018-07-24 13:56:20 +00:00
|
|
|
static LSET ApertureMask(); ///< layer set for an aperture pad
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
2015-02-17 23:53:57 +00:00
|
|
|
{
|
|
|
|
return aItem && PCB_PAD_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
bool IsType( const KICAD_T aScanTypes[] ) const override
|
|
|
|
{
|
|
|
|
if( BOARD_CONNECTED_ITEM::IsType( aScanTypes ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
|
|
|
{
|
2020-07-31 12:37:22 +00:00
|
|
|
if( m_drill.x > 0 && m_drill.y > 0 )
|
2020-05-15 23:25:33 +00:00
|
|
|
{
|
|
|
|
if( *p == PCB_LOCATE_HOLE_T )
|
|
|
|
return true;
|
2021-05-01 14:46:50 +00:00
|
|
|
else if( *p == PCB_LOCATE_PTH_T && m_attribute != PAD_ATTRIB::NPTH )
|
2020-05-15 23:25:33 +00:00
|
|
|
return true;
|
2021-05-01 14:46:50 +00:00
|
|
|
else if( *p == PCB_LOCATE_NPTH_T && m_attribute == PAD_ATTRIB::NPTH )
|
2020-05-15 23:25:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* GetParent() const;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2021-02-19 21:06:28 +00:00
|
|
|
wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
|
|
|
|
|
2020-12-15 22:32:02 +00:00
|
|
|
bool IsLocked() const override;
|
|
|
|
|
2017-02-10 19:44:02 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Import the pad settings from \a aMasterPad.
|
|
|
|
*
|
|
|
|
* The result is "this" has the same settings (sizes, shapes ... ) as \a aMasterPad.
|
|
|
|
*
|
|
|
|
* @param aMasterPad the template pad.
|
2017-02-10 19:44:02 +00:00
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
void ImportSettingsFrom( const PAD& aMasterPad );
|
2017-02-10 19:44:02 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return true if the pad has a footprint parent flipped on the back/bottom layer.
|
2016-04-06 18:15:49 +00:00
|
|
|
*/
|
2017-01-21 20:19:46 +00:00
|
|
|
bool IsFlipped() const;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2015-11-13 11:32:42 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the pad name (sometimes called pad number, although it can be an array reference
|
|
|
|
* like AA12).
|
2015-11-13 11:32:42 +00:00
|
|
|
*/
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetName( const wxString& aName ) { m_name = aName; }
|
|
|
|
const wxString& GetName() const { return m_name; }
|
2015-11-13 11:32:42 +00:00
|
|
|
|
2019-11-17 09:11:29 +00:00
|
|
|
/**
|
|
|
|
* Set the pad function (pin name in schematic)
|
|
|
|
*/
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetPinFunction( const wxString& aName ) { m_pinFunction = aName; }
|
|
|
|
const wxString& GetPinFunction() const { return m_pinFunction; }
|
2019-11-17 09:11:29 +00:00
|
|
|
|
2021-01-21 21:46:03 +00:00
|
|
|
/**
|
|
|
|
* Set the pad electrical type
|
|
|
|
*/
|
|
|
|
void SetPinType( const wxString& aType ) { m_pinType = aType; }
|
|
|
|
const wxString& GetPinType() const { return m_pinType; }
|
|
|
|
|
2020-09-29 12:07:55 +00:00
|
|
|
/**
|
|
|
|
* Before we had custom pad shapes it was common to have multiple overlapping pads to
|
|
|
|
* represent a more complex shape.
|
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
bool SameLogicalPadAs( const PAD* other ) const
|
2011-12-16 17:03:25 +00:00
|
|
|
{
|
2020-09-29 12:07:55 +00:00
|
|
|
// hide tricks behind sensible API
|
|
|
|
return GetParent() == other->GetParent() && m_name == other->m_name;
|
2011-12-16 17:03:25 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
/**
|
2020-06-25 17:16:03 +00:00
|
|
|
* Set the new shape of this pad.
|
|
|
|
*/
|
2021-05-01 12:22:35 +00:00
|
|
|
void SetShape( PAD_SHAPE aShape )
|
2020-06-25 17:16:03 +00:00
|
|
|
{
|
|
|
|
m_padShape = aShape;
|
2021-01-08 00:26:32 +00:00
|
|
|
SetDirty();
|
2020-06-25 17:16:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-14 19:45:05 +00:00
|
|
|
* @return the shape of this pad.
|
|
|
|
*/
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE GetShape() const { return m_padShape; }
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2020-06-25 17:16:03 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) override
|
|
|
|
{
|
2020-07-31 12:37:22 +00:00
|
|
|
m_pos = aPos;
|
2021-01-08 00:26:32 +00:00
|
|
|
SetDirty();
|
2020-06-25 17:16:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
wxPoint GetPosition() const override { return m_pos; }
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
/**
|
|
|
|
* @return the shape of the anchor pad shape, for custom shaped pads.
|
|
|
|
*/
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE GetAnchorPadShape() const { return m_anchorPadShape; }
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return the option for the custom pad shape to use as clearance area in copper zones.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
|
|
|
|
{
|
|
|
|
return m_customShapeClearanceArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the option for the custom pad shape to use as clearance area in copper zones.
|
|
|
|
*
|
2017-01-13 17:51:22 +00:00
|
|
|
* @param aOption is the clearance area shape CUST_PAD_SHAPE_IN_ZONE option
|
|
|
|
*/
|
|
|
|
void SetCustomShapeInZoneOpt( CUST_PAD_SHAPE_IN_ZONE aOption )
|
|
|
|
{
|
|
|
|
m_customShapeClearanceArea = aOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the shape of the anchor pad for custom shaped pads.
|
|
|
|
*
|
2021-05-01 12:22:35 +00:00
|
|
|
* @param aShape is the shape of the anchor pad shape( currently, only #PAD_SHAPE::RECT or
|
|
|
|
* #PAD_SHAPE::CIRCLE.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2021-05-01 12:22:35 +00:00
|
|
|
void SetAnchorPadShape( PAD_SHAPE aShape )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
m_anchorPadShape = ( aShape == PAD_SHAPE::RECT ) ? PAD_SHAPE::RECT : PAD_SHAPE::CIRCLE;
|
2021-01-08 00:26:32 +00:00
|
|
|
SetDirty();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 11:08:41 +00:00
|
|
|
/**
|
|
|
|
* @return true if the pad is on any copper layer, false otherwise.
|
|
|
|
*/
|
|
|
|
bool IsOnCopperLayer() const override
|
|
|
|
{
|
|
|
|
return ( GetLayerSet() & LSET::AllCuMask() ) != 0;
|
|
|
|
}
|
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetY( int y ) { m_pos.y = y; SetDirty(); }
|
|
|
|
void SetX( int x ) { m_pos.x = x; SetDirty(); }
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetPos0( const wxPoint& aPos ) { m_pos0 = aPos; }
|
|
|
|
const wxPoint& GetPos0() const { return m_pos0; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetY0( int y ) { m_pos0.y = y; }
|
|
|
|
void SetX0( int x ) { m_pos0.x = x; }
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetSize( const wxSize& aSize ) { m_size = aSize; SetDirty(); }
|
2020-07-31 12:37:22 +00:00
|
|
|
const wxSize& GetSize() const { return m_size; }
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetSizeX( const int aX ) { m_size.x = aX; SetDirty(); }
|
2020-10-16 23:13:15 +00:00
|
|
|
const int GetSizeX() const { return m_size.x; }
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetSizeY( const int aY ) { m_size.y = aY; SetDirty(); }
|
2020-10-16 23:13:15 +00:00
|
|
|
const int GetSizeY() const { return m_size.y; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetDelta( const wxSize& aSize ) { m_deltaSize = aSize; SetDirty(); }
|
2020-07-31 12:37:22 +00:00
|
|
|
const wxSize& GetDelta() const { return m_deltaSize; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetDrillSize( const wxSize& aSize ) { m_drill = aSize; SetDirty(); }
|
2020-07-31 12:37:22 +00:00
|
|
|
const wxSize& GetDrillSize() const { return m_drill; }
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetDrillSizeX( const int aX ) { m_drill.x = aX; SetDirty(); }
|
2020-10-16 23:13:15 +00:00
|
|
|
const int GetDrillSizeX() const { return m_drill.x; }
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetDrillSizeY( const int aY ) { m_drill.y = aY; SetDirty(); }
|
2020-10-16 23:13:15 +00:00
|
|
|
const int GetDrillSizeY() const { return m_drill.y; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
void SetOffset( const wxPoint& aOffset ) { m_offset = aOffset; SetDirty(); }
|
2020-07-31 12:37:22 +00:00
|
|
|
const wxPoint& GetOffset() const { return m_offset; }
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-10-06 16:38:24 +00:00
|
|
|
wxPoint GetCenter() const override { return GetPosition(); }
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
/**
|
2020-07-03 15:12:28 +00:00
|
|
|
* Has meaning only for custom shape pads.
|
2017-01-13 17:51:22 +00:00
|
|
|
* add a free shape to the shape list.
|
|
|
|
* the shape can be
|
2021-01-27 22:15:38 +00:00
|
|
|
* - a polygon (outline can have a thickness)
|
|
|
|
* - a thick segment
|
|
|
|
* - a filled circle (thickness == 0) or ring
|
|
|
|
* - a filled rect (thickness == 0) or rectangular outline
|
|
|
|
* - a arc
|
|
|
|
* - a bezier curve
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2020-11-14 01:16:02 +00:00
|
|
|
void AddPrimitivePoly( const SHAPE_POLY_SET& aPoly, int aThickness, bool aFilled );
|
|
|
|
void AddPrimitivePoly( const std::vector<wxPoint>& aPoly, int aThickness, bool aFilled );
|
2020-06-22 19:35:09 +00:00
|
|
|
void AddPrimitiveSegment( const wxPoint& aStart, const wxPoint& aEnd, int aThickness );
|
2020-11-14 01:16:02 +00:00
|
|
|
void AddPrimitiveCircle( const wxPoint& aCenter, int aRadius, int aThickness, bool aFilled );
|
|
|
|
void AddPrimitiveRect( const wxPoint& aStart, const wxPoint& aEnd, int aThickness,
|
|
|
|
bool aFilled );
|
2020-06-19 15:09:25 +00:00
|
|
|
void AddPrimitiveArc( const wxPoint& aCenter, const wxPoint& aStart, int aArcAngle,
|
2020-06-22 19:35:09 +00:00
|
|
|
int aThickness );
|
2020-06-19 15:09:25 +00:00
|
|
|
void AddPrimitiveCurve( const wxPoint& aStart, const wxPoint& aEnd, const wxPoint& aCtrl1,
|
2020-06-22 19:35:09 +00:00
|
|
|
const wxPoint& aCtrl2, int aThickness );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
|
2017-10-19 21:16:06 +00:00
|
|
|
bool GetBestAnchorPosition( VECTOR2I& aPos );
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Merge all basic shapes to a #SHAPE_POLY_SET.
|
|
|
|
*
|
|
|
|
* @note The results are relative to the pad position, orientation 0.
|
2021-04-18 16:54:36 +00:00
|
|
|
*
|
|
|
|
* @param aMergedPolygon will store the final polygon
|
|
|
|
* @param aLayer is the layer to take in account, as the exact shape can depend on the layer
|
|
|
|
* @param aErrorLoc is used when a circle (or arc) is approximated by segments
|
|
|
|
* = ERROR_INSIDE to build a polygon inside the arc/circle (usual shape to raw/plot)
|
|
|
|
* = ERROR_OUIDE to build a polygon outside the arc/circle
|
|
|
|
* (for instance when building a clearance area)
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2021-04-18 16:54:36 +00:00
|
|
|
void MergePrimitivesAsPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
|
|
|
|
ERROR_LOC aErrorLoc = ERROR_INSIDE ) const;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Clear the basic shapes list.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2017-09-20 08:28:52 +00:00
|
|
|
void DeletePrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-07 21:20:55 +00:00
|
|
|
* Accessor to the basic shape list for custom-shaped pads.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
const std::vector<std::shared_ptr<PCB_SHAPE>>& GetPrimitives() const
|
2020-06-24 11:12:39 +00:00
|
|
|
{
|
|
|
|
return m_editPrimitives;
|
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-07-12 21:02:10 +00:00
|
|
|
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
|
2011-12-02 21:56:47 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
/**
|
2020-07-25 15:41:36 +00:00
|
|
|
* Flip (mirror) the primitives left to right or top to bottom, around the anchor position
|
2021-01-27 22:15:38 +00:00
|
|
|
* in custom pads.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2020-07-25 15:41:36 +00:00
|
|
|
void FlipPrimitives( bool aFlipLeftRight );
|
2019-01-17 04:55:40 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
/**
|
2020-09-07 21:20:55 +00:00
|
|
|
* Clear the current custom shape primitives list and import a new list. Copies the input,
|
|
|
|
* which is not altered.
|
2017-01-13 17:51:22 +00:00
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
void ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2018-03-06 13:58:25 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Import a custom shape primitive list (composed of basic shapes) and add items to the
|
2020-09-07 21:20:55 +00:00
|
|
|
* current list. Copies the input, which is not altered.
|
2020-07-24 16:02:56 +00:00
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
void AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList );
|
2020-07-24 16:02:56 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-07 21:20:55 +00:00
|
|
|
* Add item to the custom shape primitives list
|
2018-03-06 13:58:25 +00:00
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
void AddPrimitive( PCB_SHAPE* aPrimitive );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2011-12-02 21:56:47 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the rotation angle of the pad.
|
|
|
|
*
|
|
|
|
* If \a aAngle is outside of 0 - 3600, then it will be normalized.
|
|
|
|
*
|
|
|
|
* @param aAngle in tenths of degrees.
|
2011-12-02 21:56:47 +00:00
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
void SetOrientation( double aAngle );
|
2011-12-02 21:56:47 +00:00
|
|
|
|
2016-05-02 10:49:14 +00:00
|
|
|
/**
|
2020-09-07 21:20:55 +00:00
|
|
|
* Set orientation in degrees.
|
2016-05-02 10:49:14 +00:00
|
|
|
*/
|
|
|
|
void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); }
|
|
|
|
|
2011-12-02 21:56:47 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the rotation angle of the pad in a variety of units (the basic call returns
|
2020-09-07 21:20:55 +00:00
|
|
|
* tenths of degrees).
|
2011-12-02 21:56:47 +00:00
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
double GetOrientation() const { return m_orient; }
|
|
|
|
double GetOrientationDegrees() const { return m_orient/10.0; }
|
|
|
|
double GetOrientationRadians() const { return m_orient*M_PI/1800; }
|
2011-12-02 21:56:47 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetDrillShape( PAD_DRILL_SHAPE_T aShape ) { m_drillShape = aShape; m_shapesDirty = true; }
|
2014-01-26 14:20:58 +00:00
|
|
|
PAD_DRILL_SHAPE_T GetDrillShape() const { return m_drillShape; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
bool IsDirty() const
|
|
|
|
{
|
|
|
|
return m_shapesDirty || m_polyDirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDirty()
|
|
|
|
{
|
|
|
|
m_shapesDirty = true;
|
|
|
|
m_polyDirty = true;
|
|
|
|
}
|
2020-06-28 18:00:40 +00:00
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
void SetLayerSet( LSET aLayers ) override { m_layerMask = aLayers; }
|
2016-09-24 18:53:15 +00:00
|
|
|
LSET GetLayerSet() const override { return m_layerMask; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
void SetAttribute( PAD_ATTRIB aAttribute );
|
|
|
|
PAD_ATTRIB GetAttribute() const { return m_attribute; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
void SetProperty( PAD_PROP aProperty );
|
|
|
|
PAD_PROP GetProperty() const { return m_property; }
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2018-07-24 13:56:20 +00:00
|
|
|
// We don't currently have an attribute for APERTURE, and adding one will change the file
|
|
|
|
// format, so for now just infer a copper-less pad to be an APERTURE pad.
|
2021-01-27 22:15:38 +00:00
|
|
|
bool IsAperturePad() const
|
|
|
|
{
|
|
|
|
return ( m_layerMask & LSET::AllCuMask() ).none();
|
|
|
|
}
|
2018-07-24 13:56:20 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetPadToDieLength( int aLength ) { m_lengthPadToDie = aLength; }
|
|
|
|
int GetPadToDieLength() const { return m_lengthPadToDie; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
int GetLocalSolderMaskMargin() const { return m_localSolderMaskMargin; }
|
|
|
|
void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2020-09-05 16:00:29 +00:00
|
|
|
int GetLocalClearance( wxString* aSource ) const override;
|
|
|
|
int GetLocalClearance() const { return m_localClearance; }
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetLocalClearance( int aClearance ) { m_localClearance = aClearance; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
int GetLocalSolderPasteMargin() const { return m_localSolderPasteMargin; }
|
|
|
|
void SetLocalSolderPasteMargin( int aMargin ) { m_localSolderPasteMargin = aMargin; }
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
double GetLocalSolderPasteMarginRatio() const { return m_localSolderPasteMarginRatio; }
|
|
|
|
void SetLocalSolderPasteMarginRatio( double aRatio ) { m_localSolderPasteMarginRatio = aRatio; }
|
2011-12-01 06:04:23 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2020-06-22 19:35:09 +00:00
|
|
|
* Convert the pad shape to a closed polygon. Circles and arcs are approximated by segments.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* @param aCornerBuffer a buffer to store the polygon.
|
|
|
|
* @param aClearanceValue the clearance around the pad.
|
|
|
|
* @param aMaxError maximum error from true when converting arcs.
|
|
|
|
* @param aErrorLoc should the approximation error be placed outside or inside the polygon?
|
|
|
|
* @param ignoreLineWidth used for edge cuts where the line width is only for visualization.
|
2018-11-14 23:34:32 +00:00
|
|
|
*/
|
2020-10-13 10:55:24 +00:00
|
|
|
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|
|
|
PCB_LAYER_ID aLayer, int aClearanceValue,
|
|
|
|
int aMaxError, ERROR_LOC aErrorLoc,
|
2020-06-22 19:35:09 +00:00
|
|
|
bool ignoreLineWidth = false ) const override;
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Build the corner list of the polygonal drill shape in the board coordinate system.
|
|
|
|
*
|
|
|
|
* @param aCornerBuffer a buffer to fill.
|
|
|
|
* @param aInflateValue the clearance or margin value.
|
|
|
|
* @param aError maximum deviation of an arc from the polygon approximation.
|
2020-10-13 10:55:24 +00:00
|
|
|
* @param aErrorLoc = should the approximation error be placed outside or inside the polygon?
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return false if the pad has no hole, true otherwise.
|
2020-06-22 19:35:09 +00:00
|
|
|
*/
|
|
|
|
bool TransformHoleWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aInflateValue,
|
2020-10-13 10:55:24 +00:00
|
|
|
int aError, ERROR_LOC aErrorLoc ) const;
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2020-07-22 23:05:22 +00:00
|
|
|
// @copydoc BOARD_ITEM::GetEffectiveShape
|
|
|
|
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2021-01-08 00:26:32 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& GetEffectivePolygon() const;
|
2020-07-25 11:58:17 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return a SHAPE object representing the pad's hole.
|
2020-06-22 19:35:09 +00:00
|
|
|
*/
|
2020-07-04 18:48:22 +00:00
|
|
|
const SHAPE_SEGMENT* GetEffectiveHoleShape() const;
|
2020-06-22 19:35:09 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the radius of a minimum sized circle which fully encloses this pad.
|
|
|
|
*
|
2020-06-22 19:35:09 +00:00
|
|
|
* The center is the pad position NOT THE SHAPE POS!
|
|
|
|
*/
|
|
|
|
int GetBoundingRadius() const;
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2018-11-14 23:34:32 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
|
|
|
|
*
|
|
|
|
* @param aSource [out] optionally reports the source as a user-readable string.
|
|
|
|
* @return the clearance in internal units.
|
2009-11-05 20:59:42 +00:00
|
|
|
*/
|
2020-09-05 16:00:29 +00:00
|
|
|
int GetLocalClearanceOverrides( wxString* aSource ) const override;
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2009-11-04 19:08:08 +00:00
|
|
|
* @return the margin for the solder mask layer
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* Usually > 0 (mask shape bigger than pad). For pads **not** on copper layers, the value
|
|
|
|
* is the local value because there is no default shape to build. For pads also on copper
|
|
|
|
* layers, the value (used to build a default shape) is:
|
|
|
|
* 1 the local value
|
|
|
|
* 2 if 0, the parent footprint value
|
|
|
|
* 3 if 0, the global value
|
2009-11-04 19:08:08 +00:00
|
|
|
*/
|
2013-07-26 16:15:11 +00:00
|
|
|
int GetSolderMaskMargin() const;
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad
|
|
|
|
* size, the margin has a x and a y value. For pads **not** on copper layers, the value is
|
|
|
|
* the local value because there is no default shape to build. For pads also on copper
|
|
|
|
* layers, the value (used to build a default shape) is:
|
|
|
|
* 1 the local value
|
|
|
|
* 2 if 0, the parent footprint value
|
|
|
|
* 3 if 0, the global value
|
2018-05-02 08:31:10 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return the margin for the solder mask layer.
|
2018-05-02 08:31:10 +00:00
|
|
|
*/
|
2013-07-31 12:51:20 +00:00
|
|
|
wxSize GetSolderPasteMargin() const;
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetZoneConnection( ZONE_CONNECTION aType ) { m_zoneConnection = aType; }
|
|
|
|
ZONE_CONNECTION GetZoneConnection() const { return m_zoneConnection; }
|
2019-12-28 00:55:11 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
/**
|
|
|
|
* Return the zone connection in effect (either locally overridden or overridden in the
|
2020-11-13 02:57:11 +00:00
|
|
|
* parent footprint).
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2020-09-10 18:35:11 +00:00
|
|
|
* Optionally reports on the source of the property (pad, parent footprint or zone).
|
2020-06-22 19:35:09 +00:00
|
|
|
*/
|
2020-09-10 18:35:11 +00:00
|
|
|
ZONE_CONNECTION GetEffectiveZoneConnection( wxString* aSource = nullptr ) const;
|
2012-02-24 23:23:46 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/**
|
|
|
|
* Set the width of the thermal spokes connecting the pad to a zone. If != 0 this will
|
|
|
|
* override similar settings in the parent footprint and zone.
|
|
|
|
*/
|
2020-09-10 18:35:11 +00:00
|
|
|
void SetThermalSpokeWidth( int aWidth ) { m_thermalWidth = aWidth; }
|
|
|
|
int GetThermalSpokeWidth() const { return m_thermalWidth; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the effective thermal spoke width having resolved any inheritance.
|
|
|
|
*/
|
|
|
|
int GetEffectiveThermalSpokeWidth( wxString* aSource = nullptr ) const;
|
2012-03-08 20:44:03 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetThermalGap( int aGap ) { m_thermalGap = aGap; }
|
2020-09-10 18:35:11 +00:00
|
|
|
int GetThermalGap() const { return m_thermalGap; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the effective thermal gap having resolved any inheritance.
|
|
|
|
*/
|
|
|
|
int GetEffectiveThermalGap( wxString* aSource = nullptr ) const;
|
2012-03-08 20:44:03 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Has meaning only for rounded rectangle pads.
|
|
|
|
*
|
2016-04-06 18:15:49 +00:00
|
|
|
* @return The radius of the rounded corners for this pad.
|
|
|
|
*/
|
2018-09-09 19:19:21 +00:00
|
|
|
void SetRoundRectCornerRadius( double aRadius );
|
2020-06-22 19:35:09 +00:00
|
|
|
int GetRoundRectCornerRadius() const;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2017-01-21 20:19:46 +00:00
|
|
|
wxPoint ShapePos() const;
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Has meaning only for rounded rectangle pads.
|
|
|
|
*
|
2020-07-03 15:12:28 +00:00
|
|
|
* Set the ratio between the smaller X or Y size and the rounded corner radius.
|
|
|
|
* Cannot be > 0.5; the normalized IPC-7351C value is 0.25
|
2016-04-06 18:15:49 +00:00
|
|
|
*/
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetRoundRectRadiusRatio( double aRadiusScale );
|
2020-07-03 15:12:28 +00:00
|
|
|
double GetRoundRectRadiusRatio() const { return m_roundedCornerScale; }
|
2018-08-29 07:13:07 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Has meaning only for chamfered rectangular pads.
|
|
|
|
*
|
2020-07-03 15:12:28 +00:00
|
|
|
* Set the ratio between the smaller X or Y size and chamfered corner size.
|
|
|
|
* Cannot be < 0.5.
|
2018-08-29 07:13:07 +00:00
|
|
|
*/
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetChamferRectRatio( double aChamferScale );
|
2020-07-03 15:12:28 +00:00
|
|
|
double GetChamferRectRatio() const { return m_chamferScale; }
|
2018-08-29 07:13:07 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Has meaning only for chamfered rectangular pads.
|
|
|
|
*
|
|
|
|
* Set the position of the chamfers for orientation 0.
|
|
|
|
*
|
|
|
|
* @param aPositions a bit-set of #RECT_CHAMFER_POSITIONS.
|
2018-08-29 07:13:07 +00:00
|
|
|
*/
|
2020-06-22 19:35:09 +00:00
|
|
|
void SetChamferPositions( int aPositions ) { m_chamferPositions = aPositions; }
|
|
|
|
int GetChamferPositions() const { return m_chamferPositions; }
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return the netcode.
|
2007-10-13 06:18:44 +00:00
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
int GetSubRatsnest() const { return m_subRatsnest; }
|
|
|
|
void SetSubRatsnest( int aSubRatsnest ) { m_subRatsnest = aSubRatsnest; }
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2020-07-27 19:41:50 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the unconnected removal property.
|
|
|
|
*
|
|
|
|
* If true, the copper is removed on zone fill or when specifically requested when the pad
|
|
|
|
* is not connected on a layer. This requires that there be a through hole.
|
2020-07-27 19:41:50 +00:00
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetRemoveUnconnected( bool aSet ) { m_removeUnconnectedLayer = aSet; }
|
|
|
|
bool GetRemoveUnconnected() const { return m_removeUnconnectedLayer; }
|
2020-07-27 19:41:50 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set whether we keep the top and bottom connections even if they are not connected.
|
2020-07-27 19:41:50 +00:00
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
void SetKeepTopBottom( bool aSet ) { m_keepTopBottomLayer = aSet; }
|
|
|
|
bool GetKeepTopBottom() const { return m_keepTopBottomLayer; }
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
return m_layerMask[aLayer];
|
|
|
|
}
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2020-12-31 01:36:44 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Check to see whether the pad should be flashed on the specific layer.
|
|
|
|
*
|
2020-12-31 01:36:44 +00:00
|
|
|
* @param aLayer Layer to check for connectivity
|
|
|
|
* @return true if connected by pad or track (or optionally zone)
|
|
|
|
*/
|
2021-01-28 21:21:22 +00:00
|
|
|
bool FlashLayer( int aLayer ) const;
|
2020-12-31 01:36:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Check to see if the pad should be flashed to any of the layers in the set.
|
|
|
|
*
|
2020-12-31 01:36:44 +00:00
|
|
|
* @param aLayers set of layers to check the via against
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return true if connected by pad or track (or optionally zone) on any of the associated
|
|
|
|
* layers
|
2020-12-31 01:36:44 +00:00
|
|
|
*/
|
2021-01-28 21:21:22 +00:00
|
|
|
bool FlashLayer( LSET aLayers ) const;
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
2017-04-22 06:49:15 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2007-08-07 06:21:19 +00:00
|
|
|
{
|
|
|
|
return wxT( "PAD" );
|
|
|
|
}
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/**
|
|
|
|
* The bounding box is cached, so this will be efficient most of the time.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Set absolute coordinates.
|
2014-07-09 09:59:24 +00:00
|
|
|
void SetDrawCoord();
|
|
|
|
|
2019-01-13 21:20:29 +00:00
|
|
|
//todo: Remove SetLocalCoord along with m_pos
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Set relative coordinates.
|
2014-07-09 09:59:24 +00:00
|
|
|
void SetLocalCoord();
|
|
|
|
|
2008-01-24 21:50:12 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Compare two pads and return 0 if they are equal.
|
|
|
|
*
|
|
|
|
* @return less than 0 if left less than right, 0 if equal, or greater than 0 if left
|
|
|
|
* greater than right.
|
2008-01-24 21:50:12 +00:00
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
static int Compare( const PAD* padref, const PAD* padcmp );
|
2008-01-24 21:50:12 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2020-07-31 12:37:22 +00:00
|
|
|
m_pos += aMoveVector;
|
2014-07-09 09:59:24 +00:00
|
|
|
SetLocalCoord();
|
2021-01-08 00:26:32 +00:00
|
|
|
SetDirty();
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-07-14 19:41:20 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return the GUI-appropriate name of the shape.
|
2011-07-14 19:41:20 +00:00
|
|
|
*/
|
|
|
|
wxString ShowPadShape() const;
|
|
|
|
|
|
|
|
/**
|
2020-07-03 15:12:28 +00:00
|
|
|
* @return the GUI-appropriate description of the pad type (attribute) : Std, SMD ...
|
2011-07-14 19:41:20 +00:00
|
|
|
*/
|
|
|
|
wxString ShowPadAttr() const;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2014-07-02 13:08:28 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Same as Clone, but returns a PAD item.
|
|
|
|
*
|
2020-02-20 12:11:04 +00:00
|
|
|
* Useful mainly for python scripts, because Clone returns an EDA_ITEM.
|
2014-07-02 13:08:28 +00:00
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* ClonePad() const
|
2014-07-02 13:08:28 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
return (PAD*) Clone();
|
2014-07-02 13:08:28 +00:00
|
|
|
}
|
|
|
|
|
2020-06-28 18:00:40 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Rebuild the effective shape cache (and bounding box and radius) for the pad and clears
|
2020-07-03 15:12:28 +00:00
|
|
|
* the dirty bit.
|
2020-06-28 18:00:40 +00:00
|
|
|
*/
|
2020-08-12 21:18:13 +00:00
|
|
|
void BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const;
|
2021-01-08 00:26:32 +00:00
|
|
|
void BuildEffectivePolygon() const;
|
2020-06-28 18:00:40 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2020-09-21 15:03:08 +00:00
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2013-07-08 09:30:50 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual const BOX2I ViewBBox() const override;
|
2013-07-26 16:15:11 +00:00
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2007-08-07 06:21:19 +00:00
|
|
|
#endif
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
private:
|
2020-08-12 21:18:13 +00:00
|
|
|
void addPadPrimitivesToPolygon( SHAPE_POLY_SET* aMergedPolygon, PCB_LAYER_ID aLayer,
|
2020-10-13 10:55:24 +00:00
|
|
|
int aError, ERROR_LOC aErrorLoc ) const;
|
2017-10-19 21:16:06 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
private:
|
2020-07-03 15:12:28 +00:00
|
|
|
wxString m_name; // Pad name (pin number in schematic)
|
2021-01-21 21:46:03 +00:00
|
|
|
wxString m_pinFunction; // Pin name in schematic
|
|
|
|
wxString m_pinType; // Pin electrical type in schematic
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
wxPoint m_pos; // Pad Position on board
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE m_padShape; // Shape: PAD_SHAPE::CIRCLE, PAD_SHAPE::RECT,
|
|
|
|
// PAD_SHAPE::OVAL, PAD_SHAPE::TRAPEZOID,
|
|
|
|
// PAD_SHAPE::ROUNDRECT, PAD_SHAPE_POLYGON
|
2020-07-03 15:12:28 +00:00
|
|
|
/*
|
|
|
|
* Editing definitions of primitives for custom pad shapes. In local coordinates relative
|
|
|
|
* to m_Pos (NOT shapePos) at orient 0.
|
|
|
|
*/
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<std::shared_ptr<PCB_SHAPE>> m_editPrimitives;
|
2020-06-24 11:12:39 +00:00
|
|
|
|
2020-09-21 12:43:26 +00:00
|
|
|
// Must be set to true to force rebuild shapes to draw (after geometry change for instance)
|
2020-09-17 16:32:42 +00:00
|
|
|
mutable bool m_shapesDirty;
|
2020-12-28 19:47:47 +00:00
|
|
|
mutable std::mutex m_shapesBuildingLock;
|
2020-09-17 16:32:42 +00:00
|
|
|
mutable EDA_RECT m_effectiveBoundingBox;
|
|
|
|
mutable std::shared_ptr<SHAPE_COMPOUND> m_effectiveShape;
|
|
|
|
mutable std::shared_ptr<SHAPE_SEGMENT> m_effectiveHoleShape;
|
2021-01-08 00:26:32 +00:00
|
|
|
|
|
|
|
mutable bool m_polyDirty;
|
|
|
|
mutable std::mutex m_polyBuildingLock;
|
2020-09-17 16:32:42 +00:00
|
|
|
mutable std::shared_ptr<SHAPE_POLY_SET> m_effectivePolygon;
|
2021-01-08 00:26:32 +00:00
|
|
|
mutable int m_effectiveBoundingRadius;
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/*
|
2017-01-13 17:51:22 +00:00
|
|
|
* How to build the custom shape in zone, to create the clearance area:
|
|
|
|
* CUST_PAD_SHAPE_IN_ZONE_OUTLINE = use pad shape
|
|
|
|
* CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL = use the convex hull of the pad shape
|
|
|
|
*/
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea;
|
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
int m_subRatsnest; // Variable used to handle subnet (block) number in
|
2020-07-03 15:12:28 +00:00
|
|
|
// ratsnest computations
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
wxSize m_drill; // Drill diameter (x == y) or slot dimensions (x != y)
|
|
|
|
wxSize m_size; // X and Y size (relative to orient 0)
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
PAD_DRILL_SHAPE_T m_drillShape; // PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG
|
2014-01-26 14:20:58 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
double m_roundedCornerScale; // Scaling factor of min(width, height) to corner
|
2020-07-03 15:12:28 +00:00
|
|
|
// radius, default 0.25
|
|
|
|
double m_chamferScale; // Scaling factor of min(width, height) to chamfer
|
|
|
|
// size, default 0.25
|
|
|
|
int m_chamferPositions; // The positions of the chamfers (at orient 0)
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE m_anchorPadShape; // For custom shaped pads: shape of pad anchor,
|
|
|
|
// PAD_SHAPE::RECT, PAD_SHAPE::CIRCLE
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/*
|
|
|
|
* Most of the time the hole is the center of the shape (m_Offset = 0). But some designers
|
|
|
|
* use oblong/rect pads with a hole moved to one of the oblong/rect pad shape ends.
|
|
|
|
* In all cases the hole is at the pad position. This offset is from the hole to the center
|
|
|
|
* of the pad shape (ie: the copper area around the hole).
|
|
|
|
* ShapePos() returns the board shape position according to the offset and the pad rotation.
|
2012-02-19 04:02:19 +00:00
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
wxPoint m_offset;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
LSET m_layerMask; // Bitwise layer: 1 = copper layer, 15 = cmp,
|
|
|
|
// 2..14 = internal layers, 16..31 = technical layers
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
wxSize m_deltaSize; // Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes
|
2020-07-03 15:12:28 +00:00
|
|
|
// one end and half expands the other. It is only valid
|
|
|
|
// to have a single axis be non-0.
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
wxPoint m_pos0; // Initial Pad position (i.e. pad position relative to the
|
2020-11-13 02:57:11 +00:00
|
|
|
// footprint anchor, orientation 0)
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
PAD_ATTRIB m_attribute; // PAD_ATTRIB_NORMAL, PAD_ATTRIB::SMD, PAD_ATTRIB::CONN,
|
|
|
|
// PAD_ATTRIB::NPTH
|
2021-05-01 14:58:30 +00:00
|
|
|
PAD_PROP m_property; // Property in fab files (BGA, FIDUCIAL, TESTPOINT, etc.)
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
double m_orient; // in 1/10 degrees
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
int m_lengthPadToDie; // Length net from pad to die, inside the package
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< If true, the pad copper is removed for layers that are not connected.
|
|
|
|
bool m_removeUnconnectedLayer;
|
|
|
|
|
|
|
|
///< When removing unconnected pads, keep the top and bottom pads.
|
|
|
|
bool m_keepTopBottomLayer;
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2020-07-03 15:12:28 +00:00
|
|
|
/*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Pad clearances, margins, etc. exist in a hierarchy. If a given level is specified then
|
2020-07-03 15:12:28 +00:00
|
|
|
* the remaining levels are NOT consulted.
|
|
|
|
*
|
|
|
|
* LEVEL 1: (highest priority) local overrides (pad, footprint, etc.)
|
|
|
|
* LEVEL 2: Rules
|
|
|
|
* LEVEL 3: Accumulated local settings, netclass settings, & board design settings
|
|
|
|
*
|
|
|
|
* These are the LEVEL 1 settings for a pad.
|
|
|
|
*/
|
2020-07-31 12:37:22 +00:00
|
|
|
int m_localClearance;
|
|
|
|
int m_localSolderMaskMargin; // Local solder mask margin
|
|
|
|
int m_localSolderPasteMargin; // Local solder paste margin absolute value
|
|
|
|
double m_localSolderPasteMarginRatio; // Local solder mask margin ratio of pad size
|
2020-07-03 15:12:28 +00:00
|
|
|
// The final margin is the sum of these 2 values
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-31 12:37:22 +00:00
|
|
|
ZONE_CONNECTION m_zoneConnection; // No connection, thermal relief, etc.
|
|
|
|
int m_thermalWidth; // Thermal spoke width.
|
|
|
|
int m_thermalGap;
|
2012-02-19 04:02:19 +00:00
|
|
|
};
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
#endif // PAD_H
|