71 if(
color == COLOR4D::WHITE )
82 if( padNumber.IsEmpty() )
95 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
97 position = primitive->GetCenter();
101 padsize.
x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
102 padsize.
y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
115 if( padsize.
x > limit && padsize.
y > limit )
124 if( padsize.
x < ( padsize.
y * 0.95 ) )
127 std::swap( padsize.
x, padsize.
y );
133 tsize = std::min( tsize, padsize.
y );
163 if( plotOnCopperLayer )
174 const bool useUTF8 =
false;
175 const bool useQuoting =
false;
189 if( !plotOnExternalCopperLayer )
209 case PAD_ATTRIB::NPTH:
213 case PAD_ATTRIB::PTH :
217 case PAD_ATTRIB::CONN:
218 if( plotOnExternalCopperLayer )
222 case PAD_ATTRIB::SMD:
224 if( plotOnExternalCopperLayer )
234 if( plotOnExternalCopperLayer )
238 case PAD_PROP::FIDUCIAL_GLBL:
242 case PAD_PROP::FIDUCIAL_LOCAL:
246 case PAD_PROP::TESTPOINT:
247 if( plotOnExternalCopperLayer )
251 case PAD_PROP::HEATSINK:
255 case PAD_PROP::CASTELLATED:
260 case PAD_PROP::MECHANICAL:
282 case PAD_SHAPE::CIRCLE:
284 aPlotMode, &metadata );
287 case PAD_SHAPE::OVAL:
292 case PAD_SHAPE::RECTANGLE:
297 case PAD_SHAPE::ROUNDRECT:
303 case PAD_SHAPE::TRAPEZOID:
314 coord[0] =
VECTOR2I( -half_size.
x - trap_delta.
y, half_size.
y + trap_delta.
x );
315 coord[1] =
VECTOR2I( half_size.
x + trap_delta.
y, half_size.
y - trap_delta.
x );
316 coord[2] =
VECTOR2I( half_size.
x - trap_delta.
y, -half_size.
y + trap_delta.
x );
317 coord[3] =
VECTOR2I( -half_size.
x + trap_delta.
y, -half_size.
y - trap_delta.
x );
323 case PAD_SHAPE::CHAMFERED_RECT:
333 aPlotMode, &metadata );
340 case PAD_SHAPE::CUSTOM:
342 const std::shared_ptr<SHAPE_POLY_SET>& polygons =
345 if( polygons->OutlineCount() )
348 polygons.get(), aPlotMode, &metadata );
373 textItem = &aFootprint->
Value();
384 std::vector<PCB_TEXT*> texts;
389 if( field->IsReference() || field->IsValue() )
392 texts.push_back( field );
397 textItem =
dynamic_cast<const PCB_TEXT*
>( item );
400 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
405 if( !
text->IsVisible() )
408 textLayer =
text->GetLayer();
409 bool strikeout =
false;
420 if(
text->GetText() == wxT(
"${REFERENCE}" ) )
428 if(
text->GetText() == wxT(
"${VALUE}" ) )
441 switch( item->
Type() )
475 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
523 for(
const std::shared_ptr<SHAPE>& shape : aDim->
GetShapes() )
525 switch( shape->Type() )
529 const SEG& seg =
static_cast<const SHAPE_SEGMENT*
>( shape.get() )->GetSeg();
531 temp_item.
SetShape( SHAPE_T::SEGMENT );
542 int radius =
static_cast<const SHAPE_CIRCLE*
>( shape.get() )->GetRadius();
544 temp_item.
SetShape( SHAPE_T::CIRCLE );
562 int dx1, dx2, dy1, dy2, radius;
571 temp_item.
SetShape( SHAPE_T::CIRCLE );
586 temp_item.
SetShape( SHAPE_T::SEGMENT );
629 switch( item->Type() )
677 wxString defaultFontName;
687 if( shownText.IsEmpty() )
764 std::vector<VECTOR2I> positions;
765 wxArrayString strings_list;
767 positions.reserve( strings_list.Count() );
771 for(
unsigned ii = 0; ii < strings_list.Count(); ii++ )
773 wxString& txt = strings_list.Item( ii );
778 if( aStrikeout && strings_list.Count() == 1 )
779 strikeoutText(
static_cast<const PCB_TEXT*
>( aText ) );
786 strikeoutText(
static_cast<const PCB_TEXT*
>( aText ) );
827 for(
int idx = 0; idx < aPolysList.
OutlineCount(); ++idx )
861 int margin = thickness;
866 if( onSolderMaskLayer
871 thickness = std::max( margin, 0 );
895 else if( onCopperLayer )
918 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
922 case SHAPE_T::SEGMENT:
927 case SHAPE_T::CIRCLE:
930 int diameter = aShape->
GetRadius() * 2 + thickness;
935 diameter = std::max( diameter, 0 );
943 plotMode, &gbr_metadata );
955 plotMode, &gbr_metadata );
965 case SHAPE_T::BEZIER:
977 const SEG& seg = it.Get();
995 tmpPoly.
Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
999 FILL_T fill = aShape->
IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1025 case SHAPE_T::RECTANGLE:
1046 poly.
Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
1050 FILL_T fill_mode = aShape->
IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1079 for(
SHAPE* shape : shapes )
1085 m_plotter->ThickSegment( a, b, thickness, plotMode,
1090 for(
SHAPE* shape : shapes )
1116 lineWidth = stroke.GetWidth();
1117 lineStyle = stroke.GetLineStyle();
1121 [&](
const SHAPE& shape )
1126 m_plotter->ThickSegment( a, b, lineWidth, GetPlotMode(),
1134 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1160 for(
int col = 0; col < aTable->
GetColCount() - 1; ++col )
1162 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1168 strokeLine( topRight, cell->
GetEnd() );
1175 for(
int row = 0; row < aTable->
GetRowCount() - 1; ++row )
1177 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1183 strokeLine( botLeft, cell->
GetEnd() );
1200 strokeRect( pos, end );
1207 const EDA_ANGLE& aOrientation,
int aSmallDrill )
1212 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1213 drillSize.
x = std::min( aSmallDrill, drillSize.
x );
1217 drillSize.
x = std::clamp( drillSize.
x, 1, aPadSize.
x - 1 );
1219 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1222 drillSize.
y = std::clamp( drillSize.
y, 1, aPadSize.
y - 1 );
1273 for(
PAD*
pad : footprint->Pads() )
1275 if(
pad->GetDrillSize().x == 0 )
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString GetNetname() const
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
FOOTPRINT * GetParentFootprint() const
const KIFONT::METRICS & GetFontMetrics() const
EMBEDDED_FILES * GetEmbeddedFiles() override
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr Vec Centre() const
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
void PlotDrillMarks()
Draw a drill mark for pads and vias.
void PlotZone(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
void PlotPadNumber(const PAD *aPad, const COLOR4D &aColor)
void PlotBoardGraphicItem(const BOARD_ITEM *item)
Plot items like text and graphics but not tracks and footprints.
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics, bool aStrikeout=false)
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
void PlotShape(const PCB_SHAPE *aShape)
bool crossoutDNPItems(PCB_LAYER_ID aLayer)
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotPcbTarget(const PCB_TARGET *aMire)
void PlotTableBorders(const PCB_TABLE *aTable)
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
void plotOneDrillMark(PAD_DRILL_SHAPE aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
bool hideDNPItems(PCB_LAYER_ID aLayer)
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
COLOR4D GetColor(int aLayer) const
KICAD_T Type() const
Returns the type of object.
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetBezierC2() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
SHAPE_POLY_SET & GetPolyShape()
virtual void SetFilled(bool aFlag)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetShape(SHAPE_T aShape)
std::vector< VECTOR2I > GetRectCorners() const
void SetEnd(const VECTOR2I &aEnd)
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
bool IsPolyShapeValid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const VECTOR2I & GetTextPos() const
bool IsMultilineAllowed() const
virtual bool IsVisible() const
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
void GetLinePositions(std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
const TEXT_ATTRIBUTES & GetAttributes() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
bool GetAreFontsEmbedded() const
void PlotPolyAsRegion(const SHAPE_LINE_CHAIN &aPoly, FILL_T aFill, int aWidth, GBR_METADATA *aGbrMetadata)
Similar to PlotPoly(), plot a filled polygon using Gerber region, therefore adding X2 attributes to t...
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aPlotMode, void *aData)
Flash a chamfered round rect pad.
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)
virtual bool IsOutline() const
A color representation with 4 components: red, green, blue, alpha.
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
const wxString & GetDefaultFont() const
LSET is a set of PCB_LAYER_IDs.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
PAD_PROP GetProperty() const
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
PAD_ATTRIB GetAttribute() const
const wxString & GetPinFunction() const
const wxString & GetNumber() const
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
int GetChamferPositions(PCB_LAYER_ID aLayer) const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool GetPlotInvisibleText() const
PLOT_TEXT_MODE GetTextMode() const
bool GetSketchDNPFPsOnFabLayers() const
bool GetPlotReference() const
int GetSketchPadLineWidth() const
DRILL_MARKS GetDrillMarksType() const
bool GetPlotValue() const
bool GetPlotFPText() const
OUTLINE_MODE GetPlotMode() const
COLOR_SETTINGS * ColorSettings() const
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
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
STROKE_PARAMS GetStroke() const override
void SetStroke(const STROKE_PARAMS &aStroke) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
bool StrokeColumns() const
bool StrokeExternal() const
bool StrokeHeader() const
PCB_TABLECELL * GetCell(int aRow, int aCol) const
std::vector< PCB_TABLECELL * > GetCells() const
const STROKE_PARAMS & GetSeparatorsStroke() const
const STROKE_PARAMS & GetBorderStroke() const
VECTOR2I GetPosition() const override
VECTOR2I GetPosition() const override
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
virtual void ThickArc(const EDA_SHAPE &aArcShape, OUTLINE_MODE aTraceMode, void *aData, int aWidth)
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
Generic fallback: Cubic Bezier curve rendered as a polyline.
RENDER_SETTINGS * RenderSettings()
virtual PLOT_FORMAT GetPlotterType() const =0
Return the effective plot engine in use.
virtual void SetTextMode(PLOT_TEXT_MODE mode)
Change the current text mode.
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
Flash a trapezoidal pad.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
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.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
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)
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.
CONST_SEGMENT_ITERATOR CIterateSegments(int aFirst, int aLast, bool aIterateHoles=false) const
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (def...
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
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.
An abstract shape on 2D plane.
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.
bool IsOnCopperLayer() const override
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
double m_SmallDrillMarkSize
The diameter of the drill marks on print and plot outputs (in mm) when the "Drill marks" option is se...
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
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)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
constexpr int mmToIU(double mm) const
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_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I