2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-24 13:22:43 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wandadoo.fr
|
2023-07-09 11:19:43 +00:00
|
|
|
* Copyright (C) 1992-2023 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
|
|
|
|
*/
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
#ifndef BOARD_ITEM_STRUCT_H
|
|
|
|
#define BOARD_ITEM_STRUCT_H
|
|
|
|
|
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-10-13 10:55:24 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <stroke_params.h>
|
2022-01-15 01:12:24 +00:00
|
|
|
#include <geometry/eda_angle.h>
|
2012-04-12 21:31:31 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
class BOARD;
|
2023-07-09 11:19:43 +00:00
|
|
|
class BOARD_DESIGN_SETTINGS;
|
2016-12-13 16:24:19 +00:00
|
|
|
class BOARD_ITEM_CONTAINER;
|
2017-11-29 18:51:01 +00:00
|
|
|
class SHAPE_POLY_SET;
|
2022-07-22 22:05:25 +00:00
|
|
|
class SHAPE_SEGMENT;
|
2019-05-31 12:15:25 +00:00
|
|
|
class PCB_BASE_FRAME;
|
2020-07-15 16:23:36 +00:00
|
|
|
class SHAPE;
|
2020-09-24 01:05:46 +00:00
|
|
|
class PCB_GROUP;
|
2023-03-30 11:49:23 +00:00
|
|
|
class FOOTPRINT;
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
class METRICS;
|
|
|
|
}
|
|
|
|
|
2008-05-05 19:56:06 +00:00
|
|
|
|
2023-02-05 13:07:30 +00:00
|
|
|
/**
|
|
|
|
* Conditionally flashed vias and pads that interact with zones of different priority can be
|
|
|
|
* very squirrelly.
|
|
|
|
*
|
|
|
|
* In particular, when filling a higher-priority zone that does -not- connect to a via/pad, we
|
|
|
|
* don't know whether or not a lower-priority zone will subsequently connect -- so we can't
|
|
|
|
* determine clearance because we don't know what the final flashing state will be.
|
|
|
|
*
|
|
|
|
* We therefore force the flashing state if the highest-priority zone with the same net -can-
|
|
|
|
* connect (whether or not it does in the end), and otherwise force the zone-connection state
|
|
|
|
* to no-connection (even though a lower priority zone -might- have otherwise connected to it.
|
|
|
|
*/
|
|
|
|
enum ZONE_LAYER_OVERRIDE
|
2022-10-18 12:00:37 +00:00
|
|
|
{
|
2023-02-05 13:07:30 +00:00
|
|
|
ZLO_NONE,
|
|
|
|
ZLO_FORCE_FLASHED,
|
|
|
|
ZLO_FORCE_NO_ZONE_CONNECTION
|
2022-10-18 12:00:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* A base class for any item which can be embedded within the #BOARD container class, and
|
|
|
|
* therefore instances of derived classes should only be found in Pcbnew or other programs
|
|
|
|
* that use class #BOARD and its contents.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class BOARD_ITEM : public EDA_ITEM
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-11 21:01:35 +00:00
|
|
|
BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype, PCB_LAYER_ID aLayer = F_Cu ) :
|
2020-09-25 17:37:03 +00:00
|
|
|
EDA_ITEM( aParent, idtype ),
|
2022-01-11 21:01:35 +00:00
|
|
|
m_layer( aLayer ),
|
2022-03-08 13:16:39 +00:00
|
|
|
m_isKnockout( false ),
|
|
|
|
m_isLocked( false ),
|
2020-09-25 17:37:03 +00:00
|
|
|
m_group( nullptr )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
~BOARD_ITEM();
|
|
|
|
|
2020-09-25 17:37:03 +00:00
|
|
|
void SetParentGroup( PCB_GROUP* aGroup ) { m_group = aGroup; }
|
|
|
|
PCB_GROUP* GetParentGroup() const { return m_group; }
|
2020-09-02 01:09:34 +00:00
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
2020-02-02 18:40:14 +00:00
|
|
|
int GetX() const
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I p = GetPosition();
|
2020-02-02 18:40:14 +00:00
|
|
|
return p.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetY() const
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I p = GetPosition();
|
2020-02-02 18:40:14 +00:00
|
|
|
return p.y;
|
|
|
|
}
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
/**
|
2020-10-06 16:38:24 +00:00
|
|
|
* This defaults to the center of the bounding box if not overridden.
|
2015-02-12 03:22:24 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return center point of the item
|
2015-02-12 03:22:24 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual VECTOR2I GetCenter() const
|
2020-10-06 16:38:24 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
return GetBoundingBox().GetCenter();
|
2020-10-06 16:38:24 +00:00
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
void SetX( int aX )
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I p( aX, GetY() );
|
2020-02-02 18:40:14 +00:00
|
|
|
SetPosition( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetY( int aY )
|
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I p( GetX(), aY );
|
2020-02-02 18:40:14 +00:00
|
|
|
SetPosition( p );
|
|
|
|
}
|
|
|
|
|
2014-01-28 15:23:08 +00:00
|
|
|
/**
|
|
|
|
* Returns information if the object is derived from BOARD_CONNECTED_ITEM.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2014-01-28 15:23:08 +00:00
|
|
|
* @return True if the object is of BOARD_CONNECTED_ITEM type, false otherwise.
|
|
|
|
*/
|
|
|
|
virtual bool IsConnected() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
/**
|
|
|
|
* Return a measure of how likely the other object is to represent the same
|
|
|
|
* object. The scale runs from 0.0 (definitely different objects) to 1.0 (same)
|
|
|
|
*
|
|
|
|
* This is a pure virtual function. Derived classes must implement this.
|
|
|
|
*/
|
|
|
|
virtual double Similarity( const BOARD_ITEM& aItem ) const = 0;
|
|
|
|
virtual bool operator==( const BOARD_ITEM& aItem ) const = 0;
|
|
|
|
|
2019-07-25 11:08:41 +00:00
|
|
|
/**
|
|
|
|
* @return true if the object is on any copper layer, false otherwise.
|
|
|
|
*/
|
|
|
|
virtual bool IsOnCopperLayer() const
|
|
|
|
{
|
|
|
|
return IsCopperLayer( GetLayer() );
|
|
|
|
}
|
|
|
|
|
2022-07-15 15:14:11 +00:00
|
|
|
virtual bool HasHole() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-05-27 12:51:02 +00:00
|
|
|
virtual bool HasDrilledHole() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-07 21:27:29 +00:00
|
|
|
virtual bool IsTented() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
|
|
|
* A value of wxPoint(0,0) which can be passed to the Draw() functions.
|
|
|
|
*/
|
2022-01-01 18:57:44 +00:00
|
|
|
static VECTOR2I ZeroOffset;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-07-22 23:05:22 +00:00
|
|
|
/**
|
|
|
|
* Some pad shapes can be complex (rounded/chamfered rectangle), even without considering
|
2020-09-02 01:09:34 +00:00
|
|
|
* custom shapes. This routine returns a COMPOUND shape (set of simple shapes which make
|
2020-12-18 14:04:03 +00:00
|
|
|
* up the pad for use with routing, collision determination, etc).
|
2020-07-22 23:05:22 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @note This list can contain a SHAPE_SIMPLE (a simple single-outline non-intersecting
|
2020-07-22 23:05:22 +00:00
|
|
|
* polygon), but should never contain a SHAPE_POLY_SET (a complex polygon consisting of
|
|
|
|
* multiple outlines and/or holes).
|
2020-09-02 01:09:34 +00:00
|
|
|
*
|
2020-07-22 23:05:22 +00:00
|
|
|
* @param aLayer in case of items spanning multiple layers, only the shapes belonging to aLayer
|
|
|
|
* will be returned. Pass UNDEFINED_LAYER to return shapes for all layers.
|
2022-10-13 11:22:57 +00:00
|
|
|
* @param aFlash optional parameter allowing a caller to force the pad to be flashed (or not
|
|
|
|
* flashed) on the current layer (default is to honour the pad's setting and
|
|
|
|
* the current connections for the given layer).
|
2020-07-22 23:05:22 +00:00
|
|
|
*/
|
2022-03-16 23:48:24 +00:00
|
|
|
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
|
2022-07-22 22:05:25 +00:00
|
|
|
FLASHING aFlash = FLASHING::DEFAULT ) const;
|
|
|
|
|
|
|
|
virtual std::shared_ptr<SHAPE_SEGMENT> GetEffectiveHoleShape() const;
|
2020-07-15 16:23:36 +00:00
|
|
|
|
2023-10-14 14:04:13 +00:00
|
|
|
/**
|
|
|
|
* Invoke a function on all children.
|
|
|
|
* @note This function should not add or remove items to the parent.
|
|
|
|
*/
|
|
|
|
virtual void RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const { }
|
|
|
|
|
2023-11-09 13:55:00 +00:00
|
|
|
/**
|
|
|
|
* Invoke a function on all descendants.
|
|
|
|
* @note This function should not add or remove items.
|
|
|
|
*/
|
2024-01-22 23:32:13 +00:00
|
|
|
virtual void RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
|
|
|
|
int aDepth = 0 ) const { }
|
2023-11-09 13:55:00 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
BOARD_ITEM_CONTAINER* GetParent() const { return (BOARD_ITEM_CONTAINER*) m_parent; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* GetParentFootprint() const;
|
|
|
|
|
|
|
|
VECTOR2I GetFPRelativePosition() const;
|
|
|
|
void SetFPRelativePosition( const VECTOR2I& aPos );
|
2021-11-26 23:01:53 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
/**
|
|
|
|
* Check if this item has line stoke properties.
|
|
|
|
*
|
|
|
|
* @see #STROKE_PARAMS
|
|
|
|
*/
|
|
|
|
virtual bool HasLineStroke() const { return false; }
|
|
|
|
|
|
|
|
virtual STROKE_PARAMS GetStroke() const;
|
|
|
|
virtual void SetStroke( const STROKE_PARAMS& aStroke );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
const KIFONT::METRICS& GetFontMetrics() const;
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return the primary layer this item is on.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2020-11-14 14:29:11 +00:00
|
|
|
virtual PCB_LAYER_ID GetLayer() const { return m_layer; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2015-06-04 12:54:07 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return a std::bitset of all layers on which the item physically resides.
|
2015-06-04 12:54:07 +00:00
|
|
|
*/
|
2022-01-14 17:25:45 +00:00
|
|
|
virtual LSET GetLayerSet() const
|
|
|
|
{
|
|
|
|
if( m_layer == UNDEFINED_LAYER )
|
|
|
|
return LSET();
|
|
|
|
else
|
|
|
|
return LSET( m_layer );
|
|
|
|
}
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
virtual void SetLayerSet( LSET aLayers )
|
|
|
|
{
|
2022-09-09 20:01:34 +00:00
|
|
|
if( aLayers.count() == 1 )
|
|
|
|
{
|
|
|
|
SetLayer( aLayers.Seq()[0] );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 11:14:08 +00:00
|
|
|
wxFAIL_MSG( wxT( "Attempted to SetLayerSet() on a single-layer object." ) );
|
2020-08-09 11:22:09 +00:00
|
|
|
|
|
|
|
// Derived classes which support multiple layers must implement this
|
|
|
|
}
|
2015-06-04 12:54:07 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Set the layer this item is on.
|
|
|
|
*
|
|
|
|
* This method is virtual because some items (in fact: class DIMENSION)
|
|
|
|
* have a slightly different initialization.
|
|
|
|
*
|
2008-04-14 19:22:48 +00:00
|
|
|
* @param aLayer The layer number.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
virtual void SetLayer( PCB_LAYER_ID aLayer )
|
2013-11-04 02:09:28 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
m_layer = aLayer;
|
2013-11-04 02:09:28 +00:00
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-02-20 12:11:04 +00:00
|
|
|
/**
|
2021-03-06 09:27:41 +00:00
|
|
|
* Create a copy of this #BOARD_ITEM.
|
2020-02-20 12:11:04 +00:00
|
|
|
*/
|
2022-02-04 14:26:32 +00:00
|
|
|
virtual BOARD_ITEM* Duplicate() const;
|
2020-02-20 12:11:04 +00:00
|
|
|
|
2013-11-20 17:26:47 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Swap data between \a aItem and \a aImage.
|
|
|
|
*
|
|
|
|
* \a aItem and \a aImage should have the same type.
|
|
|
|
*
|
|
|
|
* Used in undo and redo commands to swap values between an item and its copy.
|
|
|
|
* Only values like layer, size .. which are modified by editing are swapped.
|
|
|
|
*
|
|
|
|
* @param aImage the item image which contains data to swap.
|
2013-11-20 17:26:47 +00:00
|
|
|
*/
|
2022-11-11 17:09:25 +00:00
|
|
|
void SwapItemData( BOARD_ITEM* aImage );
|
2013-11-20 17:26:47 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Test to see if this object is on the given layer.
|
|
|
|
*
|
|
|
|
* Virtual so objects like #PAD, which reside on multiple layers can do their own form
|
|
|
|
* of testing.
|
|
|
|
*
|
2008-04-14 19:22:48 +00:00
|
|
|
* @param aLayer The layer to test for.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return true if on given layer, else false.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2023-08-01 17:37:19 +00:00
|
|
|
virtual bool IsOnLayer( PCB_LAYER_ID aLayer ) const
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2020-11-14 14:29:11 +00:00
|
|
|
return m_layer == aLayer;
|
2008-04-14 19:22:48 +00:00
|
|
|
}
|
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
virtual bool IsKnockout() const { return m_isKnockout; }
|
|
|
|
virtual void SetIsKnockout( bool aKnockout ) { m_isKnockout = aKnockout; }
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2021-07-22 11:45:33 +00:00
|
|
|
virtual bool IsLocked() const;
|
2022-03-08 13:16:39 +00:00
|
|
|
virtual void SetLocked( bool aLocked ) { m_isLocked = aLocked; }
|
2023-12-15 18:02:52 +00:00
|
|
|
|
2023-07-09 11:19:43 +00:00
|
|
|
virtual void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) { }
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Delete this object after removing from its parent if it has one.
|
2008-04-14 19:22:48 +00:00
|
|
|
*/
|
2016-12-10 15:20:21 +00:00
|
|
|
void DeleteStructure();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Move this object.
|
|
|
|
*
|
|
|
|
* @param aMoveVector the move vector for this object.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Move( const VECTOR2I& aMoveVector )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2022-02-09 11:14:08 +00:00
|
|
|
wxFAIL_MSG( wxT( "virtual BOARD_ITEM::Move called for " ) + GetClass() );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2009-08-17 02:59:38 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Rotate this object.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2022-01-13 19:32:00 +00:00
|
|
|
* @param aRotCentre the rotation center point.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2022-01-13 19:32:00 +00:00
|
|
|
virtual void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle );
|
2017-09-28 16:38:54 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Flip this object, i.e. change the board side for this object.
|
|
|
|
*
|
|
|
|
* @param aCentre the rotation point.
|
|
|
|
* @param aFlipLeftRight mirror across Y axis instead of X (the default).
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight );
|
2017-09-28 16:38:54 +00:00
|
|
|
|
2023-10-29 11:23:52 +00:00
|
|
|
/**
|
|
|
|
* Perform any normalization required after a user rotate and/or flip.
|
|
|
|
*/
|
|
|
|
virtual void Normalize() {}
|
|
|
|
|
2009-08-17 02:59:38 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return the #BOARD in which this #BOARD_ITEM resides, or NULL if none.
|
2009-08-17 02:59:38 +00:00
|
|
|
*/
|
2021-08-16 09:53:27 +00:00
|
|
|
virtual const BOARD* GetBoard() const;
|
|
|
|
virtual BOARD* GetBoard();
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2023-08-18 17:35:44 +00:00
|
|
|
/**
|
|
|
|
* For "parent" property.
|
|
|
|
* @return the parent footprint's ref or the parent item's UUID.
|
|
|
|
*/
|
|
|
|
wxString GetParentAsString() const;
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return the name of the PCB layer on which the item resides.
|
2011-07-14 15:42:44 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return the layer name associated with this item.
|
2011-07-14 15:42:44 +00:00
|
|
|
*/
|
|
|
|
wxString GetLayerName() const;
|
2012-04-12 21:31:31 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
2017-11-29 18:51:01 +00:00
|
|
|
|
2018-11-14 23:34:32 +00:00
|
|
|
/**
|
2022-10-21 12:48:45 +00:00
|
|
|
* Convert the item shape to a closed polygon. Circles and arcs are approximated by segments.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer a buffer to store the polygon.
|
|
|
|
* @param aClearance the clearance around the pad.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aError the maximum deviation from true circle.
|
|
|
|
* @param aErrorLoc should the approximation error be placed outside or inside the polygon?
|
|
|
|
* @param ignoreLineWidth used for edge cut items where the line width is only
|
|
|
|
* for visualization.
|
2018-11-14 23:34:32 +00:00
|
|
|
*/
|
2022-10-21 12:48:45 +00:00
|
|
|
virtual void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
|
|
|
|
int aClearance, int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool ignoreLineWidth = false ) const;
|
2020-05-21 17:42:42 +00:00
|
|
|
|
2024-04-28 22:05:14 +00:00
|
|
|
enum COMPARE_FLAGS : int
|
|
|
|
{
|
|
|
|
DRC = 0x01
|
|
|
|
};
|
|
|
|
|
2020-07-24 22:08:36 +00:00
|
|
|
struct ptr_cmp
|
|
|
|
{
|
|
|
|
bool operator() ( const BOARD_ITEM* a, const BOARD_ITEM* b ) const;
|
|
|
|
};
|
|
|
|
|
2020-05-21 17:42:42 +00:00
|
|
|
protected:
|
|
|
|
/**
|
2022-03-08 13:16:39 +00:00
|
|
|
* Return a string (to be shown to the user) describing a layer mask.
|
2020-05-21 17:42:42 +00:00
|
|
|
*/
|
2020-11-16 11:16:44 +00:00
|
|
|
virtual wxString layerMaskDescribe() const;
|
2020-12-18 14:04:03 +00:00
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
virtual void swapData( BOARD_ITEM* aImage );
|
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
protected:
|
2020-12-18 14:04:03 +00:00
|
|
|
PCB_LAYER_ID m_layer;
|
2022-03-08 13:16:39 +00:00
|
|
|
bool m_isKnockout;
|
|
|
|
|
|
|
|
bool m_isLocked;
|
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
PCB_GROUP* m_group;
|
2008-04-14 19:22:48 +00:00
|
|
|
};
|
|
|
|
|
2020-02-02 18:40:14 +00:00
|
|
|
#ifndef SWIG
|
|
|
|
DECLARE_ENUM_TO_WXANY( PCB_LAYER_ID );
|
|
|
|
#endif
|
|
|
|
|
2020-07-19 21:22:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A singleton item of this class is returned for a weak reference that no longer exists.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
2020-07-19 21:22:49 +00:00
|
|
|
* Its sole purpose is to flag the item as having been deleted.
|
|
|
|
*/
|
|
|
|
class DELETED_BOARD_ITEM : public BOARD_ITEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DELETED_BOARD_ITEM() :
|
|
|
|
BOARD_ITEM( nullptr, NOT_USED )
|
|
|
|
{}
|
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
|
2020-07-19 21:22:49 +00:00
|
|
|
{
|
|
|
|
return _( "(Deleted Item)" );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "DELETED_BOARD_ITEM" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// pure virtuals:
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetPosition( const VECTOR2I& ) override {}
|
|
|
|
VECTOR2I GetPosition() const override { return VECTOR2I( 0, 0 ); }
|
2020-07-19 21:22:49 +00:00
|
|
|
|
|
|
|
static DELETED_BOARD_ITEM* GetInstance()
|
|
|
|
{
|
|
|
|
static DELETED_BOARD_ITEM* item = nullptr;
|
|
|
|
|
|
|
|
if( !item )
|
|
|
|
item = new DELETED_BOARD_ITEM();
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
double Similarity( const BOARD_ITEM& aItem ) const override
|
|
|
|
{
|
|
|
|
return ( this == &aItem ) ? 1.0 : 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( const BOARD_ITEM& aItem ) const override
|
|
|
|
{
|
|
|
|
return ( this == &aItem );
|
|
|
|
}
|
|
|
|
|
2020-07-19 21:22:49 +00:00
|
|
|
#if defined(DEBUG)
|
2021-03-06 09:27:41 +00:00
|
|
|
void Show( int , std::ostream& ) const override {}
|
2020-07-19 21:22:49 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
#endif /* BOARD_ITEM_STRUCT_H */
|