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-2020 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 <fstream>
33 #include <iomanip>
34 #include <vector>
35 
36 #include <build_version.h>
37 #include <pcb_edit_frame.h>
38 #include <plotter.h>
39 
40 #include <class_board.h>
41 #include <class_module.h>
42 #include <class_track.h>
43 #include <class_zone.h>
44 
46 #include <gbr_metadata.h>
47 #include <gerber_jobfile_writer.h>
48 #include <pcbnew.h>
49 #include <pcbplot.h>
50 #include <reporter.h>
52 
54 {
55  m_pcb = aPcb;
56  m_reporter = aReporter;
57  m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
58 }
59 
60 std::string GERBER_JOBFILE_WRITER::formatStringFromUTF32( const wxString& aText )
61 {
62  std::string fmt_text; // the text after UTF32 to UTF8 conversion
63 
64  for( unsigned long letter : aText )
65  {
66  if( letter >= ' ' && letter <= 0x7F )
67  fmt_text += char( letter );
68  else
69  {
70  char buff[16];
71  sprintf( buff, "\\u%4.4lX", letter );
72  fmt_text += buff;
73  }
74  }
75  return fmt_text;
76 }
77 
78 
80 {
81  int flag = SIDE_NONE;
82 
83  for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
84  {
85  if( m_params.m_LayerId[ii] == B_SilkS )
86  flag |= SIDE_BOTTOM;
87 
88  if( m_params.m_LayerId[ii] == F_SilkS )
89  flag |= SIDE_TOP;
90  }
91 
92  return (enum ONSIDE) flag;
93 }
94 
95 
97 {
98  int flag = SIDE_NONE;
99 
100  for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
101  {
102  if( m_params.m_LayerId[ii] == B_Mask )
103  flag |= SIDE_BOTTOM;
104 
105  if( m_params.m_LayerId[ii] == F_Mask )
106  flag |= SIDE_TOP;
107  }
108 
109  return (enum ONSIDE) flag;
110 }
111 
112 const char* GERBER_JOBFILE_WRITER::sideKeyValue( enum ONSIDE aValue )
113 {
114  // return the key associated to sides used for some layers
115  // "No, TopOnly, BotOnly or Both"
116  const char* value = nullptr;
117 
118  switch( aValue )
119  {
120  case SIDE_NONE:
121  value = "No";
122  break;
123 
124  case SIDE_TOP:
125  value = "TopOnly";
126  break;
127 
128  case SIDE_BOTTOM:
129  value = "BotOnly";
130  break;
131 
132  case SIDE_BOTH:
133  value = "Both";
134  break;
135  }
136 
137  return value;
138 }
139 
140 
141 bool GERBER_JOBFILE_WRITER::CreateJobFile( const wxString& aFullFilename )
142 {
143  bool success;
144  wxString msg;
145 
146  success = WriteJSONJobFile( aFullFilename );
147 
148  if( !success )
149  {
150  if( m_reporter )
151  {
152  msg.Printf( _( "Unable to create job file \"%s\"" ), aFullFilename );
154  }
155  }
156  else if( m_reporter )
157  {
158  msg.Printf( _( "Create Gerber job file \"%s\"" ), aFullFilename );
160  }
161 
162  return success;
163 }
164 
165 
167 {
168  wxString text;
169 
170  m_json["Header"] = {
171  {
172  "GenerationSoftware",
173  {
174  { "Vendor", "KiCad" },
175  { "Application", "Pcbnew" },
176  { "Version", GetBuildVersion() }
177  }
178  },
179  {
180  // The attribute value must conform to the full version of the ISO 8601
181  // date and time format, including time and time zone.
183  }
184  };
185 }
186 
187 
188 bool GERBER_JOBFILE_WRITER::WriteJSONJobFile( const wxString& aFullFilename )
189 {
190  // Note: in Gerber job file, dimensions are in mm, and are floating numbers
191  std::ofstream file( aFullFilename.ToUTF8() );
192 
194 
195  m_json = json( {} );
196 
197  // output the job file header
198  addJSONHeader();
199 
200  // Add the General Specs
202 
203  // Job file support a few design rules:
205 
206  // output the gerber file list:
208 
209  // output the board stackup:
211 
212  file << std::setw( 2 ) << m_json << std::endl;
213 
214  return true;
215 }
216 
217 
219 {
220  m_json["GeneralSpecs"] = json( {} );
221  m_json["GeneralSpecs"]["ProjectId"] = json( {} );
222 
223  // Creates the ProjectId. Format is (from Gerber file format doc):
224  // ProjectId,<project id>,<project GUID>,<revision id>*%
225  // <project id> is the name of the project, restricted to basic ASCII symbols only,
226  // and comma not accepted
227  // All illegal chars will be replaced by underscore
228  // Rem: <project id> accepts only ASCII 7 code (only basic ASCII codes are allowed in gerber files).
229  //
230  // <project GUID> is a string which is an unique id of a project.
231  // However Kicad does not handle such a project GUID, so it is built from the board name
232  wxFileName fn = m_pcb->GetFileName();
233  wxString msg = fn.GetFullName();
234 
235  // Build a <project GUID>, from the board name
236  wxString guid = GbrMakeProjectGUIDfromString( msg );
237 
238  // build the <project id> string: this is the board short filename (without ext)
239  // and all non ASCII chars are replaced by '_', to be compatible with .gbr files.
240  msg = fn.GetName();
241 
242  // build the <rec> string. All non ASCII chars and comma are replaced by '_'
243  wxString rev = m_pcb->GetTitleBlock().GetRevision();
244 
245  if( rev.IsEmpty() )
246  rev = wxT( "rev?" );
247 
248  m_json["GeneralSpecs"]["ProjectId"]["Name"] = msg.ToAscii();
249  m_json["GeneralSpecs"]["ProjectId"]["GUID"] = guid;
250  m_json["GeneralSpecs"]["ProjectId"]["Revision"] = rev.ToAscii();
251 
252  // output the bord size in mm:
254 
255  m_json["GeneralSpecs"]["Size"]["X"] = brect.GetWidth() * m_conversionUnits;
256  m_json["GeneralSpecs"]["Size"]["Y"] = brect.GetHeight() * m_conversionUnits;
257 
258 
259  // Add some data to the JSON header, GeneralSpecs:
260  // number of copper layers
261  m_json["GeneralSpecs"]["LayerNumber"] = m_pcb->GetCopperLayerCount();
262 
263  // Board thickness
264  m_json["GeneralSpecs"]["BoardThickness"] =
266 
267  // Copper finish
269 
270  if( !brd_stackup.m_FinishType.IsEmpty() )
271  m_json["GeneralSpecs"]["Finish"] = brd_stackup.m_FinishType;
272 
273  if( brd_stackup.m_CastellatedPads )
274  m_json["GeneralSpecs"]["Castellated"] = true;
275 
276  if( brd_stackup.m_EdgePlating )
277  m_json["GeneralSpecs"]["EdgePlating"] = true;
278 
279  if( brd_stackup.m_EdgeConnectorConstraints )
280  {
281  m_json["GeneralSpecs"]["EdgeConnector"] = true;
282 
283  m_json["GeneralSpecs"]["EdgeConnectorBevelled"] =
285  }
286 
287 #if 0 // Not yet in use
288  /* The board type according to IPC-2221. There are six primary board types:
289  - Type 1 - Single-sided
290  - Type 2 - Double-sided
291  - Type 3 - Multilayer, TH components only
292  - Type 4 - Multilayer, with TH, blind and/or buried vias.
293  - Type 5 - Multilayer metal-core board, TH components only
294  - Type 6 - Multilayer metal-core
295  */
296  m_json["GeneralSpecs"]["IPC-2221-Type"] = 4;
297 
298  /* Via protection: key words:
299  Ia Tented - Single-sided
300  Ib Tented - Double-sided
301  IIa Tented and Covered - Single-sided
302  IIb Tented and Covered - Double-sided
303  IIIa Plugged - Single-sided
304  IIIb Plugged - Double-sided
305  IVa Plugged and Covered - Single-sided
306  IVb Plugged and Covered - Double-sided
307  V Filled (fully plugged)
308  VI Filled and Covered
309  VIII Filled and Capped
310  None...No protection
311  */
312  m_json["GeneralSpecs"]["ViaProtection"] = "Ib";
313 #endif
314 }
315 
316 
318 {
319  // Add the Files Attributes section in JSON format to m_JSONbuffer
320  m_json["FilesAttributes"] = json::array();
321 
322  for( unsigned ii = 0; ii < m_params.m_GerberFileList.GetCount(); ii++ )
323  {
324  wxString& name = m_params.m_GerberFileList[ii];
325  PCB_LAYER_ID layer = m_params.m_LayerId[ii];
326  wxString gbr_layer_id;
327  bool skip_file = false; // true to skip files which should not be in job file
328  const char* polarity = "Positive";
329  json file_json;
330 
331  if( layer <= B_Cu )
332  {
333  gbr_layer_id = "Copper,L";
334 
335  if( layer == B_Cu )
336  gbr_layer_id << m_pcb->GetCopperLayerCount();
337  else
338  gbr_layer_id << layer + 1;
339 
340  gbr_layer_id << ",";
341 
342  if( layer == B_Cu )
343  gbr_layer_id << "Bot";
344  else if( layer == F_Cu )
345  gbr_layer_id << "Top";
346  else
347  gbr_layer_id << "Inr";
348  }
349 
350  else
351  {
352  switch( layer )
353  {
354  case B_Adhes:
355  gbr_layer_id = "Glue,Bot";
356  break;
357  case F_Adhes:
358  gbr_layer_id = "Glue,Top";
359  break;
360 
361  case B_Paste:
362  gbr_layer_id = "SolderPaste,Bot";
363  break;
364  case F_Paste:
365  gbr_layer_id = "SolderPaste,Top";
366  break;
367 
368  case B_SilkS:
369  gbr_layer_id = "Legend,Bot";
370  break;
371  case F_SilkS:
372  gbr_layer_id = "Legend,Top";
373  break;
374 
375  case B_Mask:
376  gbr_layer_id = "SolderMask,Bot";
377  polarity = "Negative";
378  break;
379  case F_Mask:
380  gbr_layer_id = "SolderMask,Top";
381  polarity = "Negative";
382  break;
383 
384  case Edge_Cuts:
385  gbr_layer_id = "Profile";
386  break;
387 
388  case B_Fab:
389  gbr_layer_id = "AssemblyDrawing,Bot";
390  break;
391  case F_Fab:
392  gbr_layer_id = "AssemblyDrawing,Top";
393  break;
394 
395  case Dwgs_User:
396  case Cmts_User:
397  case Eco1_User:
398  case Eco2_User:
399  case Margin:
400  case B_CrtYd:
401  case F_CrtYd:
402  skip_file = true;
403  break;
404 
405  default:
406  skip_file = true;
407  m_reporter->Report( "Unexpected layer id in job file", RPT_SEVERITY_ERROR );
408  break;
409  }
410  }
411 
412  if( !skip_file )
413  {
414  // name can contain non ASCII7 chars.
415  // Ensure the name is JSON compatible.
416  std::string strname = formatStringFromUTF32( name );
417 
418  file_json["Path"] = strname.c_str();
419  file_json["FileFunction"] = gbr_layer_id;
420  file_json["FilePolarity"] = polarity;
421 
422  m_json["FilesAttributes"] += file_json;
423  }
424  }
425 }
426 
427 
429 {
430  // Add the Design Rules section in JSON format to m_JSONbuffer
431  // Job file support a few design rules:
432  const BOARD_DESIGN_SETTINGS& dsnSettings = m_pcb->GetDesignSettings();
433  NETCLASS defaultNC = *dsnSettings.GetDefault();
434  int minclearanceOuter = defaultNC.GetClearance();
435  bool hasInnerLayers = m_pcb->GetCopperLayerCount() > 2;
436 
437  // Search a smaller clearance in other net classes, if any.
438  for( NETCLASSES::const_iterator it = dsnSettings.m_NetClasses.begin();
439  it != dsnSettings.m_NetClasses.end(); ++it )
440  {
441  NETCLASS netclass = *it->second;
442  minclearanceOuter = std::min( minclearanceOuter, netclass.GetClearance() );
443  }
444 
445  // job file knows different clearance types.
446  // Kicad knows only one clearance for pads and tracks
447  int minclearance_track2track = minclearanceOuter;
448 
449  // However, pads can have a specific clearance defined for a pad or a footprint,
450  // and min clearance can be dependent on layers.
451  // Search for a minimal pad clearance:
452  int minPadClearanceOuter = defaultNC.GetClearance();
453  int minPadClearanceInner = defaultNC.GetClearance();
454 
455  for( MODULE* module : m_pcb->Modules() )
456  {
457  for( auto& pad : module->Pads() )
458  {
459  if( ( pad->GetLayerSet() & LSET::InternalCuMask() ).any() )
460  minPadClearanceInner = std::min( minPadClearanceInner, pad->GetClearance() );
461 
462  if( ( pad->GetLayerSet() & LSET::ExternalCuMask() ).any() )
463  minPadClearanceOuter = std::min( minPadClearanceOuter, pad->GetClearance() );
464  }
465  }
466 
467  m_json["DesignRules"] = { {
468  { "Layers", "Outer" },
469  { "PadToPad", minPadClearanceOuter * m_conversionUnits },
470  { "PadToTrack", minPadClearanceOuter * m_conversionUnits },
471  { "TrackToTrack", minclearance_track2track * m_conversionUnits }
472  } };
473 
474  // Until this is changed in Kicad, use the same value for internal tracks
475  int minclearanceInner = minclearanceOuter;
476 
477  // Output the minimal track width
478  int mintrackWidthOuter = INT_MAX;
479  int mintrackWidthInner = INT_MAX;
480 
481  for( TRACK* track : m_pcb->Tracks() )
482  {
483  if( track->Type() == PCB_VIA_T )
484  continue;
485 
486  if( track->GetLayer() == B_Cu || track->GetLayer() == F_Cu )
487  mintrackWidthOuter = std::min( mintrackWidthOuter, track->GetWidth() );
488  else
489  mintrackWidthInner = std::min( mintrackWidthInner, track->GetWidth() );
490  }
491 
492  if( mintrackWidthOuter != INT_MAX )
493  m_json["DesignRules"][0]["MinLineWidth"] = mintrackWidthOuter * m_conversionUnits;
494 
495  // Output the minimal zone to xx clearance
496  // Note: zones can have a zone clearance set to 0
497  // if happens, the actual zone clearance is the clearance of its class
498  minclearanceOuter = INT_MAX;
499  minclearanceInner = INT_MAX;
500 
501  for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
502  {
503  ZONE_CONTAINER* zone = m_pcb->GetArea( ii );
504 
505  if( zone->GetIsKeepout() || !zone->IsOnCopperLayer() )
506  continue;
507 
508  int zclerance = zone->GetClearance();
509 
510  if( zone->GetLayer() == B_Cu || zone->GetLayer() == F_Cu )
511  minclearanceOuter = std::min( minclearanceOuter, zclerance );
512  else
513  minclearanceInner = std::min( minclearanceInner, zclerance );
514  }
515 
516  if( minclearanceOuter != INT_MAX )
517  m_json["DesignRules"][0]["TrackToRegion"] = minclearanceOuter * m_conversionUnits;
518 
519  if( minclearanceOuter != INT_MAX )
520  m_json["DesignRules"][0]["RegionToRegion"] = minclearanceOuter * m_conversionUnits;
521 
522  if( hasInnerLayers )
523  {
524  m_json["DesignRules"] += json( {
525  { "Layers", "Inner" },
526  { "PadToPad", minPadClearanceInner * m_conversionUnits },
527  { "PadToTrack", minPadClearanceInner * m_conversionUnits },
528  { "TrackToTrack", minclearance_track2track * m_conversionUnits }
529  } );
530 
531  if( mintrackWidthInner != INT_MAX )
532  m_json["DesignRules"][1]["MinLineWidth"] = mintrackWidthInner * m_conversionUnits;
533 
534  if( minclearanceInner != INT_MAX )
535  m_json["DesignRules"][1]["TrackToRegion"] = minclearanceInner * m_conversionUnits;
536 
537  if( minclearanceInner != INT_MAX )
538  m_json["DesignRules"][1]["RegionToRegion"] = minclearanceInner * m_conversionUnits;
539  }
540 }
541 
542 
544 {
545  // Add the Material Stackup section in JSON format to m_JSONbuffer
546  m_json["MaterialStackup"] = json::array();
547 
548  // Build the candidates list:
549  LSET maskLayer;
551 
552  // Ensure brd_stackup is up to date (i.e. no change made by SynchronizeWithBoard() )
553  bool uptodate = not brd_stackup.SynchronizeWithBoard( &m_pcb->GetDesignSettings() );
554 
555  if( !uptodate && m_pcb->GetDesignSettings().m_HasStackup )
556  m_reporter->Report( _( "Board stackup settings not up to date\n"
557  "Please fix the stackup" ),
559 
560  PCB_LAYER_ID last_copper_layer = F_Cu;
561 
562  // Generate the list (top to bottom):
563  for( int ii = 0; ii < brd_stackup.GetCount(); ++ii )
564  {
565  BOARD_STACKUP_ITEM* item = brd_stackup.GetStackupLayer( ii );
566 
567  int sub_layer_count =
568  item->GetType() == BS_ITEM_TYPE_DIELECTRIC ? item->GetSublayersCount() : 1;
569 
570  for( int sub_idx = 0; sub_idx < sub_layer_count; sub_idx++ )
571  {
572  // layer thickness is always in mm
573  double thickness = item->GetThickness( sub_idx ) * m_conversionUnits;
574  wxString layer_type;
575  std::string layer_name; // for comment
576  json layer_json;
577 
578  switch( item->GetType() )
579  {
580  case BS_ITEM_TYPE_COPPER:
581  layer_type = "Copper";
582  layer_name = formatStringFromUTF32( m_pcb->GetLayerName( item->GetBrdLayerId() ) );
583  last_copper_layer = item->GetBrdLayerId();
584  break;
585 
587  layer_type = "Legend";
588  layer_name = formatStringFromUTF32( item->GetTypeName() );
589  break;
590 
592  layer_type = "SolderMask";
593  layer_name = formatStringFromUTF32( item->GetTypeName() );
594  break;
595 
597  layer_type = "SolderPaste";
598  layer_name = formatStringFromUTF32( item->GetTypeName() );
599  break;
600 
602  layer_type = "Dielectric";
603  // The option core or prepreg is not added here, as it creates constraints
604  // in build process, not necessary wanted.
605  if( sub_layer_count > 1 )
606  {
607  layer_name =
608  formatStringFromUTF32( wxString::Format( "dielectric layer %d - %d/%d",
609  item->GetDielectricLayerId(), sub_idx + 1, sub_layer_count ) );
610  }
611  else
613  "dielectric layer %d", item->GetDielectricLayerId() ) );
614  break;
615 
616  default:
617  break;
618  }
619 
620  layer_json["Type"] = layer_type;
621 
622  if( item->IsColorEditable() && uptodate )
623  {
624  if( IsPrmSpecified( item->GetColor() ) )
625  {
626  wxString colorName = item->GetColor();
627 
628  if( colorName.StartsWith( "#" ) ) // This is a user defined color.
629  {
630  // In job file a color can be given by its RGB values (0...255)
631  wxColor color( colorName );
632  colorName.Printf( "R%dG%dB%d", color.Red(), color.Green(), color.Blue() );
633  }
634 
635  layer_json["Color"] = colorName;
636  }
637  }
638 
639  if( item->IsThicknessEditable() && uptodate )
640  layer_json["Thickness"] = thickness;
641 
642  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
643  {
644  if( item->HasMaterialValue() )
645  {
646  layer_json["Material"] = item->GetMaterial( sub_idx );
647 
648  // These constrains are only written if the board has impedance controlled tracks.
649  // If the board is not impedance controlled, they are useless.
650  // Do not add constrains that create more expensive boards.
651  if( brd_stackup.m_HasDielectricConstrains )
652  {
653  // Generate Epsilon R if > 1.0 (value <= 1.0 means not specified: it is not
654  // a possible value
655  if( item->GetEpsilonR() > 1.0 )
656  layer_json["DielectricConstant"] = item->FormatEpsilonR( sub_idx );
657 
658  // Generate LossTangent > 0.0 (value <= 0.0 means not specified: it is not
659  // a possible value
660  if( item->GetLossTangent() > 0.0 )
661  layer_json["LossTangent"] = item->FormatLossTangent( sub_idx );
662  }
663  }
664 
665  PCB_LAYER_ID next_copper_layer = ( PCB_LAYER_ID )( last_copper_layer + 1 );
666 
667  // If the next_copper_layer is the last copper layer, the next layer id is B_Cu
668  if( next_copper_layer >= m_pcb->GetCopperLayerCount() - 1 )
669  next_copper_layer = B_Cu;
670 
671  wxString subLayerName;
672 
673  if( sub_layer_count > 1 )
674  subLayerName.Printf( " (%d/%d)", sub_idx + 1, sub_layer_count );
675 
676  wxString name = wxString::Format( "%s/%s%s",
677  formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
678  formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ),
679  subLayerName );
680 
681  layer_json["Name"] = name;
682 
683  // Add a comment ("Notes"):
684  wxString note;
685 
686  note << wxString::Format( "Type: %s", layer_name.c_str() );
687 
688  note << wxString::Format( " (from %s to %s)",
689  formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
690  formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ) );
691 
692  layer_json["Notes"] = note;
693  }
694  else if( item->GetType() == BS_ITEM_TYPE_SOLDERMASK
695  || item->GetType() == BS_ITEM_TYPE_SILKSCREEN )
696  {
697  if( item->HasMaterialValue() )
698  {
699  layer_json["Material"] = item->GetMaterial();
700 
701  // These constrains are only written if the board has impedance controlled tracks.
702  // If the board is not impedance controlled, they are useless.
703  // Do not add constrains that create more expensive boards.
704  if( brd_stackup.m_HasDielectricConstrains )
705  {
706  // Generate Epsilon R if > 1.0 (value <= 1.0 means not specified: it is not
707  // a possible value
708  if( item->GetEpsilonR() > 1.0 )
709  layer_json["DielectricConstant"] = item->FormatEpsilonR();
710 
711  // Generate LossTangent > 0.0 (value <= 0.0 means not specified: it is not
712  // a possible value
713  if( item->GetLossTangent() > 0.0 )
714  layer_json["LossTangent"] = item->FormatLossTangent();
715  }
716  }
717 
718  layer_json["Name"] = layer_name.c_str();
719  }
720  else
721  {
722  layer_json["Name"] = layer_name.c_str();
723  }
724 
725  m_json["MaterialStackup"].insert( m_json["MaterialStackup"].end(), layer_json );
726  }
727  }
728 }
BOARD_STACKUP_ITEM_TYPE GetType() const
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.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
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 HasMaterialValue(int aDielectricSubLayer=0) const
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:202
this class manage the layers needed to make a physical board they are solder mask,...
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:767
bool m_EdgePlating
True if the edge board is plated.
void addJSONHeader()
Add the job file header in JSON format to m_JSONbuffer.
bool IsPrmSpecified(const wxString &aPrmValue)
int color
Definition: DXF_plotter.cpp:61
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:213
int GetWidth() const
Definition: eda_rect.h:119
const char * sideKeyValue(enum ONSIDE aValue)
bool m_CastellatedPads
True if castellated pads exist.
wxString GetColor() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
iterator end()
Definition: netclass.h:249
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:62
nlohmann::json json
Definition: gerbview.cpp:40
const wxString & GetFileName() const
Definition: class_board.h:218
Classes used to generate a Gerber job file in JSON.
void addJSONFilesAttributes()
Add the Files Attributes section in JSON format to m_JSONbuffer.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
double GetLossTangent(int aDielectricSubLayer=0) const
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:659
Definitions for tracks, vias and zones.
Board plot function definition file.
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:
bool IsThicknessEditable() const
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:919
LSET is a set of PCB_LAYER_IDs.
iterator begin()
Definition: netclass.h:248
MODULES & Modules()
Definition: class_board.h:229
wxString GetBuildVersion()
Get the full KiCad 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,...
int GetThickness(int aDielectricSubLayer=0) const
NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:55
double GetEpsilonR(int aDielectricSubLayer=0) const
wxString FormatEpsilonR(int aDielectricSubLayer=0) const
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:646
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:716
wxString GetTypeName() const
wxString FormatLossTangent(int aDielectricSubLayer=0) const
this class manage one layer needed to make a physical board it can be a solder mask,...
int GetHeight() const
Definition: eda_rect.h:120
bool WriteJSONJobFile(const wxString &aFullFilename)
Creates an Gerber job file in JSON format.
PCB_LAYER_ID GetBrdLayerId() const
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:649
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:533
const char * name
Definition: DXF_plotter.cpp:60
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.
int GetDielectricLayerId() const
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
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.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
std::vector< PCB_LAYER_ID > m_LayerId
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
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:884
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...
wxString GetMaterial(int aDielectricSubLayer=0) const
void addJSONGeneralSpecs()
Add the General Specs in JSON format to m_JSONbuffer.
TRACKS & Tracks()
Definition: class_board.h:220
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:219
GERBER_JOBFILE_WRITER(BOARD *aPcb, REPORTER *aReporter=nullptr)
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.