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 <plot_common.h>
32 #include <confirm.h>
33 #include <wxPcbStruct.h>
34 #include <pcbplot.h>
35 #include <pcbstruct.h>
36 #include <base_units.h>
37 #include <reporter.h>
38 #include <class_board.h>
39 #include <pcbnew.h>
40 #include <plotcontroller.h>
41 #include <pcb_plot_params.h>
42 #include <wx/ffile.h>
43 #include <dialog_plot.h>
44 #include <macros.h>
45 #include <build_version.h>
46 
47 
48 const wxString GetGerberProtelExtension( LAYER_NUM aLayer )
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 }
87 
88 
89 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer )
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 }
200 
201 
202 static const wxString GetGerberFilePolarityAttribute( LAYER_NUM aLayer )
203 {
204  /* build the string %TF.FilePolarity,Positive*%
205  * or %TF.FilePolarity,Negative*%
206  * an emply string for layers which do not use a polarity
207  *
208  * The value of the .FilePolarity specifies whether the image represents the
209  * presence or absence of material.
210  * This attribute can only be used when the file represents a pattern in a material layer,
211  * e.g. copper, solder mask, legend.
212  * Together with.FileFunction it defines the role of that image in
213  * the layer structure of the PCB.
214  * Note that the .FilePolarity attribute does not change the image -
215  * no attribute does.
216  * It changes the interpretation of the image.
217  * For example, in a copper layer in positive polarity a round flash generates a copper pad.
218  * In a copper layer in negative polarity it generates a clearance.
219  * Solder mask images usually represent solder mask openings and are then negative.
220  * This may be counter-intuitive.
221  */
222  int polarity = 0;
223 
224  switch( aLayer )
225  {
226  case F_Adhes:
227  case B_Adhes:
228  case F_SilkS:
229  case B_SilkS:
230  case F_Paste:
231  case B_Paste:
232  polarity = 1;
233  break;
234 
235  case F_Mask:
236  case B_Mask:
237  polarity = -1;
238  break;
239 
240  default:
241  if( IsCopperLayer( aLayer ) )
242  polarity = 1;
243  break;
244  }
245 
246  wxString filePolarity;
247 
248  if( polarity == 1 )
249  filePolarity = "%TF.FilePolarity,Positive*%";
250  if( polarity == -1 )
251  filePolarity = "%TF.FilePolarity,Negative*%";
252 
253  return filePolarity;
254 }
255 
256 /* Add some X2 attributes to the file header, as defined in the
257  * Gerber file format specification J4 and "Revision 2015.06"
258  */
259 
260 // A helper function to convert a X2 attribute string to a X1 structured comment:
261 static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMode )
262 {
263  if( aUseX1CompatibilityMode )
264  {
265  aText.Replace( "%", "" );
266  aText.Prepend( "G04 #@! " );
267  }
268 
269  return aText;
270 }
271 
272 
273 void BuildGerberX2Header( const BOARD *aBoard, wxArrayString& aHeader )
274 {
275  wxString text;
276 
277  // Creates the TF,.GenerationSoftware. Format is:
278  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
279  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
280  aHeader.Add( text );
281 
282  // creates the TF.CreationDate ext:
283  // The attribute value must conform to the full version of the ISO 8601
284  // date and time format, including time and time zone. Note that this is
285  // the date the Gerber file was effectively created,
286  // not the time the project of PCB was started
287  wxDateTime date( wxDateTime::GetTimeNow() );
288  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
289  wxString msg = date.Format( wxT( "%z" ) ); // Extract the time zone offset
290  // The time zone offset format is + (or -) mm or hhmm (mm = number of minutes, hh = number of hours)
291  // we want +(or -) hh:mm
292  if( msg.Len() > 3 )
293  msg.insert( 3, ":", 1 ),
294  text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
295  aHeader.Add( text );
296 
297  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
298  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
299  // <project id> is the name of the project, restricted to basic ASCII symbols only,
300  // and comma not accepted
301  // All illegal chars will be replaced by underscore
302  // <project GUID> is a 32 hexadecimal digits string which is an unique id of a project.
303  // This is a random 128-bit number expressed in 32 hexadecimal digits.
304  // See en.wikipedia.org/wiki/GUID for more information
305  // However Kicad does not handle such a project GUID, so it is built from the board name
306  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
307  wxFileName fn = aBoard->GetFileName();
308  msg = fn.GetFullName();
309  wxString guid;
310 
311  // Build a 32 digits GUID from the board name:
312  for( unsigned ii = 0; ii < msg.Len(); ii++ )
313  {
314  int cc1 = int( msg[ii] ) & 0x0F;
315  int cc2 = ( int( msg[ii] ) >> 4) & 0x0F;
316  guid << wxString::Format( wxT( "%X%X" ), cc2, cc1 );
317 
318  if( guid.Len() >= 32 )
319  break;
320  }
321 
322  // guid has 32 digits, so add missing digits
323  int cnt = 32 - guid.Len();
324 
325  if( cnt > 0 )
326  guid.Append( '0', cnt );
327 
328  // build the <project id> string: this is the board short filename (without ext)
329  // and all non ASCII chars and comma are replaced by '_'
330  msg = fn.GetName();
331  msg.Replace( wxT( "," ), wxT( "_" ) );
332 
333  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
334  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
335  rev.Replace( wxT( "," ), wxT( "_" ) );
336 
337  if( rev.IsEmpty() )
338  rev = wxT( "rev?" );
339 
340  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
341  aHeader.Add( text );
342 
343  // Add the TF.SameCoordinates, that specify all gerber files uses the same
344  // origin and orientation, and the registration between files is OK.
345  // The parameter of TF.SameCoordinates is a string that is common
346  // to all files using the same registration and has no special meaning:
347  // this is just a key
348  // Because there is no mirroring/rotation in Kicad, only the plot offset origin
349  // can create incorrect registration.
350  // So we create a key from plot offset options.
351  // and therefore for a given board, all Gerber files having the same key have the same
352  // plot origin and use the same registration
353  //
354  // Currently the key is "Original" when using absolute Pcbnew coordinates,
355  // and te PY ans PY position od auxiliary axis, when using it.
356  // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
357  // the key is built to ensure file only using the *same* axis have the same key.
358  wxString registration_id = "Original";
359  wxPoint auxOrigin = aBoard->GetAuxOrigin();
360 
361  if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
362  registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );
363 
364  text.Printf( "%%TF.SameCoordinates,%s*%%", registration_id.GetData() );
365  aHeader.Add( text );
366 }
367 
368 
369 void AddGerberX2Header( PLOTTER * aPlotter,
370  const BOARD *aBoard, bool aUseX1CompatibilityMode )
371 {
372  wxString text;
373 
374  // Creates the TF,.GenerationSoftware. Format is:
375  // %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
376  text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
377  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
378 
379  // creates the TF.CreationDate ext:
380  // The attribute value must conform to the full version of the ISO 8601
381  // date and time format, including time and time zone. Note that this is
382  // the date the Gerber file was effectively created,
383  // not the time the project of PCB was started
384  wxDateTime date( wxDateTime::GetTimeNow() );
385  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
386  wxString msg = date.Format( wxT( "%z" ) ); // Extract the time zone offset
387  // The time zone offset format is + (or -) mm or hhmm (mm = number of minutes, hh = number of hours)
388  // we want +(or -) hh:mm
389  if( msg.Len() > 3 )
390  msg.insert( 3, ":", 1 ),
391  text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
392  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
393 
394  // Creates the TF,.ProjectId. Format is (from Gerber file format doc):
395  // %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
396  // <project id> is the name of the project, restricted to basic ASCII symbols only,
397  // and comma not accepted
398  // All illegal chars will be replaced by underscore
399  // <project GUID> is a 32 hexadecimal digits string which is an unique id of a project.
400  // This is a random 128-bit number expressed in 32 hexadecimal digits.
401  // See en.wikipedia.org/wiki/GUID for more information
402  // However Kicad does not handle such a project GUID, so it is built from the board name
403  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
404  wxFileName fn = aBoard->GetFileName();
405  msg = fn.GetFullName();
406  wxString guid;
407 
408  // Build a 32 digits GUID from the board name:
409  for( unsigned ii = 0; ii < msg.Len(); ii++ )
410  {
411  int cc1 = int( msg[ii] ) & 0x0F;
412  int cc2 = ( int( msg[ii] ) >> 4) & 0x0F;
413  guid << wxString::Format( wxT( "%X%X" ), cc2, cc1 );
414 
415  if( guid.Len() >= 32 )
416  break;
417  }
418 
419  // guid has 32 digits, so add missing digits
420  int cnt = 32 - guid.Len();
421 
422  if( cnt > 0 )
423  guid.Append( '0', cnt );
424 
425  // build the <project id> string: this is the board short filename (without ext)
426  // and all non ASCII chars and comma are replaced by '_'
427  msg = fn.GetName();
428  msg.Replace( wxT( "," ), wxT( "_" ) );
429 
430  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
431  wxString rev = ((BOARD*)aBoard)->GetTitleBlock().GetRevision();
432  rev.Replace( wxT( "," ), wxT( "_" ) );
433 
434  if( rev.IsEmpty() )
435  rev = wxT( "rev?" );
436 
437  text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
438  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
439 
440  // Add the TF.SameCoordinates, that specify all gerber files uses the same
441  // origin and orientation, and the registration between files is OK.
442  // The parameter of TF.SameCoordinates is a string that is common
443  // to all files using the same registration and has no special meaning:
444  // this is just a key
445  // Because there is no mirroring/rotation in Kicad, only the plot offset origin
446  // can create incorrect registration.
447  // So we create a key from plot offset options.
448  // and therefore for a given board, all Gerber files having the same key have the same
449  // plot origin and use the same registration
450  //
451  // Currently the key is "Original" when using absolute Pcbnew coordinates,
452  // and te PY ans PY position od auxiliary axis, when using it.
453  // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
454  // the key is built to ensure file only using the *same* axis have the same key.
455  wxString registration_id = "Original";
456  wxPoint auxOrigin = aBoard->GetAuxOrigin();
457 
458  if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
459  registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );
460 
461  text.Printf( "%%TF.SameCoordinates,%s*%%", registration_id.GetData() );
462  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
463 }
464 
465 
466 void AddGerberX2Attribute( PLOTTER * aPlotter,
467  const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode )
468 {
469  AddGerberX2Header( aPlotter, aBoard, aUseX1CompatibilityMode );
470 
471  wxString text;
472 
473  // Add the TF.FileFunction
474  text = GetGerberFileFunctionAttribute( aBoard, aLayer );
475  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
476 
477  // Add the TF.FilePolarity (for layers which support that)
478  text = GetGerberFilePolarityAttribute( aLayer );
479 
480  if( !text.IsEmpty() )
481  aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
482 }
483 
484 
485 void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir,
486  const wxString& aSuffix, const wxString& aExtension )
487 {
488  // aFilename contains the base filename only (without path and extension)
489  // when calling this function.
490  // It is expected to be a valid filename (this is usually the board filename)
491  aFilename->SetPath( aOutputDir );
492 
493  // Set the file extension
494  aFilename->SetExt( aExtension );
495 
496  // remove leading and trailing spaces if any from the suffix, if
497  // something survives add it to the name;
498  // also the suffix can contain some not allowed chars in filename (/ \ . :),
499  // so change them to underscore
500  // Remember it can be called from a python script, so the illegal chars
501  // have to be filtered here.
502  wxString suffix = aSuffix;
503  suffix.Trim( true );
504  suffix.Trim( false );
505 
506  wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
507  badchars.Append( '%' );
508 
509  for( unsigned ii = 0; ii < badchars.Len(); ii++ )
510  suffix.Replace( badchars[ii], wxT("_") );
511 
512  if( !suffix.IsEmpty() )
513  aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
514 }
515 
516 
518 {
519  m_plotter = NULL;
520  m_board = aBoard;
522 }
523 
524 
526 {
527  ClosePlot();
528 }
529 
530 
531 /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as
532  * C/POSIX using a LOCALE_IO object on the stack. This even when
533  * opening/closing the plotfile, since some drivers do I/O even then */
534 
536 {
537  LOCALE_IO toggle;
538 
539  if( m_plotter )
540  {
541  m_plotter->EndPlot();
542  delete m_plotter;
543  m_plotter = NULL;
544  }
545 }
546 
547 
548 bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
549  PlotFormat aFormat,
550  const wxString &aSheetDesc )
551 {
552  LOCALE_IO toggle;
553 
554  /* Save the current format: sadly some plot routines depends on this
555  but the main reason is that the StartPlot method uses it to
556  dispatch the plotter creation */
557  GetPlotOptions().SetFormat( aFormat );
558 
559  // Ensure that the previous plot is closed
560  ClosePlot();
561 
562  // Now compute the full filename for the output and start the plot
563  // (after ensuring the output directory is OK)
564  wxString outputDirName = GetPlotOptions().GetOutputDirectory() ;
565  wxFileName outputDir = wxFileName::DirName( outputDirName );
566  wxString boardFilename = m_board->GetFileName();
567 
568  if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
569  {
570  // outputDir contains now the full path of plot files
571  m_plotFile = boardFilename;
572  m_plotFile.SetPath( outputDir.GetPath() );
573  wxString fileExt = GetDefaultPlotExtension( aFormat );
574 
575  // Gerber format can use specific file ext, depending on layers
576  // (now not a good practice, because the official file ext is .gbr)
577  if( GetPlotOptions().GetFormat() == PLOT_FORMAT_GERBER &&
578  GetPlotOptions().GetUseGerberProtelExtensions() )
579  fileExt = GetGerberProtelExtension( GetLayer() );
580 
581  // Build plot filenames from the board name and layer names:
582  BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
583 
585  m_plotFile.GetFullPath(), aSheetDesc );
586  }
587 
588  return( m_plotter != NULL );
589 }
590 
591 
593 {
594  LOCALE_IO toggle;
595 
596  // No plot open, nothing to do...
597  if( !m_plotter )
598  return false;
599 
600  // Fully delegated to the parent
602 
603  return true;
604 }
605 
606 
607 void PLOT_CONTROLLER::SetColorMode( bool aColorMode )
608 {
609  if( !m_plotter )
610  return;
611 
612  m_plotter->SetColorMode( aColorMode );
613 }
614 
615 
617 {
618  if( !m_plotter )
619  return false;
620 
621  return m_plotter->GetColorMode();
622 }
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:525
void ClosePlot()
Close the current plot, nothing happens if it isn't open.
Definition: pcbplot.cpp:535
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
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.
PlotFormat
Enum PlotFormat is the set of supported output plot formats.
Definition: plot_common.h:49
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:616
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:48
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:369
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:466
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...
Definition: plot_common.h:166
void BuildGerberX2Header(const BOARD *aBoard, wxArrayString &aHeader)
Definition: pcbplot.cpp:273
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:517
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
Classes and definitions used in Pcbnew.
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:550
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
bool GetColorMode() const
Definition: plot_common.h:121
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:485
static const wxString GetGerberFilePolarityAttribute(LAYER_NUM aLayer)
Definition: pcbplot.cpp:202
Base plotter engine class.
Definition: plot_common.h:86
void SetColorMode(bool)
Plotters can plot in Black and White mode or Color mode SetColorMode activate/de-actiavte the Color m...
Definition: pcbplot.cpp:607
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
bool OpenPlotfile(const wxString &aSuffix, PlotFormat aFormat, const wxString &aSheetDesc)
Open a new plotfile; works as a factory for plotter objects.
Definition: pcbplot.cpp:548
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:89
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:592
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
LAYER_NUM m_plotLayer
the layer to plot
virtual void SetColorMode(bool _color_mode)
Definition: plot_common.h:116