33#include "../3d_rendering/raytracing/shapes2D/ring_2d.h"
34#include "../3d_rendering/raytracing/shapes2D/filled_circle_2d.h"
35#include "../3d_rendering/raytracing/shapes2D/round_segment_2d.h"
36#include "../3d_rendering/raytracing/shapes2D/triangle_2d.h"
61#define TO_3DU( x ) ( ( x ) * m_biuTo3Dunits )
63#define TO_SFVEC2F( vec ) SFVEC2F( TO_3DU( vec.x ), TO_3DU( -vec.y ) )
91 callback_gal.SetIsFill( font->
IsOutline() );
92 callback_gal.SetIsStroke( font->
IsStroke() );
115 if( penWidth_3DU == 0.0 )
148 addText( aDimension, aContainer, aDimension );
152 for(
const std::shared_ptr<SHAPE>& shape : aDimension->
GetShapes() )
154 switch( shape->Type() )
158 const SEG& seg =
static_cast<const SHAPE_SEGMENT*
>( shape.get() )->GetSeg();
161 TO_3DU( linewidth ), *aOwner ) );
167 int radius =
static_cast<const SHAPE_CIRCLE*
>( shape.get() )->GetRadius();
195 switch( item->Type() )
201 if(
text->GetLayer() == aLayerId &&
text->IsVisible() )
211 if( textbox->
GetLayer() == aLayerId )
213 addShape( textbox, aContainer, aFootprint );
214 addText( textbox, aContainer, aFootprint );
228 if( dimension->
GetLayer() == aLayerId )
229 addShape( dimension, aContainer, aFootprint );
239 addShape( shape, aContainer, aFootprint );
256 switch( aTrack->
Type() )
262 if( radius3DU > 0.0 )
280 if( arcsegcount <= 1 )
287 circlesegcount = std::max( 1, std::min( circlesegcount, 128 ) );
291 circlesegcount, arc->
GetWidth(), aDstContainer, *arc );
336 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
341 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
347 clearance = { 0, 0 };
351 auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->
GetEffectiveShape() );
353 for(
const SHAPE* shape : padShapes->Shapes() )
355 switch( shape->Type() )
365 if( width3DU == 0.0 )
390 if( radius3DU > 0.0 )
428 if( width3DU == 0.0 )
468 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
474 if( slot->GetSeg().A == slot->GetSeg().B )
477 TO_3DU( slot->GetWidth() / 2 + aInflateValue ),
484 TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
492 bool aSkipPlatedPads,
bool aSkipNonPlatedPads )
496 if( !
pad->IsOnLayer( aLayerId ) )
506 if(
pad->GetDrillSize() ==
pad->GetSize() &&
pad->GetOffset() ==
VECTOR2I( 0, 0 ) )
508 switch(
pad->GetShape() )
533 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
536 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
542 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
545 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
552 margin.
x +=
pad->GetSolderMaskExpansion();
553 margin.
y +=
pad->GetSolderMaskExpansion();
558 margin +=
pad->GetSolderPasteMargin();
573 const EDA_ANGLE& aArcAngle,
int aCircleToSegmentsCount,
585 arc_end = arc_start = aStart;
592 std::swap( arc_start, arc_end );
593 arcAngle = -arcAngle;
602 curr_end = arc_start;
613 curr_start = curr_end;
616 if( curr_end != arc_end )
634 const int linewidth = aShape->
GetWidth() + 1;
647 if( inner_radius3DU < 0 )
648 inner_radius3DU = 0.0;
650 if( outer_radius3DU == 0.0 )
661 aContainer->
Add(
new RING_2D( center3DU, inner_radius3DU, outer_radius3DU,
685 TO_3DU( linewidth ), *aOwner ) );
687 TO_3DU( linewidth ), *aOwner ) );
689 TO_3DU( linewidth ), *aOwner ) );
691 TO_3DU( linewidth ), *aOwner ) );
700 segCount, linewidth, aContainer, *aOwner );
708 const double linewidth3DU =
TO_3DU( linewidth );
710 if( linewidth3DU == 0.0 )
743 wxFAIL_MSG( wxT(
"BOARD_ADAPTER::addShape no implementation for " )
748 else if( linewidth > 0 )
753 double width3DU =
TO_3DU( linewidth );
761 for(
SHAPE* shape : shapes )
776 for(
SHAPE* shape : shapes )
797 const int radius = aPad->
GetSize().
x / 2;
798 const float inner_radius3DU =
TO_3DU( radius - aWidth / 2 );
799 const float outer_radius3DU =
TO_3DU( radius + aWidth / 2 );
801 aContainer->
Add(
new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aPad ) );
810 for(
int j = 0; j <
path.PointCount(); j++ )
constexpr int ARC_HIGH_DEF
void addPads(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
void addFootprintShapes(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
void addSolidAreasShapes(const ZONE *aZone, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
void createPadWithMargin(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const VECTOR2I &aMargin) const
const BOARD * GetBoard() const noexcept
void transformArcToSegments(const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aOwner)
void buildPadOutlineAsSegments(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
void addShape(const PCB_SHAPE *aShape, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM *aOwner)
void createTrack(const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer)
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
OBJECT_2D * createPadWithDrill(const PAD *aPad, int aInflateValue)
double m_biuTo3Dunits
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
void addText(const EDA_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual bool IsKnockout() const
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
const PCB_PLOT_PARAMS & GetPlotOptions() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Add(OBJECT_2D *aObject)
KICAD_T Type() const
Returns the type of object.
EDA_ANGLE GetArcAngle() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
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
wxString SHAPE_T_asString() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void TransformBoundingBoxToPolygon(SHAPE_POLY_SET *aBuffer, int aClearance) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
virtual EDA_ANGLE GetDrawRotation() const
virtual VECTOR2I GetDrawPos() const
const TEXT_ATTRIBUTES & GetAttributes() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
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)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
virtual bool IsStroke() const
virtual bool IsOutline() const
PCB specific render settings.
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
VECTOR2I ShapePos() const
PAD_SHAPE GetShape() const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
bool HasHole() const override
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
const VECTOR2I & GetSize() 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.
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
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
const VECTOR2I GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int SegmentCount() const
Return the number of segments in this line chain.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
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 Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
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 NewOutline()
Creates a new hole in a given outline.
const VECTOR2I & GetPosition() const
const VECTOR2I GetSize() const
const SEG & GetSeg() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
An abstract shape on 2D plane.
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
PLOT_DASH_TYPE GetPlotStyle() const
Handle a list of polygons defining a copper zone.
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knocking out text.
static const wxChar * m_logTrace
Trace mask used to enable or disable debug output for this class.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
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)
@ NPTH
like PAD_PTH, but not plated
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
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
std::vector< FAB_LAYER_COLOR > dummy
PLOT_DASH_TYPE
Dashed line types.
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)
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".