KiCad PCB EDA Suite
PCB_IO Class Reference

PCB_IO is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. More...

#include <kicad_plugin.h>

Inheritance diagram for PCB_IO:
PLUGIN CLIPBOARD_IO GITHUB_PLUGIN

Public Member Functions

const wxString PluginName () const override
 Function PluginName returns a brief hard coded name for this PLUGIN. More...
 
const wxString GetFileExtension () const override
 Function GetFileExtension returns the file extension for the PLUGIN. More...
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL) override
 Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows 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=NULL) override
 Function Load loads 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)
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=NULL) override
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
const MODULEGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
 Function GetEnumeratedFootprint 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=NULL) override
 Function FootprintExists check for the existence of a footprint. More...
 
MODULEFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
 Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
void FootprintSave (const wxString &aLibraryPath, const MODULE *aFootprint, const PROPERTIES *aProperties=NULL) override
 Function FootprintSave will write aModule to an existing library located at aLibraryPath. More...
 
void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
 Function FootprintDelete deletes 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=NULL) override
 Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty. More...
 
bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Function FootprintLibDelete deletes 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
 Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable. More...
 
 PCB_IO (int aControlFlags=CTL_FOR_BOARD)
 
 ~PCB_IO ()
 
void Format (BOARD_ITEM *aItem, int aNestLevel=0) const
 Function Format outputs aItem to aFormatter in s-expression format. More...
 
std::string GetStringOutput (bool doClear)
 
void SetOutputFormatter (OUTPUTFORMATTER *aFormatter)
 
BOARD_ITEMParse (const wxString &aClipboardSourceInput)
 
virtual void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function PrefetchLib If possible, prefetches the specified library (e.g. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Protected Member Functions

void validateCache (const wxString &aLibraryPath, bool checkModified=true)
 
const MODULEgetFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
 
void init (const PROPERTIES *aProperties)
 
void formatSetup (BOARD *aBoard, int aNestLevel=0) const
 formats the board setup information More...
 
void formatGeneral (BOARD *aBoard, int aNestLevel=0) const
 formats the General section of the file More...
 
void formatBoardLayers (BOARD *aBoard, int aNestLevel=0) const
 formats the board layer information More...
 
void formatNetInformation (BOARD *aBoard, int aNestLevel=0) const
 formats the Nets and Netclasses More...
 
void formatHeader (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...
 
int m_loading_format_version
 which SEXPR_BOARD_FILE_VERSION should be Load()ed? 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 (BOARD *aBoard, int aNestLevel=0) const
 
void format (DIMENSION *aDimension, int aNestLevel=0) const
 
void format (EDGE_MODULE *aModuleDrawing, int aNestLevel=0) const
 
void format (DRAWSEGMENT *aSegment, int aNestLevel=0) const
 
void format (PCB_TARGET *aTarget, int aNestLevel=0) const
 
void format (MODULE *aModule, int aNestLevel=0) const
 
void format (D_PAD *aPad, int aNestLevel=0) const
 
void format (TEXTE_PCB *aText, int aNestLevel=0) const
 
void format (TEXTE_MODULE *aText, int aNestLevel=0) const
 
void format (TRACK *aTrack, int aNestLevel=0) const
 
void format (ZONE_CONTAINER *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

PCB_IO is 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 108 of file pcbnew/kicad_plugin.h.

Constructor & Destructor Documentation

◆ PCB_IO()

PCB_IO::PCB_IO ( int  aControlFlags = CTL_FOR_BOARD)

Definition at line 1925 of file kicad_plugin.cpp.

1925  :
1926  m_cache( 0 ),
1927  m_ctl( aControlFlags ),
1928  m_parser( new PCB_PARSER() ),
1929  m_mapping( new NETINFO_MAPPING() )
1930 {
1931  init( 0 );
1932  m_out = &m_sf;
1933 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
FP_CACHE * m_cache
Footprint library cache.
PCB_PARSER reads a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD...
Definition: pcb_parser.h:69
void init(const PROPERTIES *aProperties)
PCB_PARSER * m_parser
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
STRING_FORMATTER m_sf

References init(), m_out, and m_sf.

◆ ~PCB_IO()

PCB_IO::~PCB_IO ( )

Definition at line 1936 of file kicad_plugin.cpp.

1937 {
1938  delete m_cache;
1939  delete m_parser;
1940  delete m_mapping;
1941 }
FP_CACHE * m_cache
Footprint library cache.
PCB_PARSER * m_parser
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes

References m_cache, m_mapping, and m_parser.

Member Function Documentation

◆ DoLoad()

BOARD * PCB_IO::DoLoad ( LINE_READER aReader,
BOARD aAppendToMe,
const PROPERTIES aProperties 
)

Definition at line 1958 of file kicad_plugin.cpp.

1959 {
1960  init( aProperties );
1961 
1962  m_parser->SetLineReader( &aReader );
1963  m_parser->SetBoard( aAppendToMe );
1964 
1965  BOARD* board;
1966 
1967  try
1968  {
1969  board = dynamic_cast<BOARD*>( m_parser->Parse() );
1970  }
1971  catch( const FUTURE_FORMAT_ERROR& )
1972  {
1973  // Don't wrap a FUTURE_FORMAT_ERROR in another
1974  throw;
1975  }
1976  catch( const PARSE_ERROR& parse_error )
1977  {
1978  if( m_parser->IsTooRecent() )
1979  throw FUTURE_FORMAT_ERROR( parse_error, m_parser->GetRequiredVersion() );
1980  else
1981  throw;
1982  }
1983 
1984  if( !board )
1985  {
1986  // The parser loaded something that was valid, but wasn't a board.
1987  THROW_PARSE_ERROR( _( "this file does not contain a PCB" ),
1988  m_parser->CurSource(), m_parser->CurLine(),
1989  m_parser->CurLineNumber(), m_parser->CurOffset() );
1990  }
1991 
1992  return board;
1993 }
void init(const PROPERTIES *aProperties)
wxString GetRequiredVersion()
Return a string representing the version of kicad required to open this file.
Definition: pcb_parser.cpp:208
void SetBoard(BOARD *aBoard)
Definition: pcb_parser.h:344
PCB_PARSER * m_parser
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:481
LINE_READER * SetLineReader(LINE_READER *aReader)
Function SetLineReader sets aLineReader into the parser, and returns the previous one,...
Definition: pcb_parser.h:337
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:365
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#define _(s)
Definition: 3d_actions.cpp:33
Struct FUTURE_FORMAT_ERROR variant of PARSE_ERROR indicating that a syntax or related error was likel...
Definition: ki_exception.h:172

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

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

◆ FootprintDelete()

void PCB_IO::FootprintDelete ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintDelete deletes 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 2211 of file kicad_plugin.cpp.

2213 {
2214  LOCALE_IO toggle; // toggles on, then off, the C locale.
2215 
2216  init( aProperties );
2217 
2218  validateCache( aLibraryPath );
2219 
2220  if( !m_cache->IsWritable() )
2221  {
2222  THROW_IO_ERROR( wxString::Format( _( "Library \"%s\" is read only." ),
2223  aLibraryPath.GetData() ) );
2224  }
2225 
2226  m_cache->Remove( aFootprintName );
2227 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
void Remove(const wxString &aFootprintName)
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
#define THROW_IO_ERROR(msg)
bool IsWritable() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33

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

Referenced by GITHUB_PLUGIN::FootprintDelete().

◆ FootprintEnumerate()

void PCB_IO::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aLibraryPath,
bool  aBestEfforts,
const PROPERTIES aProperties = NULL 
)
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 2017 of file kicad_plugin.cpp.

2019 {
2020  LOCALE_IO toggle; // toggles on, then off, the C locale.
2021  wxDir dir( aLibPath );
2022  wxString errorMsg;
2023 
2024  init( aProperties );
2025 
2026  try
2027  {
2028  validateCache( aLibPath );
2029  }
2030  catch( const IO_ERROR& ioe )
2031  {
2032  errorMsg = ioe.What();
2033  }
2034 
2035  // Some of the files may have been parsed correctly so we want to add the valid files to
2036  // the library.
2037 
2038  for( MODULE_CITER it = m_cache->GetModules().begin(); it != m_cache->GetModules().end(); ++it )
2039  aFootprintNames.Add( it->first );
2040 
2041  if( !errorMsg.IsEmpty() && !aBestEfforts )
2042  THROW_IO_ERROR( errorMsg );
2043 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
#define THROW_IO_ERROR(msg)
MODULE_MAP::const_iterator MODULE_CITER
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
MODULE_MAP & GetModules()

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

Referenced by GITHUB_PLUGIN::FootprintDelete(), and GITHUB_PLUGIN::FootprintEnumerate().

◆ FootprintExists()

bool PCB_IO::FootprintExists ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintExists check for the existence of a footprint.

Reimplemented from PLUGIN.

Definition at line 2083 of file kicad_plugin.cpp.

2085 {
2086  // Note: checking the cache sounds like a good idea, but won't catch files which differ
2087  // only in case.
2088  //
2089  // Since this goes out to the native filesystem, we get platform differences (ie: MSW's
2090  // case-insensitive filesystem) handled "for free".
2091  // Warning: footprint names frequently contain a point. So be careful when initializing
2092  // wxFileName, and use a CTOR with extension specified
2093  wxFileName footprintFile( aLibraryPath, aFootprintName, KiCadFootprintFileExtension );
2094 
2095  return footprintFile.Exists();
2096 }
const std::string KiCadFootprintFileExtension

References KiCadFootprintFileExtension.

◆ FootprintLibCreate()

void PCB_IO::FootprintLibCreate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintLibCreate creates 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 2237 of file kicad_plugin.cpp.

2238 {
2239  if( wxDir::Exists( aLibraryPath ) )
2240  {
2241  THROW_IO_ERROR( wxString::Format( _( "Cannot overwrite library path \"%s\"." ),
2242  aLibraryPath.GetData() ) );
2243  }
2244 
2245  LOCALE_IO toggle;
2246 
2247  init( aProperties );
2248 
2249  delete m_cache;
2250  m_cache = new FP_CACHE( this, aLibraryPath );
2251  m_cache->Save();
2252 }
friend class FP_CACHE
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
#define THROW_IO_ERROR(msg)
void Save(MODULE *aModule=NULL)
Function Save Save the footprint cache or a single module from it to disk.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33

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

Referenced by GITHUB_PLUGIN::FootprintLibCreate().

◆ FootprintLibDelete()

bool PCB_IO::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintLibDelete deletes 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
bool - 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 2255 of file kicad_plugin.cpp.

2256 {
2257  wxFileName fn;
2258  fn.SetPath( aLibraryPath );
2259 
2260  // Return if there is no library path to delete.
2261  if( !fn.DirExists() )
2262  return false;
2263 
2264  if( !fn.IsDirWritable() )
2265  {
2266  THROW_IO_ERROR( wxString::Format( _( "User does not have permission to delete directory \"%s\"." ),
2267  aLibraryPath.GetData() ) );
2268  }
2269 
2270  wxDir dir( aLibraryPath );
2271 
2272  if( dir.HasSubDirs() )
2273  {
2274  THROW_IO_ERROR( wxString::Format( _( "Library directory \"%s\" has unexpected sub-directories." ),
2275  aLibraryPath.GetData() ) );
2276  }
2277 
2278  // All the footprint files must be deleted before the directory can be deleted.
2279  if( dir.HasFiles() )
2280  {
2281  unsigned i;
2282  wxFileName tmp;
2283  wxArrayString files;
2284 
2285  wxDir::GetAllFiles( aLibraryPath, &files );
2286 
2287  for( i = 0; i < files.GetCount(); i++ )
2288  {
2289  tmp = files[i];
2290 
2291  if( tmp.GetExt() != KiCadFootprintFileExtension )
2292  {
2293  THROW_IO_ERROR( wxString::Format( _( "Unexpected file \"%s\" was found in library path \"%s\"." ),
2294  files[i].GetData(), aLibraryPath.GetData() ) );
2295  }
2296  }
2297 
2298  for( i = 0; i < files.GetCount(); i++ )
2299  wxRemoveFile( files[i] );
2300  }
2301 
2302  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint library \"%s\"." ),
2303  aLibraryPath.GetData() );
2304 
2305  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2306  // we don't want that. we want bare metal portability with no UI here.
2307  if( !wxRmdir( aLibraryPath ) )
2308  {
2309  THROW_IO_ERROR( wxString::Format( _( "Footprint library \"%s\" cannot be deleted." ),
2310  aLibraryPath.GetData() ) );
2311  }
2312 
2313  // For some reason removing a directory in Windows is not immediately updated. This delay
2314  // prevents an error when attempting to immediately recreate the same directory when over
2315  // writing an existing library.
2316 #ifdef __WINDOWS__
2317  wxMilliSleep( 250L );
2318 #endif
2319 
2320  if( m_cache && !m_cache->IsPath( aLibraryPath ) )
2321  {
2322  delete m_cache;
2323  m_cache = NULL;
2324  }
2325 
2326  return true;
2327 }
const std::string KiCadFootprintFileExtension
FP_CACHE * m_cache
Footprint library cache.
#define NULL
bool IsPath(const wxString &aPath) const
Function IsPath checks if aPath is the same as the current cache path.
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define THROW_IO_ERROR(msg)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33

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

Referenced by GITHUB_PLUGIN::FootprintLibDelete().

◆ FootprintLibOptions()

void PLUGIN::FootprintLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Function FootprintLibOptions appends 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 that 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 GITHUB_PLUGIN, and EAGLE_PLUGIN.

Definition at line 140 of file plugin.cpp.

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

References _.

Referenced by EAGLE_PLUGIN::FootprintLibOptions(), and GITHUB_PLUGIN::FootprintLibOptions().

◆ FootprintLoad()

MODULE * PCB_IO::FootprintLoad ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintLoad loads 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.
Returns
MODULE* - 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 2099 of file kicad_plugin.cpp.

2101 {
2102  const MODULE* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
2103  return footprint ? (MODULE*) footprint->Duplicate() : nullptr;
2104 }
const MODULE * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
BOARD_ITEM * Duplicate() const
Function Duplicate creates a copy of a BOARD_ITEM.

References BOARD_ITEM::Duplicate(), and getFootprint().

Referenced by GITHUB_PLUGIN::FootprintLoad().

◆ FootprintSave()

void PCB_IO::FootprintSave ( const wxString &  aLibraryPath,
const MODULE aFootprint,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintSave will write aModule 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 2107 of file kicad_plugin.cpp.

2109 {
2110  LOCALE_IO toggle; // toggles on, then off, the C locale.
2111 
2112  init( aProperties );
2113 
2114  // In this public PLUGIN API function, we can safely assume it was
2115  // called for saving into a library path.
2117 
2118  validateCache( aLibraryPath );
2119 
2120  if( !m_cache->IsWritable() )
2121  {
2122  if( !m_cache->Exists() )
2123  {
2124  const wxString msg = wxString::Format( _( "Library \"%s\" does not exist.\n"
2125  "Would you like to create it?"),
2126  GetChars( aLibraryPath ) );
2127 
2128  if( wxMessageBox( msg, _( "Library Not Found"), wxYES_NO | wxICON_QUESTION ) != wxYES )
2129  return;
2130 
2131  // Save throws its own IO_ERROR on failure, so no need to recreate here
2132  m_cache->Save( NULL );
2133  }
2134  else
2135  {
2136  wxString msg = wxString::Format( _( "Library \"%s\" is read only" ), aLibraryPath );
2137  THROW_IO_ERROR( msg );
2138  }
2139  }
2140 
2141  wxString footprintName = aFootprint->GetFPID().GetLibItemName();
2142 
2143  MODULE_MAP& mods = m_cache->GetModules();
2144 
2145  // Quietly overwrite module and delete module file from path for any by same name.
2146  wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
2148 
2149 #ifndef __WINDOWS__
2150  // Write through symlinks, don't replace them
2151  if( fn.Exists( wxFILE_EXISTS_SYMLINK ) )
2152  {
2153  char buffer[ PATH_MAX + 1 ];
2154  ssize_t pathLen = readlink( TO_UTF8( fn.GetFullPath() ), buffer, PATH_MAX );
2155 
2156  if( pathLen > 0 )
2157  {
2158  buffer[ pathLen ] = '\0';
2159  fn.Assign( fn.GetPath() + wxT( "/" ) + wxString::FromUTF8( buffer ) );
2160  fn.Normalize();
2161  }
2162  }
2163 #endif
2164 
2165  if( !fn.IsOk() )
2166  {
2167  THROW_IO_ERROR( wxString::Format( _( "Footprint file name \"%s\" is not valid." ),
2168  fn.GetFullPath() ) );
2169  }
2170 
2171  if( fn.FileExists() && !fn.IsFileWritable() )
2172  {
2173  THROW_IO_ERROR( wxString::Format( _( "No write permissions to delete file \"%s\"" ),
2174  fn.GetFullPath() ) );
2175  }
2176 
2177  wxString fullPath = fn.GetFullPath();
2178  wxString fullName = fn.GetFullName();
2179  MODULE_CITER it = mods.find( footprintName );
2180 
2181  if( it != mods.end() )
2182  {
2183  wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
2184  mods.erase( footprintName );
2185  wxRemoveFile( fullPath );
2186  }
2187 
2188  // I need my own copy for the cache
2189  MODULE* module = static_cast<MODULE*>( aFootprint->Duplicate() );
2190 
2191  // It should have no parent, orientation should be zero, and it should be on the front layer.
2192  module->SetParent( nullptr );
2193  module->SetOrientation( 0 );
2194 
2195  if( module->GetLayer() != F_Cu )
2196  {
2197  auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
2198 
2199  if( cfg )
2200  module->Flip( module->GetPosition(), cfg->m_FlipLeftRight );
2201  else
2202  module->Flip( module->GetPosition(), false );
2203  }
2204 
2205  wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
2206  mods.insert( footprintName, new FP_CACHE_ITEM( module, WX_FILENAME( fn.GetPath(), fullName ) ) );
2207  m_cache->Save( module );
2208 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
const std::string KiCadFootprintFileExtension
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
const LIB_ID & GetFPID() const
Definition: class_module.h:225
std::map< wxString, MODULE * > MODULE_MAP
Definition: eagle_parser.h:51
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
#define NULL
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define THROW_IO_ERROR(msg)
FP_CACHE_ITEM is helper class for creating a footprint library cache.
void Save(MODULE *aModule=NULL)
Function Save Save the footprint cache or a single module from it to disk.
bool IsWritable() const
MODULE_MAP::const_iterator MODULE_CITER
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: common.h:414
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
void SetOrientation(double newangle)
#define TO_UTF8(wxstring)
wxPoint GetPosition() const override
Definition: class_module.h:216
bool Exists() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
MODULE_MAP & GetModules()
BOARD_ITEM * Duplicate() const
Function Duplicate creates a copy of a BOARD_ITEM.

References _, CTL_FOR_LIBRARY, BOARD_ITEM::Duplicate(), FP_CACHE::Exists(), F_Cu, MODULE::Flip(), Format(), GetChars(), MODULE::GetFPID(), BOARD_ITEM::GetLayer(), LIB_ID::GetLibItemName(), FP_CACHE::GetModules(), MODULE::GetPosition(), init(), FP_CACHE::IsWritable(), KiCadFootprintFileExtension, Kiface(), m_cache, m_ctl, NULL, FP_CACHE::Save(), MODULE::SetOrientation(), EDA_ITEM::SetParent(), THROW_IO_ERROR, TO_UTF8, traceKicadPcbPlugin, and validateCache().

Referenced by GITHUB_PLUGIN::FootprintSave().

◆ Format()

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

Function Format outputs 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 kicad_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<BOARD*>( aItem ), aNestLevel );
408  break;
409 
410  case PCB_DIMENSION_T:
411  format( static_cast<DIMENSION*>( aItem ), aNestLevel );
412  break;
413 
414  case PCB_LINE_T:
415  format( static_cast<DRAWSEGMENT*>( aItem ), aNestLevel );
416  break;
417 
418  case PCB_MODULE_EDGE_T:
419  format( static_cast<EDGE_MODULE*>( aItem ), aNestLevel );
420  break;
421 
422  case PCB_TARGET_T:
423  format( static_cast<PCB_TARGET*>( aItem ), aNestLevel );
424  break;
425 
426  case PCB_MODULE_T:
427  format( static_cast<MODULE*>( aItem ), aNestLevel );
428  break;
429 
430  case PCB_PAD_T:
431  format( static_cast<D_PAD*>( aItem ), aNestLevel );
432  break;
433 
434  case PCB_TEXT_T:
435  format( static_cast<TEXTE_PCB*>( aItem ), aNestLevel );
436  break;
437 
438  case PCB_MODULE_TEXT_T:
439  format( static_cast<TEXTE_MODULE*>( aItem ), aNestLevel );
440  break;
441 
442  case PCB_TRACE_T:
443  case PCB_ARC_T:
444  case PCB_VIA_T:
445  format( static_cast<TRACK*>( aItem ), aNestLevel );
446  break;
447 
449  case PCB_ZONE_AREA_T:
450  format( static_cast<ZONE_CONTAINER*>( aItem ), aNestLevel );
451  break;
452 
453  default:
454  wxFAIL_MSG( wxT( "Cannot format item " ) + aItem->GetClass() );
455  }
456 }
Definition: typeinfo.h:85
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class MODULE, a footprint
Definition: typeinfo.h:89
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
virtual wxString GetClass() const =0
Function GetClass returns the class name.
void format(BOARD *aBoard, int aNestLevel=0) const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References format(), EDA_ITEM::GetClass(), PCB_ARC_T, PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, PCB_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

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

◆ format() [1/11]

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

Definition at line 607 of file kicad_plugin.cpp.

608 {
609 
610  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_modules( aBoard->Modules().begin(),
611  aBoard->Modules().end() );
612  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->Drawings().begin(),
613  aBoard->Drawings().end() );
614  std::set<TRACK*, TRACK::cmp_tracks> sorted_tracks( aBoard->Tracks().begin(),
615  aBoard->Tracks().end() );
616  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->Zones().begin(),
617  aBoard->Zones().end() );
618 
619  formatHeader( aBoard, aNestLevel );
620 
621  // Save the modules.
622  for( auto module : sorted_modules )
623  {
624  Format( module, aNestLevel );
625  m_out->Print( 0, "\n" );
626  }
627 
628  // Save the graphical items on the board (not owned by a module)
629  for( auto item : sorted_drawings )
630  Format( item, aNestLevel );
631 
632  if( sorted_drawings.size() )
633  m_out->Print( 0, "\n" );
634 
635  // Do not save MARKER_PCBs, they can be regenerated easily.
636 
637  // Save the tracks and vias.
638  for( auto track : sorted_tracks )
639  Format( track, aNestLevel );
640 
641  if( sorted_tracks.size() )
642  m_out->Print( 0, "\n" );
643 
644  // Save the polygon (which are the newer technology) zones.
645  for( auto zone : sorted_zones )
646  Format( zone, aNestLevel );
647 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
MODULES & Modules()
Definition: class_board.h:266
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
void formatHeader(BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.
DRAWINGS & Drawings()
Definition: class_board.h:275
TRACKS & Tracks()
Definition: class_board.h:257

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

Referenced by Format().

◆ format() [2/11]

void PCB_IO::format ( DIMENSION aDimension,
int  aNestLevel = 0 
) const
private

Definition at line 650 of file kicad_plugin.cpp.

651 {
652  m_out->Print( aNestLevel, "(dimension %s (width %s)",
653  FormatInternalUnits( aDimension->GetValue() ).c_str(),
654  FormatInternalUnits( aDimension->GetWidth() ).c_str() );
655 
656  formatLayer( aDimension );
657 
658  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aDimension->m_Uuid.AsString() ) );
659 
660  m_out->Print( 0, "\n" );
661 
662  Format( &aDimension->Text(), aNestLevel+1 );
663 
664  m_out->Print( aNestLevel+1, "(feature1 (pts (xy %s %s) (xy %s %s)))\n",
665  FormatInternalUnits( aDimension->m_featureLineDO.x ).c_str(),
666  FormatInternalUnits( aDimension->m_featureLineDO.y ).c_str(),
667  FormatInternalUnits( aDimension->m_featureLineDF.x ).c_str(),
668  FormatInternalUnits( aDimension->m_featureLineDF.y ).c_str() );
669 
670  m_out->Print( aNestLevel+1, "(feature2 (pts (xy %s %s) (xy %s %s)))\n",
671  FormatInternalUnits( aDimension->m_featureLineGO.x ).c_str(),
672  FormatInternalUnits( aDimension->m_featureLineGO.y ).c_str(),
673  FormatInternalUnits( aDimension->m_featureLineGF.x ).c_str(),
674  FormatInternalUnits( aDimension->m_featureLineGF.y ).c_str() );
675 
676  m_out->Print( aNestLevel+1, "(crossbar (pts (xy %s %s) (xy %s %s)))\n",
677  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
678  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
679  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
680  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str() );
681 
682  m_out->Print( aNestLevel+1, "(arrow1a (pts (xy %s %s) (xy %s %s)))\n",
683  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
684  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str(),
685  FormatInternalUnits( aDimension->m_arrowD1F.x ).c_str(),
686  FormatInternalUnits( aDimension->m_arrowD1F.y ).c_str() );
687 
688  m_out->Print( aNestLevel+1, "(arrow1b (pts (xy %s %s) (xy %s %s)))\n",
689  FormatInternalUnits( aDimension->m_crossBarF.x ).c_str(),
690  FormatInternalUnits( aDimension->m_crossBarF.y ).c_str(),
691  FormatInternalUnits( aDimension->m_arrowD2F.x ).c_str(),
692  FormatInternalUnits( aDimension->m_arrowD2F.y ).c_str() );
693 
694  m_out->Print( aNestLevel+1, "(arrow2a (pts (xy %s %s) (xy %s %s)))\n",
695  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
696  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
697  FormatInternalUnits( aDimension->m_arrowG1F.x ).c_str(),
698  FormatInternalUnits( aDimension->m_arrowG1F.y ).c_str() );
699 
700  m_out->Print( aNestLevel+1, "(arrow2b (pts (xy %s %s) (xy %s %s)))\n",
701  FormatInternalUnits( aDimension->m_crossBarO.x ).c_str(),
702  FormatInternalUnits( aDimension->m_crossBarO.y ).c_str(),
703  FormatInternalUnits( aDimension->m_arrowG2F.x ).c_str(),
704  FormatInternalUnits( aDimension->m_arrowG2F.y ).c_str() );
705 
706  m_out->Print( aNestLevel, ")\n" );
707 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
int GetWidth() const
void formatLayer(const BOARD_ITEM *aItem) const
wxPoint m_crossBarF
wxPoint m_arrowD1F
wxString AsString() const
Definition: common.cpp:165
wxPoint m_featureLineDF
wxPoint m_featureLineGO
int GetValue() const
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
const KIID m_Uuid
Definition: base_struct.h:162
TEXTE_PCB & Text()
#define TO_UTF8(wxstring)
wxPoint m_crossBarO
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.
wxPoint m_featureLineDO
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
wxPoint m_featureLineGF

References KIID::AsString(), Format(), FormatInternalUnits(), formatLayer(), DIMENSION::GetValue(), DIMENSION::GetWidth(), DIMENSION::m_arrowD1F, DIMENSION::m_arrowD2F, DIMENSION::m_arrowG1F, DIMENSION::m_arrowG2F, DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDF, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGF, DIMENSION::m_featureLineGO, m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), DIMENSION::Text(), TO_UTF8, wxPoint::x, and wxPoint::y.

◆ format() [3/11]

void PCB_IO::format ( EDGE_MODULE aModuleDrawing,
int  aNestLevel = 0 
) const
private

Definition at line 803 of file kicad_plugin.cpp.

804 {
805  switch( aModuleDrawing->GetShape() )
806  {
807  case S_SEGMENT: // Line
808  m_out->Print( aNestLevel, "(fp_line (start %s) (end %s)",
809  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
810  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
811  break;
812 
813  case S_RECT: // Rectangle
814  m_out->Print( aNestLevel, "(fp_rect (start %s) (end %s)",
815  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
816  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
817  break;
818 
819  case S_CIRCLE: // Circle
820  m_out->Print( aNestLevel, "(fp_circle (center %s) (end %s)",
821  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
822  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
823  break;
824 
825  case S_ARC: // Arc
826  m_out->Print( aNestLevel, "(fp_arc (start %s) (end %s) (angle %s)",
827  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
828  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str(),
829  FormatAngle( aModuleDrawing->GetAngle() ).c_str() );
830  break;
831 
832  case S_POLYGON: // Polygonal segment
833  if( aModuleDrawing->IsPolyShapeValid() )
834  {
835  SHAPE_POLY_SET& poly = aModuleDrawing->GetPolyShape();
836  SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
837  int pointsCount = outline.PointCount();
838 
839  m_out->Print( aNestLevel, "(fp_poly (pts" );
840 
841  for( int ii = 0; ii < pointsCount; ++ii )
842  {
843  int nestLevel = 0;
844 
845  if( ii && ( !( ii%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) ) // newline every 4 pts
846  {
847  nestLevel = aNestLevel + 1;
848  m_out->Print( 0, "\n" );
849  }
850 
851  m_out->Print( nestLevel, "%s(xy %s)",
852  nestLevel ? "" : " ", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
853  }
854 
855  m_out->Print( 0, ")" );
856  }
857  else
858  {
859  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
860  return;
861  }
862  break;
863 
864  case S_CURVE: // Bezier curve
865  m_out->Print( aNestLevel, "(fp_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
866  FormatInternalUnits( aModuleDrawing->GetStart0() ).c_str(),
867  FormatInternalUnits( aModuleDrawing->GetBezier0_C1() ).c_str(),
868  FormatInternalUnits( aModuleDrawing->GetBezier0_C2() ).c_str(),
869  FormatInternalUnits( aModuleDrawing->GetEnd0() ).c_str() );
870  break;
871 
872  default:
873  wxFAIL_MSG( "PCB_IO::format cannot format unknown EDGE_MODULE shape:"
874  + STROKE_T_asString( aModuleDrawing->GetShape() ) );
875  return;
876  };
877 
878  formatLayer( aModuleDrawing );
879 
880  m_out->Print( 0, " (width %s)", FormatInternalUnits( aModuleDrawing->GetWidth() ).c_str() );
881 
882  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aModuleDrawing->m_Uuid.AsString() ) );
883 
884  m_out->Print( 0, ")\n" );
885 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatLayer(const BOARD_ITEM *aItem) const
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
wxString AsString() const
Definition: common.cpp:165
usual segment : line with rounded ends
int PointCount() const
Function PointCount()
const wxPoint & GetStart0() const
const VECTOR2I & CPoint(int aIndex) const
Function Point()
segment with non rounded ends
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Arcs (with rounded ends)
const wxPoint & GetBezier0_C2() const
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
int GetWidth() const
const KIID m_Uuid
Definition: base_struct.h:162
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
SHAPE_LINE_CHAIN.
#define TO_UTF8(wxstring)
bool IsPolyShapeValid() const
const wxPoint & GetBezier0_C1() const
const wxPoint & GetEnd0() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

References KIID::AsString(), SHAPE_LINE_CHAIN::CPoint(), FormatAngle(), FormatInternalUnits(), formatLayer(), DRAWSEGMENT::GetAngle(), EDGE_MODULE::GetBezier0_C1(), EDGE_MODULE::GetBezier0_C2(), ADVANCED_CFG::GetCfg(), EDGE_MODULE::GetEnd0(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetShape(), EDGE_MODULE::GetStart0(), DRAWSEGMENT::GetWidth(), DRAWSEGMENT::IsPolyShapeValid(), m_out, EDA_ITEM::m_Uuid, SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::PointCount(), OUTPUTFORMATTER::Print(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), and TO_UTF8.

◆ format() [4/11]

void PCB_IO::format ( DRAWSEGMENT aSegment,
int  aNestLevel = 0 
) const
private

Definition at line 710 of file kicad_plugin.cpp.

711 {
712  switch( aSegment->GetShape() )
713  {
714  case S_SEGMENT: // Line
715  m_out->Print( aNestLevel, "(gr_line (start %s) (end %s)",
716  FormatInternalUnits( aSegment->GetStart() ).c_str(),
717  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
718 
719  if( aSegment->GetAngle() != 0.0 )
720  m_out->Print( 0, " (angle %s)", FormatAngle( aSegment->GetAngle() ).c_str() );
721 
722  break;
723 
724  case S_RECT: // Rectangle
725  m_out->Print( aNestLevel, "(gr_rect (start %s) (end %s)",
726  FormatInternalUnits( aSegment->GetStart() ).c_str(),
727  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
728  break;
729 
730  case S_CIRCLE: // Circle
731  m_out->Print( aNestLevel, "(gr_circle (center %s) (end %s)",
732  FormatInternalUnits( aSegment->GetStart() ).c_str(),
733  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
734  break;
735 
736  case S_ARC: // Arc
737  m_out->Print( aNestLevel, "(gr_arc (start %s) (end %s) (angle %s)",
738  FormatInternalUnits( aSegment->GetStart() ).c_str(),
739  FormatInternalUnits( aSegment->GetEnd() ).c_str(),
740  FormatAngle( aSegment->GetAngle() ).c_str() );
741  break;
742 
743  case S_POLYGON: // Polygon
744  if( aSegment->IsPolyShapeValid() )
745  {
746  SHAPE_POLY_SET& poly = aSegment->GetPolyShape();
747  SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
748  int pointsCount = outline.PointCount();
749 
750  m_out->Print( aNestLevel, "(gr_poly (pts\n" );
751 
752  for( int ii = 0; ii < pointsCount; ++ii )
753  {
754  int nestLevel = 0;
755 
756  if( ii && ( !( ii%4 ) || !ADVANCED_CFG::GetCfg().m_CompactSave ) ) // newline every 4 pts
757  {
758  nestLevel = aNestLevel + 1;
759  m_out->Print( 0, "\n" );
760  }
761 
762  m_out->Print( nestLevel, "%s(xy %s)",
763  nestLevel ? "" : " ", FormatInternalUnits( outline.CPoint( ii ) ).c_str() );
764  }
765 
766  m_out->Print( 0, ")" );
767  }
768  else
769  {
770  wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
771  return;
772  }
773 
774  break;
775 
776  case S_CURVE: // Bezier curve
777  m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
778  FormatInternalUnits( aSegment->GetStart() ).c_str(),
779  FormatInternalUnits( aSegment->GetBezControl1() ).c_str(),
780  FormatInternalUnits( aSegment->GetBezControl2() ).c_str(),
781  FormatInternalUnits( aSegment->GetEnd() ).c_str() );
782  break;
783 
784  default:
785  wxFAIL_MSG( "PCB_IO::format cannot format unknown DRAWSEGMENT shape:"
786  + STROKE_T_asString( aSegment->GetShape() ) );
787  return;
788  };
789 
790  formatLayer( aSegment );
791 
792  m_out->Print( 0, " (width %s)", FormatInternalUnits( aSegment->GetWidth() ).c_str() );
793 
794  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aSegment->m_Uuid.AsString() ) );
795 
796  if( aSegment->GetStatus() )
797  m_out->Print( 0, " (status %X)", aSegment->GetStatus() );
798 
799  m_out->Print( 0, ")\n" );
800 }
STATUS_FLAGS GetStatus() const
Definition: base_struct.h:229
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatLayer(const BOARD_ITEM *aItem) const
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
wxString AsString() const
Definition: common.cpp:165
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
segment with non rounded ends
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Arcs (with rounded ends)
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
int GetWidth() const
const KIID m_Uuid
Definition: base_struct.h:162
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
SHAPE_LINE_CHAIN.
const wxPoint & GetBezControl2() const
#define TO_UTF8(wxstring)
bool IsPolyShapeValid() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
const wxPoint & GetBezControl1() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

References KIID::AsString(), SHAPE_LINE_CHAIN::CPoint(), FormatAngle(), FormatInternalUnits(), formatLayer(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), ADVANCED_CFG::GetCfg(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), EDA_ITEM::GetStatus(), DRAWSEGMENT::GetWidth(), DRAWSEGMENT::IsPolyShapeValid(), m_out, EDA_ITEM::m_Uuid, SHAPE_POLY_SET::Outline(), SHAPE_LINE_CHAIN::PointCount(), OUTPUTFORMATTER::Print(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), and TO_UTF8.

◆ format() [5/11]

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

Definition at line 888 of file kicad_plugin.cpp.

889 {
890  m_out->Print( aNestLevel, "(target %s (at %s) (size %s)",
891  ( aTarget->GetShape() ) ? "x" : "plus",
892  FormatInternalUnits( aTarget->GetPosition() ).c_str(),
893  FormatInternalUnits( aTarget->GetSize() ).c_str() );
894 
895  if( aTarget->GetWidth() != 0 )
896  m_out->Print( 0, " (width %s)", FormatInternalUnits( aTarget->GetWidth() ).c_str() );
897 
898  formatLayer( aTarget );
899 
900  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTarget->m_Uuid.AsString() ) );
901 
902  m_out->Print( 0, ")\n" );
903 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatLayer(const BOARD_ITEM *aItem) const
int GetSize() const
wxString AsString() const
Definition: common.cpp:165
wxPoint GetPosition() const override
int GetWidth() const
const KIID m_Uuid
Definition: base_struct.h:162
int GetShape() const
#define TO_UTF8(wxstring)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

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() [6/11]

void PCB_IO::format ( MODULE aModule,
int  aNestLevel = 0 
) const
private

Definition at line 906 of file kicad_plugin.cpp.

907 {
908  if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
909  {
910  const wxArrayString* initial_comments = aModule->GetInitialComments();
911 
912  if( initial_comments )
913  {
914  for( unsigned i=0; i<initial_comments->GetCount(); ++i )
915  m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) );
916 
917  m_out->Print( 0, "\n" ); // improve readability?
918  }
919  }
920 
921  m_out->Print( aNestLevel, "(module %s",
922  m_out->Quotes( aModule->GetFPID().Format() ).c_str() );
923 
924  if( aModule->IsLocked() )
925  m_out->Print( 0, " locked" );
926 
927  if( aModule->IsPlaced() )
928  m_out->Print( 0, " placed" );
929 
930  formatLayer( aModule );
931 
932  m_out->Print( 0, " (tedit %lX)", (unsigned long)aModule->GetLastEditTime() );
933 
934  if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
935  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aModule->m_Uuid.AsString() ) );
936 
937  m_out->Print( 0, "\n" );
938 
939  if( !( m_ctl & CTL_OMIT_AT ) )
940  {
941  m_out->Print( aNestLevel+1, "(at %s", FormatInternalUnits( aModule->GetPosition() ).c_str() );
942 
943  if( aModule->GetOrientation() != 0.0 )
944  m_out->Print( 0, " %s", FormatAngle( aModule->GetOrientation() ).c_str() );
945 
946  m_out->Print( 0, ")\n" );
947  }
948 
949  if( !aModule->GetDescription().IsEmpty() )
950  m_out->Print( aNestLevel+1, "(descr %s)\n",
951  m_out->Quotew( aModule->GetDescription() ).c_str() );
952 
953  if( !aModule->GetKeywords().IsEmpty() )
954  m_out->Print( aNestLevel+1, "(tags %s)\n",
955  m_out->Quotew( aModule->GetKeywords() ).c_str() );
956 
957  const std::map<wxString, wxString>& props = aModule->GetProperties();
958 
959  for( const std::pair<const wxString, wxString>& prop : props )
960  {
961  m_out->Print( aNestLevel+1, "(property %s %s)\n",
962  m_out->Quotew( prop.first ).c_str(),
963  m_out->Quotew( prop.second ).c_str() );
964  }
965 
966  if( !( m_ctl & CTL_OMIT_PATH ) && !aModule->GetPath().empty() )
967  m_out->Print( aNestLevel+1, "(path %s)\n",
968  m_out->Quotew( aModule->GetPath().AsString() ).c_str() );
969 
970  if( aModule->GetPlacementCost90() != 0 )
971  m_out->Print( aNestLevel+1, "(autoplace_cost90 %d)\n", aModule->GetPlacementCost90() );
972 
973  if( aModule->GetPlacementCost180() != 0 )
974  m_out->Print( aNestLevel+1, "(autoplace_cost180 %d)\n", aModule->GetPlacementCost180() );
975 
976  if( aModule->GetLocalSolderMaskMargin() != 0 )
977  m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
978  FormatInternalUnits( aModule->GetLocalSolderMaskMargin() ).c_str() );
979 
980  if( aModule->GetLocalSolderPasteMargin() != 0 )
981  m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
982  FormatInternalUnits( aModule->GetLocalSolderPasteMargin() ).c_str() );
983 
984  if( aModule->GetLocalSolderPasteMarginRatio() != 0 )
985  m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
986  Double2Str( aModule->GetLocalSolderPasteMarginRatio() ).c_str() );
987 
988  if( aModule->GetLocalClearance() != 0 )
989  m_out->Print( aNestLevel+1, "(clearance %s)\n",
990  FormatInternalUnits( aModule->GetLocalClearance() ).c_str() );
991 
993  m_out->Print( aNestLevel+1, "(zone_connect %d)\n",
994  static_cast<int>( aModule->GetZoneConnection() ) );
995 
996  if( aModule->GetThermalWidth() != 0 )
997  m_out->Print( aNestLevel+1, "(thermal_width %s)\n",
998  FormatInternalUnits( aModule->GetThermalWidth() ).c_str() );
999 
1000  if( aModule->GetThermalGap() != 0 )
1001  m_out->Print( aNestLevel+1, "(thermal_gap %s)\n",
1002  FormatInternalUnits( aModule->GetThermalGap() ).c_str() );
1003 
1004  // Attributes
1005  if( aModule->GetAttributes() != MOD_DEFAULT )
1006  {
1007  m_out->Print( aNestLevel+1, "(attr" );
1008 
1009  if( aModule->GetAttributes() & MOD_CMS )
1010  m_out->Print( 0, " smd" );
1011 
1012  if( aModule->GetAttributes() & MOD_VIRTUAL )
1013  m_out->Print( 0, " virtual" );
1014 
1015  m_out->Print( 0, ")\n" );
1016  }
1017 
1018  Format( (BOARD_ITEM*) &aModule->Reference(), aNestLevel+1 );
1019  Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel+1 );
1020 
1021  std::set<D_PAD*, MODULE::cmp_pads> sorted_pads( aModule->Pads().begin(),
1022  aModule->Pads().end() );
1023  std::set<BOARD_ITEM*, MODULE::cmp_drawings> sorted_drawings( aModule->GraphicalItems().begin(),
1024  aModule->GraphicalItems().end() );
1025  std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aModule->Zones().begin(),
1026  aModule->Zones().end() );
1027 
1028  // Save drawing elements.
1029 
1030  for( auto gr : sorted_drawings )
1031  Format( gr, aNestLevel+1 );
1032 
1033  // Save pads.
1034  for( auto pad : sorted_pads )
1035  Format( pad, aNestLevel+1 );
1036 
1037  // Save zones.
1038  for( auto zone : sorted_zones )
1039  Format( zone, aNestLevel + 1 );
1040 
1041  // Save 3D info.
1042  auto bs3D = aModule->Models().begin();
1043  auto es3D = aModule->Models().end();
1044 
1045  while( bs3D != es3D )
1046  {
1047  if( !bs3D->m_Filename.IsEmpty() )
1048  {
1049  m_out->Print( aNestLevel+1, "(model %s%s\n",
1050  m_out->Quotew( bs3D->m_Filename ).c_str(),
1051  bs3D->m_Show ? "" : " hide" );
1052 
1053  if( bs3D->m_Opacity != 1.0 )
1054  m_out->Print( aNestLevel+2, "(opacity %0.4f)", bs3D->m_Opacity );
1055 
1056  m_out->Print( aNestLevel+2, "(offset (xyz %s %s %s))\n",
1057  Double2Str( bs3D->m_Offset.x ).c_str(),
1058  Double2Str( bs3D->m_Offset.y ).c_str(),
1059  Double2Str( bs3D->m_Offset.z ).c_str() );
1060 
1061  m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
1062  Double2Str( bs3D->m_Scale.x ).c_str(),
1063  Double2Str( bs3D->m_Scale.y ).c_str(),
1064  Double2Str( bs3D->m_Scale.z ).c_str() );
1065 
1066  m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
1067  Double2Str( bs3D->m_Rotation.x ).c_str(),
1068  Double2Str( bs3D->m_Rotation.y ).c_str(),
1069  Double2Str( bs3D->m_Rotation.z ).c_str() );
1070 
1071  m_out->Print( aNestLevel+1, ")\n" );
1072  }
1073  ++bs3D;
1074  }
1075 
1076  m_out->Print( aNestLevel, ")\n" );
1077 }
timestamp_t GetLastEditTime() const
Definition: class_module.h:356
int GetAttributes() const
Definition: class_module.h:266
double GetOrientation() const
Definition: class_module.h:221
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
int GetPlacementCost90() const
Definition: class_module.h:566
TEXTE_MODULE & Reference()
Definition: class_module.h:485
#define CTL_OMIT_AT
Omit position and rotation.
void formatLayer(const BOARD_ITEM *aItem) const
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
bool IsPlaced() const
Definition: class_module.h:326
ZONE_CONNECTION GetZoneConnection() const
Definition: class_module.h:258
PADS & Pads()
Definition: class_module.h:173
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:68
wxString AsString() const
Definition: common.cpp:165
std::string Double2Str(double aValue)
Helper function Double2Str to print a float number without using scientific notation and no trailing ...
Definition: base_units.cpp:62
const LIB_ID & GetFPID() const
Definition: class_module.h:225
const KIID_PATH & GetPath() const
Definition: class_module.h:234
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
int GetLocalSolderMaskMargin() const
Definition: class_module.h:237
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
int GetLocalClearance() const
Definition: class_module.h:240
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:484
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: class_module.h:669
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:308
const wxString & GetKeywords() const
Definition: class_module.h:231
UTF8 Format() const
Definition: lib_id.cpp:237
int GetLocalSolderPasteMargin() const
Definition: class_module.h:251
default
Definition: class_module.h:67
const KIID m_Uuid
Definition: base_struct.h:162
int GetPlacementCost180() const
Definition: class_module.h:563
virtual std::string Quotes(const std::string &aWrapee)
Function Quotes checks aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:433
const wxString & GetDescription() const
Definition: class_module.h:228
double GetLocalSolderPasteMarginRatio() const
Definition: class_module.h:254
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:211
Virtual component: when created by copper shapes on board (Like edge card connectors,...
Definition: class_module.h:70
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
wxString AsString() const
Definition: common.h:137
#define TO_UTF8(wxstring)
const std::map< wxString, wxString > & GetProperties() const
Definition: class_module.h:491
MODULE_ZONE_CONTAINERS & Zones()
Definition: class_module.h:193
wxPoint GetPosition() const override
Definition: class_module.h:216
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
#define CTL_OMIT_INITIAL_COMMENTS
omit MODULE initial comments
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.
int GetThermalWidth() const
Definition: class_module.h:261
int GetThermalGap() const
Definition: class_module.h:264
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

References KIID::AsString(), KIID_PATH::AsString(), CTL_OMIT_AT, CTL_OMIT_INITIAL_COMMENTS, CTL_OMIT_PATH, CTL_OMIT_TSTAMPS, Double2Str(), LIB_ID::Format(), Format(), FormatAngle(), FormatInternalUnits(), formatLayer(), MODULE::GetAttributes(), MODULE::GetDescription(), MODULE::GetFPID(), MODULE::GetInitialComments(), MODULE::GetKeywords(), MODULE::GetLastEditTime(), MODULE::GetLocalClearance(), MODULE::GetLocalSolderMaskMargin(), MODULE::GetLocalSolderPasteMargin(), MODULE::GetLocalSolderPasteMarginRatio(), MODULE::GetOrientation(), MODULE::GetPath(), MODULE::GetPlacementCost180(), MODULE::GetPlacementCost90(), MODULE::GetPosition(), MODULE::GetProperties(), MODULE::GetThermalGap(), MODULE::GetThermalWidth(), MODULE::GetZoneConnection(), MODULE::GraphicalItems(), INHERITED, MODULE::IsLocked(), MODULE::IsPlaced(), m_ctl, m_out, EDA_ITEM::m_Uuid, MOD_CMS, MOD_DEFAULT, MOD_VIRTUAL, MODULE::Models(), MODULE::Pads(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotes(), OUTPUTFORMATTER::Quotew(), MODULE::Reference(), TO_UTF8, MODULE::Value(), and MODULE::Zones().

◆ format() [7/11]

void PCB_IO::format ( D_PAD aPad,
int  aNestLevel = 0 
) const
private

Definition at line 1172 of file kicad_plugin.cpp.

1173 {
1174  const char* shape;
1175 
1176  switch( aPad->GetShape() )
1177  {
1178  case PAD_SHAPE_CIRCLE: shape = "circle"; break;
1179  case PAD_SHAPE_RECT: shape = "rect"; break;
1180  case PAD_SHAPE_OVAL: shape = "oval"; break;
1181  case PAD_SHAPE_TRAPEZOID: shape = "trapezoid"; break;
1183  case PAD_SHAPE_ROUNDRECT: shape = "roundrect"; break;
1184  case PAD_SHAPE_CUSTOM: shape = "custom"; break;
1185 
1186  default:
1187  THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), aPad->GetShape() ) );
1188  }
1189 
1190  const char* type;
1191 
1192  switch( aPad->GetAttribute() )
1193  {
1194  case PAD_ATTRIB_STANDARD: type = "thru_hole"; break;
1195  case PAD_ATTRIB_SMD: type = "smd"; break;
1196  case PAD_ATTRIB_CONN: type = "connect"; break;
1197  case PAD_ATTRIB_HOLE_NOT_PLATED: type = "np_thru_hole"; break;
1198 
1199  default:
1200  THROW_IO_ERROR( wxString::Format( "unknown pad attribute: %d", aPad->GetAttribute() ) );
1201  }
1202 
1203  const char* property = nullptr;
1204 
1205  switch( aPad->GetProperty() )
1206  {
1207  case PAD_PROP_NONE: break; // could be also "none"
1208  case PAD_PROP_BGA: property = "pad_prop_bga"; break;
1209  case PAD_PROP_FIDUCIAL_GLBL: property = "pad_prop_fiducial_glob"; break;
1210  case PAD_PROP_FIDUCIAL_LOCAL: property = "pad_prop_fiducial_loc"; break;
1211  case PAD_PROP_TESTPOINT: property = "pad_prop_testpoint"; break;
1212  case PAD_PROP_HEATSINK: property = "pad_prop_heatsink"; break;
1213  case PAD_PROP_CASTELLATED: property = "pad_prop_castellated"; break;
1214 
1215  default:
1216  THROW_IO_ERROR( wxString::Format( "unknown pad property: %d", aPad->GetProperty() ) );
1217  }
1218 
1219  m_out->Print( aNestLevel, "(pad %s %s %s",
1220  m_out->Quotew( aPad->GetName() ).c_str(),
1221  type, shape );
1222  m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() );
1223 
1224  if( aPad->GetOrientation() != 0.0 )
1225  m_out->Print( 0, " %s", FormatAngle( aPad->GetOrientation() ).c_str() );
1226 
1227  m_out->Print( 0, ")" );
1228  m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() );
1229 
1230  if( (aPad->GetDelta().GetWidth()) != 0 || (aPad->GetDelta().GetHeight() != 0 ) )
1231  m_out->Print( 0, " (rect_delta %s )", FormatInternalUnits( aPad->GetDelta() ).c_str() );
1232 
1233  wxSize sz = aPad->GetDrillSize();
1234  wxPoint shapeoffset = aPad->GetOffset();
1235 
1236  if( (sz.GetWidth() > 0) || (sz.GetHeight() > 0) ||
1237  (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1238  {
1239  m_out->Print( 0, " (drill" );
1240 
1241  if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1242  m_out->Print( 0, " oval" );
1243 
1244  if( sz.GetWidth() > 0 )
1245  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetWidth() ).c_str() );
1246 
1247  if( sz.GetHeight() > 0 && sz.GetWidth() != sz.GetHeight() )
1248  m_out->Print( 0, " %s", FormatInternalUnits( sz.GetHeight() ).c_str() );
1249 
1250  if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1251  m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() );
1252 
1253  m_out->Print( 0, ")" );
1254  }
1255 
1256  // Add pad property, if exists.
1257  if( property )
1258  m_out->Print( 0, " (property %s)", property );
1259 
1260  formatLayers( aPad->GetLayerSet() );
1261 
1262  // Output the radius ratio for rounded and chamfered rect pads
1263  if( aPad->GetShape() == PAD_SHAPE_ROUNDRECT || aPad->GetShape() == PAD_SHAPE_CHAMFERED_RECT)
1264  {
1265  m_out->Print( 0, " (roundrect_rratio %s)",
1266  Double2Str( aPad->GetRoundRectRadiusRatio() ).c_str() );
1267  }
1268 
1269  // Output the chamfer corners for chamfered rect pads
1270  if( aPad->GetShape() == PAD_SHAPE_CHAMFERED_RECT)
1271  {
1272  m_out->Print( 0, "\n" );
1273 
1274  m_out->Print( aNestLevel+1, "(chamfer_ratio %s)",
1275  Double2Str( aPad->GetChamferRectRatio() ).c_str() );
1276 
1277  m_out->Print( 0, " (chamfer" );
1278 
1279  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT ) )
1280  m_out->Print( 0, " top_left" );
1281 
1282  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT ) )
1283  m_out->Print( 0, " top_right" );
1284 
1285  if( ( aPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT ) )
1286  m_out->Print( 0, " bottom_left" );
1287 
1289  m_out->Print( 0, " bottom_right" );
1290 
1291  m_out->Print( 0, ")" );
1292  }
1293 
1294  std::string output;
1295 
1296  // Unconnected pad is default net so don't save it.
1297  if( !( m_ctl & CTL_OMIT_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED )
1298  StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
1299  m_out->Quotew( aPad->GetNetname() ).c_str() );
1300 
1301  // Add pinfunction, if exists.
1302  // Pin function is closely related to nets, so if CTL_OMIT_NETS is set,
1303  // omit also pin function (for instance when saved from library editor)
1304  if( !(m_ctl & CTL_OMIT_NETS) && !aPad->GetPinFunction().IsEmpty() )
1305  StrPrintf( &output, " (pinfunction %s)",
1306  m_out->Quotew( aPad->GetPinFunction() ).c_str() );
1307 
1308  if( aPad->GetPadToDieLength() != 0 )
1309  StrPrintf( &output, " (die_length %s)",
1310  FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() );
1311 
1312  if( aPad->GetLocalSolderMaskMargin() != 0 )
1313  StrPrintf( &output, " (solder_mask_margin %s)",
1314  FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() );
1315 
1316  if( aPad->GetLocalSolderPasteMargin() != 0 )
1317  StrPrintf( &output, " (solder_paste_margin %s)",
1318  FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() );
1319 
1320  if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
1321  StrPrintf( &output, " (solder_paste_margin_ratio %s)",
1322  Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() );
1323 
1324  if( aPad->GetLocalClearance() != 0 )
1325  StrPrintf( &output, " (clearance %s)", FormatInternalUnits( aPad->GetLocalClearance() ).c_str() );
1326 
1328  StrPrintf( &output, " (zone_connect %d)", static_cast<int>( aPad->GetEffectiveZoneConnection() ) );
1329 
1330  if( aPad->GetThermalWidth() != 0 )
1331  StrPrintf( &output, " (thermal_width %s)", FormatInternalUnits( aPad->GetThermalWidth() ).c_str() );
1332 
1333  if( aPad->GetThermalGap() != 0 )
1334  StrPrintf( &output, " (thermal_gap %s)", FormatInternalUnits( aPad->GetThermalGap() ).c_str() );
1335 
1336  if( output.size() )
1337  {
1338  m_out->Print( 0, "\n" );
1339  m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
1340  }
1341 
1342  if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
1343  {
1344  m_out->Print( 0, "\n");
1345  m_out->Print( aNestLevel+1, "(options" );
1346 
1348  m_out->Print( 0, " (clearance convexhull)" );
1349  #if 1 // Set to 1 to output the default option
1350  else
1351  m_out->Print( 0, " (clearance outline)" );
1352  #endif
1353 
1354  // Output the anchor pad shape (circle/rect)
1355  if( aPad->GetAnchorPadShape() == PAD_SHAPE_RECT )
1356  shape = "rect";
1357  else
1358  shape = "circle";
1359 
1360  m_out->Print( 0, " (anchor %s)", shape );
1361 
1362  m_out->Print( 0, ")"); // end of (options ...
1363 
1364  // Output graphic primitive of the pad shape
1365  m_out->Print( 0, "\n");
1366  m_out->Print( aNestLevel+1, "(primitives" );
1367 
1368  int nested_level = aNestLevel+2;
1369 
1370  // Output all basic shapes
1371  for( const std::shared_ptr<DRAWSEGMENT>& primitive : aPad->GetPrimitives() )
1372  {
1373  m_out->Print( 0, "\n");
1374 
1375  switch( primitive->GetShape() )
1376  {
1377  case S_SEGMENT: // usual segment : line with rounded ends
1378  m_out->Print( nested_level, "(gr_line (start %s) (end %s) (width %s))",
1379  FormatInternalUnits( primitive->GetStart() ).c_str(),
1380  FormatInternalUnits( primitive->GetEnd() ).c_str(),
1381  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1382  break;
1383 
1384  case S_RECT:
1385  m_out->Print( nested_level, "(gr_rect (start %s) (end %s) (width %s))",
1386  FormatInternalUnits( primitive->GetStart() ).c_str(),
1387  FormatInternalUnits( primitive->GetEnd() ).c_str(),
1388  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1389  break;
1390 
1391  case S_ARC: // Arc with rounded ends
1392  m_out->Print( nested_level, "(gr_arc (start %s) (end %s) (angle %s) (width %s))",
1393  FormatInternalUnits( primitive->GetStart() ).c_str(),
1394  FormatInternalUnits( primitive->GetEnd() ).c_str(),
1395  FormatAngle( primitive->GetAngle() ).c_str(),
1396  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1397  break;
1398 
1399  case S_CIRCLE: // ring or circle (circle if width == 0
1400  m_out->Print( nested_level, "(gr_circle (center %s) (end %s) (width %s))",
1401  FormatInternalUnits( primitive->GetStart() ).c_str(),
1402  FormatInternalUnits( primitive->GetEnd() ).c_str(),
1403  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1404  break;
1405 
1406  case S_CURVE: // Bezier Curve
1407  m_out->Print( aNestLevel, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s)) (width %s))",
1408  FormatInternalUnits( primitive->GetStart() ).c_str(),
1409  FormatInternalUnits( primitive->GetBezControl1() ).c_str(),
1410  FormatInternalUnits( primitive->GetBezControl2() ).c_str(),
1411  FormatInternalUnits( primitive->GetEnd() ).c_str(),
1412  FormatInternalUnits( primitive->GetWidth() ).c_str() );
1413  break;
1414 
1415  case S_POLYGON: // polygon
1416  if( primitive->GetPolyShape().COutline( 0 ).CPoints().size() < 2 )
1417  break; // Malformed polygon.
1418 
1419  {
1420  m_out->Print( nested_level, "(gr_poly (pts\n");
1421 
1422  // Write the polygon corners coordinates:
1423  int newLine = 0;
1424 
1425  for( const VECTOR2I &pt : primitive->GetPolyShape().COutline( 0 ).CPoints() )
1426  {
1427  if( newLine == 0 )
1428  m_out->Print( nested_level+1, "(xy %s)",
1429  FormatInternalUnits( (wxPoint) pt ).c_str() );
1430  else
1431  m_out->Print( 0, " (xy %s)",
1432  FormatInternalUnits( (wxPoint) pt ).c_str() );
1433 
1434  if( ++newLine > 4 || !ADVANCED_CFG::GetCfg().m_CompactSave )
1435  {
1436  newLine = 0;
1437  m_out->Print( 0, "\n" );
1438  }
1439  }
1440 
1441  m_out->Print( 0, ") (width %s))", FormatInternalUnits( primitive->GetWidth() ).c_str() );
1442  }
1443  break;
1444 
1445  default:
1446  break;
1447  }
1448  }
1449 
1450  m_out->Print( 0, "\n");
1451  m_out->Print( aNestLevel+1, ")" ); // end of (basic_shapes
1452  }
1453 
1454  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aPad->m_Uuid.AsString() ) );
1455 
1456  m_out->Print( 0, ")\n" );
1457 }
int GetLocalSolderMaskMargin() const
Definition: class_pad.h:350
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetPos0() const
Definition: class_pad.h:218
int StrPrintf(std::string *aResult, const char *aFormat,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
no special fabrication property
Definition: pad_shapes.h:97
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:171
int GetLocalClearance(wxString *aSource=nullptr) const override
Function GetLocalClearance returns any local clearances set in the "classic" (ie: pre-rule) system.
Definition: class_pad.cpp:592
a fiducial (usually a smd) for the full board
Definition: pad_shapes.h:99
polygon (not yet used for tracks, but could be in microwave apps)
int GetPadToDieLength() const
Definition: class_pad.h:348
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
Smd pad, used in BGA footprints.
Definition: pad_shapes.h:98
wxString AsString() const
Definition: common.cpp:165
usual segment : line with rounded ends
std::string Double2Str(double aValue)
Helper function Double2Str to print a float number without using scientific notation and no trailing ...
Definition: base_units.cpp:62
a pad used as heat sink, usually in SMD footprints
Definition: pad_shapes.h:102
const wxString & GetPinFunction() const
Definition: class_pad.h:138
int GetThermalGap() const
Definition: class_pad.cpp:722
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:338
int GetChamferPositions() const
Definition: class_pad.h:496
a pad with a castellated through hole
Definition: pad_shapes.h:103
segment with non rounded ends
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
Arcs (with rounded ends)
const wxPoint & GetOffset() const
Definition: class_pad.h:233
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:330
double GetChamferRectRatio() const
Definition: class_pad.h:488
int GetThermalWidth() const
Definition: class_pad.cpp:711
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:335
const wxString & GetName() const
Definition: class_pad.h:132
#define THROW_IO_ERROR(msg)
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
PAD_PROP_T GetProperty() const
Definition: class_pad.h:341
Bezier Curve.
const wxSize & GetDelta() const
Definition: class_pad.h:227
const wxString & GetNetname() const
Function GetNetname.
#define CTL_OMIT_NETS
Omit pads net names (useless in library)
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
ZONE_CONNECTION GetEffectiveZoneConnection() const
Return the zone connection in effect (either locally overridden or overridden in the parent module).
Definition: class_pad.cpp:700
const KIID m_Uuid
Definition: base_struct.h:162
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: class_pad.h:177
a fiducial (usually a smd) local to the parent footprint
Definition: pad_shapes.h:100
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:325
const wxSize & GetDrillSize() const
Definition: class_pad.h:230
#define TO_UTF8(wxstring)
double GetRoundRectRadiusRatio() const
Definition: class_pad.h:480
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
const std::vector< std::shared_ptr< DRAWSEGMENT > > & GetPrimitives() const
Accessor to the basic shape list.
Definition: class_pad.h:273
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
const wxSize & GetSize() const
Definition: class_pad.h:224
int GetLocalSolderPasteMargin() const
Definition: class_pad.h:356
a test point pad
Definition: pad_shapes.h:101
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:478
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
double GetLocalSolderPasteMarginRatio() const
Definition: class_pad.h:359
int Translate(int aNetCode) const
Function Translate Translates net number according to the map prepared by Update() function.

References _, KIID::AsString(), CTL_OMIT_NETS, CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL, Double2Str(), Format(), FormatAngle(), FormatInternalUnits(), formatLayers(), D_PAD::GetAnchorPadShape(), D_PAD::GetAttribute(), ADVANCED_CFG::GetCfg(), D_PAD::GetChamferPositions(), D_PAD::GetChamferRectRatio(), D_PAD::GetCustomShapeInZoneOpt(), D_PAD::GetDelta(), D_PAD::GetDrillShape(), D_PAD::GetDrillSize(), D_PAD::GetEffectiveZoneConnection(), D_PAD::GetLayerSet(), D_PAD::GetLocalClearance(), D_PAD::GetLocalSolderMaskMargin(), D_PAD::GetLocalSolderPasteMargin(), D_PAD::GetLocalSolderPasteMarginRatio(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetNetname(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetPadToDieLength(), D_PAD::GetPinFunction(), D_PAD::GetPos0(), D_PAD::GetPrimitives(), D_PAD::GetProperty(), D_PAD::GetRoundRectRadiusRatio(), D_PAD::GetShape(), D_PAD::GetSize(), D_PAD::GetThermalGap(), D_PAD::GetThermalWidth(), INHERITED, m_ctl, m_mapping, m_out, EDA_ITEM::m_Uuid, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, PAD_DRILL_SHAPE_OBLONG, PAD_PROP_BGA, PAD_PROP_CASTELLATED, PAD_PROP_FIDUCIAL_GLBL, PAD_PROP_FIDUCIAL_LOCAL, PAD_PROP_HEATSINK, PAD_PROP_NONE, PAD_PROP_TESTPOINT, PAD_SHAPE_CHAMFERED_RECT, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), RECT_CHAMFER_BOTTOM_LEFT, RECT_CHAMFER_BOTTOM_RIGHT, RECT_CHAMFER_TOP_LEFT, RECT_CHAMFER_TOP_RIGHT, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, numEval::StrPrintf(), THROW_IO_ERROR, TO_UTF8, NETINFO_MAPPING::Translate(), NETINFO_LIST::UNCONNECTED, wxPoint::x, and wxPoint::y.

◆ format() [8/11]

void PCB_IO::format ( TEXTE_PCB aText,
int  aNestLevel = 0 
) const
private

Definition at line 1460 of file kicad_plugin.cpp.

1461 {
1462  m_out->Print( aNestLevel, "(gr_text %s (at %s",
1463  m_out->Quotew( aText->GetText() ).c_str(),
1464  FormatInternalUnits( aText->GetTextPos() ).c_str() );
1465 
1466  if( aText->GetTextAngle() != 0.0 )
1467  m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() );
1468 
1469  m_out->Print( 0, ")" );
1470 
1471  formatLayer( aText );
1472 
1473  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aText->m_Uuid.AsString() ) );
1474 
1475  m_out->Print( 0, "\n" );
1476 
1477  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl );
1478 
1479  m_out->Print( aNestLevel, ")\n" );
1480 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatLayer(const BOARD_ITEM *aItem) const
double GetTextAngle() const
Definition: eda_text.h:174
wxString AsString() const
Definition: common.cpp:165
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
const KIID m_Uuid
Definition: base_struct.h:162
#define TO_UTF8(wxstring)
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

References KIID::AsString(), 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() [9/11]

void PCB_IO::format ( TEXTE_MODULE aText,
int  aNestLevel = 0 
) const
private

Definition at line 1483 of file kicad_plugin.cpp.

1484 {
1485  std::string type;
1486 
1487  switch( aText->GetType() )
1488  {
1489  case TEXTE_MODULE::TEXT_is_REFERENCE: type = "reference"; break;
1490  case TEXTE_MODULE::TEXT_is_VALUE: type = "value"; break;
1491  case TEXTE_MODULE::TEXT_is_DIVERS: type = "user";
1492  }
1493 
1494  m_out->Print( aNestLevel, "(fp_text %s %s (at %s",
1495  type.c_str(),
1496  m_out->Quotew( aText->GetText() ).c_str(),
1497  FormatInternalUnits( aText->GetPos0() ).c_str() );
1498 
1499  // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
1500  // but internally the angle is held relative to its parent footprint. parent
1501  // may be NULL when saving a footprint outside a BOARD.
1502  double orient = aText->GetTextAngle();
1503  MODULE* parent = (MODULE*) aText->GetParent();
1504 
1505  if( parent )
1506  {
1507  // GetTextAngle() is always in -360..+360 range because of
1508  // TEXTE_MODULE::SetTextAngle(), but summing that angle with an
1509  // additional board angle could kick sum up >= 360 or <= -360, so to have
1510  // consistent results, normalize again for the BOARD save. A footprint
1511  // save does not use this code path since parent is NULL.
1512 #if 0
1513  // This one could be considered reasonable if you like positive angles
1514  // in your board text.
1515  orient = NormalizeAnglePos( orient + parent->GetOrientation() );
1516 #else
1517  // Choose compatibility for now, even though this is only a 720 degree clamp
1518  // with two possible values for every angle.
1519  orient = NormalizeAngle360Min( orient + parent->GetOrientation() );
1520 #endif
1521  }
1522 
1523  if( orient != 0.0 )
1524  m_out->Print( 0, " %s", FormatAngle( orient ).c_str() );
1525 
1526  if( !aText->IsKeepUpright() )
1527  m_out->Print( 0, " unlocked" );
1528 
1529  m_out->Print( 0, ")" );
1530  formatLayer( aText );
1531 
1532  if( !aText->IsVisible() )
1533  m_out->Print( 0, " hide" );
1534 
1535  m_out->Print( 0, "\n" );
1536 
1537  aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1538 
1539  m_out->Print( aNestLevel + 1, "(tstamp %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
1540 
1541  m_out->Print( aNestLevel, ")\n" );
1542 }
double GetOrientation() const
Definition: class_module.h:221
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void formatLayer(const BOARD_ITEM *aItem) const
bool IsVisible() const
Definition: eda_text.h:186
double GetTextAngle() const
Definition: eda_text.h:174
wxString AsString() const
Definition: common.cpp:165
bool IsKeepUpright()
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:589
TEXT_TYPE GetType() const
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
const KIID m_Uuid
Definition: base_struct.h:162
const wxPoint & GetPos0() const
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:248
#define TO_UTF8(wxstring)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
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:237
BOARD_ITEM_CONTAINER * GetParent() const
#define CTL_OMIT_HIDE
Definition: eda_text.h:43
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560

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

◆ format() [10/11]

void PCB_IO::format ( TRACK aTrack,
int  aNestLevel = 0 
) const
private

Definition at line 1545 of file kicad_plugin.cpp.

1546 {
1547  if( aTrack->Type() == PCB_VIA_T )
1548  {
1549  PCB_LAYER_ID layer1, layer2;
1550 
1551  const VIA* via = static_cast<const VIA*>( aTrack );
1552  BOARD* board = (BOARD*) via->GetParent();
1553 
1554  wxCHECK_RET( board != 0, wxT( "Via " ) + via->GetSelectMenuText( EDA_UNITS::MILLIMETRES )
1555  + wxT( " has no parent." ) );
1556 
1557  m_out->Print( aNestLevel, "(via" );
1558 
1559  via->LayerPair( &layer1, &layer2 );
1560 
1561  switch( via->GetViaType() )
1562  {
1563  case VIATYPE::THROUGH: // Default shape not saved.
1564  break;
1565 
1566  case VIATYPE::BLIND_BURIED:
1567  m_out->Print( 0, " blind" );
1568  break;
1569 
1570  case VIATYPE::MICROVIA:
1571  m_out->Print( 0, " micro" );
1572  break;
1573 
1574  default:
1575  THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
1576  }
1577 
1578  m_out->Print( 0, " (at %s) (size %s)",
1579  FormatInternalUnits( aTrack->GetStart() ).c_str(),
1580  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1581 
1582  if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
1583  m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrill() ).c_str() );
1584 
1585  m_out->Print( 0, " (layers %s %s)",
1586  m_out->Quotew( m_board->GetLayerName( layer1 ) ).c_str(),
1587  m_out->Quotew( m_board->GetLayerName( layer2 ) ).c_str() );
1588  }
1589  else if( aTrack->Type() == PCB_ARC_T )
1590  {
1591  const ARC* arc = static_cast<const ARC*>( aTrack );
1592 
1593  m_out->Print( aNestLevel, "(arc (start %s) (mid %s) (end %s) (width %s)",
1594  FormatInternalUnits( arc->GetStart() ).c_str(),
1595  FormatInternalUnits( arc->GetMid() ).c_str(),
1596  FormatInternalUnits( arc->GetEnd() ).c_str(),
1597  FormatInternalUnits( arc->GetWidth() ).c_str() );
1598 
1599  m_out->Print( 0, " (layer %s)", m_out->Quotew( aTrack->GetLayerName() ).c_str() );
1600  }
1601  else
1602  {
1603  m_out->Print( aNestLevel, "(segment (start %s) (end %s) (width %s)",
1604  FormatInternalUnits( aTrack->GetStart() ).c_str(), FormatInternalUnits( aTrack->GetEnd() ).c_str(),
1605  FormatInternalUnits( aTrack->GetWidth() ).c_str() );
1606 
1607  m_out->Print( 0, " (layer %s)", m_out->Quotew( aTrack->GetLayerName() ).c_str() );
1608  }
1609 
1610  m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
1611 
1612  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTrack->m_Uuid.AsString() ) );
1613 
1614  if( aTrack->GetStatus() != 0 )
1615  m_out->Print( 0, " (status %X)", aTrack->GetStatus() );
1616 
1617  m_out->Print( 0, ")\n" );
1618 }
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
STATUS_FLAGS GetStatus() const
Definition: base_struct.h:229
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
int GetNetCode() const
Function GetNetCode.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
const wxPoint & GetStart() const
Definition: class_track.h:118
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
wxString AsString() const
Definition: common.cpp:165
PCB_LAYER_ID
A quick note on layer IDs:
const wxPoint & GetMid() const
Definition: class_track.h:298
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
Definition: class_track.h:459
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_track.cpp:72
#define THROW_IO_ERROR(msg)
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
#define UNDEFINED_DRILL_DIAMETER
Definition: class_track.h:77
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
const KIID m_Uuid
Definition: base_struct.h:162
int GetWidth() const
Definition: class_track.h:112
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * m_board
which BOARD, no ownership here
VIATYPE GetViaType() const
Definition: class_track.h:378
#define TO_UTF8(wxstring)
const wxPoint & GetEnd() const
Definition: class_track.h:115
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
BOARD_ITEM_CONTAINER * GetParent() const
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
int Translate(int aNetCode) const
Function Translate Translates net number according to the map prepared by Update() function.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, KIID::AsString(), BLIND_BURIED, Format(), FormatInternalUnits(), VIA::GetDrill(), TRACK::GetEnd(), BOARD_ITEM::GetLayerName(), BOARD::GetLayerName(), ARC::GetMid(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_ITEM::GetParent(), VIA::GetSelectMenuText(), TRACK::GetStart(), EDA_ITEM::GetStatus(), VIA::GetViaType(), TRACK::GetWidth(), VIA::LayerPair(), m_board, m_mapping, m_out, EDA_ITEM::m_Uuid, MICROVIA, MILLIMETRES, PCB_ARC_T, PCB_VIA_T, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), THROUGH, THROW_IO_ERROR, TO_UTF8, NETINFO_MAPPING::Translate(), EDA_ITEM::Type(), and UNDEFINED_DRILL_DIAMETER.

◆ format() [11/11]

void PCB_IO::format ( ZONE_CONTAINER aZone,
int  aNestLevel = 0 
) const
private

Definition at line 1621 of file kicad_plugin.cpp.

1622 {
1623  // Save the NET info; For keepout zones, net code and net name are irrelevant
1624  // so be sure a dummy value is stored, just for ZONE_CONTAINER compatibility
1625  // (perhaps netcode and netname should be not stored)
1626  m_out->Print( aNestLevel, "(zone (net %d) (net_name %s)",
1627  aZone->GetIsKeepout() ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
1628  m_out->Quotew( aZone->GetIsKeepout() ? wxT("") : aZone->GetNetname() ).c_str() );
1629 
1630  // If a zone exists on multiple layers, format accordingly
1631  if( aZone->GetLayerSet().count() > 1 )
1632  {
1633  formatLayers( aZone->GetLayerSet() );
1634  }
1635  else
1636  {
1637  formatLayer( aZone );
1638  }
1639 
1640  m_out->Print( 0, " (tstamp %s)", TO_UTF8( aZone->m_Uuid.AsString() ) );
1641 
1642  if( !aZone->GetZoneName().empty() )
1643  m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
1644 
1645  // Save the outline aux info
1646  std::string hatch;
1647 
1648  switch( aZone->GetHatchStyle() )
1649  {
1650  default:
1651  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: hatch = "none"; break;
1652  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: hatch = "edge"; break;
1653  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: hatch = "full"; break;
1654  }
1655 
1656  m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
1657  FormatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() );
1658 
1659  if( aZone->GetPriority() > 0 )
1660  m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetPriority() );
1661 
1662  m_out->Print( aNestLevel+1, "(connect_pads" );
1663 
1664  switch( aZone->GetPadConnection() )
1665  {
1666  default:
1667  case ZONE_CONNECTION::THERMAL: // Default option not saved or loaded.
1668  break;
1669 
1671  m_out->Print( 0, " thru_hole_only" );
1672  break;
1673 
1674  case ZONE_CONNECTION::FULL:
1675  m_out->Print( 0, " yes" );
1676  break;
1677 
1678  case ZONE_CONNECTION::NONE:
1679  m_out->Print( 0, " no" );
1680  break;
1681  }
1682 
1683  m_out->Print( 0, " (clearance %s))\n",
1684  FormatInternalUnits( aZone->GetZoneClearance() ).c_str() );
1685 
1686  m_out->Print( aNestLevel+1, "(min_thickness %s)",
1687  FormatInternalUnits( aZone->GetMinThickness() ).c_str() );
1688 
1689  // write it only if V 6.O version option is not used (i.e. do not write if the
1690  // "legacy" algorithm is used)
1691  if( !aZone->GetFilledPolysUseThickness() )
1692  m_out->Print( 0, " (filled_areas_thickness no)" );
1693 
1694  m_out->Print( 0, "\n" );
1695 
1696  if( aZone->GetIsKeepout() )
1697  {
1698  m_out->Print( aNestLevel+1, "(keepout (tracks %s) (vias %s) (pads %s ) (copperpour %s) (footprints %s))\n",
1699  aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
1700  aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
1701  aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
1702  aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
1703  aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
1704  }
1705 
1706  m_out->Print( aNestLevel+1, "(fill" );
1707 
1708  // Default is not filled.
1709  if( aZone->IsFilled() )
1710  m_out->Print( 0, " yes" );
1711 
1712  // Default is polygon filled.
1713  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
1714  m_out->Print( 0, " (mode hatch)" );
1715 
1716  m_out->Print( 0, " (thermal_gap %s) (thermal_bridge_width %s)",
1717  FormatInternalUnits( aZone->GetThermalReliefGap() ).c_str(),
1718  FormatInternalUnits( aZone->GetThermalReliefCopperBridge() ).c_str() );
1719 
1721  {
1722  m_out->Print( 0, " (smoothing" );
1723 
1724  switch( aZone->GetCornerSmoothingType() )
1725  {
1727  m_out->Print( 0, " chamfer" );
1728  break;
1729 
1731  m_out->Print( 0, " fillet" );
1732  break;
1733 
1734  default:
1735  THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
1736  aZone->GetCornerSmoothingType() ) );
1737  }
1738  m_out->Print( 0, ")" );
1739 
1740  if( aZone->GetCornerRadius() != 0 )
1741  m_out->Print( 0, " (radius %s)",
1742  FormatInternalUnits( aZone->GetCornerRadius() ).c_str() );
1743  }
1744 
1746  {
1747  m_out->Print( 0, " (island_removal_mode %d) (island_area_min %s)",
1748  static_cast<int>( aZone->GetIslandRemovalMode() ),
1749  FormatInternalUnits( aZone->GetMinIslandArea() / IU_PER_MM ).c_str() );
1750  }
1751 
1752  if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
1753  {
1754  m_out->Print( 0, "\n" );
1755  m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
1756  FormatInternalUnits( aZone->GetHatchThickness() ).c_str(),
1757  FormatInternalUnits( aZone->GetHatchGap() ).c_str(),
1758  Double2Str( aZone->GetHatchOrientation() ).c_str() );
1759 
1760  if( aZone->GetHatchSmoothingLevel() > 0 )
1761  {
1762  m_out->Print( 0, "\n" );
1763  m_out->Print( aNestLevel+2, "(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
1764  aZone->GetHatchSmoothingLevel(),
1765  Double2Str( aZone->GetHatchSmoothingValue() ).c_str() );
1766  }
1767 
1768  m_out->Print( 0, "\n" );
1769  m_out->Print( aNestLevel+2, "(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
1770  aZone->GetHatchBorderAlgorithm() ? "hatch_thickness" : "min_thickness",
1771  Double2Str( aZone->GetHatchHoleMinArea() ).c_str() );
1772  }
1773 
1774  m_out->Print( 0, ")\n" );
1775 
1776  int newLine = 0;
1777 
1778  if( aZone->GetNumCorners() )
1779  {
1780  bool new_polygon = true;
1781  bool is_closed = false;
1782 
1783  for( auto iterator = aZone->IterateWithHoles(); iterator; iterator++ )
1784  {
1785  if( new_polygon )
1786  {
1787  newLine = 0;
1788  m_out->Print( aNestLevel+1, "(polygon\n" );
1789  m_out->Print( aNestLevel+2, "(pts\n" );
1790  new_polygon = false;
1791  is_closed = false;
1792  }
1793 
1794  if( newLine == 0 )
1795  m_out->Print( aNestLevel+3, "(xy %s %s)",
1796  FormatInternalUnits( iterator->x ).c_str(),
1797  FormatInternalUnits( iterator->y ).c_str() );
1798  else
1799  m_out->Print( 0, " (xy %s %s)",
1800  FormatInternalUnits( iterator->x ).c_str(),
1801  FormatInternalUnits( iterator->y ).c_str() );
1802 
1803  if( newLine < 4 && ADVANCED_CFG::GetCfg().m_CompactSave )
1804  {
1805  newLine += 1;
1806  }
1807  else
1808  {
1809  newLine = 0;
1810  m_out->Print( 0, "\n" );
1811  }
1812 
1813  if( iterator.IsEndContour() )
1814  {
1815  is_closed = true;
1816 
1817  if( newLine != 0 )
1818  m_out->Print( 0, "\n" );
1819 
1820  m_out->Print( aNestLevel+2, ")\n" );
1821  m_out->Print( aNestLevel+1, ")\n" );
1822  new_polygon = true;
1823  }
1824  }
1825 
1826  if( !is_closed ) // Should not happen, but...
1827  {
1828  if( newLine != 0 )
1829  m_out->Print( 0, "\n" );
1830 
1831  m_out->Print( aNestLevel+2, ")\n" );
1832  m_out->Print( aNestLevel+1, ")\n" );
1833  }
1834  }
1835 
1836  // Save the PolysList (filled areas)
1837  for( PCB_LAYER_ID layer : aZone->GetLayerSet().Seq() )
1838  {
1839  const SHAPE_POLY_SET& fv = aZone->GetFilledPolysList( layer );
1840  newLine = 0;
1841 
1842  if( !fv.IsEmpty() )
1843  {
1844  int poly_index = 0;
1845  bool new_polygon = true;
1846  bool is_closed = false;
1847 
1848  for( auto it = fv.CIterate(); it; ++it )
1849  {
1850  if( new_polygon )
1851  {
1852  newLine = 0;
1853  m_out->Print( aNestLevel + 1, "(filled_polygon\n" );
1854  m_out->Print( aNestLevel + 2, "(layer %s)\n",
1855  TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
1856 
1857  if( aZone->IsIsland( layer, poly_index ) )
1858  m_out->Print( aNestLevel + 2, "(island)\n" );
1859 
1860  m_out->Print( aNestLevel + 2, "(pts\n" );
1861  new_polygon = false;
1862  is_closed = false;
1863  poly_index++;
1864  }
1865 
1866  if( newLine == 0 )
1867  m_out->Print( aNestLevel + 3, "(xy %s %s)",
1868  FormatInternalUnits( it->x ).c_str(),
1869  FormatInternalUnits( it->y ).c_str() );
1870  else
1871  m_out->Print( 0, " (xy %s %s)", FormatInternalUnits( it->x ).c_str(),
1872  FormatInternalUnits( it->y ).c_str() );
1873 
1874  if( newLine < 4 && ADVANCED_CFG::GetCfg().m_CompactSave )
1875  {
1876  newLine += 1;
1877  }
1878  else
1879  {
1880  newLine = 0;
1881  m_out->Print( 0, "\n" );
1882  }
1883 
1884  if( it.IsEndContour() )
1885  {
1886  is_closed = true;
1887 
1888  if( newLine != 0 )
1889  m_out->Print( 0, "\n" );
1890 
1891  m_out->Print( aNestLevel + 2, ")\n" );
1892  m_out->Print( aNestLevel + 1, ")\n" );
1893  new_polygon = true;
1894  }
1895  }
1896 
1897  if( !is_closed ) // Should not happen, but...
1898  m_out->Print( aNestLevel + 1, ")\n" );
1899  }
1900 
1901  // Save the filling segments list
1902  const auto& segs = aZone->FillSegments( layer );
1903 
1904  if( segs.size() )
1905  {
1906  m_out->Print( aNestLevel + 1, "(fill_segments\n" );
1907  m_out->Print( aNestLevel + 2, "(layer %s)\n",
1908  TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
1909 
1910  for( ZONE_SEGMENT_FILL::const_iterator it = segs.begin(); it != segs.end(); ++it )
1911  {
1912  m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n",
1913  FormatInternalUnits( wxPoint( it->A ) ).c_str(),
1914  FormatInternalUnits( wxPoint( it->B ) ).c_str() );
1915  }
1916 
1917  m_out->Print( aNestLevel + 1, ")\n" );
1918  }
1919  }
1920 
1921  m_out->Print( aNestLevel, ")\n" );
1922 }
bool GetDoNotAllowPads() const
Definition: class_zone.h:716
bool IsFilled() const
Definition: class_zone.h:190
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
int GetNetCode() const
Function GetNetCode.
void formatLayer(const BOARD_ITEM *aItem) const
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:330
int GetHatchBorderAlgorithm() const
Definition: class_zone.h:233
static constexpr double IU_PER_MM
Mock up a conversion function.
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:671
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:612
wxString AsString() const
Definition: common.cpp:165
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: class_zone.h:577
std::string Double2Str(double aValue)
Helper function Double2Str to print a float number without using scientific notation and no trailing ...
Definition: base_units.cpp:62
int GetThermalReliefGap(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:321
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:377
bool GetDoNotAllowVias() const
Definition: class_zone.h:714
long long int GetMinIslandArea() const
Definition: class_zone.h:739
int GetHatchGap() const
Definition: class_zone.h:218
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:288
wxString GetZoneName() const
Definition: class_zone.h:114
PCB_LAYER_ID
A quick note on layer IDs:
pads are covered by copper
unsigned int GetCornerRadius() const
Definition: class_zone.h:669
SHAPE_POLY_SET.
ZONE_FILL_MODE GetFillMode() const
Definition: class_zone.h:153
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:713
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: class_zone.h:735
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: class_zone.cpp:924
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:489
#define THROW_IO_ERROR(msg)
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
ZONE_CONNECTION GetPadConnection(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:818
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
int GetCornerSmoothingType() const
Definition: class_zone.h:665
double GetHatchOrientation() const
Definition: class_zone.h:221
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:712
Thermal relief only for THT pads.
const KIID m_Uuid
Definition: base_struct.h:162
Use thermal relief for pads.
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:106
double GetHatchSmoothingValue() const
Definition: class_zone.h:227
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Function IterateWithHoles returns an iterator to visit all points of the zone's main outline with hol...
Definition: class_zone.h:509
#define TO_UTF8(wxstring)
int GetMinThickness() const
Definition: class_zone.h:206
Pads are not covered.
int GetHatchSmoothingLevel() const
Definition: class_zone.h:224
bool GetDoNotAllowTracks() const
Definition: class_zone.h:715
bool GetDoNotAllowFootprints() const
Definition: class_zone.h:717
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
ZONE_SEGMENT_FILL & FillSegments(PCB_LAYER_ID aLayer)
Definition: class_zone.h:270
int GetHatchThickness() const
Definition: class_zone.h:215
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
int GetZoneClearance() const
Definition: class_zone.h:196
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx)
Checks if a given filled polygon is an insulated island.
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
double GetHatchHoleMinArea() const
Definition: class_zone.h:230
int Translate(int aNetCode) const
Function Translate Translates net number according to the map prepared by Update() function.
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:650

References _, ALWAYS, KIID::AsString(), SHAPE_POLY_SET::CIterate(), DIAGONAL_EDGE, DIAGONAL_FULL, Double2Str(), ZONE_CONTAINER::FillSegments(), Format(), FormatInternalUnits(), formatLayer(), formatLayers(), FULL, ZONE_CONTAINER::GetBorderHatchPitch(), ADVANCED_CFG::GetCfg(), ZONE_CONTAINER::GetCornerRadius(), ZONE_CONTAINER::GetCornerSmoothingType(), ZONE_CONTAINER::GetDoNotAllowCopperPour(), ZONE_CONTAINER::GetDoNotAllowFootprints(), ZONE_CONTAINER::GetDoNotAllowPads(), ZONE_CONTAINER::GetDoNotAllowTracks(), ZONE_CONTAINER::GetDoNotAllowVias(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetFilledPolysUseThickness(), ZONE_CONTAINER::GetFillMode(), ZONE_CONTAINER::GetHatchBorderAlgorithm(), ZONE_CONTAINER::GetHatchGap(), ZONE_CONTAINER::GetHatchHoleMinArea(), ZONE_CONTAINER::GetHatchOrientation(), ZONE_CONTAINER::GetHatchSmoothingLevel(), ZONE_CONTAINER::GetHatchSmoothingValue(), ZONE_CONTAINER::GetHatchStyle(), ZONE_CONTAINER::GetHatchThickness(), ZONE_CONTAINER::GetIsKeepout(), ZONE_CONTAINER::GetIslandRemovalMode(), ZONE_CONTAINER::GetLayerSet(), ZONE_CONTAINER::GetMinIslandArea(), ZONE_CONTAINER::GetMinThickness(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetNetname(), ZONE_CONTAINER::GetNumCorners(), ZONE_CONTAINER::GetPadConnection(), ZONE_CONTAINER::GetPriority(), BOARD::GetStandardLayerName(), ZONE_CONTAINER::GetThermalReliefCopperBridge(), ZONE_CONTAINER::GetThermalReliefGap(), ZONE_CONTAINER::GetZoneClearance(), ZONE_CONTAINER::GetZoneName(), HATCH_PATTERN, SHAPE_POLY_SET::IsEmpty(), ZONE_CONTAINER::IsFilled(), ZONE_CONTAINER::IsIsland(), ZONE_CONTAINER::IterateWithHoles(), IU_PER_MM, ADVANCED_CFG::m_CompactSave, m_mapping, m_out, EDA_ITEM::m_Uuid, NO_HATCH, NONE, 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_IO::formatBoardLayers ( BOARD aBoard,
int  aNestLevel = 0 
) const
protected

formats the board layer information

Definition at line 523 of file kicad_plugin.cpp.

524 {
525  m_out->Print( aNestLevel, "(layers\n" );
526 
527  // Save only the used copper layers from front to back.
528 
529  for( LSEQ cu = aBoard->GetEnabledLayers().CuStack(); cu; ++cu )
530  {
531  PCB_LAYER_ID layer = *cu;
532 
533  m_out->Print( aNestLevel+1, "(%d %s %s", layer,
534  m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str(),
535  LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
536 
537  m_out->Print( 0, ")\n" );
538  }
539 
540  // Save used non-copper layers in the order they are defined.
541  // desired sequence for non Cu BOARD layers.
542  static const PCB_LAYER_ID non_cu[] =
543  {
544  B_Adhes, // 32
545  F_Adhes,
546  B_Paste,
547  F_Paste,
548  B_SilkS,
549  F_SilkS,
550  B_Mask,
551  F_Mask,
552  Dwgs_User,
553  Cmts_User,
554  Eco1_User,
555  Eco2_User,
556  Edge_Cuts,
557  Margin,
558  B_CrtYd,
559  F_CrtYd,
560  B_Fab,
561  F_Fab
562  };
563 
564  for( LSEQ seq = aBoard->GetEnabledLayers().Seq( non_cu, arrayDim( non_cu ) ); seq; ++seq )
565  {
566  PCB_LAYER_ID layer = *seq;
567 
568  m_out->Print( aNestLevel+1, "(%d %s user", layer,
569  m_out->Quotew( aBoard->GetLayerName( layer ) ).c_str() );
570 
571  m_out->Print( 0, ")\n" );
572  }
573 
574  m_out->Print( aNestLevel, ")\n\n" );
575 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:155
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:377
static const char * ShowType(LAYER_T aType)
Function ShowType converts a LAYER_T enum to a const char*.
PCB_LAYER_ID
A quick note on layer IDs:
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Function GetLayerType returns the type of the copper layer given by aLayer.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

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_out, Margin, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), LSET::Seq(), and LAYER::ShowType().

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

◆ formatGeneral()

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

formats the General section of the file

Definition at line 502 of file kicad_plugin.cpp.

503 {
504  const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
505 
506  m_out->Print( 0, "\n" );
507  m_out->Print( aNestLevel, "(general\n" );
508  // Write Bounding box info
509  m_out->Print( aNestLevel+1, "(thickness %s)\n",
510  FormatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() );
511 
512  m_out->Print( aNestLevel+1, "(drawings %u)\n", (unsigned)aBoard->Drawings().size() );
513  m_out->Print( aNestLevel + 1, "(tracks %u)\n", (unsigned)aBoard->Tracks().size() );
514  m_out->Print( aNestLevel + 1, "(modules %u)\n", (unsigned)aBoard->Modules().size() );
515  m_out->Print( aNestLevel+1, "(nets %d)\n", m_mapping->GetSize() );
516  m_out->Print( aNestLevel, ")\n\n" );
517 
518  aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl );
519  aBoard->GetTitleBlock().Format( m_out, aNestLevel, m_ctl );
520 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:574
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function GetStandardSizes returns the standard page types, such as "A4", "A3", etc.
Definition: page_info.cpp:271
int GetSize() const
Function GetSize.
Definition: netinfo.h:390
MODULES & Modules()
Definition: class_board.h:266
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the object to aFormatter in s-expression form.
Definition: title_block.cpp:28
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:580
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
DRAWINGS & Drawings()
Definition: class_board.h:275
TRACKS & Tracks()
Definition: class_board.h:257
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References BOARD::Drawings(), TITLE_BLOCK::Format(), PAGE_INFO::Format(), FormatInternalUnits(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetDesignSettings(), BOARD::GetPageSettings(), NETINFO_MAPPING::GetSize(), BOARD::GetTitleBlock(), m_ctl, m_mapping, m_out, BOARD::Modules(), OUTPUTFORMATTER::Print(), and BOARD::Tracks().

Referenced by formatHeader().

◆ formatHeader()

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

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

Definition at line 594 of file kicad_plugin.cpp.

595 {
596  formatGeneral( aBoard, aNestLevel );
597  // Layers list.
598  formatBoardLayers( aBoard, aNestLevel );
599 
600  // Setup
601  formatSetup( aBoard, aNestLevel );
602 
603  // Save net codes and names
604  formatNetInformation( aBoard, aNestLevel );
605 }
void formatGeneral(BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
void formatNetInformation(BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
void formatSetup(BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
void formatBoardLayers(BOARD *aBoard, int aNestLevel=0) const
formats the board layer information

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

Referenced by format().

◆ formatLayer()

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

Definition at line 459 of file kicad_plugin.cpp.

460 {
461  if( m_ctl & CTL_STD_LAYER_NAMES )
462  {
463  PCB_LAYER_ID layer = aItem->GetLayer();
464 
465  // English layer names should never need quoting.
466  m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
467  }
468  else
469  m_out->Print( 0, " (layer %s)", m_out->Quotew( aItem->GetLayerName() ).c_str() );
470 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
PCB_LAYER_ID
A quick note on layer IDs:
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
#define CTL_STD_LAYER_NAMES
Use English Standard layer names.
#define TO_UTF8(wxstring)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:650

References CTL_STD_LAYER_NAMES, BOARD_ITEM::GetLayer(), BOARD_ITEM::GetLayerName(), BOARD::GetStandardLayerName(), m_ctl, m_out, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and TO_UTF8.

Referenced by format().

◆ formatLayers()

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

Definition at line 1080 of file kicad_plugin.cpp.

1081 {
1082  std::string output;
1083 
1084  if( aNestLevel == 0 )
1085  output += ' ';
1086 
1087  output += "(layers";
1088 
1089  static const LSET cu_all( LSET::AllCuMask() );
1090  static const LSET fr_bk( 2, B_Cu, F_Cu );
1091  static const LSET adhes( 2, B_Adhes, F_Adhes );
1092  static const LSET paste( 2, B_Paste, F_Paste );
1093  static const LSET silks( 2, B_SilkS, F_SilkS );
1094  static const LSET mask( 2, B_Mask, F_Mask );
1095  static const LSET crt_yd(2, B_CrtYd, F_CrtYd );
1096  static const LSET fab( 2, B_Fab, F_Fab );
1097 
1098  LSET cu_mask = cu_all;
1099 
1100  // output copper layers first, then non copper
1101 
1102  if( ( aLayerMask & cu_mask ) == cu_mask )
1103  {
1104  output += " *.Cu";
1105  aLayerMask &= ~cu_all; // clear bits, so they are not output again below
1106  }
1107  else if( ( aLayerMask & cu_mask ) == fr_bk )
1108  {
1109  output += " F&B.Cu";
1110  aLayerMask &= ~fr_bk;
1111  }
1112 
1113  if( ( aLayerMask & adhes ) == adhes )
1114  {
1115  output += " *.Adhes";
1116  aLayerMask &= ~adhes;
1117  }
1118 
1119  if( ( aLayerMask & paste ) == paste )
1120  {
1121  output += " *.Paste";
1122  aLayerMask &= ~paste;
1123  }
1124 
1125  if( ( aLayerMask & silks ) == silks )
1126  {
1127  output += " *.SilkS";
1128  aLayerMask &= ~silks;
1129  }
1130 
1131  if( ( aLayerMask & mask ) == mask )
1132  {
1133  output += " *.Mask";
1134  aLayerMask &= ~mask;
1135  }
1136 
1137  if( ( aLayerMask & crt_yd ) == crt_yd )
1138  {
1139  output += " *.CrtYd";
1140  aLayerMask &= ~crt_yd;
1141  }
1142 
1143  if( ( aLayerMask & fab ) == fab )
1144  {
1145  output += " *.Fab";
1146  aLayerMask &= ~fab;
1147  }
1148 
1149  // output any individual layers not handled in wildcard combos above
1150 
1151  wxString layerName;
1152 
1153  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
1154  {
1155  if( aLayerMask[layer] )
1156  {
1157  if( m_board && !( m_ctl & CTL_STD_LAYER_NAMES ) )
1158  layerName = m_board->GetLayerName( PCB_LAYER_ID( layer ) );
1159 
1160  else // I am being called from FootprintSave()
1161  layerName = BOARD::GetStandardLayerName( PCB_LAYER_ID( layer ) );
1162 
1163  output += ' ';
1164  output += m_out->Quotew( layerName );
1165  }
1166  }
1167 
1168  m_out->Print( aNestLevel, "%s)", output.c_str() );
1169 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
#define CTL_STD_LAYER_NAMES
Use English Standard layer names.
BOARD * m_board
which BOARD, no ownership here
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:650

References LSET::AllCuMask(), B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, CTL_STD_LAYER_NAMES, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, BOARD::GetLayerName(), BOARD::GetStandardLayerName(), m_board, m_ctl, m_out, PCB_LAYER_ID_COUNT, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by format().

◆ formatNetInformation()

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

formats the Nets and Netclasses

Definition at line 578 of file kicad_plugin.cpp.

579 {
580  for( NETINFO_ITEM* net : *m_mapping )
581  {
582  if( net == nullptr ) // Skip not actually existing nets (orphan nets)
583  continue;
584 
585  m_out->Print( aNestLevel, "(net %d %s)\n",
586  m_mapping->Translate( net->GetNet() ),
587  m_out->Quotew( net->GetNetname() ).c_str() );
588  }
589 
590  m_out->Print( 0, "\n" );
591 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
int Translate(int aNetCode) const
Function Translate Translates net number according to the map prepared by Update() function.

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

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

◆ formatSetup()

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

formats the board setup information

Definition at line 473 of file kicad_plugin.cpp.

474 {
475  // Setup
476  m_out->Print( aNestLevel, "(setup\n" );
477 
478  // Save the board physical stackup structure
480 
481  if( aBoard->GetDesignSettings().m_HasStackup )
482  stackup.FormatBoardStackup( m_out,aBoard, aNestLevel+1 );
483 
484  BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
485 
486  if( dsnSettings.m_AuxOrigin != wxPoint( 0, 0 ) )
487  m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
488  FormatInternalUnits( dsnSettings.m_AuxOrigin.x ).c_str(),
489  FormatInternalUnits( dsnSettings.m_AuxOrigin.y ).c_str() );
490 
491  if( dsnSettings.m_GridOrigin != wxPoint( 0, 0 ) )
492  m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
493  FormatInternalUnits( dsnSettings.m_GridOrigin.x ).c_str(),
494  FormatInternalUnits( dsnSettings.m_GridOrigin.y ).c_str() );
495 
496  aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
497 
498  m_out->Print( aNestLevel, ")\n\n" );
499 }
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, BOARD *aBoard, int aNestLevel) const
Writes the stackup info on board file.
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:577
wxPoint m_GridOrigin
origin for grid offsets
this class manage the layers needed to make a physical board they are solder mask,...
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
BOARD_STACKUP & GetStackupDescriptor()
bool m_HasStackup
Set to true if the board has a stackup management.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
wxPoint m_AuxOrigin
origin for plot exports
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References PCB_PLOT_PARAMS::Format(), BOARD_STACKUP::FormatBoardStackup(), FormatInternalUnits(), BOARD::GetDesignSettings(), BOARD::GetPlotOptions(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), BOARD_DESIGN_SETTINGS::m_AuxOrigin, BOARD_DESIGN_SETTINGS::m_GridOrigin, BOARD_DESIGN_SETTINGS::m_HasStackup, m_out, OUTPUTFORMATTER::Print(), wxPoint::x, and wxPoint::y.

Referenced by formatHeader().

◆ GetEnumeratedFootprint()

const MODULE * PCB_IO::GetEnumeratedFootprint ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.

Reimplemented from PLUGIN.

Definition at line 2075 of file kicad_plugin.cpp.

2078 {
2079  return getFootprint( aLibraryPath, aFootprintName, aProperties, false );
2080 }
const MODULE * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)

References getFootprint().

◆ GetFileExtension()

const wxString PCB_IO::GetFileExtension ( ) const
inlineoverridevirtual

Function GetFileExtension returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 121 of file pcbnew/kicad_plugin.h.

122  {
123  // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
124  // but to be pure, a plugin should not assume that it will always be linked
125  // with the core of the pcbnew code. (Might someday be a DLL/DSO.) Besides,
126  // file extension policy should be controlled by the plugin.
127  return wxT( "kicad_pcb" );
128  }

◆ getFootprint()

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

Definition at line 2046 of file kicad_plugin.cpp.

2050 {
2051  LOCALE_IO toggle; // toggles on, then off, the C locale.
2052 
2053  init( aProperties );
2054 
2055  try
2056  {
2057  validateCache( aLibraryPath, checkModified );
2058  }
2059  catch( const IO_ERROR& )
2060  {
2061  // do nothing with the error
2062  }
2063 
2064  const MODULE_MAP& mods = m_cache->GetModules();
2065 
2066  MODULE_CITER it = mods.find( aFootprintName );
2067 
2068  if( it == mods.end() )
2069  return nullptr;
2070 
2071  return it->second->GetModule();
2072 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
std::map< wxString, MODULE * > MODULE_MAP
Definition: eagle_parser.h:51
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
MODULE_MAP::const_iterator MODULE_CITER
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
MODULE_MAP & GetModules()

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

Referenced by FootprintLoad(), and GetEnumeratedFootprint().

◆ GetLibraryTimestamp()

long long PCB_IO::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 2231 of file kicad_plugin.cpp.

2232 {
2233  return FP_CACHE::GetTimestamp( aLibraryPath );
2234 }
static long long GetTimestamp(const wxString &aLibPath)
Function GetTimestamp Generate a timestamp representing all source files in the cache (including the ...

References FP_CACHE::GetTimestamp().

Referenced by GITHUB_PLUGIN::GetLibraryTimestamp().

◆ GetStringOutput()

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

Definition at line 181 of file pcbnew/kicad_plugin.h.

182  {
183  std::string ret = m_sf.GetString();
184  if( doClear )
185  m_sf.Clear();
186 
187  return ret;
188  }
const std::string & GetString()
Definition: richio.h:475
STRING_FORMATTER m_sf
void Clear()
Function Clear clears the buffer and empties the internal string.
Definition: richio.h:464

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

Referenced by FOOTPRINT_EDIT_FRAME::Export_Module().

◆ init()

void PCB_IO::init ( const PROPERTIES aProperties)
protected

Definition at line 1996 of file kicad_plugin.cpp.

1997 {
1998  m_board = NULL;
1999  m_reader = NULL;
2001  m_props = aProperties;
2002 }
LINE_READER * m_reader
no ownership here.
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define NULL
int m_loading_format_version
which SEXPR_BOARD_FILE_VERSION should be Load()ed?
BOARD * m_board
which BOARD, no ownership here

References m_board, m_loading_format_version, m_props, m_reader, NULL, and SEXPR_BOARD_FILE_VERSION.

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

◆ IsFootprintLibWritable()

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

Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable.

(Often system libraries are 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 2330 of file kicad_plugin.cpp.

2331 {
2332  LOCALE_IO toggle;
2333 
2334  init( NULL );
2335 
2336  validateCache( aLibraryPath );
2337 
2338  return m_cache->IsWritable();
2339 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
FP_CACHE * m_cache
Footprint library cache.
void init(const PROPERTIES *aProperties)
#define NULL
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
bool IsWritable() const

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

Referenced by GITHUB_PLUGIN::IsFootprintLibWritable().

◆ Load()

BOARD * PCB_IO::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function Load loads 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.
Returns
BOARD* - 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 1944 of file kicad_plugin.cpp.

1945 {
1946  FILE_LINE_READER reader( aFileName );
1947 
1948  BOARD* board = DoLoad( reader, aAppendToMe, aProperties );
1949 
1950  // Give the filename to the board if it's new
1951  if( !aAppendToMe )
1952  board->SetFileName( aFileName );
1953 
1954  return board;
1955 }
FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
void SetFileName(const wxString &aFileName)
Definition: class_board.h:253
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const PROPERTIES *aProperties)

References DoLoad(), and BOARD::SetFileName().

◆ Parse()

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

Definition at line 378 of file kicad_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 }
wxString GetRequiredVersion()
Return a string representing the version of kicad required to open this file.
Definition: pcb_parser.cpp:208
PCB_PARSER * m_parser
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:481
LINE_READER * SetLineReader(LINE_READER *aReader)
Function SetLineReader sets aLineReader into the parser, and returns the previous one,...
Definition: pcb_parser.h:337
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:365
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
#define TO_UTF8(wxstring)
Struct FUTURE_FORMAT_ERROR variant of PARSE_ERROR indicating that a syntax or related error was likel...
Definition: ki_exception.h:172
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254

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_module_kicad().

◆ PluginName()

const wxString PCB_IO::PluginName ( ) const
inlineoverridevirtual

Function PluginName returns a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 116 of file pcbnew/kicad_plugin.h.

117  {
118  return wxT( "KiCad" );
119  }

◆ PrefetchLib()

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

Function PrefetchLib 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.

Reimplemented in GITHUB_PLUGIN.

Definition at line 68 of file plugin.cpp.

69 {
70  (void) aLibraryPath;
71  (void) aProperties;
72 }

◆ Save()

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

Function Save will 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 354 of file kicad_plugin.cpp.

355 {
356  LOCALE_IO toggle; // toggles on, then off, the C locale.
357 
358  init( aProperties );
359 
360  m_board = aBoard; // after init()
361 
362  // Prepare net mapping that assures that net codes saved in a file are consecutive integers
363  m_mapping->SetBoard( aBoard );
364 
365  FILE_OUTPUTFORMATTER formatter( aFileName );
366 
367  m_out = &formatter; // no ownership
368 
369  m_out->Print( 0, "(kicad_pcb (version %d) (host pcbnew %s)\n", SEXPR_BOARD_FILE_VERSION,
370  formatter.Quotew( GetBuildVersion() ).c_str() );
371 
372  Format( aBoard, 1 );
373 
374  m_out->Print( 0, ")\n" );
375 }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
void init(const PROPERTIES *aProperties)
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
void SetBoard(const BOARD *aBoard)
Function SetBoard Sets a BOARD object that is used to prepare the net code map.
Definition: netinfo.h:296
wxString GetBuildVersion()
Get the full KiCad version string.
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
BOARD * m_board
which BOARD, no ownership here
FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
void Format(BOARD_ITEM *aItem, int aNestLevel=0) const
Function Format outputs aItem to aFormatter in s-expression format.

References Format(), GetBuildVersion(), init(), m_board, m_mapping, m_out, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), NETINFO_MAPPING::SetBoard(), and SEXPR_BOARD_FILE_VERSION.

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

◆ SetOutputFormatter()

void PCB_IO::SetOutputFormatter ( OUTPUTFORMATTER aFormatter)
inline

Definition at line 190 of file pcbnew/kicad_plugin.h.

190 { m_out = aFormatter; }
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership

References m_out.

Referenced by FP_CACHE::Save().

◆ validateCache()

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

Definition at line 2005 of file kicad_plugin.cpp.

2006 {
2007  if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) )
2008  {
2009  // a spectacular episode in memory management:
2010  delete m_cache;
2011  m_cache = new FP_CACHE( this, aLibraryPath );
2012  m_cache->Load();
2013  }
2014 }
friend class FP_CACHE
bool IsModified()
Function IsModified Return true if the cache is not up-to-date.
FP_CACHE * m_cache
Footprint library cache.
bool IsPath(const wxString &aPath) const
Function IsPath checks if aPath is the same as the current cache path.
void Load()

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 110 of file pcbnew/kicad_plugin.h.

Referenced by FootprintLibCreate(), and validateCache().

Member Data Documentation

◆ m_board

BOARD* PCB_IO::m_board
protected

◆ m_cache

◆ m_ctl

int PCB_IO::m_ctl
protected

◆ m_error

wxString PCB_IO::m_error
protected

for throwing exceptions

Definition at line 196 of file pcbnew/kicad_plugin.h.

◆ m_filename

wxString PCB_IO::m_filename
protected

for saves only, name is in m_reader for loads

Definition at line 204 of file pcbnew/kicad_plugin.h.

◆ m_loading_format_version

int PCB_IO::m_loading_format_version
protected

which SEXPR_BOARD_FILE_VERSION should be Load()ed?

Definition at line 206 of file pcbnew/kicad_plugin.h.

Referenced by init().

◆ m_mapping

NETINFO_MAPPING* PCB_IO::m_mapping
protected

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

Definition at line 212 of file pcbnew/kicad_plugin.h.

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

◆ m_out

◆ m_parser

PCB_PARSER* PCB_IO::m_parser
protected

◆ m_props

const PROPERTIES* PCB_IO::m_props
protected

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

Definition at line 200 of file pcbnew/kicad_plugin.h.

Referenced by init().

◆ m_reader

LINE_READER* PCB_IO::m_reader
protected

no ownership here.

Definition at line 203 of file pcbnew/kicad_plugin.h.

Referenced by init().

◆ m_sf

STRING_FORMATTER PCB_IO::m_sf
protected

Definition at line 208 of file pcbnew/kicad_plugin.h.

Referenced by GetStringOutput(), and PCB_IO().


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