KiCad PCB EDA Suite
pcbplot.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <fctsys.h>
31 #include <class_plotter.h>
32 #include <confirm.h>
33 #include <wxPcbStruct.h>
34 #include <pcbplot.h>
35 #include <base_units.h>
36 #include <reporter.h>
37 #include <class_board.h>
38 #include <pcbnew.h>
39 #include <plotcontroller.h>
40 #include <pcb_plot_params.h>
41 #include <wx/ffile.h>
42 #include <dialog_plot.h>
43 #include <macros.h>
44 #include <build_version.h>
45 
46 
47 const wxString GetGerberProtelExtension( LAYER_NUM aLayer )
48 {
49  if( IsCopperLayer( aLayer ) )
50  {
51  if( aLayer == F_Cu )
52  return wxT( "gtl" );
53  else if( aLayer == B_Cu )
54  return wxT( "gbl" );
55  else
56  {
57  return wxString::Format( wxT( "g%d" ), aLayer+1 );
58  }
59  }
60  else
61  {
62  switch( aLayer )
63  {
64  case B_Adhes: return wxT( "gba" );
65  case F_Adhes: return wxT( "gta" );
66 
67  case B_Paste: return wxT( "gbp" );
68  case F_Paste: return wxT( "gtp" );
69 
70  case B_SilkS: return wxT( "gbo" );
71  case F_SilkS: return wxT( "gto" );
72 
73  case B_Mask: return wxT( "gbs" );
74  case F_Mask: return wxT( "gts" );
75 
76  case Edge_Cuts: return wxT( "gm1" );
77 
78  case Dwgs_User:
79  case Cmts_User:
80  case Eco1_User:
81  case Eco2_User:
82  default: return wxT( "gbr" );
83  }
84  }
85 }
86 
87 
88 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer )
89 {
90  wxString attrib;
91 
92  switch( aLayer )
93  {
94  case F_Adhes:
95  attrib = "Glue,Top";
96  break;
97 
98  case B_Adhes:
99  attrib = "Glue,Bot";
100  break;
101 
102  case F_SilkS:
103  attrib = "Legend,Top";
104  break;
105 
106  case B_SilkS:
107  attrib = "Legend,Bot";
108  break;
109 
110  case F_Mask:
111  attrib = "Soldermask,Top";
112  break;
113 
114  case B_Mask:
115  attrib = "Soldermask,Bot";
116  break;
117 
118  case F_Paste:
119  attrib = "Paste,Top";
120  break;
121 
122  case B_Paste:
123  attrib = "Paste,Bot";
124  break;
125 
126  case Edge_Cuts:
127  // Board outline.
128  // Can be "Profile,NP" (Not Plated: usual) or "Profile,P"
129  // This last is the exception (Plated)
130  attrib = "Profile,NP";
131  break;
132 
133  case Dwgs_User:
134  attrib = "Drawing";
135  break;
136 
137  case Cmts_User:
138  attrib = "Other,Comment";
139  break;
140 
141  case Eco1_User:
142  attrib = "Other,ECO1";
143  break;
144 
145  case Eco2_User:
146  attrib = "Other,ECO2";
147  break;
148 
149  case B_Fab:
150  attrib = "Other,Fab,Bot";
151  break;
152 
153  case F_Fab:
154  attrib = "Other,Fab,Top";
155  break;
156 
157  case B_Cu:
158  attrib.Printf( wxT( "Copper,L%d,Bot" ), aBoard->GetCopperLayerCount() );
159  break;
160 
161  case F_Cu:
162  attrib = "Copper,L1,Top";
163  break;
164 
165  default:
166  if( IsCopperLayer( aLayer ) )
167  attrib.Printf( wxT( "Copper,L%d,Inr" ), aLayer+1 );
168  else
169  attrib.Printf( wxT( "Other,User" ), aLayer+1 );
170  break;
171  }
172 
173  // Add the signal type of the layer, if relevant
174  if( IsCopperLayer( aLayer ) )
175  {
176  LAYER_T type = aBoard->GetLayerType( ToLAYER_ID( aLayer ) );
177 
178  switch( type )
179  {
180  case LT_SIGNAL:
181  attrib += ",Signal";
182  break;
183  case LT_POWER:
184  attrib += ",Plane";
185  break;
186  case LT_MIXED:
187  attrib += ",Mixed";
188  break;
189  default:
190  break; // do nothing (but avoid a warning for unhandled LAYER_T values from GCC)
191  }
192  }
193 
194  wxString fileFct;
195  fileFct.Printf( "%%TF.FileFunction,%s*%%", GetChars( attrib ) );
196 
197  return fileFct;
198 }
199 
200 
201 static const wxString GetGerberFilePolarityAttribute( LAYER_NUM aLayer )
202 {
203  /* build the string %TF.FilePolarity,Positive*%
204  * or %TF.FilePolarity,Negative*%
205  * an emply string for layers which do not use a polarity
206  *
207  * The value of the .FilePolarity specifies whether the image represents the
208  * presence or absence of material.
209  * This attribute can only be used when the file represents a pattern in a material layer,
210  * e.g. copper, solder mask, legend.
211  * Together with.FileFunction it defines the role of that image in
212  * the layer structure of the PCB.
213  * Note that the .FilePolarity attribute does not change the image -
214  * no attribute does.
215  * It changes the interpretation of the image.
216  * For example, in a copper layer in positive polarity a round flash generates a copper pad.
217  * In a copper layer in negative polarity it generates a clearance.
218  * Solder mask images usually represent solder mask openings and are then negative.
219  * This may be counter-intuitive.
220  */
221  int polarity = 0;
222 
223  switch( aLayer )
224  {
225  case F_Adhes:
226  case B_Adhes:
227  case F_SilkS:
228  case B_SilkS:
229  case F_Paste:
230  case B_Paste:
231  polarity = 1;
232  break;
233 
234  case F_Mask:
235  case B_Mask:
236  polarity = -1;
237  break;
238 
239  default:
240  if( IsCopperLayer( aLayer ) )
241  polarity = 1;
242  break;
243  }
244 
245  wxString filePolarity;
246 
247  if( polarity == 1 )
248  filePolarity = "%TF.FilePolarity,Positive*%";
249  if( polarity == -1 )
250  filePolarity = "%TF.FilePolarity,Negative*%";
251 
252  return filePolarity;
253 }
254 
255 /* Add some X2 attributes to the file header, as defined in the
256  * Gerber file format specification J4 and "Revision 2015.06"
257  */
258 
259 // A helper function to convert a X2 attribute string to a X1 structured comment:
260 static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMode )
261 {
262  if( aUseX1CompatibilityMode )
263  {
264  aText.Replace( "%", "" );
265  aText.Prepend( "G04 #@! " );
266  }
267 
268  return aText;
269 }
270 
271 
272 void BuildGerberX2Header( const BOARD *aBoard, wxArrayString& aHeader )
273 {
274  wxString text;
275 
276  // Creates the TF,.GenerationSoftware. Format is:
277  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
278  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
279  aHeader.Add( text );
280 
281  // creates the TF.CreationDate ext:
282  // The attribute value must conform to the full version of the ISO 8601
283  // date and time format, including time and time zone. Note that this is
284  // the date the Gerber file was effectively created,
285  // not the time the project of PCB was started
286  wxDateTime date( wxDateTime::GetTimeNow() );
287  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
288  wxString msg = date.Format( wxT( "%z" ) ); // Extract the time zone offset
289  // The time zone offset format is + (or -) mm or hhmm (mm = number of minutes, hh = number of hours)
290  // we want +(or -) hh:mm
291  if( msg.Len() > 3 )
292  msg.insert( 3, ":", 1 ),
293  text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
294  aHeader.Add( text );
295 
296  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
297  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
298  // <project id> is the name of the project, restricted to basic ASCII symbols only,
299  // and comma not accepted
300  // All illegal chars will be replaced by underscore
301  // <project GUID> is a 32 hexadecimal digits string which is an unique id of a project.
302  // This is a random 128-bit number expressed in 32 hexadecimal digits.
303  // See en.wikipedia.org/wiki/GUID for more information
304  // However Kicad does not handle such a project GUID, so it is built from the board name
305  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
306  wxFileName fn = aBoard->GetFileName();
307  msg = fn.GetFullName();
308  wxString guid;
309 
310  // Build a 32 digits GUID from the board name:
311  for( unsigned ii = 0; ii < msg.Len(); ii++ )
312  {
313  int cc1 = int( msg[ii] ) & 0x0F;
314  int cc2 = ( int( msg[ii] ) >> 4) & 0x0F;
315  guid << wxString::Format( wxT( "%X%X" ), cc2, cc1 );
316 
317  if( guid.Len() >= 32 )
318  break;
319  }
320 
321  // guid has 32 digits, so add missing digits
322  int cnt = 32 - guid.Len();
323 
324  if( cnt > 0 )
325  guid.Append( '0', cnt );
326 
327  // build the <project id> string: this is the board short filename (without ext)
328  // and all non ASCII chars and comma are replaced by '_'
329  msg = fn.GetName();
330  msg.Replace( wxT( "," ), wxT( "_" ) );
331 
332  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
333  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
334  rev.Replace( wxT( "," ), wxT( "_" ) );
335 
336  if( rev.IsEmpty() )
337  rev = wxT( "rev?" );
338 
339  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
340  aHeader.Add( text );
341 
342  // Add the TF.SameCoordinates, that specify all gerber files uses the same
343  // origin and orientation, and the registration between files is OK.
344  // The parameter of TF.SameCoordinates is a string that is common
345  // to all files using the same registration and has no special meaning:
346  // this is just a key
347  // Because there is no mirroring/rotation in Kicad, only the plot offset origin
348  // can create incorrect registration.
349  // So we create a key from plot offset options.
350  // and therefore for a given board, all Gerber files having the same key have the same
351  // plot origin and use the same registration
352  //
353  // Currently the key is "Original" when using absolute Pcbnew coordinates,
354  // and te PY ans PY position od auxiliary axis, when using it.
355  // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
356  // the key is built to ensure file only using the *same* axis have the same key.
357  wxString registration_id = "Original";
358  wxPoint auxOrigin = aBoard->GetAuxOrigin();
359 
360  if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
361  registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );
362 
363  text.Printf( "%%TF.SameCoordinates,%s*%%", registration_id.GetData() );
364  aHeader.Add( text );
365 }
366 
367 
368 void AddGerberX2Header( PLOTTER * aPlotter,
369  const BOARD *aBoard, bool aUseX1CompatibilityMode )
370 {
371  wxString text;
372 
373  // Creates the TF,.GenerationSoftware. Format is:
374  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
375  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
376  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
377 
378  // creates the TF.CreationDate ext:
379  // The attribute value must conform to the full version of the ISO 8601
380  // date and time format, including time and time zone. Note that this is
381  // the date the Gerber file was effectively created,
382  // not the time the project of PCB was started
383  wxDateTime date( wxDateTime::GetTimeNow() );
384  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
385  wxString msg = date.Format( wxT( "%z" ) ); // Extract the time zone offset
386  // The time zone offset format is + (or -) mm or hhmm (mm = number of minutes, hh = number of hours)
387  // we want +(or -) hh:mm
388  if( msg.Len() > 3 )
389  msg.insert( 3, ":", 1 ),
390  text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
391  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
392 
393  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
394  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
395  // <project id> is the name of the project, restricted to basic ASCII symbols only,
396  // and comma not accepted
397  // All illegal chars will be replaced by underscore
398  // <project GUID> is a 32 hexadecimal digits string which is an unique id of a project.
399  // This is a random 128-bit number expressed in 32 hexadecimal digits.
400  // See en.wikipedia.org/wiki/GUID for more information
401  // However Kicad does not handle such a project GUID, so it is built from the board name
402  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
403  wxFileName fn = aBoard->GetFileName();
404  msg = fn.GetFullName();
405  wxString guid;
406 
407  // Build a 32 digits GUID from the board name:
408  for( unsigned ii = 0; ii < msg.Len(); ii++ )
409  {
410  int cc1 = int( msg[ii] ) & 0x0F;
411  int cc2 = ( int( msg[ii] ) >> 4) & 0x0F;
412  guid << wxString::Format( wxT( "%X%X" ), cc2, cc1 );
413 
414  if( guid.Len() >= 32 )
415  break;
416  }
417 
418  // guid has 32 digits, so add missing digits
419  int cnt = 32 - guid.Len();
420 
421  if( cnt > 0 )
422  guid.Append( '0', cnt );
423 
424  // build the <project id> string: this is the board short filename (without ext)
425  // and all non ASCII chars and comma are replaced by '_'
426  msg = fn.GetName();
427  msg.Replace( wxT( "," ), wxT( "_" ) );
428 
429  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
430  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
431  rev.Replace( wxT( "," ), wxT( "_" ) );
432 
433  if( rev.IsEmpty() )
434  rev = wxT( "rev?" );
435 
436  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
437  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
438 
439  // Add the TF.SameCoordinates, that specify all gerber files uses the same
440  // origin and orientation, and the registration between files is OK.
441  // The parameter of TF.SameCoordinates is a string that is common
442  // to all files using the same registration and has no special meaning:
443  // this is just a key
444  // Because there is no mirroring/rotation in Kicad, only the plot offset origin
445  // can create incorrect registration.
446  // So we create a key from plot offset options.
447  // and therefore for a given board, all Gerber files having the same key have the same
448  // plot origin and use the same registration
449  //
450  // Currently the key is "Original" when using absolute Pcbnew coordinates,
451  // and te PY ans PY position od auxiliary axis, when using it.
452  // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
453  // the key is built to ensure file only using the *same* axis have the same key.
454  wxString registration_id = "Original";
455  wxPoint auxOrigin = aBoard->GetAuxOrigin();
456 
457  if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
458  registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );
459 
460  text.Printf( "%%TF.SameCoordinates,%s*%%", registration_id.GetData() );
461  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
462 }
463 
464 
465 void AddGerberX2Attribute( PLOTTER * aPlotter,
466  const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode )
467 {
468  AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode );
469 
470  wxString text;
471 
472  // Add the TF.FileFunction
473  text = GetGerberFileFunctionAttribute( aBoard, aLayer );
474  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
475 
476  // Add the TF.FilePolarity (for layers which support that)
477  text = GetGerberFilePolarityAttribute( aLayer );
478 
479  if( !text.IsEmpty() )
480  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
481 }
482 
483 
484 void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir,
485  const wxString& aSuffix, const wxString& aExtension )
486 {
487  // aFilename contains the base filename only (without path and extension)
488  // when calling this function.
489  // It is expected to be a valid filename (this is usually the board filename)
490  aFilename->SetPath( aOutputDir );
491 
492  // Set the file extension
493  aFilename->SetExt( aExtension );
494 
495  // remove leading and trailing spaces if any from the suffix, if
496  // something survives add it to the name;
497  // also the suffix can contain some not allowed chars in filename (/ \ . :),
498  // so change them to underscore
499  // Remember it can be called from a python script, so the illegal chars
500  // have to be filtered here.
501  wxString suffix = aSuffix;
502  suffix.Trim( true );
503  suffix.Trim( false );
504 
505  wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
506  badchars.Append( '%' );
507 
508  for( unsigned ii = 0; ii < badchars.Len(); ii++ )
509  suffix.Replace( badchars[ii], wxT("_") );
510 
511  if( !suffix.IsEmpty() )
512  aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
513 }
514 
515 
517 {
518  m_plotter = NULL;
519  m_board = aBoard;
521 }
522 
523 
525 {
526  ClosePlot();
527 }
528 
529 
530 /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as
531  * C/POSIX using a LOCALE_IO object on the stack. This even when
532  * opening/closing the plotfile, since some drivers do I/O even then */
533 
535 {
536  LOCALE_IO toggle;
537 
538  if( m_plotter )
539  {
540  m_plotter->EndPlot();
541  delete m_plotter;
542  m_plotter = NULL;
543  }
544 }
545 
546 
547 bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
548  PlotFormat aFormat,
549  const wxString &aSheetDesc )
550 {
551  LOCALE_IO toggle;
552 
553  /* Save the current format: sadly some plot routines depends on this
554  but the main reason is that the StartPlot method uses it to
555  dispatch the plotter creation */
556  GetPlotOptions().SetFormat( aFormat );
557 
558  // Ensure that the previous plot is closed
559  ClosePlot();
560 
561  // Now compute the full filename for the output and start the plot
562  // (after ensuring the output directory is OK)
563  wxString outputDirName = GetPlotOptions().GetOutputDirectory() ;
564  wxFileName outputDir = wxFileName::DirName( outputDirName );
565  wxString boardFilename = m_board->GetFileName();
566 
567  if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
568  {
569  // outputDir contains now the full path of plot files
570  m_plotFile = boardFilename;
571  m_plotFile.SetPath( outputDir.GetPath() );
572  wxString fileExt = GetDefaultPlotExtension( aFormat );
573 
574  // Gerber format can use specific file ext, depending on layers
575  // (now not a good practice, because the official file ext is .gbr)
576  if( GetPlotOptions().GetFormat() == PLOT_FORMAT_GERBER &&
577  GetPlotOptions().GetUseGerberProtelExtensions() )
578  fileExt = GetGerberProtelExtension( GetLayer() );
579 
580  // Build plot filenames from the board name and layer names:
581  BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
582 
584  m_plotFile.GetFullPath(), aSheetDesc );
585  }
586 
587  return( m_plotter != NULL );
588 }
589 
590 
592 {
593  LOCALE_IO toggle;
594 
595  // No plot open, nothing to do...
596  if( !m_plotter )
597  return false;
598 
599  // Fully delegated to the parent
601 
602  return true;
603 }
604 
605 
606 void PLOT_CONTROLLER::SetColorMode( bool aColorMode )
607 {
608  if( !m_plotter )
609  return;
610 
611  m_plotter->SetColorMode( aColorMode );
612 }
613 
614 
616 {
617  if( !m_plotter )
618  return false;
619 
620  return m_plotter->GetColorMode();
621 }
PCB_PLOT_PARAMS & GetPlotOptions()
Accessor to the plot parameters and options.
LAYER_NUM GetLayer()
~PLOT_CONTROLLER()
Batch plotter destructor, ensures that the last plot is closed.
Definition: pcbplot.cpp:524
void ClosePlot()
Close the current plot, nothing happens if it isn't open.
Definition: pcbplot.cpp:534
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:165
PLOTTER * m_plotter
This is the plotter object; it starts NULL and become instantiated when a plotfile is requested...
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
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.
Class BOARD to handle a board.
void SetFormat(PlotFormat aFormat)
bool GetColorMode()
Definition: pcbplot.cpp:615
wxString GetDefaultPlotExtension(PlotFormat aFormat)
Returns the default plot extension for a format.
int GetCopperLayerCount() const
Function GetCopperLayerCount.
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Function GetGerberProtelExtension.
Definition: pcbplot.cpp:47
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:368
wxFileName m_plotFile
The current plot filename, set by OpenPlotfile.
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:465
bool GetUseAuxOrigin() const
void AddLineToHeader(const wxString &aExtraString)
Function AddLineToHeader Add a line to the list of free lines to print at the beginning of the file...
void BuildGerberX2Header(const BOARD *aBoard, wxArrayString &aHeader)
Definition: pcbplot.cpp:272
BOARD * m_board
The board we're plotting.
This file contains miscellaneous commonly used macros and functions.
PLOT_CONTROLLER(BOARD *aBoard)
Batch plotter constructor, nothing interesting here.
Definition: pcbplot.cpp:516
Board plot function definition file.
virtual bool EndPlot()=0
wxString GetOutputDirectory() const
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
const wxString & GetFileName() const
Definition: class_board.h:234
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Helper function EnsureFileDirectoryExists make aTargetFullFileName absolute and creates the path of t...
Definition: common.cpp:267
LAYER_T
Enum LAYER_T gives the allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:71
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:550
PlotFormat
Enum PlotFormat is the set of supported output plot formats.
Definition: class_plotter.h:50
bool GetColorMode() const
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:343
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...
Definition: pcbplot.cpp:484
static const wxString GetGerberFilePolarityAttribute(LAYER_NUM aLayer)
Definition: pcbplot.cpp:201
Base plotter engine class.
Definition: class_plotter.h:97
void SetColorMode(bool)
Plotters can plot in Black and White mode or Color mode SetColorMode activate/de-actiavte the Color m...
Definition: pcbplot.cpp:606
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:260
bool OpenPlotfile(const wxString &aSuffix, PlotFormat aFormat, const wxString &aSheetDesc)
Open a new plotfile; works as a factory for plotter objects.
Definition: pcbplot.cpp:547
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:169
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer...
Definition: pcbplot.cpp:88
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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 prepar...
bool PlotLayer()
Plot a single layer on the current plotfile m_plotLayer is the layer to plot.
Definition: pcbplot.cpp:591
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:774
LAYER_NUM m_plotLayer
the layer to plot
virtual void SetColorMode(bool _color_mode)