KiCad PCB EDA Suite
PCB_PLUGIN Class Reference

A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. More...

#include <pcb_plugin.h>

Inheritance diagram for PCB_PLUGIN:
PLUGIN CLIPBOARD_IO

Public Member Functions

const wxString PluginName () const override
 Return a brief hard coded name for this PLUGIN. More...
 
const wxString GetFileExtension () const override
 Returns the file extension for the PLUGIN. More...
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
 Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file. More...
 
BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
 Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one. More...
 
BOARDDoLoad (LINE_READER &aReader, BOARD *aAppendToMe, const PROPERTIES *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
const FOOTPRINTGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
 A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More...
 
bool FootprintExists (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
 Check for the existence of a footprint. More...
 
FOOTPRINTFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override
 Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
void FootprintSave (const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const PROPERTIES *aProperties=nullptr) override
 Write aFootprint to an existing library located at aLibraryPath. More...
 
void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
 Delete aFootprintName from the library at aLibraryPath. More...
 
long long GetLibraryTimestamp (const wxString &aLibraryPath) const override
 Generate a timestamp representing all the files in the library (including the library directory). More...
 
void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Create a new empty footprint library at aLibraryPath empty. More...
 
bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Delete an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More...
 
bool IsFootprintLibWritable (const wxString &aLibraryPath) override
 Return true if the library at aLibraryPath is writable. More...
 
 PCB_PLUGIN (int aControlFlags=CTL_FOR_BOARD)
 
virtual ~PCB_PLUGIN ()
 
void Format (const BOARD_ITEM *aItem, int aNestLevel=0) const
 Output aItem to aFormatter in s-expression format. More...
 
std::string GetStringOutput (bool doClear)
 
void SetOutputFormatter (OUTPUTFORMATTER *aFormatter)
 
BOARD_ITEMParse (const wxString &aClipboardSourceInput)
 
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints ()
 Return a container with the cached library footprints generated in the last call to Load. More...
 
virtual void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 If possible, prefetches the specified library (e.g. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Protected Member Functions

void validateCache (const wxString &aLibraryPath, bool checkModified=true)
 
const FOOTPRINTgetFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
 
void init (const PROPERTIES *aProperties)
 
void formatSetup (const BOARD *aBoard, int aNestLevel=0) const
 formats the board setup information More...
 
void formatGeneral (const BOARD *aBoard, int aNestLevel=0) const
 formats the General section of the file More...
 
void formatBoardLayers (const BOARD *aBoard, int aNestLevel=0) const
 formats the board layer information More...
 
void formatNetInformation (const BOARD *aBoard, int aNestLevel=0) const
 formats the Nets and Netclasses More...
 
void formatProperties (const BOARD *aBoard, int aNestLevel=0) const
 formats the Nets and Netclasses More...
 
void formatHeader (const BOARD *aBoard, int aNestLevel=0) const
 writes everything that comes before the board_items, like settings and layers etc More...
 

Protected Attributes

wxString m_error
 for throwing exceptions More...
 
BOARDm_board
 which BOARD, no ownership here More...
 
const PROPERTIESm_props
 passed via Save() or Load(), no ownership, may be NULL. More...
 
FP_CACHEm_cache
 Footprint library cache. More...
 
LINE_READERm_reader
 no ownership here. More...
 
wxString m_filename
 for saves only, name is in m_reader for loads More...
 
STRING_FORMATTER m_sf
 
OUTPUTFORMATTERm_out
 output any Format()s to this, no ownership More...
 
int m_ctl
 
PCB_PARSERm_parser
 
NETINFO_MAPPINGm_mapping
 mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes More...
 

Private Member Functions

void format (const BOARD *aBoard, int aNestLevel=0) const
 
void format (const PCB_DIMENSION_BASE *aDimension, int aNestLevel=0) const
 
void format (const FP_SHAPE *aFPShape, int aNestLevel=0) const
 
void format (const PCB_GROUP *aGroup, int aNestLevel=0) const
 
void format (const PCB_SHAPE *aSegment, int aNestLevel=0) const
 
void format (const PCB_TARGET *aTarget, int aNestLevel=0) const
 
void format (const FOOTPRINT *aFootprint, int aNestLevel=0) const
 
void format (const PAD *aPad, int aNestLevel=0) const
 
void format (const PCB_TEXT *aText, int aNestLevel=0) const
 
void format (const FP_TEXT *aText, int aNestLevel=0) const
 
void format (const PCB_TRACK *aTrack, int aNestLevel=0) const
 
void format (const ZONE *aZone, int aNestLevel=0) const
 
void formatLayer (const BOARD_ITEM *aItem) const
 
void formatLayers (LSET aLayerMask, int aNestLevel=0) const
 

Friends

class FP_CACHE
 

Detailed Description

A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.

Note
This class is not thread safe, but it is re-entrant multiple times in sequence.

Definition at line 141 of file pcb_plugin.h.

Constructor & Destructor Documentation

◆ PCB_PLUGIN()

PCB_PLUGIN::PCB_PLUGIN ( int  aControlFlags = CTL_FOR_BOARD)

Definition at line 2271 of file pcb_plugin.cpp.

2271  :
2272  m_cache( nullptr ),
2273  m_ctl( aControlFlags ),
2274  m_parser( new PCB_PARSER() ),
2275  m_mapping( new NETINFO_MAPPING() )
2276 {
2277  init( nullptr );
2278  m_out = &m_sf;
2279 }
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
Definition: pcb_parser.h:72
void init(const PROPERTIES *aProperties)
STRING_FORMATTER m_sf
Definition: pcb_plugin.h:293
PCB_PARSER * m_parser
Definition: pcb_plugin.h:296
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288

References init(), m_out, and m_sf.

◆ ~PCB_PLUGIN()

PCB_PLUGIN::~PCB_PLUGIN ( )
virtual

Definition at line 2282 of file pcb_plugin.cpp.

2283 {
2284  delete m_cache;
2285  delete m_parser;
2286  delete m_mapping;
2287 }
PCB_PARSER * m_parser
Definition: pcb_plugin.h:296
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288

References m_cache, m_mapping, and m_parser.

Member Function Documentation

◆ DoLoad()

BOARD * PCB_PLUGIN::DoLoad ( LINE_READER aReader,
BOARD aAppendToMe,
const PROPERTIES aProperties,
PROGRESS_REPORTER aProgressReporter,
unsigned  aLineCount 
)

Definition at line 2320 of file pcb_plugin.cpp.

2322 {
2323  init( aProperties );
2324 
2325  m_parser->SetLineReader( &aReader );
2326  m_parser->SetBoard( aAppendToMe );
2327  m_parser->SetProgressReporter( aProgressReporter, &aReader, aLineCount );
2328 
2329  BOARD* board;
2330 
2331  try
2332  {
2333  board = dynamic_cast<BOARD*>( m_parser->Parse() );
2334  }
2335  catch( const FUTURE_FORMAT_ERROR& )
2336  {
2337  // Don't wrap a FUTURE_FORMAT_ERROR in another
2338  throw;
2339  }
2340  catch( const PARSE_ERROR& parse_error )
2341  {
2342  if( m_parser->IsTooRecent() )
2343  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
2344  else
2345  throw;
2346  }
2347 
2348  if( !board )
2349  {
2350  // The parser loaded something that was valid, but wasn't a board.
2351  THROW_PARSE_ERROR( _( "This file does not contain a PCB." ), m_parser->CurSource(),
2352  m_parser->CurLine(), m_parser->CurLineNumber(), m_parser->CurOffset() );
2353  }
2354 
2355  return board;
2356 }
void SetProgressReporter(PROGRESS_REPORTER *aProgressReporter, const LINE_READER *aLineReader, unsigned aLineCount)
Definition: pcb_parser.h:111
void init(const PROPERTIES *aProperties)
PCB_PARSER * m_parser
Definition: pcb_plugin.h:296
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
Definition: pcb_parser.cpp:247
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:164
void SetBoard(BOARD *aBoard)
Definition: pcb_parser.h:102
#define _(s)
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:627
LINE_READER * SetLineReader(LINE_READER *aReader)
Set aLineReader into the parser, and returns the previous one, if any.
Definition: pcb_parser.h:95
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:133
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:174

References _, PCB_PARSER::GetRequiredVersion(), init(), PCB_PARSER::IsTooRecent(), m_parser, PCB_PARSER::Parse(), PCB_PARSER::SetBoard(), PCB_PARSER::SetLineReader(), PCB_PARSER::SetProgressReporter(), and THROW_PARSE_ERROR.

Referenced by PANEL_PCBNEW_COLOR_SETTINGS::createPreviewItems(), and Load().

◆ FootprintDelete()

void PCB_PLUGIN::FootprintDelete ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Delete aFootprintName from the library at aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of a footprint to delete from the specified library.
aPropertiesis an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the footprint or the library, or deleting it.

Reimplemented from PLUGIN.

Definition at line 2578 of file pcb_plugin.cpp.

2580 {
2581  LOCALE_IO toggle; // toggles on, then off, the C locale.
2582 
2583  init( aProperties );
2584 
2585  validateCache( aLibraryPath );
2586 
2587  if( !m_cache->IsWritable() )
2588  {
2589  THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only." ),
2590  aLibraryPath.GetData() ) );
2591  }
2592 
2593  m_cache->Remove( aFootprintName );
2594 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void init(const PROPERTIES *aProperties)
void Remove(const wxString &aFootprintName)
Definition: pcb_plugin.cpp:297
#define _(s)
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool IsWritable() const
Definition: pcb_plugin.cpp:108
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), init(), FP_CACHE::IsWritable(), m_cache, FP_CACHE::Remove(), THROW_IO_ERROR, and validateCache().

◆ FootprintEnumerate()

void PCB_PLUGIN::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aLibraryPath,
bool  aBestEfforts,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Return a list of footprint names contained within the library at aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
aFootprintNamesis the array of available footprint names inside a library.
aBestEffortsif true, don't throw on errors, just return an empty list.
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Reimplemented from PLUGIN.

Definition at line 2379 of file pcb_plugin.cpp.

2381 {
2382  LOCALE_IO toggle; // toggles on, then off, the C locale.
2383  wxDir dir( aLibPath );
2384  wxString errorMsg;
2385 
2386  init( aProperties );
2387 
2388  try
2389  {
2390  validateCache( aLibPath );
2391  }
2392  catch( const IO_ERROR& ioe )
2393  {
2394  errorMsg = ioe.What();
2395  }
2396 
2397  // Some of the files may have been parsed correctly so we want to add the valid files to
2398  // the library.
2399 
2400  for( const auto& footprint : m_cache->GetFootprints() )
2401  aFootprintNames.Add( footprint.first );
2402 
2403  if( !errorMsg.IsEmpty() && !aBestEfforts )
2404  THROW_IO_ERROR( errorMsg );
2405 }
FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.cpp:112
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void init(const PROPERTIES *aProperties)
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References FP_CACHE::GetFootprints(), init(), m_cache, THROW_IO_ERROR, validateCache(), and IO_ERROR::What().

◆ FootprintExists()

bool PCB_PLUGIN::FootprintExists ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Check for the existence of a footprint.

Reimplemented from PLUGIN.

Definition at line 2444 of file pcb_plugin.cpp.

2446 {
2447  // Note: checking the cache sounds like a good idea, but won't catch files which differ
2448  // only in case.
2449  //
2450  // Since this goes out to the native filesystem, we get platform differences (ie: MSW's
2451  // case-insensitive filesystem) handled "for free".
2452  // Warning: footprint names frequently contain a point. So be careful when initializing
2453  // wxFileName, and use a CTOR with extension specified
2454  wxFileName footprintFile( aLibraryPath, aFootprintName, KiCadFootprintFileExtension );
2455 
2456  return footprintFile.Exists();
2457 }
const std::string KiCadFootprintFileExtension

References KiCadFootprintFileExtension.

◆ FootprintLibCreate()

void PCB_PLUGIN::FootprintLibCreate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Create a new empty footprint library at aLibraryPath empty.

It is an error to attempt to create an existing library or to attempt to create on a "read only" location.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the library, or creating it.

Reimplemented from PLUGIN.

Definition at line 2604 of file pcb_plugin.cpp.

2605 {
2606  if( wxDir::Exists( aLibraryPath ) )
2607  {
2608  THROW_IO_ERROR( wxString::Format( _( "Cannot overwrite library path '%s'." ),
2609  aLibraryPath.GetData() ) );
2610  }
2611 
2612  LOCALE_IO toggle;
2613 
2614  init( aProperties );
2615 
2616  delete m_cache;
2617  m_cache = new FP_CACHE( this, aLibraryPath );
2618  m_cache->Save();
2619 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
Definition: pcb_plugin.cpp:166
void init(const PROPERTIES *aProperties)
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
friend class FP_CACHE
Definition: pcb_plugin.h:280
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), FP_CACHE, init(), m_cache, FP_CACHE::Save(), and THROW_IO_ERROR.

◆ FootprintLibDelete()

bool PCB_PLUGIN::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Delete an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain footprints.
aPropertiesis an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
true if library deleted, false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented from PLUGIN.

Definition at line 2622 of file pcb_plugin.cpp.

2623 {
2624  wxFileName fn;
2625  fn.SetPath( aLibraryPath );
2626 
2627  // Return if there is no library path to delete.
2628  if( !fn.DirExists() )
2629  return false;
2630 
2631  if( !fn.IsDirWritable() )
2632  {
2633  THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete folder '%s'." ),
2634  aLibraryPath.GetData() ) );
2635  }
2636 
2637  wxDir dir( aLibraryPath );
2638 
2639  if( dir.HasSubDirs() )
2640  {
2641  THROW_IO_ERROR( wxString::Format( _( "Library folder '%s' has unexpected sub-folders." ),
2642  aLibraryPath.GetData() ) );
2643  }
2644 
2645  // All the footprint files must be deleted before the directory can be deleted.
2646  if( dir.HasFiles() )
2647  {
2648  unsigned i;
2649  wxFileName tmp;
2650  wxArrayString files;
2651 
2652  wxDir::GetAllFiles( aLibraryPath, &files );
2653 
2654  for( i = 0; i < files.GetCount(); i++ )
2655  {
2656  tmp = files[i];
2657 
2658  if( tmp.GetExt() != KiCadFootprintFileExtension )
2659  {
2660  THROW_IO_ERROR( wxString::Format( _( "Unexpected file '%s' found in library "
2661  "path '%s'." ),
2662  files[i].GetData(),
2663  aLibraryPath.GetData() ) );
2664  }
2665  }
2666 
2667  for( i = 0; i < files.GetCount(); i++ )
2668  wxRemoveFile( files[i] );
2669  }
2670 
2671  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint library '%s'." ),
2672  aLibraryPath.GetData() );
2673 
2674  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2675  // we don't want that. we want bare metal portability with no UI here.
2676  if( !wxRmdir( aLibraryPath ) )
2677  {
2678  THROW_IO_ERROR( wxString::Format( _( "Footprint library '%s' cannot be deleted." ),
2679  aLibraryPath.GetData() ) );
2680  }
2681 
2682  // For some reason removing a directory in Windows is not immediately updated. This delay
2683  // prevents an error when attempting to immediately recreate the same directory when over
2684  // writing an existing library.
2685 #ifdef __WINDOWS__
2686  wxMilliSleep( 250L );
2687 #endif
2688 
2689  if( m_cache && !m_cache->IsPath( aLibraryPath ) )
2690  {
2691  delete m_cache;
2692  m_cache = nullptr;
2693  }
2694 
2695  return true;
2696 }
const std::string KiCadFootprintFileExtension
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
Definition: pcb_plugin.cpp:316
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), FP_CACHE::IsPath(), KiCadFootprintFileExtension, m_cache, THROW_IO_ERROR, and traceKicadPcbPlugin.

◆ FootprintLibOptions()

void PLUGIN::FootprintLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.

Options are typically appended so that a derived PLUGIN can call its base class function by the same name first, thus inheriting options declared there. Some base class options could pertain to all Footprint*() functions in all derived PLUGINs.

Note
Since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.
Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS. It may be multi-line and be quite explanatory of the option.

In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to PLUGIN, which has been avoided to date.

Reimplemented in EAGLE_PLUGIN.

Definition at line 147 of file plugin.cpp.

148 {
149  // disable all these in another couple of months, after everyone has seen them:
150 #if 1
151  (*aListToAppendTo)["debug_level"] = UTF8( _( "Enable <b>debug</b> logging for Footprint*() "
152  "functions in this PLUGIN." ) );
153 
154  (*aListToAppendTo)["read_filter_regex"] = UTF8( _( "Regular expression <b>footprint name</b> "
155  "filter." ) );
156 
157  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _( "Enable transaction logging. The "
158  "mere presence of this option "
159  "turns on the logging, no need to "
160  "set a Value." ) );
161 
162  (*aListToAppendTo)["username"] = UTF8( _( "User name for <b>login</b> to some special library "
163  "server." ) );
164 
165  (*aListToAppendTo)["password"] = UTF8( _( "Password for <b>login</b> to some special library "
166  "server." ) );
167 #endif
168 
169 #if 1
170  // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
171  // if and when implemented.
172  (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _( "Enter the python module which "
173  "implements the PLUGIN::Footprint*() "
174  "functions." ) );
175 #endif
176 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
#define _(s)

References _.

Referenced by EAGLE_PLUGIN::FootprintLibOptions().

◆ FootprintLoad()

FOOTPRINT * PCB_PLUGIN::FootprintLoad ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
bool  aKeepUUID = false,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of the footprint to load.
aPropertiesis an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
aKeepUUID= true to keep initial items UUID, false to set new UUID normally true if loaded in the footprint editor, false if loaded in the board editor. Make sense only in kicad_plugin
Returns
the FOOTPRINT object if found caller owns it, else NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aFootprintName cannot be found.

Reimplemented from PLUGIN.

Definition at line 2460 of file pcb_plugin.cpp.

2464 {
2465  const FOOTPRINT* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
2466 
2467  if( footprint )
2468  {
2469  FOOTPRINT* copy;
2470 
2471  if( aKeepUUID )
2472  copy = static_cast<FOOTPRINT*>( footprint->Clone() );
2473  else
2474  copy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
2475 
2476  copy->SetParent( nullptr );
2477  return copy;
2478  }
2479 
2480  return nullptr;
2481 }
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1725
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1293
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)

References FOOTPRINT::Clone(), copy, FOOTPRINT::Duplicate(), and getFootprint().

◆ FootprintSave()

void PCB_PLUGIN::FootprintSave ( const wxString &  aLibraryPath,
const FOOTPRINT aFootprint,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Write aFootprint to an existing library located at aLibraryPath.

If a footprint by the same name already exists, it is replaced.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintis what to store in the library. The caller continues to own the footprint after this call.
aPropertiesis an associative array that can be used to tell the saver how to save the footprint, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented from PLUGIN.

Definition at line 2484 of file pcb_plugin.cpp.

2486 {
2487  LOCALE_IO toggle; // toggles on, then off, the C locale.
2488 
2489  init( aProperties );
2490 
2491  // In this public PLUGIN API function, we can safely assume it was
2492  // called for saving into a library path.
2494 
2495  validateCache( aLibraryPath );
2496 
2497  if( !m_cache->IsWritable() )
2498  {
2499  if( !m_cache->Exists() )
2500  {
2501  const wxString msg = wxString::Format( _( "Library '%s' does not exist.\n"
2502  "Would you like to create it?"),
2503  aLibraryPath );
2504 
2505  if( wxMessageBox( msg, _( "Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2506  return;
2507 
2508  // Save throws its own IO_ERROR on failure, so no need to recreate here
2509  m_cache->Save( nullptr );
2510  }
2511  else
2512  {
2513  wxString msg = wxString::Format( _( "Library '%s' is read only." ), aLibraryPath );
2514  THROW_IO_ERROR( msg );
2515  }
2516  }
2517 
2518  wxString footprintName = aFootprint->GetFPID().GetLibItemName();
2519 
2520  FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
2521 
2522  // Quietly overwrite footprint and delete footprint file from path for any by same name.
2523  wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
2525 
2526  // Write through symlinks, don't replace them
2528 
2529  if( !fn.IsOk() )
2530  {
2531  THROW_IO_ERROR( wxString::Format( _( "Footprint file name '%s' is not valid." ),
2532  fn.GetFullPath() ) );
2533  }
2534 
2535  if( fn.FileExists() && !fn.IsFileWritable() )
2536  {
2537  THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete '%s'." ),
2538  fn.GetFullPath() ) );
2539  }
2540 
2541  wxString fullPath = fn.GetFullPath();
2542  wxString fullName = fn.GetFullName();
2543  FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
2544 
2545  if( it != footprints.end() )
2546  {
2547  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
2548  footprints.erase( footprintName );
2549  wxRemoveFile( fullPath );
2550  }
2551 
2552  // I need my own copy for the cache
2553  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() );
2554 
2555  // It's orientation should be zero and it should be on the front layer.
2556  footprint->SetOrientation( 0 );
2557 
2558  if( footprint->GetLayer() != F_Cu )
2559  {
2560  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
2561 
2562  if( cfg )
2563  footprint->Flip( footprint->GetPosition(), cfg->m_FlipLeftRight );
2564  else
2565  footprint->Flip( footprint->GetPosition(), false );
2566  }
2567 
2568  // Detach it from the board
2569  footprint->SetParent( nullptr );
2570 
2571  wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
2572  footprints.insert( footprintName,
2573  new FP_CACHE_ITEM( footprint, WX_FILENAME( fn.GetPath(), fullName ) ) );
2574  m_cache->Save( footprint );
2575 }
FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.cpp:112
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
Definition: pcb_plugin.cpp:166
const std::string KiCadFootprintFileExtension
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void init(const PROPERTIES *aProperties)
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1681
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1491
static void ResolvePossibleSymlinks(wxFileName &aFilename)
Definition: wx_filename.cpp:85
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define _(s)
const LIB_ID & GetFPID() const
Definition: footprint.h:195
Helper class for creating a footprint library cache.
Definition: pcb_plugin.cpp:69
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool IsWritable() const
Definition: pcb_plugin.cpp:108
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: wx_filename.h:36
std::map< wxString, FOOTPRINT * > FOOTPRINT_MAP
Definition: eagle_parser.h:50
Definition: layer_ids.h:71
wxPoint GetPosition() const override
Definition: footprint.h:187
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1293
bool Exists() const
Definition: pcb_plugin.cpp:110
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
Definition: pcb_plugin.h:128

References _, FOOTPRINT::Clone(), CTL_FOR_LIBRARY, FP_CACHE::Exists(), F_Cu, FOOTPRINT::Flip(), Format(), FP_CACHE::GetFootprints(), FOOTPRINT::GetFPID(), BOARD_ITEM::GetLayer(), LIB_ID::GetLibItemName(), FOOTPRINT::GetPosition(), init(), FP_CACHE::IsWritable(), KiCadFootprintFileExtension, Kiface(), m_cache, m_ctl, PCBNEW_SETTINGS::m_FlipLeftRight, WX_FILENAME::ResolvePossibleSymlinks(), FP_CACHE::Save(), FOOTPRINT::SetOrientation(), EDA_ITEM::SetParent(), THROW_IO_ERROR, traceKicadPcbPlugin, and validateCache().

◆ Format()

void PCB_PLUGIN::Format ( const BOARD_ITEM aItem,
int  aNestLevel = 0 
) const

Output aItem to aFormatter in s-expression format.

Parameters
aItemA pointer the an BOARD_ITEM object to format.
aNestLevelThe indentation nest level.
Exceptions
IO_ERRORon write error.

Definition at line 400 of file pcb_plugin.cpp.

401 {
402  LOCALE_IO toggle; // public API function, perform anything convenient for caller
403 
404  switch( aItem->Type() )
405  {
406  case PCB_T:
407  format( static_cast<const BOARD*>( aItem ), aNestLevel );
408  break;
409 
410  case PCB_DIM_ALIGNED_T:
411  case PCB_DIM_CENTER_T:
413  case PCB_DIM_LEADER_T:
414  format( static_cast<const PCB_DIMENSION_BASE*>( aItem ), aNestLevel );
415  break;
416 
417  case PCB_SHAPE_T:
418  format( static_cast<const PCB_SHAPE*>( aItem ), aNestLevel );
419  break;
420 
421  case PCB_FP_SHAPE_T:
422  format( static_cast<const FP_SHAPE*>( aItem ), aNestLevel );
423  break;
424 
425  case PCB_TARGET_T:
426  format( static_cast<const PCB_TARGET*>( aItem ), aNestLevel );
427  break;
428 
429  case PCB_FOOTPRINT_T:
430  format( static_cast<const FOOTPRINT*>( aItem ), aNestLevel );
431  break;
432 
433  case PCB_PAD_T:
434  format( static_cast<const PAD*>( aItem ), aNestLevel );
435  break;
436 
437  case PCB_TEXT_T:
438  format( static_cast<const PCB_TEXT*>( aItem ), aNestLevel );
439  break;
440 
441  case PCB_FP_TEXT_T:
442  format( static_cast<const FP_TEXT*>( aItem ), aNestLevel );
443  break;
444 
445  case PCB_GROUP_T:
446  format( static_cast<const PCB_GROUP*>( aItem ), aNestLevel );
447  break;
448 
449  case PCB_TRACE_T:
450  case PCB_ARC_T:
451  case PCB_VIA_T:
452  format( static_cast<const PCB_TRACK*>( aItem ), aNestLevel );
453  break;
454 
455  case PCB_FP_ZONE_T:
456  case PCB_ZONE_T:
457  format( static_cast<const ZONE*>( aItem ), aNestLevel );
458  break;
459 
460  default:
461  wxFAIL_MSG( wxT( "Cannot format item " ) + aItem->GetClass() );
462  }
463 }
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
Definition: typeinfo.h:84
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void format(const BOARD *aBoard, int aNestLevel=0) const
Definition: pcb_plugin.cpp:660
class ZONE, a copper pour area
Definition: typeinfo.h:105
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual wxString GetClass() const =0
Return the class name.
class ZONE, managed by a footprint
Definition: typeinfo.h:94
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References format(), EDA_ITEM::GetClass(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_PAD_T, PCB_SHAPE_T, PCB_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, and EDA_ITEM::Type().

Referenced by FOOTPRINT_EDIT_FRAME::ExportFootprint(), format(), CLIPBOARD_IO::Save(), FP_CACHE::Save(), Save(), and CLIPBOARD_IO::SaveSelection().

◆ format() [1/12]

void PCB_PLUGIN::format ( const BOARD aBoard,
int  aNestLevel = 0 
) const
private

Definition at line 660 of file pcb_plugin.cpp.

661 {
662  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->Footprints().begin(),
663  aBoard->Footprints().end() );
664  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->Drawings().begin(),
665  aBoard->Drawings().end() );
666  std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->Tracks().begin(),
667  aBoard->Tracks().end() );
668  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->Zones().begin(),
669  aBoard->Zones().end() );
670  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->Groups().begin(),
671  aBoard->Groups().end() );
672  formatHeader( aBoard, aNestLevel );
673 
674  // Save the footprints.
675  for( BOARD_ITEM* footprint : sorted_footprints )
676  {
677  Format( footprint, aNestLevel );
678  m_out->Print( 0, "\n" );
679  }
680 
681  // Save the graphical items on the board (not owned by a footprint)
682  for( BOARD_ITEM* item : sorted_drawings )
683  Format( item, aNestLevel );
684 
685  if( sorted_drawings.size() )
686  m_out->Print( 0, "\n" );
687 
688  // Do not save PCB_MARKERs, they can be regenerated easily.
689 
690  // Save the tracks and vias.
691  for( PCB_TRACK* track : sorted_tracks )
692  Format( track, aNestLevel );
693 
694  if( sorted_tracks.size() )
695  m_out->Print( 0, "\n" );
696 
697  // Save the polygon (which are the newer technology) zones.
698  for( auto zone : sorted_zones )
699  Format( zone, aNestLevel );
700 
701  // Save the groups
702  for( BOARD_ITEM* group : sorted_groups )
703  Format( group, aNestLevel );
704 }
ZONES & Zones()
Definition: board.h:240
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:254
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
Definition: pcb_plugin.cpp:642
FOOTPRINTS & Footprints()
Definition: board.h:234
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:400
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
DRAWINGS & Drawings()
Definition: board.h:237
TRACKS & Tracks()
Definition: board.h:231

References BOARD::Drawings(), BOARD::Footprints(), Format(), formatHeader(), group, BOARD::Groups(), m_out, OUTPUTFORMATTER::Print(), BOARD::Tracks(), and BOARD::Zones().

Referenced by Format().

◆ format() [2/12]

void PCB_PLUGIN::format ( const PCB_DIMENSION_BASE aDimension,
int  aNestLevel = 0 
) const
private

Definition at line 707 of file pcb_plugin.cpp.

708 {
709  const PCB_DIM_ALIGNED* aligned = dynamic_cast<const PCB_DIM_ALIGNED*>( aDimension );
710  const PCB_DIM_ORTHOGONAL* ortho = dynamic_cast<const PCB_DIM_ORTHOGONAL*>( aDimension );
711  const PCB_DIM_CENTER* center = dynamic_cast<const PCB_DIM_CENTER*>( aDimension );
712  const PCB_DIM_LEADER* leader = dynamic_cast<const PCB_DIM_LEADER*>( aDimension );
713 
714  m_out->Print( aNestLevel, "(dimension" );
715 
716  if( aDimension->IsLocked() )
717  m_out->Print( 0, " locked" );
718 
719  if( aDimension->Type() == PCB_DIM_ALIGNED_T )
720  m_out->Print( 0, " (type aligned)" );
721  else if( aDimension->Type() == PCB_DIM_LEADER_T )
722  m_out->Print( 0, " (type leader)" );
723  else if( aDimension->Type() == PCB_DIM_CENTER_T )
724  m_out->Print( 0, " (type center)" );
725  else if( aDimension->Type() == PCB_DIM_ORTHOGONAL_T )
726  m_out->Print( 0, " (type orthogonal)" );
727  else
728  wxFAIL_MSG( wxT( "Cannot format unknown dimension type!" ) );
729 
730  formatLayer( aDimension );
731 
732  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aDimension->m_Uuid.AsString() ) );
733 
734  m_out->Print( 0, "\n" );
735 
736  m_out->Print( aNestLevel+1, "(pts (xy %s %s) (xy %s %s))\n",
737  FormatInternalUnits( aDimension->GetStart().x ).c_str(),
738  FormatInternalUnits( aDimension->GetStart().y ).c_str(),
739  FormatInternalUnits( aDimension->GetEnd().x ).c_str(),
740  FormatInternalUnits( aDimension->GetEnd().y ).c_str() );
741 
742  if( aligned )
743  {
744  m_out->Print( aNestLevel+1, "(height %s)\n",
745  FormatInternalUnits( aligned->GetHeight() ).c_str() );
746  }
747 
748  if( ortho )
749  {
750  m_out->Print( aNestLevel+1, "(orientation %d)\n",
751  static_cast<int>( ortho->GetOrientation() ) );
752  }
753 
754  if( !center )
755  {
756  Format( &aDimension->Text(), aNestLevel + 1 );
757 
758  m_out->Print( aNestLevel + 1, "(format" );
759 
760  if( !aDimension->GetPrefix().IsEmpty() )
761  m_out->Print( 0, " (prefix %s)", m_out->Quotew( aDimension->GetPrefix() ).c_str() );
762 
763  if( !aDimension->GetSuffix().IsEmpty() )
764  m_out->Print( 0, " (suffix %s)", m_out->Quotew( aDimension->GetSuffix() ).c_str() );
765 
766  m_out->Print( 0, " (units %d) (units_format %d) (precision %d)",
767  static_cast<int>( aDimension->GetUnitsMode() ),
768  static_cast<int>( aDimension->GetUnitsFormat() ), aDimension->GetPrecision() );
769 
770  if( aDimension->GetOverrideTextEnabled() )
771  m_out->Print( 0, " (override_value %s)",
772  m_out->Quotew( aDimension->GetOverrideText() ).c_str() );
773 
774  if( aDimension->GetSuppressZeroes() )
775  m_out->Print( 0, " suppress_zeroes" );
776 
777  m_out->Print( 0, ")\n" );
778  }
779 
780  m_out->Print( aNestLevel+1, "(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
781  FormatInternalUnits( aDimension->GetLineThickness() ).c_str(),
782  FormatInternalUnits( aDimension->GetArrowLength() ).c_str(),
783  static_cast<int>( aDimension->GetTextPositionMode() ) );
784 
785  if( aligned )
786  {
787  m_out->Print( 0, " (extension_height %s)",
788  FormatInternalUnits( aligned->GetExtensionHeight() ).c_str() );
789  }
790 
791  if( leader )
792  m_out->Print( 0, " (text_frame %d)", static_cast<int>( leader->GetTextFrame() ) );
793 
794  m_out->Print( 0, " (extension_offset %s)",
795  FormatInternalUnits( aDimension->GetExtensionOffset() ).c_str() );
796 
797  if( aDimension->GetKeepTextAligned() )
798  m_out->Print( 0, " keep_text_aligned" );
799 
800  m_out->Print( 0, ")\n" );
801 
802  m_out->Print( aNestLevel, ")\n" );
803 }
bool GetKeepTextAligned() const
DIM_UNITS_FORMAT GetUnitsFormat() const
int GetHeight() const
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
PCB_TEXT & Text()
int GetExtensionOffset() const
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
wxString AsString() const
Definition: kiid.cpp:236
bool GetOverrideTextEnabled() const
virtual bool IsLocked() const
Definition: board_item.cpp:64
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
int GetPrecision() const
DIM_UNITS_MODE GetUnitsMode() const
For better understanding of the points that make a dimension:
wxString GetPrefix() const
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
DIM_TEXT_FRAME GetTextFrame() const
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
int GetExtensionHeight() const
int GetArrowLength() const
wxString GetSuffix() const
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
bool GetSuppressZeroes() const
Mark the center of a circle or arc with a cross shape.
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:400
const KIID m_Uuid
Definition: eda_item.h:474
A leader is a dimension-like object pointing to a specific point.
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
virtual const wxPoint & GetEnd() const
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
DIM_TEXT_POSITION GetTextPositionMode() const
int GetLineThickness() const
wxString GetOverrideText() const
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References KIID::AsString(), Format(), FormatInternalUnits(), formatLayer(), PCB_DIMENSION_BASE::GetArrowLength(), PCB_DIMENSION_BASE::GetEnd(), PCB_DIM_ALIGNED::GetExtensionHeight(), PCB_DIMENSION_BASE::GetExtensionOffset(), PCB_DIM_ALIGNED::GetHeight(), PCB_DIMENSION_BASE::GetKeepTextAligned(), PCB_DIMENSION_BASE::GetLineThickness(), PCB_DIMENSION_BASE::GetOverrideText(), PCB_DIMENSION_BASE::GetOverrideTextEnabled(), PCB_DIMENSION_BASE::GetPrecision(), PCB_DIMENSION_BASE::GetPrefix(), PCB_DIMENSION_BASE::GetStart(), PCB_DIMENSION_BASE::GetSuffix(), PCB_DIMENSION_BASE::GetSuppressZeroes(), PCB_DIM_LEADER::GetTextFrame(), PCB_DIMENSION_BASE::GetTextPositionMode(), PCB_DIMENSION_BASE::GetUnitsFormat(), PCB_DIMENSION_BASE::GetUnitsMode(), BOARD_ITEM::IsLocked(), m_out, EDA_ITEM::m_Uuid, ortho, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), PCB_DIMENSION_BASE::Text(), TO_UTF8, and EDA_ITEM::Type().

◆ format() [3/12]

void PCB_PLUGIN::format ( const FP_SHAPE aFPShape,
int  aNestLevel = 0 
) const
private

Definition at line 939 of file pcb_plugin.cpp.

940 {
941  std::string locked = aFPShape->IsLocked() ? " locked" : "";
942 
943  switch( aFPShape->GetShape() )
944  {
945  case SHAPE_T::SEGMENT:
946  m_out->Print( aNestLevel, "(fp_line%s (start %s) (end %s)",
947  locked.c_str(),
948  FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
949  FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
950  break;
951 
952  case SHAPE_T::RECT:
953  m_out->Print( aNestLevel, "(fp_rect%s (start %s) (end %s)",
954  locked.c_str(),
955  FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
956  FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
957  break;
958 
959  case SHAPE_T::CIRCLE:
960  m_out->Print( aNestLevel, "(fp_circle%s (center %s) (end %s)",
961  locked.c_str(),
962  FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
963  FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
964  break;
965 
966  case SHAPE_T::ARC:
967  m_out->Print( aNestLevel, "(fp_arc%s (start %s) (mid %s) (end %s)",
968  locked.c_str(),
969  FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
970  FormatInternalUnits( aFPShape->GetArcMid0() ).c_str(),
971  FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
972  break;
973 
974  case SHAPE_T::POLY:
975  if( aFPShape->IsPolyShapeValid() )
976  {
977  const SHAPE_POLY_SET& poly = aFPShape->GetPolyShape();
978  const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
979 
980  m_out->Print( aNestLevel, "(fp_poly%s (pts",
981  locked.c_str() );
982 
983  bool need_newline = false;
984 
985  for( int ii = 0; ii < outline.PointCount(); ++ii )
986  {
987  int nestLevel = 0;
988 
989  if( !( ii % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave )
990  {
991  // newline every 4 pts.
992  m_out->Print( 0, "\n" );
993  need_newline = false;
994  nestLevel = aNestLevel + 2;
995  }
996 
997  int ind = outline.ArcIndex( ii );
998 
999  if( ind < 0 )
1000  {
1001  m_out->Print( nestLevel, "%s(xy %s)",
1002  nestLevel ? "" : " ",
1003  FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
1004  need_newline = true;
1005  }
1006  else
1007  {
1008  auto& arc = outline.Arc( ind );
1009  m_out->Print( nestLevel, "%s(arc (start %s) (mid %s) (end %s))",
1010  nestLevel ? "" : " ",
1011  FormatInternalUnits( arc.GetP0() ).c_str(),
1012  FormatInternalUnits( arc.GetArcMid() ).c_str(),
1013  FormatInternalUnits( arc.GetP1() ).c_str() );
1014  need_newline = true;
1015 
1016  do
1017  {
1018  ++ii;
1019  } while( ii < outline.PointCount() && outline.ArcIndex( ii ) == ind );
1020 
1021  --ii;
1022  }
1023  }
1024 
1025  if( need_newline )
1026  m_out->Print( 0, "\n" );
1027 
1028  m_out->Print( aNestLevel + 1, ")" );
1029  }
1030  else
1031  {
1032  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
1033  return;
1034  }
1035  break;
1036 
1037  case SHAPE_T::BEZIER:
1038  m_out->Print( aNestLevel, "(fp_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1039  locked.c_str(),
1040  FormatInternalUnits( aFPShape->GetStart0() ).c_str(),
1041  FormatInternalUnits( aFPShape->GetBezierC1_0() ).c_str(),
1042  FormatInternalUnits( aFPShape->GetBezierC2_0() ).c_str(),
1043  FormatInternalUnits( aFPShape->GetEnd0() ).c_str() );
1044  break;
1045 
1046  default:
1047  wxFAIL_MSG( wxT( "PCB_PLUGIN::format not implemented for " ) + aFPShape->SHAPE_T_asString() );
1048  return;
1049  };
1050 
1051  formatLayer( aFPShape );
1052 
1053  m_out->Print( 0, " (width %s)", FormatInternalUnits( aFPShape->GetWidth() ).c_str() );
1054 
1055  // The filled flag represents if a solid fill is present on circles, rectangles and polygons
1056  if( ( aFPShape->GetShape() == SHAPE_T::POLY )
1057  || ( aFPShape->GetShape() == SHAPE_T::RECT )
1058  || ( aFPShape->GetShape() == SHAPE_T::CIRCLE ) )
1059  {
1060  if( aFPShape->IsFilled() )
1061  m_out->Print( 0, " (fill solid)" );
1062  else
1063  m_out->Print( 0, " (fill none)" );
1064  }
1065 
1066  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aFPShape->m_Uuid.AsString() ) );
1067 
1068  m_out->Print( 0, ")\n" );
1069 }
const SHAPE_ARC & Arc(size_t aArc) const
int GetWidth() const
Definition: eda_shape.h:98
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
const wxPoint & GetStart0() const
Definition: fp_shape.h:112
wxString AsString() const
Definition: kiid.cpp:236
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1210
virtual bool IsLocked() const
Definition: board_item.cpp:64
int PointCount() const
Return the number of points (vertices) in this line chain.
bool IsFilled() const
Definition: eda_shape.h:90
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
wxPoint GetArcMid0() const
Definition: fp_shape.cpp:180
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:227
const KIID m_Uuid
Definition: eda_item.h:474
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const wxPoint & GetEnd0() const
Definition: fp_shape.h:115
const wxPoint & GetBezierC2_0() const
Definition: fp_shape.h:121
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
SHAPE_T GetShape() const
Definition: eda_shape.h:101
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
const wxPoint & GetBezierC1_0() const
Definition: fp_shape.h:118
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480

References ARC, SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), KIID::AsString(), BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoint(), FormatInternalUnits(), formatLayer(), FP_SHAPE::GetArcMid0(), FP_SHAPE::GetBezierC1_0(), FP_SHAPE::GetBezierC2_0(), ADVANCED_CFG::GetCfg(), FP_SHAPE::GetEnd0(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), FP_SHAPE::GetStart0(), EDA_SHAPE::GetWidth(), EDA_SHAPE::IsFilled(), BOARD_ITEM::IsLocked(), EDA_SHAPE::IsPolyShapeValid(), locked, ADVANCED_CFG::m_CompactSave, m_out, EDA_ITEM::m_Uuid, SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::PointCount(), POLY, OUTPUTFORMATTER::Print(), RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and TO_UTF8.

◆ format() [4/12]

void PCB_PLUGIN::format ( const PCB_GROUP aGroup,
int  aNestLevel = 0 
) const
private

Definition at line 1769 of file pcb_plugin.cpp.

1770 {
1771  // Don't write empty groups
1772  if( aGroup->GetItems().empty() )
1773  return;
1774 
1775  m_out->Print( aNestLevel, "(group %s%s (id %s)\n",
1776  m_out->Quotew( aGroup->GetName() ).c_str(),
1777  aGroup->IsLocked() ? " locked" : "",
1778  TO_UTF8( aGroup->m_Uuid.AsString() ) );
1779 
1780  m_out->Print( aNestLevel + 1, "(members\n" );
1781 
1782  wxArrayString memberIds;
1783 
1784  for( BOARD_ITEM* member : aGroup->GetItems() )
1785  memberIds.Add( member->m_Uuid.AsString() );
1786 
1787  memberIds.Sort();
1788 
1789  for( const wxString& memberId : memberIds )
1790  m_out->Print( aNestLevel + 2, "%s\n", TO_UTF8( memberId ) );
1791 
1792  m_out->Print( aNestLevel + 1, ")\n" ); // Close `members` token.
1793  m_out->Print( aNestLevel, ")\n" ); // Close `group` token.
1794 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
wxString AsString() const
Definition: kiid.cpp:236
virtual bool IsLocked() const
Definition: board_item.cpp:64
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxString GetName() const
Definition: pcb_group.h:65
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const KIID m_Uuid
Definition: eda_item.h:474
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References KIID::AsString(), PCB_GROUP::GetItems(), PCB_GROUP::GetName(), BOARD_ITEM::IsLocked(), m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and TO_UTF8.

◆ format() [5/12]

void PCB_PLUGIN::format ( const PCB_SHAPE aSegment,
int  aNestLevel = 0 
) const
private

Definition at line 806 of file pcb_plugin.cpp.

807 {
808  std::string locked = aShape->IsLocked() ? " locked" : "";
809 
810  switch( aShape->GetShape() )
811  {
812  case SHAPE_T::SEGMENT:
813  m_out->Print( aNestLevel, "(gr_line%s (start %s) (end %s)",
814  locked.c_str(),
815  FormatInternalUnits( aShape->GetStart() ).c_str(),
816  FormatInternalUnits( aShape->GetEnd() ).c_str() );
817  break;
818 
819  case SHAPE_T::RECT:
820  m_out->Print( aNestLevel, "(gr_rect%s (start %s) (end %s)",
821  locked.c_str(),
822  FormatInternalUnits( aShape->GetStart() ).c_str(),
823  FormatInternalUnits( aShape->GetEnd() ).c_str() );
824  break;
825 
826  case SHAPE_T::CIRCLE:
827  m_out->Print( aNestLevel, "(gr_circle%s (center %s) (end %s)",
828  locked.c_str(),
829  FormatInternalUnits( aShape->GetStart() ).c_str(),
830  FormatInternalUnits( aShape->GetEnd() ).c_str() );
831  break;
832 
833  case SHAPE_T::ARC:
834  m_out->Print( aNestLevel, "(gr_arc%s (start %s) (mid %s) (end %s)",
835  locked.c_str(),
836  FormatInternalUnits( aShape->GetStart() ).c_str(),
837  FormatInternalUnits( aShape->GetArcMid() ).c_str(),
838  FormatInternalUnits( aShape->GetEnd() ).c_str() );
839  break;
840 
841  case SHAPE_T::POLY:
842  if( aShape->IsPolyShapeValid() )
843  {
844  const SHAPE_POLY_SET& poly = aShape->GetPolyShape();
845  const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
846 
847  m_out->Print( aNestLevel, "(gr_poly%s\n", locked.c_str() );
848  m_out->Print( aNestLevel + 1, "(pts\n" );
849 
850  bool needNewline = false;
851  int nestLevel = aNestLevel + 2;
852  int shapesAdded = 0;
853 
854  for( int ii = 0; ii < outline.PointCount(); ++ii )
855  {
856  int ind = outline.ArcIndex( ii );
857 
858  if( ind < 0 )
859  {
860  m_out->Print( nestLevel, "(xy %s)",
861  FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
862  needNewline = true;
863  }
864  else
865  {
866  const SHAPE_ARC& arc = outline.Arc( ind );
867  m_out->Print( nestLevel, "(arc (start %s) (mid %s) (end %s))",
868  FormatInternalUnits( arc.GetP0() ).c_str(),
869  FormatInternalUnits( arc.GetArcMid() ).c_str(),
870  FormatInternalUnits( arc.GetP1() ).c_str() );
871  needNewline = true;
872 
873  do
874  {
875  ++ii;
876  } while( ii < outline.PointCount() && outline.ArcIndex( ii ) == ind );
877 
878  --ii;
879  }
880 
881  ++shapesAdded;
882 
883  if( !( shapesAdded % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave )
884  {
885  // newline every 4 shapes if compact save
886  m_out->Print( 0, "\n" );
887  needNewline = false;
888  }
889  }
890 
891  if( needNewline )
892  m_out->Print( 0, "\n" );
893 
894  m_out->Print( aNestLevel + 1, ")" );
895  }
896  else
897  {
898  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
899  return;
900  }
901 
902  break;
903 
904  case SHAPE_T::BEZIER:
905  m_out->Print( aNestLevel, "(gr_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))",
906  locked.c_str(),
907  FormatInternalUnits( aShape->GetStart() ).c_str(),
908  FormatInternalUnits( aShape->GetBezierC1() ).c_str(),
909  FormatInternalUnits( aShape->GetBezierC2() ).c_str(),
910  FormatInternalUnits( aShape->GetEnd() ).c_str() );
911  break;
912 
913  default:
914  UNIMPLEMENTED_FOR( aShape->SHAPE_T_asString() );
915  return;
916  };
917 
918  formatLayer( aShape );
919 
920  m_out->Print( 0, " (width %s)", FormatInternalUnits( aShape->GetWidth() ).c_str() );
921 
922  // The filled flag represents if a solid fill is present on circles, rectangles and polygons
923  if( ( aShape->GetShape() == SHAPE_T::POLY )
924  || ( aShape->GetShape() == SHAPE_T::RECT )
925  || ( aShape->GetShape() == SHAPE_T::CIRCLE ) )
926  {
927  if( aShape->IsFilled() )
928  m_out->Print( 0, " (fill solid)" );
929  else
930  m_out->Print( 0, " (fill none)" );
931  }
932 
933  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aShape->m_Uuid.AsString() ) );
934 
935  m_out->Print( 0, ")\n" );
936 }
const SHAPE_ARC & Arc(size_t aArc) const
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:113
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480

References ARC, SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), KIID::AsString(), BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoint(), FormatInternalUnits(), formatLayer(), SHAPE_ARC::GetArcMid(), EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), ADVANCED_CFG::GetCfg(), EDA_SHAPE::GetEnd(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), EDA_SHAPE::IsFilled(), BOARD_ITEM::IsLocked(), EDA_SHAPE::IsPolyShapeValid(), locked, ADVANCED_CFG::m_CompactSave, m_out, EDA_ITEM::m_Uuid, SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::PointCount(), POLY, OUTPUTFORMATTER::Print(), RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), TO_UTF8, and UNIMPLEMENTED_FOR.

◆ format() [6/12]

void PCB_PLUGIN::format ( const PCB_TARGET aTarget,
int  aNestLevel = 0 
) const
private

Definition at line 1072 of file pcb_plugin.cpp.

1073 {
1074  m_out->Print( aNestLevel, "(target %s (at %s) (size %s)",
1075  ( aTarget->GetShape() ) ? "x" : "plus",
1076  FormatInternalUnits( aTarget->GetPosition() ).c_str(),
1077  FormatInternalUnits( aTarget->GetSize() ).c_str() );
1078 
1079  if( aTarget->GetWidth() != 0 )
1080  m_out->Print( 0, " (width %s)", FormatInternalUnits( aTarget->GetWidth() ).c_str() );
1081 
1082  formatLayer( aTarget );
1083 
1084  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTarget->m_Uuid.AsString() ) );
1085 
1086  m_out->Print( 0, ")\n" );
1087 }
int GetSize() const
Definition: pcb_target.h:62
wxString AsString() const
Definition: kiid.cpp:236
wxPoint GetPosition() const override
Definition: pcb_target.h:56
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
int GetWidth() const
Definition: pcb_target.h:65
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const KIID m_Uuid
Definition: eda_item.h:474
int GetShape() const
Definition: pcb_target.h:59
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480

References KIID::AsString(), FormatInternalUnits(), formatLayer(), PCB_TARGET::GetPosition(), PCB_TARGET::GetShape(), PCB_TARGET::GetSize(), PCB_TARGET::GetWidth(), m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

◆ format() [7/12]

void PCB_PLUGIN::format ( const FOOTPRINT aFootprint,
int  aNestLevel = 0 
) const
private

Definition at line 1090 of file pcb_plugin.cpp.

1091 {
1092  if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
1093  {
1094  const wxArrayString* initial_comments = aFootprint->GetInitialComments();
1095 
1096  if( initial_comments )
1097  {
1098  for( unsigned i = 0; i < initial_comments->GetCount(); ++i )
1099  m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) );
1100 
1101  m_out->Print( 0, "\n" ); // improve readability?
1102  }
1103  }
1104 
1105  if( m_ctl & CTL_OMIT_LIBNAME )
1106  m_out->Print( aNestLevel, "(footprint %s",
1107  m_out->Quotes( aFootprint->GetFPID().GetLibItemName() ).c_str() );
1108  else
1109  m_out->Print( aNestLevel, "(footprint %s",
1110  m_out->Quotes( aFootprint->GetFPID().Format() ).c_str() );
1111 
1112  if( !( m_ctl & CTL_OMIT_FOOTPRINT_VERSION ) )
1113  m_out->Print( 0, " (version %d) (generator pcbnew)\n ", SEXPR_BOARD_FILE_VERSION );
1114 
1115  if( aFootprint->IsLocked() )
1116  m_out->Print( 0, " locked" );
1117 
1118  if( aFootprint->IsPlaced() )
1119  m_out->Print( 0, " placed" );
1120 
1121  formatLayer( aFootprint );
1122 
1123  m_out->Print( 0, "\n" );
1124  m_out->Print( aNestLevel+1, "(tedit %lX)", (unsigned long)aFootprint->GetLastEditTime() );
1125 
1126  if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
1127  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aFootprint->m_Uuid.AsString() ) );
1128 
1129  m_out->Print( 0, "\n" );
1130 
1131  if( !( m_ctl & CTL_OMIT_AT ) )
1132  {
1133  m_out->Print( aNestLevel+1, "(at %s",
1134  FormatInternalUnits( aFootprint->GetPosition() ).c_str() );
1135 
1136  if( aFootprint->GetOrientation() != 0.0 )
1137  m_out->Print( 0, " %s", FormatAngle( aFootprint->GetOrientation() ).c_str() );
1138 
1139  m_out->Print( 0, ")\n" );
1140  }
1141 
1142  if( !aFootprint->GetDescription().IsEmpty() )
1143  m_out->Print( aNestLevel+1, "(descr %s)\n",
1144  m_out->Quotew( aFootprint->GetDescription() ).c_str() );
1145 
1146  if( !aFootprint->GetKeywords().IsEmpty() )
1147  m_out->Print( aNestLevel+1, "(tags %s)\n",
1148  m_out->Quotew( aFootprint->GetKeywords() ).c_str() );
1149 
1150  const std::map<wxString, wxString>& props = aFootprint->GetProperties();
1151 
1152  for( const std::pair<const wxString, wxString>& prop : props )
1153  {
1154  m_out->Print( aNestLevel+1, "(property %s %s)\n",
1155  m_out->Quotew( prop.first ).c_str(),
1156  m_out->Quotew( prop.second ).c_str() );
1157  }
1158 
1159  if( !( m_ctl & CTL_OMIT_PATH ) && !aFootprint->GetPath().empty() )
1160  m_out->Print( aNestLevel+1, "(path %s)\n",
1161  m_out->Quotew( aFootprint->GetPath().AsString() ).c_str() );
1162 
1163  if( aFootprint->GetPlacementCost90() != 0 )
1164  m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aFootprint->GetPlacementCost90() );
1165 
1166  if( aFootprint->GetPlacementCost180() != 0 )
1167  m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aFootprint->GetPlacementCost180() );
1168 
1169  if( aFootprint->GetLocalSolderMaskMargin() != 0 )
1170  m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
1171  FormatInternalUnits( aFootprint->GetLocalSolderMaskMargin() ).c_str() );
1172 
1173  if( aFootprint->GetLocalSolderPasteMargin() != 0 )
1174  m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
1175  FormatInternalUnits( aFootprint->GetLocalSolderPasteMargin() ).c_str() );
1176 
1177  if( aFootprint->GetLocalSolderPasteMarginRatio() != 0 )
1178  m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
1179  Double2Str( aFootprint->GetLocalSolderPasteMarginRatio() ).c_str() );
1180 
1181  if( aFootprint->GetLocalClearance() != 0 )
1182  m_out->Print( aNestLevel+1, "(clearance %s)\n",
1183  FormatInternalUnits( aFootprint->GetLocalClearance() ).c_str() );
1184 
1185  if( aFootprint->GetZoneConnection() != ZONE_CONNECTION::INHERITED )
1186  m_out->Print( aNestLevel+1, "(zone_connect %d)\n",
1187  static_cast<int>( aFootprint->GetZoneConnection() ) );
1188 
1189  if( aFootprint->GetThermalWidth() != 0 )
1190  m_out->Print( aNestLevel+1, "(thermal_width %s)\n",
1191  FormatInternalUnits( aFootprint->GetThermalWidth() ).c_str() );
1192 
1193  if( aFootprint->GetThermalGap() != 0 )
1194  m_out->Print( aNestLevel+1, "(thermal_gap %s)\n",
1195  FormatInternalUnits( aFootprint->GetThermalGap() ).c_str() );
1196 
1197  // Attributes
1198  if( aFootprint->GetAttributes() )
1199  {
1200  m_out->Print( aNestLevel+1, "(attr" );
1201 
1202  if( aFootprint->GetAttributes() & FP_SMD )
1203  m_out->Print( 0, " smd" );
1204 
1205  if( aFootprint->GetAttributes() & FP_THROUGH_HOLE )
1206  m_out->Print( 0, " through_hole" );
1207 
1208  if( aFootprint->GetAttributes() & FP_BOARD_ONLY )
1209  m_out->Print( 0, " board_only" );
1210 
1211  if( aFootprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES )
1212  m_out->Print( 0, " exclude_from_pos_files" );
1213 
1214  if( aFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM )
1215  m_out->Print( 0, " exclude_from_bom" );
1216 
1217  m_out->Print( 0, ")\n" );
1218  }
1219 
1220  Format( (BOARD_ITEM*) &aFootprint->Reference(), aNestLevel + 1 );
1221  Format( (BOARD_ITEM*) &aFootprint->Value(), aNestLevel + 1 );
1222 
1223  std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->Pads().begin(),
1224  aFootprint->Pads().end() );
1225  std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1226  aFootprint->GraphicalItems().begin(),
1227  aFootprint->GraphicalItems().end() );
1228  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aFootprint->Zones().begin(),
1229  aFootprint->Zones().end() );
1230  std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->Groups().begin(),
1231  aFootprint->Groups().end() );
1232 
1233  // Save drawing elements.
1234 
1235  for( BOARD_ITEM* gr : sorted_drawings )
1236  Format( gr, aNestLevel+1 );
1237 
1238  // Save pads.
1239  for( PAD* pad : sorted_pads )
1240  Format( pad, aNestLevel+1 );
1241 
1242  // Save zones.
1243  for( BOARD_ITEM* zone : sorted_zones )
1244  Format( zone, aNestLevel + 1 );
1245 
1246  // Save groups.
1247  for( BOARD_ITEM* group : sorted_groups )
1248  Format( group, aNestLevel + 1 );
1249 
1250  // Save 3D info.
1251  auto bs3D = aFootprint->Models().begin();
1252  auto es3D = aFootprint->Models().end();
1253 
1254  while( bs3D != es3D )
1255  {
1256  if( !bs3D->m_Filename.IsEmpty() )
1257  {
1258  m_out->Print( aNestLevel+1, "(model %s%s\n",
1259  m_out->Quotew( bs3D->m_Filename ).c_str(),
1260  bs3D->m_Show ? "" : " hide" );
1261 
1262  if( bs3D->m_Opacity != 1.0 )
1263  m_out->Print( aNestLevel+2, "(opacity %0.4f)", bs3D->m_Opacity );
1264 
1265  m_out->Print( aNestLevel+2, "(offset (xyz %s %s %s))\n",
1266  Double2Str( bs3D->m_Offset.x ).c_str(),
1267  Double2Str( bs3D->m_Offset.y ).c_str(),
1268  Double2Str( bs3D->m_Offset.z ).c_str() );
1269 
1270  m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
1271  Double2Str( bs3D->m_Scale.x ).c_str(),
1272  Double2Str( bs3D->m_Scale.y ).c_str(),
1273  Double2Str( bs3D->m_Scale.z ).c_str() );
1274 
1275  m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
1276  Double2Str( bs3D->m_Rotation.x ).c_str(),
1277  Double2Str( bs3D->m_Rotation.y ).c_str(),
1278  Double2Str( bs3D->m_Rotation.z ).c_str() );
1279 
1280  m_out->Print( aNestLevel+1, ")\n" );
1281  }
1282 
1283  ++bs3D;
1284  }
1285 
1286  m_out->Print( aNestLevel, ")\n" );
1287 }
bool IsLocked() const override
Definition: footprint.h:297
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
Definition: pcb_plugin.h:105
const wxString & GetDescription() const
Definition: footprint.h:201
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:183
const KIID_PATH & GetPath() const
Definition: footprint.h:207
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
Definition: pcb_plugin.h:113
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int GetPlacementCost180() const
Definition: footprint.h:581
double GetOrientation() const
Definition: footprint.h:191
wxString AsString() const
Definition: kiid.cpp:236
#define CTL_OMIT_FOOTPRINT_VERSION
Omit the version string from the (footprint)
Definition: pcb_plugin.h:119
virtual std::string Quotes(const std::string &aWrapee) const
Check aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:455
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
Definition: pcb_plugin.h:111
timestamp_t GetLastEditTime() const
Definition: footprint.h:346
PADS & Pads()
Definition: footprint.h:169
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:502
FP_TEXT & Reference()
Definition: footprint.h:503
#define CTL_OMIT_LIBNAME
Omit lib alias when saving (used for.
Definition: pcb_plugin.h:117
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
FP_ZONES & Zones()
Definition: footprint.h:175
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:515
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
#define CTL_OMIT_INITIAL_COMMENTS
omit FOOTPRINT initial comments
Definition: pcb_plugin.h:112
int GetLocalClearance() const
Definition: footprint.h:213
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
bool IsPlaced() const
Definition: footprint.h:315
const LIB_ID & GetFPID() const
Definition: footprint.h:195
const wxString & GetKeywords() const
Definition: footprint.h:204
int GetThermalWidth() const
Definition: footprint.h:234
UTF8 Format() const
Definition: lib_id.cpp:116
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:400
const KIID m_Uuid
Definition: eda_item.h:474
const wxArrayString * GetInitialComments() const
Definition: footprint.h:691
FP_GROUPS & Groups()
Definition: footprint.h:178
#define CTL_OMIT_AT
Omit position and rotation.
Definition: pcb_plugin.h:114
int GetLocalSolderMaskMargin() const
Definition: footprint.h:210
int GetAttributes() const
Definition: footprint.h:239
wxString AsString() const
Definition: kiid.cpp:316
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
wxPoint GetPosition() const override
Definition: footprint.h:187
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:227
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:509
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:231
int GetPlacementCost90() const
Definition: footprint.h:584
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int GetLocalSolderPasteMargin() const
Definition: footprint.h:224
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
Definition: pad.h:57
int GetThermalGap() const
Definition: footprint.h:237
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References KIID::AsString(), KIID_PATH::AsString(), CTL_OMIT_AT, CTL_OMIT_FOOTPRINT_VERSION, CTL_OMIT_INITIAL_COMMENTS, CTL_OMIT_LIBNAME, CTL_OMIT_PATH, CTL_OMIT_TSTAMPS, Double2Str(), LIB_ID::Format(), Format(), FormatAngle(), FormatInternalUnits(), formatLayer(), FP_BOARD_ONLY, FP_EXCLUDE_FROM_BOM, FP_EXCLUDE_FROM_POS_FILES, FP_SMD, FP_THROUGH_HOLE, FOOTPRINT::GetAttributes(), FOOTPRINT::GetDescription(), FOOTPRINT::GetFPID(), FOOTPRINT::GetInitialComments(), FOOTPRINT::GetKeywords(), FOOTPRINT::GetLastEditTime(), LIB_ID::GetLibItemName(), FOOTPRINT::GetLocalClearance(), FOOTPRINT::GetLocalSolderMaskMargin(), FOOTPRINT::GetLocalSolderPasteMargin(), FOOTPRINT::GetLocalSolderPasteMarginRatio(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPath(), FOOTPRINT::GetPlacementCost180(), FOOTPRINT::GetPlacementCost90(), FOOTPRINT::GetPosition(), FOOTPRINT::GetProperties(), FOOTPRINT::GetThermalGap(), FOOTPRINT::GetThermalWidth(), FOOTPRINT::GetZoneConnection(), FOOTPRINT::GraphicalItems(), group, FOOTPRINT::Groups(), INHERITED, FOOTPRINT::IsLocked(), FOOTPRINT::IsPlaced(), m_ctl, m_out, EDA_ITEM::m_Uuid, FOOTPRINT::Models(), pad, FOOTPRINT::Pads(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotes(), OUTPUTFORMATTER::Quotew(), FOOTPRINT::Reference(), SEXPR_BOARD_FILE_VERSION, TO_UTF8, FOOTPRINT::Value(), and FOOTPRINT::Zones().

◆ format() [8/12]

void PCB_PLUGIN::format ( const PAD aPad,
int  aNestLevel = 0 
) const
private

Definition at line 1376 of file pcb_plugin.cpp.

1377 {
1378  const char* shape;
1379 
1380  switch( aPad->GetShape() )
1381  {
1382  case PAD_SHAPE::CIRCLE: shape = "circle"; break;
1383  case PAD_SHAPE::RECT: shape = "rect"; break;
1384  case PAD_SHAPE::OVAL: shape = "oval"; break;
1385  case PAD_SHAPE::TRAPEZOID: shape = "trapezoid"; break;
1387  case PAD_SHAPE::ROUNDRECT: shape = "roundrect"; break;
1388  case PAD_SHAPE::CUSTOM: shape = "custom"; break;
1389 
1390  default:
1391  THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), aPad->GetShape() ) );
1392  }
1393 
1394  const char* type;
1395 
1396  switch( aPad->GetAttribute() )
1397  {
1398  case PAD_ATTRIB::PTH: type = "thru_hole"; break;
1399  case PAD_ATTRIB::SMD: type = "smd"; break;
1400  case PAD_ATTRIB::CONN: type = "connect"; break;
1401  case PAD_ATTRIB::NPTH: type = "np_thru_hole"; break;
1402 
1403  default:
1404  THROW_IO_ERROR( wxString::Format( wxT( "unknown pad attribute: %d" ),
1405  aPad->GetAttribute() ) );
1406  }
1407 
1408  const char* property = nullptr;
1409 
1410  switch( aPad->GetProperty() )
1411  {
1412  case PAD_PROP::NONE: break; // could be "none"
1413  case PAD_PROP::BGA: property = "pad_prop_bga"; break;
1414  case PAD_PROP::FIDUCIAL_GLBL: property = "pad_prop_fiducial_glob"; break;
1415  case PAD_PROP::FIDUCIAL_LOCAL: property = "pad_prop_fiducial_loc"; break;
1416  case PAD_PROP::TESTPOINT: property = "pad_prop_testpoint"; break;
1417  case PAD_PROP::HEATSINK: property = "pad_prop_heatsink"; break;
1418  case PAD_PROP::CASTELLATED: property = "pad_prop_castellated"; break;
1419 
1420  default:
1421  THROW_IO_ERROR( wxString::Format( wxT( "unknown pad property: %d" ),
1422  aPad->GetProperty() ) );
1423  }
1424 
1425  m_out->Print( aNestLevel, "(pad %s %s %s",
1426  m_out->Quotew( aPad->GetNumber() ).c_str(),
1427  type,
1428  shape );
1429 
1430  if( aPad->IsLocked() )
1431  m_out->Print( 0, " locked" );
1432 
1433  m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() );
1434 
1435  if( aPad->GetOrientation() != 0.0 )
1436  m_out->Print( 0, " %s", FormatAngle( aPad->GetOrientation() ).c_str() );
1437 
1438  m_out->Print( 0, ")" );
1439 
1440  m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() );
1441 
1442  if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
1443  m_out->Print( 0, " (rect_delta %s)", FormatInternalUnits( aPad->GetDelta() ).c_str() );
1444 
1445  wxSize sz = aPad->GetDrillSize();
1446  wxPoint shapeoffset = aPad->GetOffset();
1447 
1448  if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
1449  (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1450  {
1451  m_out->Print( 0, " (drill" );
1452 
1453  if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1454  m_out->Print( 0, " oval" );
1455 
1456  if( sz.GetWidth() > 0 )
1457  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetWidth() ).c_str() );
1458 
1459  if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
1460  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetHeight() ).c_str() );
1461 
1462  if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1463  m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() );
1464 
1465  m_out->Print( 0, ")" );
1466  }
1467 
1468  // Add pad property, if exists.
1469  if( property )
1470  m_out->Print( 0, " (property %s)", property );
1471 
1472  formatLayers( aPad->GetLayerSet() );
1473 
1474  if( aPad->GetAttribute() == PAD_ATTRIB::PTH )
1475  {
1476  if( aPad->GetRemoveUnconnected() )
1477  {
1478  m_out->Print( 0, " (remove_unused_layers)" );
1479 
1480  if( aPad->GetKeepTopBottom() )
1481  m_out->Print( 0, " (keep_end_layers)" );
1482  }
1483  }
1484 
1485  // Output the radius ratio for rounded and chamfered rect pads
1486  if( aPad->GetShape() == PAD_SHAPE::ROUNDRECT || aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1487  {
1488  m_out->Print( 0, " (roundrect_rratio %s)",
1489  Double2Str( aPad->GetRoundRectRadiusRatio() ).c_str() );
1490  }
1491 
1492  // Output the chamfer corners for chamfered rect pads
1493  if( aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1494  {
1495  m_out->Print( 0, "\n" );
1496 
1497  m_out->Print( aNestLevel+1, "(chamfer_ratio %s)",
1498  Double2Str( aPad->GetChamferRectRatio() ).c_str() );
1499 
1500  m_out->Print( 0, " (chamfer" );
1501 
1502  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT ) )
1503  m_out->Print( 0, " top_left" );
1504 
1505  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT ) )
1506  m_out->Print( 0, " top_right" );
1507 
1508  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT ) )
1509  m_out->Print( 0, " bottom_left" );
1510 
1512  m_out->Print( 0, " bottom_right" );
1513 
1514  m_out->Print( 0, ")" );
1515  }
1516 
1517  std::string output;
1518 
1519  // Unconnected pad is default net so don't save it.
1520  if( !( m_ctl & CTL_OMIT_PAD_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED )
1521  {
1522  StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
1523  m_out->Quotew( aPad->GetNetname() ).c_str() );
1524  }
1525 
1526  // Pin functions and types are closely related to nets, so if CTL_OMIT_NETS is set, omit
1527  // them as well (for instance when saved from library editor).
1528  if( !( m_ctl & CTL_OMIT_PAD_NETS ) )
1529  {
1530  if( !aPad->GetPinFunction().IsEmpty() )
1531  {
1532  StrPrintf( &output, " (pinfunction %s)",
1533  m_out->Quotew( aPad->GetPinFunction() ).c_str() );
1534  }
1535 
1536  if( !aPad->GetPinType().IsEmpty() )
1537  {
1538  StrPrintf( &output, " (pintype %s)",
1539  m_out->Quotew( aPad->GetPinType() ).c_str() );
1540  }
1541  }
1542 
1543  if( aPad->GetPadToDieLength() != 0 )
1544  {
1545  StrPrintf( &output, " (die_length %s)",
1546  FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() );
1547  }
1548 
1549  if( aPad->GetLocalSolderMaskMargin() != 0 )
1550  {
1551  StrPrintf( &output, " (solder_mask_margin %s)",
1552  FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() );
1553  }
1554 
1555  if( aPad->GetLocalSolderPasteMargin() != 0 )
1556  {
1557  StrPrintf( &output, " (solder_paste_margin %s)",
1558  FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() );
1559  }
1560 
1561  if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
1562  {
1563  StrPrintf( &output, " (solder_paste_margin_ratio %s)",
1564  Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() );
1565  }
1566 
1567  if( aPad->GetLocalClearance() != 0 )
1568  {
1569  StrPrintf( &output, " (clearance %s)",
1570  FormatInternalUnits( aPad->GetLocalClearance() ).c_str() );
1571  }
1572 
1574  {
1575  StrPrintf( &output, " (zone_connect %d)",
1576  static_cast<int>( aPad->GetZoneConnection() ) );
1577  }
1578 
1579  if( aPad->GetThermalSpokeWidth() != 0 )
1580  {
1581  StrPrintf( &output, " (thermal_width %s)",
1582  FormatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() );
1583  }
1584 
1585  if( aPad->GetThermalGap() != 0 )
1586  {
1587  StrPrintf( &output, " (thermal_gap %s)",
1588  FormatInternalUnits( aPad->GetThermalGap() ).c_str() );
1589  }
1590 
1591  if( output.size() )
1592  {
1593  m_out->Print( 0, "\n" );
1594  m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
1595  }
1596 
1597  if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
1598  {
1599  m_out->Print( 0, "\n");
1600  m_out->Print( aNestLevel+1, "(options" );
1601 
1603  m_out->Print( 0, " (clearance convexhull)" );
1604  #if 1 // Set to 1 to output the default option
1605  else
1606  m_out->Print( 0, " (clearance outline)" );
1607  #endif
1608 
1609  // Output the anchor pad shape (circle/rect)
1610  if( aPad->GetAnchorPadShape() == PAD_SHAPE::RECT )
1611  shape = "rect";
1612  else
1613  shape = "circle";
1614 
1615  m_out->Print( 0, " (anchor %s)", shape );
1616 
1617  m_out->Print( 0, ")"); // end of (options ...
1618 
1619  // Output graphic primitive of the pad shape
1620  m_out->Print( 0, "\n");
1621  m_out->Print( aNestLevel+1, "(primitives" );
1622 
1623  int nested_level = aNestLevel+2;
1624 
1625  // Output all basic shapes
1626  for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
1627  {
1628  m_out->Print( 0, "\n");
1629 
1630  switch( primitive->GetShape() )
1631  {
1632  case SHAPE_T::SEGMENT:
1633  m_out->Print( nested_level, "(gr_line (start %s) (end %s)",
1634  FormatInternalUnits( primitive->GetStart() ).c_str(),
1635  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1636  break;
1637 
1638  case SHAPE_T::RECT:
1639  m_out->Print( nested_level, "(gr_rect (start %s) (end %s)",
1640  FormatInternalUnits( primitive->GetStart() ).c_str(),
1641  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1642  break;
1643 
1644  case SHAPE_T::ARC:
1645  m_out->Print( aNestLevel, "(gr_arc (start %s) (mid %s) (end %s)",
1646  FormatInternalUnits( primitive->GetStart() ).c_str(),
1647  FormatInternalUnits( primitive->GetArcMid() ).c_str(),
1648  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1649  break;
1650 
1651  case SHAPE_T::CIRCLE:
1652  m_out->Print( nested_level, "(gr_circle (center %s) (end %s)",
1653  FormatInternalUnits( primitive->GetStart() ).c_str(),
1654  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1655  break;
1656 
1657  case SHAPE_T::BEZIER:
1658  m_out->Print( nested_level, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1659  FormatInternalUnits( primitive->GetStart() ).c_str(),
1660  FormatInternalUnits( primitive->GetBezierC1() ).c_str(),
1661  FormatInternalUnits( primitive->GetBezierC2() ).c_str(),
1662  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1663  break;
1664 
1665  case SHAPE_T::POLY:
1666  if( primitive->IsPolyShapeValid() )
1667  {
1668  const SHAPE_POLY_SET& poly = primitive->GetPolyShape();
1669  const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
1670 
1671  m_out->Print( nested_level, "(gr_poly (pts" );
1672 
1673  bool need_newline = false;
1674 
1675  for( int ii = 0; ii < outline.PointCount(); ++ii )
1676  {
1677  nested_level = 0;
1678 
1679  if( !( ii % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave )
1680  {
1681  // newline every 4 pts.
1682  m_out->Print( 0, "\n" );
1683  need_newline = false;
1684  nested_level = aNestLevel + 4;
1685  }
1686 
1687  int ind = outline.ArcIndex( ii );
1688 
1689  if( ind < 0 )
1690  {
1691  m_out->Print( nested_level, "%s(xy %s)",
1692  nested_level ? "" : " ",
1693  FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
1694  need_newline = true;
1695  }
1696  else
1697  {
1698  const SHAPE_ARC& arc = outline.Arc( ind );
1699  m_out->Print( nested_level, "%s(arc (start %s) (mid %s) (end %s))",
1700  nested_level ? "" : " ",
1701  FormatInternalUnits( arc.GetP0() ).c_str(),
1702  FormatInternalUnits( arc.GetArcMid() ).c_str(),
1703  FormatInternalUnits( arc.GetP1() ).c_str() );
1704  need_newline = true;
1705 
1706  do
1707  {
1708  ++ii;
1709  } while( ii < outline.PointCount() && outline.ArcIndex( ii ) == ind );
1710 
1711  --ii;
1712  }
1713  }
1714 
1715  if( need_newline )
1716  m_out->Print( 0, "\n" );
1717 
1718  m_out->Print( aNestLevel + 3, ")" );
1719  }
1720  break;
1721 
1722  default:
1723  break;
1724  }
1725 
1726  m_out->Print( 0, " (width %s)",
1727  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1728 
1729  if( primitive->IsFilled() )
1730  m_out->Print( 0, " (fill yes)" );
1731 
1732  m_out->Print( 0, ")" );
1733  }
1734 
1735  m_out->Print( 0, "\n");
1736  m_out->Print( aNestLevel+1, ")" ); // end of (basic_shapes
1737  }
1738 
1739  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aPad->m_Uuid.AsString() ) );
1740 
1741  m_out->Print( 0, ")\n" );
1742 }
int GetLocalSolderMaskMargin() const
Definition: pad.h:386
const SHAPE_ARC & Arc(size_t aArc) const
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
int GetLocalSolderPasteMargin() const
Definition: pad.h:393
double GetRoundRectRadiusRatio() const
Definition: pad.h:524
PAD_PROP GetProperty() const
Definition: pad.h:374
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
bool IsLocked() const override
Definition: pad.cpp:150
wxString AsString() const
Definition: kiid.cpp:236
a test point pad
int PointCount() const
Return the number of points (vertices) in this line chain.
int GetThermalGap() const
Definition: pad.h:500
bool GetKeepTopBottom() const
Definition: pad.h:564
Plated through hole pad.
a pad used as heat sink, usually in SMD footprints
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
Definition: richio.cpp:79
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:477
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const wxPoint & GetOffset() const
Definition: pad.h:250
const wxSize & GetDrillSize() const
Definition: pad.h:243
like PAD_PTH, but not plated
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:515
int GetThermalSpokeWidth() const
Definition: pad.h:492
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
Definition: pad.h:349
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
const wxSize & GetSize() const
Definition: pad.h:233
Smd pad, used in BGA footprints.
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:113
const wxString & GetNumber() const
Definition: pad.h:129
const wxString & GetPinType() const
Definition: pad.h:146
PAD_SHAPE GetShape() const
Definition: pad.h:170
a fiducial (usually a smd) local to the parent footprint
#define _(s)
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:368
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:735
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:396
const KIID m_Uuid
Definition: eda_item.h:474
const wxSize & GetDelta() const
Definition: pad.h:240
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
const wxPoint & GetPos0() const
Definition: pad.h:227
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:188
a fiducial (usually a smd) for the full board
double GetChamferRectRatio() const
Definition: pad.h:533
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:354
no special fabrication property
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PAD_ATTRIB GetAttribute() const
Definition: pad.h:371
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
int GetChamferPositions() const
Definition: pad.h:543
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
a pad with a castellated through hole
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
int GetPadToDieLength() const
Definition: pad.h:384
const wxString & GetPinFunction() const
Definition: pad.h:140
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:372
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
bool GetRemoveUnconnected() const
Definition: pad.h:558
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
#define CTL_OMIT_PAD_NETS
Omit pads net names (useless in library)
Definition: pcb_plugin.h:110
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:301
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:183
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References _, ARC, SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), KIID::AsString(), BEZIER, BGA, CASTELLATED, CHAMFERED_RECT, CIRCLE, CONN, SHAPE_LINE_CHAIN::CPoint(), CTL_OMIT_PAD_NETS, CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL, CUSTOM, Double2Str(), FIDUCIAL_GLBL, FIDUCIAL_LOCAL, Format(), FormatAngle(), FormatInternalUnits(), formatLayers(), PAD::GetAnchorPadShape(), SHAPE_ARC::GetArcMid(), PAD::GetAttribute(), ADVANCED_CFG::GetCfg(), PAD::GetChamferPositions(), PAD::GetChamferRectRatio(), PAD::GetCustomShapeInZoneOpt(), PAD::GetDelta(), PAD::GetDrillShape(), PAD::GetDrillSize(), PAD::GetKeepTopBottom(), PAD::GetLayerSet(), PAD::GetLocalClearance(), PAD::GetLocalSolderMaskMargin(), PAD::GetLocalSolderPasteMargin(), PAD::GetLocalSolderPasteMarginRatio(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetNetname(), PAD::GetNumber(), PAD::GetOffset(), PAD::GetOrientation(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), PAD::GetPadToDieLength(), PAD::GetPinFunction(), PAD::GetPinType(), PAD::GetPos0(), PAD::GetPrimitives(), PAD::GetProperty(), PAD::GetRemoveUnconnected(), PAD::GetRoundRectRadiusRatio(), PAD::GetShape(), PAD::GetSize(), PAD::GetThermalGap(), PAD::GetThermalSpokeWidth(), PAD::GetZoneConnection(), HEATSINK, INHERITED, PAD::IsLocked(), ADVANCED_CFG::m_CompactSave, m_ctl, m_mapping, m_out, EDA_ITEM::m_Uuid, NONE, NPTH, SHAPE_POLY_SET::Outline(), OVAL, PAD_DRILL_SHAPE_OBLONG, SHAPE_LINE_CHAIN::PointCount(), POLY, OUTPUTFORMATTER::Print(), PTH, OUTPUTFORMATTER::Quotew(), RECT, RECT_CHAMFER_BOTTOM_LEFT, RECT_CHAMFER_BOTTOM_RIGHT, RECT_CHAMFER_TOP_LEFT, RECT_CHAMFER_TOP_RIGHT, ROUNDRECT, SEGMENT, SMD, StrPrintf(), TESTPOINT, THROW_IO_ERROR, TO_UTF8, NETINFO_MAPPING::Translate(), TRAPEZOID, and NETINFO_LIST::UNCONNECTED.

◆ format() [9/12]

void PCB_PLUGIN::format ( const PCB_TEXT aText,
int  aNestLevel = 0 
) const
private

Definition at line 1745 of file pcb_plugin.cpp.

1746 {
1747  m_out->Print( aNestLevel, "(gr_text %s (at %s",
1748  m_out->Quotew( aText->GetText() ).c_str(),
1749  FormatInternalUnits( aText->GetTextPos() ).c_str() );
1750 
1751  if( aText->GetTextAngle() != 0.0 )
1752  m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() );
1753 
1754  m_out->Print( 0, ")" );
1755 
1756  formatLayer( aText );
1757 
1758  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aText->m_Uuid.AsString() ) );
1759 
1760  m_out->Print( 0, "\n" );
1761 
1762  // PCB_TEXTS are never hidden, so always omit "hide" attribute
1763  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1764 
1765  m_out->Print( aNestLevel, ")\n" );
1766 }
double GetTextAngle() const
Definition: eda_text.h:195
wxString AsString() const
Definition: kiid.cpp:236
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:515
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const KIID m_Uuid
Definition: eda_item.h:474
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
#define CTL_OMIT_HIDE
Definition: eda_text.h:77
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References KIID::AsString(), CTL_OMIT_HIDE, FormatAngle(), FormatInternalUnits(), formatLayer(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), m_ctl, m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and TO_UTF8.

◆ format() [10/12]

void PCB_PLUGIN::format ( const FP_TEXT aText,
int  aNestLevel = 0 
) const
private

Definition at line 1797 of file pcb_plugin.cpp.

1798 {
1799  std::string type;
1800 
1801  switch( aText->GetType() )
1802  {
1803  case FP_TEXT::TEXT_is_REFERENCE: type = "reference"; break;
1804  case FP_TEXT::TEXT_is_VALUE: type = "value"; break;
1805  case FP_TEXT::TEXT_is_DIVERS: type = "user";
1806  }
1807 
1808  std::string locked = aText->IsLocked() ? " locked" : "";
1809 
1810  m_out->Print( aNestLevel, "(fp_text %s%s %s (at %s",
1811  type.c_str(),
1812  locked.c_str(),
1813  m_out->Quotew( aText->GetText() ).c_str(),
1814  FormatInternalUnits( aText->GetPos0() ).c_str() );
1815 
1816  // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
1817  // but internally the angle is held relative to its parent footprint. parent
1818  // may be NULL when saving a footprint outside a BOARD.
1819  double orient = aText->GetTextAngle();
1820  FOOTPRINT* parent = (FOOTPRINT*) aText->GetParent();
1821 
1822  if( parent )
1823  {
1824  // GetTextAngle() is always in -360..+360 range because of
1825  // FP_TEXT::SetTextAngle(), but summing that angle with an
1826  // additional board angle could kick sum up >= 360 or <= -360, so to have
1827  // consistent results, normalize again for the BOARD save. A footprint
1828  // save does not use this code path since parent is NULL.
1829 #if 0
1830  // This one could be considered reasonable if you like positive angles
1831  // in your board text.
1832  orient = NormalizeAnglePos( orient + parent->GetOrientation() );
1833 #else
1834  // Choose compatibility for now, even though this is only a 720 degree clamp
1835  // with two possible values for every angle.
1836  orient = NormalizeAngle360Min( orient + parent->GetOrientation() );
1837 #endif
1838  }
1839 
1840  if( orient != 0.0 )
1841  m_out->Print( 0, " %s", FormatAngle( orient ).c_str() );
1842 
1843  if( !aText->IsKeepUpright() )
1844  m_out->Print( 0, " unlocked" );
1845 
1846  m_out->Print( 0, ")" );
1847  formatLayer( aText );
1848 
1849  if( !aText->IsVisible() )
1850  m_out->Print( 0, " hide" );
1851 
1852  m_out->Print( 0, "\n" );
1853 
1854  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1855 
1856  m_out->Print( aNestLevel + 1, "(tstamp %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
1857 
1858  m_out->Print( aNestLevel, ")\n" );
1859 }
bool IsKeepUpright() const
Definition: fp_text.h:110
double GetOrientation() const
Definition: footprint.h:191
double GetTextAngle() const
Definition: eda_text.h:195
wxString AsString() const
Definition: kiid.cpp:236
virtual bool IsLocked() const
Definition: board_item.cpp:64
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:515
TEXT_TYPE GetType() const
Definition: fp_text.h:141
virtual bool IsVisible() const
Definition: eda_text.h:207
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
const KIID m_Uuid
Definition: eda_item.h:474
const wxPoint & GetPos0() const
Definition: fp_text.h:166
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:281
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
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:254
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:136
#define CTL_OMIT_HIDE
Definition: eda_text.h:77
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References KIID::AsString(), CTL_OMIT_HIDE, FormatAngle(), FormatInternalUnits(), formatLayer(), FOOTPRINT::GetOrientation(), BOARD_ITEM::GetParent(), FP_TEXT::GetPos0(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), FP_TEXT::GetType(), FP_TEXT::IsKeepUpright(), BOARD_ITEM::IsLocked(), EDA_TEXT::IsVisible(), locked, m_ctl, m_out, EDA_ITEM::m_Uuid, NormalizeAngle360Min(), NormalizeAnglePos(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), FP_TEXT::TEXT_is_DIVERS, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, and TO_UTF8.

◆ format() [11/12]

void PCB_PLUGIN::format ( const PCB_TRACK aTrack,
int  aNestLevel = 0 
) const
private

Definition at line 1862 of file pcb_plugin.cpp.

1863 {
1864  if( aTrack->Type() == PCB_VIA_T )
1865  {
1866  PCB_LAYER_ID layer1, layer2;
1867 
1868  const PCB_VIA* via = static_cast<const PCB_VIA*>( aTrack );
1869  BOARD* board = (BOARD*) via->GetParent();
1870 
1871  wxCHECK_RET( board != nullptr, wxT( "Via " ) +
1872  via->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) + wxT( " has no parent." ) );
1873 
1874  m_out->Print( aNestLevel, "(via" );
1875 
1876  via->LayerPair( &layer1, &layer2 );
1877 
1878  switch( via->GetViaType() )
1879  {
1880  case VIATYPE::THROUGH: // Default shape not saved.
1881  break;
1882 
1883  case VIATYPE::BLIND_BURIED:
1884  m_out->Print( 0, " blind" );
1885  break;
1886 
1887  case VIATYPE::MICROVIA:
1888  m_out->Print( 0, " micro" );
1889  break;
1890 
1891  default:
1892  THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
1893  }
1894 
1895  if( via->IsLocked() )
1896  m_out->Print( 0, " locked" );
1897 
1898  m_out->Print( 0, " (at %s) (size %s)",
1899  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1900  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1901 
1902  // Old boards were using UNDEFINED_DRILL_DIAMETER value in file for via drill when
1903  // via drill was the netclass value.
1904  // recent boards always set the via drill to the actual value, but now we need to
1905  // always store the drill value, because netclass value is not stored in the board file.
1906  // Otherwise the drill value of some (old) vias can be unknown
1907  if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
1908  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrill() ).c_str() );
1909  else // Probably old board!
1910  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrillValue() ).c_str() );
1911 
1912  m_out->Print( 0, " (layers %s %s)",
1913  m_out->Quotew( LSET::Name( layer1 ) ).c_str(),
1914  m_out->Quotew( LSET::Name( layer2 ) ).c_str() );
1915 
1916  if( via->GetRemoveUnconnected() )
1917  {
1918  m_out->Print( 0, " (remove_unused_layers)" );
1919 
1920  if( via->GetKeepTopBottom() )
1921  m_out->Print( 0, " (keep_end_layers)" );
1922  }
1923 
1924  if( via->GetIsFree() )
1925  m_out->Print( 0, " (free)" );
1926  }
1927  else if( aTrack->Type() == PCB_ARC_T )
1928  {
1929  const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
1930  std::string locked = arc->IsLocked() ? " locked" : "";
1931 
1932  m_out->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s) (width %s)",
1933  locked.c_str(),
1934  FormatInternalUnits( arc->GetStart() ).c_str(),
1935  FormatInternalUnits( arc->GetMid() ).c_str(),
1936  FormatInternalUnits( arc->GetEnd() ).c_str(),
1937  FormatInternalUnits( arc->GetWidth() ).c_str() );
1938 
1939  m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( arc->GetLayer() ) ).c_str() );
1940  }
1941  else
1942  {
1943  std::string locked = aTrack->IsLocked() ? " locked" : "";
1944 
1945  m_out->Print( aNestLevel, "(segment%s (start %s) (end %s) (width %s)",
1946  locked.c_str(),
1947  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1948  FormatInternalUnits( aTrack->GetEnd() ).c_str(),
1949  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1950 
1951  m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( aTrack->GetLayer() ) ).c_str() );
1952  }
1953 
1954  m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
1955 
1956  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTrack->m_Uuid.AsString() ) );
1957 
1958  m_out->Print( 0, ")\n" );
1959 }
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
wxString AsString() const
Definition: kiid.cpp:236
int GetWidth() const
Definition: pcb_track.h:102
virtual bool IsLocked() const
Definition: board_item.cpp:64
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
#define UNDEFINED_DRILL_DIAMETER
Definition: pcb_track.h:69
#define _(s)
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
const KIID m_Uuid
Definition: eda_item.h:474
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
const wxPoint & GetMid() const
Definition: pcb_track.h:272
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
const wxPoint & GetStart() const
Definition: pcb_track.h:108
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References _, KIID::AsString(), BLIND_BURIED, Format(), FormatInternalUnits(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_ARC::GetMid(), BOARD_CONNECTED_ITEM::GetNetCode(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), locked, m_mapping, m_out, EDA_ITEM::m_Uuid, MICROVIA, MILLIMETRES, LSET::Name(), PCB_ARC_T, PCB_VIA_T, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), THROUGH, THROW_IO_ERROR, TO_UTF8, NETINFO_MAPPING::Translate(), EDA_ITEM::Type(), UNDEFINED_DRILL_DIAMETER, and via.

◆ format() [12/12]

void PCB_PLUGIN::format ( const ZONE aZone,
int  aNestLevel = 0 
) const
private

Definition at line 1962 of file pcb_plugin.cpp.

1963 {
1964  std::string locked = aZone->IsLocked() ? " locked" : "";
1965 
1966  // Save the NET info; For keepout zones, net code and net name are irrelevant
1967  // so be sure a dummy value is stored, just for ZONE compatibility
1968  // (perhaps netcode and netname should be not stored)
1969  m_out->Print( aNestLevel, "(zone%s (net %d) (net_name %s)",
1970  locked.c_str(),
1971  aZone->GetIsRuleArea() ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
1972  m_out->Quotew( aZone->GetIsRuleArea() ? wxT("") : aZone->GetNetname() ).c_str() );
1973 
1974  // If a zone exists on multiple layers, format accordingly
1975  if( aZone->GetLayerSet().count() > 1 )
1976  {
1977  formatLayers( aZone->GetLayerSet() );
1978  }
1979  else
1980  {
1981  formatLayer( aZone );
1982  }
1983 
1984  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aZone->m_Uuid.AsString() ) );
1985 
1986  if( !aZone->GetZoneName().empty() )
1987  m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
1988 
1989  // Save the outline aux info
1990  std::string hatch;
1991 
1992  switch( aZone->GetHatchStyle() )
1993  {
1994  default:
1995  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: hatch = "none"; break;
1996  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: hatch = "edge"; break;
1997  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: hatch = "full"; break;
1998  }
1999 
2000  m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
2001  FormatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() );
2002 
2003  if( aZone->GetPriority() > 0 )
2004  m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetPriority() );
2005 
2006  m_out->Print( aNestLevel+1, "(connect_pads" );
2007 
2008  switch( aZone->GetPadConnection() )
2009  {
2010  default:
2011  case ZONE_CONNECTION::THERMAL: // Default option not saved or loaded.
2012  break;
2013 
2015  m_out->Print( 0, " thru_hole_only" );
2016  break;
2017 
2018  case ZONE_CONNECTION::FULL:
2019  m_out->Print( 0, " yes" );
2020  break;
2021 
2022  case ZONE_CONNECTION::NONE:
2023  m_out->Print( 0, " no" );
2024  break;
2025  }
2026 
2027  m_out->Print( 0, " (clearance %s))\n",
2028  FormatInternalUnits( aZone->GetLocalClearance() ).c_str() );
2029 
2030  m_out->Print( aNestLevel+1, "(min_thickness %s)",
2031  FormatInternalUnits( aZone->GetMinThickness() ).c_str() );
2032 
2033  // write it only if V 6.O version option is used (i.e. do not write if the "legacy"
2034  // algorithm is used)
2035  if( !aZone->GetFilledPolysUseThickness() )
2036  m_out->Print( 0, " (filled_areas_thickness no)" );
2037 
2038  m_out->Print( 0, "\n" );
2039 
2040  if( aZone->GetIsRuleArea() )
2041  {
2042  m_out->Print( aNestLevel + 1,
2043  "(keepout (tracks %s) (vias %s) (pads %s ) (copperpour %s) "
2044  "(footprints %s))\n",
2045  aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
2046  aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
2047  aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
2048  aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
2049  aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
2050  }
2051 
2052  m_out->Print( aNestLevel + 1, "(fill" );
2053 
2054  // Default is not filled.
2055  if( aZone->IsFilled() )
2056  m_out->Print( 0, " yes" );
2057 
2058  // Default is polygon filled.
2059  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2060  m_out->Print( 0, " (mode hatch)" );
2061 
2062  m_out->Print( 0, " (thermal_gap %s) (thermal_bridge_width %s)",
2063  FormatInternalUnits( aZone->GetThermalReliefGap() ).c_str(),
2064  FormatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() );
2065 
2067  {
2068  m_out->Print( 0, " (smoothing" );
2069 
2070  switch( aZone->GetCornerSmoothingType() )
2071  {
2073  m_out->Print( 0, " chamfer" );
2074  break;
2075 
2077  m_out->Print( 0, " fillet" );
2078  break;
2079 
2080  default:
2081  THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
2082  aZone->GetCornerSmoothingType() ) );
2083  }
2084  m_out->Print( 0, ")" );
2085 
2086  if( aZone->GetCornerRadius() != 0 )
2087  m_out->Print( 0, " (radius %s)",
2088  FormatInternalUnits( aZone->GetCornerRadius() ).c_str() );
2089  }
2090 
2092  {
2093  m_out->Print( 0, " (island_removal_mode %d) (island_area_min %s)",
2094  static_cast<int>( aZone->GetIslandRemovalMode() ),
2095  FormatInternalUnits( aZone->GetMinIslandArea() / IU_PER_MM ).c_str() );
2096  }
2097 
2098  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2099  {
2100  m_out->Print( 0, "\n" );
2101  m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2102  FormatInternalUnits( aZone->GetHatchThickness() ).c_str(),
2103  FormatInternalUnits( aZone->GetHatchGap() ).c_str(),
2104  Double2Str( aZone->GetHatchOrientation() ).c_str() );
2105 
2106  if( aZone->GetHatchSmoothingLevel() > 0 )
2107  {
2108  m_out->Print( 0, "\n" );
2109  m_out->Print( aNestLevel+2, "(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2110  aZone->GetHatchSmoothingLevel(),
2111  Double2Str( aZone->GetHatchSmoothingValue() ).c_str() );
2112  }
2113 
2114  m_out->Print( 0, "\n" );
2115  m_out->Print( aNestLevel+2, "(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2116  aZone->GetHatchBorderAlgorithm() ? "hatch_thickness" : "min_thickness",
2117  Double2Str( aZone->GetHatchHoleMinArea() ).c_str() );
2118  }
2119 
2120  m_out->Print( 0, ")\n" );
2121 
2122  if( aZone->GetNumCorners() )
2123  {
2124  SHAPE_POLY_SET::POLYGON poly = aZone->Outline()->Polygon(0);
2125 
2126  for( auto& chain : poly )
2127  {
2128  m_out->Print( aNestLevel + 1, "(polygon\n" );
2129  m_out->Print( aNestLevel + 2, "(pts" );
2130 
2131  bool need_newline = true;
2132 
2133  for( int ii = 0; ii < chain.PointCount(); ++ii )
2134  {
2135  int nestLevel = 0;
2136 
2137  if( !( ii % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) // newline every 4 pts
2138  {
2139  m_out->Print( 0, "\n" );
2140  need_newline = false;
2141  nestLevel = aNestLevel + 3;
2142  }
2143 
2144  int ind = chain.ArcIndex( ii );
2145 
2146  if( ind < 0 )
2147  {
2148  m_out->Print( nestLevel, "%s(xy %s)",
2149  nestLevel ? "" : " ",
2150  FormatInternalUnits( chain.CPoint( ii ) ).c_str() );
2151  need_newline = true;
2152  }
2153  else
2154  {
2155  auto& arc = chain.Arc( ind );
2156  m_out->Print( nestLevel, "%s(arc (start %s) (mid %s) (end %s))",
2157  nestLevel ? "" : " ",
2158  FormatInternalUnits( arc.GetP0() ).c_str(),
2159  FormatInternalUnits( arc.GetArcMid() ).c_str(),
2160  FormatInternalUnits( arc.GetP1() ).c_str() );
2161  need_newline = true;
2162 
2163  do
2164  {
2165  ++ii;
2166  } while( ii < chain.PointCount() && chain.ArcIndex( ii ) == ind );
2167 
2168  --ii;
2169  }
2170  }
2171 
2172  if( need_newline )
2173  m_out->Print( 0, "\n" );
2174 
2175  m_out->Print( aNestLevel + 2, ")\n" );
2176  m_out->Print( aNestLevel + 1, ")\n" );
2177 
2178  }
2179  }
2180 
2181  // Save the PolysList (filled areas)
2182  for( PCB_LAYER_ID layer : aZone->GetLayerSet().Seq() )
2183  {
2184  const SHAPE_POLY_SET& fv = aZone->GetFilledPolysList( layer );
2185 
2186  for( int ii = 0; ii < fv.OutlineCount(); ++ii )
2187  {
2188  m_out->Print( aNestLevel + 1, "(filled_polygon\n" );
2189  m_out->Print( aNestLevel + 2, "(layer %s)\n",
2190  m_out->Quotew( LSET::Name( layer ) ).c_str() );
2191 
2192  if( aZone->IsIsland( layer, ii ) )
2193  m_out->Print( aNestLevel + 2, "(island)\n" );
2194 
2195  m_out->Print( aNestLevel + 2, "(pts" );
2196 
2197  const SHAPE_LINE_CHAIN& chain = fv.COutline( ii );
2198 
2199  bool need_newline = true;
2200 
2201  for( int jj = 0; jj < chain.PointCount(); ++jj )
2202  {
2203  int nestLevel = 0;
2204 
2205  if( !( jj%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) // newline every 4 pts
2206  {
2207  m_out->Print( 0, "\n" );
2208  need_newline = false;
2209  nestLevel = aNestLevel + 3;
2210  }
2211 
2212  int ind = chain.ArcIndex( jj );
2213 
2214  if( ind < 0 )
2215  {
2216  m_out->Print( nestLevel, "%s(xy %s)",
2217  nestLevel ? "" : " ",
2218  FormatInternalUnits( chain.CPoint( jj ) ).c_str() );
2219  need_newline = true;
2220  }
2221  else
2222  {
2223  auto& arc = chain.Arc( ind );
2224  m_out->Print( nestLevel, "%s(arc (start %s) (mid %s) (end %s))",
2225  nestLevel ? "" : " ",
2226  FormatInternalUnits( arc.GetP0() ).c_str(),
2227  FormatInternalUnits( arc.GetArcMid() ).c_str(),
2228  FormatInternalUnits( arc.GetP1() ).c_str() );
2229  need_newline = true;
2230 
2231  do
2232  {
2233  ++jj;
2234  } while( jj < chain.PointCount() && chain.ArcIndex( jj ) == ind );
2235 
2236  --jj;
2237  }
2238  }
2239 
2240  if( need_newline )
2241  m_out->Print( 0, "\n" );
2242 
2243  m_out->Print( aNestLevel+2, ")\n" );
2244  m_out->Print( aNestLevel+1, ")\n" );
2245  }
2246 
2247  // Save the filling segments list
2248  const std::vector<SEG>& segs = aZone->FillSegments( layer );
2249 
2250  if( segs.size() )
2251  {
2252  m_out->Print( aNestLevel + 1, "(fill_segments\n" );
2253  m_out->Print( aNestLevel + 2, "(layer %s)\n",
2254  TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
2255 
2256  for( const SEG& seg : segs )
2257  {
2258  m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n",
2259  FormatInternalUnits( wxPoint( seg.A ) ).c_str(),
2260  FormatInternalUnits( wxPoint( seg.B ) ).c_str() );
2261  }
2262 
2263  m_out->Print( aNestLevel + 1, ")\n" );
2264  }
2265  }
2266 
2267  m_out->Print( aNestLevel, ")\n" );
2268 }
std::vector< SHAPE_LINE_CHAIN > POLYGON
< represents a single polygon outline with holes.
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: zone.h:525
const SHAPE_ARC & Arc(size_t aArc) const
int GetHatchGap() const
Definition: zone.h:256
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
bool GetDoNotAllowFootprints() const
Definition: zone.h:740
int GetHatchThickness() const
Definition: zone.h:253
unsigned GetPriority() const
Definition: zone.h:122
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:735
static constexpr double IU_PER_MM
Mock up a conversion function.
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:869
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
bool GetDoNotAllowVias() const
Definition: zone.h:737
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:289
double GetHatchSmoothingValue() const
Definition: zone.h:265
wxString AsString() const
Definition: kiid.cpp:236
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
bool IsFilled() const
Definition: zone.h:234
virtual bool IsLocked() const
Definition: board_item.cpp:64
int PointCount() const
Return the number of points (vertices) in this line chain.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:181
int GetThermalReliefGap() const
Definition: zone.h:191
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
double GetHatchHoleMinArea() const
Definition: zone.h:268
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool GetDoNotAllowPads() const
Definition: zone.h:739
bool GetDoNotAllowCopperPour() const
Definition: zone.h:736
pads are covered by copper
int GetMinThickness() const
Definition: zone.h:244
int GetHatchSmoothingLevel() const
Definition: zone.h:262
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
std::vector< SEG > & FillSegments(PCB_LAYER_ID aLayer)
Definition: zone.h:308
Represent a set of closed polygons.
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:492
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
bool GetDoNotAllowTracks() const
Definition: zone.h:738
#define _(s)
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:615
Thermal relief only for THT pads.
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
const KIID m_Uuid
Definition: eda_item.h:474
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Definition: seg.h:40
double GetHatchOrientation() const
Definition: zone.h:259
Use thermal relief for pads.
unsigned int GetCornerRadius() const
Definition: zone.h:689
int GetHatchBorderAlgorithm() const
Definition: zone.h:271
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:751
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1075
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
Pads are not covered.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
long long int GetMinIslandArea() const
Definition: zone.h:754
int GetThermalReliefSpokeWidth() const
Definition: zone.h:202
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
POLYGON & Polygon(int aIndex)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
ZONE_CONNECTION GetPadConnection(PAD *aPad, wxString *aSource=nullptr) const
Definition: zone.cpp:753
wxString GetZoneName() const
Definition: zone.h:129
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
int GetCornerSmoothingType() const
Definition: zone.h:685
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:606
bool GetFilledPolysUseThickness() const
Definition: zone.h:691

References _, ALWAYS, SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), KIID::AsString(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), DIAGONAL_EDGE, DIAGONAL_FULL, Double2Str(), ZONE::FillSegments(), Format(), FormatInternalUnits(), formatLayer(), formatLayers(), FULL, ZONE::GetBorderHatchPitch(), ADVANCED_CFG::GetCfg(), ZONE::GetCornerRadius(), ZONE::GetCornerSmoothingType(), ZONE::GetDoNotAllowCopperPour(), ZONE::GetDoNotAllowFootprints(), ZONE::GetDoNotAllowPads(), ZONE::GetDoNotAllowTracks(), ZONE::GetDoNotAllowVias(), ZONE::GetFilledPolysList(), ZONE::GetFilledPolysUseThickness(), ZONE::GetFillMode(), ZONE::GetHatchBorderAlgorithm(), ZONE::GetHatchGap(), ZONE::GetHatchHoleMinArea(), ZONE::GetHatchOrientation(), ZONE::GetHatchSmoothingLevel(), ZONE::GetHatchSmoothingValue(), ZONE::GetHatchStyle(), ZONE::GetHatchThickness(), ZONE::GetIslandRemovalMode(), ZONE::GetIsRuleArea(), ZONE::GetLayerSet(), ZONE::GetLocalClearance(), ZONE::GetMinIslandArea(), ZONE::GetMinThickness(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetNetname(), ZONE::GetNumCorners(), ZONE::GetPadConnection(), ZONE::GetPriority(), BOARD::GetStandardLayerName(), ZONE::GetThermalReliefGap(), ZONE::GetThermalReliefSpokeWidth(), ZONE::GetZoneName(), HATCH_PATTERN, ZONE::IsFilled(), ZONE::IsIsland(), BOARD_ITEM::IsLocked(), IU_PER_MM, locked, ADVANCED_CFG::m_CompactSave, m_mapping, m_out, EDA_ITEM::m_Uuid, LSET::Name(), NO_HATCH, NONE, ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::Polygon(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), LSET::Seq(), ZONE_SETTINGS::SMOOTHING_CHAMFER, ZONE_SETTINGS::SMOOTHING_FILLET, ZONE_SETTINGS::SMOOTHING_NONE, THERMAL, THROW_IO_ERROR, THT_THERMAL, TO_UTF8, and NETINFO_MAPPING::Translate().

◆ formatBoardLayers()

void PCB_PLUGIN::formatBoardLayers ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the board layer information

Definition at line 542 of file pcb_plugin.cpp.

543 {
544  m_out->Print( aNestLevel, "(layers\n" );
545 
546  // Save only the used copper layers from front to back.
547 
548  for( LSEQ cu = aBoard->GetEnabledLayers().CuStack(); cu; ++cu )
549  {
550  PCB_LAYER_ID layer = *cu;
551 
552  m_out->Print( aNestLevel+1, "(%d %s %s", layer,
553  m_out->Quotew( LSET::Name( layer ) ).c_str(),
554  LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
555 
556  if( LSET::Name( layer ) != m_board->GetLayerName( layer ) )
557  m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
558 
559  m_out->Print( 0, ")\n" );
560  }
561 
562  // Save used non-copper layers in the order they are defined.
563  // desired sequence for non Cu BOARD layers.
564  static const PCB_LAYER_ID non_cu[] =
565  {
566  B_Adhes, // 32
567  F_Adhes,
568  B_Paste,
569  F_Paste,
570  B_SilkS,
571  F_SilkS,
572  B_Mask,
573  F_Mask,
574  Dwgs_User,
575  Cmts_User,
576  Eco1_User,
577  Eco2_User,
578  Edge_Cuts,
579  Margin,
580  B_CrtYd,
581  F_CrtYd,
582  B_Fab,
583  F_Fab,
584  User_1,
585  User_2,
586  User_3,
587  User_4,
588  User_5,
589  User_6,
590  User_7,
591  User_8,
592  User_9
593  };
594 
595  for( LSEQ seq = aBoard->GetEnabledLayers().Seq( non_cu, arrayDim( non_cu ) ); seq; ++seq )
596  {
597  PCB_LAYER_ID layer = *seq;
598 
599  m_out->Print( aNestLevel+1, "(%d %s user", layer,
600  m_out->Quotew( LSET::Name( layer ) ).c_str() );
601 
602  if( m_board->GetLayerName( layer ) != LSET::Name( layer ) )
603  m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
604 
605  m_out->Print( 0, ")\n" );
606  }
607 
608  m_out->Print( aNestLevel, ")\n\n" );
609 }
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:170
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:467
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition: board.cpp:427
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BOARD * m_board
which BOARD, no ownership here
Definition: pcb_plugin.h:284
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:477
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition: board.cpp:396
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References arrayDim(), B_Adhes, B_CrtYd, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, LSET::CuStack(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, BOARD::GetEnabledLayers(), BOARD::GetLayerName(), BOARD::GetLayerType(), m_board, m_out, Margin, LSET::Name(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), LSET::Seq(), LAYER::ShowType(), User_1, User_2, User_3, User_4, User_5, User_6, User_7, User_8, and User_9.

Referenced by formatHeader(), and CLIPBOARD_IO::SaveSelection().

◆ formatGeneral()

void PCB_PLUGIN::formatGeneral ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the General section of the file

Definition at line 526 of file pcb_plugin.cpp.

527 {
528  const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
529 
530  m_out->Print( 0, "\n" );
531  m_out->Print( aNestLevel, "(general\n" );
532  m_out->Print( aNestLevel+1, "(thickness %s)\n",
533  FormatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() );
534 
535  m_out->Print( aNestLevel, ")\n\n" );
536 
537  aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl );
538  aBoard->GetTitleBlock().Format( m_out, aNestLevel, m_ctl );
539 }
const PAGE_INFO & GetPageSettings() const
Definition: board.h:536
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:271
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: title_block.cpp:29
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:542
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
Container for design settings for a BOARD object.

References TITLE_BLOCK::Format(), PAGE_INFO::Format(), FormatInternalUnits(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetDesignSettings(), BOARD::GetPageSettings(), BOARD::GetTitleBlock(), m_ctl, m_out, and OUTPUTFORMATTER::Print().

Referenced by formatHeader().

◆ formatHeader()

void PCB_PLUGIN::formatHeader ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

writes everything that comes before the board_items, like settings and layers etc

Definition at line 642 of file pcb_plugin.cpp.

643 {
644  formatGeneral( aBoard, aNestLevel );
645 
646  // Layers list.
647  formatBoardLayers( aBoard, aNestLevel );
648 
649  // Setup
650  formatSetup( aBoard, aNestLevel );
651 
652  // Properties
653  formatProperties( aBoard, aNestLevel );
654 
655  // Save net codes and names
656  formatNetInformation( aBoard, aNestLevel );
657 }
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
Definition: pcb_plugin.cpp:474
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
Definition: pcb_plugin.cpp:526
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
Definition: pcb_plugin.cpp:542
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:628
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:612

References formatBoardLayers(), formatGeneral(), formatNetInformation(), formatProperties(), and formatSetup().

Referenced by format().

◆ formatLayer()

void PCB_PLUGIN::formatLayer ( const BOARD_ITEM aItem) const
private

Definition at line 466 of file pcb_plugin.cpp.

467 {
468  PCB_LAYER_ID layer = aItem->GetLayer();
469 
470  m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( layer ) ).c_str() );
471 }
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References BOARD_ITEM::GetLayer(), m_out, LSET::Name(), OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by format().

◆ formatLayers()

void PCB_PLUGIN::formatLayers ( LSET  aLayerMask,
int  aNestLevel = 0 
) const
private

Definition at line 1290 of file pcb_plugin.cpp.

1291 {
1292  std::string output;
1293 
1294  if( aNestLevel == 0 )
1295  output += ' ';
1296 
1297  output += "(layers";
1298 
1299  static const LSET cu_all( LSET::AllCuMask() );
1300  static const LSET fr_bk( 2, B_Cu, F_Cu );
1301  static const LSET adhes( 2, B_Adhes, F_Adhes );
1302  static const LSET paste( 2, B_Paste, F_Paste );
1303  static const LSET silks( 2, B_SilkS, F_SilkS );
1304  static const LSET mask( 2, B_Mask, F_Mask );
1305  static const LSET crt_yd( 2, B_CrtYd, F_CrtYd );
1306  static const LSET fab( 2, B_Fab, F_Fab );
1307 
1308  LSET cu_mask = cu_all;
1309 
1310  // output copper layers first, then non copper
1311 
1312  if( ( aLayerMask & cu_mask ) == cu_mask )
1313  {
1314  output += " *.Cu";
1315  aLayerMask &= ~cu_all; // clear bits, so they are not output again below
1316  }
1317  else if( ( aLayerMask & cu_mask ) == fr_bk )
1318  {
1319  output += " F&B.Cu";
1320  aLayerMask &= ~fr_bk;
1321  }
1322 
1323  if( ( aLayerMask & adhes ) == adhes )
1324  {
1325  output += " *.Adhes";
1326  aLayerMask &= ~adhes;
1327  }
1328 
1329  if( ( aLayerMask & paste ) == paste )
1330  {
1331  output += " *.Paste";
1332  aLayerMask &= ~paste;
1333  }
1334 
1335  if( ( aLayerMask & silks ) == silks )
1336  {
1337  output += " *.SilkS";
1338  aLayerMask &= ~silks;
1339  }
1340 
1341  if( ( aLayerMask & mask ) == mask )
1342  {
1343  output += " *.Mask";
1344  aLayerMask &= ~mask;
1345  }
1346 
1347  if( ( aLayerMask & crt_yd ) == crt_yd )
1348  {
1349  output += " *.CrtYd";
1350  aLayerMask &= ~crt_yd;
1351  }
1352 
1353  if( ( aLayerMask & fab ) == fab )
1354  {
1355  output += " *.Fab";
1356  aLayerMask &= ~fab;
1357  }
1358 
1359  // output any individual layers not handled in wildcard combos above
1360  wxString layerName;
1361 
1362  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
1363  {
1364  if( aLayerMask[layer] )
1365  {
1366  layerName = LSET::Name( PCB_LAYER_ID( layer ) );
1367  output += ' ';
1368  output += m_out->Quotew( layerName );
1369  }
1370  }
1371 
1372  m_out->Print( aNestLevel, "%s)", output.c_str() );
1373 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References LSET::AllCuMask(), B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, m_out, LSET::Name(), paste, PCB_LAYER_ID_COUNT, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by format().

◆ formatNetInformation()

void PCB_PLUGIN::formatNetInformation ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the Nets and Netclasses

Definition at line 612 of file pcb_plugin.cpp.

613 {
614  for( NETINFO_ITEM* net : *m_mapping )
615  {
616  if( net == nullptr ) // Skip not actually existing nets (orphan nets)
617  continue;
618 
619  m_out->Print( aNestLevel, "(net %d %s)\n",
620  m_mapping->Translate( net->GetNetCode() ),
621  m_out->Quotew( net->GetNetname() ).c_str() );
622  }
623 
624  m_out->Print( 0, "\n" );
625 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
Handle the data for a net.
Definition: netinfo.h:66
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References m_mapping, m_out, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and NETINFO_MAPPING::Translate().

Referenced by formatHeader(), and CLIPBOARD_IO::SaveSelection().

◆ formatProperties()

void PCB_PLUGIN::formatProperties ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the Nets and Netclasses

Definition at line 628 of file pcb_plugin.cpp.

629 {
630  for( const std::pair<const wxString, wxString>& prop : aBoard->GetProperties() )
631  {
632  m_out->Print( aNestLevel, "(property %s %s)\n",
633  m_out->Quotew( prop.first ).c_str(),
634  m_out->Quotew( prop.second ).c_str() );
635  }
636 
637  if( !aBoard->GetProperties().empty() )
638  m_out->Print( 0, "\n" );
639 }
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:259
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References BOARD::GetProperties(), m_out, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by formatHeader().

◆ formatSetup()

void PCB_PLUGIN::formatSetup ( const BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the board setup information

Definition at line 474 of file pcb_plugin.cpp.

475 {
476  // Setup
477  m_out->Print( aNestLevel, "(setup\n" );
478 
479  // Save the board physical stackup structure
480  const BOARD_STACKUP& stackup = aBoard->GetDesignSettings().GetStackupDescriptor();
481 
482  if( aBoard->GetDesignSettings().m_HasStackup )
483  stackup.FormatBoardStackup( m_out, aBoard, aNestLevel+1 );
484 
485  BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
486 
487  m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
488  FormatInternalUnits( dsnSettings.m_SolderMaskMargin ).c_str() );
489 
490  if( dsnSettings.m_SolderMaskMinWidth )
491  m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n",
492  FormatInternalUnits( dsnSettings.m_SolderMaskMinWidth ).c_str() );
493 
494  if( dsnSettings.m_SolderPasteMargin != 0 )
495  m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
496  FormatInternalUnits( dsnSettings.m_SolderPasteMargin ).c_str() );
497 
498  if( dsnSettings.m_SolderPasteMarginRatio != 0 )
499  m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
500  Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
501 
502  wxPoint origin = dsnSettings.GetAuxOrigin();
503 
504  if( origin != wxPoint( 0, 0 ) )
505  {
506  m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
507  FormatInternalUnits( origin.x ).c_str(),
508  FormatInternalUnits( origin.y ).c_str() );
509  }
510 
511  origin = dsnSettings.GetGridOrigin();
512 
513  if( origin != wxPoint( 0, 0 ) )
514  {
515  m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
516  FormatInternalUnits( origin.x ).c_str(),
517  FormatInternalUnits( origin.y ).c_str() );
518  }
519 
520  aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
521 
522  m_out->Print( aNestLevel, ")\n\n" );
523 }
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:539
Manage layers needed to make a physical board.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
const wxPoint & GetGridOrigin()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
BOARD_STACKUP & GetStackupDescriptor()
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
const wxPoint & GetAuxOrigin()
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
Container for design settings for a BOARD object.

References Double2Str(), PCB_PLOT_PARAMS::Format(), BOARD_STACKUP::FormatBoardStackup(), FormatInternalUnits(), BOARD_DESIGN_SETTINGS::GetAuxOrigin(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetGridOrigin(), BOARD::GetPlotOptions(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), BOARD_DESIGN_SETTINGS::m_HasStackup, m_out, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, BOARD_DESIGN_SETTINGS::m_SolderMaskMinWidth, BOARD_DESIGN_SETTINGS::m_SolderPasteMargin, BOARD_DESIGN_SETTINGS::m_SolderPasteMarginRatio, and OUTPUTFORMATTER::Print().

Referenced by formatHeader().

◆ GetEnumeratedFootprint()

const FOOTPRINT * PCB_PLUGIN::GetEnumeratedFootprint ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.

Reimplemented from PLUGIN.

Definition at line 2436 of file pcb_plugin.cpp.

2439 {
2440  return getFootprint( aLibraryPath, aFootprintName, aProperties, false );
2441 }
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)

References getFootprint().

◆ GetFileExtension()

const wxString PCB_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 149 of file pcb_plugin.h.

150  {
151  // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
152  // but to be pure, a plugin should not assume that it will always be linked
153  // with the core of the Pcbnew code. (Might someday be a DLL/DSO.) Besides,
154  // file extension policy should be controlled by the plugin.
155  return wxT( "kicad_pcb" );
156  }

◆ getFootprint()

const FOOTPRINT * PCB_PLUGIN::getFootprint ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties,
bool  checkModified 
)
protected

Definition at line 2408 of file pcb_plugin.cpp.

2412 {
2413  LOCALE_IO toggle; // toggles on, then off, the C locale.
2414 
2415  init( aProperties );
2416 
2417  try
2418  {
2419  validateCache( aLibraryPath, checkModified );
2420  }
2421  catch( const IO_ERROR& )
2422  {
2423  // do nothing with the error
2424  }
2425 
2426  FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
2427  FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
2428 
2429  if( it == footprints.end() )
2430  return nullptr;
2431 
2432  return it->second->GetFootprint();
2433 }
FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.cpp:112
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void init(const PROPERTIES *aProperties)
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
std::map< wxString, FOOTPRINT * > FOOTPRINT_MAP
Definition: eagle_parser.h:50
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References FP_CACHE::GetFootprints(), init(), m_cache, and validateCache().

Referenced by FootprintLoad(), and GetEnumeratedFootprint().

◆ GetImportedCachedLibraryFootprints()

std::vector< FOOTPRINT * > PLUGIN::GetImportedCachedLibraryFootprints ( )
virtualinherited

Return a container with the cached library footprints generated in the last call to Load.

This function is intended to be used ONLY by the non-KiCad board importers for the purpose of obtaining the footprint library of the design and creating a project-specific library.

Returns
Footprints (caller owns the objects)

Reimplemented in EAGLE_PLUGIN, and CADSTAR_PCB_ARCHIVE_PLUGIN.

Definition at line 54 of file plugin.cpp.

55 {
56  not_implemented( this, __FUNCTION__ );
57  return std::vector<FOOTPRINT*>();
58 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Throw an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:38

References not_implemented().

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ GetLibraryTimestamp()

long long PCB_PLUGIN::GetLibraryTimestamp ( const wxString &  aLibraryPath) const
overridevirtual

Generate a timestamp representing all the files in the library (including the library directory).

Timestamps should not be considered ordered, they either match or they don't.

Implements PLUGIN.

Definition at line 2598 of file pcb_plugin.cpp.

2599 {
2600  return FP_CACHE::GetTimestamp( aLibraryPath );
2601 }
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
Definition: pcb_plugin.cpp:330

References FP_CACHE::GetTimestamp().

◆ GetStringOutput()

std::string PCB_PLUGIN::GetStringOutput ( bool  doClear)
inline

Definition at line 211 of file pcb_plugin.h.

212  {
213  std::string ret = m_sf.GetString();
214 
215  if( doClear )
216  m_sf.Clear();
217 
218  return ret;
219  }
STRING_FORMATTER m_sf
Definition: pcb_plugin.h:293
const std::string & GetString()
Definition: richio.h:438
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:428

References STRING_FORMATTER::Clear(), STRING_FORMATTER::GetString(), and m_sf.

Referenced by FOOTPRINT_EDIT_FRAME::ExportFootprint().

◆ init()

void PCB_PLUGIN::init ( const PROPERTIES aProperties)
protected

Definition at line 2359 of file pcb_plugin.cpp.

2360 {
2361  m_board = nullptr;
2362  m_reader = nullptr;
2363  m_props = aProperties;
2364 }
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_plugin.h:287
BOARD * m_board
which BOARD, no ownership here
Definition: pcb_plugin.h:284
LINE_READER * m_reader
no ownership here.
Definition: pcb_plugin.h:290

References m_board, m_props, and m_reader.

Referenced by DoLoad(), FootprintDelete(), FootprintEnumerate(), FootprintLibCreate(), FootprintSave(), getFootprint(), IsFootprintLibWritable(), CLIPBOARD_IO::Load(), PCB_PLUGIN(), CLIPBOARD_IO::Save(), and Save().

◆ IsFootprintLibWritable()

bool PCB_PLUGIN::IsFootprintLibWritable ( const wxString &  aLibraryPath)
overridevirtual

Return true if the library at aLibraryPath is writable.

The system libraries are typically read only because of where they are installed..

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Reimplemented from PLUGIN.

Definition at line 2699 of file pcb_plugin.cpp.

2700 {
2701  LOCALE_IO toggle;
2702 
2703  init( nullptr );
2704 
2705  validateCache( aLibraryPath );
2706 
2707  return m_cache->IsWritable();
2708 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void init(const PROPERTIES *aProperties)
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
bool IsWritable() const
Definition: pcb_plugin.cpp:108
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288

References init(), FP_CACHE::IsWritable(), m_cache, and validateCache().

◆ Load()

BOARD * PCB_PLUGIN::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = nullptr,
PROJECT aProject = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
overridevirtual

Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one.

This may be used to load an entire new BOARD, or to augment an existing one if aAppendToMe is not NULL.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aAppendToMeis an existing BOARD to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
aProjectis the optional PROJECT object primarily used by third party importers.
aProgressReporteran optional progress reporter
aLineCounta line count (necessary if a progress reporter is supplied)
Returns
the successfully loaded board, or the same one as aAppendToMe if aAppendToMe was not NULL, and caller owns it.
Exceptions
IO_ERRORif there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible.

Reimplemented from PLUGIN.

Definition at line 2290 of file pcb_plugin.cpp.

2292 {
2293  FILE_LINE_READER reader( aFileName );
2294 
2295  unsigned lineCount = 0;
2296 
2297  if( aProgressReporter )
2298  {
2299  aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
2300 
2301  if( !aProgressReporter->KeepRefreshing() )
2302  THROW_IO_ERROR( _( "Open cancelled by user." ) );
2303 
2304  while( reader.ReadLine() )
2305  lineCount++;
2306 
2307  reader.Rewind();
2308  }
2309 
2310  BOARD* board = DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount );
2311 
2312  // Give the filename to the board if it's new
2313  if( !aAppendToMe )
2314  board->SetFileName( aFileName );
2315 
2316  return board;
2317 }
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const PROPERTIES *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
A LINE_READER that reads from an open file.
Definition: richio.h:172
#define _(s)
void SetFileName(const wxString &aFileName)
Definition: board.h:227
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, DoLoad(), Format(), PROGRESS_REPORTER::KeepRefreshing(), FILE_LINE_READER::ReadLine(), PROGRESS_REPORTER::Report(), FILE_LINE_READER::Rewind(), BOARD::SetFileName(), and THROW_IO_ERROR.

Referenced by PNS_LOG_FILE::Load().

◆ Parse()

BOARD_ITEM * PCB_PLUGIN::Parse ( const wxString &  aClipboardSourceInput)

Definition at line 378 of file pcb_plugin.cpp.

379 {
380  std::string input = TO_UTF8( aClipboardSourceInput );
381 
382  STRING_LINE_READER reader( input, wxT( "clipboard" ) );
383 
384  m_parser->SetLineReader( &reader );
385 
386  try
387  {
388  return m_parser->Parse();
389  }
390  catch( const PARSE_ERROR& parse_error )
391  {
392  if( m_parser->IsTooRecent() )
393  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
394  else
395  throw;
396  }
397 }
PCB_PARSER * m_parser
Definition: pcb_plugin.h:296
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
Definition: pcb_parser.cpp:247
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:627
LINE_READER * SetLineReader(LINE_READER *aReader)
Set aLineReader into the parser, and returns the previous one, if any.
Definition: pcb_parser.h:95
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:133
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:174
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240

References PCB_PARSER::GetRequiredVersion(), PCB_PARSER::IsTooRecent(), m_parser, PCB_PARSER::Parse(), PCB_PARSER::SetLineReader(), and TO_UTF8.

Referenced by CLIPBOARD_IO::Parse(), and parse_footprint_kicad().

◆ PluginName()

const wxString PCB_PLUGIN::PluginName ( ) const
inlineoverridevirtual

Return a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 144 of file pcb_plugin.h.

145  {
146  return wxT( "KiCad" );
147  }

◆ PrefetchLib()

void PLUGIN::PrefetchLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

If possible, prefetches the specified library (e.g.

performing downloads). Does not parse. Threadsafe.

This is a no-op for libraries that cannot be prefetched. Plugins that cannot prefetch need not override this; a default no-op is provided.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is an error prefetching the library.

Definition at line 75 of file plugin.cpp.

76 {
77 }

◆ Save()

void PCB_PLUGIN::Save ( const wxString &  aFileName,
BOARD aBoard,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file.

Parameters
aFileNameis the name of a file to save to on disk.
aBoardis the class BOARD in memory document tree from which to extract information when writing to aFileName. The caller continues to own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
aPropertiesis an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it) and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented from PLUGIN.

Reimplemented in CLIPBOARD_IO.

Definition at line 338 of file pcb_plugin.cpp.

339 {
340  LOCALE_IO toggle; // toggles on, then off, the C locale.
341 
342  wxString sanityResult = aBoard->GroupsSanityCheck();
343 
344  if( sanityResult != wxEmptyString )
345  {
346  KIDIALOG dlg( nullptr, wxString::Format(
347  _( "Please report this bug. Error validating group structure: %s"
348  "\n\nSave anyway?" ), sanityResult ),
349  _( "Internal group data structure corrupt" ),
350  wxOK | wxCANCEL | wxICON_ERROR );
351  dlg.SetOKLabel( _( "Save Anyway" ) );
352 
353  if( dlg.ShowModal() == wxID_CANCEL )
354  return;
355  }
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) (generator pcbnew)\n", SEXPR_BOARD_FILE_VERSION );
369 
370  Format( aBoard, 1 );
371 
372  m_out->Print( 0, ")\n" );
373 
374  m_out = nullptr;
375 }
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
Definition: pcb_plugin.h:105
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
void init(const PROPERTIES *aProperties)
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
Definition: netinfo.h:200
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
#define _(s)
BOARD * m_board
which BOARD, no ownership here
Definition: pcb_plugin.h:284
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:400
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:297
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Used for text file output.
Definition: richio.h:456
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition: board.cpp:1978
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

References _, Format(), Format(), BOARD::GroupsSanityCheck(), init(), m_board, m_mapping, m_out, OUTPUTFORMATTER::Print(), NETINFO_MAPPING::SetBoard(), SEXPR_BOARD_FILE_VERSION, and KIDIALOG::ShowModal().

Referenced by KI_TEST::DumpBoardToFile(), and ROUTER_TOOL::saveRouterDebugLog().

◆ SetOutputFormatter()

void PCB_PLUGIN::SetOutputFormatter ( OUTPUTFORMATTER aFormatter)
inline

Definition at line 221 of file pcb_plugin.h.

221 { m_out = aFormatter; }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294

References m_out.

Referenced by FP_CACHE::Save().

◆ validateCache()

void PCB_PLUGIN::validateCache ( const wxString &  aLibraryPath,
bool  checkModified = true 
)
protected

Definition at line 2367 of file pcb_plugin.cpp.

2368 {
2369  if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) )
2370  {
2371  // a spectacular episode in memory management:
2372  delete m_cache;
2373  m_cache = new FP_CACHE( this, aLibraryPath );
2374  m_cache->Load();
2375  }
2376 }
bool IsModified()
Return true if the cache is not up-to-date.
Definition: pcb_plugin.cpp:322
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
Definition: pcb_plugin.cpp:316
void Load()
Definition: pcb_plugin.cpp:233
friend class FP_CACHE
Definition: pcb_plugin.h:280
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:288

References FP_CACHE, FP_CACHE::IsModified(), FP_CACHE::IsPath(), FP_CACHE::Load(), and m_cache.

Referenced by FootprintDelete(), FootprintEnumerate(), FootprintSave(), getFootprint(), and IsFootprintLibWritable().

Friends And Related Function Documentation

◆ FP_CACHE

friend class FP_CACHE
friend

Definition at line 280 of file pcb_plugin.h.

Referenced by FootprintLibCreate(), and validateCache().

Member Data Documentation

◆ m_board

BOARD* PCB_PLUGIN::m_board
protected

which BOARD, no ownership here

Definition at line 284 of file pcb_plugin.h.

Referenced by formatBoardLayers(), init(), CLIPBOARD_IO::Save(), Save(), CLIPBOARD_IO::SaveSelection(), and CLIPBOARD_IO::SetBoard().

◆ m_cache

FP_CACHE* PCB_PLUGIN::m_cache
protected

◆ m_ctl

int PCB_PLUGIN::m_ctl
protected

Definition at line 295 of file pcb_plugin.h.

Referenced by FootprintSave(), format(), and formatGeneral().

◆ m_error

wxString PCB_PLUGIN::m_error
protected

for throwing exceptions

Definition at line 283 of file pcb_plugin.h.

◆ m_filename

wxString PCB_PLUGIN::m_filename
protected

for saves only, name is in m_reader for loads

Definition at line 291 of file pcb_plugin.h.

◆ m_mapping

NETINFO_MAPPING* PCB_PLUGIN::m_mapping
protected

mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes

Definition at line 297 of file pcb_plugin.h.

Referenced by format(), formatNetInformation(), CLIPBOARD_IO::Save(), Save(), CLIPBOARD_IO::SaveSelection(), and ~PCB_PLUGIN().

◆ m_out

◆ m_parser

PCB_PARSER* PCB_PLUGIN::m_parser
protected

Definition at line 296 of file pcb_plugin.h.

Referenced by DoLoad(), CLIPBOARD_IO::Load(), FP_CACHE::Load(), Parse(), and ~PCB_PLUGIN().

◆ m_props

const PROPERTIES* PCB_PLUGIN::m_props
protected

passed via Save() or Load(), no ownership, may be NULL.

Definition at line 287 of file pcb_plugin.h.

Referenced by init().

◆ m_reader

LINE_READER* PCB_PLUGIN::m_reader
protected

no ownership here.

Definition at line 290 of file pcb_plugin.h.

Referenced by init().

◆ m_sf

STRING_FORMATTER PCB_PLUGIN::m_sf
protected

Definition at line 293 of file pcb_plugin.h.

Referenced by GetStringOutput(), and PCB_PLUGIN().


The documentation for this class was generated from the following files: