2012-01-14 14:50:32 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-07-22 14:50:35 +02:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 14:50:32 -05: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
|
|
|
|
*/
|
|
|
|
|
2024-09-27 09:08:31 +01:00
|
|
|
#pragma once
|
2011-08-01 11:29:27 -04:00
|
|
|
|
2023-07-30 15:39:07 -04:00
|
|
|
#include <board_connected_item.h>
|
2021-07-14 21:03:32 +01:00
|
|
|
#include <eda_shape.h>
|
2011-09-23 09:57:12 -04:00
|
|
|
|
2020-07-02 17:06:09 +01:00
|
|
|
|
2011-09-23 09:57:12 -04:00
|
|
|
class LINE_READER;
|
|
|
|
class EDA_DRAW_FRAME;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2013-01-12 12:32:24 -05:00
|
|
|
class MSG_PANEL_ITEM;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2011-08-01 11:29:27 -04:00
|
|
|
|
2023-07-30 15:39:07 -04:00
|
|
|
class PCB_SHAPE : public BOARD_CONNECTED_ITEM, public EDA_SHAPE
|
2008-01-16 18:48:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-30 10:52:52 +00:00
|
|
|
PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T aItemType, SHAPE_T aShapeType );
|
2021-07-17 19:52:13 +01:00
|
|
|
|
2024-09-27 09:08:31 +01:00
|
|
|
PCB_SHAPE( BOARD_ITEM* aParent = nullptr, SHAPE_T aShapeType = SHAPE_T::SEGMENT );
|
2012-01-14 14:50:32 -05:00
|
|
|
|
2016-05-30 10:44:48 +02:00
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
2012-01-14 14:50:32 -05:00
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
~PCB_SHAPE() override;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
static bool ClassOf( const EDA_ITEM* aItem )
|
2015-02-18 00:53:57 +01:00
|
|
|
{
|
2020-10-04 15:19:33 +01:00
|
|
|
return aItem && PCB_SHAPE_T == aItem->Type();
|
2015-02-18 00:53:57 +01:00
|
|
|
}
|
|
|
|
|
2021-07-14 21:03:32 +01:00
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "PCB_SHAPE" );
|
|
|
|
}
|
|
|
|
|
2024-01-20 18:35:29 -05:00
|
|
|
void Serialize( google::protobuf::Any &aContainer ) const override;
|
|
|
|
bool Deserialize( const google::protobuf::Any &aContainer ) override;
|
|
|
|
|
2023-08-11 00:01:39 -04:00
|
|
|
bool IsConnected() const override;
|
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
wxString GetFriendlyName() const override { return getFriendlyName(); }
|
2022-11-25 12:37:18 -05:00
|
|
|
|
2022-09-12 12:38:24 +02:00
|
|
|
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
|
2020-05-16 00:25:33 +01:00
|
|
|
|
2023-07-30 15:39:07 -04:00
|
|
|
void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
PCB_LAYER_ID GetLayer() const override { return m_layer; }
|
|
|
|
|
2024-09-16 02:39:12 +02:00
|
|
|
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
|
|
|
|
|
|
|
|
virtual LSET GetLayerSet() const override;
|
|
|
|
virtual void SetLayerSet( const LSET& aLayers ) override;
|
|
|
|
|
2022-08-20 10:27:35 +01:00
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I GetPosition() const override { return getPosition(); }
|
2020-11-14 08:51:21 +01:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I GetCenter() const override { return getCenter(); }
|
2011-11-28 21:08:14 -06:00
|
|
|
|
2023-07-30 15:39:07 -04:00
|
|
|
/**
|
|
|
|
* @return a list of connection points (may be empty): points where this shape can form
|
|
|
|
* electrical connections to other shapes that are natural "start/end" points.
|
|
|
|
*/
|
|
|
|
std::vector<VECTOR2I> GetConnectionPoints() const;
|
|
|
|
|
2021-07-17 20:56:18 +01:00
|
|
|
bool HasLineStroke() const override { return true; }
|
|
|
|
|
|
|
|
STROKE_PARAMS GetStroke() const override { return m_stroke; }
|
|
|
|
void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
|
|
|
|
|
2023-09-14 13:39:35 +01:00
|
|
|
int GetWidth() const override;
|
|
|
|
|
2023-07-09 12:19:43 +01:00
|
|
|
void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override;
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
/**
|
|
|
|
* Return 4 corners for a rectangle or rotated rectangle (stored as a poly). Unimplemented
|
|
|
|
* for other shapes.
|
|
|
|
*/
|
2023-03-02 14:54:19 +00:00
|
|
|
virtual std::vector<VECTOR2I> GetCorners() const;
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2011-12-02 15:56:47 -06:00
|
|
|
/**
|
2021-07-14 21:03:32 +01:00
|
|
|
* Allows items to return their visual center rather than their anchor. For some shapes this
|
|
|
|
* is similar to GetCenter(), but for unfilled shapes a point on the outline is better.
|
2021-07-22 10:36:57 +02:00
|
|
|
*/
|
2022-01-01 01:04:08 -05:00
|
|
|
const VECTOR2I GetFocusPosition() const override;
|
2020-06-23 00:17:21 +02:00
|
|
|
|
2020-07-02 17:06:09 +01:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Make a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
|
2020-07-02 17:06:09 +01:00
|
|
|
*/
|
2022-03-16 16:48:24 -07:00
|
|
|
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
|
|
|
|
FLASHING aFlash = FLASHING::DEFAULT ) const override;
|
2020-07-02 17:06:09 +01:00
|
|
|
|
2023-09-13 11:27:04 +01:00
|
|
|
bool IsProxyItem() const override { return m_proxyItem; }
|
|
|
|
void SetIsProxyItem( bool aIsProxy = true ) override;
|
2023-09-04 20:48:34 +01:00
|
|
|
|
2020-04-24 14:36:10 +01:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2022-08-31 10:15:42 +01:00
|
|
|
const BOX2I GetBoundingBox() const override { return getBoundingBox(); }
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
|
2008-01-16 18:48:04 +00:00
|
|
|
{
|
2021-07-14 21:03:32 +01:00
|
|
|
return hitTest( aPosition, aAccuracy );
|
2008-01-16 18:48:04 +00:00
|
|
|
}
|
2008-01-22 20:36:46 +00:00
|
|
|
|
2022-08-31 10:33:46 +01:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
|
2021-07-14 21:03:32 +01:00
|
|
|
{
|
|
|
|
return hitTest( aRect, aContained, aAccuracy );
|
|
|
|
}
|
2008-05-05 19:46:54 +00:00
|
|
|
|
2023-10-29 11:23:52 +00:00
|
|
|
void Normalize() override;
|
2022-07-07 10:39:10 -07:00
|
|
|
|
2024-09-28 17:22:22 +02:00
|
|
|
/**
|
|
|
|
* Normalize coordinates to compare 2 similar PCB_SHAPES
|
|
|
|
* similat to Normalize(), but also normalize SEGMENT end points
|
|
|
|
* needed only for graphic comparisons
|
|
|
|
*/
|
|
|
|
void NormalizeForCompare() override;
|
|
|
|
|
2023-10-29 11:23:52 +00:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2023-10-29 11:23:52 +00:00
|
|
|
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2024-09-27 09:08:31 +01:00
|
|
|
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2024-10-07 21:52:39 -04:00
|
|
|
virtual void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
|
2022-09-22 15:05:06 +01:00
|
|
|
|
2020-06-24 12:12:39 +01:00
|
|
|
void Scale( double aScale );
|
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2022-10-21 13:48:45 +01:00
|
|
|
* Convert the shape to a closed polygon. Circles and arcs are approximated by segments.
|
2021-06-04 09:04:30 -04:00
|
|
|
*
|
2022-10-21 13:48:45 +01:00
|
|
|
* @param aBuffer is a buffer to store the polygon.
|
|
|
|
* @param aClearance is the clearance around the pad.
|
2021-06-04 09:04:30 -04:00
|
|
|
* @param aError is the maximum deviation from a true arc.
|
Fix typos in pcbnew sub-directory
Found via `codespell -q 3 -S *.po,./thirdparty,./Documentation/changelogs -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,ba,busses,dout,einstance,leaded,modul,ontext,ot,overide,serie,te,,tesselate,tesselator,tht`
2022-06-29 16:21:10 -04:00
|
|
|
* @param aErrorLoc whether any approximation error should be placed inside or outside
|
2022-10-21 13:48:45 +01:00
|
|
|
* @param ignoreLineWidth is used for edge cut items where the line width is only for
|
|
|
|
* visualization
|
2009-11-16 08:13:40 +00:00
|
|
|
*/
|
2022-10-21 13:48:45 +01:00
|
|
|
void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
|
|
|
|
int aError, ERROR_LOC aErrorLoc,
|
|
|
|
bool ignoreLineWidth = false ) const override;
|
2011-07-14 11:42:44 -04:00
|
|
|
|
2024-06-27 10:11:55 +01:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
2008-05-05 19:46:54 +00:00
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-08-01 11:29:27 -04:00
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 10:39:27 -04:00
|
|
|
|
2024-04-15 21:18:54 +01:00
|
|
|
const BOX2I ViewBBox() const override;
|
2015-09-03 23:05:01 +02:00
|
|
|
|
2024-11-21 13:18:36 -08:00
|
|
|
std::vector<int> ViewGetLayers() const override;
|
2023-07-30 15:39:07 -04:00
|
|
|
|
2022-03-07 18:03:06 +01:00
|
|
|
///< @copydoc VIEW_ITEM::ViewGetLOD
|
2025-01-02 19:24:39 +08:00
|
|
|
double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
|
2022-03-07 18:03:06 +01:00
|
|
|
|
2023-09-14 14:39:42 -07:00
|
|
|
double Similarity( const BOARD_ITEM& aBoardItem ) const override;
|
|
|
|
|
2024-06-08 17:27:34 -04:00
|
|
|
bool operator==( const PCB_SHAPE& aShape ) const;
|
2023-09-14 14:39:42 -07:00
|
|
|
bool operator==( const BOARD_ITEM& aBoardItem ) const override;
|
|
|
|
|
2024-09-16 02:39:12 +02:00
|
|
|
void SetHasSolderMask( bool aVal ) { m_hasSolderMask = aVal; }
|
|
|
|
bool HasSolderMask() const { return m_hasSolderMask; }
|
|
|
|
|
|
|
|
void SetLocalSolderMaskMargin( std::optional<int> aMargin ) { m_solderMaskMargin = aMargin; }
|
|
|
|
std::optional<int> GetLocalSolderMaskMargin() const { return m_solderMaskMargin; }
|
|
|
|
|
|
|
|
int GetSolderMaskExpansion() const;
|
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2024-04-15 21:18:54 +01:00
|
|
|
void swapData( BOARD_ITEM* aImage ) override;
|
2017-10-31 14:59:03 +01:00
|
|
|
|
2025-02-23 12:08:20 +00:00
|
|
|
void updateHatching() const override;
|
|
|
|
|
2020-07-24 15:08:36 -07:00
|
|
|
struct cmp_drawings
|
|
|
|
{
|
|
|
|
bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
|
|
|
};
|
2024-09-16 02:39:12 +02:00
|
|
|
|
2025-02-23 12:08:20 +00:00
|
|
|
protected:
|
2024-09-16 02:39:12 +02:00
|
|
|
bool m_hasSolderMask;
|
|
|
|
std::optional<int> m_solderMaskMargin;
|
2008-01-16 18:48:04 +00:00
|
|
|
};
|