KiCad PCB EDA Suite
kicad_plugin.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) 2012 CERN
5  * Copyright (C) 1992-2018 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 
25 #include <fctsys.h>
26 #include <kicad_string.h>
27 #include <common.h>
28 #include <build_version.h> // LEGACY_BOARD_FILE_VERSION
29 #include <macros.h>
31 #include <base_units.h>
32 #include <trace_helpers.h>
33 
34 #include <class_board.h>
35 #include <class_module.h>
36 #include <class_pcb_text.h>
37 #include <class_dimension.h>
38 #include <class_track.h>
39 #include <class_zone.h>
40 #include <class_drawsegment.h>
41 #include <class_pcb_target.h>
42 #include <class_edge_mod.h>
43 #include <pcb_plot_params.h>
44 #include <zones.h>
45 #include <kicad_plugin.h>
46 #include <pcb_parser.h>
47 
48 #include <wx/dir.h>
49 #include <wx/filename.h>
50 #include <wx/wfstream.h>
51 #include <boost/ptr_container/ptr_map.hpp>
52 #include <memory.h>
54 #include <convert_basic_shapes_to_polygon.h> // for enum RECT_CHAMFER_POSITIONS definition
55 
56 using namespace PCB_KEYS_T;
57 
58 
60 void filterNetClass( const BOARD& aBoard, NETCLASS& aNetClass )
61 {
62  auto connectivity = aBoard.GetConnectivity();
63 
64  for( NETCLASS::iterator it = aNetClass.begin(); it != aNetClass.end(); )
65  {
66  NETINFO_ITEM* netinfo = aBoard.FindNet( *it );
67 
68  if( netinfo && connectivity->GetNodeCount( netinfo->GetNet() ) <= 0 ) // hopefully there are no nets with negative
69  aNetClass.Remove( it++ ); // node count, but you never know..
70  else
71  ++it;
72  }
73 }
74 
85 {
87  std::unique_ptr<MODULE> m_module;
88 
89 public:
90  FP_CACHE_ITEM( MODULE* aModule, const WX_FILENAME& aFileName );
91 
92  const WX_FILENAME& GetFileName() const { return m_filename; }
93  const MODULE* GetModule() const { return m_module.get(); }
94 };
95 
96 
97 FP_CACHE_ITEM::FP_CACHE_ITEM( MODULE* aModule, const WX_FILENAME& aFileName ) :
98  m_filename( aFileName ),
99  m_module( aModule )
100 { }
101 
102 
103 typedef boost::ptr_map< wxString, FP_CACHE_ITEM > MODULE_MAP;
104 typedef MODULE_MAP::iterator MODULE_ITER;
105 typedef MODULE_MAP::const_iterator MODULE_CITER;
106 
107 
108 class FP_CACHE
109 {
110  PCB_IO* m_owner; // Plugin object that owns the cache.
111  wxFileName m_lib_path; // The path of the library.
112  wxString m_lib_raw_path; // For quick comparisons.
113  MODULE_MAP m_modules; // Map of footprint file name per MODULE*.
114 
115  bool m_cache_dirty; // Stored separately because it's expensive to check
116  // m_cache_timestamp against all the files.
117  long long m_cache_timestamp; // A hash of the timestamps for all the footprint
118  // files.
119 
120 public:
121  FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath );
122 
123  wxString GetPath() const { return m_lib_raw_path; }
124  bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
125  bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
127 
128  // Most all functions in this class throw IO_ERROR exceptions. There are no
129  // error codes nor user interface calls from here, nor in any PLUGIN.
130  // Catch these exceptions higher up please.
131 
138  void Save( MODULE* aModule = NULL );
139 
140  void Load();
141 
142  void Remove( const wxString& aFootprintName );
143 
150  static long long GetTimestamp( const wxString& aLibPath );
151 
156  bool IsModified();
157 
170  bool IsPath( const wxString& aPath ) const;
171 };
172 
173 
174 FP_CACHE::FP_CACHE( PCB_IO* aOwner, const wxString& aLibraryPath )
175 {
176  m_owner = aOwner;
177  m_lib_raw_path = aLibraryPath;
178  m_lib_path.SetPath( aLibraryPath );
179  m_cache_timestamp = 0;
180  m_cache_dirty = true;
181 }
182 
183 
184 void FP_CACHE::Save( MODULE* aModule )
185 {
186  m_cache_timestamp = 0;
187 
188  if( !m_lib_path.DirExists() && !m_lib_path.Mkdir() )
189  {
190  THROW_IO_ERROR( wxString::Format( _( "Cannot create footprint library path \"%s\"" ),
191  m_lib_raw_path ) );
192  }
193 
194  if( !m_lib_path.IsDirWritable() )
195  {
196  THROW_IO_ERROR( wxString::Format( _( "Footprint library path \"%s\" is read only" ),
197  m_lib_raw_path ) );
198  }
199 
200  for( MODULE_ITER it = m_modules.begin(); it != m_modules.end(); ++it )
201  {
202  if( aModule && aModule != it->second->GetModule() )
203  continue;
204 
205  WX_FILENAME fn = it->second->GetFileName();
206 
207  wxString tempFileName =
208 #ifdef USE_TMP_FILE
209  wxFileName::CreateTempFileName( fn.GetPath() );
210 #else
211  fn.GetFullPath();
212 #endif
213  // Allow file output stream to go out of scope to close the file stream before
214  // renaming the file.
215  {
216  wxLogTrace( traceKicadPcbPlugin, wxT( "Creating temporary library file %s" ),
217  GetChars( tempFileName ) );
218 
219  FILE_OUTPUTFORMATTER formatter( tempFileName );
220 
221  m_owner->SetOutputFormatter( &formatter );
222  m_owner->Format( (BOARD_ITEM*) it->second->GetModule() );
223  }
224 
225 #ifdef USE_TMP_FILE
226  wxRemove( fn.GetFullPath() ); // it is not an error if this does not exist
227 
228  // Even on linux you can see an _intermittent_ error when calling wxRename(),
229  // and it is fully inexplicable. See if this dodges the error.
230  wxMilliSleep( 250L );
231 
232  if( !wxRenameFile( tempFileName, fn.GetFullPath() ) )
233  {
234  wxString msg = wxString::Format(
235  _( "Cannot rename temporary file \"%s\" to footprint library file \"%s\"" ),
236  GetChars( tempFileName ),
237  GetChars( fn.GetFullPath() )
238  );
239  THROW_IO_ERROR( msg );
240  }
241 #endif
243  }
244 
245  m_cache_timestamp += m_lib_path.GetModificationTime().GetValue().GetValue();
246 
247  // If we've saved the full cache, we clear the dirty flag.
248  if( !aModule )
249  m_cache_dirty = false;
250 }
251 
252 
254 {
255  m_cache_dirty = false;
256  m_cache_timestamp = 0;
257 
258  wxDir dir( m_lib_raw_path );
259 
260  if( !dir.IsOpened() )
261  {
262  wxString msg = wxString::Format( _( "Footprint library path \"%s\" does not exist" ),
263  m_lib_raw_path );
264  THROW_IO_ERROR( msg );
265  }
266 
267  wxString fullName;
268  wxString fileSpec = wxT( "*." ) + KiCadFootprintFileExtension;
269 
270  // wxFileName construction is egregiously slow. Construct it once and just swap out
271  // the filename thereafter.
272  WX_FILENAME fn( m_lib_raw_path, wxT( "dummyName" ) );
273 
274  if( dir.GetFirst( &fullName, fileSpec ) )
275  {
276  wxString cacheError;
277 
278  do
279  {
280  fn.SetFullName( fullName );
281 
282  // Queue I/O errors so only files that fail to parse don't get loaded.
283  try
284  {
285  FILE_LINE_READER reader( fn.GetFullPath() );
286 
287  m_owner->m_parser->SetLineReader( &reader );
288 
289  MODULE* footprint = (MODULE*) m_owner->m_parser->Parse();
290  wxString fpName = fn.GetName();
291 
292  footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
293  m_modules.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
294 
296  }
297  catch( const IO_ERROR& ioe )
298  {
299  if( !cacheError.IsEmpty() )
300  cacheError += "\n\n";
301 
302  cacheError += ioe.What();
303  }
304  } while( dir.GetNext( &fullName ) );
305 
306  if( !cacheError.IsEmpty() )
307  THROW_IO_ERROR( cacheError );
308  }
309 }
310 
311 
312 void FP_CACHE::Remove( const wxString& aFootprintName )
313 {
314  MODULE_CITER it = m_modules.find( aFootprintName );
315 
316  if( it == m_modules.end() )
317  {
318  wxString msg = wxString::Format( _( "library \"%s\" has no footprint \"%s\" to delete" ),
320  aFootprintName );
321  THROW_IO_ERROR( msg );
322  }
323 
324  // Remove the module from the cache and delete the module file from the library.
325  wxString fullPath = it->second->GetFileName().GetFullPath();
326  m_modules.erase( aFootprintName );
327  wxRemoveFile( fullPath );
328 }
329 
330 
331 bool FP_CACHE::IsPath( const wxString& aPath ) const
332 {
333  return aPath == m_lib_raw_path;
334 }
335 
336 
338 {
340 
341  return m_cache_dirty;
342 }
343 
344 
345 long long FP_CACHE::GetTimestamp( const wxString& aLibPath )
346 {
347  wxString fileSpec = wxT( "*." ) + KiCadFootprintFileExtension;
348 
349  return TimestampDir( aLibPath, fileSpec );
350 }
351 
352 
353 void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
354 {
355  LOCALE_IO toggle; // toggles on, then off, the C locale.
356 
357  init( aProperties );
358 
359  m_board = aBoard; // after init()
360 
361  // Prepare net mapping that assures that net codes saved in a file are consecutive integers
362  m_mapping->SetBoard( aBoard );
363 
364  FILE_OUTPUTFORMATTER formatter( aFileName );
365 
366  m_out = &formatter; // no ownership
367 
368  m_out->Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n", SEXPR_BOARD_FILE_VERSION,
369  formatter.Quotew( GetBuildVersion() ).c_str() );
370 
371  Format( aBoard, 1 );
372 
373  m_out->Print( 0, ")\n" );
374 }
375 
376 
377 BOARD_ITEM* PCB_IO::Parse( const wxString& aClipboardSourceInput )
378 {
379  std::string input = TO_UTF8( aClipboardSourceInput );
380 
381  STRING_LINE_READER reader( input, wxT( "clipboard" ) );
382 
383  m_parser->SetLineReader( &reader );
384 
385  try
386  {
387  return m_parser->Parse();
388  }
389  catch( const PARSE_ERROR& parse_error )
390  {
391  if( m_parser->IsTooRecent() )
392  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
393  else
394  throw;
395  }
396 }
397 
398 
399 void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const
400 {
401  LOCALE_IO toggle; // public API function, perform anything convenient for caller
402 
403  switch( aItem->Type() )
404  {
405  case PCB_T:
406  format( static_cast<BOARD*>( aItem ), aNestLevel );
407  break;
408 
409  case PCB_DIMENSION_T:
410  format( static_cast<DIMENSION*>( aItem ), aNestLevel );
411  break;
412 
413  case PCB_LINE_T:
414  format( static_cast<DRAWSEGMENT*>( aItem ), aNestLevel );
415  break;
416 
417  case PCB_MODULE_EDGE_T:
418  format( static_cast<EDGE_MODULE*>( aItem ), aNestLevel );
419  break;
420 
421  case PCB_TARGET_T:
422  format( static_cast<PCB_TARGET*>( aItem ), aNestLevel );
423  break;
424 
425  case PCB_MODULE_T:
426  format( static_cast<MODULE*>( aItem ), aNestLevel );
427  break;
428 
429  case PCB_PAD_T:
430  format( static_cast<D_PAD*>( aItem ), aNestLevel );
431  break;
432 
433  case PCB_TEXT_T:
434  format( static_cast<TEXTE_PCB*>( aItem ), aNestLevel );
435  break;
436 
437  case PCB_MODULE_TEXT_T:
438  format( static_cast<TEXTE_MODULE*>( aItem ), aNestLevel );
439  break;
440 
441  case PCB_TRACE_T:
442  case PCB_VIA_T:
443  format( static_cast<TRACK*>( aItem ), aNestLevel );
444  break;
445 
446  case PCB_ZONE_AREA_T:
447  format( static_cast<ZONE_CONTAINER*>( aItem ), aNestLevel );
448  break;
449 
450  default:
451  wxFAIL_MSG( wxT( "Cannot format item " ) + aItem->GetClass() );
452  }
453 }
454 
455 
456 void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
457 {
458  if( m_ctl & CTL_STD_LAYER_NAMES )
459  {
460  PCB_LAYER_ID layer = aItem->GetLayer();
461 
462  // English layer names should never need quoting.
463  m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
464  }
465  else
466  m_out->Print( 0, " (layer %s)", m_out->Quotew( aItem->GetLayerName() ).c_str() );
467 }
468 
469 void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const
470 {
471  const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
472 
473  // Setup
474  m_out->Print( aNestLevel, "(setup\n" );
475 
476  // Save current default track width, for compatibility with older Pcbnew version;
477  m_out->Print( aNestLevel+1, "(last_trace_width %s)\n",
478  FormatInternalUnits( dsnSettings.GetCurrentTrackWidth() ).c_str() );
479 
480  // Save custom tracks width list (the first is not saved here: this is the netclass value
481  for( unsigned ii = 1; ii < dsnSettings.m_TrackWidthList.size(); ii++ )
482  m_out->Print( aNestLevel+1, "(user_trace_width %s)\n",
483  FormatInternalUnits( dsnSettings.m_TrackWidthList[ii] ).c_str() );
484 
485  m_out->Print( aNestLevel+1, "(trace_clearance %s)\n",
486  FormatInternalUnits( dsnSettings.GetDefault()->GetClearance() ).c_str() );
487 
488  // ZONE_SETTINGS
489  m_out->Print( aNestLevel+1, "(zone_clearance %s)\n",
490  FormatInternalUnits( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() );
491  m_out->Print( aNestLevel+1, "(zone_45_only %s)\n",
492  aBoard->GetZoneSettings().m_Zone_45_Only ? "yes" : "no" );
493 
494  m_out->Print( aNestLevel+1, "(trace_min %s)\n",
495  FormatInternalUnits( dsnSettings.m_TrackMinWidth ).c_str() );
496 
497  // Save current default via size, for compatibility with older Pcbnew version;
498  m_out->Print( aNestLevel+1, "(via_size %s)\n",
499  FormatInternalUnits( dsnSettings.GetDefault()->GetViaDiameter() ).c_str() );
500  m_out->Print( aNestLevel+1, "(via_drill %s)\n",
501  FormatInternalUnits( dsnSettings.GetDefault()->GetViaDrill() ).c_str() );
502  m_out->Print( aNestLevel+1, "(via_min_size %s)\n",
503  FormatInternalUnits( dsnSettings.m_ViasMinSize ).c_str() );
504  m_out->Print( aNestLevel+1, "(via_min_drill %s)\n",
505  FormatInternalUnits( dsnSettings.m_ViasMinDrill ).c_str() );
506 
507  // Save custom vias diameters list (the first is not saved here: this is
508  // the netclass value
509  for( unsigned ii = 1; ii < dsnSettings.m_ViasDimensionsList.size(); ii++ )
510  m_out->Print( aNestLevel+1, "(user_via %s %s)\n",
511  FormatInternalUnits( dsnSettings.m_ViasDimensionsList[ii].m_Diameter ).c_str(),
512  FormatInternalUnits( dsnSettings.m_ViasDimensionsList[ii].m_Drill ).c_str() );
513 
514  // for old versions compatibility:
515  if( dsnSettings.m_BlindBuriedViaAllowed )
516  m_out->Print( aNestLevel+1, "(blind_buried_vias_allowed yes)\n" );
517 
518  m_out->Print( aNestLevel+1, "(uvia_size %s)\n",
519  FormatInternalUnits( dsnSettings.GetDefault()->GetuViaDiameter() ).c_str() );
520  m_out->Print( aNestLevel+1, "(uvia_drill %s)\n",
521  FormatInternalUnits( dsnSettings.GetDefault()->GetuViaDrill() ).c_str() );
522  m_out->Print( aNestLevel+1, "(uvias_allowed %s)\n",
523  ( dsnSettings.m_MicroViasAllowed ) ? "yes" : "no" );
524  m_out->Print( aNestLevel+1, "(uvia_min_size %s)\n",
525  FormatInternalUnits( dsnSettings.m_MicroViasMinSize ).c_str() );
526  m_out->Print( aNestLevel+1, "(uvia_min_drill %s)\n",
527  FormatInternalUnits( dsnSettings.m_MicroViasMinDrill ).c_str() );
528 
529  // 6.0 TODO: are we going to update the tokens we save these under?
530  // 6.0 TODO: need to save the LAYER_CLASS_OTHERS stuff
531  // 6.0 TODO: need to save the TextItalic and TextUpright settings
532 
533  m_out->Print( aNestLevel+1, "(edge_width %s)\n",
534  FormatInternalUnits( dsnSettings.m_LineThickness[ LAYER_CLASS_EDGES ] ).c_str() );
535 
536  m_out->Print( aNestLevel+1, "(segment_width %s)\n",
537  FormatInternalUnits( dsnSettings.m_LineThickness[ LAYER_CLASS_COPPER ] ).c_str() );
538  m_out->Print( aNestLevel+1, "(pcb_text_width %s)\n",
539  FormatInternalUnits( dsnSettings.m_TextThickness[ LAYER_CLASS_COPPER ] ).c_str() );
540  m_out->Print( aNestLevel+1, "(pcb_text_size %s %s)\n",
541  FormatInternalUnits( dsnSettings.m_TextSize[ LAYER_CLASS_COPPER ].x ).c_str(),
542  FormatInternalUnits( dsnSettings.m_TextSize[ LAYER_CLASS_COPPER ].y ).c_str() );
543 
544  m_out->Print( aNestLevel+1, "(mod_edge_width %s)\n",
545  FormatInternalUnits( dsnSettings.m_LineThickness[ LAYER_CLASS_SILK ] ).c_str() );
546  m_out->Print( aNestLevel+1, "(mod_text_size %s %s)\n",
547  FormatInternalUnits( dsnSettings.m_TextSize[ LAYER_CLASS_SILK ].x ).c_str(),
548  FormatInternalUnits( dsnSettings.m_TextSize[ LAYER_CLASS_SILK ].y ).c_str() );
549  m_out->Print( aNestLevel+1, "(mod_text_width %s)\n",
550  FormatInternalUnits( dsnSettings.m_TextThickness[ LAYER_CLASS_SILK ] ).c_str() );
551 
552  m_out->Print( aNestLevel+1, "(pad_size %s %s)\n",
553  FormatInternalUnits( dsnSettings.m_Pad_Master.GetSize().x ).c_str(),
554  FormatInternalUnits( dsnSettings.m_Pad_Master.GetSize().y ).c_str() );
555  m_out->Print( aNestLevel+1, "(pad_drill %s)\n",
556  FormatInternalUnits( dsnSettings.m_Pad_Master.GetDrillSize().x ).c_str() );
557 
558  m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
559  FormatInternalUnits( dsnSettings.m_SolderMaskMargin ).c_str() );
560 
561  if( dsnSettings.m_SolderMaskMinWidth )
562  m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n",
563  FormatInternalUnits( dsnSettings.m_SolderMaskMinWidth ).c_str() );
564 
565  if( dsnSettings.m_SolderPasteMargin != 0 )
566  m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
567  FormatInternalUnits( dsnSettings.m_SolderPasteMargin ).c_str() );
568 
569  if( dsnSettings.m_SolderPasteMarginRatio != 0 )
570  m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
571  Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
572 
573  m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
574  FormatInternalUnits( aBoard->GetAuxOrigin().x ).c_str(),
575  FormatInternalUnits( aBoard->GetAuxOrigin().y ).c_str() );
576 
577  if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y )
578  m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
579  FormatInternalUnits( aBoard->GetGridOrigin().x ).c_str(),
580  FormatInternalUnits( aBoard->GetGridOrigin().y ).c_str() );
581 
582  m_out->Print( aNestLevel+1, "(visible_elements %X)\n",
583  dsnSettings.GetVisibleElements() );
584 
585  aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
586 
587  m_out->Print( aNestLevel, ")\n\n" );
588 }
589 
590 
591 void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const
592 {
593  const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
594 
595  m_out->Print( 0, "\n" );
596  m_out->Print( aNestLevel, "(general\n" );
597  // Write Bounding box info
598  m_out->Print( aNestLevel+1, "(thickness %s)\n",
599  FormatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() );
600 
601  m_out->Print( aNestLevel+1, "(drawings %d)\n", aBoard->Drawings().Size() );
602  m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() );
603  m_out->Print( aNestLevel+1, "(modules %d)\n", aBoard->m_Modules.GetCount() );
604  m_out->Print( aNestLevel+1, "(nets %d)\n", m_mapping->GetSize() );
605  m_out->Print( aNestLevel, ")\n\n" );
606 
607  aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl );
608  aBoard->GetTitleBlock().Format( m_out, aNestLevel, m_ctl );
609 }
610 
611 
612 void PCB_IO::formatBoardLayers( BOARD* aBoard, int aNestLevel ) const
613 {
614  m_out->Print( aNestLevel, "(layers\n" );
615 
616  // Save only the used copper layers from front to back.
617  LSET visible_layers = aBoard->GetVisibleLayers();
618 
619  for( LSEQ cu = aBoard->GetEnabledLayers().CuStack(); cu; ++cu )
620  {
621  PCB_LAYER_ID layer = *cu;
622 
623  m_out->Print( aNestLevel+1, "(%d %s %s", layer,
624  m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str(),
625  LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
626 
627  if( !visible_layers[layer] )
628  m_out->Print( 0, " hide" );
629 
630  m_out->Print( 0, ")\n" );
631  }
632 
633  // Save used non-copper layers in the order they are defined.
634  // desired sequence for non Cu BOARD layers.
635  static const PCB_LAYER_ID non_cu[] =
636  {
637  B_Adhes, // 32
638  F_Adhes,
639  B_Paste,
640  F_Paste,
641  B_SilkS,
642  F_SilkS,
643  B_Mask,
644  F_Mask,
645  Dwgs_User,
646  Cmts_User,
647  Eco1_User,
648  Eco2_User,
649  Edge_Cuts,
650  Margin,
651  B_CrtYd,
652  F_CrtYd,
653  B_Fab,
654  F_Fab
655  };
656 
657  for( LSEQ seq = aBoard->GetEnabledLayers().Seq( non_cu, arrayDim( non_cu ) ); seq; ++seq )
658  {
659  PCB_LAYER_ID layer = *seq;
660 
661  m_out->Print( aNestLevel+1, "(%d %s user", layer,
662  m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str() );
663 
664  if( !visible_layers[layer] )
665  m_out->Print( 0, " hide" );
666 
667  m_out->Print( 0, ")\n" );
668  }
669 
670  m_out->Print( aNestLevel, ")\n\n" );
671 }
672 
673 
674 void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const
675 {
676  const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
677  for( NETINFO_ITEM* net : *m_mapping )
678  {
679  m_out->Print( aNestLevel, "(net %d %s)\n",
680  m_mapping->Translate( net->GetNet() ),
681  m_out->Quotew( net->GetNetname() ).c_str() );
682  }
683 
684  m_out->Print( 0, "\n" );
685 
686  // Save the default net class first.
687  NETCLASS defaultNC = *dsnSettings.GetDefault();
688  filterNetClass( *aBoard, defaultNC ); // Remove empty nets (from a copy of a netclass)
689  defaultNC.Format( m_out, aNestLevel, m_ctl );
690 
691  // Save the rest of the net classes alphabetically.
692  for( const auto& it : dsnSettings.m_NetClasses )
693  {
694  NETCLASS netclass = *it.second;
695  filterNetClass( *aBoard, netclass ); // Remove empty nets (from a copy of a netclass)
696  netclass.Format( m_out, aNestLevel, m_ctl );
697  }
698 }
699 
700 
701 void PCB_IO::formatHeader( BOARD* aBoard, int aNestLevel ) const
702 {
703  formatGeneral( aBoard, aNestLevel );
704  // Layers.
705  formatBoardLayers( aBoard, aNestLevel );
706  // Setup
707  formatSetup( aBoard, aNestLevel );
708  // Save net codes and names
709  formatNetInformation( aBoard, aNestLevel );
710 }
711 
712 void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
713 {
714  formatHeader( aBoard, aNestLevel );
715 
716  // Save the modules.
717  for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
718  {
719  Format( module, aNestLevel );
720  m_out->Print( 0, "\n" );
721  }
722 
723  // Save the graphical items on the board (not owned by a module)
724  for( auto item : aBoard->Drawings() )
725  Format( item, aNestLevel );
726 
727  if( aBoard->Drawings().Size() )
728  m_out->Print( 0, "\n" );
729 
730  // Do not save MARKER_PCBs, they can be regenerated easily.
731 
732  // Save the tracks and vias.
733  for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
734  Format( track, aNestLevel );
735 
736  if( aBoard->m_Track.GetCount() )
737  m_out->Print( 0, "\n" );
738 
741 
742  // Save the polygon (which are the newer technology) zones.
743  for( int i = 0; i < aBoard->GetAreaCount(); ++i )
744  Format( aBoard->GetArea( i ), aNestLevel );
745 }
746 
747 
748 void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const
749 {
750  m_out->Print( aNestLevel, "(dimension %s (width %s)",
751  FormatInternalUnits( aDimension->GetValue() ).c_str(),
752  FormatInternalUnits( aDimension->GetWidth() ).c_str() );
753 
754  formatLayer( aDimension );
755 
756  if( aDimension->GetTimeStamp() )
757  m_out->Print( 0, " (tstamp %lX)", (unsigned long)aDimension->GetTimeStamp() );
758 
759  m_out->Print( 0, "\n" );
760 
761  Format( &aDimension->Text(), aNestLevel+1 );
762 
763  m_out->Print( aNestLevel+1, "(feature1 (pts (xy %s %s) (xy %s %s)))\n",
764  FormatInternalUnits( aDimension->m_featureLineDO.x ).c_str(),
765  FormatInternalUnits( aDimension->m_featureLineDO.y ).c_str(),
766  FormatInternalUnits( aDimension->m_featureLineDF.x ).c_str(),
767  FormatInternalUnits( aDimension->m_featureLineDF.y ).c_str() );
768 
769  m_out->Print( aNestLevel+1, "(feature2 (pts (xy %s %s) (xy %s %s)))\n",
770  FormatInternalUnits( aDimension->m_featureLineGO.x ).c_str(),
771  FormatInternalUnits( aDimension->m_featureLineGO.y ).c_str(),
772  FormatInternalUnits( aDimension->m_featureLineGF.x ).c_str(),
773  FormatInternalUnits( aDimension->m_featureLineGF.y ).c_str() );
774 
775  m_out->Print( aNestLevel+1, "(crossbar (pts (xy %s %s) (xy %s %s)))\n",
776  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
777  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
778  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
779  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str() );
780 
781  m_out->Print( aNestLevel+1, "(arrow1a (pts (xy %s %s) (xy %s %s)))\n",
782  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
783  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str(),
784  FormatInternalUnits( aDimension->m_arrowD1F.x ).c_str(),
785  FormatInternalUnits( aDimension->m_arrowD1F.y ).c_str() );
786 
787  m_out->Print( aNestLevel+1, "(arrow1b (pts (xy %s %s) (xy %s %s)))\n",
788  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
789  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str(),
790  FormatInternalUnits( aDimension->m_arrowD2F.x ).c_str(),
791  FormatInternalUnits( aDimension->m_arrowD2F.y ).c_str() );
792 
793  m_out->Print( aNestLevel+1, "(arrow2a (pts (xy %s %s) (xy %s %s)))\n",
794  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
795  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
796  FormatInternalUnits( aDimension->m_arrowG1F.x ).c_str(),
797  FormatInternalUnits( aDimension->m_arrowG1F.y ).c_str() );
798 
799  m_out->Print( aNestLevel+1, "(arrow2b (pts (xy %s %s) (xy %s %s)))\n",
800  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
801  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
802  FormatInternalUnits( aDimension->m_arrowG2F.x ).c_str(),
803  FormatInternalUnits( aDimension->m_arrowG2F.y ).c_str() );
804 
805  m_out->Print( aNestLevel, ")\n" );
806 }
807 
808 
809 void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const
810 {
811  switch( aSegment->GetShape() )
812  {
813  case S_SEGMENT: // Line
814  m_out->Print( aNestLevel, "(gr_line (start %s) (end %s)",
815  FormatInternalUnits( aSegment->GetStart() ).c_str(),
816  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
817 
818  if( aSegment->GetAngle() != 0.0 )
819  m_out->Print( 0, " (angle %s)", FormatAngle( aSegment->GetAngle() ).c_str() );
820 
821  break;
822 
823  case S_CIRCLE: // Circle
824  m_out->Print( aNestLevel, "(gr_circle (center %s) (end %s)",
825  FormatInternalUnits( aSegment->GetStart() ).c_str(),
826  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
827  break;
828 
829  case S_ARC: // Arc
830  m_out->Print( aNestLevel, "(gr_arc (start %s) (end %s) (angle %s)",
831  FormatInternalUnits( aSegment->GetStart() ).c_str(),
832  FormatInternalUnits( aSegment->GetEnd() ).c_str(),
833  FormatAngle( aSegment->GetAngle() ).c_str() );
834  break;
835 
836  case S_POLYGON: // Polygon
837  if( aSegment->IsPolyShapeValid() )
838  {
839  SHAPE_POLY_SET& poly = aSegment->GetPolyShape();
840  SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
841  int pointsCount = outline.PointCount();
842 
843  m_out->Print( aNestLevel, "(gr_poly (pts" );
844 
845  for( int ii = 0; ii < pointsCount; ++ii )
846  {
847  m_out->Print( 0, " (xy %s)", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
848  }
849 
850  m_out->Print( 0, ")" );
851  }
852  else
853  {
854  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
855  return;
856  }
857 
858  break;
859 
860  case S_CURVE: // Bezier curve
861  m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
862  FormatInternalUnits( aSegment->GetStart() ).c_str(),
863  FormatInternalUnits( aSegment->GetBezControl1() ).c_str(),
864  FormatInternalUnits( aSegment->GetBezControl2() ).c_str(),
865  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
866  break;
867 
868  default:
869  wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
870  return;
871  };
872 
873  formatLayer( aSegment );
874 
875  m_out->Print( 0, " (width %s)", FormatInternalUnits( aSegment->GetWidth() ).c_str() );
876 
877  if( aSegment->GetTimeStamp() )
878  m_out->Print( 0, " (tstamp %lX)", (unsigned long)aSegment->GetTimeStamp() );
879 
880  if( aSegment->GetStatus() )
881  m_out->Print( 0, " (status %X)", aSegment->GetStatus() );
882 
883  m_out->Print( 0, ")\n" );
884 }
885 
886 
887 void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const
888 {
889  switch( aModuleDrawing->GetShape() )
890  {
891  case S_SEGMENT: // Line
892  m_out->Print( aNestLevel, "(fp_line (start %s) (end %s)",
893  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
894  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
895  break;
896 
897  case S_CIRCLE: // Circle
898  m_out->Print( aNestLevel, "(fp_circle (center %s) (end %s)",
899  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
900  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
901  break;
902 
903  case S_ARC: // Arc
904  m_out->Print( aNestLevel, "(fp_arc (start %s) (end %s) (angle %s)",
905  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
906  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str(),
907  FormatAngle( aModuleDrawing->GetAngle() ).c_str() );
908  break;
909 
910  case S_POLYGON: // Polygonal segment
911  if( aModuleDrawing->IsPolyShapeValid() )
912  {
913  SHAPE_POLY_SET& poly = aModuleDrawing->GetPolyShape();
914  SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
915  int pointsCount = outline.PointCount();
916 
917  m_out->Print( aNestLevel, "(fp_poly (pts" );
918 
919  for( int ii = 0; ii < pointsCount; ++ii )
920  {
921  int nestLevel = 0;
922 
923  if( ii && !( ii%4 ) ) // newline every 4 pts
924  {
925  nestLevel = aNestLevel + 1;
926  m_out->Print( 0, "\n" );
927  }
928 
929  m_out->Print( nestLevel, "%s(xy %s)",
930  nestLevel ? "" : " ", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
931  }
932 
933  m_out->Print( 0, ")" );
934  }
935  else
936  {
937  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
938  return;
939  }
940  break;
941 
942  case S_CURVE: // Bezier curve
943  m_out->Print( aNestLevel, "(fp_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
944  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
945  FormatInternalUnits( aModuleDrawing->GetBezier0_C1() ).c_str(),
946  FormatInternalUnits( aModuleDrawing->GetBezier0_C2() ).c_str(),
947  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
948  break;
949 
950  default:
951  wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) );
952  return;
953  };
954 
955  formatLayer( aModuleDrawing );
956 
957  m_out->Print( 0, " (width %s)", FormatInternalUnits( aModuleDrawing->GetWidth() ).c_str() );
958 
959  m_out->Print( 0, ")\n" );
960 }
961 
962 
963 void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const
964 {
965  m_out->Print( aNestLevel, "(target %s (at %s) (size %s)",
966  ( aTarget->GetShape() ) ? "x" : "plus",
967  FormatInternalUnits( aTarget->GetPosition() ).c_str(),
968  FormatInternalUnits( aTarget->GetSize() ).c_str() );
969 
970  if( aTarget->GetWidth() != 0 )
971  m_out->Print( 0, " (width %s)", FormatInternalUnits( aTarget->GetWidth() ).c_str() );
972 
973  formatLayer( aTarget );
974 
975  if( aTarget->GetTimeStamp() )
976  m_out->Print( 0, " (tstamp %lX)", (unsigned long)aTarget->GetTimeStamp() );
977 
978  m_out->Print( 0, ")\n" );
979 }
980 
981 
982 void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
983 {
984  if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
985  {
986  const wxArrayString* initial_comments = aModule->GetInitialComments();
987 
988  if( initial_comments )
989  {
990  for( unsigned i=0; i<initial_comments->GetCount(); ++i )
991  m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) );
992 
993  m_out->Print( 0, "\n" ); // improve readability?
994  }
995  }
996 
997  m_out->Print( aNestLevel, "(module %s",
998  m_out->Quotes( aModule->GetFPID().Format() ).c_str() );
999 
1000  if( aModule->IsLocked() )
1001  m_out->Print( 0, " locked" );
1002 
1003  if( aModule->IsPlaced() )
1004  m_out->Print( 0, " placed" );
1005 
1006  formatLayer( aModule );
1007 
1008  m_out->Print( 0, " (tedit %lX)", (unsigned long)aModule->GetLastEditTime() );
1009 
1010  if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
1011  {
1012  m_out->Print( 0, " (tstamp %lX)\n", (unsigned long)aModule->GetTimeStamp() );
1013  }
1014  else
1015  m_out->Print( 0, "\n" );
1016 
1017  if( !( m_ctl & CTL_OMIT_AT ) )
1018  {
1019  m_out->Print( aNestLevel+1, "(at %s", FormatInternalUnits( aModule->GetPosition() ).c_str() );
1020 
1021  if( aModule->GetOrientation() != 0.0 )
1022  m_out->Print( 0, " %s", FormatAngle( aModule->GetOrientation() ).c_str() );
1023 
1024  m_out->Print( 0, ")\n" );
1025  }
1026 
1027  if( !aModule->GetDescription().IsEmpty() )
1028  m_out->Print( aNestLevel+1, "(descr %s)\n",
1029  m_out->Quotew( aModule->GetDescription() ).c_str() );
1030 
1031  if( !aModule->GetKeywords().IsEmpty() )
1032  m_out->Print( aNestLevel+1, "(tags %s)\n",
1033  m_out->Quotew( aModule->GetKeywords() ).c_str() );
1034 
1035  if( !( m_ctl & CTL_OMIT_PATH ) && !!aModule->GetPath() )
1036  m_out->Print( aNestLevel+1, "(path %s)\n",
1037  m_out->Quotew( aModule->GetPath() ).c_str() );
1038 
1039  if( aModule->GetPlacementCost90() != 0 )
1040  m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aModule->GetPlacementCost90() );
1041 
1042  if( aModule->GetPlacementCost180() != 0 )
1043  m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aModule->GetPlacementCost180() );
1044 
1045  if( aModule->GetLocalSolderMaskMargin() != 0 )
1046  m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
1047  FormatInternalUnits( aModule->GetLocalSolderMaskMargin() ).c_str() );
1048 
1049  if( aModule->GetLocalSolderPasteMargin() != 0 )
1050  m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
1051  FormatInternalUnits( aModule->GetLocalSolderPasteMargin() ).c_str() );
1052 
1053  if( aModule->GetLocalSolderPasteMarginRatio() != 0 )
1054  m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
1055  Double2Str( aModule->GetLocalSolderPasteMarginRatio() ).c_str() );
1056 
1057  if( aModule->GetLocalClearance() != 0 )
1058  m_out->Print( aNestLevel+1, "(clearance %s)\n",
1059  FormatInternalUnits( aModule->GetLocalClearance() ).c_str() );
1060 
1061  if( aModule->GetZoneConnection() != PAD_ZONE_CONN_INHERITED )
1062  m_out->Print( aNestLevel+1, "(zone_connect %d)\n", aModule->GetZoneConnection() );
1063 
1064  if( aModule->GetThermalWidth() != 0 )
1065  m_out->Print( aNestLevel+1, "(thermal_width %s)\n",
1066  FormatInternalUnits( aModule->GetThermalWidth() ).c_str() );
1067 
1068  if( aModule->GetThermalGap() != 0 )
1069  m_out->Print( aNestLevel+1, "(thermal_gap %s)\n",
1070  FormatInternalUnits( aModule->GetThermalGap() ).c_str() );
1071 
1072  // Attributes
1073  if( aModule->GetAttributes() != MOD_DEFAULT )
1074  {
1075  m_out->Print( aNestLevel+1, "(attr" );
1076 
1077  if( aModule->GetAttributes() & MOD_CMS )
1078  m_out->Print( 0, " smd" );
1079 
1080  if( aModule->GetAttributes() & MOD_VIRTUAL )
1081  m_out->Print( 0, " virtual" );
1082 
1083  m_out->Print( 0, ")\n" );
1084  }
1085 
1086  Format( (BOARD_ITEM*) &aModule->Reference(), aNestLevel+1 );
1087  Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel+1 );
1088 
1089  // Save drawing elements.
1090  for( BOARD_ITEM* gr = aModule->GraphicalItemsList(); gr; gr = gr->Next() )
1091  Format( gr, aNestLevel+1 );
1092 
1093  // Save pads.
1094  for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
1095  format( pad, aNestLevel+1 );
1096 
1097  // Save 3D info.
1098  auto bs3D = aModule->Models().begin();
1099  auto es3D = aModule->Models().end();
1100 
1101  while( bs3D != es3D )
1102  {
1103  if( !bs3D->m_Filename.IsEmpty() )
1104  {
1105  m_out->Print( aNestLevel+1, "(model %s\n",
1106  m_out->Quotew( bs3D->m_Filename ).c_str() );
1107 
1108  /* Write 3D model offset in mm
1109  * 4.0.x wrote "at" which was actually in inches
1110  * 5.0.x onwards, 3D model offset is written using "offset"
1111  *
1112  * If the offset is all zero, write "at" (fewer file changes)
1113  * Otherwise, write "offset"
1114  */
1115 
1116  wxString offsetTag = "offset";
1117 
1118  if( bs3D->m_Offset.x == 0 &&
1119  bs3D->m_Offset.y == 0 &&
1120  bs3D->m_Offset.z == 0 )
1121  {
1122  offsetTag = "at";
1123  }
1124 
1125  m_out->Print( aNestLevel+2, "(%s (xyz %s %s %s))\n",
1126  offsetTag.ToStdString().c_str(),
1127  Double2Str( bs3D->m_Offset.x ).c_str(),
1128  Double2Str( bs3D->m_Offset.y ).c_str(),
1129  Double2Str( bs3D->m_Offset.z ).c_str() );
1130 
1131  m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
1132  Double2Str( bs3D->m_Scale.x ).c_str(),
1133  Double2Str( bs3D->m_Scale.y ).c_str(),
1134  Double2Str( bs3D->m_Scale.z ).c_str() );
1135 
1136  m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
1137  Double2Str( bs3D->m_Rotation.x ).c_str(),
1138  Double2Str( bs3D->m_Rotation.y ).c_str(),
1139  Double2Str( bs3D->m_Rotation.z ).c_str() );
1140 
1141  m_out->Print( aNestLevel+1, ")\n" );
1142  }
1143  ++bs3D;
1144  }
1145 
1146  m_out->Print( aNestLevel, ")\n" );
1147 }
1148 
1149 
1150 void PCB_IO::formatLayers( LSET aLayerMask, int aNestLevel ) const
1151 {
1152  std::string output;
1153 
1154  if( aNestLevel == 0 )
1155  output += ' ';
1156 
1157  output += "(layers";
1158 
1159  static const LSET cu_all( LSET::AllCuMask() );
1160  static const LSET fr_bk( 2, B_Cu, F_Cu );
1161  static const LSET adhes( 2, B_Adhes, F_Adhes );
1162  static const LSET paste( 2, B_Paste, F_Paste );
1163  static const LSET silks( 2, B_SilkS, F_SilkS );
1164  static const LSET mask( 2, B_Mask, F_Mask );
1165  static const LSET crt_yd(2, B_CrtYd, F_CrtYd );
1166  static const LSET fab( 2, B_Fab, F_Fab );
1167 
1168  LSET cu_mask = cu_all;
1169 
1170  // output copper layers first, then non copper
1171 
1172  if( ( aLayerMask & cu_mask ) == cu_mask )
1173  {
1174  output += " *.Cu";
1175  aLayerMask &= ~cu_all; // clear bits, so they are not output again below
1176  }
1177  else if( ( aLayerMask & cu_mask ) == fr_bk )
1178  {
1179  output += " F&B.Cu";
1180  aLayerMask &= ~fr_bk;
1181  }
1182 
1183  if( ( aLayerMask & adhes ) == adhes )
1184  {
1185  output += " *.Adhes";
1186  aLayerMask &= ~adhes;
1187  }
1188 
1189  if( ( aLayerMask & paste ) == paste )
1190  {
1191  output += " *.Paste";
1192  aLayerMask &= ~paste;
1193  }
1194 
1195  if( ( aLayerMask & silks ) == silks )
1196  {
1197  output += " *.SilkS";
1198  aLayerMask &= ~silks;
1199  }
1200 
1201  if( ( aLayerMask & mask ) == mask )
1202  {
1203  output += " *.Mask";
1204  aLayerMask &= ~mask;
1205  }
1206 
1207  if( ( aLayerMask & crt_yd ) == crt_yd )
1208  {
1209  output += " *.CrtYd";
1210  aLayerMask &= ~crt_yd;
1211  }
1212 
1213  if( ( aLayerMask & fab ) == fab )
1214  {
1215  output += " *.Fab";
1216  aLayerMask &= ~fab;
1217  }
1218 
1219  // output any individual layers not handled in wildcard combos above
1220 
1221  wxString layerName;
1222 
1223  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
1224  {
1225  if( aLayerMask[layer] )
1226  {
1227  if( m_board && !( m_ctl & CTL_STD_LAYER_NAMES ) )
1228  layerName = m_board->GetLayerName( PCB_LAYER_ID( layer ) );
1229 
1230  else // I am being called from FootprintSave()
1231  layerName = BOARD::GetStandardLayerName( PCB_LAYER_ID( layer ) );
1232 
1233  output += ' ';
1234  output += m_out->Quotew( layerName );
1235  }
1236  }
1237 
1238  m_out->Print( aNestLevel, "%s)", output.c_str() );
1239 }
1240 
1241 
1242 void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
1243 {
1244  const char* shape;
1245 
1246  switch( aPad->GetShape() )
1247  {
1248  case PAD_SHAPE_CIRCLE: shape = "circle"; break;
1249  case PAD_SHAPE_RECT: shape = "rect"; break;
1250  case PAD_SHAPE_OVAL: shape = "oval"; break;
1251  case PAD_SHAPE_TRAPEZOID: shape = "trapezoid"; break;
1253  case PAD_SHAPE_ROUNDRECT: shape = "roundrect"; break;
1254  case PAD_SHAPE_CUSTOM: shape = "custom"; break;
1255 
1256  default:
1257  THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), aPad->GetShape() ) );
1258  }
1259 
1260  const char* type;
1261 
1262  switch( aPad->GetAttribute() )
1263  {
1264  case PAD_ATTRIB_STANDARD: type = "thru_hole"; break;
1265  case PAD_ATTRIB_SMD: type = "smd"; break;
1266  case PAD_ATTRIB_CONN: type = "connect"; break;
1267  case PAD_ATTRIB_HOLE_NOT_PLATED: type = "np_thru_hole"; break;
1268 
1269  default:
1270  THROW_IO_ERROR( wxString::Format( "unknown pad attribute: %d", aPad->GetAttribute() ) );
1271  }
1272 
1273  m_out->Print( aNestLevel, "(pad %s %s %s",
1274  m_out->Quotew( aPad->GetName() ).c_str(),
1275  type, shape );
1276  m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() );
1277 
1278  if( aPad->GetOrientation() != 0.0 )
1279  m_out->Print( 0, " %s", FormatAngle( aPad->GetOrientation() ).c_str() );
1280 
1281  m_out->Print( 0, ")" );
1282  m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() );
1283 
1284  if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
1285  m_out->Print( 0, " (rect_delta %s )", FormatInternalUnits( aPad->GetDelta() ).c_str() );
1286 
1287  wxSize sz = aPad->GetDrillSize();
1288  wxPoint shapeoffset = aPad->GetOffset();
1289 
1290  if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
1291  (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1292  {
1293  m_out->Print( 0, " (drill" );
1294 
1295  if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1296  m_out->Print( 0, " oval" );
1297 
1298  if( sz.GetWidth() > 0 )
1299  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetWidth() ).c_str() );
1300 
1301  if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
1302  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetHeight() ).c_str() );
1303 
1304  if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1305  m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() );
1306 
1307  m_out->Print( 0, ")" );
1308  }
1309 
1310  formatLayers( aPad->GetLayerSet() );
1311 
1312  // Output the radius ratio for rounded and chamfered rect pads
1313  if( aPad->GetShape() == PAD_SHAPE_ROUNDRECT || aPad->GetShape() == PAD_SHAPE_CHAMFERED_RECT)
1314  {
1315  m_out->Print( 0, " (roundrect_rratio %s)",
1316  Double2Str( aPad->GetRoundRectRadiusRatio() ).c_str() );
1317  }
1318 
1319  // Output the chamfer corners for chamfered rect pads
1320  if( aPad->GetShape() == PAD_SHAPE_CHAMFERED_RECT)
1321  {
1322  m_out->Print( 0, "\n" );
1323 
1324  m_out->Print( aNestLevel+1, "(chamfer_ratio %s)",
1325  Double2Str( aPad->GetChamferRectRatio() ).c_str() );
1326 
1327  m_out->Print( 0, " (chamfer" );
1328 
1329  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT ) )
1330  m_out->Print( 0, " top_left" );
1331 
1332  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT ) )
1333  m_out->Print( 0, " top_right" );
1334 
1335  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT ) )
1336  m_out->Print( 0, " bottom_left" );
1337 
1339  m_out->Print( 0, " bottom_right" );
1340 
1341  m_out->Print( 0, ")" );
1342  }
1343 
1344  std::string output;
1345 
1346  // Unconnected pad is default net so don't save it.
1347  if( !( m_ctl & CTL_OMIT_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED )
1348  StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
1349  m_out->Quotew( aPad->GetNetname() ).c_str() );
1350 
1351  if( aPad->GetPadToDieLength() != 0 )
1352  StrPrintf( &output, " (die_length %s)", FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() );
1353 
1354  if( aPad->GetLocalSolderMaskMargin() != 0 )
1355  StrPrintf( &output, " (solder_mask_margin %s)",
1356  FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() );
1357 
1358  if( aPad->GetLocalSolderPasteMargin() != 0 )
1359  StrPrintf( &output, " (solder_paste_margin %s)",
1360  FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() );
1361 
1362  if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
1363  StrPrintf( &output, " (solder_paste_margin_ratio %s)",
1364  Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() );
1365 
1366  if( aPad->GetLocalClearance() != 0 )
1367  StrPrintf( &output, " (clearance %s)", FormatInternalUnits( aPad->GetLocalClearance() ).c_str() );
1368 
1370  StrPrintf( &output, " (zone_connect %d)", aPad->GetZoneConnection() );
1371 
1372  if( aPad->GetThermalWidth() != 0 )
1373  StrPrintf( &output, " (thermal_width %s)", FormatInternalUnits( aPad->GetThermalWidth() ).c_str() );
1374 
1375  if( aPad->GetThermalGap() != 0 )
1376  StrPrintf( &output, " (thermal_gap %s)", FormatInternalUnits( aPad->GetThermalGap() ).c_str() );
1377 
1378  if( output.size() )
1379  {
1380  m_out->Print( 0, "\n" );
1381  m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
1382  }
1383 
1384  if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
1385  {
1386  m_out->Print( 0, "\n");
1387  m_out->Print( aNestLevel+1, "(options" );
1388 
1390  m_out->Print( 0, " (clearance convexhull)" );
1391  #if 1 // Set to 1 to output the default option
1392  else
1393  m_out->Print( 0, " (clearance outline)" );
1394  #endif
1395 
1396  // Output the anchor pad shape (circle/rect)
1397  if( aPad->GetAnchorPadShape() == PAD_SHAPE_RECT )
1398  shape = "rect";
1399  else
1400  shape = "circle";
1401 
1402  m_out->Print( 0, " (anchor %s)", shape );
1403 
1404  m_out->Print( 0, ")"); // end of (options ...
1405 
1406  // Output graphic primitive of the pad shape
1407  m_out->Print( 0, "\n");
1408  m_out->Print( aNestLevel+1, "(primitives" );
1409 
1410  int nested_level = aNestLevel+2;
1411 
1412  // Output all basic shapes
1413  for( unsigned icnt = 0; icnt < aPad->GetPrimitives().size(); ++icnt )
1414  {
1415  m_out->Print( 0, "\n");
1416 
1417  const PAD_CS_PRIMITIVE& primitive = aPad->GetPrimitives()[icnt];
1418 
1419  switch( primitive.m_Shape )
1420  {
1421  case S_SEGMENT: // usual segment : line with rounded ends
1422  m_out->Print( nested_level, "(gr_line (start %s) (end %s) (width %s))",
1423  FormatInternalUnits( primitive.m_Start ).c_str(),
1424  FormatInternalUnits( primitive.m_End ).c_str(),
1425  FormatInternalUnits( primitive.m_Thickness ).c_str() );
1426  break;
1427 
1428  case S_ARC: // Arc with rounded ends
1429  m_out->Print( nested_level, "(gr_arc (start %s) (end %s) (angle %s) (width %s))",
1430  FormatInternalUnits( primitive.m_Start ).c_str(),
1431  FormatInternalUnits( primitive.m_End ).c_str(),
1432  FormatAngle( primitive.m_ArcAngle ).c_str(),
1433  FormatInternalUnits( primitive.m_Thickness ).c_str() );
1434  break;
1435 
1436  case S_CIRCLE: // ring or circle (circle if width == 0
1437  m_out->Print( nested_level, "(gr_circle (center %s) (end %s %s) (width %s))",
1438  FormatInternalUnits( primitive.m_Start ).c_str(),
1439  FormatInternalUnits( primitive.m_Start.x + primitive.m_Radius ).c_str(),
1440  FormatInternalUnits( primitive.m_Start.y ).c_str(),
1441  FormatInternalUnits( primitive.m_Thickness ).c_str() );
1442  break;
1443 
1444  case S_CURVE: // Bezier Curve
1445  m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s)) (width %s))",
1446  FormatInternalUnits( primitive.m_Start ).c_str(),
1447  FormatInternalUnits( primitive.m_Ctrl1 ).c_str(),
1448  FormatInternalUnits( primitive.m_Ctrl2 ).c_str(),
1449  FormatInternalUnits( primitive.m_End ).c_str(),
1450  FormatInternalUnits( primitive.m_Thickness ).c_str() );
1451  break;
1452 
1453  case S_POLYGON: // polygon
1454  if( primitive.m_Poly.size() < 2 )
1455  break; // Malformed polygon.
1456 
1457  {
1458  m_out->Print( nested_level, "(gr_poly (pts\n");
1459 
1460  // Write the polygon corners coordinates:
1461  const std::vector< wxPoint>& poly = primitive.m_Poly;
1462  int newLine = 0;
1463 
1464  for( unsigned ii = 0; ii < poly.size(); ii++ )
1465  {
1466  if( newLine == 0 )
1467  m_out->Print( nested_level+1, " (xy %s)",
1468  FormatInternalUnits( wxPoint( poly[ii].x, poly[ii].y ) ).c_str() );
1469  else
1470  m_out->Print( 0, " (xy %s)",
1471  FormatInternalUnits( wxPoint( poly[ii].x, poly[ii].y ) ).c_str() );
1472 
1473  if( ++newLine > 4 )
1474  {
1475  newLine = 0;
1476  m_out->Print( 0, "\n" );
1477  }
1478  }
1479 
1480  m_out->Print( 0, ") (width %s))", FormatInternalUnits( primitive.m_Thickness ).c_str() );
1481  }
1482  break;
1483 
1484  default:
1485  break;
1486  }
1487  }
1488 
1489  m_out->Print( 0, "\n");
1490  m_out->Print( aNestLevel+1, ")" ); // end of (basic_shapes
1491  }
1492 
1493  m_out->Print( 0, ")\n" );
1494 }
1495 
1496 
1497 void PCB_IO::format( TEXTE_PCB* aText, int aNestLevel ) const
1498 {
1499  m_out->Print( aNestLevel, "(gr_text %s (at %s",
1500  m_out->Quotew( aText->GetText() ).c_str(),
1501  FormatInternalUnits( aText->GetTextPos() ).c_str() );
1502 
1503  if( aText->GetTextAngle() != 0.0 )
1504  m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() );
1505 
1506  m_out->Print( 0, ")" );
1507 
1508  formatLayer( aText );
1509 
1510  if( aText->GetTimeStamp() )
1511  m_out->Print( 0, " (tstamp %lX)", (unsigned long)aText->GetTimeStamp() );
1512 
1513  m_out->Print( 0, "\n" );
1514 
1515  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl );
1516 
1517  m_out->Print( aNestLevel, ")\n" );
1518 }
1519 
1520 
1521 void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const
1522 {
1523  std::string type;
1524 
1525  switch( aText->GetType() )
1526  {
1527  case TEXTE_MODULE::TEXT_is_REFERENCE: type = "reference"; break;
1528  case TEXTE_MODULE::TEXT_is_VALUE: type = "value"; break;
1529  case TEXTE_MODULE::TEXT_is_DIVERS: type = "user";
1530  }
1531 
1532  m_out->Print( aNestLevel, "(fp_text %s %s (at %s", type.c_str(),
1533  m_out->Quotew( aText->GetText() ).c_str(),
1534  FormatInternalUnits( aText->GetPos0() ).c_str() );
1535 
1536  // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
1537  // but internally the angle is held relative to its parent footprint. parent
1538  // may be NULL when saving a footprint outside a BOARD.
1539  double orient = aText->GetTextAngle();
1540  MODULE* parent = (MODULE*) aText->GetParent();
1541 
1542  if( parent )
1543  {
1544  // GetTextAngle() is always in -360..+360 range because of
1545  // TEXTE_MODULE::SetTextAngle(), but summing that angle with an
1546  // additional board angle could kick sum up >= 360 or <= -360, so to have
1547  // consistent results, normalize again for the BOARD save. A footprint
1548  // save does not use this code path since parent is NULL.
1549 #if 0
1550  // This one could be considered reasonable if you like positive angles
1551  // in your board text.
1552  orient = NormalizeAnglePos( orient + parent->GetOrientation() );
1553 #else
1554  // Choose compatibility for now, even though this is only a 720 degree clamp
1555  // with two possible values for every angle.
1556  orient = NormalizeAngle360Min( orient + parent->GetOrientation() );
1557 #endif
1558  }
1559 
1560  if( orient != 0.0 )
1561  m_out->Print( 0, " %s", FormatAngle( orient ).c_str() );
1562 
1563  if( !aText->IsKeepUpright() )
1564  m_out->Print( 0, " unlocked" );
1565 
1566  m_out->Print( 0, ")" );
1567  formatLayer( aText );
1568 
1569  if( !aText->IsVisible() )
1570  m_out->Print( 0, " hide" );
1571 
1572  m_out->Print( 0, "\n" );
1573 
1574  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1575 
1576  m_out->Print( aNestLevel, ")\n" );
1577 }
1578 
1579 
1580 void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const
1581 {
1582  if( aTrack->Type() == PCB_VIA_T )
1583  {
1584  PCB_LAYER_ID layer1, layer2;
1585 
1586  const VIA* via = static_cast<const VIA*>( aTrack );
1587  BOARD* board = (BOARD*) via->GetParent();
1588 
1589  wxCHECK_RET( board != 0, wxT( "Via " ) + via->GetSelectMenuText( MILLIMETRES ) +
1590  wxT( " has no parent." ) );
1591 
1592  m_out->Print( aNestLevel, "(via" );
1593 
1594  via->LayerPair( &layer1, &layer2 );
1595 
1596  switch( via->GetViaType() )
1597  {
1598  case VIA_THROUGH: // Default shape not saved.
1599  break;
1600 
1601  case VIA_BLIND_BURIED:
1602  m_out->Print( 0, " blind" );
1603  break;
1604 
1605  case VIA_MICROVIA:
1606  m_out->Print( 0, " micro" );
1607  break;
1608 
1609  default:
1610  THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
1611  }
1612 
1613  m_out->Print( 0, " (at %s) (size %s)",
1614  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1615  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1616 
1617  if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
1618  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrill() ).c_str() );
1619 
1620  m_out->Print( 0, " (layers %s %s)",
1621  m_out->Quotew( m_board->GetLayerName( layer1 ) ).c_str(),
1622  m_out->Quotew( m_board->GetLayerName( layer2 ) ).c_str() );
1623  }
1624  else
1625  {
1626  m_out->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)",
1627  FormatInternalUnits( aTrack->GetStart() ).c_str(), FormatInternalUnits( aTrack->GetEnd() ).c_str(),
1628  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1629 
1630  m_out->Print( 0, " (layer %s)", m_out->Quotew( aTrack->GetLayerName() ).c_str() );
1631  }
1632 
1633  m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
1634 
1635  if( aTrack->GetTimeStamp() != 0 )
1636  m_out->Print( 0, " (tstamp %lX)", (unsigned long)aTrack->GetTimeStamp() );
1637 
1638  if( aTrack->GetStatus() != 0 )
1639  m_out->Print( 0, " (status %X)", aTrack->GetStatus() );
1640 
1641  m_out->Print( 0, ")\n" );
1642 }
1643 
1644 
1645 void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
1646 {
1647  // Save the NET info; For keepout zones, net code and net name are irrelevant
1648  // so be sure a dummy value is stored, just for ZONE_CONTAINER compatibility
1649  // (perhaps netcode and netname should be not stored)
1650  m_out->Print( aNestLevel, "(zone (net %d) (net_name %s)",
1651  aZone->GetIsKeepout() ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
1652  m_out->Quotew( aZone->GetIsKeepout() ? wxT("") : aZone->GetNetname() ).c_str() );
1653 
1654  // If a zone exists on multiple layers, format accordingly
1655  if( aZone->GetLayerSet().count() > 1 )
1656  {
1657  formatLayers( aZone->GetLayerSet() );
1658  }
1659  else
1660  {
1661  formatLayer( aZone );
1662  }
1663 
1664  m_out->Print( 0, " (tstamp %lX)", (unsigned long) aZone->GetTimeStamp() );
1665 
1666  // Save the outline aux info
1667  std::string hatch;
1668 
1669  switch( aZone->GetHatchStyle() )
1670  {
1671  default:
1672  case ZONE_CONTAINER::NO_HATCH: hatch = "none"; break;
1673  case ZONE_CONTAINER::DIAGONAL_EDGE: hatch = "edge"; break;
1674  case ZONE_CONTAINER::DIAGONAL_FULL: hatch = "full"; break;
1675  }
1676 
1677  m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
1678  FormatInternalUnits( aZone->GetHatchPitch() ).c_str() );
1679 
1680  if( aZone->GetPriority() > 0 )
1681  m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetPriority() );
1682 
1683  m_out->Print( aNestLevel+1, "(connect_pads" );
1684 
1685  switch( aZone->GetPadConnection() )
1686  {
1687  default:
1688  case PAD_ZONE_CONN_THERMAL: // Default option not saved or loaded.
1689  break;
1690 
1692  m_out->Print( 0, " thru_hole_only" );
1693  break;
1694 
1695  case PAD_ZONE_CONN_FULL:
1696  m_out->Print( 0, " yes" );
1697  break;
1698 
1699  case PAD_ZONE_CONN_NONE:
1700  m_out->Print( 0, " no" );
1701  break;
1702  }
1703 
1704  m_out->Print( 0, " (clearance %s))\n",
1705  FormatInternalUnits( aZone->GetZoneClearance() ).c_str() );
1706 
1707  m_out->Print( aNestLevel+1, "(min_thickness %s)",
1708  FormatInternalUnits( aZone->GetMinThickness() ).c_str() );
1709 
1710  m_out->Print( 0, "\n" );
1711 
1712  if( aZone->GetIsKeepout() )
1713  {
1714  m_out->Print( aNestLevel+1, "(keepout (tracks %s) (vias %s) (copperpour %s))\n",
1715  aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
1716  aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
1717  aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed" );
1718  }
1719 
1720  m_out->Print( aNestLevel+1, "(fill" );
1721 
1722  // Default is not filled.
1723  if( aZone->IsFilled() )
1724  m_out->Print( 0, " yes" );
1725 
1726  // Default is polygon filled.
1727  if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
1728  m_out->Print( 0, " (mode hatch)" );
1729 
1730  m_out->Print( 0, " (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)",
1731  aZone->GetArcSegmentCount(),
1732  FormatInternalUnits( aZone->GetThermalReliefGap() ).c_str(),
1733  FormatInternalUnits( aZone->GetThermalReliefCopperBridge() ).c_str() );
1734 
1736  {
1737  m_out->Print( 0, " (smoothing" );
1738 
1739  switch( aZone->GetCornerSmoothingType() )
1740  {
1742  m_out->Print( 0, " chamfer" );
1743  break;
1744 
1746  m_out->Print( 0, " fillet" );
1747  break;
1748 
1749  default:
1750  THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
1751  aZone->GetCornerSmoothingType() ) );
1752  }
1753  m_out->Print( 0, ")" );
1754 
1755  if( aZone->GetCornerRadius() != 0 )
1756  m_out->Print( 0, " (radius %s)",
1757  FormatInternalUnits( aZone->GetCornerRadius() ).c_str() );
1758  }
1759 
1760  if( aZone->GetFillMode() == ZFM_HATCH_PATTERN )
1761  {
1762  m_out->Print( 0, "\n" );
1763  m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
1764  FormatInternalUnits( aZone->GetHatchFillTypeThickness() ).c_str(),
1765  FormatInternalUnits( aZone->GetHatchFillTypeGap() ).c_str(),
1766  Double2Str( aZone->GetHatchFillTypeOrientation() ).c_str() );
1767 
1768  if( aZone->GetHatchFillTypeSmoothingLevel() > 0 )
1769  {
1770  m_out->Print( 0, "\n" );
1771  m_out->Print( aNestLevel+2, "(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
1773  Double2Str( aZone->GetHatchFillTypeSmoothingValue() ).c_str() );
1774  }
1775  }
1776 
1777  m_out->Print( 0, ")\n" );
1778 
1779  int newLine = 0;
1780 
1781  if( aZone->GetNumCorners() )
1782  {
1783  bool new_polygon = true;
1784  bool is_closed = false;
1785 
1786  for( auto iterator = aZone->IterateWithHoles(); iterator; iterator++ )
1787  {
1788  if( new_polygon )
1789  {
1790  newLine = 0;
1791  m_out->Print( aNestLevel+1, "(polygon\n" );
1792  m_out->Print( aNestLevel+2, "(pts\n" );
1793  new_polygon = false;
1794  is_closed = false;
1795  }
1796 
1797  if( newLine == 0 )
1798  m_out->Print( aNestLevel+3, "(xy %s %s)",
1799  FormatInternalUnits( iterator->x ).c_str(), FormatInternalUnits( iterator->y ).c_str() );
1800  else
1801  m_out->Print( 0, " (xy %s %s)",
1802  FormatInternalUnits( iterator->x ).c_str(), FormatInternalUnits( iterator->y ).c_str() );
1803 
1804  if( newLine < 4 )
1805  {
1806  newLine += 1;
1807  }
1808  else
1809  {
1810  newLine = 0;
1811  m_out->Print( 0, "\n" );
1812  }
1813 
1814  if( iterator.IsEndContour() )
1815  {
1816  is_closed = true;
1817 
1818  if( newLine != 0 )
1819  m_out->Print( 0, "\n" );
1820 
1821  m_out->Print( aNestLevel+2, ")\n" );
1822  m_out->Print( aNestLevel+1, ")\n" );
1823  new_polygon = true;
1824  }
1825  }
1826 
1827  if( !is_closed ) // Should not happen, but...
1828  m_out->Print( aNestLevel+1, ")\n" );
1829 
1830  }
1831 
1832  // Save the PolysList (filled areas)
1833  const SHAPE_POLY_SET& fv = aZone->GetFilledPolysList();
1834  newLine = 0;
1835 
1836  if( !fv.IsEmpty() )
1837  {
1838  bool new_polygon = true;
1839  bool is_closed = false;
1840 
1841  for( auto it = fv.CIterate(); it; ++it )
1842  {
1843  if( new_polygon )
1844  {
1845  newLine = 0;
1846  m_out->Print( aNestLevel+1, "(filled_polygon\n" );
1847  m_out->Print( aNestLevel+2, "(pts\n" );
1848  new_polygon = false;
1849  is_closed = false;
1850  }
1851 
1852  if( newLine == 0 )
1853  m_out->Print( aNestLevel+3, "(xy %s %s)",
1854  FormatInternalUnits( it->x ).c_str(), FormatInternalUnits( it->y ).c_str() );
1855  else
1856  m_out->Print( 0, " (xy %s %s)",
1857  FormatInternalUnits( it->x ) .c_str(), FormatInternalUnits( it->y ).c_str() );
1858 
1859  if( newLine < 4 )
1860  {
1861  newLine += 1;
1862  }
1863  else
1864  {
1865  newLine = 0;
1866  m_out->Print( 0, "\n" );
1867  }
1868 
1869  if( it.IsEndContour() )
1870  {
1871  is_closed = true;
1872 
1873  if( newLine != 0 )
1874  m_out->Print( 0, "\n" );
1875 
1876  m_out->Print( aNestLevel+2, ")\n" );
1877  m_out->Print( aNestLevel+1, ")\n" );
1878  new_polygon = true;
1879  }
1880  }
1881 
1882  if( !is_closed ) // Should not happen, but...
1883  m_out->Print( aNestLevel+1, ")\n" );
1884  }
1885 
1886  // Save the filling segments list
1887  const auto& segs = aZone->FillSegments();
1888 
1889  if( segs.size() )
1890  {
1891  m_out->Print( aNestLevel+1, "(fill_segments\n" );
1892 
1893  for( ZONE_SEGMENT_FILL::const_iterator it = segs.begin(); it != segs.end(); ++it )
1894  {
1895  m_out->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n",
1896  FormatInternalUnits( wxPoint( it->A ) ).c_str(),
1897  FormatInternalUnits( wxPoint( it->B ) ).c_str() );
1898  }
1899 
1900  m_out->Print( aNestLevel+1, ")\n" );
1901  }
1902 
1903  m_out->Print( aNestLevel, ")\n" );
1904 }
1905 
1906 
1907 PCB_IO::PCB_IO( int aControlFlags ) :
1908  m_cache( 0 ),
1909  m_ctl( aControlFlags ),
1910  m_parser( new PCB_PARSER() ),
1911  m_mapping( new NETINFO_MAPPING() )
1912 {
1913  init( 0 );
1914  m_out = &m_sf;
1915 }
1916 
1917 
1919 {
1920  delete m_cache;
1921  delete m_parser;
1922  delete m_mapping;
1923 }
1924 
1925 
1926 BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
1927 {
1928  FILE_LINE_READER reader( aFileName );
1929 
1930  init( aProperties );
1931 
1932  m_parser->SetLineReader( &reader );
1933  m_parser->SetBoard( aAppendToMe );
1934 
1935  BOARD* board;
1936 
1937  try
1938  {
1939  board = dynamic_cast<BOARD*>( m_parser->Parse() );
1940  }
1941  catch( const FUTURE_FORMAT_ERROR& )
1942  {
1943  // Don't wrap a FUTURE_FORMAT_ERROR in another
1944  throw;
1945  }
1946  catch( const PARSE_ERROR& parse_error )
1947  {
1948  if( m_parser->IsTooRecent() )
1949  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
1950  else
1951  throw;
1952  }
1953 
1954  if( !board )
1955  {
1956  // The parser loaded something that was valid, but wasn't a board.
1957  THROW_PARSE_ERROR( _( "this file does not contain a PCB" ),
1958  m_parser->CurSource(), m_parser->CurLine(),
1959  m_parser->CurLineNumber(), m_parser->CurOffset() );
1960  }
1961 
1962  // Give the filename to the board if it's new
1963  if( !aAppendToMe )
1964  board->SetFileName( aFileName );
1965 
1966  return board;
1967 }
1968 
1969 
1970 void PCB_IO::init( const PROPERTIES* aProperties )
1971 {
1972  m_board = NULL;
1973  m_reader = NULL;
1975  m_props = aProperties;
1976 }
1977 
1978 
1979 void PCB_IO::validateCache( const wxString& aLibraryPath, bool checkModified )
1980 {
1981  if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) )
1982  {
1983  // a spectacular episode in memory management:
1984  delete m_cache;
1985  m_cache = new FP_CACHE( this, aLibraryPath );
1986  m_cache->Load();
1987  }
1988 }
1989 
1990 
1991 void PCB_IO::FootprintEnumerate( wxArrayString& aFootprintNames,
1992  const wxString& aLibraryPath,
1993  const PROPERTIES* aProperties )
1994 {
1995  LOCALE_IO toggle; // toggles on, then off, the C locale.
1996  wxDir dir( aLibraryPath );
1997 
1998  init( aProperties );
1999 
2000  wxString errorMsg;
2001 
2002  try
2003  {
2004  validateCache( aLibraryPath );
2005  }
2006  catch( const IO_ERROR& ioe )
2007  {
2008  errorMsg = ioe.What();
2009  }
2010 
2011  // Some of the files may have been parsed correctly so we want to add the valid files to
2012  // the library.
2013 
2014  const MODULE_MAP& mods = m_cache->GetModules();
2015 
2016  for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
2017  {
2018  aFootprintNames.Add( it->first );
2019  }
2020 
2021  if( !errorMsg.IsEmpty() )
2022  THROW_IO_ERROR( errorMsg );
2023 }
2024 
2025 
2026 const MODULE* PCB_IO::getFootprint( const wxString& aLibraryPath,
2027  const wxString& aFootprintName,
2028  const PROPERTIES* aProperties,
2029  bool checkModified )
2030 {
2031  LOCALE_IO toggle; // toggles on, then off, the C locale.
2032 
2033  init( aProperties );
2034 
2035  try
2036  {
2037  validateCache( aLibraryPath, checkModified );
2038  }
2039  catch( const IO_ERROR& )
2040  {
2041  // do nothing with the error
2042  }
2043 
2044  const MODULE_MAP& mods = m_cache->GetModules();
2045 
2046  MODULE_CITER it = mods.find( aFootprintName );
2047 
2048  if( it == mods.end() )
2049  {
2050  return NULL;
2051  }
2052 
2053  return it->second->GetModule();
2054 }
2055 
2056 
2057 const MODULE* PCB_IO::GetEnumeratedFootprint( const wxString& aLibraryPath,
2058  const wxString& aFootprintName,
2059  const PROPERTIES* aProperties )
2060 {
2061  return getFootprint( aLibraryPath, aFootprintName, aProperties, false );
2062 }
2063 
2064 
2065 MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
2066  const PROPERTIES* aProperties )
2067 {
2068  const MODULE* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
2069  return footprint ? new MODULE( *footprint ) : nullptr;
2070 }
2071 
2072 
2073 void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
2074  const PROPERTIES* aProperties )
2075 {
2076  LOCALE_IO toggle; // toggles on, then off, the C locale.
2077 
2078  init( aProperties );
2079 
2080  // In this public PLUGIN API function, we can safely assume it was
2081  // called for saving into a library path.
2083 
2084  validateCache( aLibraryPath );
2085 
2086  if( !m_cache->IsWritable() )
2087  {
2088  if( !m_cache->Exists() )
2089  {
2090  const wxString msg = wxString::Format( _( "Library \"%s\" does not exist.\n"
2091  "Would you like to create it?"),
2092  GetChars( aLibraryPath ) );
2093 
2094  if( wxMessageBox( msg, _( "Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2095  return;
2096 
2097  // Save throws its own IO_ERROR on failure, so no need to recreate here
2098  m_cache->Save( NULL );
2099  }
2100  else
2101  {
2102  wxString msg = wxString::Format( _( "Library \"%s\" is read only" ), aLibraryPath );
2103  THROW_IO_ERROR( msg );
2104  }
2105  }
2106 
2107  wxString footprintName = aFootprint->GetFPID().GetLibItemName();
2108 
2109  MODULE_MAP& mods = m_cache->GetModules();
2110 
2111  // Quietly overwrite module and delete module file from path for any by same name.
2112  wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
2114 
2115 #ifndef __WINDOWS__
2116  // Write through symlinks, don't replace them
2117  if( fn.Exists( wxFILE_EXISTS_SYMLINK ) )
2118  {
2119  char buffer[ PATH_MAX + 1 ];
2120  ssize_t pathLen = readlink( TO_UTF8( fn.GetFullPath() ), buffer, PATH_MAX );
2121 
2122  if( pathLen > 0 )
2123  {
2124  buffer[ pathLen ] = '\0';
2125  fn.Assign( fn.GetPath() + wxT( "/" ) + wxString::FromUTF8( buffer ) );
2126  fn.Normalize();
2127  }
2128  }
2129 #endif
2130 
2131  if( !fn.IsOk() )
2132  {
2133  THROW_IO_ERROR( wxString::Format( _( "Footprint file name \"%s\" is not valid." ),
2134  fn.GetFullPath() ) );
2135  }
2136 
2137  if( fn.FileExists() && !fn.IsFileWritable() )
2138  {
2139  THROW_IO_ERROR( wxString::Format( _( "No write permissions to delete file \"%s\"" ),
2140  fn.GetFullPath() ) );
2141  }
2142 
2143  wxString fullPath = fn.GetFullPath();
2144  wxString fullName = fn.GetFullName();
2145  MODULE_CITER it = mods.find( footprintName );
2146 
2147  if( it != mods.end() )
2148  {
2149  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
2150  mods.erase( footprintName );
2151  wxRemoveFile( fullPath );
2152  }
2153 
2154  // I need my own copy for the cache
2155  MODULE* module = new MODULE( *aFootprint );
2156 
2157  // and it's time stamp must be 0, it should have no parent, orientation should
2158  // be zero, and it should be on the front layer.
2159  module->SetTimeStamp( 0 );
2160  module->SetParent( 0 );
2161  module->SetOrientation( 0 );
2162 
2163  if( module->GetLayer() != F_Cu )
2164  module->Flip( module->GetPosition() );
2165 
2166  wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
2167  mods.insert( footprintName, new FP_CACHE_ITEM( module, WX_FILENAME( fn.GetPath(), fullName ) ) );
2168  m_cache->Save( module );
2169 }
2170 
2171 
2172 void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
2173  const PROPERTIES* aProperties )
2174 {
2175  LOCALE_IO toggle; // toggles on, then off, the C locale.
2176 
2177  init( aProperties );
2178 
2179  validateCache( aLibraryPath );
2180 
2181  if( !m_cache->IsWritable() )
2182  {
2183  THROW_IO_ERROR( wxString::Format( _( "Library \"%s\" is read only" ),
2184  aLibraryPath.GetData() ) );
2185  }
2186 
2187  m_cache->Remove( aFootprintName );
2188 }
2189 
2190 
2191 
2192 long long PCB_IO::GetLibraryTimestamp( const wxString& aLibraryPath ) const
2193 {
2194  return FP_CACHE::GetTimestamp( aLibraryPath );
2195 }
2196 
2197 
2198 void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
2199 {
2200  if( wxDir::Exists( aLibraryPath ) )
2201  {
2202  THROW_IO_ERROR( wxString::Format( _( "cannot overwrite library path \"%s\"" ),
2203  aLibraryPath.GetData() ) );
2204  }
2205 
2206  LOCALE_IO toggle;
2207 
2208  init( aProperties );
2209 
2210  delete m_cache;
2211  m_cache = new FP_CACHE( this, aLibraryPath );
2212  m_cache->Save();
2213 }
2214 
2215 
2216 bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
2217 {
2218  wxFileName fn;
2219  fn.SetPath( aLibraryPath );
2220 
2221  // Return if there is no library path to delete.
2222  if( !fn.DirExists() )
2223  return false;
2224 
2225  if( !fn.IsDirWritable() )
2226  {
2227  THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory \"%s\"" ),
2228  aLibraryPath.GetData() ) );
2229  }
2230 
2231  wxDir dir( aLibraryPath );
2232 
2233  if( dir.HasSubDirs() )
2234  {
2235  THROW_IO_ERROR( wxString::Format( _( "library directory \"%s\" has unexpected sub-directories" ),
2236  aLibraryPath.GetData() ) );
2237  }
2238 
2239  // All the footprint files must be deleted before the directory can be deleted.
2240  if( dir.HasFiles() )
2241  {
2242  unsigned i;
2243  wxFileName tmp;
2244  wxArrayString files;
2245 
2246  wxDir::GetAllFiles( aLibraryPath, &files );
2247 
2248  for( i = 0; i < files.GetCount(); i++ )
2249  {
2250  tmp = files[i];
2251 
2252  if( tmp.GetExt() != KiCadFootprintFileExtension )
2253  {
2254  THROW_IO_ERROR( wxString::Format( _( "unexpected file \"%s\" was found in library path \"%s\"" ),
2255  files[i].GetData(), aLibraryPath.GetData() ) );
2256  }
2257  }
2258 
2259  for( i = 0; i < files.GetCount(); i++ )
2260  {
2261  wxRemoveFile( files[i] );
2262  }
2263  }
2264 
2265  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint library \"%s\"" ),
2266  aLibraryPath.GetData() );
2267 
2268  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2269  // we don't want that. we want bare metal portability with no UI here.
2270  if( !wxRmdir( aLibraryPath ) )
2271  {
2272  THROW_IO_ERROR( wxString::Format( _( "footprint library \"%s\" cannot be deleted" ),
2273  aLibraryPath.GetData() ) );
2274  }
2275 
2276  // For some reason removing a directory in Windows is not immediately updated. This delay
2277  // prevents an error when attempting to immediately recreate the same directory when over
2278  // writing an existing library.
2279 #ifdef __WINDOWS__
2280  wxMilliSleep( 250L );
2281 #endif
2282 
2283  if( m_cache && !m_cache->IsPath( aLibraryPath ) )
2284  {
2285  delete m_cache;
2286  m_cache = NULL;
2287  }
2288 
2289  return true;
2290 }
2291 
2292 
2293 bool PCB_IO::IsFootprintLibWritable( const wxString& aLibraryPath )
2294 {
2295  LOCALE_IO toggle;
2296 
2297  init( NULL );
2298 
2299  validateCache( aLibraryPath );
2300 
2301  return m_cache->IsWritable();
2302 }
timestamp_t GetLastEditTime() const
Definition: class_module.h:315
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:676
friend class FP_CACHE
MODULE_MAP::iterator MODULE_ITER
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
int m_SolderMaskMargin
Solder mask margin.
int GetAttributes() const
Definition: class_module.h:225
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
int GetLocalSolderMaskMargin() const
Definition: class_pad.h:426
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
double GetOrientation() const
Definition: class_module.h:188
bool IsFilled() const
Definition: class_zone.h:187
STATUS_FLAGS GetStatus() const
Definition: base_struct.h:256
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:150
LINE_READER * m_reader
no ownership here.
void formatGeneral(BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
int GetPlacementCost90() const
Definition: class_module.h:573
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:549
bool IsModified()
Function IsModified Return true if the cache is not up-to-date.
TEXTE_MODULE & Reference()
Definition: class_module.h:503
std::unique_ptr< MODULE > m_module
int GetNetCode() const
Function GetNetCode.
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:552
const MODULE * GetModule() const
Definition: typeinfo.h:85
#define CTL_OMIT_AT
Omit position and rotation.
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
const wxPoint & GetPos0() const
Definition: class_pad.h:265
Class PCB_IO is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
int GetWidth() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
int StrPrintf(std::string *aResult, const char *aFormat,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
void formatLayer(const BOARD_ITEM *aItem) const
TEXTE_PCB class definition.
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:635
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
int m_SolderPasteMargin
Solder paste margin absolute value.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:177
wxFileName m_lib_path
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
Implementation of conversion functions that require both schematic and board internal units.
wxPoint m_crossBarF
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
std::vector< int > m_TrackWidthList
const std::string KiCadFootprintFileExtension
wxPoint m_arrowD1F
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:228
FP_CACHE * m_cache
Footprint library cache.
const wxPoint & GetStart() const
Definition: class_track.h:133
STROKE_T GetShape() const
Class PCB_PARSER reads a Pcbnew s-expression formatted LINE_READER object and returns the appropriate...
Definition: pcb_parser.h:65
int GetSize() const
int GetHatchFillTypeThickness() const
Definition: class_zone.h:208
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
const MODULE * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for m...
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
bool IsVisible() const
Definition: eda_text.h:193
bool IsPlaced() const
Definition: class_module.h:285
Class BOARD to handle a board.
void init(const PROPERTIES *aProperties)
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
polygon (not yet used for tracks, but could be in microwave apps)
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
int GetPadToDieLength() const
Definition: class_pad.h:424
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:62
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
ZONE_SEGMENT_FILL & FillSegments()
Definition: class_zone.h:257
const wxString & GetPath() const
Definition: class_module.h:201
const WX_FILENAME & GetFileName() const
wxString m_lib_raw_path
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:76
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
double GetTextAngle() const
Definition: eda_text.h:181
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
double GetHatchFillTypeOrientation() const
Definition: class_zone.h:214
wxString GetName() const
Definition: common.cpp:643
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Return a list of footprint names contained within the library at aLibraryPath.
void formatNetInformation(BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Classes to handle copper zones.
double GetHatchFillTypeSmoothingValue() const
Definition: class_zone.h:220
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable.
usual segment : line with rounded ends
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
std::string Double2Str(double aValue)
Helper function Double2Str to print a float number without using scientific notation and no trailing ...
Definition: base_units.cpp:63
const LIB_ID & GetFPID() const
Definition: class_module.h:192
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
wxPoint m_featureLineDF
int GetThermalReliefGap(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:626
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function GetStandardSizes returns the standard page types, such as "A4", "A3", etc.
Definition: page_info.cpp:267
void SetFullName(const wxString &aFileNameAndExtension)
Definition: common.cpp:637
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
#define cu(a)
Definition: auxiliary.h:88
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
int GetThermalGap() const
Definition: class_pad.cpp:759
int GetLocalSolderMaskMargin() const
Definition: class_module.h:204
int PointCount() const
Function PointCount()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:367
int GetLocalClearance() const
Definition: class_pad.h:429
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
wxPoint m_Ctrl1
is also the start point of the arc
Definition: class_pad.h:102
iterator begin()
Definition: netclass.h:132
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:417
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
This file contains miscellaneous commonly used macros and functions.
int GetChamferPositions() const
has meaning only for chamfered rect pads
Definition: class_pad.h:695
bool GetDoNotAllowVias() const
Definition: class_zone.h:653
static const char * ShowType(LAYER_T aType)
Function ShowType converts a LAYER_T enum to a const char*.
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
void SetBoard(const BOARD *aBoard)
Function SetBoard Sets a BOARD object that is used to prepare the net code map.
Definition: netinfo.h:285
long long m_cache_timestamp
Pads are not covered.
Definition: zones.h:52
wxPoint m_featureLineGO
int GetNumSegmTrack() const
Functions to get some items count.
const wxPoint & GetStart0() const
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:243
bool IsKeepUpright()
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:47
wxSize m_TextSize[LAYER_CLASS_COUNT]
DIMENSION class definition.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
int GetArcSegmentCount() const
Definition: class_zone.h:185
MODULE_MAP m_modules
class MODULE, a footprint
Definition: typeinfo.h:89
long long GetTimestamp()
Definition: common.cpp:677
void Remove(const wxString &aFootprintName)
int GetWidth() const
MODULE_MAP::const_iterator MODULE_CITER
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:490
PCB_IO(int aControlFlags=CTL_FOR_BOARD)
boost::ptr_map< wxString, FP_CACHE_ITEM > MODULE_MAP
STRINGSET::iterator iterator
Definition: netclass.h:131
PCB_LAYER_ID
A quick note on layer IDs:
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
wxString GetRequiredVersion()
Return a string representing the version of kicad required to open this file.
Definition: pcb_parser.cpp:184
int m_TextThickness[LAYER_CLASS_COUNT]
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:98
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:981
void FootprintLibCreate(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty.
Class LSET is a set of PCB_LAYER_IDs.
const std::vector< PAD_CS_PRIMITIVE > & GetPrimitives() const
Accessor to the basic shape list.
Definition: class_pad.h:341
HATCH_STYLE GetHatchStyle() const
Definition: class_zone.h:547
void SetBoard(BOARD *aBoard)
Definition: pcb_parser.h:325
unsigned int GetCornerRadius() const
Definition: class_zone.h:623
int GetSize() const
Function GetSize.
Definition: netinfo.h:379
std::vector< wxPoint > m_Poly
Bezier Control point 2.
Definition: class_pad.h:104
int GetLocalClearance() const
Definition: class_module.h:207
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void FootprintSave(const wxString &aLibraryPath, const MODULE *aFootprint, const PROPERTIES *aProperties=NULL) override
Function FootprintSave will write aModule to an existing library located at aLibraryPath.
iterator end()
Definition: netclass.h:133
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:219
bool IsPath(const wxString &aPath) const
Function IsPath checks if aPath is the same as the current cache path.
Class SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
ZONE_FILL_MODE GetFillMode() const
Definition: class_zone.h:170
int GetValue() const
int m_TrackMinWidth
track min value for width ((min copper size value
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
Definition: class_track.h:452
Arcs (with rounded ends)
int m_ViasMinSize
vias (not micro vias) min diameter
const wxPoint & GetOffset() const
Definition: class_pad.h:280
int m_loading_format_version
which SEXPR_BOARD_FILE_VERSION should be Load()ed?
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:400
double GetChamferRectRatio() const
has meaning only for chamfered rect pads
Definition: class_pad.h:672
int GetThermalWidth() const
Definition: class_pad.cpp:748
Class NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:55
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:91
TEXT_TYPE GetType() const
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:414
wxPoint m_arrowG1F
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:652
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:292
wxPoint m_arrowD2F
wxPoint m_arrowG2F
int m_ViasMinDrill
vias (not micro vias) min drill diameter
Definition of file extensions used in Kicad.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:210
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:459
VIATYPE_T GetViaType() const
Definition: class_track.h:437
const wxString & GetName() const
Definition: class_pad.h:192
int m_ZoneClearance
Clearance value.
Definition: zone_settings.h:64
long long TimestampDir(const wxString &aDirPath, const wxString &aFilespec)
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/...
Definition: common.cpp:836
PCB_IO * m_owner
wxLogTrace helper definitions.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the object to aFormatter in s-expression form.
Definition: worksheet.cpp:168
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
#define THROW_IO_ERROR(msg)
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
const wxPoint & GetBezier0_C2() const
SHAPE_POLY_SET & GetPolyShape()
std::map< wxString, MODULE * > MODULE_MAP
Definition: eagle_plugin.h:36
void formatSetup(BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
WX_FILENAME m_filename
void SetFileName(const wxString &aFileName)
Definition: class_board.h:235
Bezier Curve.
#define UNDEFINED_DRILL_DIAMETER
Definition: class_track.h:66
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:345
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
PCB_PARSER * m_parser
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
const wxSize & GetDelta() const
Definition: class_pad.h:274
const wxString & GetNetname() const
Function GetNetname.
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101
#define CTL_OMIT_NETS
Omit pads net names (useless in library)
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:444
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
Class FP_CACHE_ITEM is helper class for creating a footprint library cache.
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: class_module.h:697
int m_MicroViasMinSize
micro vias (not vias) min diameter
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:63
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
void Save(MODULE *aModule=NULL)
Function Save Save the footprint cache or a single module from it to disk.
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:267
const wxString & GetKeywords() const
Definition: class_module.h:198
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
STROKE_T m_Shape
Definition: class_pad.h:94
int m_LineThickness[LAYER_CLASS_COUNT]
int GetCornerSmoothingType() const
Definition: class_zone.h:619
Thermal relief only for THT pads.
Definition: zones.h:55
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
UTF8 Format() const
Definition: lib_id.cpp:237
const wxPoint & GetGridOrigin() const
Definition: class_board.h:352
int GetLocalSolderPasteMargin() const
Definition: class_module.h:210
int GetWidth() const
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:651
LINE_READER * SetLineReader(LINE_READER *aReader)
Function SetLineReader sets aLineReader into the parser, and returns the previous one,...
Definition: pcb_parser.h:318
wxPoint m_Ctrl2
Bezier Control point 1.
Definition: class_pad.h:103
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:99
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function FootprintDelete deletes aFootprintName from the library at aLibraryPath.
default
Definition: class_module.h:75
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:107
wxString GetPath() const
Definition: common.cpp:656
const wxPoint & GetPos0() const
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: class_pad.h:234
int m_Thickness
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT)
Definition: class_pad.h:95
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
int GetPlacementCost180() const
Definition: class_module.h:570
virtual std::string Quotes(const std::string &aWrapee)
Function Quotes checks aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:433
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Function GetLayerType returns the type of the copper layer given by aLayer.
void Load()
void formatBoardLayers(BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
wxString GetFullPath() const
Definition: common.cpp:662
const wxString & GetDescription() const
Definition: class_module.h:195
double GetAngle() const
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
bool IsWritable() const
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:343
double GetLocalSolderPasteMarginRatio() const
Definition: class_module.h:213
MODULE_MAP::const_iterator MODULE_CITER
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:178
void Remove(iterator aName)
Function Remove will remove NET name aName from the collection of members.
Definition: netclass.h:143
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
STRING_FORMATTER m_sf
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:96
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:100
virtual wxString GetClass() const =0
Function GetClass returns the class name.
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:555
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: common.h:397
int GetVisibleElements() const
Function GetVisibleElements returns a bit-mask of all the element categories that are visible.
int GetWidth() const
Definition: class_track.h:127
const MODULE * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
Class to handle a graphic segment.
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.
ZoneConnection GetPadConnection(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:999
int GetNet() const
Function GetNet.
Definition: netinfo.h:227
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
DLIST< MODULE > m_Modules
Definition: class_board.h:248
Class SHAPE_LINE_CHAIN.
void SetOrientation(double newangle)
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Function IterateWithHoles returns an iterator to visit all points of the zone's main outline with hol...
Definition: class_zone.h:479
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:394
Virtual component: when created by copper shapes on board (Like edge card connectors,...
Definition: class_module.h:78
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:242
TEXTE_PCB & Text()
#define CTL_STD_LAYER_NAMES
Use English Standard layer names.
size_t i
Definition: json11.cpp:597
const wxSize & GetDrillSize() const
Definition: class_pad.h:277
D_PAD m_Pad_Master
A dummy pad to store all default parameters.
BOARD * m_board
which BOARD, no ownership here
int GetShape() const
void format(BOARD *aBoard, int aNestLevel=0) const
int GetHatchPitch() const
Hatch related methods.
const wxPoint & GetBezControl2() const
const ZONE_SETTINGS & GetZoneSettings() const
Definition: class_board.h:558
The common library.
int GetMinThickness() const
Definition: class_zone.h:199
bool IsPolyShapeValid() const
const wxPoint & GetEnd() const
Definition: class_track.h:130
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
bool GetDoNotAllowTracks() const
Definition: class_zone.h:654
FP_CACHE_ITEM(MODULE *aModule, const WX_FILENAME &aFileName)
double GetRoundRectRadiusRatio() const
has meaning only for rounded rect pads
Definition: class_pad.h:646
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the net class to aFormatter in s-expression form.
Definition: netclass.cpp:253
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
const wxPoint & GetBezier0_C1() const
wxPoint m_crossBarO
const wxPoint & GetEnd0() const
int GetHatchFillTypeSmoothingLevel() const
Definition: class_zone.h:217
PCB_TARGET class definition.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const wxPoint & GetBezControl1() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Pcbnew s-expression file format parser definition.
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162
DLIST< TRACK > m_Track
Definition: class_board.h:249
void filterNetClass(const BOARD &aBoard, NETCLASS &aNetClass)
Removes empty nets (i.e. with node count equal zero) from net classes
Struct FUTURE_FORMAT_ERROR variant of PARSE_ERROR indicating that a syntax or related error was likel...
Definition: ki_exception.h:172
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:218
FP_CACHE(PCB_IO *aOwner, const wxString &aLibraryPath)
void formatHeader(BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
Module description (excepted pads)
bool m_MicroViasAllowed
true to allow micro vias
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:952
bool m_cache_dirty
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
int GetZoneClearance() const
Definition: class_zone.h:193
int m_MicroViasMinDrill
micro vias (not vias) min drill diameter
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
#define CTL_OMIT_INITIAL_COMMENTS
omit MODULE initial comments
MODULE_MAP::iterator MODULE_ITER
ZoneConnection GetZoneConnection() const
Definition: class_pad.cpp:737
double m_SolderPasteMarginRatio
Solder pask margin ratio value of pad size The final margin is the sum of these 2 values.
const wxSize & GetSize() const
Definition: class_pad.h:271
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.
int GetThermalWidth() const
Definition: class_module.h:220
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
Definition: trigo.h:231
int GetLocalSolderPasteMargin() const
Definition: class_pad.h:432
bool FootprintLibDelete(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Function FootprintLibDelete deletes an existing footprint library and returns true,...
BOARD_ITEM_CONTAINER * GetParent() const
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
#define CTL_OMIT_HIDE
Definition: eda_text.h:58
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
static long long GetTimestamp(const wxString &aLibPath)
Function GetTimestamp Generate a timestamp representing all source files in the cache (including the ...
bool Exists() const
wxPoint m_featureLineDO
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:465
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
int GetHatchFillTypeGap() const
Definition: class_zone.h:211
const wxPoint GetPosition() const override
Definition: class_module.h:183
int GetThermalGap() const
Definition: class_module.h:223
void SetFPID(const LIB_ID &aFPID)
Definition: class_module.h:193
Use thermal relief for pads.
Definition: zones.h:53
wxString GetPath() const
Class DIMENSION.
double m_ArcAngle
radius of a circle
Definition: class_pad.h:99
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:457
double GetLocalSolderPasteMarginRatio() const
Definition: class_pad.h:435
MODULE_MAP & GetModules()
ZoneConnection GetZoneConnection() const
Definition: class_module.h:217
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:253
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL) override
Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows a...
const wxPoint GetPosition() const override
int Translate(int aNetCode) const
Function Translate Translates net number according to the map prepared by Update() function.
int m_SolderMaskMinWidth
Solder mask min width.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:654
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
pads are covered by copper
Definition: zones.h:54
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:580
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
wxPoint m_featureLineGF