KiCad PCB EDA Suite
pcbplot.h File Reference

Board plot function definition file. More...

Go to the source code of this file.

Classes

class  BRDITEMS_PLOTTER
 

Macros

#define PLOT_MIN_SCALE   0.01
 
#define PLOT_MAX_SCALE   100.0
 
#define SMALL_DRILL   KiROUND( 0.35 * IU_PER_MM )
 

Functions

PLOTTERStartPlotBoard (BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetDesc)
 Open a new plotfile using the options (and especially the format) specified in the options and prepare the page for plotting. More...
 
void PlotOneBoardLayer (BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
 Function PlotOneBoardLayer main function to plot one copper or technical layer. More...
 
void PlotStandardLayer (BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
 Function PlotStandardLayer plot copper or technical layers. More...
 
void PlotLayerOutlines (BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
 Function PlotLayerOutlines plot copper outline of a copper layer. More...
 
void BuildPlotFileName (wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
 Function BuildPlotFileName (helper function) Complete a plot filename: forces the output directory, add a suffix to the name and sets the specified extension the suffix is usually the layer name replaces not allowed chars in suffix by '_'. More...
 
const wxString GetGerberProtelExtension (LAYER_NUM aLayer)
 Function GetGerberProtelExtension. More...
 
const wxString GetGerberFileFunctionAttribute (const BOARD *aBoard, LAYER_NUM aLayer)
 Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer, as defined in the Gerber file format specification J1 (chapter 5). More...
 
void AddGerberX2Header (PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode=false)
 Calculates some X2 attributes, as defined in the Gerber file format specification J4 (chapter 5) and add them the to the gerber file header: TF.GenerationSoftware TF.CreationDate TF.ProjectId file format attribute is not added. More...
 
void AddGerberX2Attribute (PLOTTER *aPlotter, const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode)
 Calculates some X2 attributes, as defined in the Gerber file format specification and add them to the gerber file header: TF.GenerationSoftware TF.CreationDate TF.ProjectId TF.FileFunction TF.FilePolarity. More...
 

Detailed Description

Board plot function definition file.

Definition in file pcbplot.h.

Macro Definition Documentation

◆ PLOT_MAX_SCALE

#define PLOT_MAX_SCALE   100.0

Definition at line 57 of file pcbplot.h.

◆ PLOT_MIN_SCALE

#define PLOT_MIN_SCALE   0.01

Definition at line 56 of file pcbplot.h.

◆ SMALL_DRILL

#define SMALL_DRILL   KiROUND( 0.35 * IU_PER_MM )

Definition at line 60 of file pcbplot.h.

Function Documentation

◆ AddGerberX2Attribute()

void AddGerberX2Attribute ( PLOTTER aPlotter,
const BOARD aBoard,
LAYER_NUM  aLayer,
bool  aUseX1CompatibilityMode 
)

Calculates some X2 attributes, as defined in the Gerber file format specification and add them to the gerber file header: TF.GenerationSoftware TF.CreationDate TF.ProjectId TF.FileFunction TF.FilePolarity.

Parameters
aPlotter= the current plotter.
aBoard= the board, needed to extract some info
aLayer= the layer number to create the attribute for
aUseX1CompatibilityMode= false to generate X2 attributes, true to use X1 compatibility (X2 attributes added as structured comments, starting by "G04 #@! " followed by the X2 attribute

Definition at line 350 of file pcbplot.cpp.

352 {
353  AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode );
354 
355  wxString text;
356 
357  // Add the TF.FileFunction
358  text = GetGerberFileFunctionAttribute( aBoard, aLayer );
359  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
360 
361  // Add the TF.FilePolarity (for layers which support that)
362  text = GetGerberFilePolarityAttribute( aLayer );
363 
364  if( !text.IsEmpty() )
365  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
366 }
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode)
Calculates some X2 attributes, as defined in the Gerber file format specification J4 (chapter 5) and ...
Definition: pcbplot.cpp:278
void AddLineToHeader(const wxString &aExtraString)
Add a line to the list of free lines to print at the beginning of the file.
Definition: plotter.h:195
static const wxString GetGerberFilePolarityAttribute(LAYER_NUM aLayer)
Definition: pcbplot.cpp:207
static wxString & makeStringCompatX1(wxString &aText, bool aUseX1CompatibilityMode)
Definition: pcbplot.cpp:266
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer,...
Definition: pcbplot.cpp:85

References AddGerberX2Header(), PLOTTER::AddLineToHeader(), GetGerberFileFunctionAttribute(), GetGerberFilePolarityAttribute(), and makeStringCompatX1().

Referenced by StartPlotBoard().

◆ AddGerberX2Header()

void AddGerberX2Header ( PLOTTER aPlotter,
const BOARD aBoard,
bool  aUseX1CompatibilityMode = false 
)

Calculates some X2 attributes, as defined in the Gerber file format specification J4 (chapter 5) and add them the to the gerber file header: TF.GenerationSoftware TF.CreationDate TF.ProjectId file format attribute is not added.

Parameters
aPlotter= the current plotter.
aBoard= the board, needed to extract some info
aUseX1CompatibilityMode= false to generate X2 attributes, true to use X1 compatibility (X2 attributes added as structured comments, starting by "G04 #@! " followed by the X2 attribute

Definition at line 278 of file pcbplot.cpp.

280 {
281  wxString text;
282 
283  // Creates the TF,.GenerationSoftware. Format is:
284  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
285  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
286  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
287 
288  // creates the TF.CreationDate attribute:
289  text = GbrMakeCreationDateAttributeString( aUseX1CompatibilityMode ?
292  aPlotter->AddLineToHeader( text );
293 
294  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
295  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
296  // <project id> is the name of the project, restricted to basic ASCII symbols only,
297  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
298  // and comma not accepted
299  // All illegal chars will be replaced by underscore
300  //
301  // <project GUID> is a string which is an unique id of a project.
302  // However Kicad does not handle such a project GUID, so it is built from the board name
303  wxFileName fn = aBoard->GetFileName();
304  wxString msg = fn.GetFullName();
305 
306  // Build a <project GUID>, from the board name
307  wxString guid = GbrMakeProjectGUIDfromString( msg );
308 
309  // build the <project id> string: this is the board short filename (without ext)
310  // and all non ASCII chars and comma are replaced by '_'
311  msg = fn.GetName();
312  msg.Replace( wxT( "," ), wxT( "_" ) );
313 
314  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
315  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
316  rev.Replace( wxT( "," ), wxT( "_" ) );
317 
318  if( rev.IsEmpty() )
319  rev = wxT( "rev?" );
320 
321  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), guid, rev.ToAscii() );
322  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
323 
324  // Add the TF.SameCoordinates, that specify all gerber files uses the same
325  // origin and orientation, and the registration between files is OK.
326  // The parameter of TF.SameCoordinates is a string that is common
327  // to all files using the same registration and has no special meaning:
328  // this is just a key
329  // Because there is no mirroring/rotation in Kicad, only the plot offset origin
330  // can create incorrect registration.
331  // So we create a key from plot offset options.
332  // and therefore for a given board, all Gerber files having the same key have the same
333  // plot origin and use the same registration
334  //
335  // Currently the key is "Original" when using absolute Pcbnew coordinates,
336  // and te PY ans PY position od auxiliary axis, when using it.
337  // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
338  // the key is built to ensure file only using the *same* axis have the same key.
339  wxString registration_id = "Original";
340  wxPoint auxOrigin = aBoard->GetDesignSettings().m_AuxOrigin;
341 
342  if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
343  registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );
344 
345  text.Printf( "%%TF.SameCoordinates,%s*%%", registration_id.GetData() );
346  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
347 }
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:575
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:557
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
void AddLineToHeader(const wxString &aExtraString)
Add a line to the list of free lines to print at the beginning of the file.
Definition: plotter.h:195
const wxString & GetFileName() const
Definition: class_board.h:279
wxString GetBuildVersion()
Get the full KiCad version string.
wxString GbrMakeProjectGUIDfromString(wxString &aText)
A helper function to build a project GUID using format RFC4122 Version 1 or 4 from the project name,...
static wxString & makeStringCompatX1(wxString &aText, bool aUseX1CompatibilityMode)
Definition: pcbplot.cpp:266
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:186
bool GetUseAuxOrigin() const
wxPoint m_AuxOrigin
origin for plot exports

References PLOTTER::AddLineToHeader(), GBR_NC_STRING_FORMAT_X1, GBR_NC_STRING_FORMAT_X2, GbrMakeCreationDateAttributeString(), GbrMakeProjectGUIDfromString(), GetBuildVersion(), BOARD::GetDesignSettings(), BOARD::GetFileName(), BOARD::GetPlotOptions(), PCB_PLOT_PARAMS::GetUseAuxOrigin(), BOARD_DESIGN_SETTINGS::m_AuxOrigin, makeStringCompatX1(), wxPoint::x, and wxPoint::y.

Referenced by AddGerberX2Attribute(), GERBER_WRITER::createDrillFile(), and PLACEFILE_GERBER_WRITER::CreatePlaceFile().

◆ BuildPlotFileName()

void BuildPlotFileName ( wxFileName *  aFilename,
const wxString &  aOutputDir,
const wxString &  aSuffix,
const wxString &  aExtension 
)

Function BuildPlotFileName (helper function) Complete a plot filename: forces the output directory, add a suffix to the name and sets the specified extension the suffix is usually the layer name replaces not allowed chars in suffix by '_'.

Parameters
aFilename= the wxFileName to initialize Contains the base filename
aOutputDir= the path
aSuffix= the suffix to add to the base filename
aExtension= the file extension

Definition at line 369 of file pcbplot.cpp.

371 {
372  // aFilename contains the base filename only (without path and extension)
373  // when calling this function.
374  // It is expected to be a valid filename (this is usually the board filename)
375  aFilename->SetPath( aOutputDir );
376 
377  // Set the file extension
378  aFilename->SetExt( aExtension );
379 
380  // remove leading and trailing spaces if any from the suffix, if
381  // something survives add it to the name;
382  // also the suffix can contain some not allowed chars in filename (/ \ . : and some others),
383  // so change them to underscore
384  // Remember it can be called from a python script, so the illegal chars
385  // have to be filtered here.
386  wxString suffix = aSuffix;
387  suffix.Trim( true );
388  suffix.Trim( false );
389 
390  wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
391  badchars.Append( "%." );
392 
393  for( unsigned ii = 0; ii < badchars.Len(); ii++ )
394  suffix.Replace( badchars[ii], wxT("_") );
395 
396  if( !suffix.IsEmpty() )
397  aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
398 }

Referenced by DIALOG_EXPORT_SVG::ExportSVGFile(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

◆ GetGerberFileFunctionAttribute()

const wxString GetGerberFileFunctionAttribute ( const BOARD aBoard,
LAYER_NUM  aLayer 
)

Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer, as defined in the Gerber file format specification J1 (chapter 5).

The returned string includes the "%TF.FileFunction" attribute prefix and the "*%" suffix.

Parameters
aBoard= the board, needed to get the total count of copper layers
aLayer= the layer number to create the attribute for
Returns
The attribute, as a text string

Definition at line 85 of file pcbplot.cpp.

86 {
87  wxString attrib;
88 
89  switch( aLayer )
90  {
91  case F_Adhes:
92  attrib = "Glue,Top";
93  break;
94 
95  case B_Adhes:
96  attrib = "Glue,Bot";
97  break;
98 
99  case F_SilkS:
100  attrib = "Legend,Top";
101  break;
102 
103  case B_SilkS:
104  attrib = "Legend,Bot";
105  break;
106 
107  case F_Mask:
108  attrib = "Soldermask,Top";
109  break;
110 
111  case B_Mask:
112  attrib = "Soldermask,Bot";
113  break;
114 
115  case F_Paste:
116  attrib = "Paste,Top";
117  break;
118 
119  case B_Paste:
120  attrib = "Paste,Bot";
121  break;
122 
123  case Edge_Cuts:
124  // Board outline.
125  // Can be "Profile,NP" (Not Plated: usual) or "Profile,P"
126  // This last is the exception (Plated)
127  attrib = "Profile,NP";
128  break;
129 
130  case Dwgs_User:
131  attrib = "OtherDrawing,Comment";
132  break;
133 
134  case Cmts_User:
135  attrib = "Other,Comment";
136  break;
137 
138  case Eco1_User:
139  attrib = "Other,ECO1";
140  break;
141 
142  case Eco2_User:
143  attrib = "Other,ECO2";
144  break;
145 
146  case B_Fab:
147  // This is actually a assembly layer
148  attrib = "AssemblyDrawing,Bot";
149  break;
150 
151  case F_Fab:
152  // This is actually a assembly layer
153  attrib = "AssemblyDrawing,Top";
154  break;
155 
156  case B_Cu:
157  attrib.Printf( wxT( "Copper,L%d,Bot" ), aBoard->GetCopperLayerCount() );
158  break;
159 
160  case F_Cu:
161  attrib = "Copper,L1,Top";
162  break;
163 
164  default:
165  if( IsCopperLayer( aLayer ) )
166  attrib.Printf( wxT( "Copper,L%d,Inr" ), aLayer+1 );
167  else
168  attrib.Printf( wxT( "Other,User" ), aLayer+1 );
169  break;
170  }
171 
172  // This code adds a optional parameter: the type of copper layers.
173  // Because it is not used by Pcbnew (it can be used only by external autorouters)
174  // user do not really set this parameter.
175  // Therefore do not add it.
176  // However, this code is left here, for perhaps a future usage.
177 #if 0
178  // Add the signal type of the layer, if relevant
179  if( IsCopperLayer( aLayer ) )
180  {
181  LAYER_T type = aBoard->GetLayerType( ToLAYER_ID( aLayer ) );
182 
183  switch( type )
184  {
185  case LT_SIGNAL:
186  attrib += ",Signal";
187  break;
188  case LT_POWER:
189  attrib += ",Plane";
190  break;
191  case LT_MIXED:
192  attrib += ",Mixed";
193  break;
194  default:
195  break; // do nothing (but avoid a warning for unhandled LAYER_T values from GCC)
196  }
197  }
198 #endif
199 
200  wxString fileFct;
201  fileFct.Printf( "%%TF.FileFunction,%s*%%", attrib );
202 
203  return fileFct;
204 }
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:62
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
int GetCopperLayerCount() const
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:897

References B_Adhes, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, BOARD::GetCopperLayerCount(), BOARD::GetLayerType(), IsCopperLayer(), LT_MIXED, LT_POWER, LT_SIGNAL, and ToLAYER_ID().

Referenced by AddGerberX2Attribute().

◆ GetGerberProtelExtension()

const wxString GetGerberProtelExtension ( LAYER_NUM  aLayer)

Function GetGerberProtelExtension.

Returns
the appropriate Gerber file extension for aLayer used by Protel, and still sometimes in use (although the official Gerber Ext is now .gbr)

Definition at line 44 of file pcbplot.cpp.

45 {
46  if( IsCopperLayer( aLayer ) )
47  {
48  if( aLayer == F_Cu )
49  return wxT( "gtl" );
50  else if( aLayer == B_Cu )
51  return wxT( "gbl" );
52  else
53  {
54  return wxString::Format( wxT( "g%d" ), aLayer+1 );
55  }
56  }
57  else
58  {
59  switch( aLayer )
60  {
61  case B_Adhes: return wxT( "gba" );
62  case F_Adhes: return wxT( "gta" );
63 
64  case B_Paste: return wxT( "gbp" );
65  case F_Paste: return wxT( "gtp" );
66 
67  case B_SilkS: return wxT( "gbo" );
68  case F_SilkS: return wxT( "gto" );
69 
70  case B_Mask: return wxT( "gbs" );
71  case F_Mask: return wxT( "gts" );
72 
73  case Edge_Cuts: return wxT( "gm1" );
74 
75  case Dwgs_User:
76  case Cmts_User:
77  case Eco1_User:
78  case Eco2_User:
79  default: return wxT( "gbr" );
80  }
81  }
82 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.

References B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, Format(), and IsCopperLayer().

Referenced by PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

◆ PlotLayerOutlines()

void PlotLayerOutlines ( BOARD aBoard,
PLOTTER aPlotter,
LSET  aLayerMask,
const PCB_PLOT_PARAMS aPlotOpt 
)

Function PlotLayerOutlines plot copper outline of a copper layer.

Parameters
aBoard= the board to plot
aPlotter= the plotter to use
aLayerMask= the mask to define the layers to plot
aPlotOpt= the plot options. Has meaning for some formats only

Definition at line 590 of file plot_board_layers.cpp.

592 {
593  BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
594  itemplotter.SetLayerSet( aLayerMask );
595 
596  SHAPE_POLY_SET outlines;
597 
598  for( LSEQ seq = aLayerMask.Seq( plot_seq, arrayDim( plot_seq ) ); seq; ++seq )
599  {
600  PCB_LAYER_ID layer = *seq;
601 
602  outlines.RemoveAllContours();
603  aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines );
604 
605  outlines.Simplify( SHAPE_POLY_SET::PM_FAST );
606 
607  // Plot outlines
608  std::vector<wxPoint> cornerList;
609 
610  // Now we have one or more basic polygons: plot each polygon
611  for( int ii = 0; ii < outlines.OutlineCount(); ii++ )
612  {
613  for(int kk = 0; kk <= outlines.HoleCount (ii); kk++ )
614  {
615  cornerList.clear();
616  const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 );
617 
618  for( int jj = 0; jj < path.PointCount(); jj++ )
619  cornerList.emplace_back( (wxPoint) path.CPoint( jj ) );
620 
621  // Ensure the polygon is closed
622  if( cornerList[0] != cornerList[cornerList.size() - 1] )
623  cornerList.push_back( cornerList[0] );
624 
625  aPlotter->PlotPoly( cornerList, FILL_TYPE::NO_FILL );
626  }
627  }
628 
629  // Plot pad holes
631  {
632  int smallDrill = (aPlotOpt.GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE)
633  ? SMALL_DRILL : INT_MAX;
634 
635  for( MODULE* module : aBoard->Modules() )
636  {
637  for( D_PAD* pad : module->Pads() )
638  {
639  wxSize hole = pad->GetDrillSize();
640 
641  if( hole.x == 0 || hole.y == 0 )
642  continue;
643 
644  if( hole.x == hole.y )
645  {
646  hole.x = std::min( smallDrill, hole.x );
647  aPlotter->Circle( pad->GetPosition(), hole.x, FILL_TYPE::NO_FILL );
648  }
649  else
650  {
651  // Note: small drill marks have no significance when applied to slots
652  const SHAPE_SEGMENT* seg = pad->GetEffectiveHoleShape();
653  aPlotter->ThickSegment( (wxPoint) seg->GetSeg().A,
654  (wxPoint) seg->GetSeg().B,
655  seg->GetWidth(), SKETCH, NULL );
656  }
657  }
658  }
659  }
660 
661  // Plot vias holes
662  for( TRACK* track : aBoard->Tracks() )
663  {
664  const VIA* via = dyn_cast<const VIA*>( track );
665 
666  if( via && via->IsOnLayer( layer ) ) // via holes can be not through holes
667  {
668  aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), FILL_TYPE::NO_FILL );
669  }
670  }
671  }
672 }
#define SMALL_DRILL
Definition: pcbplot.h:60
int OutlineCount() const
Returns the number of outlines in the set
static const PCB_LAYER_ID plot_seq[]
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Draw a polygon ( filled or not )
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int PointCount() const
Function PointCount()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:410
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:506
const SEG & GetSeg() const
const VECTOR2I & CPoint(int aIndex) const
Function Point()
PCB_LAYER_ID
A quick note on layer IDs:
#define NULL
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
MODULES & Modules()
Definition: class_board.h:284
SHAPE_POLY_SET.
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines)
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:127
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
VECTOR2I A
Definition: seg.h:47
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
wxPoint GetPosition() const override
Definition: class_track.h:423
DrillMarksType GetDrillMarksType() const
int GetWidth() const
TRACKS & Tracks()
Definition: class_board.h:281
VECTOR2I B
Definition: seg.h:48

References SEG::A, arrayDim(), SEG::B, SHAPE_POLY_SET::CHole(), PLOTTER::Circle(), BOARD::ConvertBrdLayerToPolygonalContours(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), PCB_PLOT_PARAMS::GetDrillMarksType(), VIA::GetDrillValue(), VIA::GetPosition(), SHAPE_SEGMENT::GetSeg(), SHAPE_SEGMENT::GetWidth(), SHAPE_POLY_SET::HoleCount(), VIA::IsOnLayer(), BOARD::Modules(), PCB_PLOT_PARAMS::NO_DRILL_SHAPE, NO_FILL, NULL, SHAPE_POLY_SET::OutlineCount(), plot_seq, PLOTTER::PlotPoly(), SHAPE_POLY_SET::PM_FAST, SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::RemoveAllContours(), LSET::Seq(), BRDITEMS_PLOTTER::SetLayerSet(), SHAPE_POLY_SET::Simplify(), SKETCH, SMALL_DRILL, PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE, PLOTTER::ThickSegment(), and BOARD::Tracks().

Referenced by PlotOneBoardLayer().

◆ PlotOneBoardLayer()

void PlotOneBoardLayer ( BOARD aBoard,
PLOTTER aPlotter,
PCB_LAYER_ID  aLayer,
const PCB_PLOT_PARAMS aPlotOpt 
)

Function PlotOneBoardLayer main function to plot one copper or technical layer.

It prepare options and calls the specialized plot function, according to the layer type

Parameters
aBoard= the board to plot
aPlotter= the plotter to use
aLayer= the layer id to plot
aPlotOpt= the plot options (files, sketch). Has meaning for some formats only

Definition at line 60 of file plot_board_layers.cpp.

62 {
63  PCB_PLOT_PARAMS plotOpt = aPlotOpt;
64  int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
65 
66  // Set a default color and the text mode for this layer
67  aPlotter->SetColor( aPlotOpt.GetColor() );
68  aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
69 
70  // Specify that the contents of the "Edges Pcb" layer are to be plotted in addition to the
71  // contents of the currently specified layer.
72  LSET layer_mask( aLayer );
73 
74  if( !aPlotOpt.GetExcludeEdgeLayer() )
75  layer_mask.set( Edge_Cuts );
76 
77  if( IsCopperLayer( aLayer ) )
78  {
79  // Skip NPTH pads on copper layers ( only if hole size == pad size ):
80  // Drill mark will be plotted if drill mark is SMALL_DRILL_SHAPE or FULL_DRILL_SHAPE
81  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF )
82  {
83  plotOpt.SetSkipPlotNPTH_Pads( false );
84  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
85  }
86  else
87  {
88  plotOpt.SetSkipPlotNPTH_Pads( true );
89  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
90  }
91  }
92  else
93  {
94  switch( aLayer )
95  {
96  case B_Mask:
97  case F_Mask:
98  plotOpt.SetSkipPlotNPTH_Pads( false );
99  // Disable plot pad holes
101 
102  // Plot solder mask:
103  if( soldermask_min_thickness == 0 )
104  {
105  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF )
106  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
107  else
108  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
109  }
110  else
111  PlotSolderMaskLayer( aBoard, aPlotter, layer_mask, plotOpt,
112  soldermask_min_thickness );
113 
114  break;
115 
116  case B_Adhes:
117  case F_Adhes:
118  case B_Paste:
119  case F_Paste:
120  plotOpt.SetSkipPlotNPTH_Pads( false );
121  // Disable plot pad holes
123 
124  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF )
125  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
126  else
127  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
128  break;
129 
130  case F_SilkS:
131  case B_SilkS:
132  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF && plotOpt.GetDXFPlotPolygonMode() )
133  // PlotLayerOutlines() is designed only for DXF plotters.
134  // and must not be used for other plot formats
135  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
136  else
137  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
138 
139  // Gerber: Subtract soldermask from silkscreen if enabled
140  if( aPlotter->GetPlotterType() == PLOT_FORMAT::GERBER
141  && plotOpt.GetSubtractMaskFromSilk() )
142  {
143  if( aLayer == F_SilkS )
144  layer_mask = LSET( F_Mask );
145  else
146  layer_mask = LSET( B_Mask );
147 
148  // Create the mask to subtract by creating a negative layer polarity
149  aPlotter->SetLayerPolarity( false );
150 
151  // Disable plot pad holes
153 
154  // Plot the mask
155  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
156  }
157  break;
158 
159  // These layers are plotted like silk screen layers.
160  // Mainly, pads on these layers are not filled.
161  // This is not necessary the best choice.
162  case Dwgs_User:
163  case Cmts_User:
164  case Eco1_User:
165  case Eco2_User:
166  case Edge_Cuts:
167  case Margin:
168  case F_CrtYd:
169  case B_CrtYd:
170  case F_Fab:
171  case B_Fab:
172  plotOpt.SetSkipPlotNPTH_Pads( false );
174 
175  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF && plotOpt.GetDXFPlotPolygonMode() )
176  // PlotLayerOutlines() is designed only for DXF plotters.
177  // and must not be used for other plot formats
178  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
179  else
180  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
181  break;
182 
183  default:
184  plotOpt.SetSkipPlotNPTH_Pads( false );
186 
187  if( plotOpt.GetFormat() == PLOT_FORMAT::DXF && plotOpt.GetDXFPlotPolygonMode() )
188  // PlotLayerOutlines() is designed only for DXF plotters.
189  // and must not be used for other plot formats
190  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
191  else
192  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
193  break;
194  }
195  }
196 }
bool GetDXFPlotPolygonMode() const
virtual void SetColor(COLOR4D color)=0
virtual void SetLayerPolarity(bool aPositive)
Set the current Gerber layer polarity to positive or negative by writing %LPD*% or %LPC*% to the Gerb...
Definition: plotter.h:458
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotStandardLayer plot copper or technical layers.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:557
void SetDrillMarksType(DrillMarksType aVal)
static void PlotSolderMaskLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt, int aMinThickness)
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotLayerOutlines plot copper outline of a copper layer.
LSET is a set of PCB_LAYER_IDs.
PLOT_FORMAT GetFormat() const
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
COLOR4D GetColor() const
virtual void SetTextMode(PLOT_TEXT_MODE mode)
Change the current text mode.
Definition: plotter.h:467
void SetSkipPlotNPTH_Pads(bool aSkip)
PLOT_TEXT_MODE GetTextMode() const
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
bool GetSubtractMaskFromSilk() const
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
bool GetExcludeEdgeLayer() const

References B_Adhes, B_CrtYd, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, DXF, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, GERBER, PCB_PLOT_PARAMS::GetColor(), BOARD::GetDesignSettings(), PCB_PLOT_PARAMS::GetDXFPlotPolygonMode(), PCB_PLOT_PARAMS::GetExcludeEdgeLayer(), PCB_PLOT_PARAMS::GetFormat(), PLOTTER::GetPlotterType(), PCB_PLOT_PARAMS::GetSubtractMaskFromSilk(), PCB_PLOT_PARAMS::GetTextMode(), IsCopperLayer(), BOARD_DESIGN_SETTINGS::m_SolderMaskMinWidth, Margin, PCB_PLOT_PARAMS::NO_DRILL_SHAPE, PlotLayerOutlines(), PlotSolderMaskLayer(), PlotStandardLayer(), PLOTTER::SetColor(), PCB_PLOT_PARAMS::SetDrillMarksType(), PLOTTER::SetLayerPolarity(), PCB_PLOT_PARAMS::SetSkipPlotNPTH_Pads(), and PLOTTER::SetTextMode().

Referenced by DIALOG_EXPORT_SVG::CreateSVGFile(), DIALOG_PLOT::Plot(), and PLOT_CONTROLLER::PlotLayer().

◆ PlotStandardLayer()

void PlotStandardLayer ( BOARD aBoard,
PLOTTER aPlotter,
LSET  aLayerMask,
const PCB_PLOT_PARAMS aPlotOpt 
)

Function PlotStandardLayer plot copper or technical layers.

not used for silk screen layers, because these layers have specific requirements, mainly for pads

Parameters
aBoard= the board to plot
aPlotter= the plotter to use
aLayerMask= the mask to define the layers to plot
aPlotOpt= the plot options (files, sketch). Has meaning for some formats only

aPlotOpt has 3 important options to control this plot, which are set, depending on the layer type to plot SetEnablePlotVia( bool aEnable ) aEnable = true to plot vias, false to skip vias (has meaning only for solder mask layers). SetSkipPlotNPTH_Pads( bool aSkip ) aSkip = true to skip NPTH Pads, when the pad size and the pad hole have the same size. Used in GERBER format only. SetDrillMarksType( DrillMarksType aVal ) controle the actual hole: no hole, small hole, actual hole

pads not connected to copper are optionally not drawn

Vias not connected to copper are optionally not drawn

Definition at line 203 of file plot_board_layers.cpp.

205 {
206  BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
207 
208  itemplotter.SetLayerSet( aLayerMask );
209 
210  OUTLINE_MODE plotMode = aPlotOpt.GetPlotMode();
211  bool onCopperLayer = ( LSET::AllCuMask() & aLayerMask ).any();
212  bool onSolderMaskLayer = ( LSET( 2, F_Mask, B_Mask ) & aLayerMask ).any();
213  bool onSolderPasteLayer = ( LSET( 2, F_Paste, B_Paste ) & aLayerMask ).any();
214  bool onFrontFab = ( LSET( F_Fab ) & aLayerMask ).any();
215  bool onBackFab = ( LSET( B_Fab ) & aLayerMask ).any();
216  bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers();
217 
218  // Plot edge layer and graphic items
219  itemplotter.PlotBoardGraphicItems();
220 
221  // Draw footprint texts:
222  for( MODULE* module : aBoard->Modules() )
223  itemplotter.PlotFootprintTextItems( module );
224 
225  // Draw footprint other graphic items:
226  for( MODULE* module : aBoard->Modules() )
227  itemplotter.PlotFootprintGraphicItems( module );
228 
229  // Plot footprint pads
230  for( MODULE* module : aBoard->Modules() )
231  {
232  aPlotter->StartBlock( NULL );
233 
234  for( D_PAD* pad : module->Pads() )
235  {
236  OUTLINE_MODE padPlotMode = plotMode;
237 
238  if( !( pad->GetLayerSet() & aLayerMask ).any() )
239  {
240  if( sketchPads &&
241  ( ( onFrontFab && pad->GetLayerSet().Contains( F_Cu ) ) ||
242  ( onBackFab && pad->GetLayerSet().Contains( B_Cu ) ) ) )
243  padPlotMode = SKETCH;
244  else
245  continue;
246  }
247 
249  if( onCopperLayer && !pad->FlashLayer( aLayerMask ) )
250  continue;
251 
253 
254  if( pad->GetLayerSet()[B_Cu] )
255  color = aPlotOpt.ColorSettings()->GetColor( LAYER_PAD_BK );
256 
257  if( pad->GetLayerSet()[F_Cu] )
258  color = color.LegacyMix( aPlotOpt.ColorSettings()->GetColor( LAYER_PAD_FR ) );
259 
260  if( sketchPads && aLayerMask[F_Fab] )
261  color = aPlotOpt.ColorSettings()->GetColor( F_Fab );
262  else if( sketchPads && aLayerMask[B_Fab] )
263  color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
264 
265  wxSize margin;
266  int width_adj = 0;
267 
268  if( onCopperLayer )
269  width_adj = itemplotter.getFineWidthAdj();
270 
271  if( onSolderMaskLayer )
272  margin.x = margin.y = pad->GetSolderMaskMargin();
273 
274  if( onSolderPasteLayer )
275  margin = pad->GetSolderPasteMargin();
276 
277  // Now offset the pad size by margin + width_adj
278  wxSize padPlotsSize = pad->GetSize() + margin * 2 + wxSize( width_adj, width_adj );
279 
280  // Store these parameters that can be modified to plot inflated/deflated pads shape
281  PAD_SHAPE_T padShape = pad->GetShape();
282  wxSize padSize = pad->GetSize();
283  wxSize padDelta = pad->GetDelta(); // has meaning only for trapezoidal pads
284  double padCornerRadius = pad->GetRoundRectCornerRadius();
285 
286  // Don't draw a null size item :
287  if( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 )
288  continue;
289 
290  switch( pad->GetShape() )
291  {
292  case PAD_SHAPE_CIRCLE:
293  case PAD_SHAPE_OVAL:
294  pad->SetSize( padPlotsSize );
295 
296  if( aPlotOpt.GetSkipPlotNPTH_Pads() &&
298  ( pad->GetSize() == pad->GetDrillSize() ) &&
299  ( pad->GetAttribute() == PAD_ATTRIB_NPTH ) )
300  break;
301 
302  itemplotter.PlotPad( pad, color, padPlotMode );
303  break;
304 
305  case PAD_SHAPE_RECT:
306  pad->SetSize( padPlotsSize );
307 
308  if( margin.x > 0 )
309  {
310  pad->SetShape( PAD_SHAPE_ROUNDRECT );
311  pad->SetRoundRectCornerRadius( margin.x );
312  }
313 
314  itemplotter.PlotPad( pad, color, padPlotMode );
315  break;
316 
317  case PAD_SHAPE_TRAPEZOID:
318  {
319  wxSize scale( padPlotsSize.x / padSize.x, padPlotsSize.y / padSize.y );
320  pad->SetDelta( wxSize( padDelta.x * scale.x, padDelta.y * scale.y ) );
321  pad->SetSize( padPlotsSize );
322 
323  itemplotter.PlotPad( pad, color, padPlotMode );
324  }
325  break;
326 
327  case PAD_SHAPE_ROUNDRECT:
329  // Chamfer and rounding are stored as a percent and so don't need scaling
330  pad->SetSize( padPlotsSize );
331  itemplotter.PlotPad( pad, color, padPlotMode );
332  break;
333 
334  case PAD_SHAPE_CUSTOM:
335  {
336  // inflate/deflate a custom shape is a bit complex.
337  // so build a similar pad shape, and inflate/deflate the polygonal shape
338  D_PAD dummy( *pad );
339  SHAPE_POLY_SET shape;
340  pad->MergePrimitivesAsPolygon( &shape, UNDEFINED_LAYER );
341  // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
342  // which can create bad shapes if margin.x is < 0
343  int maxError = aBoard->GetDesignSettings().m_MaxError;
344  int numSegs = GetArcToSegmentCount( margin.x, maxError, 360.0 );
345  shape.InflateWithLinkedHoles( margin.x, numSegs, SHAPE_POLY_SET::PM_FAST );
346  dummy.DeletePrimitivesList();
347  dummy.AddPrimitivePoly( shape, 0 );
348 
349  // Be sure the anchor pad is not bigger than the deflated shape because this
350  // anchor will be added to the pad shape when plotting the pad. So now the
351  // polygonal shape is built, we can clamp the anchor size
352  if( margin.x < 0 ) // we expect margin.x = margin.y for custom pads
353  dummy.SetSize( padPlotsSize );
354 
355  itemplotter.PlotPad( &dummy, color, padPlotMode );
356  }
357  break;
358  }
359 
360  // Restore the pad parameters modified by the plot code
361  pad->SetSize( padSize );
362  pad->SetDelta( padDelta );
363  pad->SetShape( padShape );
364  pad->SetRoundRectCornerRadius( padCornerRadius );
365  }
366 
367  aPlotter->EndBlock( NULL );
368  }
369 
370  // Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,
371  // plot them on solder mask
372 
373  GBR_METADATA gbr_metadata;
374 
375  bool isOnCopperLayer = ( aLayerMask & LSET::AllCuMask() ).any();
376 
377  if( isOnCopperLayer )
378  {
381  }
382 
383  aPlotter->StartBlock( NULL );
384 
385  for( TRACK* track : aBoard->Tracks() )
386  {
387  const VIA* via = dyn_cast<const VIA*>( track );
388 
389  if( !via )
390  continue;
391 
392  // vias are not plotted if not on selected layer, but if layer is SOLDERMASK_LAYER_BACK
393  // or SOLDERMASK_LAYER_FRONT, vias are drawn only if they are on the corresponding
394  // external copper layer
395  LSET via_mask_layer = via->GetLayerSet();
396 
397  if( aPlotOpt.GetPlotViaOnMaskLayer() )
398  {
399  if( via_mask_layer[B_Cu] )
400  via_mask_layer.set( B_Mask );
401 
402  if( via_mask_layer[F_Cu] )
403  via_mask_layer.set( F_Mask );
404  }
405 
406  if( !( via_mask_layer & aLayerMask ).any() )
407  continue;
408 
409  int via_margin = 0;
410  double width_adj = 0;
411 
412  // If the current layer is a solder mask, use the global mask clearance for vias
413  if( aLayerMask[B_Mask] || aLayerMask[F_Mask] )
414  via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
415 
416  if( ( aLayerMask & LSET::AllCuMask() ).any() )
417  width_adj = itemplotter.getFineWidthAdj();
418 
419  int diameter = via->GetWidth() + 2 * via_margin + width_adj;
420 
422  if( onCopperLayer && !via->FlashLayer( aLayerMask ) )
423  continue;
424 
425  // Don't draw a null size item :
426  if( diameter <= 0 )
427  continue;
428 
429  // Some vias can be not connected (no net).
430  // Set the m_NotInNet for these vias to force a empty net name in gerber file
431  gbr_metadata.m_NetlistMetadata.m_NotInNet = via->GetNetname().IsEmpty();
432 
433  gbr_metadata.SetNetName( via->GetNetname() );
434 
435  COLOR4D color = aPlotOpt.ColorSettings()->GetColor(
436  LAYER_VIAS + static_cast<int>( via->GetViaType() ) );
437  // Set plot color (change WHITE to LIGHTGRAY because the white items are not seen on a
438  // white paper or screen
439  aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY );
440  aPlotter->FlashPadCircle( via->GetStart(), diameter, plotMode, &gbr_metadata );
441  }
442 
443  aPlotter->EndBlock( NULL );
444  aPlotter->StartBlock( NULL );
446 
447  // Plot tracks (not vias) :
448  for( TRACK* track : aBoard->Tracks() )
449  {
450  if( track->Type() == PCB_VIA_T )
451  continue;
452 
453  if( !aLayerMask[track->GetLayer()] )
454  continue;
455 
456  // Some track segments can be not connected (no net).
457  // Set the m_NotInNet for these segments to force a empty net name in gerber file
458  gbr_metadata.m_NetlistMetadata.m_NotInNet = track->GetNetname().IsEmpty();
459 
460  gbr_metadata.SetNetName( track->GetNetname() );
461  int width = track->GetWidth() + itemplotter.getFineWidthAdj();
462  aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
463 
464  if( track->Type() == PCB_ARC_T )
465  {
466  ARC* arc = static_cast<ARC*>( track );
467  VECTOR2D center( arc->GetCenter() );
468  int radius = arc->GetRadius();
469  double start_angle = arc->GetArcAngleStart();
470  double end_angle = start_angle + arc->GetAngle();
471 
472  aPlotter->ThickArc( wxPoint( center.x, center.y ), -end_angle, -start_angle,
473  radius, width, plotMode, &gbr_metadata );
474  }
475  else
476  {
477  aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
478  &gbr_metadata );
479  }
480 
481  }
482 
483  aPlotter->EndBlock( NULL );
484 
485  // Plot filled ares
486  aPlotter->StartBlock( NULL );
487 
488  NETINFO_ITEM nonet( aBoard );
489 
490  for( ZONE_CONTAINER* zone : aBoard->Zones() )
491  {
492  for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
493  {
494  if( !aLayerMask[layer] )
495  continue;
496 
497  SHAPE_POLY_SET mainArea = zone->GetFilledPolysList( layer );
498  SHAPE_POLY_SET islands;
499 
500  for( int i = mainArea.OutlineCount() - 1; i >= 0; i-- )
501  {
502  if( zone->IsIsland( layer, i ) )
503  {
504  islands.AddOutline( mainArea.CPolygon( i )[0] );
505  mainArea.DeletePolygon( i );
506  }
507  }
508 
509  itemplotter.PlotFilledAreas( zone, mainArea );
510 
511  if( !islands.IsEmpty() )
512  {
513  ZONE_CONTAINER dummy( *zone );
514  dummy.SetNet( &nonet );
515  itemplotter.PlotFilledAreas( &dummy, islands );
516  }
517  }
518  }
519 
520  aPlotter->EndBlock( NULL );
521 
522  // Adding drill marks, if required and if the plotter is able to plot them:
524  itemplotter.PlotDrillMarks();
525 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:749
OUTLINE_MODE GetPlotMode() const
OUTLINE_MODE
Definition: outline_mode.h:24
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
virtual wxPoint GetCenter() const override
Function GetCenter()
Definition: class_track.h:312
const POLYGON & CPolygon(int aIndex) const
int OutlineCount() const
Returns the number of outlines in the set
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...
Definition: plotter.h:498
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
virtual void SetColor(COLOR4D color)=0
const wxPoint & GetStart() const
Definition: class_track.h:116
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:170
int color
Definition: DXF_plotter.cpp:60
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:489
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
wxString GetNetname() const
Function GetNetname.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:557
Definition: color4d.h:45
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:506
PAD_SHAPE_T
Enum PAD_SHAPE_T is the set of pad shapes, used with D_PAD::{Set,Get}Shape()
Definition: pad_shapes.h:33
void DeletePolygon(int aIdx)
Deletes aIdx-th polygon from the set
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
#define NULL
MODULES & Modules()
Definition: class_board.h:284
SHAPE_POLY_SET.
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
bool GetSkipPlotNPTH_Pads() const
double GetRadius() const
aperture used for connected items like tracks (not vias)
Definition: gbr_metadata.h:84
Definition: color4d.h:49
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
double GetAngle() const
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:180
COLOR4D GetColor(int aLayer) const
bool GetSketchPadsOnFabLayers() const
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
ZONE_CONTAINERS & Zones()
Definition: class_board.h:290
bool GetPlotViaOnMaskLayer() const
const int scale
smd pads, front layer
int GetWidth() const
Definition: class_track.h:110
Meta control for all vias opacity/visibility.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
VIATYPE GetViaType() const
Definition: class_track.h:384
void InflateWithLinkedHoles(int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode)
Performs outline inflation/deflation, using round corners.
virtual void ThickArc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:530
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:160
COLOR_SETTINGS * ColorSettings() const
double GetArcAngleStart() const
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:212
DrillMarksType GetDrillMarksType() const
print info associated to a net (TO.N attribute)
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
TRACKS & Tracks()
Definition: class_board.h:281
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References SHAPE_POLY_SET::AddOutline(), LSET::AllCuMask(), B_Cu, B_Fab, B_Mask, B_Paste, BLACK, color, PCB_PLOT_PARAMS::ColorSettings(), SHAPE_POLY_SET::CPolygon(), SHAPE_POLY_SET::DeletePolygon(), dummy(), PLOTTER::EndBlock(), F_Cu, F_Fab, F_Mask, F_Paste, VIA::FlashLayer(), PLOTTER::FlashPadCircle(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD, GBR_NETLIST_METADATA::GBR_NETINFO_NET, ARC::GetAngle(), ARC::GetArcAngleStart(), GetArcToSegmentCount(), ARC::GetCenter(), COLOR_SETTINGS::GetColor(), BRDITEMS_PLOTTER::getColor(), BOARD::GetDesignSettings(), PCB_PLOT_PARAMS::GetDrillMarksType(), BRDITEMS_PLOTTER::getFineWidthAdj(), VIA::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetname(), PCB_PLOT_PARAMS::GetPlotMode(), PCB_PLOT_PARAMS::GetPlotViaOnMaskLayer(), ARC::GetRadius(), PCB_PLOT_PARAMS::GetSketchPadsOnFabLayers(), PCB_PLOT_PARAMS::GetSkipPlotNPTH_Pads(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), SHAPE_POLY_SET::InflateWithLinkedHoles(), SHAPE_POLY_SET::IsEmpty(), LAYER_PAD_BK, LAYER_PAD_FR, LAYER_VIAS, LIGHTGRAY, BOARD_DESIGN_SETTINGS::m_MaxError, GBR_METADATA::m_NetlistMetadata, GBR_NETLIST_METADATA::m_NotInNet, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, BOARD::Modules(), PCB_PLOT_PARAMS::NO_DRILL_SHAPE, NULL, SHAPE_POLY_SET::OutlineCount(), PAD_ATTRIB_NPTH, PAD_SHAPE_CHAMFERED_RECT, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, PCB_ARC_T, PCB_VIA_T, BRDITEMS_PLOTTER::PlotBoardGraphicItems(), BRDITEMS_PLOTTER::PlotDrillMarks(), BRDITEMS_PLOTTER::PlotFilledAreas(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPad(), SHAPE_POLY_SET::PM_FAST, scale, GBR_METADATA::SetApertureAttrib(), PLOTTER::SetColor(), BRDITEMS_PLOTTER::SetLayerSet(), GBR_METADATA::SetNetAttribType(), GBR_METADATA::SetNetName(), SKETCH, PLOTTER::StartBlock(), PLOTTER::ThickArc(), PLOTTER::ThickSegment(), BOARD::Tracks(), UNDEFINED_LAYER, WHITE, and BOARD::Zones().

Referenced by PlotOneBoardLayer(), and PlotSolderMaskLayer().

◆ StartPlotBoard()

PLOTTER* StartPlotBoard ( BOARD aBoard,
PCB_PLOT_PARAMS aPlotOpts,
int  aLayer,
const wxString &  aFullFileName,
const wxString &  aSheetDesc 
)

Open a new plotfile using the options (and especially the format) specified in the options and prepare the page for plotting.

Return the plotter object if OK, NULL if the file is not created (or has a problem)

Definition at line 1021 of file plot_board_layers.cpp.

1023 {
1024  // Create the plotter driver and set the few plotter specific options
1025  PLOTTER* plotter = NULL;
1026 
1027  switch( aPlotOpts->GetFormat() )
1028  {
1029  case PLOT_FORMAT::DXF:
1030  DXF_PLOTTER* DXF_plotter;
1031  DXF_plotter = new DXF_PLOTTER();
1032  DXF_plotter->SetUnits( aPlotOpts->GetDXFPlotUnits() );
1033 
1034  plotter = DXF_plotter;
1035  break;
1036 
1037  case PLOT_FORMAT::POST:
1038  PS_PLOTTER* PS_plotter;
1039  PS_plotter = new PS_PLOTTER();
1040  PS_plotter->SetScaleAdjust( aPlotOpts->GetFineScaleAdjustX(),
1041  aPlotOpts->GetFineScaleAdjustY() );
1042  plotter = PS_plotter;
1043  break;
1044 
1045  case PLOT_FORMAT::PDF:
1046  plotter = new PDF_PLOTTER();
1047  break;
1048 
1049  case PLOT_FORMAT::HPGL:
1050  HPGL_PLOTTER* HPGL_plotter;
1051  HPGL_plotter = new HPGL_PLOTTER();
1052 
1053  // HPGL options are a little more convoluted to compute, so they get their own function
1054  ConfigureHPGLPenSizes( HPGL_plotter, aPlotOpts );
1055  plotter = HPGL_plotter;
1056  break;
1057 
1058  case PLOT_FORMAT::GERBER:
1059  plotter = new GERBER_PLOTTER();
1060  break;
1061 
1062  case PLOT_FORMAT::SVG:
1063  plotter = new SVG_PLOTTER();
1064  break;
1065 
1066  default:
1067  wxASSERT( false );
1068  return NULL;
1069  }
1070 
1072  renderSettings->LoadColors( aPlotOpts->ColorSettings() );
1073  renderSettings->SetDefaultPenWidth( Millimeter2iu( 0.0212 ) ); // Hairline at 1200dpi
1074  plotter->SetRenderSettings( renderSettings );
1075 
1076  // Compute the viewport and set the other options
1077 
1078  // page layout is not mirrored, so temporarily change mirror option for the page layout
1079  PCB_PLOT_PARAMS plotOpts = *aPlotOpts;
1080 
1081  if( plotOpts.GetPlotFrameRef() && plotOpts.GetMirror() )
1082  plotOpts.SetMirror( false );
1083 
1084  initializePlotter( plotter, aBoard, &plotOpts );
1085 
1086  if( plotter->OpenFile( aFullFileName ) )
1087  {
1088  plotter->ClearHeaderLinesList();
1089 
1090  // For the Gerber "file function" attribute, set the layer number
1091  if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1092  {
1093  bool useX2mode = plotOpts.GetUseGerberX2format();
1094 
1095  GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
1096  gbrplotter->DisableApertMacros( plotOpts.GetDisableGerberMacros() );
1097  gbrplotter->UseX2format( useX2mode );
1098  gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
1099 
1100  // Attributes can be added using X2 format or as comment (X1 format)
1101  AddGerberX2Attribute( plotter, aBoard, aLayer, not useX2mode );
1102  }
1103 
1104  plotter->StartPlot();
1105 
1106  // Plot the frame reference if requested
1107  if( aPlotOpts->GetPlotFrameRef() )
1108  {
1109  PlotWorkSheet( plotter, aBoard->GetProject(), aBoard->GetTitleBlock(),
1110  aBoard->GetPageSettings(), "1", 1, aSheetDesc, aBoard->GetFileName() );
1111 
1112  if( aPlotOpts->GetMirror() )
1113  initializePlotter( plotter, aBoard, aPlotOpts );
1114  }
1115 
1116  // When plotting a negative board: draw a black rectangle (background for plot board
1117  // in white) and switch the current color to WHITE; note the color inversion is actually
1118  // done in the driver (if supported)
1119  if( aPlotOpts->GetNegative() )
1120  {
1121  EDA_RECT bbox = aBoard->ComputeBoundingBox();
1122  FillNegativeKnockout( plotter, bbox );
1123  }
1124 
1125  return plotter;
1126  }
1127 
1128  delete plotter->RenderSettings();
1129  delete plotter;
1130  return NULL;
1131 }
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:572
virtual void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: pcb_painter.cpp:87
void UseX2NetAttributes(bool aEnable)
bool GetPlotFrameRef() const
static void initializePlotter(PLOTTER *aPlotter, BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts)
Set up most plot options for plotting a board (especially the viewport) Important thing: page size is...
virtual bool StartPlot()=0
static void FillNegativeKnockout(PLOTTER *aPlotter, const EDA_RECT &aBbbox)
Prefill in black an area a little bigger than the board to prepare for the negative plot.
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition: plotter.cpp:76
bool GetDisableGerberMacros() const
void SetScaleAdjust(double scaleX, double scaleY)
Set the 'fine' scaling for the postscript engine.
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition: plotter.h:163
PROJECT * GetProject() const
Definition: class_board.h:396
void SetMirror(bool aFlag)
void UseX2format(bool aEnable)
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode)
Calculates some X2 attributes, as defined in the Gerber file format specification and add them to the...
Definition: pcbplot.cpp:350
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
const wxString & GetFileName() const
Definition: class_board.h:279
bool GetUseGerberX2format() const
bool GetMirror() const
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:64
PLOT_FORMAT GetFormat() const
#define NULL
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
bool GetIncludeGerberNetlistInfo() const
static void ConfigureHPGLPenSizes(HPGL_PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts)
Calculate the effective size of HPGL pens and set them in the plotter object.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
double GetFineScaleAdjustX() const
void DisableApertMacros(bool aDisable)
Disable Aperture Macro (AM) command, only for broken Gerber Readers Regions will be used instead of A...
Base plotter engine class.
Definition: plotter.h:130
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:164
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:578
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void ClearHeaderLinesList()
Remove all lines from the list of free lines to print at the beginning of the file.
Definition: plotter.h:203
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
double GetFineScaleAdjustY() const
COLOR_SETTINGS * ColorSettings() const
DXF_UNITS GetDXFPlotUnits() const
void PlotWorkSheet(PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const wxString &aSheetNumber, int aNumberOfSheets, const wxString &aSheetDesc, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage)
bool GetNegative() const
void SetDefaultPenWidth(int aWidth)
static constexpr int Millimeter2iu(double mm)

References AddGerberX2Attribute(), PLOTTER::ClearHeaderLinesList(), PCB_PLOT_PARAMS::ColorSettings(), BOARD::ComputeBoundingBox(), ConfigureHPGLPenSizes(), GERBER_PLOTTER::DisableApertMacros(), DXF, FillNegativeKnockout(), GERBER, PCB_PLOT_PARAMS::GetDisableGerberMacros(), PCB_PLOT_PARAMS::GetDXFPlotUnits(), BOARD::GetFileName(), PCB_PLOT_PARAMS::GetFineScaleAdjustX(), PCB_PLOT_PARAMS::GetFineScaleAdjustY(), PCB_PLOT_PARAMS::GetFormat(), PCB_PLOT_PARAMS::GetIncludeGerberNetlistInfo(), PCB_PLOT_PARAMS::GetMirror(), PCB_PLOT_PARAMS::GetNegative(), BOARD::GetPageSettings(), PCB_PLOT_PARAMS::GetPlotFrameRef(), PLOTTER::GetPlotterType(), BOARD::GetProject(), BOARD::GetTitleBlock(), PCB_PLOT_PARAMS::GetUseGerberX2format(), HPGL, initializePlotter(), KIGFX::PCB_RENDER_SETTINGS::LoadColors(), Millimeter2iu(), NULL, PLOTTER::OpenFile(), PDF, PlotWorkSheet(), POST, PLOTTER::RenderSettings(), KIGFX::RENDER_SETTINGS::SetDefaultPenWidth(), PCB_PLOT_PARAMS::SetMirror(), PLOTTER::SetRenderSettings(), PSLIKE_PLOTTER::SetScaleAdjust(), DXF_PLOTTER::SetUnits(), PLOTTER::StartPlot(), SVG, GERBER_PLOTTER::UseX2format(), and GERBER_PLOTTER::UseX2NetAttributes().

Referenced by DIALOG_EXPORT_SVG::CreateSVGFile(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().