61#define TO_3DU( x ) ( ( x ) * m_biuTo3Dunits )
63#define TO_SFVEC2F( vec ) SFVEC2F( TO_3DU( vec.x ), TO_3DU( -vec.y ) )
75 float aOuterRadius,
const BOARD_ITEM& aBoardItem )
77 if( aOuterRadius > aInnerRadius && aInnerRadius > 0.0f )
78 aContainer->
Add(
new RING_2D( aCenter, aInnerRadius, aOuterRadius, aBoardItem ) );
114 else if(
const PCB_TEXT* pcbText =
dynamic_cast<const PCB_TEXT*
>( aOwner ) )
128 penWidth_3DU, *aOwner );
141 callback_gal.DrawGlyphs( *cache );
166 addText( aDimension, aContainer, aDimension );
170 for(
const std::shared_ptr<SHAPE>& shape : aDimension->
GetShapes() )
172 switch( shape->Type() )
179 TO_3DU( linewidth ), *aOwner );
203 const std::bitset<LAYER_3D_END>& aFlags )
212 wxCHECK2( field,
continue );
220 if( field->GetLayer() == aLayerId && field->IsVisible() )
221 addText( field, aContainer, field );
226 switch( item->Type() )
241 if(
text->GetLayer() == aLayerId )
251 if( textbox->
GetLayer() == aLayerId )
252 addShape( textbox, aContainer, aFootprint );
261 if(
table->GetLayer() == aLayerId )
275 if( dimension->
GetLayer() == aLayerId )
276 addShape( dimension, aContainer, aFootprint );
286 addShape( shape, aContainer, aFootprint, aLayerId );
295 if( barcode->
GetLayer() == aLayerId )
296 addBarCode( barcode, aContainer, aFootprint );
314 switch( aTrack->
Type() )
319 float width3DU =
TO_3DU(
via->GetWidth( aLayer ) + aMargin * 2 );
349 if(
radius < std::numeric_limits<double>::min() || arc_angle.
IsZero() )
354 if( arcsegcount <= 1 )
361 circlesegcount = std::clamp( circlesegcount, 1, 128 );
365 arc->
GetWidth() + aMargin * 2, aDstContainer, *arc );
399 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
416 auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->
GetEffectiveShape( aLayer ) );
418 for(
const SHAPE* shape : padShapes->Shapes() )
420 switch( shape->Type() )
488 const int width = ellipse->
GetWidth();
522 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::createPadHole pad has no hole" ) );
531 TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
541 if( !
pad->IsOnLayer( aLayerId ) )
549 if( !
pad->IsOnCopperLayer() )
553 if( !
pad->FlashLayer( aLayerId ) )
563 margin.
x +=
pad->GetSolderMaskExpansion( aLayerId );
564 margin.
y +=
pad->GetSolderMaskExpansion( aLayerId );
569 margin +=
pad->GetSolderPasteMargin( aLayerId );
584 const EDA_ANGLE& aArcAngle,
int aCircleToSegmentsCount,
596 arc_end = arc_start = aStart;
603 std::swap( arc_start, arc_end );
604 arcAngle = -arcAngle;
613 curr_end = arc_start;
617 TO_3DU( aWidth ), aOwner );
619 curr_start = curr_end;
622 if( curr_end != arc_end )
625 TO_3DU( aWidth ), aOwner );
644 linewidth += margin * 2;
650 isHatchedFill =
false;
654 float linewidth3DU =
TO_3DU( linewidth );
666 if( isSolidFill || innerR3DU <= 0.0 )
676 addRING_2D( aContainer, center3DU, innerR3DU, outerR3DU, *aOwner );
715 for(
int ii = 0; ii < r_outline.
PointCount(); ii++ )
719 linewidth3DU, *aOwner );
730 linewidth3DU, *aOwner );
732 linewidth3DU, *aOwner );
734 linewidth3DU, *aOwner );
736 linewidth3DU, *aOwner );
750 EDA_ANGLE arcAngle = endAngle - startAngle;
783 for(
size_t i = 0; i + 1 < pts.size(); i++ )
786 linewidth3DU, *aOwner );
827 for(
int outlineIdx = 0; outlineIdx < polyShape.
OutlineCount(); ++outlineIdx )
834 std::vector<VECTOR2I> pts;
841 for(
size_t i = 0; i + 1 < pts.size(); i++ )
850 linewidth3DU, *aOwner );
886 for(
SHAPE* shape : shapes )
896 for(
SHAPE* shape : shapes )
903 wxFAIL_MSG( wxT(
"BOARD_ADAPTER::addShape no implementation for " )
921 for(
SHAPE* shape : shapes )
926 addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( a ), TO_SFVEC2F( b ),
927 linewidth3DU, *aOwner );
931 for(
SHAPE* shape : shapes )
951 std::vector<VECTOR2I> polygon;
952 aEnding.
GetShapes( aPoint, aTangent, linewidth, polygon );
954 if( polygon.empty() )
961 float stroke3DU =
TO_3DU( strokeW );
963 for(
size_t ii = 0; ii + 1 < polygon.size(); ii++ )
966 stroke3DU, *aOwner );
975 for(
size_t ii = 0; ii < polygon.size(); ii++ )
977 size_t next = ( ii + 1 ) % polygon.size();
980 stroke3DU, *aOwner );
1007 addText( aTextBox, aContainer, aOwner );
1044 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
1045 addText( cell, aContainer, aOwner );
1065 const float inner_radius3DU =
TO_3DU(
radius - aWidth / 2.0 );
1066 const float outer_radius3DU =
TO_3DU(
radius + aWidth / 2.0 );
1068 addRING_2D( aContainer, center3DU, inner_radius3DU, outer_radius3DU, *aPad );
1076 for(
int j = 0; j <
path.PointCount(); j++ )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void addPads(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
void createTrackWithMargin(const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, int aMargin=0)
void addSolidAreasShapes(const ZONE *aZone, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
void addFootprintShapes(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, const std::bitset< LAYER_3D_END > &aVisibilityFlags)
void createArcSegments(const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM &aOwner)
void createPadWithMargin(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const VECTOR2I &aMargin) const
void addBarCode(const PCB_BARCODE *aBarCode, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
void buildPadOutlineAsSegments(const PAD *aPad, PCB_LAYER_ID aLayer, CONTAINER_2D_BASE *aDstContainer, int aWidth)
void addTable(const PCB_TABLE *aTable, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM *aOwner)
void createPadHoleShape(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aInflateValue)
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
void addShape(const PCB_SHAPE *aShape, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM *aOwner, PCB_LAYER_ID aLayer)
double m_biuTo3Dunits
Scale factor to convert board internal units.
void addText(const EDA_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsKnockout() const
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Convert the item shape to a polyset.
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
constexpr int GetSizeMax() const
void Add(OBJECT_2D *aObject)
KICAD_T Type() const
Returns the type of object.
static bool ShortenSegmentForEndings(VECTOR2I &aStart, VECTOR2I &aEnd, const LINE_ENDING &aStartEnding, const LINE_ENDING &aEndEnding, int aLineWidth)
Shorten a segment body for line endings.
const SHAPE_POLY_SET & GetHatching() const
int GetRectangleWidth() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
SHAPE_POLY_SET & GetPolyShape()
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
std::vector< SHAPE * > MakeEffectiveShapesForStroking(int aLineWidth=-1) const
Make a set of SHAPE objects to hand to STROKE_PARAMS::Stroke().
bool GetShortenedBodyPolyPoints(const SHAPE_LINE_CHAIN &aOutline, int aOutlineIdx, std::vector< VECTOR2I > &aPoints, int aLineWidth) const
Copy an outline and apply line-ending body shortening when applicable.
bool IsHatchedFill() const
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
std::vector< VECTOR2I > GetRectCorners() const
const LINE_ENDING & GetStartEnding() const
wxString SHAPE_T_asString() const
int GetRectangleHeight() const
bool ShortenArcForEndings(EDA_ANGLE &aStartAngle, EDA_ANGLE &aArcAngle, double aRadius, int aLineWidth) const
Shorten an arc body for line endings.
std::vector< VECTOR2D > ShortenedBezierPolyline(int aLineWidth) const
Return the flattened Bezier polyline after line-ending shortening.
const LINE_ENDING & GetEndEnding() const
int GetCornerRadius() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
KIFONT::FONT * GetFont() const
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
virtual EDA_ANGLE GetDrawRotation() const
virtual VECTOR2I GetDrawPos() const
virtual wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
const TEXT_ATTRIBUTES & GetAttributes() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
PCB specific render settings.
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
LINE_ENDING_STYLE GetStyle() const
void GetShapes(const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, std::vector< VECTOR2I > &aPolygon) const
Generate ending geometry as polygon vertices at the given point and direction.
int GetStrokeWidth() const
Outline stroke width.
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Return a SHAPE_SEGMENT object representing the pad's hole.
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
bool HasHole() const override
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
bool IsDegenerated(int aThreshold=5) const
EDA_ANGLE GetAngle() const
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
Parameters and options when plotting/printing a board.
double GetDashedLineGapRatio() const
double GetDashedLineDashRatio() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
bool HasSolderMask() const
int GetSolderMaskExpansion() const
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
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
VECTOR2I GetPosition() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
std::vector< PCB_TABLECELL * > GetCells() const
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
A round rectangle shape, based on a rectangle and a radius.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aMaxError) const
Get the polygonal representation of the roundrect.
int GetWidth() const override
const SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError=DefaultAccuracyForPCB(), int *aActualError=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
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.
int SegmentCount() const
Return the number of segments in this line chain.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
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)
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
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.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const VECTOR2I & GetPosition() const
const VECTOR2I GetSize() const
const SEG & GetSeg() const
int GetWidth() const override
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
virtual int GetWidth() const
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
Handle a list of polygons defining a copper zone.
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
CORNER_STRATEGY
define how inflate transform build inflated polygon
@ ROUND_ALL_CORNERS
All angles are rounded.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
void addFILLED_CIRCLE_2D(CONTAINER_2D_BASE *aContainer, const SFVEC2F &aCenter, float aRadius, const BOARD_ITEM &aBoardItem)
void addROUND_SEGMENT_2D(CONTAINER_2D_BASE *aContainer, const SFVEC2F &aStart, const SFVEC2F &aEnd, float aWidth, const BOARD_ITEM &aBoardItem)
void addRING_2D(CONTAINER_2D_BASE *aContainer, const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, const BOARD_ITEM &aBoardItem)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
static const wxChar * m_logTrace
Trace mask used to enable or disable debug output for this class.
bool IsSolderMaskLayer(int aLayer)
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BARCODE class definition.
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
@ SH_POLY_SET
set of polygons (with holes, etc.)
@ SH_RECT
axis-aligned rectangle
@ SH_SIMPLE
simple polygon
@ SH_ELLIPSE
ellipse or elliptical arc
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
std::vector< FAB_LAYER_COLOR > dummy
LINE_STYLE
Dashed line types.
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
void ConvertPolygonToTriangles(const SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I