25#include <google/protobuf/any.pb.h>
26#include <magic_enum.hpp>
46#include <api/board/board_types.pb.h>
65static BOARD_ELLIPSE decompose2x2(
double m00,
double m01,
double m10,
double m11 )
67 const double A = m00 * m00 + m10 * m10;
68 const double B = m00 * m01 + m10 * m11;
69 const double C = m01 * m01 + m11 * m11;
71 const double diff =
A -
C;
72 const double rad = std::hypot( diff, 2.0 *
B );
73 const double lambda1 = (
A +
C + rad ) * 0.5;
74 const double lambda2 = (
A +
C - rad ) * 0.5;
76 const double sigma1 = std::sqrt( std::max( 0.0, lambda1 ) );
77 const double sigma2 = std::sqrt( std::max( 0.0, lambda2 ) );
98 const double vn = std::hypot( v0x, v0y );
107 u0x = ( m00 * v0x + m01 * v0y ) / sigma1;
108 u0y = ( m10 * v0x + m11 * v0y ) / sigma1;
121static BOARD_ELLIPSE decomposeBoardEllipse(
const TRANSFORM_TRS& aXform,
int aLibMajor,
int aLibMinor,
128 const double phi = aLibRotation.
AsRadians();
129 const double cTheta = std::cos( theta );
130 const double sTheta = std::sin( theta );
131 const double cPhi = std::cos( phi );
132 const double sPhi = std::sin( phi );
133 const double a = aLibMajor;
134 const double b = aLibMinor;
136 const double m00 = a * ( sx * cTheta * cPhi - sy * sTheta * sPhi );
137 const double m01 = -b * ( sx * cTheta * sPhi + sy * sTheta * cPhi );
138 const double m10 = a * ( sx * sTheta * cPhi + sy * cTheta * sPhi );
139 const double m11 = b * ( -sx * sTheta * sPhi + sy * cTheta * cPhi );
141 return decompose2x2( m00, m01, m10, m11 );
146static BOARD_ELLIPSE composeLibEllipse(
const TRANSFORM_TRS& aXform,
double aBoardMajor,
double aBoardMinor,
152 const double beta = aBoardRotation.
AsRadians();
154 const double li00 = std::cos( theta ) / sx;
155 const double li01 = std::sin( theta ) / sx;
156 const double li10 = -std::sin( theta ) / sy;
157 const double li11 = std::cos( theta ) / sy;
159 const double e00 = aBoardMajor * std::cos( beta );
160 const double e01 = -aBoardMinor * std::sin( beta );
161 const double e10 = aBoardMajor * std::sin( beta );
162 const double e11 = aBoardMinor * std::cos( beta );
164 return decompose2x2( li00 * e00 + li01 * e10, li00 * e01 + li01 * e11, li10 * e00 + li11 * e10,
165 li10 * e01 + li11 * e11 );
220 *
this = *
static_cast<const PCB_SHAPE*
>( aOther );
228 BoardGraphicShape msg;
232 msg.mutable_id()->set_value(
m_Uuid.AsStdString() );
233 msg.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
239 PadCustomShapeOptions* options = msg.mutable_pad_custom_shape_options();
244 case SHAPE_T::SEGMENT: options->set_is_thermal_spoke_template(
true );
break;
245 default: wxFAIL_MSG( wxT(
"Unexpected proxy shape type" ) );
break;
250 msg.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
252 msg.mutable_parent()->set_value(
board->m_Uuid.AsStdString() );
256 SolderMaskOverrides* sm = msg.mutable_solder_mask();
257 sm->set_expose_copper(
true );
264 aContainer.PackFrom( msg );
273 BoardGraphicShape msg;
275 if( !aContainer.UnpackTo( &msg ) )
291 SetLocked( msg.locked() == types::LS_LOCKED );
298 if( msg.has_pad_custom_shape_options() )
300 switch( msg.pad_custom_shape_options().role_case() )
302 case PadCustomShapeOptions::kIsNumberBox:
308 case PadCustomShapeOptions::kIsThermalSpokeTemplate:
314 case PadCustomShapeOptions::ROLE_NOT_SET:
319 if( msg.has_solder_mask() )
323 if( msg.solder_mask().has_solder_mask_margin() )
343 bool sametype =
false;
345 for(
KICAD_T scanType : aScanTypes )
395 &&
GetBoard()->GetDesignSettings().m_DRCEngine->HasRulesForConstraintType(
412 margin =
board->GetDesignSettings().m_SolderMaskExpansion;
417 margin = std::max( margin, -
GetWidth() / 2 );
447 if( layermask.test(
F_Cu ) )
450 if( layermask.test(
B_Cu ) )
473 std::vector<VECTOR2I> ret;
489 ret.emplace_back( pt.m_point );
500 ret.emplace_back(
GetEnd() );
504 for(
auto iter =
GetPolyShape().CIterate(); iter; ++iter )
505 ret.emplace_back( *iter );
511 ret.emplace_back( pt );
518 const double cosPhi = std::cos( phi );
519 const double sinPhi = std::sin( phi );
536 const double cosPhi = std::cos( phi );
537 const double sinPhi = std::sin( phi );
540 auto eval = [&](
double theta ) ->
VECTOR2I
542 const double lx = a * std::cos( theta );
543 const double ly = b * std::sin( theta );
550 if( thetaEnd < thetaStart )
551 thetaEnd += 2.0 *
M_PI;
553 ret.emplace_back( eval( thetaStart ) );
554 ret.emplace_back( eval( thetaEnd ) );
555 ret.emplace_back( eval( 0.5 * ( thetaStart + thetaEnd ) ) );
593 item->TransformShapeToPolygon( knockouts, layer, margin, maxError,
ERROR_OUTSIDE );
606 if( item->GetLayer() == layer && item->GetBoundingBox().Intersects( bbox ) )
607 knockoutItem( item );
619 knockouts.
Append( footprint->GetCourtyard( layer ) );
622 footprint->RunOnChildren(
630 knockoutItem( item );
665 return s == 1.0 ? lib :
KiROUND( lib * s );
719 std::vector<VECTOR2I> pts;
730 pts.emplace_back( pt );
738 while( pts.size() < 4 )
739 pts.emplace_back( pts.back() +
VECTOR2I( 10, 10 ) );
776 return seg.A.y == seg.B.y;
782 return seg.A.x == seg.B.x;
790 if( horizontal( outline.
Segment( 0 ) )
791 && vertical( outline.
Segment( 1 ) )
792 && horizontal( outline.
Segment( 2 ) )
793 && vertical( outline.
Segment( 3 ) ) )
801 else if( vertical( outline.
Segment( 0 ) )
802 && horizontal( outline.
Segment( 1 ) )
803 && vertical( outline.
Segment( 2 ) )
804 && horizontal( outline.
Segment( 3 ) ) )
824 if( ( libStart.
x > libEnd.
x ) || ( libStart.
x == libEnd.
x && libStart.
y < libEnd.
y ) )
839 rotate( aRotCentre, aAngle );
849 bool mirrorLib =
false;
858 double sx = 1.0, sy = 1.0;
874 p.x = 2 * libCenter.
x - p.x;
876 p.y = 2 * libCenter.
y - p.y;
900 for(
auto it =
m_libPoly.IterateWithHoles(); it; it++ )
943 flip( aCentre, aFlipDirection );
1016 xform.
SetScale( aScaleX, aScaleY );
1049 if( minorRadius > majorRadius )
1051 std::swap( majorRadius, minorRadius );
1074 int libRadius = (
m_libStart - libCenter ).EuclideanNorm();
1094 if( wrap( midAngle, startAngle ) > wrap( endAngle, startAngle ) )
1095 std::swap( startAngle, endAngle );
1097 while( endAngle < startAngle )
1100 if( minorRadius > majorRadius )
1102 std::swap( majorRadius, minorRadius );
1172 std::unique_ptr<SHAPE_ELLIPSE> libEllipse;
1193 for(
int ii = 0; ii <
chain.PointCount(); ++ii )
1239 for(
int ii = 0; ii < rounded.
Outline( 0 ).PointCount(); ++ii )
1288 return fp->GetTransform().InverseApply(
GetArcMid() );
1300 return fp->GetTransform().InverseApply(
GetBezierC1() );
1312 return fp->GetTransform().InverseApply(
GetBezierC2() );
1410 bool hasXform =
false;
1414 double sx = 1.0, sy = 1.0;
1415 static_cast<const PAD*
>(
static_cast<const BOARD_ITEM*
>(
GetParent() ) )->GetPrimitiveLibScale( sx, sy );
1417 hasXform = ( sx != 1.0 || sy != 1.0 );
1421 xform = fp->GetTransform();
1471 for(
auto it =
m_libPoly.IterateWithHoles(); it; it++ )
1521 flip( aCentre, aFlipDirection );
1527 PAD* parentPad =
nullptr;
1533 for(
PAD*
pad : fp->Pads() )
1535 if(
pad->IsEntered() )
1605 checkLayer = parent->GetLayer();
1620 std::vector<int> layers;
1621 layers.reserve( 5 );
1632 layers.push_back(
F_Mask );
1634 layers.push_back(
B_Mask );
1653 aList.emplace_back(
_(
"Footprint" ), parent->GetReference() );
1656 aList.emplace_back(
_(
"Type" ),
_(
"Drawing" ) );
1659 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
1685 return wxString::Format(
_(
"%s %s of %s on %s" ),
1693 return wxString::Format(
_(
"%s %s on %s" ),
1703 return wxString::Format(
_(
"%s of %s on %s" ),
1710 return wxString::Format(
_(
"%s on %s" ),
1750 bbox.
Merge( endingsBBox );
1808 if( aFirst->
Type() != aSecond->
Type() )
1809 return aFirst->
Type() < aSecond->
Type();
1839 return width * width;
1845 return width * width;
1856 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
1857 bool ignoreLineWidth )
const
1865 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
1879 return *
this == other;
1925 double similarity = 1.0;
1971 if( layerEnum.
Choices().GetCount() == 0 )
1986 auto isPolygonOrEllipse =
1991 const SHAPE_T t = shape->GetShape();
1999 isPolygonOrEllipse );
2001 isPolygonOrEllipse );
2006 auto isNotBezierOrEllipseArc =
2011 const SHAPE_T t = shape->GetShape();
2019 isNotBezierOrEllipseArc );
2030 auto isNotCircleOrEllipse =
2035 const SHAPE_T t = shape->GetShape();
2043 isNotCircleOrEllipse );
2045 isNotCircleOrEllipse );
2047 isNotCircleOrEllipse );
2049 isNotCircleOrEllipse );
2061 return shape->IsOnCopperLayer();
2069 auto isPadEditMode =
2070 [](
BOARD* aBoard ) ->
bool
2072 if( aBoard && aBoard->IsFootprintHolder() )
2074 for(
FOOTPRINT* fp : aBoard->Footprints() )
2076 for(
PAD*
pad : fp->Pads() )
2078 if(
pad->IsEntered() )
2087 auto showNumberBoxProperty =
2093 return isPadEditMode( shape->GetBoard() );
2099 auto showSpokeTemplateProperty =
2105 return isPadEditMode( shape->GetBoard() );
2111 const wxString groupPadPrimitives =
_HKI(
"Pad Primitives" );
2115 groupPadPrimitives )
2121 groupPadPrimitives )
2125 const wxString groupTechLayers =
_HKI(
"Technical Layers" );
2127 auto isExternalCuLayer =
2130 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
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() const
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
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
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.
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings, bool aCheckSide) override
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
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.
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.
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 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.
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.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
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 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)
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