72 wxCHECK( aBoard && aPlotter && aLayers.size(), );
74 for(
LSEQ seq = aLayers; seq; ++seq )
83 std::vector<wxString> properties;
86 _(
"Reference designator" ),
87 fp->Reference().GetShownText() ) );
91 fp->Value().GetShownText() ) );
93 for(
const auto& [
name, value ] : fp->GetProperties() )
98 fp->GetFPIDAsString() ) );
102 fp->GetDescription() ) );
106 fp->GetKeywords() ) );
125 LSET layer_mask( aLayer );
154 if( soldermask_min_thickness == 0 )
164 soldermask_min_thickness );
273 bool onFrontFab = (
LSET(
F_Fab ) & aLayerMask ).any();
274 bool onBackFab = (
LSET(
B_Fab ) & aLayerMask ).any();
293 for(
PAD*
pad : footprint->Pads() )
297 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
300 ( ( onFrontFab &&
pad->GetLayerSet().Contains(
F_Cu ) ) ||
301 ( onBackFab &&
pad->GetLayerSet().Contains(
B_Cu ) ) ) )
312 if( onCopperLayer && !
pad->FlashLayer( aLayerMask ) )
318 if( aLayerMask.count() == 1 )
324 if( (
pad->GetLayerSet() & aLayerMask )[
B_Cu] )
327 if( (
pad->GetLayerSet() & aLayerMask )[
F_Cu] )
330 if( sketchPads && aLayerMask[
F_Fab] )
332 else if( sketchPads && aLayerMask[
B_Fab] )
342 if( onSolderMaskLayer )
343 margin.
x = margin.
y =
pad->GetSolderMaskExpansion();
345 if( onSolderPasteLayer )
346 margin =
pad->GetSolderPasteMargin();
352 int mask_clearance = margin.
x;
361 double padCornerRadius =
pad->GetRoundRectCornerRadius();
366 && ( padPlotsSize.
x <= 0 || padPlotsSize.
y <= 0 ) )
369 switch(
pad->GetShape() )
373 pad->SetSize( padPlotsSize );
377 (
pad->GetSize() ==
pad->GetDrillSize() ) &&
387 pad->SetSize( padPlotsSize );
389 if( mask_clearance > 0 )
392 pad->SetRoundRectCornerRadius( mask_clearance );
404 if( mask_clearance == 0 )
415 int dx = padSize.
x / 2;
416 int dy = padSize.
y / 2;
417 int ddx = padDelta.
x / 2;
418 int ddy = padDelta.
y / 2;
420 outline.
Append( -dx - ddy, dy + ddx );
421 outline.
Append( dx + ddy, dy - ddx );
422 outline.
Append( dx - ddy, -dy + ddx );
423 outline.
Append( -dx + ddy, -dy - ddx );
431 dummy.DeletePrimitivesList();
432 dummy.AddPrimitivePoly( outline, 0,
true );
448 int initial_radius =
pad->GetRoundRectCornerRadius();
449 pad->SetSize( padPlotsSize );
450 pad->SetRoundRectCornerRadius( std::max( initial_radius + mask_clearance, 0 ) );
457 if( mask_clearance == 0 )
460 pad->SetSize( padPlotsSize );
485 dummy.DeletePrimitivesList();
486 dummy.AddPrimitivePoly( outline, 0,
true );
492 dummy.SetPosition(
pad->GetPosition() );
493 dummy.SetOrientation(
pad->GetOrientation() );
506 pad->MergePrimitivesAsPolygon( &shape );
513 dummy.DeletePrimitivesList();
514 dummy.AddPrimitivePoly( shape, 0,
true );
519 if( mask_clearance < 0 )
520 dummy.SetSize( padPlotsSize );
528 pad->SetSize( padSize );
529 pad->SetDelta( padDelta );
530 pad->SetShape( padShape );
531 pad->SetRoundRectCornerRadius( padCornerRadius );
535 aPlotter->
Bookmark( footprint->GetBoundingBox(), footprint->GetReference(),
_(
"Footprints" ) );
545 if( isOnCopperLayer )
555 const PCB_VIA*
via = dyn_cast<const PCB_VIA*>( track );
563 LSET via_mask_layer =
via->GetLayerSet();
567 if( via_mask_layer[
B_Cu] )
568 via_mask_layer.set(
B_Mask );
570 if( via_mask_layer[
F_Cu] )
571 via_mask_layer.set(
F_Mask );
574 if( !( via_mask_layer & aLayerMask ).any() )
578 double width_adj = 0;
581 via_margin =
via->GetSolderMaskExpansion();
586 int diameter =
via->GetWidth() + 2 * via_margin + width_adj;
589 if( onCopperLayer && !
via->FlashLayer( aLayerMask ) )
621 if( !aLayerMask[track->GetLayer()] )
628 gbr_metadata.
SetNetName( track->GetNetname() );
641 width, plotMode, &gbr_metadata );
646 width, plotMode, &gbr_metadata );
651 aPlotter->
ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
663 for(
const ZONE* zone : aBoard->
Zones() )
667 if( !aLayerMask[layer] )
675 if( zone->IsIsland( layer, i ) )
687 dummy.SetNet( &nonet );
722 std::vector<VECTOR2I> cornerList;
727 for(
int kk = 0; kk <= outlines.
HoleCount(ii); kk++ )
731 ( kk == 0 ) ? outlines.
COutline( ii ) : outlines.
CHole( ii, kk - 1 );
746 for(
PAD*
pad : footprint->Pads() )
750 std::shared_ptr<SHAPE_SEGMENT> slot =
pad->GetEffectiveHoleShape();
752 if( slot->GetSeg().A == slot->GetSeg().B )
754 int drill = std::min( smallDrill, slot->GetWidth() );
762 slot->GetWidth(),
SKETCH,
nullptr );
772 const PCB_VIA*
via = dyn_cast<const PCB_VIA*>( track );
774 if(
via &&
via->IsOnLayer( layer ) )
822 boardOutline = &buffer;
826 int inflate = aMinThickness / 2 - 1;
857 footprint->TransformPadsToPolySet( initialPolys, layer, 0, maxError,
ERROR_OUTSIDE );
859 footprint->TransformPadsToPolySet( areas, layer, inflate, maxError,
ERROR_OUTSIDE );
861 for(
const BOARD_ITEM* item : footprint->GraphicalItems() )
866 item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
ERROR_OUTSIDE );
869 item->TransformShapeToPolygon( areas, layer, inflate, maxError,
ERROR_OUTSIDE );
881 const PCB_VIA*
via = dyn_cast<const PCB_VIA*>( track );
884 if( !
via || !
via->IsOnLayer( layer ) )
887 int clearance =
via->GetSolderMaskExpansion();
890 via->TransformShapeToPolygon( initialPolys, layer, clearance, maxError,
ERROR_OUTSIDE );
893 clearance += inflate;
894 via->TransformShapeToPolygon( areas, layer, clearance, maxError,
ERROR_OUTSIDE );
906 if( item->IsOnLayer( layer ) )
909 item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
ERROR_OUTSIDE );
911 item->TransformShapeToPolygon( areas, layer, inflate, maxError,
ERROR_OUTSIDE );
921 if( !zone->IsOnLayer( layer ) )
925 zone->TransformSmoothedOutlineToPolygon( areas, inflate + zone_margin, maxError,
929 zone->TransformSmoothedOutlineToPolygon( initialPolys, zone_margin, maxError,
939 areas.
Deflate( inflate, numSegs );
987 constexpr double poly_min_area_mm2 = 0.01;
989 if( curr_area < poly_min_area_mm2 )
1013 bool autocenter =
false;
1022 sheet_info = &pageA4;
1024 paperscale = (double) paperSizeIU.
x / pageSizeIU.
x;
1029 sheet_info = &pageInfo;
1030 paperSizeIU = pageSizeIU;
1034 autocenter = (aPlotOpts->
GetScale() != 1.0);
1041 double compound_scale;
1045 if( aPlotOpts->
GetAutoScale() && boardSize.
x > 0 && boardSize.
y > 0 )
1047 double xscale = (paperSizeIU.
x * 0.8) / boardSize.
x;
1048 double yscale = (paperSizeIU.
y * 0.8) / boardSize.
y;
1050 compound_scale = std::min( xscale, yscale ) * paperscale;
1054 compound_scale = aPlotOpts->
GetScale() * paperscale;
1063 offset.
x =
KiROUND( boardCenter.
x - ( paperSizeIU.
x / 2.0 ) / compound_scale );
1064 offset.
y =
KiROUND( boardCenter.
y - ( paperSizeIU.
y / 2.0 ) / compound_scale );
1097 BOX2I area = aBbbox;
1127 const wxString& aFullFileName,
const wxString& aSheetName,
1128 const wxString& aSheetPath )
1140 plotter = DXF_plotter;
1148 plotter = PS_plotter;
1161 plotter = HPGL_plotter;
1170 "Invalid board layer %d, cannot build a valid Gerber file header",
1205 if( plotter->
OpenFile( aFullFileName ) )
constexpr EDA_IU_SCALE pcbIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const VECTOR2I & GetAuxOrigin()
int m_SolderMaskExpansion
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const PAGE_INFO & GetPageSettings() const
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines) const
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
TITLE_BLOCK & GetTitleBlock()
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
FOOTPRINTS & Footprints()
const std::map< wxString, wxString > & GetProperties() const
const wxString & GetFileName() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const Vec & GetOrigin() const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
const Vec & GetSize() const
void PlotDrillMarks()
Draw a drill mark for pads and vias.
void SetLayerSet(LSET aLayerMask)
void PlotPcbGraphicItem(const BOARD_ITEM *item)
void PlotFilledAreas(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
void PlotPad(const PAD *aPad, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
void PlotFootprintShape(const FP_SHAPE *aShape)
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotBoardGraphicItems()
Plot items like text and graphics but not tracks and footprints.
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
COLOR4D GetColor(int aLayer) const
When creating polygons to create a clearance polygonal area, the polygon must be same or bigger than ...
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
void UseX2format(bool aEnable)
void UseX2NetAttributes(bool aEnable)
void DisableApertMacros(bool aDisable)
Disable Aperture Macro (AM) command, only for broken Gerber Readers.
virtual void SetPenSpeed(int speed)
virtual void SetPenNumber(int number)
virtual void SetPenDiameter(double diameter)
A color representation with 4 components: red, green, blue, alpha.
PCB specific render settings.
void LoadColors(const COLOR_SETTINGS *aSettings) override
void SetDefaultPenWidth(int aWidth)
void SetLayerName(const wxString &aLayerName)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
LSEQ SeqStackupBottom2Top() const
Return the sequence that is typical for a bottom-to-top stack-up.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Handle the data for a net.
Describe the page size and margins of a paper page on which to eventually print or plot.
const VECTOR2I GetSizeIU(double aIUScale) const
Gets the page size in internal units.
EDA_ANGLE GetAngle() const
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Parameters and options when plotting/printing a board.
PLOT_FORMAT GetFormat() const
bool GetSkipPlotNPTH_Pads() const
void SetDrillMarksType(DRILL_MARKS aVal)
bool GetUseAuxOrigin() const
void SetSkipPlotNPTH_Pads(bool aSkip)
DXF_UNITS GetDXFPlotUnits() const
bool GetAutoScale() const
PLOT_TEXT_MODE GetTextMode() const
double GetHPGLPenDiameter() const
unsigned GetSvgPrecision() const
unsigned GetBlackAndWhite() const
bool GetDXFPlotPolygonMode() const
void SetMirror(bool aFlag)
bool GetSketchPadsOnFabLayers() const
bool GetSubtractMaskFromSilk() const
int GetGerberPrecision() const
int GetHPGLPenSpeed() const
double GetFineScaleAdjustY() const
int GetHPGLPenNum() const
DRILL_MARKS GetDrillMarksType() const
bool GetUseGerberX2format() const
bool GetIncludeGerberNetlistInfo() const
double GetFineScaleAdjustX() const
bool GetPlotFrameRef() const
bool GetPlotViaOnMaskLayer() const
bool GetDisableGerberMacros() const
OUTLINE_MODE GetPlotMode() const
COLOR_SETTINGS * ColorSettings() const
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
Base plotter engine class.
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
virtual void SetNegative(bool aNegative)
virtual void SetSvgCoordinatesFormat(unsigned aPrecision)
Set the number of digits for mantissa in coordinates in mm for SVG plotter.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
void SetRenderSettings(RENDER_SETTINGS *aSettings)
virtual bool StartPlot(const wxString &aPageNumber)=0
RENDER_SETTINGS * RenderSettings()
virtual void SetGerberCoordinatesFormat(int aResolution, bool aUseInches=false)
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
virtual void SetTextMode(PLOT_TEXT_MODE mode)
Change the current text mode.
virtual void SetCreator(const wxString &aCreator)
void ClearHeaderLinesList()
Remove all lines from the list of free lines to print at the beginning of the file.
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
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 HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void SetLayerPolarity(bool aPositive)
Set the current Gerber layer polarity to positive or negative by writing %LPD*% or %LPC*% to the Gerb...
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void ThickArc(const VECTOR2I &aCentre, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
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...
void SetScaleAdjust(double scaleX, double scaleY)
Set the 'fine' scaling for the postscript engine.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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 DeletePolygon(int aIdx)
Delete aIdx-th polygon and its triangulation data from the set.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=CHAMFER_ALL_CORNERS)
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
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 SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of vertices in a given outline/hole.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
void InflateWithLinkedHoles(int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode)
Perform outline inflation/deflation, using round corners.
const POLYGON & CPolygon(int aIndex) const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle a list of polygons defining a copper zone.
void SetMinThickness(int aMinThickness)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void PlotDrawingSheet(PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const std::map< wxString, wxString > *aProperties, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage)
static constexpr EDA_ANGLE & FULL_CIRCLE
static constexpr EDA_ANGLE & ANGLE_0
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
double m_SmallDrillMarkSize
The diameter of the drill marks on print and plot outputs (in mm), when the "Drill marks" option is s...
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
@ NPTH
like PAD_PTH, but not plated
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, int aLayer, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification and add them to the g...
static void FillNegativeKnockout(PLOTTER *aPlotter, const BOX2I &aBbbox)
Prefill in black an area a little bigger than the board to prepare for the negative plot.
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayers, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot a copper layer or mask.
static void PlotSolderMaskLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt, int aMinThickness)
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter)
Plot interactive items (hypertext links, properties, etc.).
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Plot one copper or technical layer.
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot outlines of copper layer.
static void ConfigureHPGLPenSizes(HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS *aPlotOpts)
Calculate the effective size of HPGL pens and set them in the plotter object.
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
static void initializePlotter(PLOTTER *aPlotter, const BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts)
Set up most plot options for plotting a board (especially the viewport) Important thing: page size is...
Plotting engines similar to ps (PostScript, Gerber, svg)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< FAB_LAYER_COLOR > dummy
constexpr int mmToIU(double mm) const
@ 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_ARC_T
class PCB_ARC, an arc track 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".