44 poly_no_hole.
Append( aPoly );
51 for(
int ii = 0; ii < poly_no_hole.
OutlineCount(); ++ii )
93 const EDA_ANGLE& aArcAngle,
int aThickness )
108 const VECTOR2I& aCtrl2,
int aThickness )
170 if( aPrimitivesList.size() )
180 for(
const std::shared_ptr<PCB_SHAPE>& prim : aPrimitivesList )
212 if( !primitive->IsAnnotationProxy() )
213 primitive->TransformShapeToPolygon( polyset,
UNDEFINED_LAYER, 0, aError, aErrorLoc );
263 const int minSteps = 10;
264 const int maxSteps = 50;
268 auto bbox = poly.
BBox();
270 if( bbox.GetWidth() < bbox.GetHeight() )
273 stepsY = minSteps * (double) bbox.
GetHeight() / (double )(bbox.GetWidth() + 1);
278 stepsX = minSteps * (double) bbox.GetWidth() / (double )(bbox.GetHeight() + 1);
281 stepsX = std::max(minSteps, std::min( maxSteps, stepsX ) );
282 stepsY = std::max(minSteps, std::min( maxSteps, stepsY ) );
286 int64_t minDist = std::numeric_limits<int64_t>::max();
298 std::optional<VECTOR2I> bestAnchor( []()->std::optional<VECTOR2I> {
return std::nullopt; }() );
300 for(
int y = 0; y < stepsY ; y++ )
302 for(
int x = 0; x < stepsX; x++ )
305 p.
x +=
rescale( x, bbox.GetWidth(), (stepsX - 1) );
306 p.
y +=
rescale( y, bbox.GetHeight(), (stepsY - 1) );
314 if( distEdge >= minDistEdge )
constexpr int ARC_HIGH_DEF
constexpr int ARC_LOW_DEF
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetHeight() const
virtual void SetParent(EDA_ITEM *aParent)
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
void SetFilled(bool aFlag)
void SetPolyShape(const SHAPE_POLY_SET &aShape)
void SetStart(const VECTOR2I &aStart)
void SetShape(SHAPE_T aShape)
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
void SetIsAnnotationProxy(bool aIsProxy=true)
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
void AddPrimitiveArc(const VECTOR2I &aCenter, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aThickness)
void AppendPrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Import a custom shape primitive list (composed of basic shapes) and add items to the current list.
void AddPrimitiveAnnotationBox(const VECTOR2I &aStart, const VECTOR2I &aEnd)
Has meaning only for custom shape pads.
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
void DeletePrimitivesList()
Clear the basic shapes list.
void AddPrimitiveSegment(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aThickness)
void AddPrimitiveCurve(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCtrl1, const VECTOR2I &aCtrl2, int aThickness)
bool GetBestAnchorPosition(VECTOR2I &aPos)
void AddPrimitiveCircle(const VECTOR2I &aCenter, int aRadius, int aThickness, bool aFilled)
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void AddPrimitivePoly(const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
void AddPrimitiveRect(const VECTOR2I &aStart, const VECTOR2I &aEnd, int aThickness, bool aFilled)
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
void addPadPrimitivesToPolygon(SHAPE_POLY_SET *aMergedPolygon, int aError, ERROR_LOC aErrorLoc) const
const VECTOR2I & GetSize() const
PAD_SHAPE GetAnchorPadShape() const
void SetStroke(const STROKE_PARAMS &aStroke) override
int Distance(const VECTOR2I &aP, bool aOutlineOnly=false) const
Compute the minimum distance between the line chain and a point aP.
Represent a set of closed polygons.
bool HasHoles() const
Return true if the polygon set has any holes that share a vertex.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
const SHAPE_LINE_CHAIN Outline() const
Simple container to manage line stroke parameters.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
double EuclideanNorm(const VECTOR2I &vector)
T rescale(T aNumerator, T aValue, T aDenominator)
Scale a number (value) by rational (numerator/denominator).