25#include <google/protobuf/any.pb.h>
26#include <magic_enum.hpp>
47#include <api/board/board_types.pb.h>
59 auto map = [&](
const VECTOR2I& aPt )
67 aPoly.
SetVertex( it.GetIndex(), map( *it ) );
79 for(
int i = 0; i < aChain.PointCount(); i++ )
81 int arcIndex = aChain.ArcIndex( i );
85 mapped.
Append( map( aChain.CPoint( i ) ) );
89 const SHAPE_ARC& arc = aChain.Arc( arcIndex );
98 while( i + 1 < aChain.PointCount() && aChain.ArcIndex( i + 1 ) == arcIndex )
108 transformChain( aPoly.
Outline( i ) );
110 for(
int j = 0; j < aPoly.
HoleCount( i ); j++ )
111 transformChain( aPoly.
Hole( i, j ) );
123 EDA_ANGLE startShift;
128static BOARD_ELLIPSE decompose2x2(
double m00,
double m01,
double m10,
double m11 )
130 const double A = m00 * m00 + m10 * m10;
131 const double B = m00 * m01 + m10 * m11;
132 const double C = m01 * m01 + m11 * m11;
134 const double diff = A -
C;
135 const double rad = std::hypot( diff, 2.0 *
B );
136 const double lambda1 = ( A +
C + rad ) * 0.5;
137 const double lambda2 = ( A +
C - rad ) * 0.5;
139 const double sigma1 = std::sqrt( std::max( 0.0, lambda1 ) );
140 const double sigma2 = std::sqrt( std::max( 0.0, lambda2 ) );
161 const double vn = std::hypot( v0x, v0y );
170 u0x = ( m00 * v0x + m01 * v0y ) / sigma1;
171 u0y = ( m10 * v0x + m11 * v0y ) / sigma1;
184static BOARD_ELLIPSE decomposeBoardEllipse(
const TRANSFORM_TRS& aXform,
int aLibMajor,
int aLibMinor,
191 const double phi = aLibRotation.
AsRadians();
192 const double cTheta = std::cos( theta );
193 const double sTheta = std::sin( theta );
194 const double cPhi = std::cos( phi );
195 const double sPhi = std::sin( phi );
196 const double a = aLibMajor;
197 const double b = aLibMinor;
199 const double m00 = a * ( sx * cTheta * cPhi - sy * sTheta * sPhi );
200 const double m01 = -b * ( sx * cTheta * sPhi + sy * sTheta * cPhi );
201 const double m10 = a * ( sx * sTheta * cPhi + sy * cTheta * sPhi );
202 const double m11 = b * ( -sx * sTheta * sPhi + sy * cTheta * cPhi );
204 return decompose2x2( m00, m01, m10, m11 );
209static BOARD_ELLIPSE composeLibEllipse(
const TRANSFORM_TRS& aXform,
double aBoardMajor,
double aBoardMinor,
215 const double beta = aBoardRotation.
AsRadians();
217 const double li00 = std::cos( theta ) / sx;
218 const double li01 = std::sin( theta ) / sx;
219 const double li10 = -std::sin( theta ) / sy;
220 const double li11 = std::cos( theta ) / sy;
222 const double e00 = aBoardMajor * std::cos( beta );
223 const double e01 = -aBoardMinor * std::sin( beta );
224 const double e10 = aBoardMajor * std::sin( beta );
225 const double e11 = aBoardMinor * std::cos( beta );
227 return decompose2x2( li00 * e00 + li01 * e10, li00 * e01 + li01 * e11, li10 * e00 + li11 * e10,
228 li10 * e01 + li11 * e11 );
283 *
this = *
static_cast<const PCB_SHAPE*
>( aOther );
291 BoardGraphicShape msg;
295 msg.mutable_id()->set_value(
m_Uuid.AsStdString() );
296 msg.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
302 PadCustomShapeOptions* options = msg.mutable_pad_custom_shape_options();
307 case SHAPE_T::SEGMENT: options->set_is_thermal_spoke_template(
true );
break;
308 default: wxFAIL_MSG( wxT(
"Unexpected proxy shape type" ) );
break;
313 msg.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
315 msg.mutable_parent()->set_value(
board->m_Uuid.AsStdString() );
319 SolderMaskOverrides* sm = msg.mutable_solder_mask();
320 sm->set_expose_copper(
true );
327 aContainer.PackFrom( msg );
336 BoardGraphicShape msg;
338 if( !aContainer.UnpackTo( &msg ) )
354 SetLocked( msg.locked() == types::LS_LOCKED );
361 if( msg.has_pad_custom_shape_options() )
363 switch( msg.pad_custom_shape_options().role_case() )
365 case PadCustomShapeOptions::kIsNumberBox:
371 case PadCustomShapeOptions::kIsThermalSpokeTemplate:
377 case PadCustomShapeOptions::ROLE_NOT_SET:
382 if( msg.has_solder_mask() )
386 if( msg.solder_mask().has_solder_mask_margin() )
406 bool sametype =
false;
408 for(
KICAD_T scanType : aScanTypes )
474 margin =
board->GetDesignSettings().m_SolderMaskExpansion;
479 margin = std::max( margin, -
GetWidth() / 2 );
509 if( layermask.test(
F_Cu ) )
512 if( layermask.test(
B_Cu ) )
535 std::vector<VECTOR2I> ret;
551 ret.emplace_back( pt.m_point );
562 ret.emplace_back(
GetEnd() );
566 for(
auto iter =
GetPolyShape().CIterate(); iter; ++iter )
567 ret.emplace_back( *iter );
573 ret.emplace_back( pt );
580 const double cosPhi = std::cos( phi );
581 const double sinPhi = std::sin( phi );
598 const double cosPhi = std::cos( phi );
599 const double sinPhi = std::sin( phi );
602 auto eval = [&](
double theta ) ->
VECTOR2I
604 const double lx = a * std::cos( theta );
605 const double ly = b * std::sin( theta );
612 if( thetaEnd < thetaStart )
613 thetaEnd += 2.0 *
M_PI;
615 ret.emplace_back( eval( thetaStart ) );
616 ret.emplace_back( eval( thetaEnd ) );
617 ret.emplace_back( eval( 0.5 * ( thetaStart + thetaEnd ) ) );
659 item->TransformShapeToPolygon( knockouts, layer, margin, maxError,
ERROR_OUTSIDE );
672 if( item->GetLayer() == layer && item->GetBoundingBox().Intersects( bbox ) )
673 knockoutItem( item );
685 knockouts.
Append( footprint->GetCourtyard( layer ) );
688 footprint->RunOnChildren(
696 knockoutItem( item );
731 return s == 1.0 ? lib :
KiROUND( lib * s );
785 std::vector<VECTOR2I> pts;
796 pts.emplace_back( pt );
804 while( pts.size() < 4 )
805 pts.emplace_back( pts.back() +
VECTOR2I( 10, 10 ) );
842 return seg.A.y == seg.B.y;
848 return seg.A.x == seg.B.x;
856 if( horizontal( outline.
Segment( 0 ) )
857 && vertical( outline.
Segment( 1 ) )
858 && horizontal( outline.
Segment( 2 ) )
859 && vertical( outline.
Segment( 3 ) ) )
867 else if( vertical( outline.
Segment( 0 ) )
868 && horizontal( outline.
Segment( 1 ) )
869 && vertical( outline.
Segment( 2 ) )
870 && horizontal( outline.
Segment( 3 ) ) )
890 if( ( libStart.
x > libEnd.
x ) || ( libStart.
x == libEnd.
x && libStart.
y < libEnd.
y ) )
905 rotate( aRotCentre, aAngle );
915 bool mirrorLib =
false;
924 double sx = 1.0, sy = 1.0;
940 p.x = 2 * libCenter.
x - p.x;
942 p.y = 2 * libCenter.
y - p.y;
966 m_libPoly.Mirror( libCenter, aFlipDirection );
1003 flip( aCentre, aFlipDirection );
1083 xform.
SetScale( aScaleX, aScaleY );
1116 if( minorRadius > majorRadius )
1118 std::swap( majorRadius, minorRadius );
1141 int libRadius = (
m_libStart - libCenter ).EuclideanNorm();
1161 if( wrap( midAngle, startAngle ) > wrap( endAngle, startAngle ) )
1162 std::swap( startAngle, endAngle );
1164 while( endAngle < startAngle )
1167 if( minorRadius > majorRadius )
1169 std::swap( majorRadius, minorRadius );
1239 std::unique_ptr<SHAPE_ELLIPSE> libEllipse;
1260 for(
int ii = 0; ii <
chain.PointCount(); ++ii )
1306 for(
int ii = 0; ii < rounded.
Outline( 0 ).PointCount(); ++ii )
1354 return fp->GetTransform().InverseApply(
GetArcMid() );
1366 return fp->GetTransform().InverseApply(
GetBezierC1() );
1378 return fp->GetTransform().InverseApply(
GetBezierC2() );
1475 bool hasXform =
false;
1479 double sx = 1.0, sy = 1.0;
1480 static_cast<const PAD*
>(
static_cast<const BOARD_ITEM*
>(
GetParent() ) )->GetPrimitiveLibScale( sx, sy );
1482 hasXform = ( sx != 1.0 || sy != 1.0 );
1486 xform = fp->GetTransform();
1583 flip( aCentre, aFlipDirection );
1589 PAD* parentPad =
nullptr;
1595 for(
PAD*
pad : fp->Pads() )
1597 if(
pad->IsEntered() )
1667 checkLayer = parent->GetLayer();
1682 std::vector<int> layers;
1683 layers.reserve( 5 );
1694 layers.push_back(
F_Mask );
1696 layers.push_back(
B_Mask );
1715 aList.emplace_back(
_(
"Footprint" ), parent->GetReference() );
1718 aList.emplace_back(
_(
"Type" ),
_(
"Drawing" ) );
1721 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
1747 return wxString::Format(
_(
"%s %s of %s on %s" ),
1755 return wxString::Format(
_(
"%s %s on %s" ),
1765 return wxString::Format(
_(
"%s of %s on %s" ),
1772 return wxString::Format(
_(
"%s on %s" ),
1812 bbox.
Merge( endingsBBox );
1875 if( aFirst->
Type() != aSecond->
Type() )
1876 return aFirst->
Type() < aSecond->
Type();
1906 return width * width;
1912 return width * width;
1923 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
1924 bool ignoreLineWidth )
const
1932 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
1946 return *
this == other;
1992 double similarity = 1.0;
2038 if( layerEnum.
Choices().GetCount() == 0 )
2053 auto isPolygonOrEllipse =
2058 const SHAPE_T t = shape->GetShape();
2066 isPolygonOrEllipse );
2068 isPolygonOrEllipse );
2073 auto isNotBezierOrEllipseArc =
2078 const SHAPE_T t = shape->GetShape();
2086 isNotBezierOrEllipseArc );
2097 auto isNotCircleOrEllipse =
2102 const SHAPE_T t = shape->GetShape();
2110 isNotCircleOrEllipse );
2112 isNotCircleOrEllipse );
2114 isNotCircleOrEllipse );
2116 isNotCircleOrEllipse );
2128 return shape->IsOnCopperLayer();
2136 auto isPadEditMode =
2137 [](
BOARD* aBoard ) ->
bool
2139 if( aBoard && aBoard->IsFootprintHolder() )
2141 for(
FOOTPRINT* fp : aBoard->Footprints() )
2143 for(
PAD*
pad : fp->Pads() )
2145 if(
pad->IsEntered() )
2154 auto showNumberBoxProperty =
2160 return isPadEditMode( shape->GetBoard() );
2166 auto showSpokeTemplateProperty =
2172 return isPadEditMode( shape->GetBoard() );
2178 const wxString groupPadPrimitives =
_HKI(
"Pad Primitives" );
2182 groupPadPrimitives )
2188 groupPadPrimitives )
2192 const wxString groupTechLayers =
_HKI(
"Technical Layers" );
2194 auto isExternalCuLayer =
2197 if(
auto shape =
dynamic_cast<PCB_SHAPE*
>( aItem ) )
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
#define DEFAULT_LINE_WIDTH
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
wxString GetNetname() const
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void PackNet(kiapi::board::types::Net *aProto) const
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
void UnpackNet(const kiapi::board::types::Net &aProto)
Assigns a net to this item from an API message.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual double GetCoverageArea(int aTextMargin) const
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
BOARD_ITEM_CONTAINER * GetParent() const
virtual bool IsOnCopperLayer() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Information pertinent to a Pcbnew printed circuit board.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
constexpr const Vec & GetPosition() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec & GetOrigin() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Represent basic circle geometry with utility geometry functions.
The base class for create windows for drawing purpose.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
KICAD_T Type() const
Returns the type of object.
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
std::map< wxString, wxString > m_customProperties
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
EDA_ITEM * m_parent
Owner.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
virtual int GetHatchLineSpacing() const
virtual void SetEnd(const VECTOR2I &aEnd)
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false, bool includeFill=false) const
Convert the shape to a closed polygon.
int GetEllipseMinorRadius() const
const VECTOR2I & GetBezierC2() const
const VECTOR2I & GetEllipseCenter() const
bool GetLineEndingsBoundingBox(BOX2I &aBBox, int aLineWidth) const
virtual void SetCenter(const VECTOR2I &aCenter)
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
std::vector< SHAPE * > MakeEffectiveShapesWithLineEndings(int aLineWidth) const
Make effective geometry for the shape body shortened for line endings plus the line-ending geometry i...
EDA_ANGLE GetEllipseEndAngle() const
virtual void SetCornerRadius(int aRadius)
int GetEllipseMajorRadius() const
virtual int GetEffectiveWidth() const
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
virtual void SetEllipseEndAngle(const EDA_ANGLE &aA)
bool operator==(const EDA_SHAPE &aOther) const
virtual void SetBezierC2(const VECTOR2I &aPt)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
virtual void SetBezierC1(const VECTOR2I &aPt)
virtual void SetEllipseRotation(const EDA_ANGLE &aA)
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
virtual void SetEllipseCenter(const VECTOR2I &aPt)
virtual void SetEllipseMinorRadius(int aR)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual void SetEllipseMajorRadius(int aR)
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
virtual void UpdateHatching() const
virtual void SetEllipseStartAngle(const EDA_ANGLE &aA)
virtual void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
wxString SHAPE_T_asString() const
double Similarity(const EDA_SHAPE &aOther) const
const VECTOR2I & GetBezierC1() const
const BOX2I getBoundingBox() const
virtual int GetWidth() const
void RebuildBezierToSegmentsPointsList()
int GetCornerRadius() const
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void SetStart(const VECTOR2I &aStart)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
VECTOR2I GetArcMid() const
virtual bool IsVisible() const
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
Class that other classes need to inherit from, in order to be inspectable.
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
const std::unordered_set< KIID > & GetConstrainedItems() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisibleCached(int aLayer) const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
LSET is a set of PCB_LAYER_IDs.
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
static const LSET & AllLayersMask()
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
std::optional< int > GetLocalThermalSpokeWidthOverride() const
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
VECTOR2I m_libEllipseCenter
void swapData(BOARD_ITEM *aImage) override
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
void SetEllipseCenter(const VECTOR2I &aPt) override
void SetCenter(const VECTOR2I &aCenter) override
EDA_ANGLE m_libEllipseStartAngle
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
virtual void syncLibCoords()
SHAPE_POLY_SET getHatchingKnockouts() const override
void SetBezierC1(const VECTOR2I &aPt) override
void SetCornerRadius(int aCornerRadius) override
std::optional< int > GetLocalSolderMaskMargin() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
VECTOR2I GetLibraryBezierC1() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
void SetWidth(int aWidth) override
EDA_ANGLE m_libEllipseEndAngle
void SetLibStrokeWidth(int aWidth)
void rebakeFromTransform(const TRANSFORM_TRS &aXform)
int GetWidth() const override
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
bool HasSolderMask() const
void SetEllipseStartAngle(const EDA_ANGLE &aA) override
void SetHasSolderMask(bool aVal)
std::optional< int > m_solderMaskMargin
int GetSolderMaskExpansion() const
void NormalizeForCompare() override
Normalize coordinates to compare 2 similar PCB_SHAPES similat to Normalize(), but also normalize SEGM...
void SetShape(SHAPE_T aShape) override
void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const override
Convert the item shape to a polyset.
void SetEllipseEndAngle(const EDA_ANGLE &aA) override
int m_libEllipseMinorRadius
const VECTOR2I GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
virtual void SetLayerSet(const LSET &aLayers) override
void SetEnd(const VECTOR2I &aEnd) override
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetLibraryEnd() const
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
bool IsProxyItem() const override
void SetEllipseRotation(const EDA_ANGLE &aA) override
const FOOTPRINT * transformFp() const
VECTOR2I GetLibraryStart() const
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool operator==(const PCB_SHAPE &aShape) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetEllipseMinorRadius(int aR) override
wxString GetFriendlyName() const override
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
STROKE_PARAMS GetStroke() const override
void SetIsProxyItem(bool aIsProxy=true) override
void RebakeWithScale(double aScaleX, double aScaleY)
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
void Move(const VECTOR2I &aMoveVector) override
Move this object.
std::vector< VECTOR2I > GetConnectionPoints() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
int getMaxError() const override
void SetStart(const VECTOR2I &aStart) override
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
void SetBezierC2(const VECTOR2I &aPt) override
void UpdateHatching() const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void Scale(double aScale)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SHAPE_POLY_SET GetLibraryPolyShape() const
void SetStroke(const STROKE_PARAMS &aStroke) override
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void CopyFrom(const BOARD_ITEM *aOther) override
VECTOR2I GetLibraryBezierC2() const
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
EDA_ANGLE m_libEllipseRotation
int m_libEllipseMajorRadius
VECTOR2I GetLibraryArcMid() const
void SetEllipseMajorRadius(int aR) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
const VECTOR2I & GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
SEG Segment(int aIndex) const
Return a copy of the aIndex-th segment in the line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
ITERATOR IterateWithHoles(int aOutline)
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
@ SOLDER_MASK_EXPANSION_CONSTRAINT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
#define PCB_EDIT_FRAME_NAME
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
bool IsSolderMaskLayer(int aLayer)
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_CONSTRAINT_SHADOW
Shadow layer for items bound to a constraint.
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#define UNIMPLEMENTED_FOR(type)
@ LEFT_RIGHT
Flip left to right (around the Y axis)
std::vector< TYPED_POINT2I > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static void transformPolyVertices(SHAPE_POLY_SET &aPoly, const TRANSFORM_TRS &aXform, bool aInverse)
static double fpScaleLinear(const FOOTPRINT *aFp)
static struct PCB_SHAPE_DESC _PCB_SHAPE_DESC
static bool isCopper(const PNS::ITEM *aItem)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
Utility functions for working with shapes.
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
const SHAPE_LINE_CHAIN chain
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
static double sweep(float aStart, float aEnd)
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_SHAPE_LOCATE_ELLIPSE_ARC_T
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_LOCATE_BOARD_EDGE_T
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_SHAPE_LOCATE_CIRCLE_T
@ PCB_SHAPE_LOCATE_SEGMENT_T
@ PCB_SHAPE_LOCATE_RECT_T
@ PCB_SHAPE_LOCATE_ELLIPSE_T
@ PCB_SHAPE_LOCATE_BEZIER_T
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_SHAPE_LOCATE_POLY_T
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM