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 2269 of file pcb_plugin.cpp.

2269  :
2270  m_cache( nullptr ),
2271  m_ctl( aControlFlags ),
2272  m_parser( new PCB_PARSER() ),
2273  m_mapping( new NETINFO_MAPPING() )
2274 {
2275  init( nullptr );
2276  m_out = &m_sf;
2277 }
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 2280 of file pcb_plugin.cpp.

2281 {
2282  delete m_cache;
2283  delete m_parser;
2284  delete m_mapping;
2285 }
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 2318 of file pcb_plugin.cpp.

2320 {
2321  init( aProperties );
2322 
2323  m_parser->SetLineReader( &aReader );
2324  m_parser->SetBoard( aAppendToMe );
2325  m_parser->SetProgressReporter( aProgressReporter, &aReader, aLineCount );
2326 
2327  BOARD* board;
2328 
2329  try
2330  {
2331  board = dynamic_cast<BOARD*>( m_parser->Parse() );
2332  }
2333  catch( const FUTURE_FORMAT_ERROR& )
2334  {
2335  // Don't wrap a FUTURE_FORMAT_ERROR in another
2336  throw;
2337  }
2338  catch( const PARSE_ERROR& parse_error )
2339  {
2340  if( m_parser->IsTooRecent() )
2341  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
2342  else
2343  throw;
2344  }
2345 
2346  if( !board )
2347  {
2348  // The parser loaded something that was valid, but wasn't a board.
2349  THROW_PARSE_ERROR( _( "This file does not contain a PCB." ), m_parser->CurSource(),
2350  m_parser->CurLine(), m_parser->CurLineNumber(), m_parser->CurOffset() );
2351  }
2352 
2353  return board;
2354 }
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:246
#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:626
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 2576 of file pcb_plugin.cpp.

2578 {
2579  LOCALE_IO toggle; // toggles on, then off, the C locale.
2580 
2581  init( aProperties );
2582 
2583  validateCache( aLibraryPath );
2584 
2585  if( !m_cache->IsWritable() )
2586  {
2587  THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only." ),
2588  aLibraryPath.GetData() ) );
2589  }
2590 
2591  m_cache->Remove( aFootprintName );
2592 }
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 2377 of file pcb_plugin.cpp.

2379 {
2380  LOCALE_IO toggle; // toggles on, then off, the C locale.
2381  wxDir dir( aLibPath );
2382  wxString errorMsg;
2383 
2384  init( aProperties );
2385 
2386  try
2387  {
2388  validateCache( aLibPath );
2389  }
2390  catch( const IO_ERROR& ioe )
2391  {
2392  errorMsg = ioe.What();
2393  }
2394 
2395  // Some of the files may have been parsed correctly so we want to add the valid files to
2396  // the library.
2397 
2398  for( const auto& footprint : m_cache->GetFootprints() )
2399  aFootprintNames.Add( footprint.first );
2400 
2401  if( !errorMsg.IsEmpty() && !aBestEfforts )
2402  THROW_IO_ERROR( errorMsg );
2403 }
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 2442 of file pcb_plugin.cpp.

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

2603 {
2604  if( wxDir::Exists( aLibraryPath ) )
2605  {
2606  THROW_IO_ERROR( wxString::Format( _( "Cannot overwrite library path '%s'." ),
2607  aLibraryPath.GetData() ) );
2608  }
2609 
2610  LOCALE_IO toggle;
2611 
2612  init( aProperties );
2613 
2614  delete m_cache;
2615  m_cache = new FP_CACHE( this, aLibraryPath );
2616  m_cache->Save();
2617 }
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 2620 of file pcb_plugin.cpp.

2621 {
2622  wxFileName fn;
2623  fn.SetPath( aLibraryPath );
2624 
2625  // Return if there is no library path to delete.
2626  if( !fn.DirExists() )
2627  return false;
2628 
2629  if( !fn.IsDirWritable() )
2630  {
2631  THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete folder '%s'." ),
2632  aLibraryPath.GetData() ) );
2633  }
2634 
2635  wxDir dir( aLibraryPath );
2636 
2637  if( dir.HasSubDirs() )
2638  {
2639  THROW_IO_ERROR( wxString::Format( _( "Library folder '%s' has unexpected sub-folders." ),
2640  aLibraryPath.GetData() ) );
2641  }
2642 
2643  // All the footprint files must be deleted before the directory can be deleted.
2644  if( dir.HasFiles() )
2645  {
2646  unsigned i;
2647  wxFileName tmp;
2648  wxArrayString files;
2649 
2650  wxDir::GetAllFiles( aLibraryPath, &files );
2651 
2652  for( i = 0; i < files.GetCount(); i++ )
2653  {
2654  tmp = files[i];
2655 
2656  if( tmp.GetExt() != KiCadFootprintFileExtension )
2657  {
2658  THROW_IO_ERROR( wxString::Format( _( "Unexpected file '%s' found in library "
2659  "path '%s'." ),
2660  files[i].GetData(),
2661  aLibraryPath.GetData() ) );
2662  }
2663  }
2664 
2665  for( i = 0; i < files.GetCount(); i++ )
2666  wxRemoveFile( files[i] );
2667  }
2668 
2669  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint library '%s'." ),
2670  aLibraryPath.GetData() );
2671 
2672  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2673  // we don't want that. we want bare metal portability with no UI here.
2674  if( !wxRmdir( aLibraryPath ) )
2675  {
2676  THROW_IO_ERROR( wxString::Format( _( "Footprint library '%s' cannot be deleted." ),
2677  aLibraryPath.GetData() ) );
2678  }
2679 
2680  // For some reason removing a directory in Windows is not immediately updated. This delay
2681  // prevents an error when attempting to immediately recreate the same directory when over
2682  // writing an existing library.
2683 #ifdef __WINDOWS__
2684  wxMilliSleep( 250L );
2685 #endif
2686 
2687  if( m_cache && !m_cache->IsPath( aLibraryPath ) )
2688  {
2689  delete m_cache;
2690  m_cache = nullptr;
2691  }
2692 
2693  return true;
2694 }
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( _(
152  "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
153  ));
154 
155  (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
156  "Regular expression <b>footprint name</b> filter."
157  ));
158 
159  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
160  "Enable transaction logging. The mere presence of this option turns on the "
161  "logging, no need to set a Value."
162  ));
163 
164  (*aListToAppendTo)["username"] = UTF8( _(
165  "User name for <b>login</b> to some special library server."
166  ));
167 
168  (*aListToAppendTo)["password"] = UTF8( _(
169  "Password for <b>login</b> to some special library server."
170  ));
171 #endif
172 
173 #if 1
174  // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
175  // if and when implemented.
176  (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
177  "Enter the python module which implements the PLUGIN::Footprint*() functions."
178  ));
179 #endif
180 }
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 2458 of file pcb_plugin.cpp.

2462 {
2463  const FOOTPRINT* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
2464 
2465  if( footprint )
2466  {
2467  FOOTPRINT* copy;
2468 
2469  if( aKeepUUID )
2470  copy = static_cast<FOOTPRINT*>( footprint->Clone() );
2471  else
2472  copy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
2473 
2474  copy->SetParent( nullptr );
2475  return copy;
2476  }
2477 
2478  return nullptr;
2479 }
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1724
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1292
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 2482 of file pcb_plugin.cpp.

2484 {
2485  LOCALE_IO toggle; // toggles on, then off, the C locale.
2486 
2487  init( aProperties );
2488 
2489  // In this public PLUGIN API function, we can safely assume it was
2490  // called for saving into a library path.
2492 
2493  validateCache( aLibraryPath );
2494 
2495  if( !m_cache->IsWritable() )
2496  {
2497  if( !m_cache->Exists() )
2498  {
2499  const wxString msg = wxString::Format( _( "Library '%s' does not exist.\n"
2500  "Would you like to create it?"),
2501  aLibraryPath );
2502 
2503  if( wxMessageBox( msg, _( "Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2504  return;
2505 
2506  // Save throws its own IO_ERROR on failure, so no need to recreate here
2507  m_cache->Save( nullptr );
2508  }
2509  else
2510  {
2511  wxString msg = wxString::Format( _( "Library '%s' is read only." ), aLibraryPath );
2512  THROW_IO_ERROR( msg );
2513  }
2514  }
2515 
2516  wxString footprintName = aFootprint->GetFPID().GetLibItemName();
2517 
2518  FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
2519 
2520  // Quietly overwrite footprint and delete footprint file from path for any by same name.
2521  wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
2523 
2524  // Write through symlinks, don't replace them
2526 
2527  if( !fn.IsOk() )
2528  {
2529  THROW_IO_ERROR( wxString::Format( _( "Footprint file name '%s' is not valid." ),
2530  fn.GetFullPath() ) );
2531  }
2532 
2533  if( fn.FileExists() && !fn.IsFileWritable() )
2534  {
2535  THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete '%s'." ),
2536  fn.GetFullPath() ) );
2537  }
2538 
2539  wxString fullPath = fn.GetFullPath();
2540  wxString fullName = fn.GetFullName();
2541  FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
2542 
2543  if( it != footprints.end() )
2544  {
2545  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
2546  footprints.erase( footprintName );
2547  wxRemoveFile( fullPath );
2548  }
2549 
2550  // I need my own copy for the cache
2551  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() );
2552 
2553  // It's orientation should be zero and it should be on the front layer.
2554  footprint->SetOrientation( 0 );
2555 
2556  if( footprint->GetLayer() != F_Cu )
2557  {
2558  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
2559 
2560  if( cfg )
2561  footprint->Flip( footprint->GetPosition(), cfg->m_FlipLeftRight );
2562  else
2563  footprint->Flip( footprint->GetPosition(), false );
2564  }
2565 
2566  // Detach it from the board
2567  footprint->SetParent( nullptr );
2568 
2569  wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
2570  footprints.insert( footprintName,
2571  new FP_CACHE_ITEM( footprint, WX_FILENAME( fn.GetPath(), fullName ) ) );
2572  m_cache->Save( footprint );
2573 }
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:1680
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1490
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:1292
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:142
#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:230
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:485
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( "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:89
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:230
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1185
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:81
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:207
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:92
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:485

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 1767 of file pcb_plugin.cpp.

1768 {
1769  // Don't write empty groups
1770  if( aGroup->GetItems().empty() )
1771  return;
1772 
1773  m_out->Print( aNestLevel, "(group %s%s (id %s)\n",
1774  m_out->Quotew( aGroup->GetName() ).c_str(),
1775  aGroup->IsLocked() ? " locked" : "",
1776  TO_UTF8( aGroup->m_Uuid.AsString() ) );
1777 
1778  m_out->Print( aNestLevel + 1, "(members\n" );
1779 
1780  wxArrayString memberIds;
1781 
1782  for( BOARD_ITEM* member : aGroup->GetItems() )
1783  memberIds.Add( member->m_Uuid.AsString() );
1784 
1785  memberIds.Sort();
1786 
1787  for( const wxString& memberId : memberIds )
1788  m_out->Print( aNestLevel + 2, "%s\n", TO_UTF8( memberId ) );
1789 
1790  m_out->Print( aNestLevel + 1, ")\n" ); // Close `members` token.
1791  m_out->Print( aNestLevel, ")\n" ); // Close `group` token.
1792 }
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:230
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:485

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:230
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:485

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:294
#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:198
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:204
#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:579
double GetOrientation() const
Definition: footprint.h:191
wxString AsString() const
Definition: kiid.cpp:230
#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:344
PADS & Pads()
Definition: footprint.h:169
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:500
FP_TEXT & Reference()
Definition: footprint.h:501
#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:520
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:210
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
bool IsPlaced() const
Definition: footprint.h:312
const LIB_ID & GetFPID() const
Definition: footprint.h:195
const wxString & GetKeywords() const
Definition: footprint.h:201
int GetThermalWidth() const
Definition: footprint.h:231
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:689
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:207
int GetAttributes() const
Definition: footprint.h:236
wxString AsString() const
Definition: kiid.cpp:310
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:224
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:507
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:228
int GetPlacementCost90() const
Definition: footprint.h:582
void formatLayer(const BOARD_ITEM *aItem) const
Definition: pcb_plugin.cpp:466
int GetLocalSolderPasteMargin() const
Definition: footprint.h:221
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:234
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
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( "unknown pad attribute: %d", aPad->GetAttribute() ) );
1405  }
1406 
1407  const char* property = nullptr;
1408 
1409  switch( aPad->GetProperty() )
1410  {
1411  case PAD_PROP::NONE: break; // could be "none"
1412  case PAD_PROP::BGA: property = "pad_prop_bga"; break;
1413  case PAD_PROP::FIDUCIAL_GLBL: property = "pad_prop_fiducial_glob"; break;
1414  case PAD_PROP::FIDUCIAL_LOCAL: property = "pad_prop_fiducial_loc"; break;
1415  case PAD_PROP::TESTPOINT: property = "pad_prop_testpoint"; break;
1416  case PAD_PROP::HEATSINK: property = "pad_prop_heatsink"; break;
1417  case PAD_PROP::CASTELLATED: property = "pad_prop_castellated"; break;
1418 
1419  default:
1420  THROW_IO_ERROR( wxString::Format( "unknown pad property: %d", aPad->GetProperty() ) );
1421  }
1422 
1423  m_out->Print( aNestLevel, "(pad %s %s %s",
1424  m_out->Quotew( aPad->GetNumber() ).c_str(),
1425  type,
1426  shape );
1427 
1428  if( aPad->IsLocked() )
1429  m_out->Print( 0, " locked" );
1430 
1431  m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() );
1432 
1433  if( aPad->GetOrientation() != 0.0 )
1434  m_out->Print( 0, " %s", FormatAngle( aPad->GetOrientation() ).c_str() );
1435 
1436  m_out->Print( 0, ")" );
1437 
1438  m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() );
1439 
1440  if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
1441  m_out->Print( 0, " (rect_delta %s)", FormatInternalUnits( aPad->GetDelta() ).c_str() );
1442 
1443  wxSize sz = aPad->GetDrillSize();
1444  wxPoint shapeoffset = aPad->GetOffset();
1445 
1446  if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
1447  (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1448  {
1449  m_out->Print( 0, " (drill" );
1450 
1451  if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1452  m_out->Print( 0, " oval" );
1453 
1454  if( sz.GetWidth() > 0 )
1455  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetWidth() ).c_str() );
1456 
1457  if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
1458  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetHeight() ).c_str() );
1459 
1460  if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1461  m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() );
1462 
1463  m_out->Print( 0, ")" );
1464  }
1465 
1466  // Add pad property, if exists.
1467  if( property )
1468  m_out->Print( 0, " (property %s)", property );
1469 
1470  formatLayers( aPad->GetLayerSet() );
1471 
1472  if( aPad->GetAttribute() == PAD_ATTRIB::PTH )
1473  {
1474  if( aPad->GetRemoveUnconnected() )
1475  {
1476  m_out->Print( 0, " (remove_unused_layers)" );
1477 
1478  if( aPad->GetKeepTopBottom() )
1479  m_out->Print( 0, " (keep_end_layers)" );
1480  }
1481  }
1482 
1483  // Output the radius ratio for rounded and chamfered rect pads
1484  if( aPad->GetShape() == PAD_SHAPE::ROUNDRECT || aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1485  {
1486  m_out->Print( 0, " (roundrect_rratio %s)",
1487  Double2Str( aPad->GetRoundRectRadiusRatio() ).c_str() );
1488  }
1489 
1490  // Output the chamfer corners for chamfered rect pads
1491  if( aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1492  {
1493  m_out->Print( 0, "\n" );
1494 
1495  m_out->Print( aNestLevel+1, "(chamfer_ratio %s)",
1496  Double2Str( aPad->GetChamferRectRatio() ).c_str() );
1497 
1498  m_out->Print( 0, " (chamfer" );
1499 
1500  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT ) )
1501  m_out->Print( 0, " top_left" );
1502 
1503  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT ) )
1504  m_out->Print( 0, " top_right" );
1505 
1506  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT ) )
1507  m_out->Print( 0, " bottom_left" );
1508 
1510  m_out->Print( 0, " bottom_right" );
1511 
1512  m_out->Print( 0, ")" );
1513  }
1514 
1515  std::string output;
1516 
1517  // Unconnected pad is default net so don't save it.
1518  if( !( m_ctl & CTL_OMIT_PAD_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED )
1519  {
1520  StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
1521  m_out->Quotew( aPad->GetNetname() ).c_str() );
1522  }
1523 
1524  // Pin functions and types are closely related to nets, so if CTL_OMIT_NETS is set, omit
1525  // them as well (for instance when saved from library editor).
1526  if( !( m_ctl & CTL_OMIT_PAD_NETS ) )
1527  {
1528  if( !aPad->GetPinFunction().IsEmpty() )
1529  {
1530  StrPrintf( &output, " (pinfunction %s)",
1531  m_out->Quotew( aPad->GetPinFunction() ).c_str() );
1532  }
1533 
1534  if( !aPad->GetPinType().IsEmpty() )
1535  {
1536  StrPrintf( &output, " (pintype %s)",
1537  m_out->Quotew( aPad->GetPinType() ).c_str() );
1538  }
1539  }
1540 
1541  if( aPad->GetPadToDieLength() != 0 )
1542  {
1543  StrPrintf( &output, " (die_length %s)",
1544  FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() );
1545  }
1546 
1547  if( aPad->GetLocalSolderMaskMargin() != 0 )
1548  {
1549  StrPrintf( &output, " (solder_mask_margin %s)",
1550  FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() );
1551  }
1552 
1553  if( aPad->GetLocalSolderPasteMargin() != 0 )
1554  {
1555  StrPrintf( &output, " (solder_paste_margin %s)",
1556  FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() );
1557  }
1558 
1559  if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
1560  {
1561  StrPrintf( &output, " (solder_paste_margin_ratio %s)",
1562  Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() );
1563  }
1564 
1565  if( aPad->GetLocalClearance() != 0 )
1566  {
1567  StrPrintf( &output, " (clearance %s)",
1568  FormatInternalUnits( aPad->GetLocalClearance() ).c_str() );
1569  }
1570 
1572  {
1573  StrPrintf( &output, " (zone_connect %d)",
1574  static_cast<int>( aPad->GetZoneConnection() ) );
1575  }
1576 
1577  if( aPad->GetThermalSpokeWidth() != 0 )
1578  {
1579  StrPrintf( &output, " (thermal_width %s)",
1580  FormatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() );
1581  }
1582 
1583  if( aPad->GetThermalGap() != 0 )
1584  {
1585  StrPrintf( &output, " (thermal_gap %s)",
1586  FormatInternalUnits( aPad->GetThermalGap() ).c_str() );
1587  }
1588 
1589  if( output.size() )
1590  {
1591  m_out->Print( 0, "\n" );
1592  m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
1593  }
1594 
1595  if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
1596  {
1597  m_out->Print( 0, "\n");
1598  m_out->Print( aNestLevel+1, "(options" );
1599 
1601  m_out->Print( 0, " (clearance convexhull)" );
1602  #if 1 // Set to 1 to output the default option
1603  else
1604  m_out->Print( 0, " (clearance outline)" );
1605  #endif
1606 
1607  // Output the anchor pad shape (circle/rect)
1608  if( aPad->GetAnchorPadShape() == PAD_SHAPE::RECT )
1609  shape = "rect";
1610  else
1611  shape = "circle";
1612 
1613  m_out->Print( 0, " (anchor %s)", shape );
1614 
1615  m_out->Print( 0, ")"); // end of (options ...
1616 
1617  // Output graphic primitive of the pad shape
1618  m_out->Print( 0, "\n");
1619  m_out->Print( aNestLevel+1, "(primitives" );
1620 
1621  int nested_level = aNestLevel+2;
1622 
1623  // Output all basic shapes
1624  for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
1625  {
1626  m_out->Print( 0, "\n");
1627 
1628  switch( primitive->GetShape() )
1629  {
1630  case SHAPE_T::SEGMENT:
1631  m_out->Print( nested_level, "(gr_line (start %s) (end %s)",
1632  FormatInternalUnits( primitive->GetStart() ).c_str(),
1633  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1634  break;
1635 
1636  case SHAPE_T::RECT:
1637  m_out->Print( nested_level, "(gr_rect (start %s) (end %s)",
1638  FormatInternalUnits( primitive->GetStart() ).c_str(),
1639  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1640  break;
1641 
1642  case SHAPE_T::ARC:
1643  m_out->Print( aNestLevel, "(gr_arc (start %s) (mid %s) (end %s)",
1644  FormatInternalUnits( primitive->GetStart() ).c_str(),
1645  FormatInternalUnits( primitive->GetArcMid() ).c_str(),
1646  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1647  break;
1648 
1649  case SHAPE_T::CIRCLE:
1650  m_out->Print( nested_level, "(gr_circle (center %s) (end %s)",
1651  FormatInternalUnits( primitive->GetStart() ).c_str(),
1652  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1653  break;
1654 
1655  case SHAPE_T::BEZIER:
1656  m_out->Print( nested_level, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1657  FormatInternalUnits( primitive->GetStart() ).c_str(),
1658  FormatInternalUnits( primitive->GetBezierC1() ).c_str(),
1659  FormatInternalUnits( primitive->GetBezierC2() ).c_str(),
1660  FormatInternalUnits( primitive->GetEnd() ).c_str() );
1661  break;
1662 
1663  case SHAPE_T::POLY:
1664  if( primitive->IsPolyShapeValid() )
1665  {
1666  const SHAPE_POLY_SET& poly = primitive->GetPolyShape();
1667  const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
1668 
1669  m_out->Print( nested_level, "(gr_poly (pts" );
1670 
1671  bool need_newline = false;
1672 
1673  for( int ii = 0; ii < outline.PointCount(); ++ii )
1674  {
1675  nested_level = 0;
1676 
1677  if( !( ii % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave )
1678  {
1679  // newline every 4 pts.
1680  m_out->Print( 0, "\n" );
1681  need_newline = false;
1682  nested_level = aNestLevel + 4;
1683  }
1684 
1685  int ind = outline.ArcIndex( ii );
1686 
1687  if( ind < 0 )
1688  {
1689  m_out->Print( nested_level, "%s(xy %s)",
1690  nested_level ? "" : " ",
1691  FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
1692  need_newline = true;
1693  }
1694  else
1695  {
1696  const SHAPE_ARC& arc = outline.Arc( ind );
1697  m_out->Print( nested_level, "%s(arc (start %s) (mid %s) (end %s))",
1698  nested_level ? "" : " ",
1699  FormatInternalUnits( arc.GetP0() ).c_str(),
1700  FormatInternalUnits( arc.GetArcMid() ).c_str(),
1701  FormatInternalUnits( arc.GetP1() ).c_str() );
1702  need_newline = true;
1703 
1704  do
1705  {
1706  ++ii;
1707  } while( ii < outline.PointCount() && outline.ArcIndex( ii ) == ind );
1708 
1709  --ii;
1710  }
1711  }
1712 
1713  if( need_newline )
1714  m_out->Print( 0, "\n" );
1715 
1716  m_out->Print( aNestLevel + 3, ")" );
1717  }
1718  break;
1719 
1720  default:
1721  break;
1722  }
1723 
1724  m_out->Print( 0, " (width %s)",
1725  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1726 
1727  if( primitive->IsFilled() )
1728  m_out->Print( 0, " (fill yes)" );
1729 
1730  m_out->Print( 0, ")" );
1731  }
1732 
1733  m_out->Print( 0, "\n");
1734  m_out->Print( aNestLevel+1, ")" ); // end of (basic_shapes
1735  }
1736 
1737  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aPad->m_Uuid.AsString() ) );
1738 
1739  m_out->Print( 0, ")\n" );
1740 }
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:523
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:149
wxString AsString() const
Definition: kiid.cpp:230
a test point pad
int PointCount() const
Return the number of points (vertices) in this line chain.
int GetThermalGap() const
Definition: pad.h:499
bool GetKeepTopBottom() const
Definition: pad.h:563
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:476
#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:520
int GetThermalSpokeWidth() const
Definition: pad.h:491
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:718
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:532
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:542
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:557
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:485
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 1743 of file pcb_plugin.cpp.

1744 {
1745  m_out->Print( aNestLevel, "(gr_text %s (at %s",
1746  m_out->Quotew( aText->GetText() ).c_str(),
1747  FormatInternalUnits( aText->GetTextPos() ).c_str() );
1748 
1749  if( aText->GetTextAngle() != 0.0 )
1750  m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() );
1751 
1752  m_out->Print( 0, ")" );
1753 
1754  formatLayer( aText );
1755 
1756  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aText->m_Uuid.AsString() ) );
1757 
1758  m_out->Print( 0, "\n" );
1759 
1760  // PCB_TEXTS are never hidden, so always omit "hide" attribute
1761  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1762 
1763  m_out->Print( aNestLevel, ")\n" );
1764 }
double GetTextAngle() const
Definition: eda_text.h:195
wxString AsString() const
Definition: kiid.cpp:230
#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:520
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:485
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 1795 of file pcb_plugin.cpp.

1796 {
1797  std::string type;
1798 
1799  switch( aText->GetType() )
1800  {
1801  case FP_TEXT::TEXT_is_REFERENCE: type = "reference"; break;
1802  case FP_TEXT::TEXT_is_VALUE: type = "value"; break;
1803  case FP_TEXT::TEXT_is_DIVERS: type = "user";
1804  }
1805 
1806  std::string locked = aText->IsLocked() ? " locked" : "";
1807 
1808  m_out->Print( aNestLevel, "(fp_text %s%s %s (at %s",
1809  type.c_str(),
1810  locked.c_str(),
1811  m_out->Quotew( aText->GetText() ).c_str(),
1812  FormatInternalUnits( aText->GetPos0() ).c_str() );
1813 
1814  // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
1815  // but internally the angle is held relative to its parent footprint. parent
1816  // may be NULL when saving a footprint outside a BOARD.
1817  double orient = aText->GetTextAngle();
1818  FOOTPRINT* parent = (FOOTPRINT*) aText->GetParent();
1819 
1820  if( parent )
1821  {
1822  // GetTextAngle() is always in -360..+360 range because of
1823  // FP_TEXT::SetTextAngle(), but summing that angle with an
1824  // additional board angle could kick sum up >= 360 or <= -360, so to have
1825  // consistent results, normalize again for the BOARD save. A footprint
1826  // save does not use this code path since parent is NULL.
1827 #if 0
1828  // This one could be considered reasonable if you like positive angles
1829  // in your board text.
1830  orient = NormalizeAnglePos( orient + parent->GetOrientation() );
1831 #else
1832  // Choose compatibility for now, even though this is only a 720 degree clamp
1833  // with two possible values for every angle.
1834  orient = NormalizeAngle360Min( orient + parent->GetOrientation() );
1835 #endif
1836  }
1837 
1838  if( orient != 0.0 )
1839  m_out->Print( 0, " %s", FormatAngle( orient ).c_str() );
1840 
1841  if( !aText->IsKeepUpright() )
1842  m_out->Print( 0, " unlocked" );
1843 
1844  m_out->Print( 0, ")" );
1845  formatLayer( aText );
1846 
1847  if( !aText->IsVisible() )
1848  m_out->Print( 0, " hide" );
1849 
1850  m_out->Print( 0, "\n" );
1851 
1852  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1853 
1854  m_out->Print( aNestLevel + 1, "(tstamp %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
1855 
1856  m_out->Print( aNestLevel, ")\n" );
1857 }
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:230
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:520
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:135
#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:485
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 1860 of file pcb_plugin.cpp.

1861 {
1862  if( aTrack->Type() == PCB_VIA_T )
1863  {
1864  PCB_LAYER_ID layer1, layer2;
1865 
1866  const PCB_VIA* via = static_cast<const PCB_VIA*>( aTrack );
1867  BOARD* board = (BOARD*) via->GetParent();
1868 
1869  wxCHECK_RET( board != nullptr, wxT( "Via " ) +
1870  via->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) + wxT( " has no parent." ) );
1871 
1872  m_out->Print( aNestLevel, "(via" );
1873 
1874  via->LayerPair( &layer1, &layer2 );
1875 
1876  switch( via->GetViaType() )
1877  {
1878  case VIATYPE::THROUGH: // Default shape not saved.
1879  break;
1880 
1881  case VIATYPE::BLIND_BURIED:
1882  m_out->Print( 0, " blind" );
1883  break;
1884 
1885  case VIATYPE::MICROVIA:
1886  m_out->Print( 0, " micro" );
1887  break;
1888 
1889  default:
1890  THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
1891  }
1892 
1893  if( via->IsLocked() )
1894  m_out->Print( 0, " locked" );
1895 
1896  m_out->Print( 0, " (at %s) (size %s)",
1897  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1898  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1899 
1900  // Old boards were using UNDEFINED_DRILL_DIAMETER value in file for via drill when
1901  // via drill was the netclass value.
1902  // recent boards always set the via drill to the actual value, but now we need to
1903  // always store the drill value, because netclass value is not stored in the board file.
1904  // Otherwise the drill value of some (old) vias can be unknown
1905  if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
1906  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrill() ).c_str() );
1907  else // Probably old board!
1908  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrillValue() ).c_str() );
1909 
1910  m_out->Print( 0, " (layers %s %s)",
1911  m_out->Quotew( LSET::Name( layer1 ) ).c_str(),
1912  m_out->Quotew( LSET::Name( layer2 ) ).c_str() );
1913 
1914  if( via->GetRemoveUnconnected() )
1915  {
1916  m_out->Print( 0, " (remove_unused_layers)" );
1917 
1918  if( via->GetKeepTopBottom() )
1919  m_out->Print( 0, " (keep_end_layers)" );
1920  }
1921 
1922  if( via->GetIsFree() )
1923  m_out->Print( 0, " (free)" );
1924  }
1925  else if( aTrack->Type() == PCB_ARC_T )
1926  {
1927  const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
1928  std::string locked = arc->IsLocked() ? " locked" : "";
1929 
1930  m_out->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s) (width %s)",
1931  locked.c_str(),
1932  FormatInternalUnits( arc->GetStart() ).c_str(),
1933  FormatInternalUnits( arc->GetMid() ).c_str(),
1934  FormatInternalUnits( arc->GetEnd() ).c_str(),
1935  FormatInternalUnits( arc->GetWidth() ).c_str() );
1936 
1937  m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( arc->GetLayer() ) ).c_str() );
1938  }
1939  else
1940  {
1941  std::string locked = aTrack->IsLocked() ? " locked" : "";
1942 
1943  m_out->Print( aNestLevel, "(segment%s (start %s) (end %s) (width %s)",
1944  locked.c_str(),
1945  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1946  FormatInternalUnits( aTrack->GetEnd() ).c_str(),
1947  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1948 
1949  m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( aTrack->GetLayer() ) ).c_str() );
1950  }
1951 
1952  m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
1953 
1954  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTrack->m_Uuid.AsString() ) );
1955 
1956  m_out->Print( 0, ")\n" );
1957 }
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:230
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:142
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
const wxPoint & GetMid() const
Definition: pcb_track.h:271
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
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 1960 of file pcb_plugin.cpp.

1961 {
1962  std::string locked = aZone->IsLocked() ? " locked" : "";
1963 
1964  // Save the NET info; For keepout zones, net code and net name are irrelevant
1965  // so be sure a dummy value is stored, just for ZONE compatibility
1966  // (perhaps netcode and netname should be not stored)
1967  m_out->Print( aNestLevel, "(zone%s (net %d) (net_name %s)",
1968  locked.c_str(),
1969  aZone->GetIsRuleArea() ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
1970  m_out->Quotew( aZone->GetIsRuleArea() ? wxT("") : aZone->GetNetname() ).c_str() );
1971 
1972  // If a zone exists on multiple layers, format accordingly
1973  if( aZone->GetLayerSet().count() > 1 )
1974  {
1975  formatLayers( aZone->GetLayerSet() );
1976  }
1977  else
1978  {
1979  formatLayer( aZone );
1980  }
1981 
1982  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aZone->m_Uuid.AsString() ) );
1983 
1984  if( !aZone->GetZoneName().empty() )
1985  m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
1986 
1987  // Save the outline aux info
1988  std::string hatch;
1989 
1990  switch( aZone->GetHatchStyle() )
1991  {
1992  default:
1993  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: hatch = "none"; break;
1994  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: hatch = "edge"; break;
1995  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: hatch = "full"; break;
1996  }
1997 
1998  m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
1999  FormatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() );
2000 
2001  if( aZone->GetPriority() > 0 )
2002  m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetPriority() );
2003 
2004  m_out->Print( aNestLevel+1, "(connect_pads" );
2005 
2006  switch( aZone->GetPadConnection() )
2007  {
2008  default:
2009  case ZONE_CONNECTION::THERMAL: // Default option not saved or loaded.
2010  break;
2011 
2013  m_out->Print( 0, " thru_hole_only" );
2014  break;
2015 
2016  case ZONE_CONNECTION::FULL:
2017  m_out->Print( 0, " yes" );
2018  break;
2019 
2020  case ZONE_CONNECTION::NONE:
2021  m_out->Print( 0, " no" );
2022  break;
2023  }
2024 
2025  m_out->Print( 0, " (clearance %s))\n",
2026  FormatInternalUnits( aZone->GetLocalClearance() ).c_str() );
2027 
2028  m_out->Print( aNestLevel+1, "(min_thickness %s)",
2029  FormatInternalUnits( aZone->GetMinThickness() ).c_str() );
2030 
2031  // write it only if V 6.O version option is used (i.e. do not write if the "legacy"
2032  // algorithm is used)
2033  if( !aZone->GetFilledPolysUseThickness() )
2034  m_out->Print( 0, " (filled_areas_thickness no)" );
2035 
2036  m_out->Print( 0, "\n" );
2037 
2038  if( aZone->GetIsRuleArea() )
2039  {
2040  m_out->Print( aNestLevel + 1,
2041  "(keepout (tracks %s) (vias %s) (pads %s ) (copperpour %s) "
2042  "(footprints %s))\n",
2043  aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
2044  aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
2045  aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
2046  aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
2047  aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
2048  }
2049 
2050  m_out->Print( aNestLevel + 1, "(fill" );
2051 
2052  // Default is not filled.
2053  if( aZone->IsFilled() )
2054  m_out->Print( 0, " yes" );
2055 
2056  // Default is polygon filled.
2057  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2058  m_out->Print( 0, " (mode hatch)" );
2059 
2060  m_out->Print( 0, " (thermal_gap %s) (thermal_bridge_width %s)",
2061  FormatInternalUnits( aZone->GetThermalReliefGap() ).c_str(),
2062  FormatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() );
2063 
2065  {
2066  m_out->Print( 0, " (smoothing" );
2067 
2068  switch( aZone->GetCornerSmoothingType() )
2069  {
2071  m_out->Print( 0, " chamfer" );
2072  break;
2073 
2075  m_out->Print( 0, " fillet" );
2076  break;
2077 
2078  default:
2079  THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
2080  aZone->GetCornerSmoothingType() ) );
2081  }
2082  m_out->Print( 0, ")" );
2083 
2084  if( aZone->GetCornerRadius() != 0 )
2085  m_out->Print( 0, " (radius %s)",
2086  FormatInternalUnits( aZone->GetCornerRadius() ).c_str() );
2087  }
2088 
2090  {
2091  m_out->Print( 0, " (island_removal_mode %d) (island_area_min %s)",
2092  static_cast<int>( aZone->GetIslandRemovalMode() ),
2093  FormatInternalUnits( aZone->GetMinIslandArea() / IU_PER_MM ).c_str() );
2094  }
2095 
2096  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2097  {
2098  m_out->Print( 0, "\n" );
2099  m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2100  FormatInternalUnits( aZone->GetHatchThickness() ).c_str(),
2101  FormatInternalUnits( aZone->GetHatchGap() ).c_str(),
2102  Double2Str( aZone->GetHatchOrientation() ).c_str() );
2103 
2104  if( aZone->GetHatchSmoothingLevel() > 0 )
2105  {
2106  m_out->Print( 0, "\n" );
2107  m_out->Print( aNestLevel+2, "(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2108  aZone->GetHatchSmoothingLevel(),
2109  Double2Str( aZone->GetHatchSmoothingValue() ).c_str() );
2110  }
2111 
2112  m_out->Print( 0, "\n" );
2113  m_out->Print( aNestLevel+2, "(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2114  aZone->GetHatchBorderAlgorithm() ? "hatch_thickness" : "min_thickness",
2115  Double2Str( aZone->GetHatchHoleMinArea() ).c_str() );
2116  }
2117 
2118  m_out->Print( 0, ")\n" );
2119 
2120  if( aZone->GetNumCorners() )
2121  {
2122  SHAPE_POLY_SET::POLYGON poly = aZone->Outline()->Polygon(0);
2123 
2124  for( auto& chain : poly )
2125  {
2126  m_out->Print( aNestLevel + 1, "(polygon\n" );
2127  m_out->Print( aNestLevel + 2, "(pts" );
2128 
2129  bool need_newline = true;
2130 
2131  for( int ii = 0; ii < chain.PointCount(); ++ii )
2132  {
2133  int nestLevel = 0;
2134 
2135  if( !( ii % 4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) // newline every 4 pts
2136  {
2137  m_out->Print( 0, "\n" );
2138  need_newline = false;
2139  nestLevel = aNestLevel + 3;
2140  }
2141 
2142  int ind = chain.ArcIndex( ii );
2143 
2144  if( ind < 0 )
2145  {
2146  m_out->Print( nestLevel, "%s(xy %s)",
2147  nestLevel ? "" : " ",
2148  FormatInternalUnits( chain.CPoint( ii ) ).c_str() );
2149  need_newline = true;
2150  }
2151  else
2152  {
2153  auto& arc = chain.Arc( ind );
2154  m_out->Print( nestLevel, "%s(arc (start %s) (mid %s) (end %s))",
2155  nestLevel ? "" : " ",
2156  FormatInternalUnits( arc.GetP0() ).c_str(),
2157  FormatInternalUnits( arc.GetArcMid() ).c_str(),
2158  FormatInternalUnits( arc.GetP1() ).c_str() );
2159  need_newline = true;
2160 
2161  do
2162  {
2163  ++ii;
2164  } while( ii < chain.PointCount() && chain.ArcIndex( ii ) == ind );
2165 
2166  --ii;
2167  }
2168  }
2169 
2170  if( need_newline )
2171  m_out->Print( 0, "\n" );
2172 
2173  m_out->Print( aNestLevel + 2, ")\n" );
2174  m_out->Print( aNestLevel + 1, ")\n" );
2175 
2176  }
2177  }
2178 
2179  // Save the PolysList (filled areas)
2180  for( PCB_LAYER_ID layer : aZone->GetLayerSet().Seq() )
2181  {
2182  const SHAPE_POLY_SET& fv = aZone->GetFilledPolysList( layer );
2183 
2184  for( int ii = 0; ii < fv.OutlineCount(); ++ii )
2185  {
2186  m_out->Print( aNestLevel + 1, "(filled_polygon\n" );
2187  m_out->Print( aNestLevel + 2, "(layer %s)\n",
2188  m_out->Quotew( LSET::Name( layer ) ).c_str() );
2189 
2190  if( aZone->IsIsland( layer, ii ) )
2191  m_out->Print( aNestLevel + 2, "(island)\n" );
2192 
2193  m_out->Print( aNestLevel + 2, "(pts" );
2194 
2195  const SHAPE_LINE_CHAIN& chain = fv.COutline( ii );
2196 
2197  bool need_newline = true;
2198 
2199  for( int jj = 0; jj < chain.PointCount(); ++jj )
2200  {
2201  int nestLevel = 0;
2202 
2203  if( !( jj%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) // newline every 4 pts
2204  {
2205  m_out->Print( 0, "\n" );
2206  need_newline = false;
2207  nestLevel = aNestLevel + 3;
2208  }
2209 
2210  int ind = chain.ArcIndex( jj );
2211 
2212  if( ind < 0 )
2213  {
2214  m_out->Print( nestLevel, "%s(xy %s)",
2215  nestLevel ? "" : " ",
2216  FormatInternalUnits( chain.CPoint( jj ) ).c_str() );
2217  need_newline = true;
2218  }
2219  else
2220  {
2221  auto& arc = chain.Arc( ind );
2222  m_out->Print( nestLevel, "%s(arc (start %s) (mid %s) (end %s))",
2223  nestLevel ? "" : " ",
2224  FormatInternalUnits( arc.GetP0() ).c_str(),
2225  FormatInternalUnits( arc.GetArcMid() ).c_str(),
2226  FormatInternalUnits( arc.GetP1() ).c_str() );
2227  need_newline = true;
2228 
2229  do
2230  {
2231  ++jj;
2232  } while( jj < chain.PointCount() && chain.ArcIndex( jj ) == ind );
2233 
2234  --jj;
2235  }
2236  }
2237 
2238  if( need_newline )
2239  m_out->Print( 0, "\n" );
2240 
2241  m_out->Print( aNestLevel+2, ")\n" );
2242  m_out->Print( aNestLevel+1, ")\n" );
2243  }
2244 
2245  // Save the filling segments list
2246  const std::vector<SEG>& segs = aZone->FillSegments( layer );
2247 
2248  if( segs.size() )
2249  {
2250  m_out->Print( aNestLevel + 1, "(fill_segments\n" );
2251  m_out->Print( aNestLevel + 2, "(layer %s)\n",
2252  TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
2253 
2254  for( const SEG& seg : segs )
2255  {
2256  m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n",
2257  FormatInternalUnits( wxPoint( seg.A ) ).c_str(),
2258  FormatInternalUnits( wxPoint( seg.B ) ).c_str() );
2259  }
2260 
2261  m_out->Print( aNestLevel + 1, ")\n" );
2262  }
2263  }
2264 
2265  m_out->Print( aNestLevel, ")\n" );
2266 }
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:523
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:738
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:733
static constexpr double IU_PER_MM
Mock up a conversion function.
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:904
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
bool GetDoNotAllowVias() const
Definition: zone.h:735
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:295
double GetHatchSmoothingValue() const
Definition: zone.h:265
wxString AsString() const
Definition: kiid.cpp:230
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:635
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:737
bool GetDoNotAllowCopperPour() const
Definition: zone.h:734
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:498
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:294
bool GetDoNotAllowTracks() const
Definition: zone.h:736
#define _(s)
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:613
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:687
int GetHatchBorderAlgorithm() const
Definition: zone.h:271
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:749
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1137
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:752
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:788
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:683
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
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:689

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:466
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:485
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:142
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:505
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:485
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 2434 of file pcb_plugin.cpp.

2437 {
2438  return getFootprint( aLibraryPath, aFootprintName, aProperties, false );
2439 }
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 2406 of file pcb_plugin.cpp.

2410 {
2411  LOCALE_IO toggle; // toggles on, then off, the C locale.
2412 
2413  init( aProperties );
2414 
2415  try
2416  {
2417  validateCache( aLibraryPath, checkModified );
2418  }
2419  catch( const IO_ERROR& )
2420  {
2421  // do nothing with the error
2422  }
2423 
2424  FOOTPRINT_MAP& footprints = m_cache->GetFootprints();
2425  FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
2426 
2427  if( it == footprints.end() )
2428  return nullptr;
2429 
2430  return it->second->GetFootprint();
2431 }
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 2596 of file pcb_plugin.cpp.

2597 {
2598  return FP_CACHE::GetTimestamp( aLibraryPath );
2599 }
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 2357 of file pcb_plugin.cpp.

2358 {
2359  m_board = nullptr;
2360  m_reader = nullptr;
2361  m_props = aProperties;
2362 }
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 2697 of file pcb_plugin.cpp.

2698 {
2699  LOCALE_IO toggle;
2700 
2701  init( nullptr );
2702 
2703  validateCache( aLibraryPath );
2704 
2705  return m_cache->IsWritable();
2706 }
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 2288 of file pcb_plugin.cpp.

2290 {
2291  FILE_LINE_READER reader( aFileName );
2292 
2293  unsigned lineCount = 0;
2294 
2295  if( aProgressReporter )
2296  {
2297  aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
2298 
2299  if( !aProgressReporter->KeepRefreshing() )
2300  THROW_IO_ERROR( _( "Open cancelled by user." ) );
2301 
2302  while( reader.ReadLine() )
2303  lineCount++;
2304 
2305  reader.Rewind();
2306  }
2307 
2308  BOARD* board = DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount );
2309 
2310  // Give the filename to the board if it's new
2311  if( !aAppendToMe )
2312  board->SetFileName( aFileName );
2313 
2314  return board;
2315 }
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:246
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:626
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:2023
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 2365 of file pcb_plugin.cpp.

2366 {
2367  if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) )
2368  {
2369  // a spectacular episode in memory management:
2370  delete m_cache;
2371  m_cache = new FP_CACHE( this, aLibraryPath );
2372  m_cache->Load();
2373  }
2374 }
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: