KiCad PCB EDA Suite
gerber_jobfile_writer.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) 2018 Jean_Pierre Charras <jp.charras at wanadoo.fr>
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include <fctsys.h>
31 
32 #include <vector>
33 
34 #include <plotter.h>
35 #include <pcb_edit_frame.h>
36 #include <build_version.h>
37 
38 #include <class_board.h>
39 #include <class_zone.h>
40 #include <class_module.h>
41 
42 #include <pcbplot.h>
43 #include <pcbnew.h>
44 #include <gerber_jobfile_writer.h>
46 #include <reporter.h>
47 #include <gbr_metadata.h>
49 
50 
52 {
53  m_pcb = aPcb;
54  m_reporter = aReporter;
55  m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
56  m_indent = 0;
57 }
58 
59 std::string GERBER_JOBFILE_WRITER::formatStringFromUTF32( const wxString& aText )
60 {
61  std::string fmt_text; // the text after UTF32 to UTF8 conversion
62 
63  for( unsigned long letter: aText )
64  {
65  if( letter >= ' ' && letter <= 0x7F )
66  fmt_text += char( letter );
67  else
68  {
69  char buff[16];
70  sprintf( buff, "\\u%4.4lX", letter );
71  fmt_text += buff;
72  }
73  }
74  return fmt_text;
75 }
76 
77 
79 {
80  int flag = SIDE_NONE;
81 
82  for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
83  {
84  if( m_params.m_LayerId[ii] == B_SilkS )
85  flag |= SIDE_BOTTOM;
86 
87  if( m_params.m_LayerId[ii] == F_SilkS )
88  flag |= SIDE_TOP;
89  }
90 
91  return (enum ONSIDE)flag;
92 }
93 
94 
96 {
97  int flag = SIDE_NONE;
98 
99  for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
100  {
101  if( m_params.m_LayerId[ii] == B_Mask )
102  flag |= SIDE_BOTTOM;
103 
104  if( m_params.m_LayerId[ii] == F_Mask )
105  flag |= SIDE_TOP;
106  }
107 
108  return (enum ONSIDE)flag;
109 }
110 
111 const char* GERBER_JOBFILE_WRITER::sideKeyValue( enum ONSIDE aValue )
112 {
113  // return the key associated to sides used for some layers
114  // "No, TopOnly, BotOnly or Both"
115  const char* value = nullptr;
116 
117  switch( aValue )
118  {
119  case SIDE_NONE:
120  value = "No"; break;
121 
122  case SIDE_TOP:
123  value = "TopOnly"; break;
124 
125  case SIDE_BOTTOM:
126  value = "BotOnly"; break;
127 
128  case SIDE_BOTH:
129  value = "Both"; break;
130 
131  }
132 
133  return value;
134 }
135 
136 
137 bool GERBER_JOBFILE_WRITER::CreateJobFile( const wxString& aFullFilename )
138 {
139  bool success;
140  wxString msg;
141 
142  success = WriteJSONJobFile( aFullFilename );
143 
144  if( !success )
145  {
146  if( m_reporter )
147  {
148  msg.Printf( _( "Unable to create job file \"%s\"" ), aFullFilename );
150  }
151  }
152  else if( m_reporter )
153  {
154  msg.Printf( _( "Create Gerber job file \"%s\"" ), aFullFilename );
156  }
157 
158  return success;
159 }
160 
161 
163 {
164  wxString text;
165  openBlock();
166  addJSONObject( "\"Header\":\n" );
167  openBlock();
168 
169  // Creates the GenerationSoftware
170  addJSONObject( "\"GenerationSoftware\":\n" );
171  openBlock();
172  addJSONObject( "\"Vendor\": \"KiCad\",\n" );
173  addJSONObject( "\"Application\": \"Pcbnew\",\n" );
174  text.Printf( "\"Version\": \"%s\"\n", GetBuildVersion() );
175  addJSONObject( text );
177 
178  // creates the CreationDate attribute:
179  // The attribute value must conform to the full version of the ISO 8601
180  // date and time format, including time and time zone.
182  addJSONObject( text );
183 
185 }
186 
187 
189 {
190  if( m_JSONbuffer.Last() == ',' )
191  {
192  m_JSONbuffer.RemoveLast();
193  return;
194  }
195 
196  if( m_JSONbuffer.Last() == '\n' )
197  {
198  m_JSONbuffer.RemoveLast();
199 
200  if( m_JSONbuffer.Last() == ',' )
201  m_JSONbuffer.RemoveLast();
202 
203  m_JSONbuffer.Append( '\n' );
204  }
205 }
206 
207 bool GERBER_JOBFILE_WRITER::WriteJSONJobFile( const wxString& aFullFilename )
208 {
209  // Note: in Gerber job file, dimensions are in mm, and are floating numbers
210  FILE* jobFile = wxFopen( aFullFilename, "wt" );
211 
212  m_JSONbuffer.Empty();
213  m_indent = 0;
214 
215  if( jobFile == nullptr )
216  return false;
217 
219 
220  // output the job file header
221  addJSONHeader();
222 
223  // Add the General Specs
225 
226  // Job file support a few design rules:
228 
229  // output the gerber file list:
231 
232  // output the board stackup:
234 
235  // Close job file full block data
236  removeJSONSepararator(); // remove the last separator
237  closeBlock();
238 
239  fputs( TO_UTF8( m_JSONbuffer ), jobFile );
240 
241  fclose( jobFile );
242 
243  return true;
244 }
245 
246 
248 {
249  addJSONObject( "\"GeneralSpecs\":\n" );
250  openBlock();
251 
252  addJSONObject( "\"ProjectId\":\n" );
253  openBlock();
254 
255  // Creates the ProjectId. Format is (from Gerber file format doc):
256  // ProjectId,<project id>,<project GUID>,<revision id>*%
257  // <project id> is the name of the project, restricted to basic ASCII symbols only,
258  // and comma not accepted
259  // All illegal chars will be replaced by underscore
260  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
261  //
262  // <project GUID> is a string which is an unique id of a project.
263  // However Kicad does not handle such a project GUID, so it is built from the board name
264  wxFileName fn = m_pcb->GetFileName();
265  wxString msg = fn.GetFullName();
266 
267  // Build a <project GUID>, from the board name
268  wxString guid = GbrMakeProjectGUIDfromString( msg );
269 
270  // build the <project id> string: this is the board short filename (without ext)
271  // and all non ASCII chars are replaced by '_', to be compatible with .gbr files.
272  msg = fn.GetName();
273 
274  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
275  wxString rev = m_pcb->GetTitleBlock().GetRevision();
276 
277  if( rev.IsEmpty() )
278  rev = wxT( "rev?" );
279 
280  addJSONObject( wxString::Format( "\"Name\": \"%s\",\n", msg.ToAscii() ) );
281  addJSONObject( wxString::Format( "\"GUID\": \"%s\",\n", guid ) );
282  addJSONObject( wxString::Format( "\"Revision\": \"%s\"\n", rev.ToAscii() ) );
283 
285 
286  // output the bord size in mm:
288  addJSONObject( "\"Size\":\n" );
289  openBlock();
290 
291  addJSONObject( wxString::Format( "\"X\": %.3f,\n", brect.GetWidth()*m_conversionUnits ) );
292  addJSONObject( wxString::Format( "\"Y\": %.3f\n", brect.GetHeight()*m_conversionUnits ) );
294 
295  // Add some data to the JSON header, GeneralSpecs:
296  // number of copper layers
297  addJSONObject( wxString::Format( "\"LayerNumber\": %d,\n", m_pcb->GetCopperLayerCount() ) );
298 
299  // Board thickness
300  addJSONObject( wxString::Format( "\"BoardThickness\": %.3f,\n",
302 
303 
304  // Copper finish
306 
307  if( !brd_stackup.m_FinishType.IsEmpty() )
308  addJSONObject( wxString::Format( "\"Finish\": \"%s\",\n", brd_stackup.m_FinishType ) );
309 
310  if( brd_stackup.m_CastellatedPads )
311  addJSONObject( "\"Castellated\": \"true\",\n" );
312 
313  if( brd_stackup.m_EdgePlating )
314  addJSONObject( "\"EdgePlating\": \"true\",\n" );
315 
316  if( brd_stackup.m_EdgeConnectorConstraints )
317  {
318  addJSONObject( "\"EdgeConnector\": \"true\",\n" );
319 
321  addJSONObject( "\"EdgeConnectorBevelled\": \"true\",\n" );
322  else
323  addJSONObject( "\"EdgeConnectorBevelled\": \"false\",\n" );
324  }
325 
326 #if 0 // Not yet in use
327  /* The board type according to IPC-2221. There are six primary board types:
328  - Type 1 - Single-sided
329  - Type 2 - Double-sided
330  - Type 3 - Multilayer, TH components only
331  - Type 4 - Multilayer, with TH, blind and/or buried vias.
332  - Type 5 - Multilayer metal-core board, TH components only
333  - Type 6 - Multilayer metal-core
334  */
335  addJSONObject( wxString::Format( "\"IPC-2221-Type\": \"%d\",\n", 4 ) );
336 
337  /* Via protection: key words:
338  Ia Tented - Single-sided
339  Ib Tented - Double-sided
340  IIa Tented and Covered - Single-sided
341  IIb Tented and Covered - Double-sided
342  IIIa Plugged - Single-sided
343  IIIb Plugged - Double-sided
344  IVa Plugged and Covered - Single-sided
345  IVb Plugged and Covered - Double-sided
346  V Filled (fully plugged)
347  VI Filled and Covered
348  VIII Filled and Capped
349  None...No protection
350  */
351  addJSONObject( wxString::Format( "\"ViaProtection\": \"%s\",\n", "Ib" ) );
352 #endif
355 }
356 
357 
359 {
360  // Add the Files Attributes section in JSON format to m_JSONbuffer
361  addJSONObject( "\"FilesAttributes\":\n" );
362  openArrayBlock();
363 
364  for( unsigned ii = 0; ii < m_params.m_GerberFileList.GetCount(); ii ++ )
365  {
366  wxString& name = m_params.m_GerberFileList[ii];
367  PCB_LAYER_ID layer = m_params.m_LayerId[ii];
368  wxString gbr_layer_id;
369  bool skip_file = false; // true to skip files which should not be in job file
370  const char* polarity = "Positive";
371 
372  if( layer <= B_Cu )
373  {
374  gbr_layer_id = "Copper,L";
375 
376  if( layer == B_Cu )
377  gbr_layer_id << m_pcb->GetCopperLayerCount();
378  else
379  gbr_layer_id << layer+1;
380 
381  gbr_layer_id << ",";
382 
383  if( layer == B_Cu )
384  gbr_layer_id << "Bot";
385  else if( layer == F_Cu )
386  gbr_layer_id << "Top";
387  else
388  gbr_layer_id << "Inr";
389  }
390 
391  else
392  {
393  switch( layer )
394  {
395  case B_Adhes:
396  gbr_layer_id = "Glue,Bot"; break;
397  case F_Adhes:
398  gbr_layer_id = "Glue,Top"; break;
399 
400  case B_Paste:
401  gbr_layer_id = "SolderPaste,Bot"; break;
402  case F_Paste:
403  gbr_layer_id = "SolderPaste,Top"; break;
404 
405  case B_SilkS:
406  gbr_layer_id = "Legend,Bot"; break;
407  case F_SilkS:
408  gbr_layer_id = "Legend,Top"; break;
409 
410  case B_Mask:
411  gbr_layer_id = "SolderMask,Bot"; polarity = "Negative"; break;
412  case F_Mask:
413  gbr_layer_id = "SolderMask,Top"; polarity = "Negative"; break;
414 
415  case Edge_Cuts:
416  gbr_layer_id = "Profile"; break;
417 
418  case B_Fab:
419  gbr_layer_id = "AssemblyDrawing,Bot"; break;
420  case F_Fab:
421  gbr_layer_id = "AssemblyDrawing,Top"; break;
422 
423  case Dwgs_User:
424  case Cmts_User:
425  case Eco1_User:
426  case Eco2_User:
427  case Margin:
428  case B_CrtYd:
429  case F_CrtYd:
430  skip_file = true; break;
431 
432  default:
433  skip_file = true;
434  m_reporter->Report( "Unexpected layer id in job file",
436  break;
437  }
438  }
439 
440  if( !skip_file )
441  {
442  // name can contain non ASCII7 chars.
443  // Ensure the name is JSON compatible.
444  std::string strname = formatStringFromUTF32( name );
445 
446  openBlock();
447  addJSONObject( wxString::Format( "\"Path\": \"%s\",\n", strname.c_str() ) );
448  addJSONObject( wxString::Format( "\"FileFunction\": \"%s\",\n", gbr_layer_id ) ),
449  addJSONObject( wxString::Format( "\"FilePolarity\": \"%s\"\n", polarity ) );
451  }
452  }
453  // Close the file list:
454  removeJSONSepararator(); // remove the last separator
456 }
457 
458 
460 {
461  // Add the Design Rules section in JSON format to m_JSONbuffer
462  // Job file support a few design rules:
463  const BOARD_DESIGN_SETTINGS& dsnSettings = m_pcb->GetDesignSettings();
464  NETCLASS defaultNC = *dsnSettings.GetDefault();
465  int minclearanceOuter = defaultNC.GetClearance();
466  bool hasInnerLayers = m_pcb->GetCopperLayerCount() > 2;
467 
468  // Search a smaller clearance in other net classes, if any.
469  for( NETCLASSES::const_iterator it = dsnSettings.m_NetClasses.begin();
470  it != dsnSettings.m_NetClasses.end();
471  ++it )
472  {
473  NETCLASS netclass = *it->second;
474  minclearanceOuter = std::min( minclearanceOuter, netclass.GetClearance() );
475  }
476 
477  // job file knows different clearance types.
478  // Kicad knows only one clearance for pads and tracks
479  int minclearance_track2track = minclearanceOuter;
480 
481  // However, pads can have a specific clearance defined for a pad or a footprint,
482  // and min clearance can be dependent on layers.
483  // Search for a minimal pad clearance:
484  int minPadClearanceOuter = defaultNC.GetClearance();
485  int minPadClearanceInner = defaultNC.GetClearance();
486 
487  for( MODULE* module : m_pcb->Modules() )
488  {
489  for( auto& pad : module->Pads() )
490  {
491  if( ( pad->GetLayerSet() & LSET::InternalCuMask() ).any() )
492  minPadClearanceInner = std::min( minPadClearanceInner, pad->GetClearance() );
493 
494  if( ( pad->GetLayerSet() & LSET::ExternalCuMask() ).any() )
495  minPadClearanceOuter = std::min( minPadClearanceOuter, pad->GetClearance() );
496  }
497  }
498 
499 
500  addJSONObject( "\"DesignRules\":\n" );
501  openArrayBlock();
502 
503  openBlock();
504  addJSONObject( "\"Layers\": \"Outer\",\n" );
505  addJSONObject( wxString::Format( "\"PadToPad\": %.3f,\n", minPadClearanceOuter*m_conversionUnits ) );
506  addJSONObject( wxString::Format( "\"PadToTrack\": %.3f,\n", minPadClearanceOuter*m_conversionUnits ) );
507  addJSONObject( wxString::Format( "\"TrackToTrack\": %.3f,\n", minclearance_track2track*m_conversionUnits ) );
508 
509  // Until this is changed in Kicad, use the same value for internal tracks
510  int minclearanceInner = minclearanceOuter;
511 
512  // Output the minimal track width
513  int mintrackWidthOuter = INT_MAX;
514  int mintrackWidthInner = INT_MAX;
515 
516  for( TRACK* track : m_pcb->Tracks() )
517  {
518  if( track->Type() == PCB_VIA_T )
519  continue;
520 
521  if( track->GetLayer() == B_Cu || track->GetLayer() == F_Cu )
522  mintrackWidthOuter = std::min( mintrackWidthOuter, track->GetWidth() );
523  else
524  mintrackWidthInner = std::min( mintrackWidthInner, track->GetWidth() );
525  }
526 
527  if( mintrackWidthOuter != INT_MAX )
528  addJSONObject( wxString::Format( "\"MinLineWidth\": %.3f,\n",
529  mintrackWidthOuter*m_conversionUnits ) );
530 
531  // Output the minimal zone to xx clearance
532  // Note: zones can have a zone clearance set to 0
533  // if happens, the actual zone clearance is the clearance of its class
534  minclearanceOuter = INT_MAX;
535  minclearanceInner = INT_MAX;
536 
537  for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
538  {
539  ZONE_CONTAINER* zone = m_pcb->GetArea( ii );
540 
541  if( zone->GetIsKeepout() || !zone->IsOnCopperLayer() )
542  continue;
543 
544  int zclerance = zone->GetClearance();
545 
546  if( zone->GetLayer() == B_Cu || zone->GetLayer() == F_Cu )
547  minclearanceOuter = std::min( minclearanceOuter, zclerance );
548  else
549  minclearanceInner = std::min( minclearanceInner, zclerance );
550  }
551 
552  if( minclearanceOuter != INT_MAX )
553  addJSONObject( wxString::Format( "\"TrackToRegion\": %.3f,\n",
554  minclearanceOuter*m_conversionUnits ) );
555 
556  if( minclearanceOuter != INT_MAX )
557  addJSONObject( wxString::Format( "\"RegionToRegion\": %.3f,\n",
558  minclearanceOuter*m_conversionUnits ) );
559 
560  removeJSONSepararator(); // remove the last separator
561 
562  if( !hasInnerLayers )
563  closeBlock();
564  else
566 
567 
568  if( hasInnerLayers )
569  {
570  openBlock();
571  addJSONObject( "\"Layers\": \"Inner\",\n" );
572  addJSONObject( wxString::Format( "\"PadToPad\": %.3f,\n", minPadClearanceInner*m_conversionUnits ) );
573  addJSONObject( wxString::Format( "\"PadToTrack\": %.3f,\n", minPadClearanceInner*m_conversionUnits ) );
574  addJSONObject( wxString::Format( "\"TrackToTrack\": %.3f,\n", minclearance_track2track*m_conversionUnits ) );
575 
576  if( mintrackWidthInner != INT_MAX )
577  addJSONObject( wxString::Format( "\"MinLineWidth\": %.3f,\n", mintrackWidthInner*m_conversionUnits ) );
578 
579  if( minclearanceInner != INT_MAX )
580  addJSONObject( wxString::Format( "\"TrackToRegion\": %.3f,\n", minclearanceInner*m_conversionUnits ) );
581 
582  if( minclearanceInner != INT_MAX )
583  addJSONObject( wxString::Format( "\"RegionToRegion\": %.3f,\n", minclearanceInner*m_conversionUnits ) );
584 
585  removeJSONSepararator(); // remove the last separator
586  closeBlock();
587  }
588 
589  // Close DesignRules
591 }
592 
593 
595 {
596  // Add the Material Stackup section in JSON format to m_JSONbuffer
597  addJSONObject( "\"MaterialStackup\":\n" );
598  openArrayBlock();
599 
600  // Build the candidates list:
601  LSET maskLayer;
603 
604  // Ensure brd_stackup is up to date (i.e. no change made by SynchronizeWithBoard() )
605  bool uptodate = not brd_stackup.SynchronizeWithBoard( &m_pcb->GetDesignSettings() );
606 
607  if( !uptodate && m_pcb->GetDesignSettings().m_HasStackup )
608  m_reporter->Report( _( "Board stackup settings not up to date\n"
609  "Please fix the stackup" ), REPORTER::RPT_ERROR );
610 
611  PCB_LAYER_ID last_copper_layer = F_Cu;
612 
613  // Generate the list (top to bottom):
614  for( int ii = 0; ii < brd_stackup.GetCount(); ++ii )
615  {
616  BOARD_STACKUP_ITEM* item = brd_stackup.GetStackupLayer( ii );
617  double thickness = item->m_Thickness*m_conversionUnits; // layer thickness is always in mm
618  wxString layer_type;
619  std::string layer_name; // for comment
620 
621  switch( item->m_Type )
622  {
623  case BS_ITEM_TYPE_COPPER:
624  layer_type = "Copper";
625  layer_name = formatStringFromUTF32( m_pcb->GetLayerName( item->m_LayerId ) );
626  last_copper_layer = item->m_LayerId;
627  break;
628 
630  layer_type = "Legend";
631  layer_name = formatStringFromUTF32( item->m_TypeName );
632  break;
633 
635  layer_type = "SolderMask";
636  layer_name = formatStringFromUTF32( item->m_TypeName );
637  break;
638 
640  layer_type = "SolderPaste";
641  layer_name = formatStringFromUTF32( item->m_TypeName );
642  break;
643 
645  layer_type = "Dielectric";
646  layer_name = formatStringFromUTF32( wxString::Format( "dielectric layer %d (%s)",
647  item->m_DielectricLayerId, item->m_TypeName ) );
648  break;
649 
650  default:
651  break;
652  }
653 
654  openBlock();
655  addJSONObject( wxString::Format( "\"Type\": \"%s\",\n", layer_type ) );
656 
657  if( item->IsColorEditable() && uptodate )
658  {
659  if( !item->m_Color.IsEmpty() && item->m_Color != NOT_SPECIFIED )
660  addJSONObject( wxString::Format( "\"Color\": \"%s\",\n", item->m_Color ) );
661  }
662 
663  if( item->IsThicknessEditable() && uptodate )
664  addJSONObject( wxString::Format( "\"Thickness\": %.3f,\n", thickness ) );
665 
666  if( item->m_Type == BS_ITEM_TYPE_DIELECTRIC )
667  {
668  addJSONObject( wxString::Format( "\"Material\": \"%s\",\n", item->m_Material ) );
669 
670  // These constrains are only written if the board has impedance controlled tracks.
671  // If the board is not impedance controlled, they are useless.
672  // Do not add constrains that create more expensive boards.
673  if( brd_stackup.m_HasDielectricConstrains )
674  {
675  addJSONObject( wxString::Format( "\"DielectricConstant\": %.1f,\n", item->m_EpsilonR ) );
676  addJSONObject( wxString::Format( "\"LossTangent\": %f,\n", item->m_LossTangent ) );
677  }
678 
679  PCB_LAYER_ID next_copper_layer = (PCB_LAYER_ID) (last_copper_layer+1);
680 
681  // If the next_copper_layer is the last copper layer, the next layer id is B_Cu
682  if( next_copper_layer >= m_pcb->GetCopperLayerCount()-1 )
683  next_copper_layer = B_Cu;
684 
685  // Add a comment ("Notes"):
686  wxString note = "\"Notes\": ";
687 
688  if( uptodate ) // We can add the dielectric variant ("core" "prepreg" ...):
689  note << wxString::Format( " \"Type: %s", layer_name.c_str() );
690 
691  note << wxString::Format( " \"(from %s to %s)\"\n",
692  formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
693  formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ) );
694 
695  addJSONObject( note );
696  }
697  else
698  {
699  addJSONObject( wxString::Format( "\"Notes\": \"Layer: %s\",\n", layer_name.c_str() ) );
700  }
701 
704  }
705 
708 }
std::string formatStringFromUTF32(const wxString &aText)
A helper function to convert a wxString ( therefore a Unicode text ) to a JSON compatible string (a e...
a class to handle special data (items attributes) during plot.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:57
double m_EpsilonR
the physical layer thickness in internal units
BOARD_STACKUP_ITEM * GetStackupLayer(int aIndex)
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
bool CreateJobFile(const wxString &aFullFilename)
Creates a Gerber job file.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:175
this class manage the layers needed to make a physical board they are solder mask,...
void removeJSONSepararator()
Remove the comma if it is the last char in m_JSONbuffer, or the previous char if the last char is a ...
wxString m_FinishType
The name of external copper finish.
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:804
bool m_EdgePlating
True if the edge board is plated.
void addJSONHeader()
Add the job file header in JSON format to m_JSONbuffer.
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specifed in job file: BS_EDGE_CONNECTOR...
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:178
int GetWidth() const
Definition: eda_rect.h:117
const char * sideKeyValue(enum ONSIDE aValue)
bool m_CastellatedPads
True if castellated pads exist.
void addJSONObject(const wxString &aParam)
Add aParam to m_JSONbuffer, with suitable indentation.
int m_Thickness
mainly for silkscreen and solder mask
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
iterator end()
Definition: netclass.h:249
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
wxString m_Material
type name of layer (copper, silk screen, core, prepreg ...)
const wxString & GetFileName() const
Definition: class_board.h:225
Classes used to generate a Gerber job file in JSON.
void closeBlock()
close a JSON block: decrement indentation and add '}'
void addJSONFilesAttributes()
Add the Files Attributes section in JSON format to m_JSONbuffer.
NETCLASS_MAP::const_iterator const_iterator
Definition: netclass.h:251
bool SynchronizeWithBoard(BOARD_DESIGN_SETTINGS *aSettings)
Synchronize the BOARD_STACKUP_ITEM* list with the board.
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_zone.cpp:616
void openBlock()
open a JSON block: add '{' and increment indentation
Board plot function definition file.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
wxArrayString m_GerberFileList
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
BOARD_STACKUP & GetStackupDescriptor()
PCB_LAYER_ID
A quick note on layer IDs:
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:955
Class LSET is a set of PCB_LAYER_IDs.
iterator begin()
Definition: netclass.h:248
MODULES & Modules()
Definition: class_board.h:236
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
const wxString & GetRevision() const
Definition: title_block.h:89
wxString GbrMakeProjectGUIDfromString(wxString &aText)
A helper function to build a project GUID using format RFC4122 Version 1 or 4 from the project name,...
Class NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:55
PCB_LAYER_ID m_LayerId
For dielectric (and solder mask) the dielectric loss.
Definition of file extensions used in Kicad.
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:636
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:706
void openArrayBlock()
open a JSON array block: add '[' and increment indentation
void closeBlockWithSep()
close a JSON block: decrement indentation and add '}' and ','
this class manage one layer needed to make a physical board it can be a solder mask,...
#define _(s)
int GetHeight() const
Definition: eda_rect.h:118
bool WriteJSONJobFile(const wxString &aFullFilename)
Creates an Gerber job file in JSON format.
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:621
void closeArrayBlockWithSep()
close a JSON array block: decrement indentation and add ']' and ','
wxString m_Color
the "layer" id for dielectric layers, from 1 (top) to 32 (bottom)
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:561
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
const char * name
Definition: DXF_plotter.cpp:61
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
NETCLASSPTR GetDefault() const
Function GetDefault.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
int GetClearance() const
Definition: netclass.h:162
void addJSONDesignRules()
Add the Design Rules section in JSON format to m_JSONbuffer.
int GetCopperLayerCount() const
Function GetCopperLayerCount.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
std::vector< PCB_LAYER_ID > m_LayerId
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Module description (excepted pads)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:926
bool m_HasStackup
Set to true if the board has a stackup management.
void addJSONMaterialStackup()
Add the Material Stackup section in JSON format to m_JSONbuffer This is the ordered list of stackup l...
BOARD_STACKUP_ITEM_TYPE m_Type
#define NOT_SPECIFIED
void addJSONGeneralSpecs()
Add the General Specs in JSON format to m_JSONbuffer.
int m_DielectricLayerId
type of material (has meaning only for dielectric
TRACKS & Tracks()
Definition: class_board.h:227
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:184
GERBER_JOBFILE_WRITER(BOARD *aPcb, REPORTER *aReporter=nullptr)
#define min(a, b)
Definition: auxiliary.h:85
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.