2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-07-22 12:50:35 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2024-04-15 20:18:54 +00:00
|
|
|
* Copyright (C) 1992-2024 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-10-04 23:34:59 +00:00
|
|
|
#ifndef PCB_SHAPE_H
|
|
|
|
#define PCB_SHAPE_H
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
#include <board_connected_item.h>
|
2021-07-14 20:03:32 +00:00
|
|
|
#include <eda_shape.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2020-07-02 16:06:09 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class LINE_READER;
|
|
|
|
class EDA_DRAW_FRAME;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2023-07-30 19:39:07 +00: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 18:52:13 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
PCB_SHAPE( BOARD_ITEM* aParent = NULL, SHAPE_T aShapeType = SHAPE_T::SEGMENT );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2016-05-30 08:44:48 +00:00
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
2012-01-14 19:50:32 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
~PCB_SHAPE() override;
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
static bool ClassOf( const EDA_ITEM* aItem )
|
2015-02-17 23:53:57 +00:00
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
return aItem && PCB_SHAPE_T == aItem->Type();
|
2015-02-17 23:53:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
wxString GetClass() const override
|
|
|
|
{
|
|
|
|
return wxT( "PCB_SHAPE" );
|
|
|
|
}
|
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
void Serialize( google::protobuf::Any &aContainer ) const override;
|
|
|
|
bool Deserialize( const google::protobuf::Any &aContainer ) override;
|
|
|
|
|
2023-08-11 04:01:39 +00:00
|
|
|
bool IsConnected() const override;
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
wxString GetFriendlyName() const override { return getFriendlyName(); }
|
2022-11-25 17:37:18 +00:00
|
|
|
|
2022-09-12 10:38:24 +00:00
|
|
|
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
|
2020-05-15 23:25:33 +00:00
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
PCB_LAYER_ID GetLayer() const override { return m_layer; }
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return getPosition(); }
|
2020-11-14 07:51:21 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetCenter() const override { return getCenter(); }
|
2011-11-29 03:08:14 +00:00
|
|
|
|
2023-07-30 19:39:07 +00: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 19:56:18 +00: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 12:39:35 +00:00
|
|
|
int GetWidth() const override;
|
|
|
|
|
2023-07-09 11:19:43 +00: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 21:56:47 +00:00
|
|
|
/**
|
2021-07-14 20:03:32 +00: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 08:36:57 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I GetFocusPosition() const override;
|
2020-06-22 22:17:21 +00:00
|
|
|
|
2020-07-02 16:06:09 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Make a set of SHAPE objects representing the PCB_SHAPE. Caller owns the objects.
|
2020-07-02 16:06:09 +00:00
|
|
|
*/
|
2022-03-16 23:48:24 +00:00
|
|
|
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
|
|
|
|
FLASHING aFlash = FLASHING::DEFAULT ) const override;
|
2020-07-02 16:06:09 +00:00
|
|
|
|
2023-09-13 10:27:04 +00:00
|
|
|
bool IsProxyItem() const override { return m_proxyItem; }
|
|
|
|
void SetIsProxyItem( bool aIsProxy = true ) override;
|
2023-09-04 19:48:34 +00:00
|
|
|
|
2020-04-24 13:36:10 +00: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 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override { return getBoundingBox(); }
|
2008-01-16 18:48:04 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
|
2008-01-16 18:48:04 +00:00
|
|
|
{
|
2021-07-14 20:03:32 +00:00
|
|
|
return hitTest( aPosition, aAccuracy );
|
2008-01-16 18:48:04 +00:00
|
|
|
}
|
2008-01-22 20:36:46 +00:00
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
|
2021-07-14 20:03:32 +00: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 17:39:10 +00:00
|
|
|
|
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
|
|
|
|
2023-10-29 11:23:52 +00:00
|
|
|
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
2009-11-16 08:13:40 +00:00
|
|
|
|
2022-09-22 14:05:06 +00:00
|
|
|
virtual void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis );
|
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
void Scale( double aScale );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2022-10-21 12:48:45 +00:00
|
|
|
* Convert the shape to a closed polygon. Circles and arcs are approximated by segments.
|
2021-06-04 13:04:30 +00:00
|
|
|
*
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer is a buffer to store the polygon.
|
|
|
|
* @param aClearance is the clearance around the pad.
|
2021-06-04 13:04:30 +00: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 20:21:10 +00:00
|
|
|
* @param aErrorLoc whether any approximation error should be placed inside or outside
|
2022-10-21 12:48:45 +00: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 12:48:45 +00: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 15:42:44 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
2008-05-05 19:46:54 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
const BOX2I ViewBBox() const override;
|
2015-09-03 21:05:01 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
2023-07-30 19:39:07 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
///< @copydoc VIEW_ITEM::ViewGetLOD
|
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
double Similarity( const BOARD_ITEM& aBoardItem ) const override;
|
|
|
|
|
2024-06-08 21:27:34 +00:00
|
|
|
bool operator==( const PCB_SHAPE& aShape ) const;
|
2023-09-14 21:39:42 +00:00
|
|
|
bool operator==( const BOARD_ITEM& aBoardItem ) const override;
|
|
|
|
|
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 20:18:54 +00:00
|
|
|
void swapData( BOARD_ITEM* aImage ) override;
|
2017-10-31 13:59:03 +00:00
|
|
|
|
2020-07-24 22:08:36 +00:00
|
|
|
struct cmp_drawings
|
|
|
|
{
|
|
|
|
bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
|
|
|
|
};
|
2008-01-16 18:48:04 +00:00
|
|
|
};
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
#endif // PCB_SHAPE_H
|