KiCad PCB EDA Suite
pcbplot.h File Reference

Board plot function definition file. More...

#include <wx/filename.h>
#include <pad_shapes.h>
#include <pcb_plot_params.h>
#include <layers_id_colors_and_visibility.h>

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 )
 
#define OPTKEY_LAYERBASE   wxT( "PlotLayer_%d" )
 
#define OPTKEY_PRINT_X_FINESCALE_ADJ   wxT( "PrintXFineScaleAdj" )
 
#define OPTKEY_PRINT_Y_FINESCALE_ADJ   wxT( "PrintYFineScaleAdj" )
 
#define OPTKEY_PRINT_SCALE   wxT( "PrintScale" )
 
#define OPTKEY_PRINT_MODULE_SCALE   wxT( "PrintModuleScale" )
 
#define OPTKEY_PRINT_PAGE_FRAME   wxT( "PrintPageFrame" )
 
#define OPTKEY_PRINT_MONOCHROME_MODE   wxT( "PrintMonochrome" )
 
#define OPTKEY_PRINT_PAGE_PER_LAYER   wxT( "PrintSinglePage" )
 
#define OPTKEY_PRINT_PADS_DRILL   wxT( "PrintPadsDrillOpt" )
 
#define OPTKEY_PLOT_X_FINESCALE_ADJ   wxT( "PlotXFineScaleAdj" )
 
#define OPTKEY_PLOT_Y_FINESCALE_ADJ   wxT( "PlotYFineScaleAdj" )
 
#define CONFIG_PS_FINEWIDTH_ADJ   wxT( "PSPlotFineWidthAdj" )
 

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 PlotSilkScreen (BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
 Function PlotSilkScreen plot silkscreen layers which have specific requirements, mainly for pads. 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)
 Function AddGerberX2Header 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)
 Function AddGerberX2Attribute 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 TF.FileFunction TF.FilePolarity. More...
 

Detailed Description

Board plot function definition file.

Definition in file pcbplot.h.

Macro Definition Documentation

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

Function Documentation

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

Function AddGerberX2Attribute 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 TF.FileFunction TF.FilePolarity.

Parameters
aPlotter,thecurrent 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 346 of file pcbplot.cpp.

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

Referenced by StartPlotBoard().

348 {
349  AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode );
350 
351  wxString text;
352 
353  // Add the TF.FileFunction
354  text = GetGerberFileFunctionAttribute( aBoard, aLayer );
355  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
356 
357  // Add the TF.FilePolarity (for layers which support that)
358  text = GetGerberFilePolarityAttribute( aLayer );
359 
360  if( !text.IsEmpty() )
361  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
362 }
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode)
Function AddGerberX2Header Calculates some X2 attributes, as defined in the Gerber file format specif...
Definition: pcbplot.cpp:273
void AddLineToHeader(const wxString &aExtraString)
Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file...
Definition: plot_common.h:166
static const wxString GetGerberFilePolarityAttribute(LAYER_NUM aLayer)
Definition: pcbplot.cpp:202
static wxString & makeStringCompatX1(wxString &aText, bool aUseX1CompatibilityMode)
Definition: pcbplot.cpp:261
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer...
Definition: pcbplot.cpp:89
void AddGerberX2Header ( PLOTTER aPlotter,
const BOARD aBoard,
bool  aUseX1CompatibilityMode = false 
)

Function AddGerberX2Header 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,thecurrent 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 273 of file pcbplot.cpp.

References PLOTTER::AddLineToHeader(), Format(), GetBuildVersion(), GetChars(), BOARD::GetFileName(), and makeStringCompatX1().

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

275 {
276  wxString text;
277 
278  // Creates the TF,.GenerationSoftware. Format is:
279  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
280  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
281  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
282 
283  // creates the TF.CreationDate ext:
284  // The attribute value must conform to the full version of the ISO 8601
285  // date and time format, including time and time zone. Note that this is
286  // the date the Gerber file was effectively created,
287  // not the time the project of PCB was started
288  wxDateTime date( wxDateTime::GetTimeNow() );
289  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
290  wxString msg = date.Format( wxT( "%z" ) ); // Extract the time zone offset
291  // The time zone offset format is + (or -) mm or hhmm (mm = number of minutes, hh = number of hours)
292  // we want +(or -) hh:mm
293  if( msg.Len() > 3 )
294  msg.insert( 3, ":", 1 ),
295  text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
296  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
297 
298  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
299  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
300  // <project id> is the name of the project, restricted to basic ASCII symbols only,
301  // and comma not accepted
302  // All illegal chars will be replaced by underscore
303  // <project GUID> is a 32 hexadecimal digits string which is an unique id of a project.
304  // This is a random 128-bit number expressed in 32 hexadecimal digits.
305  // See en.wikipedia.org/wiki/GUID for more information
306  // However Kicad does not handle such a project GUID, so it is built from the board name
307  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
308  wxFileName fn = aBoard->GetFileName();
309  msg = fn.GetFullName();
310  wxString guid;
311 
312  // Build a 32 digits GUID from the board name:
313  for( unsigned ii = 0; ii < msg.Len(); ii++ )
314  {
315  int cc1 = int( msg[ii] ) & 0x0F;
316  int cc2 = ( int( msg[ii] ) >> 4) & 0x0F;
317  guid << wxString::Format( wxT( "%X%X" ), cc2, cc1 );
318 
319  if( guid.Len() >= 32 )
320  break;
321  }
322 
323  // guid has 32 digits, so add missing digits
324  int cnt = 32 - guid.Len();
325 
326  if( cnt > 0 )
327  guid.Append( '0', cnt );
328 
329  // build the <project id> string: this is the board short filename (without ext)
330  // and all non ASCII chars and comma are replaced by '_'
331  msg = fn.GetName();
332  msg.Replace( wxT( "," ), wxT( "_" ) );
333 
334  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
335  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
336  rev.Replace( wxT( "," ), wxT( "_" ) );
337 
338  if( rev.IsEmpty() )
339  rev = wxT( "rev?" );
340 
341  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
342  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
343 }
void AddLineToHeader(const wxString &aExtraString)
Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file...
Definition: plot_common.h:166
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
const wxString & GetFileName() const
Definition: class_board.h:237
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
static wxString & makeStringCompatX1(wxString &aText, bool aUseX1CompatibilityMode)
Definition: pcbplot.cpp:261
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:205
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
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 365 of file pcbplot.cpp.

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

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

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, GetChars(), BOARD::GetCopperLayerCount(), BOARD::GetLayerType(), IsCopperLayer(), LT_MIXED, LT_POWER, LT_SIGNAL, and ToLAYER_ID().

Referenced by AddGerberX2Attribute().

90 {
91  wxString attrib;
92 
93  switch( aLayer )
94  {
95  case F_Adhes:
96  attrib = "Glue,Top";
97  break;
98 
99  case B_Adhes:
100  attrib = "Glue,Bot";
101  break;
102 
103  case F_SilkS:
104  attrib = "Legend,Top";
105  break;
106 
107  case B_SilkS:
108  attrib = "Legend,Bot";
109  break;
110 
111  case F_Mask:
112  attrib = "Soldermask,Top";
113  break;
114 
115  case B_Mask:
116  attrib = "Soldermask,Bot";
117  break;
118 
119  case F_Paste:
120  attrib = "Paste,Top";
121  break;
122 
123  case B_Paste:
124  attrib = "Paste,Bot";
125  break;
126 
127  case Edge_Cuts:
128  // Board outline.
129  // Can be "Profile,NP" (Not Plated: usual) or "Profile,P"
130  // This last is the exception (Plated)
131  attrib = "Profile,NP";
132  break;
133 
134  case Dwgs_User:
135  attrib = "Drawing";
136  break;
137 
138  case Cmts_User:
139  attrib = "Other,Comment";
140  break;
141 
142  case Eco1_User:
143  attrib = "Other,ECO1";
144  break;
145 
146  case Eco2_User:
147  attrib = "Other,ECO2";
148  break;
149 
150  case B_Fab:
151  attrib = "Other,Fab,Bot";
152  break;
153 
154  case F_Fab:
155  attrib = "Other,Fab,Top";
156  break;
157 
158  case B_Cu:
159  attrib.Printf( wxT( "Copper,L%d,Bot" ), aBoard->GetCopperLayerCount() );
160  break;
161 
162  case F_Cu:
163  attrib = "Copper,L1,Top";
164  break;
165 
166  default:
167  if( IsCopperLayer( aLayer ) )
168  attrib.Printf( wxT( "Copper,L%d,Inr" ), aLayer+1 );
169  else
170  attrib.Printf( wxT( "Other,User" ), aLayer+1 );
171  break;
172  }
173 
174  // Add the signal type of the layer, if relevant
175  if( IsCopperLayer( aLayer ) )
176  {
177  LAYER_T type = aBoard->GetLayerType( ToLAYER_ID( aLayer ) );
178 
179  switch( type )
180  {
181  case LT_SIGNAL:
182  attrib += ",Signal";
183  break;
184  case LT_POWER:
185  attrib += ",Plane";
186  break;
187  case LT_MIXED:
188  attrib += ",Mixed";
189  break;
190  default:
191  break; // do nothing (but avoid a warning for unhandled LAYER_T values from GCC)
192  }
193  }
194 
195  wxString fileFct;
196  fileFct.Printf( "%%TF.FileFunction,%s*%%", GetChars( attrib ) );
197 
198  return fileFct;
199 }
int GetCopperLayerCount() const
Function GetCopperLayerCount.
LAYER_T
Enum LAYER_T gives the allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:68
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Function GetLayerType returns the type of the copper layer given by aLayer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
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 48 of file pcbplot.cpp.

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().

49 {
50  if( IsCopperLayer( aLayer ) )
51  {
52  if( aLayer == F_Cu )
53  return wxT( "gtl" );
54  else if( aLayer == B_Cu )
55  return wxT( "gbl" );
56  else
57  {
58  return wxString::Format( wxT( "g%d" ), aLayer+1 );
59  }
60  }
61  else
62  {
63  switch( aLayer )
64  {
65  case B_Adhes: return wxT( "gba" );
66  case F_Adhes: return wxT( "gta" );
67 
68  case B_Paste: return wxT( "gbp" );
69  case F_Paste: return wxT( "gtp" );
70 
71  case B_SilkS: return wxT( "gbo" );
72  case F_SilkS: return wxT( "gto" );
73 
74  case B_Mask: return wxT( "gbs" );
75  case F_Mask: return wxT( "gts" );
76 
77  case Edge_Cuts: return wxT( "gm1" );
78 
79  case Dwgs_User:
80  case Cmts_User:
81  case Eco1_User:
82  case Eco2_User:
83  default: return wxT( "gbr" );
84  }
85  }
86 }
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:205
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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 633 of file plot_board_layers.cpp.

References SHAPE_POLY_SET::CHole(), PLOTTER::Circle(), BOARD::ConvertBrdLayerToPolygonalContours(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), DIM, dyn_cast(), PCB_PLOT_PARAMS::GetDrillMarksType(), VIA::GetDrillValue(), VIA::GetPosition(), SHAPE_POLY_SET::HoleCount(), VIA::IsOnLayer(), BOARD::m_Modules, BOARD::m_Track, TRACK::Next(), MODULE::Next(), D_PAD::Next(), PCB_PLOT_PARAMS::NO_DRILL_SHAPE, NO_FILL, 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, PLOTTER::ThickSegment(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PlotOneBoardLayer().

635 {
636 
637  BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
638  itemplotter.SetLayerSet( aLayerMask );
639 
640  SHAPE_POLY_SET outlines;
641 
642  for( LSEQ seq = aLayerMask.Seq( plot_seq, DIM( plot_seq ) ); seq; ++seq )
643  {
644  PCB_LAYER_ID layer = *seq;
645 
646  outlines.RemoveAllContours();
647  aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines );
648 
649  outlines.Simplify( SHAPE_POLY_SET::PM_FAST );
650 
651  // Plot outlines
652  std::vector< wxPoint > cornerList;
653 
654  // Now we have one or more basic polygons: plot each polygon
655  for( int ii = 0; ii < outlines.OutlineCount(); ii++ )
656  {
657  for(int kk = 0; kk <= outlines.HoleCount (ii); kk++ )
658  {
659  cornerList.clear();
660  const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 );
661 
662  for( int jj = 0; jj < path.PointCount(); jj++ )
663  cornerList.push_back( wxPoint( path.CPoint( jj ).x , path.CPoint( jj ).y ) );
664 
665 
666  // Ensure the polygon is closed
667  if( cornerList[0] != cornerList[cornerList.size() - 1] )
668  cornerList.push_back( cornerList[0] );
669 
670  aPlotter->PlotPoly( cornerList, NO_FILL );
671  }
672  }
673 
674  // Plot pad holes
676  {
677  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
678  {
679  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
680  {
681  wxSize hole = pad->GetDrillSize();
682 
683  if( hole.x == 0 || hole.y == 0 )
684  continue;
685 
686  if( hole.x == hole.y )
687  aPlotter->Circle( pad->GetPosition(), hole.x, NO_FILL );
688  else
689  {
690  wxPoint drl_start, drl_end;
691  int width;
692  pad->GetOblongDrillGeometry( drl_start, drl_end, width );
693  aPlotter->ThickSegment( pad->GetPosition() + drl_start,
694  pad->GetPosition() + drl_end, width, SKETCH, NULL );
695  }
696  }
697  }
698  }
699 
700  // Plot vias holes
701  for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
702  {
703  const VIA* via = dyn_cast<const VIA*>( track );
704 
705  if( via && via->IsOnLayer( layer ) ) // via holes can be not through holes
706  {
707  aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), NO_FILL );
708  }
709  }
710  }
711 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
int PointCount() const
Function PointCount()
static const PCB_LAYER_ID plot_seq[]
MODULE * Next() const
Definition: class_module.h:100
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Returns the number of outlines in the set
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:337
DrillMarksType GetDrillMarksType() const
PCB_LAYER_ID
A quick note on layer IDs:
Class SHAPE_POLY_SET.
D_PAD * Next() const
Definition: class_pad.h:106
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines)
Function ConvertBrdLayerToPolygonalContours Build a set of polygons which are the outlines of copper ...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
TRACK * Next() const
Definition: class_track.h:98
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
DLIST< MODULE > m_Modules
Definition: class_board.h:243
Class SHAPE_LINE_CHAIN.
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
const wxPoint & GetPosition() const override
Definition: class_track.h:416
DLIST< TRACK > m_Track
Definition: class_board.h:244
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
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 153 of file plot_board_layers.cpp.

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

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

155 {
156  PCB_PLOT_PARAMS plotOpt = aPlotOpt;
157  int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
158 
159  // Set a default color and the text mode for this layer
160  aPlotter->SetColor( aPlotOpt.GetColor() );
161  aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
162 
163  // Specify that the contents of the "Edges Pcb" layer are to be plotted
164  // in addition to the contents of the currently specified layer.
165  LSET layer_mask( aLayer );
166 
167  if( !aPlotOpt.GetExcludeEdgeLayer() )
168  layer_mask.set( Edge_Cuts );
169 
170  if( IsCopperLayer( aLayer ) )
171  {
172  // Skip NPTH pads on copper layers ( only if hole size == pad size ):
173  // Drill mark will be plotted,
174  // if drill mark is SMALL_DRILL_SHAPE or FULL_DRILL_SHAPE
175  if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
176  {
177  plotOpt.SetSkipPlotNPTH_Pads( false );
178  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
179  }
180  else
181  {
182  plotOpt.SetSkipPlotNPTH_Pads( true );
183  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
184  }
185  }
186  else
187  {
188  switch( aLayer )
189  {
190  case B_Mask:
191  case F_Mask:
192  plotOpt.SetSkipPlotNPTH_Pads( false );
193  // Disable plot pad holes
195 
196  // Plot solder mask:
197  if( soldermask_min_thickness == 0 )
198  {
199  if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
200  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
201  else
202  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
203  }
204  else
205  PlotSolderMaskLayer( aBoard, aPlotter, layer_mask, plotOpt,
206  soldermask_min_thickness );
207 
208  break;
209 
210  case B_Adhes:
211  case F_Adhes:
212  case B_Paste:
213  case F_Paste:
214  plotOpt.SetSkipPlotNPTH_Pads( false );
215  // Disable plot pad holes
217 
218  if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
219  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
220  else
221  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
222  break;
223 
224  case F_SilkS:
225  case B_SilkS:
226  if ( plotOpt.GetPlotOutlineMode() )
227  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
228  else
229  PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt );
230 
231  // Gerber: Subtract soldermask from silkscreen if enabled
232  if( aPlotter->GetPlotterType() == PLOT_FORMAT_GERBER
233  && plotOpt.GetSubtractMaskFromSilk() )
234  {
235  if( aLayer == F_SilkS )
236  layer_mask = LSET( F_Mask );
237  else
238  layer_mask = LSET( B_Mask );
239 
240  // Create the mask to subtract by creating a negative layer polarity
241  aPlotter->SetLayerPolarity( false );
242 
243  // Disable plot pad holes
245 
246  // Plot the mask
247  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
248  }
249  break;
250 
251  // These layers are plotted like silk screen layers.
252  // Mainly, pads on these layers are not filled.
253  // This is not necessary the best choice.
254  case Dwgs_User:
255  case Cmts_User:
256  case Eco1_User:
257  case Eco2_User:
258  case Edge_Cuts:
259  case Margin:
260  case F_CrtYd:
261  case B_CrtYd:
262  case F_Fab:
263  case B_Fab:
264  plotOpt.SetSkipPlotNPTH_Pads( false );
266 
267  if ( plotOpt.GetPlotOutlineMode() )
268  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
269  else
270  PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt );
271  break;
272 
273  default:
274  plotOpt.SetSkipPlotNPTH_Pads( false );
276 
277  if ( plotOpt.GetPlotOutlineMode() )
278  PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
279  else
280  PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
281  break;
282  }
283  }
284 }
bool GetSubtractMaskFromSilk() const
virtual void SetColor(COLOR4D color)=0
virtual void SetLayerPolarity(bool aPositive)
Function SetLayerPolarity sets current Gerber layer polarity to positive or negative by writing %LPD*...
Definition: plot_common.h:401
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotStandardLayer plot copper or technical layers.
void PlotSilkScreen(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotSilkScreen plot silkscreen layers which have specific requirements, mainly for pads...
void SetDrillMarksType(DrillMarksType aVal)
bool GetExcludeEdgeLayer() const
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.
Class LSET is a set of PCB_LAYER_IDs.
PlotTextMode GetTextMode() const
virtual void SetTextMode(PlotTextMode mode)
Change the current text mode.
Definition: plot_common.h:410
void SetSkipPlotNPTH_Pads(bool aSkip)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
PlotFormat GetFormat() const
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
COLOR4D GetColor() const
virtual PlotFormat GetPlotterType() const =0
Returns the effective plot engine in use.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
bool GetPlotOutlineMode() const
int m_SolderMaskMinWidth
Solder mask min width.
void PlotSilkScreen ( BOARD aBoard,
PLOTTER aPlotter,
LSET  aLayerMask,
const PCB_PLOT_PARAMS aPlotOpt 
)

Function PlotSilkScreen plot silkscreen layers which have specific requirements, mainly for pads.

Should not be used for other layers

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

Definition at line 68 of file plot_board_layers.cpp.

References B_SilkS, BLACK, color, PLOTTER::EndBlock(), F_SilkS, BOARD::GetArea(), BOARD::GetAreaCount(), GetChars(), BOARD_ITEM::GetLayer(), BOARD::GetLayerColor(), PCB_PLOT_PARAMS::GetPlotMode(), PCB_PLOT_PARAMS::GetPlotPadsOnSilkLayer(), BOARD::m_Modules, BOARD::m_Zone, MODULE::Next(), D_PAD::Next(), SEGZONE::Next(), BRDITEMS_PLOTTER::Plot_Edges_Modules(), BRDITEMS_PLOTTER::PlotAllTextsModule(), BRDITEMS_PLOTTER::PlotBoardGraphicItems(), BRDITEMS_PLOTTER::PlotFilledAreas(), BRDITEMS_PLOTTER::PlotPad(), BRDITEMS_PLOTTER::SetLayerSet(), SKETCH, PLOTTER::StartBlock(), and PLOTTER::ThickSegment().

Referenced by PlotOneBoardLayer().

70 {
71  BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
72  itemplotter.SetLayerSet( aLayerMask );
73 
74  // Plot edge layer and graphic items
75  itemplotter.PlotBoardGraphicItems();
76 
77  // Plot footprint outlines :
78  itemplotter.Plot_Edges_Modules();
79 
80  // Plot pads (creates pads outlines, for pads on silkscreen layers)
81  LSET layersmask_plotpads = aLayerMask;
82 
83  // Calculate the mask layers of allowed layers for pads
84 
85  if( !aPlotOpt.GetPlotPadsOnSilkLayer() ) // Do not plot pads on silk screen layers
86  layersmask_plotpads.set( B_SilkS, false ).set( F_SilkS, false );
87 
88  if( layersmask_plotpads.any() )
89  {
90  for( MODULE* Module = aBoard->m_Modules; Module; Module = Module->Next() )
91  {
92  aPlotter->StartBlock( NULL );
93 
94  for( D_PAD * pad = Module->Pads(); pad; pad = pad->Next() )
95  {
96  // See if the pad is on this layer
97  LSET masklayer = pad->GetLayerSet();
98  if( !( masklayer & layersmask_plotpads ).any() )
99  continue;
100 
102 
103  if( layersmask_plotpads[B_SilkS] )
104  color = aBoard->GetLayerColor( B_SilkS );
105 
106  if( layersmask_plotpads[F_SilkS] )
107  color = ( color == COLOR4D::BLACK) ? aBoard->GetLayerColor( F_SilkS ) : color;
108 
109  itemplotter.PlotPad( pad, color, SKETCH );
110  }
111 
112  aPlotter->EndBlock( NULL );
113  }
114  }
115 
116  // Plot footprints fields (ref, value ...)
117  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
118  {
119  if( ! itemplotter.PlotAllTextsModule( module ) )
120  {
121  wxLogMessage( _( "Your BOARD has a bad layer number for footprint %s" ),
122  GetChars( module->GetReference() ) );
123  }
124  }
125 
126  // Plot filled areas
127  aPlotter->StartBlock( NULL );
128 
129  for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
130  {
131  ZONE_CONTAINER* edge_zone = aBoard->GetArea( ii );
132 
133  if( !aLayerMask[ edge_zone->GetLayer() ] )
134  continue;
135 
136  itemplotter.PlotFilledAreas( edge_zone );
137  }
138 
139  aPlotter->EndBlock( NULL );
140 
141  // Plot segments used to fill zone areas (outdated, but here for old boards
142  // compatibility):
143  for( SEGZONE* seg = aBoard->m_Zone; seg; seg = seg->Next() )
144  {
145  if( !aLayerMask[ seg->GetLayer() ] )
146  continue;
147 
148  aPlotter->ThickSegment( seg->GetStart(), seg->GetEnd(), seg->GetWidth(),
149  itemplotter.GetPlotMode(), NULL );
150  }
151 }
COLOR4D GetLayerColor(PCB_LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
virtual void EndBlock(void *aData)
calling this function allows to define the end of a group of drawing items for instance in SVG or Ger...
Definition: plot_common.h:436
MODULE * Next() const
Definition: class_module.h:100
virtual void StartBlock(void *aData)
calling this function allows to define the beginning of a group of drawing items, for instance in SVG...
Definition: plot_common.h:427
DLIST< SEGZONE > m_Zone
Definition: class_board.h:245
SEGZONE * Next() const
Definition: class_track.h:363
Class LSET is a set of PCB_LAYER_IDs.
D_PAD * Next() const
Definition: class_pad.h:106
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
DLIST< MODULE > m_Modules
Definition: class_board.h:243
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
bool GetPlotPadsOnSilkLayer() const
Definition: colors.h:45
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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

Definition at line 290 of file plot_board_layers.cpp.

References LSET::AllCuMask(), B_Cu, B_Mask, B_Paste, BLACK, color, delta, dyn_cast(), PLOTTER::EndBlock(), F_Cu, F_Mask, F_Paste, PLOTTER::FlashPadCircle(), GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR, GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD, GBR_NETLIST_METADATA::GBR_NETINFO_NET, BOARD::GetArea(), BOARD::GetAreaCount(), GetChars(), BRDITEMS_PLOTTER::getColor(), BOARD::GetDesignSettings(), PCB_PLOT_PARAMS::GetDrillMarksType(), BRDITEMS_PLOTTER::getFineWidthAdj(), BOARD_ITEM::GetLayer(), VIA::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetname(), PCB_PLOT_PARAMS::GetPlotMode(), PCB_PLOT_PARAMS::GetPlotViaOnMaskLayer(), PCB_PLOT_PARAMS::GetSkipPlotNPTH_Pads(), TRACK::GetStart(), VIA::GetViaType(), BOARD::GetVisibleElementColor(), TRACK::GetWidth(), LAYER_PAD_BK, LAYER_PAD_FR, LAYER_VIAS, LIGHTGRAY, BOARD::m_Modules, GBR_METADATA::m_NetlistMetadata, GBR_NETLIST_METADATA::m_NotInNet, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, BOARD::m_Track, BOARD::m_Zone, TRACK::Next(), MODULE::Next(), D_PAD::Next(), BOARD_ITEM::Next(), SEGZONE::Next(), PCB_PLOT_PARAMS::NO_DRILL_SHAPE, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, PCB_MODULE_EDGE_T, PCB_VIA_T, BRDITEMS_PLOTTER::Plot_1_EdgeModule(), BRDITEMS_PLOTTER::PlotAllTextsModule(), BRDITEMS_PLOTTER::PlotBoardGraphicItems(), BRDITEMS_PLOTTER::PlotDrillMarks(), BRDITEMS_PLOTTER::PlotFilledAreas(), BRDITEMS_PLOTTER::PlotPad(), GBR_METADATA::SetApertureAttrib(), PLOTTER::SetColor(), BRDITEMS_PLOTTER::SetLayerSet(), GBR_METADATA::SetNetAttribType(), GBR_METADATA::SetNetName(), PLOTTER::StartBlock(), PLOTTER::ThickSegment(), WHITE, wxPoint::x, and wxPoint::y.

Referenced by DIALOG_SVG_PRINT::CreateSVGFile(), and PlotOneBoardLayer().

292 {
293  BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
294 
295  itemplotter.SetLayerSet( aLayerMask );
296 
297  EDA_DRAW_MODE_T plotMode = aPlotOpt.GetPlotMode();
298 
299  // Plot edge layer and graphic items
300  itemplotter.PlotBoardGraphicItems();
301 
302  // Draw footprint shapes without pads (pads will plotted later)
303  // We plot here module texts, but they are usually on silkscreen layer,
304  // so they are not plot here but plot by PlotSilkScreen()
305  // Plot footprints fields (ref, value ...)
306  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
307  {
308  if( ! itemplotter.PlotAllTextsModule( module ) )
309  {
310  wxLogMessage( _( "Your BOARD has a bad layer number for footprint %s" ),
311  GetChars( module->GetReference() ) );
312  }
313  }
314 
315  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
316  {
317  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
318  {
319  if( !aLayerMask[ item->GetLayer() ] )
320  continue;
321 
322  switch( item->Type() )
323  {
324  case PCB_MODULE_EDGE_T:
325  itemplotter.Plot_1_EdgeModule( (EDGE_MODULE*) item );
326  break;
327 
328  default:
329  break;
330  }
331  }
332  }
333 
334  // Plot footprint pads
335  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
336  {
337  aPlotter->StartBlock( NULL );
338 
339  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
340  {
341  if( (pad->GetLayerSet() & aLayerMask) == 0 )
342  continue;
343 
344  wxSize margin;
345  double width_adj = 0;
346 
347  if( ( aLayerMask & LSET::AllCuMask() ).any() )
348  width_adj = itemplotter.getFineWidthAdj();
349 
350  static const LSET speed( 4, B_Mask, F_Mask, B_Paste, F_Paste );
351 
352  LSET anded = ( speed & aLayerMask );
353 
354  if( anded == LSET( F_Mask ) || anded == LSET( B_Mask ) )
355  {
356  margin.x = margin.y = pad->GetSolderMaskMargin();
357  }
358  else if( anded == LSET( F_Paste ) || anded == LSET( B_Paste ) )
359  {
360  margin = pad->GetSolderPasteMargin();
361  }
362 
363  // Now offset the pad size by margin + width_adj
364  // this is easy for most shapes, but not for a trapezoid
365  wxSize padPlotsSize;
366  wxSize extraSize = margin * 2;
367  extraSize.x += width_adj;
368  extraSize.y += width_adj;
369  wxSize deltaSize = pad->GetDelta(); // has meaning only for trapezoidal pads
370 
371  if( pad->GetShape() == PAD_SHAPE_TRAPEZOID )
372  { // The easy way is to use BuildPadPolygon to calculate
373  // size and delta of the trapezoidal pad after offseting:
374  wxPoint coord[4];
375  pad->BuildPadPolygon( coord, extraSize/2, 0.0 );
376  // Calculate the size and delta from polygon corners coordinates:
377  // coord[0] is the lower left
378  // coord[1] is the upper left
379  // coord[2] is the upper right
380  // coord[3] is the lower right
381 
382  // the size is the distance between middle of segments
383  // (left/right or top/bottom)
384  // size X is the dist between left and right middle points:
385  padPlotsSize.x = ( ( -coord[0].x + coord[3].x ) // the lower segment X length
386  + ( -coord[1].x + coord[2].x ) ) // the upper segment X length
387  / 2; // the Y size is the half sum
388  // size Y is the dist between top and bottom middle points:
389  padPlotsSize.y = ( ( coord[0].y - coord[1].y ) // the left segment Y lenght
390  + ( coord[3].y - coord[2].y ) ) // the right segment Y lenght
391  / 2; // the Y size is the half sum
392 
393  // calculate the delta ( difference of lenght between 2 opposite edges )
394  // The delta.x is the delta along the X axis, therefore the delta of Y lenghts
395  wxSize delta;
396 
397  if( coord[0].y != coord[3].y )
398  delta.x = coord[0].y - coord[3].y;
399  else
400  delta.y = coord[1].x - coord[0].x;
401 
402  pad->SetDelta( delta );
403  }
404  else
405  padPlotsSize = pad->GetSize() + extraSize;
406 
407  // Don't draw a null size item :
408  if( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 )
409  continue;
410 
412 
413  if( pad->GetLayerSet()[B_Cu] )
414  color = aBoard->GetVisibleElementColor( LAYER_PAD_BK );
415 
416  if( pad->GetLayerSet()[F_Cu] )
417  color = color.LegacyMix( aBoard->GetVisibleElementColor( LAYER_PAD_FR ) );
418 
419  // Temporary set the pad size to the required plot size:
420  wxSize tmppadsize = pad->GetSize();
421  pad->SetSize( padPlotsSize );
422 
423  switch( pad->GetShape() )
424  {
425  case PAD_SHAPE_CIRCLE:
426  case PAD_SHAPE_OVAL:
427  if( aPlotOpt.GetSkipPlotNPTH_Pads() &&
428  (pad->GetSize() == pad->GetDrillSize()) &&
429  (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
430  break;
431 
432  // Fall through:
433  case PAD_SHAPE_TRAPEZOID:
434  case PAD_SHAPE_RECT:
435  case PAD_SHAPE_ROUNDRECT:
436  default:
437  itemplotter.PlotPad( pad, color, plotMode );
438  break;
439  }
440 
441  pad->SetSize( tmppadsize ); // Restore the pad size
442  pad->SetDelta( deltaSize );
443  }
444 
445  aPlotter->EndBlock( NULL );
446  }
447 
448  // Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,
449  // plot them on solder mask
450 
451  GBR_METADATA gbr_metadata;
452 
453  bool isOnCopperLayer = ( aLayerMask & LSET::AllCuMask() ).any();
454 
455  if( isOnCopperLayer )
456  {
459  }
460 
461  aPlotter->StartBlock( NULL );
462 
463  for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
464  {
465  const VIA* Via = dyn_cast<const VIA*>( track );
466 
467  if( !Via )
468  continue;
469 
470  // vias are not plotted if not on selected layer, but if layer
471  // is SOLDERMASK_LAYER_BACK or SOLDERMASK_LAYER_FRONT,vias are drawn,
472  // only if they are on the corresponding external copper layer
473  LSET via_mask_layer = Via->GetLayerSet();
474 
475  if( aPlotOpt.GetPlotViaOnMaskLayer() )
476  {
477  if( via_mask_layer[B_Cu] )
478  via_mask_layer.set( B_Mask );
479 
480  if( via_mask_layer[F_Cu] )
481  via_mask_layer.set( F_Mask );
482  }
483 
484  if( !( via_mask_layer & aLayerMask ).any() )
485  continue;
486 
487  int via_margin = 0;
488  double width_adj = 0;
489 
490  // If the current layer is a solder mask, use the global mask
491  // clearance for vias
492  if( aLayerMask[B_Mask] || aLayerMask[F_Mask] )
493  via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
494 
495  if( ( aLayerMask & LSET::AllCuMask() ).any() )
496  width_adj = itemplotter.getFineWidthAdj();
497 
498  int diameter = Via->GetWidth() + 2 * via_margin + width_adj;
499 
500  // Don't draw a null size item :
501  if( diameter <= 0 )
502  continue;
503 
504  // Some vias can be not connected (no net).
505  // Set the m_NotInNet for these vias to force a empty net name in gerber file
506  gbr_metadata.m_NetlistMetadata.m_NotInNet = Via->GetNetname().IsEmpty();
507 
508  gbr_metadata.SetNetName( Via->GetNetname() );
509 
510  COLOR4D color = aBoard->GetVisibleElementColor( LAYER_VIAS + Via->GetViaType() );
511  // Set plot color (change WHITE to LIGHTGRAY because
512  // the white items are not seen on a white paper or screen
513  aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
514  aPlotter->FlashPadCircle( Via->GetStart(), diameter, plotMode, &gbr_metadata );
515  }
516 
517  aPlotter->EndBlock( NULL );
518  aPlotter->StartBlock( NULL );
520 
521  // Plot tracks (not vias) :
522  for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
523  {
524  if( track->Type() == PCB_VIA_T )
525  continue;
526 
527  if( !aLayerMask[track->GetLayer()] )
528  continue;
529 
530  // Some track segments can be not connected (no net).
531  // Set the m_NotInNet for these segments to force a empty net name in gerber file
532  gbr_metadata.m_NetlistMetadata.m_NotInNet = track->GetNetname().IsEmpty();
533 
534  gbr_metadata.SetNetName( track->GetNetname() );
535  int width = track->GetWidth() + itemplotter.getFineWidthAdj();
536  aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
537  aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, &gbr_metadata );
538  }
539 
540  aPlotter->EndBlock( NULL );
541 
542  // Plot zones (outdated, for old boards compatibility):
543  for( TRACK* track = aBoard->m_Zone; track; track = track->Next() )
544  {
545  if( !aLayerMask[track->GetLayer()] )
546  continue;
547 
548  int width = track->GetWidth() + itemplotter.getFineWidthAdj();
549  aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
550  aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, NULL );
551  }
552 
553  // Plot filled ares
554  aPlotter->StartBlock( NULL );
555  for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
556  {
557  ZONE_CONTAINER* zone = aBoard->GetArea( ii );
558 
559  if( !aLayerMask[zone->GetLayer()] )
560  continue;
561 
562  itemplotter.PlotFilledAreas( zone );
563  }
564  aPlotter->EndBlock( NULL );
565 
566  // Adding drill marks, if required and if the plotter is able to plot them:
568  itemplotter.PlotDrillMarks();
569 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:639
int m_SolderMaskMargin
Solder mask margin.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
virtual void EndBlock(void *aData)
calling this function allows to define the end of a group of drawing items for instance in SVG or Ger...
Definition: plot_common.h:436
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual void SetColor(COLOR4D color)=0
void SetNetAttribType(int aNetAttribType)
MODULE * Next() const
Definition: class_module.h:100
virtual void StartBlock(void *aData)
calling this function allows to define the beginning of a group of drawing items, for instance in SVG...
Definition: plot_common.h:427
DLIST< SEGZONE > m_Zone
Definition: class_board.h:245
COLOR4D GetVisibleElementColor(GAL_LAYER_ID LAYER_aPCB)
Function GetVisibleElementColor returns the color of a pcb visible element.
smd pads, back layer
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
static const int delta[8][2]
Definition: solve.cpp:112
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
SEGZONE * Next() const
Definition: class_track.h:363
BOARD_ITEM * Next() const
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadCircle
DrillMarksType GetDrillMarksType() const
Class LSET is a set of PCB_LAYER_IDs.
VIATYPE_T GetViaType() const
Definition: class_track.h:446
EDA_DRAW_MODE_T
Definition: eda_text.h:62
const wxPoint & GetStart() const
Definition: class_track.h:121
D_PAD * Next() const
Definition: class_pad.h:106
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
bool GetPlotViaOnMaskLayer() const
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
aperture used for connected items like tracks (not vias)
void SetNetName(const wxString &aNetname)
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool GetSkipPlotNPTH_Pads() const
TRACK * Next() const
Definition: class_track.h:98
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
smd pads, front layer
const wxString & GetNetname() const
Function GetNetname.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
DLIST< MODULE > m_Modules
Definition: class_board.h:243
int GetWidth() const
Definition: class_track.h:115
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
EDA_DRAW_MODE_T GetPlotMode() const
Definition: colors.h:49
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
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:108
DLIST< TRACK > m_Track
Definition: class_board.h:244
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: colors.h:45
print info associated to a net (TO.N attribute)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 1004 of file plot_board_layers.cpp.

References AddGerberX2Attribute(), PLOTTER::ClearHeaderLinesList(), BOARD::ComputeBoundingBox(), ConfigureHPGLPenSizes(), FillNegativeKnockout(), 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::GetTitleBlock(), PCB_PLOT_PARAMS::GetUseGerberAttributes(), initializePlotter(), PLOTTER::OpenFile(), PLOT_FORMAT_DXF, PLOT_FORMAT_GERBER, PLOT_FORMAT_HPGL, PLOT_FORMAT_PDF, PLOT_FORMAT_POST, PLOT_FORMAT_SVG, PlotWorkSheet(), PCB_PLOT_PARAMS::SetMirror(), PSLIKE_PLOTTER::SetScaleAdjust(), PLOTTER::StartPlot(), GERBER_PLOTTER::UseX2Attributes(), and GERBER_PLOTTER::UseX2NetAttributes().

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

1008 {
1009  // Create the plotter driver and set the few plotter specific
1010  // options
1011  PLOTTER* plotter = NULL;
1012 
1013  switch( aPlotOpts->GetFormat() )
1014  {
1015  case PLOT_FORMAT_DXF:
1016  plotter = new DXF_PLOTTER();
1017  break;
1018 
1019  case PLOT_FORMAT_POST:
1020  PS_PLOTTER* PS_plotter;
1021  PS_plotter = new PS_PLOTTER();
1022  PS_plotter->SetScaleAdjust( aPlotOpts->GetFineScaleAdjustX(),
1023  aPlotOpts->GetFineScaleAdjustY() );
1024  plotter = PS_plotter;
1025  break;
1026 
1027  case PLOT_FORMAT_PDF:
1028  plotter = new PDF_PLOTTER();
1029  break;
1030 
1031  case PLOT_FORMAT_HPGL:
1032  HPGL_PLOTTER* HPGL_plotter;
1033  HPGL_plotter = new HPGL_PLOTTER();
1034 
1035  /* HPGL options are a little more convoluted to compute, so
1036  they're split in an other function */
1037  ConfigureHPGLPenSizes( HPGL_plotter, aPlotOpts );
1038  plotter = HPGL_plotter;
1039  break;
1040 
1041  case PLOT_FORMAT_GERBER:
1042  plotter = new GERBER_PLOTTER();
1043  break;
1044 
1045  case PLOT_FORMAT_SVG:
1046  plotter = new SVG_PLOTTER();
1047  break;
1048 
1049  default:
1050  wxASSERT( false );
1051  return NULL;
1052  }
1053 
1054  // Compute the viewport and set the other options
1055 
1056  // page layout is not mirrored, so temporary change mirror option
1057  // just to plot the page layout
1058  PCB_PLOT_PARAMS plotOpts = *aPlotOpts;
1059 
1060  if( plotOpts.GetPlotFrameRef() && plotOpts.GetMirror() )
1061  plotOpts.SetMirror( false );
1062 
1063  initializePlotter( plotter, aBoard, &plotOpts );
1064 
1065  if( plotter->OpenFile( aFullFileName ) )
1066  {
1067  plotter->ClearHeaderLinesList();
1068 
1069  // For the Gerber "file function" attribute, set the layer number
1070  if( plotter->GetPlotterType() == PLOT_FORMAT_GERBER )
1071  {
1072  bool useX2mode = plotOpts.GetUseGerberAttributes();
1073 
1074  if( useX2mode )
1075  {
1076  AddGerberX2Attribute( plotter, aBoard, aLayer, false );
1077  GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
1078  gbrplotter->UseX2Attributes( true );
1079  gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
1080  }
1081  else
1082  {
1083  AddGerberX2Attribute( plotter, aBoard, aLayer, true );
1084  }
1085  }
1086 
1087  plotter->StartPlot();
1088 
1089  // Plot the frame reference if requested
1090  if( aPlotOpts->GetPlotFrameRef() )
1091  {
1092  PlotWorkSheet( plotter, aBoard->GetTitleBlock(),
1093  aBoard->GetPageSettings(),
1094  1, 1, // Only one page
1095  aSheetDesc, aBoard->GetFileName() );
1096 
1097  if( aPlotOpts->GetMirror() )
1098  initializePlotter( plotter, aBoard, aPlotOpts );
1099  }
1100 
1101  /* When plotting a negative board: draw a black rectangle
1102  * (background for plot board in white) and switch the current
1103  * color to WHITE; note the color inversion is actually done
1104  * in the driver (if supported) */
1105  if( aPlotOpts->GetNegative() )
1106  {
1107  EDA_RECT bbox = aBoard->ComputeBoundingBox();
1108  FillNegativeKnockout( plotter, bbox );
1109  }
1110 
1111  return plotter;
1112  }
1113 
1114  delete plotter;
1115  return NULL;
1116 }
bool GetMirror() const
void UseX2NetAttributes(bool aEnable)
Definition: plot_common.h:1112
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...
bool GetUseGerberAttributes() const
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
void SetScaleAdjust(double scaleX, double scaleY)
Set the 'fine' scaling for the postscript engine.
Definition: plot_common.h:663
void SetMirror(bool aFlag)
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode)
Function AddGerberX2Attribute Calculates some X2 attributes, as defined in the Gerber file format spe...
Definition: pcbplot.cpp:346
double GetFineScaleAdjustX() const
void PlotWorkSheet(PLOTTER *plotter, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, int aSheetNumber, int aNumberOfSheets, const wxString &aSheetDesc, const wxString &aFilename)
bool GetIncludeGerberNetlistInfo() const
const wxString & GetFileName() const
Definition: class_board.h:237
static void ConfigureHPGLPenSizes(HPGL_PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts)
Calculate the effective size of HPGL pens and set them in the plotter object.
PlotFormat GetFormat() const
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:545
Base plotter engine class.
Definition: plot_common.h:86
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:551
bool GetNegative() const
virtual PlotFormat GetPlotterType() const =0
Returns the effective plot engine in use.
bool GetPlotFrameRef() const
Class EDA_RECT handles the component boundary box.
void ClearHeaderLinesList()
Function ClearHeaderLinesList remove all lines from the list of free lines to print at the beginning ...
Definition: plot_common.h:175
void UseX2Attributes(bool aEnable)
Definition: plot_common.h:1111
double GetFineScaleAdjustY() const