KiCad PCB EDA Suite
LEGACY_PLUGIN Class Reference

LEGACY_PLUGIN is a PLUGIN derivation which could possibly be put into a DLL/DSO. More...

#include <legacy_plugin.h>

Inheritance diagram for LEGACY_PLUGIN:
PLUGIN

Public Types

typedef int BIU
 

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...
 
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...
 
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...
 
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...
 
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...
 
long long GetLibraryTimestamp (const wxString &aLibraryPath) const override
 Generate a timestamp representing all the files in the library (including the library directory). More...
 
bool IsFootprintLibWritable (const wxString &aLibraryPath) override
 Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable. More...
 
 LEGACY_PLUGIN ()
 
 ~LEGACY_PLUGIN ()
 
void SetReader (LINE_READER *aReader)
 
void SetFilePtr (FILE *aFile)
 
void SaveModule3D (const MODULE *aModule) const
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL)
 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...
 
virtual void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function PrefetchLib If possible, prefetches the specified library (e.g. More...
 
virtual const MODULEGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More...
 
virtual bool FootprintExists (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function FootprintExists check for the existence of a footprint. More...
 
virtual void FootprintSave (const wxString &aLibraryPath, const MODULE *aFootprint, const PROPERTIES *aProperties=NULL)
 Function FootprintSave will write aModule to an existing library located at aLibraryPath. More...
 
virtual void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function FootprintDelete deletes aFootprintName from the library at aLibraryPath. More...
 
virtual void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Static Public Member Functions

static PCB_LAYER_ID leg_layer2new (int cu_count, LAYER_NUM aLayerNum)
 
static LSET leg_mask2new (int cu_count, unsigned aMask)
 

Protected Member Functions

void init (const PROPERTIES *aProperties)
 initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. More...
 
int getNetCode (int aNetCode)
 

Converts net code using the mapping table if available, otherwise returns unchanged net code

More...
 
BIU biuParse (const char *aValue, const char **nptrptr=NULL)
 Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to the current value of diskToBui. More...
 
double degParse (const char *aValue, const char **nptrptr=NULL)
 Function degParse parses an ASCII decimal floating point value which is certainly an angle. More...
 
void checkVersion ()
 
void loadAllSections (bool doAppend)
 
void loadGENERAL ()
 
void loadSETUP ()
 
void loadSHEET ()
 
void load3D (MODULE *aModule)
 
void loadPAD (MODULE *aModule)
 
void loadMODULE_TEXT (FP_TEXT *aText)
 
void loadMODULE_EDGE (MODULE *aModule)
 
void loadPCB_LINE ()
 
void loadNETINFO_ITEM ()
 
void loadPCB_TEXT ()
 
void loadNETCLASS ()
 
void loadMODULE (MODULE *aModule)
 
void loadTrackList (int aStructType)
 Function loadTrackList reads a list of segments (Tracks and Vias, or Segzones) More...
 
void loadZONE_CONTAINER ()
 
void loadDIMENSION ()
 
void loadPCB_TARGET ()
 
void cacheLib (const wxString &aLibraryPath)
 we only cache one footprint library for now, this determines which one. More...
 

Protected Attributes

int m_cu_count
 
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...
 
LINE_READERm_reader
 no ownership here. More...
 
FILE * m_fp
 no ownership here. More...
 
wxString m_field
 reused to stuff MODULE fields. More...
 
int m_loading_format_version
 which BOARD_FORMAT_VERSION am I Load()ing? More...
 
LP_CACHEm_cache
 
bool m_showLegacyZoneWarning
 
NETINFO_MAPPINGm_mapping
 mapping for net codes, so only not empty nets are stored with consecutive integers as net codes More...
 
std::vector< int > m_netCodes
 net codes mapping for boards being loaded More...
 
double biuToDisk
 convert from BIUs to disk engineering units with this scale factor More...
 
double diskToBiu
 convert from disk engineering units to BIUs with this scale factor More...
 

Friends

struct LP_CACHE
 

Detailed Description

LEGACY_PLUGIN is a PLUGIN derivation which could possibly be put into a DLL/DSO.

As with any PLUGIN, there is no UI, i.e. windowing calls allowed.

Definition at line 61 of file legacy_plugin.h.

Member Typedef Documentation

◆ BIU

typedef int LEGACY_PLUGIN::BIU

Definition at line 97 of file legacy_plugin.h.

Constructor & Destructor Documentation

◆ LEGACY_PLUGIN()

LEGACY_PLUGIN::LEGACY_PLUGIN ( )

Definition at line 3441 of file legacy_plugin.cpp.

3441  :
3442  m_cu_count( 16 ), // for FootprintLoad()
3443  m_board( nullptr ),
3444  m_props( nullptr ),
3445  m_reader( nullptr ),
3446  m_fp( nullptr ),
3447  m_cache( nullptr ),
3448  m_mapping( new NETINFO_MAPPING() )
3449 {
3450  init( NULL );
3451 }
FILE * m_fp
no ownership here.
LINE_READER * m_reader
no ownership here.
#define NULL
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
BOARD * m_board
which BOARD, no ownership here
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty nets are stored with consecutive integers as net codes
LP_CACHE * m_cache
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.

References init(), and NULL.

◆ ~LEGACY_PLUGIN()

LEGACY_PLUGIN::~LEGACY_PLUGIN ( )

Definition at line 3454 of file legacy_plugin.cpp.

3455 {
3456  delete m_cache;
3457  delete m_mapping;
3458 }
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty nets are stored with consecutive integers as net codes
LP_CACHE * m_cache

References m_cache, and m_mapping.

Member Function Documentation

◆ biuParse()

BIU LEGACY_PLUGIN::biuParse ( const char *  aValue,
const char **  nptrptr = NULL 
)
protected

Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to the current value of diskToBui.

This fuction is the complement of fmtBIU(). One has to know what the other is doing.

Parameters
aValueis the ASCII value in C locale form with possible leading whitespace
nptrptrmay be NULL, but if not, then it tells where to put a pointer to the next unconsumed input text. See "man strtod" for more information.
Returns
BIU - the converted Board Internal Unit.

Definition at line 2931 of file legacy_plugin.cpp.

2932 {
2933  char* nptr;
2934 
2935  errno = 0;
2936 
2937  double fval = strtod( aValue, &nptr );
2938 
2939  if( errno )
2940  {
2941  m_error.Printf( _( "invalid float number in file: \"%s\"\nline: %d, offset: %d" ),
2942  m_reader->GetSource().GetData(),
2943  m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
2944 
2946  }
2947 
2948  if( aValue == nptr )
2949  {
2950  m_error.Printf( _( "missing float number in file: \"%s\"\nline: %d, offset: %d" ),
2951  m_reader->GetSource().GetData(),
2952  m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
2953 
2955  }
2956 
2957  if( nptrptr )
2958  *nptrptr = nptr;
2959 
2960  fval *= diskToBiu;
2961 
2962  // fval is up into the whole number realm here, and should be bounded
2963  // within INT_MIN to INT_MAX since BIU's are nanometers.
2964  return KiROUND( fval );
2965 }
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:160
double diskToBiu
convert from disk engineering units to BIUs with this scale factor
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, diskToBiu, LINE_READER::GetSource(), KiROUND(), LINE_READER::Line(), LINE_READER::LineNumber(), m_error, m_reader, and THROW_IO_ERROR.

Referenced by loadDIMENSION(), loadGENERAL(), loadMODULE(), loadMODULE_EDGE(), loadMODULE_TEXT(), loadNETCLASS(), loadPAD(), loadPCB_LINE(), loadPCB_TARGET(), loadPCB_TEXT(), loadSETUP(), loadTrackList(), and loadZONE_CONTAINER().

◆ cacheLib()

void LEGACY_PLUGIN::cacheLib ( const wxString &  aLibraryPath)
protected

we only cache one footprint library for now, this determines which one.

Definition at line 3331 of file legacy_plugin.cpp.

3332 {
3333  if( !m_cache || m_cache->m_lib_path != aLibraryPath || m_cache->IsModified() )
3334  {
3335  // a spectacular episode in memory management:
3336  delete m_cache;
3337  m_cache = new LP_CACHE( this, aLibraryPath );
3338  m_cache->Load();
3339  }
3340 }
friend struct LP_CACHE
Definition: legacy_plugin.h:63
bool IsModified()
wxString m_lib_path
LP_CACHE * m_cache

References LP_CACHE::IsModified(), LP_CACHE::Load(), LP_CACHE, m_cache, and LP_CACHE::m_lib_path.

Referenced by FootprintEnumerate(), FootprintLoad(), and IsFootprintLibWritable().

◆ checkVersion()

void LEGACY_PLUGIN::checkVersion ( )
protected

Definition at line 536 of file legacy_plugin.cpp.

537 {
538  // Read first line and TEST if it is a PCB file format header like this:
539  // "PCBNEW-BOARD Version 1 ...."
540 
541  m_reader->ReadLine();
542 
543  char* line = m_reader->Line();
544 
545  if( !TESTLINE( "PCBNEW-BOARD" ) )
546  {
547  THROW_IO_ERROR( "Unknown file type" );
548  }
549 
550  int ver = 1; // if sccanf fails
551  sscanf( line, "PCBNEW-BOARD Version %d", &ver );
552 
553 #if !defined(DEBUG)
554  if( ver > LEGACY_BOARD_FILE_VERSION )
555  {
556  // "File \"%s\" is format version: %d.\nI only support format version <= %d.\nPlease upgrade Pcbnew to load this file."
558  m_reader->GetSource().GetData(), ver, LEGACY_BOARD_FILE_VERSION );
560  }
561 #endif
562 
565 }
void SetFileFormatVersionAtLoad(int aVersion)
Definition: class_board.h:336
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
int m_loading_format_version
which BOARD_FORMAT_VERSION am I Load()ing?
LINE_READER * m_reader
no ownership here.
BOARD * m_board
which BOARD, no ownership here
virtual char * ReadLine()=0
Function ReadLine reads a line of text into the buffer and increments the line number counter.
#define VERSION_ERROR_FORMAT
wxString m_error
for throwing exceptions
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References LINE_READER::GetSource(), LINE_READER::Line(), m_board, m_error, m_loading_format_version, m_reader, LINE_READER::ReadLine(), BOARD::SetFileFormatVersionAtLoad(), TESTLINE, THROW_IO_ERROR, and VERSION_ERROR_FORMAT.

Referenced by Load().

◆ degParse()

double LEGACY_PLUGIN::degParse ( const char *  aValue,
const char **  nptrptr = NULL 
)
protected

Function degParse parses an ASCII decimal floating point value which is certainly an angle.

This is a dedicated function for encapsulating support for the migration from tenths of degrees to degrees in floating point. This function is the complement of fmtDEG(). One has to know what the other is doing.

Parameters
aValueis the ASCII value in C locale form with possible leading whitespace
nptrptrmay be NULL, but if not, then it tells where to put a pointer to the next unconsumed input text. See "man strtod" for more information.
Returns
double - the string converted to a primitive double type

Definition at line 2968 of file legacy_plugin.cpp.

2969 {
2970  char* nptr;
2971 
2972  errno = 0;
2973 
2974  double fval = strtod( aValue, &nptr );
2975 
2976  if( errno )
2977  {
2978  m_error.Printf( _( "invalid float number in file: \"%s\"\nline: %d, offset: %d" ),
2979  m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
2980 
2982  }
2983 
2984  if( aValue == nptr )
2985  {
2986  m_error.Printf( _( "missing float number in file: \"%s\"\nline: %d, offset: %d" ),
2987  m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
2988 
2990  }
2991 
2992  if( nptrptr )
2993  *nptrptr = nptr;
2994 
2995  return fval;
2996 }
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:160
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, LINE_READER::GetSource(), LINE_READER::Line(), LINE_READER::LineNumber(), m_error, m_reader, and THROW_IO_ERROR.

Referenced by loadDIMENSION(), loadMODULE_EDGE(), loadMODULE_TEXT(), loadPAD(), loadPCB_LINE(), and loadPCB_TEXT().

◆ FootprintDelete()

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

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 in PCB_IO, and GPCB_PLUGIN.

Definition at line 110 of file plugin.cpp.

112 {
113  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
114  not_implemented( this, __FUNCTION__ );
115 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:39

References not_implemented().

◆ FootprintEnumerate()

void LEGACY_PLUGIN::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 3343 of file legacy_plugin.cpp.

3345 {
3346  LOCALE_IO toggle; // toggles on, then off, the C locale.
3347  wxString errorMsg;
3348 
3349  init( aProperties );
3350 
3351  try
3352  {
3353  cacheLib( aLibPath );
3354  }
3355  catch( const IO_ERROR& ioe )
3356  {
3357  errorMsg = ioe.What();
3358  }
3359 
3360  // Some of the files may have been parsed correctly so we want to add the valid files to
3361  // the library.
3362 
3363  for( MODULE_CITER it = m_cache->m_modules.begin(); it != m_cache->m_modules.end(); ++it )
3364  aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
3365 
3366  if( !errorMsg.IsEmpty() && !aBestEfforts )
3367  THROW_IO_ERROR( errorMsg );
3368 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
void cacheLib(const wxString &aLibraryPath)
we only cache one footprint library for now, this determines which one.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
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
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
MODULE_MAP m_modules
LP_CACHE * m_cache

References cacheLib(), FROM_UTF8(), init(), m_cache, LP_CACHE::m_modules, THROW_IO_ERROR, and IO_ERROR::What().

◆ FootprintExists()

bool PLUGIN::FootprintExists ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintExists check for the existence of a footprint.

Reimplemented in PCB_IO.

Definition at line 85 of file plugin.cpp.

87 {
88  // default implementation
89  return FootprintLoad( aLibraryPath, aFootprintName, aProperties ) != nullptr;
90 }
virtual MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
Definition: plugin.cpp:93

References PLUGIN::FootprintLoad().

◆ FootprintLibCreate()

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

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 in PCB_IO.

Definition at line 118 of file plugin.cpp.

119 {
120  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
121  not_implemented( this, __FUNCTION__ );
122 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:39

References not_implemented().

◆ FootprintLibDelete()

bool LEGACY_PLUGIN::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 3399 of file legacy_plugin.cpp.

3400 {
3401  wxFileName fn = aLibraryPath;
3402 
3403  if( !fn.FileExists() )
3404  return false;
3405 
3406  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
3407  // we don't want that. we want bare metal portability with no UI here.
3408  if( wxRemove( aLibraryPath ) )
3409  {
3411  _( "library \"%s\" cannot be deleted" ),
3412  aLibraryPath.GetData() ) );
3413  }
3414 
3415  if( m_cache && m_cache->m_lib_path == aLibraryPath )
3416  {
3417  delete m_cache;
3418  m_cache = 0;
3419  }
3420 
3421  return true;
3422 }
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:201
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_lib_path
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
LP_CACHE * m_cache

References _, Format(), m_cache, LP_CACHE::m_lib_path, and THROW_IO_ERROR.

◆ 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 EAGLE_PLUGIN.

Definition at line 141 of file plugin.cpp.

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

◆ FootprintLoad()

MODULE * LEGACY_PLUGIN::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 3371 of file legacy_plugin.cpp.

3373 {
3374  LOCALE_IO toggle; // toggles on, then off, the C locale.
3375 
3376  init( aProperties );
3377 
3378  cacheLib( aLibraryPath );
3379 
3380  const MODULE_MAP& mods = m_cache->m_modules;
3381 
3382  MODULE_CITER it = mods.find( TO_UTF8( aFootprintName ) );
3383 
3384  if( it == mods.end() )
3385  {
3386  /*
3387  THROW_IO_ERROR( wxString::Format( _( "No \"%s\" footprint in library \"%s\"" ),
3388  aFootprintName.GetData(), aLibraryPath.GetData() ) );
3389  */
3390 
3391  return NULL;
3392  }
3393 
3394  // Return copy of already loaded MODULE
3395  return (MODULE*) it->second->Duplicate();
3396 }
void cacheLib(const wxString &aLibraryPath)
we only cache one footprint library for now, this determines which one.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
std::map< wxString, MODULE * > MODULE_MAP
Definition: eagle_parser.h:51
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:95
#define NULL
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
MODULE_MAP::const_iterator MODULE_CITER
MODULE_MAP m_modules
LP_CACHE * m_cache

References cacheLib(), init(), m_cache, LP_CACHE::m_modules, NULL, and TO_UTF8.

◆ FootprintSave()

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

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 in PCB_IO.

Definition at line 102 of file plugin.cpp.

104 {
105  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
106  not_implemented( this, __FUNCTION__ );
107 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:39

References not_implemented().

◆ GetEnumeratedFootprint()

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

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

Reimplemented in PCB_IO, and GPCB_PLUGIN.

Definition at line 76 of file plugin.cpp.

79 {
80  // default implementation
81  return FootprintLoad( aLibraryPath, aFootprintName, aProperties );
82 }
virtual MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
Definition: plugin.cpp:93

References PLUGIN::FootprintLoad().

◆ GetFileExtension()

const wxString LEGACY_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Function GetFileExtension returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 74 of file legacy_plugin.h.

75  {
76  return wxT( "brd" );
77  }

◆ GetLibraryTimestamp()

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

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

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

Implements PLUGIN.

Definition at line 3325 of file legacy_plugin.cpp.

3326 {
3327  return LP_CACHE::GetTimestamp( aLibraryPath );
3328 }
static long long GetTimestamp(const wxString &aLibPath)

References LP_CACHE::GetTimestamp().

◆ getNetCode()

int LEGACY_PLUGIN::getNetCode ( int  aNetCode)
inlineprotected

Converts net code using the mapping table if available, otherwise returns unchanged net code

Definition at line 143 of file legacy_plugin.h.

144  {
145  if( (unsigned int) aNetCode < m_netCodes.size() )
146  return m_netCodes[aNetCode];
147 
148  return aNetCode;
149  }
std::vector< int > m_netCodes
net codes mapping for boards being loaded

References m_netCodes.

Referenced by loadPAD(), loadTrackList(), and loadZONE_CONTAINER().

◆ init()

void LEGACY_PLUGIN::init ( const PROPERTIES aProperties)
protected

initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.

Definition at line 2999 of file legacy_plugin.cpp.

3000 {
3002  m_cu_count = 16;
3003  m_board = NULL;
3004  m_showLegacyZoneWarning = true;
3005  m_props = aProperties;
3006 
3007  // conversion factor for saving RAM BIUs to KICAD legacy file format.
3008  biuToDisk = 1.0/IU_PER_MM; // BIUs are nanometers & file is mm
3009 
3010  // Conversion factor for loading KICAD legacy file format into BIUs in RAM
3011  // Start by assuming the *.brd file is in deci-mils.
3012  // If we see "Units mm" in the $GENERAL section, set diskToBiu to 1000000.0
3013  // then, during the file loading process, to start a conversion from
3014  // mm to nanometers. The deci-mil legacy files have no such "Units" marker
3015  // so we must assume the file is in deci-mils until told otherwise.
3016 
3017  diskToBiu = IU_PER_MILS / 10; // BIUs are nanometers
3018 }
bool m_showLegacyZoneWarning
static constexpr double IU_PER_MM
Mock up a conversion function.
int m_loading_format_version
which BOARD_FORMAT_VERSION am I Load()ing?
double biuToDisk
convert from BIUs to disk engineering units with this scale factor
#define NULL
double diskToBiu
convert from disk engineering units to BIUs with this scale factor
BOARD * m_board
which BOARD, no ownership here
#define IU_PER_MILS
Definition: plotter.cpp:137
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.

References biuToDisk, diskToBiu, IU_PER_MILS, IU_PER_MM, m_board, m_cu_count, m_loading_format_version, m_props, m_showLegacyZoneWarning, and NULL.

Referenced by FootprintEnumerate(), FootprintLoad(), IsFootprintLibWritable(), LEGACY_PLUGIN(), and Load().

◆ IsFootprintLibWritable()

bool LEGACY_PLUGIN::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 3425 of file legacy_plugin.cpp.

3426 {
3427 #if 0 // no support for 32 Cu layers in legacy format
3428  return false;
3429 #else
3430  LOCALE_IO toggle;
3431 
3432  init( NULL );
3433 
3434  cacheLib( aLibraryPath );
3435 
3436  return m_cache->m_writable;
3437 #endif
3438 }
void cacheLib(const wxString &aLibraryPath)
we only cache one footprint library for now, this determines which one.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
#define NULL
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
LP_CACHE * m_cache

References cacheLib(), init(), m_cache, LP_CACHE::m_writable, and NULL.

◆ leg_layer2new()

PCB_LAYER_ID LEGACY_PLUGIN::leg_layer2new ( int  cu_count,
LAYER_NUM  aLayerNum 
)
static

Definition at line 282 of file legacy_plugin.cpp.

283 {
284  int newid;
285  unsigned old = aLayerNum;
286 
287  // this is a speed critical function, be careful.
288 
289  if( unsigned( old ) <= unsigned( LAYER_N_FRONT ) )
290  {
291  // In .brd files, the layers are numbered from back to front
292  // (the opposite of the .kicad_pcb files)
293  if( old == LAYER_N_FRONT )
294  newid = F_Cu;
295  else if( old == LAYER_N_BACK )
296  newid = B_Cu;
297  else
298  {
299  newid = cu_count - 1 - old;
300  wxASSERT( newid >= 0 );
301  // This is of course incorrect, but at least it avoid crashing pcbnew:
302  if( newid < 0 )
303  newid = 0;
304  }
305  }
306  else
307  {
308  switch( old )
309  {
310  case ADHESIVE_N_BACK: newid = B_Adhes; break;
311  case ADHESIVE_N_FRONT: newid = F_Adhes; break;
312  case SOLDERPASTE_N_BACK: newid = B_Paste; break;
313  case SOLDERPASTE_N_FRONT: newid = F_Paste; break;
314  case SILKSCREEN_N_BACK: newid = B_SilkS; break;
315  case SILKSCREEN_N_FRONT: newid = F_SilkS; break;
316  case SOLDERMASK_N_BACK: newid = B_Mask; break;
317  case SOLDERMASK_N_FRONT: newid = F_Mask; break;
318  case DRAW_N: newid = Dwgs_User; break;
319  case COMMENT_N: newid = Cmts_User; break;
320  case ECO1_N: newid = Eco1_User; break;
321  case ECO2_N: newid = Eco2_User; break;
322  case EDGE_N: newid = Edge_Cuts; break;
323  default:
324 // wxASSERT( 0 );
325  // Remap all illegal non copper layers to comment layer
326  newid = Cmts_User;
327  }
328  }
329 
330  return PCB_LAYER_ID( newid );
331 }
#define SILKSCREEN_N_BACK
#define LAYER_N_BACK
#define COMMENT_N
#define EDGE_N
#define ADHESIVE_N_FRONT
#define SOLDERMASK_N_FRONT
#define ECO2_N
#define SOLDERMASK_N_BACK
#define ADHESIVE_N_BACK
#define SILKSCREEN_N_FRONT
PCB_LAYER_ID
A quick note on layer IDs:
#define ECO1_N
#define LAYER_N_FRONT
#define SOLDERPASTE_N_FRONT
#define DRAW_N
#define SOLDERPASTE_N_BACK

References ADHESIVE_N_BACK, ADHESIVE_N_FRONT, B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, COMMENT_N, DRAW_N, Dwgs_User, ECO1_N, Eco1_User, ECO2_N, Eco2_User, Edge_Cuts, EDGE_N, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, LAYER_N_BACK, LAYER_N_FRONT, SILKSCREEN_N_BACK, SILKSCREEN_N_FRONT, SOLDERMASK_N_BACK, SOLDERMASK_N_FRONT, SOLDERPASTE_N_BACK, and SOLDERPASTE_N_FRONT.

Referenced by leg_mask2new(), loadDIMENSION(), loadMODULE(), loadMODULE_EDGE(), loadMODULE_TEXT(), loadPCB_LINE(), loadPCB_TARGET(), loadPCB_TEXT(), loadSETUP(), loadTrackList(), and loadZONE_CONTAINER().

◆ leg_mask2new()

LSET LEGACY_PLUGIN::leg_mask2new ( int  cu_count,
unsigned  aMask 
)
static

Definition at line 334 of file legacy_plugin.cpp.

335 {
336  LSET ret;
337 
338  if( ( aMask & ALL_CU_LAYERS ) == ALL_CU_LAYERS )
339  {
340  ret = LSET::AllCuMask();
341 
342  aMask &= ~ALL_CU_LAYERS;
343  }
344 
345  for( int i=0; aMask; ++i, aMask >>= 1 )
346  {
347  if( aMask & 1 )
348  ret.set( leg_layer2new( cu_count, i ) );
349  }
350 
351  return ret;
352 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:749
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
LSET is a set of PCB_LAYER_IDs.
#define ALL_CU_LAYERS

References ALL_CU_LAYERS, LSET::AllCuMask(), and leg_layer2new().

Referenced by loadGENERAL(), and loadPAD().

◆ Load()

BOARD * LEGACY_PLUGIN::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 391 of file legacy_plugin.cpp.

393 {
394  LOCALE_IO toggle; // toggles on, then off, the C locale.
395 
396  init( aProperties );
397 
398  m_board = aAppendToMe ? aAppendToMe : new BOARD();
399 
400  // Give the filename to the board if it's new
401  if( !aAppendToMe )
402  m_board->SetFileName( aFileName );
403 
404  // delete on exception, iff I own m_board, according to aAppendToMe
405  std::unique_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
406 
407  FILE_LINE_READER reader( aFileName );
408 
409  m_reader = &reader; // member function accessibility
410 
411  checkVersion();
412 
413  loadAllSections( bool( aAppendToMe ) );
414 
415  deleter.release();
416  return m_board;
417 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
LINE_READER * m_reader
no ownership here.
FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:181
#define NULL
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void SetFileName(const wxString &aFileName)
Definition: class_board.h:277
BOARD * m_board
which BOARD, no ownership here
void loadAllSections(bool doAppend)
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:186

References checkVersion(), init(), loadAllSections(), m_board, m_reader, NULL, and BOARD::SetFileName().

◆ load3D()

void LEGACY_PLUGIN::load3D ( MODULE aModule)
protected

Definition at line 1862 of file legacy_plugin.cpp.

1863 {
1864  MODULE_3D_SETTINGS t3D;
1865 
1866  char* line;
1867  while( ( line = READLINE( m_reader ) ) != NULL )
1868  {
1869  if( TESTLINE( "Na" ) ) // Shape File Name
1870  {
1871  char buf[512];
1872  ReadDelimitedText( buf, line + SZ( "Na" ), sizeof(buf) );
1873  t3D.m_Filename = buf;
1874  }
1875 
1876  else if( TESTLINE( "Sc" ) ) // Scale
1877  {
1878  sscanf( line + SZ( "Sc" ), "%lf %lf %lf\n",
1879  &t3D.m_Scale.x,
1880  &t3D.m_Scale.y,
1881  &t3D.m_Scale.z );
1882  }
1883 
1884  else if( TESTLINE( "Of" ) ) // Offset
1885  {
1886  sscanf( line + SZ( "Of" ), "%lf %lf %lf\n",
1887  &t3D.m_Offset.x,
1888  &t3D.m_Offset.y,
1889  &t3D.m_Offset.z );
1890  }
1891 
1892  else if( TESTLINE( "Ro" ) ) // Rotation
1893  {
1894  sscanf( line + SZ( "Ro" ), "%lf %lf %lf\n",
1895  &t3D.m_Rotation.x,
1896  &t3D.m_Rotation.y,
1897  &t3D.m_Rotation.z );
1898  }
1899 
1900  else if( TESTLINE( "$EndSHAPE3D" ) )
1901  {
1902  aModule->Models().push_back( t3D );
1903  return; // preferred exit
1904  }
1905  }
1906 
1907  THROW_IO_ERROR( "Missing '$EndSHAPE3D'" );
1908 }
#define READLINE(rdr)
VECTOR3D m_Offset
3D model offset (mm)
Definition: class_module.h:95
LINE_READER * m_reader
no ownership here.
#define NULL
wxString m_Filename
The 3D shape filename in 3D library.
Definition: class_module.h:97
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:196
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: class_module.h:94
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: class_module.h:93
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References MODULE_3D_SETTINGS::m_Filename, MODULE_3D_SETTINGS::m_Offset, m_reader, MODULE_3D_SETTINGS::m_Rotation, MODULE_3D_SETTINGS::m_Scale, MODULE::Models(), NULL, ReadDelimitedText(), READLINE, SZ, TESTLINE, THROW_IO_ERROR, MODULE_3D_SETTINGS::VECTOR3D::x, MODULE_3D_SETTINGS::VECTOR3D::y, and MODULE_3D_SETTINGS::VECTOR3D::z.

Referenced by loadMODULE().

◆ loadAllSections()

void LEGACY_PLUGIN::loadAllSections ( bool  doAppend)
protected

Definition at line 420 of file legacy_plugin.cpp.

421 {
422  // $GENERAL section is first
423 
424  // $SHEETDESCR section is next
425 
426  // $SETUP section is next
427 
428  // Then follows $EQUIPOT and all the rest
429  char* line;
430 
431  while( ( line = READLINE( m_reader ) ) != NULL )
432  {
433  // put the more frequent ones at the top, but realize TRACKs are loaded as a group
434 
435  if( TESTLINE( "$MODULE" ) )
436  {
437  std::unique_ptr<MODULE> module = std::make_unique<MODULE>( m_board );
438 
439  LIB_ID fpid;
440  std::string fpName = StrPurge( line + SZ( "$MODULE" ) );
441 
442  // The footprint names in legacy libraries can contain the '/' and ':'
443  // characters which will cause the FPID parser to choke.
444  ReplaceIllegalFileNameChars( &fpName );
445 
446  if( !fpName.empty() )
447  fpid.Parse( fpName, LIB_ID::ID_PCB, true );
448 
449  module->SetFPID( fpid );
450 
451  loadMODULE( module.get() );
452  m_board->Add( module.release(), ADD_MODE::APPEND );
453  }
454 
455  else if( TESTLINE( "$DRAWSEGMENT" ) )
456  {
457  loadPCB_LINE();
458  }
459 
460  else if( TESTLINE( "$EQUIPOT" ) )
461  {
463  }
464 
465  else if( TESTLINE( "$TEXTPCB" ) )
466  {
467  loadPCB_TEXT();
468  }
469 
470  else if( TESTLINE( "$TRACK" ) )
471  {
473  }
474 
475  else if( TESTLINE( "$NCLASS" ) )
476  {
477  loadNETCLASS();
478  }
479 
480  else if( TESTLINE( "$CZONE_OUTLINE" ) )
481  {
483  }
484 
485  else if( TESTLINE( "$COTATION" ) )
486  {
487  loadDIMENSION();
488  }
489 
490  else if( TESTLINE( "$PCB_TARGET" ) || TESTLINE( "$MIREPCB" ) )
491  {
492  loadPCB_TARGET();
493  }
494 
495  else if( TESTLINE( "$ZONE" ) )
496  {
497  // No longer supported; discard segment fills
499  }
500 
501  else if( TESTLINE( "$GENERAL" ) )
502  {
503  loadGENERAL();
504  }
505 
506  else if( TESTLINE( "$SHEETDESCR" ) )
507  {
508  loadSHEET();
509  }
510 
511  else if( TESTLINE( "$SETUP" ) )
512  {
513  if( !doAppend )
514  {
515  loadSETUP();
516  }
517  else
518  {
519  while( ( line = READLINE( m_reader ) ) != NULL )
520  {
521  // gobble until $EndSetup
522  if( TESTLINE( "$EndSETUP" ) )
523  break;
524  }
525  }
526  }
527 
528  else if( TESTLINE( "$EndBOARD" ) )
529  return; // preferred exit
530  }
531 
532  THROW_IO_ERROR( "Missing '$EndBOARD'" );
533 }
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
Definition: string.cpp:365
the 3d code uses this value
Definition: typeinfo.h:80
void loadMODULE(MODULE *aModule)
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
Definition: string.cpp:735
#define READLINE(rdr)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
LINE_READER * m_reader
no ownership here.
#define NULL
BOARD * m_board
which BOARD, no ownership here
void loadZONE_CONTAINER()
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
void loadTrackList(int aStructType)
Function loadTrackList reads a list of segments (Tracks and Vias, or Segzones)

References BOARD::Add(), APPEND, LIB_ID::ID_PCB, loadDIMENSION(), loadGENERAL(), loadMODULE(), loadNETCLASS(), loadNETINFO_ITEM(), loadPCB_LINE(), loadPCB_TARGET(), loadPCB_TEXT(), loadSETUP(), loadSHEET(), loadTrackList(), loadZONE_CONTAINER(), m_board, m_reader, NOT_USED, NULL, LIB_ID::Parse(), PCB_TRACE_T, READLINE, ReplaceIllegalFileNameChars(), StrPurge(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by Load().

◆ loadDIMENSION()

void LEGACY_PLUGIN::loadDIMENSION ( )
protected

Definition at line 2729 of file legacy_plugin.cpp.

2730 {
2731  std::unique_ptr<ALIGNED_DIMENSION> dim = std::make_unique<ALIGNED_DIMENSION>( m_board );
2732 
2733  char* line;
2734 
2735  while( ( line = READLINE( m_reader ) ) != NULL )
2736  {
2737  const char* data;
2738 
2739  if( TESTLINE( "$endCOTATION" ) )
2740  {
2741  m_board->Add( dim.release(), ADD_MODE::APPEND );
2742  return; // preferred exit
2743  }
2744 
2745  else if( TESTLINE( "Va" ) )
2746  {
2747  BIU value = biuParse( line + SZ( "Va" ) );
2748  // unused; dimension value is calculated from coordinates
2749  ( void )value;
2750  }
2751 
2752  else if( TESTLINE( "Ge" ) )
2753  {
2754  // e.g. "Ge 1 21 68183921-93a5-49ac-91b0-49d05a0e1647\r\n"
2755  int shape = intParse( line + SZ( "De" ), (const char**) &data );
2756  LAYER_NUM layer_num = layerParse( data, &data );
2757  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2758 
2759  dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2760  const_cast<KIID&>( dim->m_Uuid ) = KIID( uuid );
2761  // not used
2762  ( void )shape;
2763  }
2764 
2765  else if( TESTLINE( "Te" ) )
2766  {
2767  char buf[2048];
2768 
2769  ReadDelimitedText( buf, line + SZ( "Te" ), sizeof(buf) );
2770  dim->SetText( FROM_UTF8( buf ) );
2771  }
2772 
2773  else if( TESTLINE( "Po" ) )
2774  {
2775  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
2776  BIU pos_y = biuParse( data, &data );
2777  BIU width = biuParse( data, &data );
2778  BIU height = biuParse( data, &data );
2779  BIU thickn = biuParse( data, &data );
2780  double orient = degParse( data, &data );
2781  char* mirror = strtok_r( (char*) data, delims, (char**) &data );
2782 
2783  // This sets both DIMENSION's position and internal m_Text's.
2784  // @todo: But why do we even know about internal m_Text?
2785  dim->SetPosition( wxPoint( pos_x, pos_y ) );
2786  dim->SetTextSize( wxSize( width, height ) );
2787 
2788  dim->Text().SetMirrored( mirror && *mirror == '0' );
2789  dim->Text().SetTextThickness( thickn );
2790  dim->Text().SetTextAngle( orient );
2791  }
2792 
2793  else if( TESTLINE( "Sb" ) )
2794  {
2795  int ignore = biuParse( line + SZ( "Sb" ), &data );
2796  BIU crossBarOx = biuParse( data, &data );
2797  BIU crossBarOy = biuParse( data, &data );
2798  BIU crossBarFx = biuParse( data, &data );
2799  BIU crossBarFy = biuParse( data, &data );
2800  BIU width = biuParse( data );
2801 
2802  dim->SetLineThickness( width );
2803  dim->UpdateHeight( wxPoint( crossBarFx, crossBarFy ),
2804  wxPoint( crossBarOx, crossBarOy ) );
2805  (void) ignore;
2806  }
2807 
2808  else if( TESTLINE( "Sd" ) )
2809  {
2810  int ignore = intParse( line + SZ( "Sd" ), &data );
2811  BIU featureLineDOx = biuParse( data, &data );
2812  BIU featureLineDOy = biuParse( data, &data );
2813  BIU featureLineDFx = biuParse( data, &data );
2814  BIU featureLineDFy = biuParse( data );
2815 
2816  dim->SetStart( wxPoint( featureLineDOx, featureLineDOy ) );
2817  ( void )ignore;
2818  ( void )featureLineDFx;
2819  ( void )featureLineDFy;
2820  }
2821 
2822  else if( TESTLINE( "Sg" ) )
2823  {
2824  int ignore = intParse( line + SZ( "Sg" ), &data );
2825  BIU featureLineGOx = biuParse( data, &data );
2826  BIU featureLineGOy = biuParse( data, &data );
2827  BIU featureLineGFx = biuParse( data, &data );
2828  BIU featureLineGFy = biuParse( data );
2829 
2830  (void) ignore;
2831  dim->SetEnd( wxPoint( featureLineGOx, featureLineGOy ) );
2832  ( void )ignore;
2833  ( void )featureLineGFx;
2834  ( void )featureLineGFy;
2835  }
2836 
2837  // Arrow: no longer imported
2838  else if( TESTLINE( "S1" ) )
2839  {
2840  int ignore = intParse( line + SZ( "S1" ), &data );
2841  biuParse( data, &data ); // skipping excessive data
2842  biuParse( data, &data ); // skipping excessive data
2843  biuParse( data, &data );
2844  biuParse( data );
2845 
2846  (void) ignore;
2847  }
2848 
2849  // Arrow: no longer imported
2850  else if( TESTLINE( "S2" ) )
2851  {
2852  int ignore = intParse( line + SZ( "S2" ), &data );
2853  biuParse( data, &data ); // skipping excessive data
2854  biuParse( data, &data ); // skipping excessive data
2855  biuParse( data, &data );
2856  biuParse( data, &data );
2857 
2858  (void) ignore;
2859  }
2860 
2861  // Arrow: no longer imported
2862  else if( TESTLINE( "S3" ) )
2863  {
2864  int ignore = intParse( line + SZ( "S3" ), &data );
2865  biuParse( data, &data ); // skipping excessive data
2866  biuParse( data, &data ); // skipping excessive data
2867  biuParse( data, &data );
2868  biuParse( data, &data );
2869 
2870  (void) ignore;
2871  }
2872 
2873  // Arrow: no longer imported
2874  else if( TESTLINE( "S4" ) )
2875  {
2876  int ignore = intParse( line + SZ( "S4" ), &data );
2877  biuParse( data, &data ); // skipping excessive data
2878  biuParse( data, &data ); // skipping excessive data
2879  biuParse( data, &data );
2880  biuParse( data, &data );
2881 
2882  (void) ignore;
2883  }
2884  }
2885 
2886  THROW_IO_ERROR( "Missing '$endCOTATION'" );
2887 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
#define NULL
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
int LAYER_NUM
This can be replaced with int and removed.
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
char * strtok_r(char *str, const char *delim, char **nextp)
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References BOARD::Add(), APPEND, biuParse(), degParse(), delims, FROM_UTF8(), intParse(), layerParse(), leg_layer2new(), m_board, m_cu_count, m_reader, NULL, ReadDelimitedText(), READLINE, strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadGENERAL()

void LEGACY_PLUGIN::loadGENERAL ( )
protected

Definition at line 568 of file legacy_plugin.cpp.

569 {
570  char* line;
571  char* saveptr;
572  bool saw_LayerCount = false;
573 
574  while( ( line = READLINE( m_reader ) ) != NULL )
575  {
576  const char* data;
577 
578  if( TESTLINE( "Units" ) )
579  {
580  // what are the engineering units of the lengths in the BOARD?
581  data = strtok_r( line + SZ("Units"), delims, &saveptr );
582 
583  if( !strcmp( data, "mm" ) )
584  {
586  }
587  }
588 
589  else if( TESTLINE( "LayerCount" ) )
590  {
591  int tmp = intParse( line + SZ( "LayerCount" ) );
592 
594 
595  // This has to be set early so that leg_layer2new() works OK, and
596  // that means before parsing "EnabledLayers" and "VisibleLayers".
597  m_cu_count = tmp;
598 
599  saw_LayerCount = true;
600  }
601 
602  else if( TESTLINE( "EnabledLayers" ) )
603  {
604  if( !saw_LayerCount )
605  THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
606 
607  LEG_MASK enabledLayers = hexParse( line + SZ( "EnabledLayers" ) );
608  LSET new_mask = leg_mask2new( m_cu_count, enabledLayers );
609 
610  m_board->SetEnabledLayers( new_mask );
611 
612  // layer visibility equals layer usage, unless overridden later via "VisibleLayers"
613  // Must call SetEnabledLayers() before calling SetVisibleLayers().
614  m_board->SetVisibleLayers( new_mask );
615 
616  // Ensure copper layers count is not modified:
618  }
619 
620  else if( TESTLINE( "VisibleLayers" ) )
621  {
622  // Keep all enabled layers visible.
623  // the old visibility control does not make sense in current Pcbnew version
624  // However, this code works.
625  #if 0
626  if( !saw_LayerCount )
627  THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
628 
629  LEG_MASK visibleLayers = hexParse( line + SZ( "VisibleLayers" ) );
630 
631  LSET new_mask = leg_mask2new( m_cu_count, visibleLayers );
632 
633  m_board->SetVisibleLayers( new_mask );
634  #endif
635  }
636 
637  else if( TESTLINE( "Ly" ) ) // Old format for Layer count
638  {
639  if( !saw_LayerCount )
640  {
641  LEG_MASK layer_mask = hexParse( line + SZ( "Ly" ) );
642 
643  m_cu_count = layerMaskCountSet( layer_mask & ALL_CU_LAYERS );
645 
646  saw_LayerCount = true;
647  }
648  }
649 
650  else if( TESTLINE( "BoardThickness" ) )
651  {
652  BIU thickn = biuParse( line + SZ( "BoardThickness" ) );
654  }
655 
656  else if( TESTLINE( "NoConn" ) )
657  {
658  // ignore
659  intParse( line + SZ( "NoConn" ) );
660  }
661 
662  else if( TESTLINE( "Di" ) )
663  {
664  biuParse( line + SZ( "Di" ), &data );
665  biuParse( data, &data );
666  biuParse( data, &data );
667  biuParse( data );
668  }
669 
670  else if( TESTLINE( "Nnets" ) )
671  {
672  m_netCodes.resize( intParse( line + SZ( "Nnets" ) ) );
673  }
674 
675  else if( TESTLINE( "Nn" ) ) // id "Nnets" for old .brd files
676  {
677  m_netCodes.resize( intParse( line + SZ( "Nn" ) ) );
678  }
679 
680  else if( TESTLINE( "$EndGENERAL" ) )
681  return; // preferred exit
682  }
683 
684  THROW_IO_ERROR( "Missing '$EndGENERAL'" );
685 }
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static constexpr double IU_PER_MM
Mock up a conversion function.
static const char delims[]
void SetCopperLayerCount(int aCount)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
#define READLINE(rdr)
void SetBoardThickness(int aThickness)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
std::vector< int > m_netCodes
net codes mapping for boards being loaded
LINE_READER * m_reader
no ownership here.
LSET is a set of PCB_LAYER_IDs.
#define NULL
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
#define ALL_CU_LAYERS
unsigned LEG_MASK
LEGACY_PLUGIN::BIU BIU
double diskToBiu
convert from disk engineering units to BIUs with this scale factor
BOARD * m_board
which BOARD, no ownership here
static LSET leg_mask2new(int cu_count, unsigned aMask)
int layerMaskCountSet(LEG_MASK aMask)
Count the number of set layers in the mask.
static long hexParse(const char *next, const char **out=NULL)
Function hexParse parses an ASCII hex integer string with possible leading whitespace into a long int...
char * strtok_r(char *str, const char *delim, char **nextp)
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...

References ALL_CU_LAYERS, biuParse(), delims, diskToBiu, BOARD::GetDesignSettings(), hexParse(), intParse(), IU_PER_MM, layerMaskCountSet(), leg_mask2new(), m_board, m_cu_count, m_netCodes, m_reader, NULL, READLINE, BOARD_DESIGN_SETTINGS::SetBoardThickness(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), BOARD::SetVisibleLayers(), strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadMODULE()

void LEGACY_PLUGIN::loadMODULE ( MODULE aModule)
protected

Definition at line 1181 of file legacy_plugin.cpp.

1182 {
1183  char* line;
1184 
1185  while( ( line = READLINE( m_reader ) ) != NULL )
1186  {
1187  const char* data;
1188 
1189  // most frequently encountered ones at the top
1190 
1191  if( TESTSUBSTR( "D" ) && strchr( "SCAP", line[1] ) ) // read a drawing item, e.g. "DS"
1192  {
1193  loadMODULE_EDGE( aModule );
1194  }
1195 
1196  else if( TESTLINE( "$PAD" ) )
1197  {
1198  loadPAD( aModule );
1199  }
1200 
1201  // Read a footprint text description (ref, value, or drawing)
1202  else if( TESTSUBSTR( "T" ) )
1203  {
1204  // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n"
1205  int tnum = intParse( line + SZ( "T" ) );
1206 
1207  FP_TEXT* text = nullptr;
1208 
1209  switch( tnum )
1210  {
1212  text = &aModule->Reference();
1213  break;
1214 
1216  text = &aModule->Value();
1217  break;
1218 
1219  // All other fields greater than 1.
1220  default:
1221  text = new FP_TEXT( aModule );
1222  aModule->Add( text );
1223  }
1224 
1225  loadMODULE_TEXT( text );
1226  }
1227 
1228  else if( TESTLINE( "Po" ) )
1229  {
1230  // e.g. "Po 19120 39260 900 0 4E823D06 68183921-93a5-49ac-91b0-49d05a0e1647 ~~\r\n"
1231  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
1232  BIU pos_y = biuParse( data, &data );
1233  int orient = intParse( data, &data );
1234  LAYER_NUM layer_num = layerParse( data, &data );
1235  PCB_LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
1236  long edittime = hexParse( data, &data );
1237  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
1238 
1239  data = strtok_r( (char*) data+1, delims, (char**) &data );
1240 
1241  // data is now a two character long string
1242  // Note: some old files do not have this field
1243  if( data && data[0] == 'F' )
1244  aModule->SetLocked( true );
1245 
1246  if( data && data[1] == 'P' )
1247  aModule->SetIsPlaced( true );
1248 
1249  aModule->SetPosition( wxPoint( pos_x, pos_y ) );
1250  aModule->SetLayer( layer_id );
1251  aModule->SetOrientation( orient );
1252  const_cast<KIID&>( aModule->m_Uuid ) = KIID( uuid );
1253  aModule->SetLastEditTime( edittime );
1254  }
1255 
1256  /* footprint name set earlier, immediately after MODULE construction
1257  else if( TESTLINE( "Li" ) ) // Library name of footprint
1258  {
1259  // There can be whitespace in the footprint name on some old libraries.
1260  // Grab everything after "Li" up to end of line:
1261  //aModule->SetFPID( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
1262  }
1263  */
1264 
1265  else if( TESTLINE( "Sc" ) ) // timestamp
1266  {
1267  char* uuid = strtok_r( (char*) line + SZ( "Sc" ), delims, (char**) &data );
1268  const_cast<KIID&>( aModule->m_Uuid ) = KIID( uuid );
1269  }
1270 
1271  else if( TESTLINE( "Op" ) ) // (Op)tions for auto placement
1272  {
1273  int itmp1 = hexParse( line + SZ( "Op" ), &data );
1274  int itmp2 = hexParse( data );
1275 
1276  int cntRot180 = itmp2 & 0x0F;
1277  if( cntRot180 > 10 )
1278  cntRot180 = 10;
1279 
1280  aModule->SetPlacementCost180( cntRot180 );
1281 
1282  int cntRot90 = itmp1 & 0x0F;
1283  if( cntRot90 > 10 )
1284  cntRot90 = 0;
1285 
1286  itmp1 = (itmp1 >> 4) & 0x0F;
1287  if( itmp1 > 10 )
1288  itmp1 = 0;
1289 
1290  aModule->SetPlacementCost90( (itmp1 << 4) | cntRot90 );
1291  }
1292 
1293  else if( TESTLINE( "At" ) ) // (At)tributes of module
1294  {
1295  int attrs = 0;
1296 
1297  data = line + SZ( "At" );
1298 
1299  if( strstr( data, "SMD" ) )
1300  attrs |= MOD_SMD;
1301  else if( strstr( data, "VIRTUAL" ) )
1303  else
1305 
1306  aModule->SetAttributes( attrs );
1307  }
1308 
1309  else if( TESTLINE( "AR" ) ) // Alternate Reference
1310  {
1311  // e.g. "AR /68183921-93a5-49ac-e164-49d05a0e1647/93a549d0-49d0-e164-91b0-49d05a0e1647"
1312  data = strtok_r( line + SZ( "AR" ), delims, (char**) &data );
1313 
1314  if( data )
1315  aModule->SetPath( KIID_PATH( FROM_UTF8( data ) ) );
1316  }
1317 
1318  else if( TESTLINE( "$SHAPE3D" ) )
1319  {
1320  load3D( aModule );
1321  }
1322 
1323  else if( TESTLINE( "Cd" ) )
1324  {
1325  // e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n"
1326  aModule->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) );
1327  }
1328 
1329  else if( TESTLINE( "Kw" ) ) // Key words
1330  {
1331  aModule->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) );
1332  }
1333 
1334  else if( TESTLINE( ".SolderPasteRatio" ) )
1335  {
1336  double tmp = atof( line + SZ( ".SolderPasteRatio" ) );
1337  // Due to a bug in dialog editor in Modedit, fixed in BZR version 3565
1338  // this parameter can be broken.
1339  // It should be >= -50% (no solder paste) and <= 0% (full area of the pad)
1340 
1341  if( tmp < -0.50 )
1342  tmp = -0.50;
1343  if( tmp > 0.0 )
1344  tmp = 0.0;
1345  aModule->SetLocalSolderPasteMarginRatio( tmp );
1346  }
1347 
1348  else if( TESTLINE( ".SolderPaste" ) )
1349  {
1350  BIU tmp = biuParse( line + SZ( ".SolderPaste" ) );
1351  aModule->SetLocalSolderPasteMargin( tmp );
1352  }
1353 
1354  else if( TESTLINE( ".SolderMask" ) )
1355  {
1356  BIU tmp = biuParse( line + SZ( ".SolderMask" ) );
1357  aModule->SetLocalSolderMaskMargin( tmp );
1358  }
1359 
1360  else if( TESTLINE( ".LocalClearance" ) )
1361  {
1362  BIU tmp = biuParse( line + SZ( ".LocalClearance" ) );
1363  aModule->SetLocalClearance( tmp );
1364  }
1365 
1366  else if( TESTLINE( ".ZoneConnection" ) )
1367  {
1368  int tmp = intParse( line + SZ( ".ZoneConnection" ) );
1369  aModule->SetZoneConnection( (ZONE_CONNECTION) tmp );
1370  }
1371 
1372  else if( TESTLINE( ".ThermalWidth" ) )
1373  {
1374  BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) );
1375  aModule->SetThermalWidth( tmp );
1376  }
1377 
1378  else if( TESTLINE( ".ThermalGap" ) )
1379  {
1380  BIU tmp = biuParse( line + SZ( ".ThermalGap" ) );
1381  aModule->SetThermalGap( tmp );
1382  }
1383 
1384  else if( TESTLINE( "$EndMODULE" ) )
1385  {
1386  aModule->CalculateBoundingBox();
1387 
1388  return; // preferred exit
1389  }
1390  }
1391 
1392  wxString msg = wxString::Format(
1393  _( "Missing '$EndMODULE' for MODULE \"%s\"" ), aModule->GetFPID().GetLibItemName().wx_str() );
1394 
1395  THROW_IO_ERROR( msg );
1396 }
void SetPlacementCost90(int aCost)
Definition: class_module.h:558
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
void SetThermalGap(int aGap)
Definition: class_module.h:248
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
Definition: string.cpp:365
void SetLocalClearance(int aClearance)
Definition: class_module.h:226
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetPlacementCost180(int aCost)
Definition: class_module.h:555
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
FP_TEXT & Value()
read/write accessors:
Definition: class_module.h:475
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
const LIB_ID & GetFPID() const
Definition: class_module.h:210
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: class_module.h:240
void load3D(MODULE *aModule)
FP_TEXT & Reference()
Definition: class_module.h:476
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
Definition: kiid.h:44
PCB_LAYER_ID
A quick note on layer IDs:
LINE_READER * m_reader
no ownership here.
#define NULL
void loadMODULE_EDGE(MODULE *aModule)
void SetLastEditTime(timestamp_t aTime)
Definition: class_module.h:339
void loadMODULE_TEXT(FP_TEXT *aText)
void SetThermalWidth(int aWidth)
Definition: class_module.h:245
void SetIsPlaced(bool isPlaced)
Definition: class_module.h:312
LEGACY_PLUGIN::BIU BIU
void SetPosition(const wxPoint &aPos) override
#define TESTSUBSTR(x)
C sub-string compare test for a specific length of characters.
void SetLocalSolderMaskMargin(int aMargin)
Definition: class_module.h:223
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
int LAYER_NUM
This can be replaced with int and removed.
void SetOrientation(double aNewAngle)
const KIID m_Uuid
Definition: eda_item.h:151
void SetLocalSolderPasteMargin(int aMargin)
Definition: class_module.h:237
void SetLocked(bool isLocked) override
Function SetLocked sets the MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: class_module.h:303
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:201
#define _(s)
Definition: 3d_actions.cpp:33
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: class_module.h:242
static long hexParse(const char *next, const char **out=NULL)
Function hexParse parses an ASCII hex integer string with possible leading whitespace into a long int...
wxString wx_str() const
Definition: utf8.cpp:51
char * strtok_r(char *str, const char *delim, char **nextp)
void SetKeywords(const wxString &aKeywords)
Definition: class_module.h:217
void SetPath(const KIID_PATH &aPath)
Definition: class_module.h:220
void loadPAD(MODULE *aModule)
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
void SetAttributes(int aAttributes)
Definition: class_module.h:252
void SetDescription(const wxString &aDoc)
Definition: class_module.h:214

References _, MODULE::Add(), biuParse(), MODULE::CalculateBoundingBox(), delims, Format(), FROM_UTF8(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), hexParse(), intParse(), layerParse(), leg_layer2new(), load3D(), loadMODULE_EDGE(), loadMODULE_TEXT(), loadPAD(), m_cu_count, m_reader, EDA_ITEM::m_Uuid, MOD_EXCLUDE_FROM_BOM, MOD_EXCLUDE_FROM_POS_FILES, MOD_SMD, MOD_THROUGH_HOLE, NULL, READLINE, MODULE::Reference(), MODULE::SetAttributes(), MODULE::SetDescription(), MODULE::SetIsPlaced(), MODULE::SetKeywords(), MODULE::SetLastEditTime(), BOARD_ITEM::SetLayer(), MODULE::SetLocalClearance(), MODULE::SetLocalSolderMaskMargin(), MODULE::SetLocalSolderPasteMargin(), MODULE::SetLocalSolderPasteMarginRatio(), MODULE::SetLocked(), MODULE::SetOrientation(), MODULE::SetPath(), MODULE::SetPlacementCost180(), MODULE::SetPlacementCost90(), MODULE::SetPosition(), MODULE::SetThermalGap(), MODULE::SetThermalWidth(), MODULE::SetZoneConnection(), StrPurge(), strtok_r(), SZ, TESTLINE, TESTSUBSTR, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, THROW_IO_ERROR, MODULE::Value(), and UTF8::wx_str().

Referenced by loadAllSections(), and LP_CACHE::LoadModules().

◆ loadMODULE_EDGE()

void LEGACY_PLUGIN::loadMODULE_EDGE ( MODULE aModule)
protected

Definition at line 1634 of file legacy_plugin.cpp.

1635 {
1636  PCB_SHAPE_TYPE_T shape;
1637  char* line = m_reader->Line(); // obtain current (old) line
1638 
1639  switch( line[1] )
1640  {
1641  case 'S': shape = S_SEGMENT; break;
1642  case 'C': shape = S_CIRCLE; break;
1643  case 'A': shape = S_ARC; break;
1644  case 'P': shape = S_POLYGON; break;
1645  default:
1646  m_error.Printf( _( "Unknown FP_SHAPE type:'%c=0x%02x' on line:%d of footprint:\"%s\"" ),
1647  (unsigned char) line[1],
1648  (unsigned char) line[1],
1649  m_reader->LineNumber(),
1650  aModule->GetFPID().GetLibItemName().wx_str()
1651  );
1653  }
1654 
1655  std::unique_ptr<FP_SHAPE> dwg = std::make_unique<FP_SHAPE>( aModule, shape ); // a drawing
1656 
1657  const char* data;
1658 
1659  // common to all cases, and we have to check their values uniformly at end
1660  BIU width = 1;
1662 
1663  switch( shape )
1664  {
1665  case S_ARC:
1666  {
1667  BIU start0_x = biuParse( line + SZ( "DA" ), &data );
1668  BIU start0_y = biuParse( data, &data );
1669  BIU end0_x = biuParse( data, &data );
1670  BIU end0_y = biuParse( data, &data );
1671  double angle = degParse( data, &data );
1672 
1673  width = biuParse( data, &data );
1674  layer = layerParse( data );
1675 
1676  dwg->m_Start0 = wxPoint( start0_x, start0_y );
1677  dwg->m_End0 = wxPoint( end0_x, end0_y );
1678 
1679  // Setting angle will set m_ThirdPoint0, so must be done after setting
1680  // m_Start0 and m_End0
1681  dwg->SetAngle( angle );
1682  }
1683  break;
1684 
1685  case S_SEGMENT:
1686  case S_CIRCLE:
1687  {
1688  // e.g. "DS -7874 -10630 7874 -10630 50 20\r\n"
1689  BIU start0_x = biuParse( line + SZ( "DS" ), &data );
1690  BIU start0_y = biuParse( data, &data );
1691  BIU end0_x = biuParse( data, &data );
1692  BIU end0_y = biuParse( data, &data );
1693 
1694  width = biuParse( data, &data );
1695  layer = layerParse( data );
1696 
1697  dwg->m_Start0 = wxPoint( start0_x, start0_y );
1698  dwg->m_End0 = wxPoint( end0_x, end0_y );
1699  }
1700  break;
1701 
1702  case S_POLYGON:
1703  {
1704  // e.g. "DP %d %d %d %d %d %d %d\n"
1705  BIU start0_x = biuParse( line + SZ( "DP" ), &data );
1706  BIU start0_y = biuParse( data, &data );
1707  BIU end0_x = biuParse( data, &data );
1708  BIU end0_y = biuParse( data, &data );
1709  int ptCount = intParse( data, &data );
1710 
1711  width = biuParse( data, &data );
1712  layer = layerParse( data );
1713 
1714  dwg->m_Start0 = wxPoint( start0_x, start0_y );
1715  dwg->m_End0 = wxPoint( end0_x, end0_y );
1716 
1717  std::vector<wxPoint> pts;
1718  pts.reserve( ptCount );
1719 
1720  for( int ii = 0; ii<ptCount; ++ii )
1721  {
1722  if( ( line = READLINE( m_reader ) ) == NULL )
1723  {
1724  THROW_IO_ERROR( "S_POLGON point count mismatch." );
1725  }
1726 
1727  // e.g. "Dl 23 44\n"
1728 
1729  if( !TESTLINE( "Dl" ) )
1730  {
1731  THROW_IO_ERROR( "Missing Dl point def" );
1732  }
1733 
1734  BIU x = biuParse( line + SZ( "Dl" ), &data );
1735  BIU y = biuParse( data );
1736 
1737  pts.emplace_back( x, y );
1738  }
1739 
1740  dwg->SetPolyPoints( pts );
1741  }
1742  break;
1743 
1744  default:
1745  // first switch code above prevents us from getting here.
1746  break;
1747  }
1748 
1749  // Check for a reasonable layer:
1750  // m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints
1751  // can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed.
1752  if( layer < FIRST_LAYER || layer > LAST_NON_COPPER_LAYER )
1753  layer = SILKSCREEN_N_FRONT;
1754 
1755  dwg->SetWidth( width );
1756  dwg->SetLayer( leg_layer2new( m_cu_count, layer ) );
1757 
1758  FP_SHAPE* fpShape = dwg.release();
1759 
1760  aModule->Add( fpShape );
1761 
1762  // this had been done at the MODULE level before, presumably because the
1763  // FP_SHAPE needs to be already added to a module before this function will work.
1764  fpShape->SetDrawCoord();
1765 }
usual segment : line with rounded ends
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
const LIB_ID & GetFPID() const
Definition: class_module.h:210
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
Arcs (with rounded ends)
#define SILKSCREEN_N_FRONT
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
LINE_READER * m_reader
no ownership here.
#define NULL
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:160
LEGACY_PLUGIN::BIU BIU
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
int LAYER_NUM
This can be replaced with int and removed.
PCB_SHAPE_TYPE_T
Enum PCB_SHAPE_TYPE_T is the set of shapes for PCB graphics and tracks and footprint graphics in the ...
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
polygon (not yet used for tracks, but could be in microwave apps)
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
#define LAST_NON_COPPER_LAYER
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxString wx_str() const
Definition: utf8.cpp:51
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
#define FIRST_NON_COPPER_LAYER

References _, MODULE::Add(), PNS::angle(), biuParse(), degParse(), FIRST_NON_COPPER_LAYER, MODULE::GetFPID(), LIB_ID::GetLibItemName(), intParse(), LAST_NON_COPPER_LAYER, layerParse(), leg_layer2new(), LINE_READER::Line(), LINE_READER::LineNumber(), m_cu_count, m_error, m_reader, NULL, READLINE, S_ARC, S_CIRCLE, S_POLYGON, S_SEGMENT, FP_SHAPE::SetDrawCoord(), SILKSCREEN_N_FRONT, SZ, TESTLINE, THROW_IO_ERROR, and UTF8::wx_str().

Referenced by loadMODULE().

◆ loadMODULE_TEXT()

void LEGACY_PLUGIN::loadMODULE_TEXT ( FP_TEXT aText)
protected

Definition at line 1768 of file legacy_plugin.cpp.

1769 {
1770  const char* data;
1771  const char* txt_end;
1772  const char* line = m_reader->Line(); // current (old) line
1773 
1774  // sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
1775  // &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x,
1776  // &m_Orient, &m_Thickness, BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
1777 
1778  // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n"
1779  // or T1 0 500 600 400 900 80 M V 20 N"74LS245"
1780  // ouch, the last example has no space between N and "74LS245" !
1781  // that is an older version.
1782 
1783  int type = intParse( line+1, &data );
1784  BIU pos0_x = biuParse( data, &data );
1785  BIU pos0_y = biuParse( data, &data );
1786  BIU size0_y = biuParse( data, &data );
1787  BIU size0_x = biuParse( data, &data );
1788  double orient = degParse( data, &data );
1789  BIU thickn = biuParse( data, &data );
1790 
1791  // read the quoted text before the first call to strtok() which introduces
1792  // NULs into the string and chops it into mutliple C strings, something
1793  // ReadDelimitedText() cannot traverse.
1794 
1795  // convert the "quoted, escaped, UTF8, text" to a wxString, find it by skipping
1796  // as far forward as needed until the first double quote.
1797  txt_end = data + ReadDelimitedText( &m_field, data );
1798  m_field.Replace( "%V", "${VALUE}" );
1799  m_field.Replace( "%R", "${REFERENCE}" );
1800  aText->SetText( m_field );
1801 
1802  // after switching to strtok, there's no easy coming back because of the
1803  // embedded nul(s?) placed to the right of the current field.
1804  // (that's the reason why strtok was deprecated...)
1805  char* mirror = strtok_r( (char*) data, delims, (char**) &data );
1806  char* hide = strtok_r( NULL, delims, (char**) &data );
1807  char* tmp = strtok_r( NULL, delims, (char**) &data );
1808 
1809  LAYER_NUM layer_num = tmp ? layerParse( tmp ) : SILKSCREEN_N_FRONT;
1810 
1811  char* italic = strtok_r( NULL, delims, (char**) &data );
1812 
1813  char* hjust = strtok_r( (char*) txt_end, delims, (char**) &data );
1814  char* vjust = strtok_r( NULL, delims, (char**) &data );
1815 
1816  if( type != FP_TEXT::TEXT_is_REFERENCE
1817  && type != FP_TEXT::TEXT_is_VALUE )
1818  type = FP_TEXT::TEXT_is_DIVERS;
1819 
1820  aText->SetType( static_cast<FP_TEXT::TEXT_TYPE>( type ) );
1821 
1822  aText->SetPos0( wxPoint( pos0_x, pos0_y ) );
1823  aText->SetTextSize( wxSize( size0_x, size0_y ) );
1824 
1825  orient -= ( static_cast<MODULE*>( aText->GetParent() ) )->GetOrientation();
1826 
1827  aText->SetTextAngle( orient );
1828 
1829  aText->SetTextThickness( thickn < 1 ? 0 : thickn );
1830 
1831  aText->SetMirrored( mirror && *mirror == 'M' );
1832 
1833  aText->SetVisible( !(hide && *hide == 'I') );
1834 
1835  aText->SetItalic( italic && *italic == 'I' );
1836 
1837  if( hjust )
1838  aText->SetHorizJustify( horizJustify( hjust ) );
1839 
1840  if( vjust )
1841  aText->SetVertJustify( vertJustify( vjust ) );
1842 
1843  // A protection against mal formed (or edited by hand) files:
1844  if( layer_num < FIRST_LAYER )
1845  layer_num = FIRST_LAYER;
1846  else if( layer_num > LAST_NON_COPPER_LAYER )
1847  layer_num = LAST_NON_COPPER_LAYER;
1848  else if( layer_num == LAYER_N_BACK )
1849  layer_num = SILKSCREEN_N_BACK;
1850  else if( layer_num == LAYER_N_FRONT )
1851  layer_num = SILKSCREEN_N_FRONT;
1852  else if( layer_num < LAYER_N_FRONT ) // this case is a internal layer
1853  layer_num = SILKSCREEN_N_FRONT;
1854 
1855  aText->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
1856 
1857  // Calculate the actual position.
1858  aText->SetDrawCoord();
1859 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:194
#define SILKSCREEN_N_BACK
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
#define LAYER_N_BACK
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:68
void SetItalic(bool isItalic)
Definition: eda_text.h:185
static const char delims[]
void SetVisible(bool aVisible)
Definition: eda_text.h:191
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
void SetDrawCoord()
Set absolute coordinates.
Definition: fp_text.cpp:198
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
wxString m_field
reused to stuff MODULE fields.
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:142
#define SILKSCREEN_N_FRONT
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
LINE_READER * m_reader
no ownership here.
static EDA_TEXT_HJUSTIFY_T horizJustify(const char *horizontal)
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:120
#define NULL
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
LEGACY_PLUGIN::BIU BIU
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:169
int LAYER_NUM
This can be replaced with int and removed.
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
#define LAYER_N_FRONT
#define FIRST_LAYER
static EDA_TEXT_VJUSTIFY_T vertJustify(const char *vertical)
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define LAST_NON_COPPER_LAYER
char * strtok_r(char *str, const char *delim, char **nextp)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:164
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
BOARD_ITEM_CONTAINER * GetParent() const

References biuParse(), degParse(), delims, FIRST_LAYER, BOARD_ITEM::GetParent(), horizJustify(), intParse(), LAST_NON_COPPER_LAYER, LAYER_N_BACK, LAYER_N_FRONT, layerParse(), leg_layer2new(), LINE_READER::Line(), m_cu_count, m_field, m_reader, NULL, ReadDelimitedText(), FP_TEXT::SetDrawCoord(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), FP_TEXT::SetPos0(), EDA_TEXT::SetText(), FP_TEXT::SetTextAngle(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), FP_TEXT::SetType(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), SILKSCREEN_N_BACK, SILKSCREEN_N_FRONT, strtok_r(), FP_TEXT::TEXT_is_DIVERS, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, and vertJustify().

Referenced by loadMODULE().

◆ loadNETCLASS()

void LEGACY_PLUGIN::loadNETCLASS ( )
protected

Definition at line 2344 of file legacy_plugin.cpp.

2345 {
2346  char buf[1024];
2347  wxString netname;
2348  char* line;
2349 
2350  // create an empty NETCLASS without a name, but do not add it to the BOARD
2351  // yet since that would bypass duplicate netclass name checking within the BOARD.
2352  // store it temporarily in an unique_ptr until successfully inserted into the BOARD
2353  // just before returning.
2354  NETCLASSPTR nc = std::make_shared<NETCLASS>( wxEmptyString );
2355 
2356  while( ( line = READLINE( m_reader ) ) != NULL )
2357  {
2358  if( TESTLINE( "AddNet" ) ) // most frequent type of line
2359  {
2360  // e.g. "AddNet "V3.3D"\n"
2361  ReadDelimitedText( buf, line + SZ( "AddNet" ), sizeof(buf) );
2362  netname = FROM_UTF8( buf );
2363  nc->Add( netname );
2364  }
2365 
2366  else if( TESTLINE( "Clearance" ) )
2367  {
2368  BIU tmp = biuParse( line + SZ( "Clearance" ) );
2369  nc->SetClearance( tmp );
2370  }
2371 
2372  else if( TESTLINE( "TrackWidth" ) )
2373  {
2374  BIU tmp = biuParse( line + SZ( "TrackWidth" ) );
2375  nc->SetTrackWidth( tmp );
2376  }
2377 
2378  else if( TESTLINE( "ViaDia" ) )
2379  {
2380  BIU tmp = biuParse( line + SZ( "ViaDia" ) );
2381  nc->SetViaDiameter( tmp );
2382  }
2383 
2384  else if( TESTLINE( "ViaDrill" ) )
2385  {
2386  BIU tmp = biuParse( line + SZ( "ViaDrill" ) );
2387  nc->SetViaDrill( tmp );
2388  }
2389 
2390  else if( TESTLINE( "uViaDia" ) )
2391  {
2392  BIU tmp = biuParse( line + SZ( "uViaDia" ) );
2393  nc->SetuViaDiameter( tmp );
2394  }
2395 
2396  else if( TESTLINE( "uViaDrill" ) )
2397  {
2398  BIU tmp = biuParse( line + SZ( "uViaDrill" ) );
2399  nc->SetuViaDrill( tmp );
2400  }
2401 
2402  else if( TESTLINE( "Name" ) )
2403  {
2404  ReadDelimitedText( buf, line + SZ( "Name" ), sizeof(buf) );
2405  nc->SetName( FROM_UTF8( buf ) );
2406  }
2407 
2408  else if( TESTLINE( "Desc" ) )
2409  {
2410  ReadDelimitedText( buf, line + SZ( "Desc" ), sizeof(buf) );
2411  nc->SetDescription( FROM_UTF8( buf ) );
2412  }
2413 
2414  else if( TESTLINE( "$EndNCLASS" ) )
2415  {
2416  if( !m_board->GetDesignSettings().GetNetClasses().Add( nc ) )
2417  {
2418  // Must have been a name conflict, this is a bad board file.
2419  // User may have done a hand edit to the file.
2420 
2421  // unique_ptr will delete nc on this code path
2422 
2423  m_error.Printf( _( "duplicate NETCLASS name \"%s\"" ), nc->GetName().GetData() );
2425  }
2426 
2427  return; // preferred exit
2428  }
2429  }
2430 
2431  THROW_IO_ERROR( "Missing '$EndNCLASS'" );
2432 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
#define READLINE(rdr)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
LINE_READER * m_reader
no ownership here.
#define NULL
NETCLASSES & GetNetClasses() const
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
bool Add(const NETCLASSPTR &aNetclass)
Function Add takes aNetclass and puts it into this NETCLASSES container.
Definition: netclass.cpp:90
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References _, NETCLASSES::Add(), biuParse(), FROM_UTF8(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetNetClasses(), m_board, m_error, m_reader, NULL, ReadDelimitedText(), READLINE, SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadNETINFO_ITEM()

void LEGACY_PLUGIN::loadNETINFO_ITEM ( )
protected

Definition at line 2021 of file legacy_plugin.cpp.

2022 {
2023  /* a net description is something like
2024  * $EQUIPOT
2025  * Na 5 "/BIT1"
2026  * St ~
2027  * $EndEQUIPOT
2028  */
2029 
2030  char buf[1024];
2031 
2032  NETINFO_ITEM* net = NULL;
2033  char* line;
2034  int netCode = 0;
2035 
2036  while( ( line = READLINE( m_reader ) ) != NULL )
2037  {
2038  const char* data;
2039 
2040  if( TESTLINE( "Na" ) )
2041  {
2042  // e.g. "Na 58 "/cpu.sch/PAD7"\r\n"
2043 
2044  netCode = intParse( line + SZ( "Na" ), &data );
2045 
2046  ReadDelimitedText( buf, data, sizeof(buf) );
2047 
2048  if( net == NULL )
2049  net = new NETINFO_ITEM( m_board, FROM_UTF8( buf ), netCode );
2050  else
2051  {
2052  THROW_IO_ERROR( "Two net definitions in '$EQUIPOT' block" );
2053  }
2054  }
2055 
2056  else if( TESTLINE( "$EndEQUIPOT" ) )
2057  {
2058  // net 0 should be already in list, so store this net
2059  // if it is not the net 0, or if the net 0 does not exists.
2060  if( net && ( net->GetNet() > 0 || m_board->FindNet( 0 ) == NULL ) )
2061  {
2062  m_board->Add( net );
2063 
2064  // Be sure we have room to store the net in m_netCodes
2065  if( (int)m_netCodes.size() <= netCode )
2066  m_netCodes.resize( netCode+1 );
2067 
2068  m_netCodes[netCode] = net->GetNet();
2069  net = NULL;
2070  }
2071  else
2072  {
2073  delete net;
2074  net = NULL; // Avoid double deletion.
2075  }
2076 
2077  return; // preferred exit
2078  }
2079  }
2080 
2081  // If we are here, there is an error.
2082  delete net;
2083  THROW_IO_ERROR( "Missing '$EndEQUIPOT'" );
2084 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
#define READLINE(rdr)
std::vector< int > m_netCodes
net codes mapping for boards being loaded
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
LINE_READER * m_reader
no ownership here.
#define NULL
BOARD * m_board
which BOARD, no ownership here
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
int GetNet() const
Function GetNet.
Definition: netinfo.h:223
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References BOARD::Add(), BOARD::FindNet(), FROM_UTF8(), NETINFO_ITEM::GetNet(), intParse(), m_board, m_netCodes, m_reader, NULL, ReadDelimitedText(), READLINE, SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadPAD()

void LEGACY_PLUGIN::loadPAD ( MODULE aModule)
protected

Definition at line 1399 of file legacy_plugin.cpp.

1400 {
1401  std::unique_ptr<D_PAD> pad = std::make_unique<D_PAD>( aModule );
1402  char* line;
1403  char* saveptr;
1404 
1405  while( ( line = READLINE( m_reader ) ) != NULL )
1406  {
1407  const char* data;
1408 
1409  if( TESTLINE( "Sh" ) ) // (Sh)ape and padname
1410  {
1411  // e.g. "Sh "A2" C 520 520 0 0 900"
1412  // or "Sh "1" R 157 1378 0 0 900"
1413 
1414  // mypadname is LATIN1/CRYLIC for BOARD_FORMAT_VERSION 1,
1415  // but for BOARD_FORMAT_VERSION 2, it is UTF8 from disk.
1416  // So we have to go through two code paths. Moving forward
1417  // padnames will be in UTF8 on disk, as are all KiCad strings on disk.
1418  char mypadname[50];
1419 
1420  data = line + SZ( "Sh" ) + 1; // +1 skips trailing whitespace
1421 
1422  data = data + ReadDelimitedText( mypadname, data, sizeof(mypadname) ) + 1; // +1 trailing whitespace
1423 
1424  while( isSpace( *data ) )
1425  ++data;
1426 
1427  unsigned char padchar = (unsigned char) *data++;
1428  int padshape;
1429 
1430  BIU size_x = biuParse( data, &data );
1431  BIU size_y = biuParse( data, &data );
1432  BIU delta_x = biuParse( data, &data );
1433  BIU delta_y = biuParse( data, &data );
1434  double orient = degParse( data );
1435 
1436  switch( padchar )
1437  {
1438  case 'C': padshape = PAD_SHAPE_CIRCLE; break;
1439  case 'R': padshape = PAD_SHAPE_RECT; break;
1440  case 'O': padshape = PAD_SHAPE_OVAL; break;
1441  case 'T': padshape = PAD_SHAPE_TRAPEZOID; break;
1442  default:
1443  m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line: %d of footprint: \"%s\"" ),
1444  padchar,
1445  padchar,
1446  m_reader->LineNumber(),
1447  aModule->GetFPID().GetLibItemName().wx_str()
1448  );
1450  }
1451 
1452  // go through a wxString to establish a universal character set properly
1453  wxString padname;
1454 
1455  if( m_loading_format_version == 1 )
1456  {
1457  // add 8 bit bytes, file format 1 was KiCad font type byte,
1458  // simply promote those 8 bit bytes up into UNICODE. (subset of LATIN1)
1459  const unsigned char* cp = (unsigned char*) mypadname;
1460  while( *cp )
1461  {
1462  padname += *cp++; // unsigned, ls 8 bits only
1463  }
1464  }
1465  else
1466  {
1467  // version 2, which is UTF8.
1468  padname = FROM_UTF8( mypadname );
1469  }
1470  // chances are both were ASCII, but why take chances?
1471 
1472  pad->SetName( padname );
1473  pad->SetShape( PAD_SHAPE_T( padshape ) );
1474  pad->SetSize( wxSize( size_x, size_y ) );
1475  pad->SetDelta( wxSize( delta_x, delta_y ) );
1476  pad->SetOrientation( orient );
1477  }
1478 
1479  else if( TESTLINE( "Dr" ) ) // (Dr)ill
1480  {
1481  // e.g. "Dr 350 0 0" or "Dr 0 0 0 O 0 0"
1482  BIU drill_x = biuParse( line + SZ( "Dr" ), &data );
1483  BIU drill_y = drill_x;
1484  BIU offs_x = biuParse( data, &data );
1485  BIU offs_y = biuParse( data, &data );
1486 
1488 
1489  data = strtok_r( (char*) data, delims, &saveptr );
1490  if( data ) // optional shape
1491  {
1492  if( data[0] == 'O' )
1493  {
1494  drShape = PAD_DRILL_SHAPE_OBLONG;
1495 
1496  data = strtok_r( NULL, delims, &saveptr );
1497  drill_x = biuParse( data );
1498 
1499  data = strtok_r( NULL, delims, &saveptr );
1500  drill_y = biuParse( data );
1501  }
1502  }
1503 
1504  pad->SetDrillShape( drShape );
1505  pad->SetOffset( wxPoint( offs_x, offs_y ) );
1506  pad->SetDrillSize( wxSize( drill_x, drill_y ) );
1507  }
1508 
1509  else if( TESTLINE( "At" ) ) // (At)tribute
1510  {
1511  // e.g. "At SMD N 00888000"
1512  // sscanf( PtLine, "%s %s %X", BufLine, BufCar, &m_layerMask );
1513 
1514  PAD_ATTR_T attribute;
1515 
1516  data = strtok_r( line + SZ( "At" ), delims, &saveptr );
1517 
1518  if( !strcmp( data, "SMD" ) )
1519  attribute = PAD_ATTRIB_SMD;
1520  else if( !strcmp( data, "CONN" ) )
1521  attribute = PAD_ATTRIB_CONN;
1522  else if( !strcmp( data, "HOLE" ) )
1523  attribute = PAD_ATTRIB_NPTH;
1524  else
1525  attribute = PAD_ATTRIB_PTH;
1526 
1527  strtok_r( NULL, delims, &saveptr ); // skip unused prm
1528  data = strtok_r( NULL, delims, &saveptr );
1529 
1530  LEG_MASK layer_mask = hexParse( data );
1531 
1532  pad->SetLayerSet( leg_mask2new( m_cu_count, layer_mask ) );
1533  pad->SetAttribute( attribute );
1534  }
1535 
1536  else if( TESTLINE( "Ne" ) ) // (Ne)tname
1537  {
1538  // e.g. "Ne 461 "V5.0"
1539 
1540  char buf[1024]; // can be fairly long
1541  int netcode = intParse( line + SZ( "Ne" ), &data );
1542 
1543  // Store the new code mapping
1544  pad->SetNetCode( getNetCode( netcode ) );
1545 
1546  // read Netname
1547  ReadDelimitedText( buf, data, sizeof(buf) );
1548 
1549  if( m_board )
1550  wxASSERT( m_board->FindNet( getNetCode( netcode ) )->GetNetname()
1551  == FROM_UTF8( StrPurge( buf ) ) );
1552  }
1553 
1554  else if( TESTLINE( "Po" ) ) // (Po)sition
1555  {
1556  // e.g. "Po 500 -500"
1557  wxPoint pos;
1558 
1559  pos.x = biuParse( line + SZ( "Po" ), &data );
1560  pos.y = biuParse( data );
1561 
1562  pad->SetPos0( pos );
1563  // pad->SetPosition( pos ); set at function return
1564  }
1565 
1566  else if( TESTLINE( "Le" ) )
1567  {
1568  BIU tmp = biuParse( line + SZ( "Le" ) );
1569  pad->SetPadToDieLength( tmp );
1570  }
1571 
1572  else if( TESTLINE( ".SolderMask" ) )
1573  {
1574  BIU tmp = biuParse( line + SZ( ".SolderMask" ) );
1575  pad->SetLocalSolderMaskMargin( tmp );
1576  }
1577 
1578  else if( TESTLINE( ".SolderPasteRatio" ) )
1579  {
1580  double tmp = atof( line + SZ( ".SolderPasteRatio" ) );
1581  pad->SetLocalSolderPasteMarginRatio( tmp );
1582  }
1583 
1584  else if( TESTLINE( ".SolderPaste" ) )
1585  {
1586  BIU tmp = biuParse( line + SZ( ".SolderPaste" ) );
1587  pad->SetLocalSolderPasteMargin( tmp );
1588  }
1589 
1590  else if( TESTLINE( ".LocalClearance" ) )
1591  {
1592  BIU tmp = biuParse( line + SZ( ".LocalClearance" ) );
1593  pad->SetLocalClearance( tmp );
1594  }
1595 
1596  else if( TESTLINE( ".ZoneConnection" ) )
1597  {
1598  int tmp = intParse( line + SZ( ".ZoneConnection" ) );
1599  pad->SetZoneConnection( (ZONE_CONNECTION) tmp );
1600  }
1601 
1602  else if( TESTLINE( ".ThermalWidth" ) )
1603  {
1604  BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) );
1605  pad->SetThermalSpokeWidth( tmp );
1606  }
1607 
1608  else if( TESTLINE( ".ThermalGap" ) )
1609  {
1610  BIU tmp = biuParse( line + SZ( ".ThermalGap" ) );
1611  pad->SetThermalGap( tmp );
1612  }
1613 
1614  else if( TESTLINE( "$EndPAD" ) )
1615  {
1616  // pad's "Position" is not relative to the module's,
1617  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
1618 
1619  wxPoint padpos = pad->GetPos0();
1620 
1621  RotatePoint( &padpos, aModule->GetOrientation() );
1622 
1623  pad->SetPosition( padpos + aModule->GetPosition() );
1624 
1625  aModule->Add( pad.release() );
1626  return; // preferred exit
1627  }
1628  }
1629 
1630  THROW_IO_ERROR( "Missing '$EndPAD'" );
1631 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
double GetOrientation() const
Definition: class_module.h:206
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
Definition: string.cpp:365
PAD_ATTR_T
Enum PAD_ATTR_T is the set of pad shapes, used with D_PAD::{Set,Get}Attribute() The double name is fo...
Definition: pad_shapes.h:78
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
static const char delims[]
const LIB_ID & GetFPID() const
Definition: class_module.h:210
#define READLINE(rdr)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
PAD_DRILL_SHAPE_T
Enum PAD_DRILL_SHAPE_T is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:66
int m_loading_format_version
which BOARD_FORMAT_VERSION am I Load()ing?
PAD_SHAPE_T
Enum PAD_SHAPE_T is the set of pad shapes, used with D_PAD::{Set,Get}Shape()
Definition: pad_shapes.h:33
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
LINE_READER * m_reader
no ownership here.
#define NULL
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:160
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
unsigned LEG_MASK
LEGACY_PLUGIN::BIU BIU
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
BOARD * m_board
which BOARD, no ownership here
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
static bool isSpace(int c)
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
static LSET leg_mask2new(int cu_count, unsigned aMask)
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
static long hexParse(const char *next, const char **out=NULL)
Function hexParse parses an ASCII hex integer string with possible leading whitespace into a long int...
wxString wx_str() const
Definition: utf8.cpp:51
Plated through hole pad.
Definition: pad_shapes.h:80
char * strtok_r(char *str, const char *delim, char **nextp)
wxPoint GetPosition() const override
Definition: class_module.h:201
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
int getNetCode(int aNetCode)
Converts net code using the mapping table if available, otherwise returns unchanged net code
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References _, MODULE::Add(), biuParse(), degParse(), delims, BOARD::FindNet(), FROM_UTF8(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), getNetCode(), NETINFO_ITEM::GetNetname(), MODULE::GetOrientation(), MODULE::GetPosition(), hexParse(), intParse(), isSpace(), leg_mask2new(), LINE_READER::LineNumber(), m_board, m_cu_count, m_error, m_loading_format_version, m_reader, NULL, PAD_ATTRIB_CONN, PAD_ATTRIB_NPTH, PAD_ATTRIB_PTH, PAD_ATTRIB_SMD, PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_TRAPEZOID, ReadDelimitedText(), READLINE, RotatePoint(), StrPurge(), strtok_r(), SZ, TESTLINE, THROW_IO_ERROR, and UTF8::wx_str().

Referenced by loadMODULE().

◆ loadPCB_LINE()

void LEGACY_PLUGIN::loadPCB_LINE ( )
protected

Definition at line 1911 of file legacy_plugin.cpp.

1912 {
1913  /* example:
1914  $DRAWSEGMENT
1915  Po 0 57500 -1000 57500 0 150
1916  De 24 0 900 0 0
1917  $EndDRAWSEGMENT
1918  */
1919 
1920  std::unique_ptr<PCB_SHAPE> dseg = std::make_unique<PCB_SHAPE>( m_board );
1921 
1922  char* line;
1923  char* saveptr;
1924 
1925  while( ( line = READLINE( m_reader ) ) != NULL )
1926  {
1927  const char* data;
1928 
1929  if( TESTLINE( "Po" ) )
1930  {
1931  int shape = intParse( line + SZ( "Po" ), &data );
1932  BIU start_x = biuParse( data, &data );
1933  BIU start_y = biuParse( data, &data );
1934  BIU end_x = biuParse( data, &data );
1935  BIU end_y = biuParse( data, &data );
1936  BIU width = biuParse( data );
1937 
1938  if( width < 0 )
1939  width = 0;
1940 
1941  dseg->SetShape( PCB_SHAPE_TYPE_T( shape ) );
1942  dseg->SetWidth( width );
1943  dseg->SetStart( wxPoint( start_x, start_y ) );
1944  dseg->SetEnd( wxPoint( end_x, end_y ) );
1945  }
1946 
1947  else if( TESTLINE( "De" ) )
1948  {
1949  BIU x = 0;
1950  BIU y;
1951 
1952  data = strtok_r( line + SZ( "De" ), delims, &saveptr );
1953  for( int i = 0; data; ++i, data = strtok_r( NULL, delims, &saveptr ) )
1954  {
1955  switch( i )
1956  {
1957  case 0:
1958  LAYER_NUM layer;
1959  layer = layerParse( data );
1960 
1961  if( layer < FIRST_NON_COPPER_LAYER )
1962  layer = FIRST_NON_COPPER_LAYER;
1963 
1964  else if( layer > LAST_NON_COPPER_LAYER )
1965  layer = LAST_NON_COPPER_LAYER;
1966 
1967  dseg->SetLayer( leg_layer2new( m_cu_count, layer ) );
1968  break;
1969  case 1:
1970  int mtype;
1971  mtype = intParse( data );
1972  dseg->SetType( mtype ); // m_Type
1973  break;
1974  case 2:
1975  double angle;
1976  angle = degParse( data );
1977  dseg->SetAngle( angle ); // m_Angle
1978  break;
1979  case 3:
1980  const_cast<KIID&>( dseg->m_Uuid ) = KIID( data );
1981  break;
1982  case 4:
1983  STATUS_FLAGS state;
1984  state = static_cast<STATUS_FLAGS>( hexParse( data ) );
1985  dseg->SetState( state, true );
1986  break;
1987 
1988  // Bezier Control Points
1989  case 5:
1990  x = biuParse( data );
1991  break;
1992  case 6:
1993  y = biuParse( data );
1994  dseg->SetBezControl1( wxPoint( x, y ) );
1995  break;
1996 
1997  case 7:
1998  x = biuParse( data );
1999  break;
2000  case 8:
2001  y = biuParse( data );
2002  dseg->SetBezControl2( wxPoint( x, y ) );
2003  break;
2004 
2005  default:
2006  break;
2007  }
2008  }
2009  }
2010 
2011  else if( TESTLINE( "$EndDRAWSEGMENT" ) )
2012  {
2013  m_board->Add( dseg.release(), ADD_MODE::APPEND );
2014  return; // preferred exit
2015  }
2016  }
2017 
2018  THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" );
2019 }
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
#define NULL
unsigned STATUS_FLAGS
Definition: eda_item.h:141
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
int LAYER_NUM
This can be replaced with int and removed.
PCB_SHAPE_TYPE_T
Enum PCB_SHAPE_TYPE_T is the set of shapes for PCB graphics and tracks and footprint graphics in the ...
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
#define LAST_NON_COPPER_LAYER
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static long hexParse(const char *next, const char **out=NULL)
Function hexParse parses an ASCII hex integer string with possible leading whitespace into a long int...
char * strtok_r(char *str, const char *delim, char **nextp)
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
#define FIRST_NON_COPPER_LAYER

References BOARD::Add(), PNS::angle(), APPEND, biuParse(), degParse(), delims, FIRST_NON_COPPER_LAYER, hexParse(), intParse(), LAST_NON_COPPER_LAYER, layerParse(), leg_layer2new(), m_board, m_cu_count, m_reader, NULL, READLINE, strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadPCB_TARGET()

void LEGACY_PLUGIN::loadPCB_TARGET ( )
protected

Definition at line 2890 of file legacy_plugin.cpp.

2891 {
2892  char* line;
2893 
2894  while( ( line = READLINE( m_reader ) ) != NULL )
2895  {
2896  const char* data;
2897 
2898  if( TESTLINE( "$EndPCB_TARGET" ) || TESTLINE( "$EndMIREPCB" ) )
2899  {
2900  return; // preferred exit
2901  }
2902 
2903  else if( TESTLINE( "Po" ) )
2904  {
2905  int shape = intParse( line + SZ( "Po" ), &data );
2906  LAYER_NUM layer_num = layerParse( data, &data );
2907  BIU pos_x = biuParse( data, &data );
2908  BIU pos_y = biuParse( data, &data );
2909  BIU size = biuParse( data, &data );
2910  BIU width = biuParse( data, &data );
2911  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2912 
2913  if( layer_num < FIRST_NON_COPPER_LAYER )
2914  layer_num = FIRST_NON_COPPER_LAYER;
2915 
2916  else if( layer_num > LAST_NON_COPPER_LAYER )
2917  layer_num = LAST_NON_COPPER_LAYER;
2918 
2919  PCB_TARGET* t = new PCB_TARGET( m_board, shape, leg_layer2new( m_cu_count, layer_num ),
2920  wxPoint( pos_x, pos_y ), size, width );
2921  m_board->Add( t, ADD_MODE::APPEND );
2922 
2923  const_cast<KIID&>( t->m_Uuid ) = KIID( uuid );
2924  }
2925  }
2926 
2927  THROW_IO_ERROR( "Missing '$EndDIMENSION'" );
2928 }
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
#define NULL
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
int LAYER_NUM
This can be replaced with int and removed.
const KIID m_Uuid
Definition: eda_item.h:151
#define LAST_NON_COPPER_LAYER
char * strtok_r(char *str, const char *delim, char **nextp)
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
#define FIRST_NON_COPPER_LAYER

References BOARD::Add(), APPEND, biuParse(), delims, FIRST_NON_COPPER_LAYER, intParse(), LAST_NON_COPPER_LAYER, layerParse(), leg_layer2new(), m_board, m_cu_count, m_reader, EDA_ITEM::m_Uuid, NULL, READLINE, strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadPCB_TEXT()

void LEGACY_PLUGIN::loadPCB_TEXT ( )
protected

Definition at line 2087 of file legacy_plugin.cpp.

2088 {
2089  /* examples:
2090  For a single line text:
2091  ----------------------
2092  $TEXTPCB
2093  Te "Text example"
2094  Po 66750 53450 600 800 150 0
2095  De 24 1 0 Italic
2096  $EndTEXTPCB
2097 
2098  For a multi line text:
2099  ---------------------
2100  $TEXTPCB
2101  Te "Text example"
2102  Nl "Line 2"
2103  Po 66750 53450 600 800 150 0
2104  De 24 1 0 Italic
2105  $EndTEXTPCB
2106  Nl "line nn" is a line added to the current text
2107  */
2108 
2109  char text[1024];
2110 
2111  // maybe someday a constructor that takes all this data in one call?
2112  PCB_TEXT* pcbtxt = new PCB_TEXT( m_board );
2113  m_board->Add( pcbtxt, ADD_MODE::APPEND );
2114 
2115  char* line;
2116 
2117  while( ( line = READLINE( m_reader ) ) != NULL )
2118  {
2119  const char* data;
2120 
2121  if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts)
2122  {
2123  ReadDelimitedText( text, line + SZ( "Te" ), sizeof(text) );
2124  pcbtxt->SetText( FROM_UTF8( text ) );
2125  }
2126 
2127  else if( TESTLINE( "nl" ) ) // next line of the current text
2128  {
2129  ReadDelimitedText( text, line + SZ( "nl" ), sizeof(text) );
2130  pcbtxt->SetText( pcbtxt->GetText() + wxChar( '\n' ) + FROM_UTF8( text ) );
2131  }
2132 
2133  else if( TESTLINE( "Po" ) )
2134  {
2135  wxSize size;
2136 
2137  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
2138  BIU pos_y = biuParse( data, &data );
2139  size.x = biuParse( data, &data );
2140  size.y = biuParse( data, &data );
2141  BIU thickn = biuParse( data, &data );
2142  double angle = degParse( data );
2143 
2144  pcbtxt->SetTextSize( size );
2145  pcbtxt->SetTextThickness( thickn );
2146  pcbtxt->SetTextAngle( angle );
2147 
2148  pcbtxt->SetTextPos( wxPoint( pos_x, pos_y ) );
2149  }
2150 
2151  else if( TESTLINE( "De" ) )
2152  {
2153  // e.g. "De 21 1 68183921-93a5-49ac-91b0-49d05a0e1647 Normal C\r\n"
2154  LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
2155  int notMirrored = intParse( data, &data );
2156  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2157  char* style = strtok_r( NULL, delims, (char**) &data );
2158  char* hJustify = strtok_r( NULL, delims, (char**) &data );
2159  char* vJustify = strtok_r( NULL, delims, (char**) &data );
2160 
2161  pcbtxt->SetMirrored( !notMirrored );
2162  const_cast<KIID&>( pcbtxt->m_Uuid ) = KIID( uuid );
2163  pcbtxt->SetItalic( !strcmp( style, "Italic" ) );
2164 
2165  if( hJustify )
2166  pcbtxt->SetHorizJustify( horizJustify( hJustify ) );
2167  else
2168  {
2169  // boom, somebody changed a constructor, I was relying on this:
2170  wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER );
2171  }
2172 
2173  if( vJustify )
2174  pcbtxt->SetVertJustify( vertJustify( vJustify ) );
2175 
2176  if( layer_num < FIRST_COPPER_LAYER )
2177  layer_num = FIRST_COPPER_LAYER;
2178  else if( layer_num > LAST_NON_COPPER_LAYER )
2179  layer_num = LAST_NON_COPPER_LAYER;
2180 
2181  if( layer_num >= FIRST_NON_COPPER_LAYER ||
2182  is_leg_copperlayer_valid( m_cu_count, layer_num ) )
2183  pcbtxt->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2184  else // not perfect, but putting this text on front layer is a workaround
2185  pcbtxt->SetLayer( F_Cu );
2186  }
2187 
2188  else if( TESTLINE( "$EndTEXTPCB" ) )
2189  {
2190  return; // preferred exit
2191  }
2192  }
2193 
2194  THROW_IO_ERROR( "Missing '$EndTEXTPCB'" );
2195 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:194
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
void SetTextAngle(double aAngle) override
Definition: pcb_text.cpp:100
void SetItalic(bool isItalic)
Definition: eda_text.h:185
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
#define READLINE(rdr)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
static EDA_TEXT_HJUSTIFY_T horizJustify(const char *horizontal)
bool is_leg_copperlayer_valid(int aCu_Count, LAYER_NUM aLegacyLayerNum)
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:120
#define NULL
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
int LAYER_NUM
This can be replaced with int and removed.
const KIID m_Uuid
Definition: eda_item.h:151
double degParse(const char *aValue, const char **nptrptr=NULL)
Function degParse parses an ASCII decimal floating point value which is certainly an angle.
static EDA_TEXT_VJUSTIFY_T vertJustify(const char *vertical)
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define LAST_NON_COPPER_LAYER
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
char * strtok_r(char *str, const char *delim, char **nextp)
#define FIRST_COPPER_LAYER
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:164
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
#define TESTLINE(x)
C string compare test for a specific length of characters.
#define FIRST_NON_COPPER_LAYER

References BOARD::Add(), PNS::angle(), APPEND, biuParse(), degParse(), delims, F_Cu, FIRST_COPPER_LAYER, FIRST_NON_COPPER_LAYER, FROM_UTF8(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetText(), GR_TEXT_HJUSTIFY_CENTER, horizJustify(), intParse(), is_leg_copperlayer_valid(), LAST_NON_COPPER_LAYER, layerParse(), leg_layer2new(), m_board, m_cu_count, m_reader, EDA_ITEM::m_Uuid, NULL, ReadDelimitedText(), READLINE, EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetText(), PCB_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), strtok_r(), SZ, TESTLINE, THROW_IO_ERROR, and vertJustify().

Referenced by loadAllSections().

◆ loadSETUP()

void LEGACY_PLUGIN::loadSETUP ( )
protected

Definition at line 833 of file legacy_plugin.cpp.

834 {
837  NETCLASS* netclass_default = bds.GetDefault();
838  char* line;
839  char* saveptr;
840 
842 
843  while( ( line = READLINE( m_reader ) ) != NULL )
844  {
845  const char* data;
846 
847  if( TESTLINE( "PcbPlotParams" ) )
848  {
849  PCB_PLOT_PARAMS plot_opts;
850 
851  PCB_PLOT_PARAMS_PARSER parser( line + SZ( "PcbPlotParams" ), m_reader->GetSource() );
852 
853  plot_opts.Parse( &parser );
854 
855  m_board->SetPlotOptions( plot_opts );
856  }
857 
858  else if( TESTLINE( "AuxiliaryAxisOrg" ) )
859  {
860  BIU gx = biuParse( line + SZ( "AuxiliaryAxisOrg" ), &data );
861  BIU gy = biuParse( data );
862 
863  // m_board->SetAuxOrigin( wxPoint( gx, gy ) ); gets overwritten by SetDesignSettings() below
864  bds.m_AuxOrigin = wxPoint( gx, gy );
865  }
866 
867  /* Done from $General above's "LayerCount"
868  else if( TESTLINE( "Layers" ) )
869  {
870  int tmp = intParse( line + SZ( "Layers" ) );
871  m_board->SetCopperLayerCount( tmp );
872 
873  m_cu_count = tmp;
874  }
875  */
876 
877  else if( TESTSUBSTR( "Layer[" ) )
878  {
879  // eg: "Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T>"
880 
881  LAYER_NUM layer_num = layerParse( line + SZ( "Layer[" ), &data );
882  PCB_LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
883 
884  /*
885  switch( layer_num )
886  {
887  case LAYER_N_BACK:
888  layer_id = B_Cu;
889  break;
890 
891  case LAYER_N_FRONT:
892  layer_id = F_Cu;
893  break;
894 
895  default:
896  layer_id = PCB_LAYER_ID( layer_num );
897  }
898  */
899 
900  data = strtok_r( (char*) data+1, delims, &saveptr ); // +1 for ']'
901 
902  if( data )
903  {
904  wxString layerName = FROM_UTF8( data );
905  m_board->SetLayerName( layer_id, layerName );
906 
907  data = strtok_r( NULL, delims, &saveptr );
908 
909  if( data ) // optional in old board files
910  {
911  LAYER_T type = LAYER::ParseType( data );
912  m_board->SetLayerType( layer_id, type );
913  }
914  }
915  }
916 
917  else if( TESTLINE( "TrackWidth" ) )
918  {
919  BIU tmp = biuParse( line + SZ( "TrackWidth" ) );
920  netclass_default->SetTrackWidth( tmp );
921  }
922 
923  else if( TESTLINE( "TrackWidthList" ) )
924  {
925  BIU tmp = biuParse( line + SZ( "TrackWidthList" ) );
926  bds.m_TrackWidthList.push_back( tmp );
927  }
928 
929  else if( TESTLINE( "TrackClearence" ) )
930  {
931  BIU tmp = biuParse( line + SZ( "TrackClearence" ) );
932  netclass_default->SetClearance( tmp );
933  }
934 
935  else if( TESTLINE( "TrackMinWidth" ) )
936  {
937  BIU tmp = biuParse( line + SZ( "TrackMinWidth" ) );
938  bds.m_TrackMinWidth = tmp;
939  }
940 
941  else if( TESTLINE( "ZoneClearence" ) )
942  {
943  BIU tmp = biuParse( line + SZ( "ZoneClearence" ) );
944  zs.m_ZoneClearance = tmp;
945  }
946 
947  else if( TESTLINE( "Zone_45_Only" ) )
948  {
949  bool tmp = (bool) intParse( line + SZ( "Zone_45_Only" ) );
950  zs.m_Zone_45_Only = tmp;
951  }
952 
953  else if( TESTLINE( "DrawSegmWidth" ) )
954  {
955  BIU tmp = biuParse( line + SZ( "DrawSegmWidth" ) );
956  bds.m_LineThickness[ LAYER_CLASS_COPPER ] = tmp;
957  }
958 
959  else if( TESTLINE( "EdgeSegmWidth" ) )
960  {
961  BIU tmp = biuParse( line + SZ( "EdgeSegmWidth" ) );
962  bds.m_LineThickness[ LAYER_CLASS_EDGES ] = tmp;
963  }
964 
965  else if( TESTLINE( "ViaMinSize" ) )
966  {
967  BIU tmp = biuParse( line + SZ( "ViaMinSize" ) );
968  bds.m_ViasMinSize = tmp;
969  }
970 
971  else if( TESTLINE( "MicroViaMinSize" ) )
972  {
973  BIU tmp = biuParse( line + SZ( "MicroViaMinSize" ) );
974  bds.m_MicroViasMinSize = tmp;
975  }
976 
977  else if( TESTLINE( "ViaSizeList" ) )
978  {
979  // e.g. "ViaSizeList DIAMETER [DRILL]"
980 
981  BIU drill = 0;
982  BIU diameter = biuParse( line + SZ( "ViaSizeList" ), &data );
983 
984  data = strtok_r( (char*) data, delims, (char**) &data );
985  if( data ) // DRILL may not be present ?
986  drill = biuParse( data );
987 
988  bds.m_ViasDimensionsList.emplace_back( diameter,
989  drill );
990  }
991 
992  else if( TESTLINE( "ViaSize" ) )
993  {
994  BIU tmp = biuParse( line + SZ( "ViaSize" ) );
995  netclass_default->SetViaDiameter( tmp );
996  }
997 
998  else if( TESTLINE( "ViaDrill" ) )
999  {
1000  BIU tmp = biuParse( line + SZ( "ViaDrill" ) );
1001  netclass_default->SetViaDrill( tmp );
1002  }
1003 
1004  else if( TESTLINE( "ViaMinDrill" ) )
1005  {
1006  BIU tmp = biuParse( line + SZ( "ViaMinDrill" ) );
1007  bds.m_MinThroughDrill = tmp;
1008  }
1009 
1010  else if( TESTLINE( "MicroViaSize" ) )
1011  {
1012  BIU tmp = biuParse( line + SZ( "MicroViaSize" ) );
1013  netclass_default->SetuViaDiameter( tmp );
1014  }
1015 
1016  else if( TESTLINE( "MicroViaDrill" ) )
1017  {
1018  BIU tmp = biuParse( line + SZ( "MicroViaDrill" ) );
1019  netclass_default->SetuViaDrill( tmp );
1020  }
1021 
1022  else if( TESTLINE( "MicroViaMinDrill" ) )
1023  {
1024  BIU tmp = biuParse( line + SZ( "MicroViaMinDrill" ) );
1025  bds.m_MicroViasMinDrill = tmp;
1026  }
1027 
1028  else if( TESTLINE( "MicroViasAllowed" ) )
1029  {
1030  int tmp = intParse( line + SZ( "MicroViasAllowed" ) );
1031  bds.m_MicroViasAllowed = tmp;
1032  }
1033 
1034  else if( TESTLINE( "TextPcbWidth" ) )
1035  {
1036  BIU tmp = biuParse( line + SZ( "TextPcbWidth" ) );
1037  bds.m_TextThickness[ LAYER_CLASS_COPPER ] = tmp;
1038  }
1039 
1040  else if( TESTLINE( "TextPcbSize" ) )
1041  {
1042  BIU x = biuParse( line + SZ( "TextPcbSize" ), &data );
1043  BIU y = biuParse( data );
1044 
1045  bds.m_TextSize[ LAYER_CLASS_COPPER ] = wxSize( x, y );
1046  }
1047 
1048  else if( TESTLINE( "EdgeModWidth" ) )
1049  {
1050  BIU tmp = biuParse( line + SZ( "EdgeModWidth" ) );
1051  bds.m_LineThickness[ LAYER_CLASS_SILK ] = tmp;
1052  bds.m_LineThickness[ LAYER_CLASS_OTHERS ] = tmp;
1053  }
1054 
1055  else if( TESTLINE( "TextModWidth" ) )
1056  {
1057  BIU tmp = biuParse( line + SZ( "TextModWidth" ) );
1058  bds.m_TextThickness[ LAYER_CLASS_SILK ] = tmp;
1059  bds.m_TextThickness[ LAYER_CLASS_OTHERS ] = tmp;
1060  }
1061 
1062  else if( TESTLINE( "TextModSize" ) )
1063  {
1064  BIU x = biuParse( line + SZ( "TextModSize" ), &data );
1065  BIU y = biuParse( data );
1066 
1067  bds.m_TextSize[ LAYER_CLASS_SILK ] = wxSize( x, y );
1068  bds.m_TextSize[ LAYER_CLASS_OTHERS ] = wxSize( x, y );
1069  }
1070 
1071  else if( TESTLINE( "PadSize" ) )
1072  {
1073  BIU x = biuParse( line + SZ( "PadSize" ), &data );
1074  BIU y = biuParse( data );
1075 
1076  bds.m_Pad_Master.SetSize( wxSize( x, y ) );
1077  }
1078 
1079  else if( TESTLINE( "PadDrill" ) )
1080  {
1081  BIU tmp = biuParse( line + SZ( "PadDrill" ) );
1082  bds.m_Pad_Master.SetDrillSize( wxSize( tmp, tmp ) );
1083  }
1084 
1085  else if( TESTLINE( "Pad2MaskClearance" ) )
1086  {
1087  BIU tmp = biuParse( line + SZ( "Pad2MaskClearance" ) );
1088  bds.m_SolderMaskMargin = tmp;
1089  }
1090 
1091  else if( TESTLINE( "SolderMaskMinWidth" ) )
1092  {
1093  BIU tmp = biuParse( line + SZ( "SolderMaskMinWidth" ) );
1094  bds.m_SolderMaskMinWidth = tmp;
1095  }
1096 
1097  else if( TESTLINE( "Pad2PasteClearance" ) )
1098  {
1099  BIU tmp = biuParse( line + SZ( "Pad2PasteClearance" ) );
1100  bds.m_SolderPasteMargin = tmp;
1101  }
1102 
1103  else if( TESTLINE( "Pad2PasteClearanceRatio" ) )
1104  {
1105  double ratio = atof( line + SZ( "Pad2PasteClearanceRatio" ) );
1106  bds.m_SolderPasteMarginRatio = ratio;
1107  }
1108 
1109  else if( TESTLINE( "GridOrigin" ) )
1110  {
1111  BIU x = biuParse( line + SZ( "GridOrigin" ), &data );
1112  BIU y = biuParse( data );
1113 
1114  // m_board->SetGridOrigin( wxPoint( x, y ) ); gets overwritten by SetDesignSettings() below
1115  bds.m_GridOrigin = wxPoint( x, y );
1116  }
1117 
1118  else if( TESTLINE( "VisibleElements" ) )
1119  {
1120  // Keep all elements visible.
1121  // the old visibility control does not make sense in current Pcbnew version,
1122  // and this code does not work.
1123  #if 0
1124  int visibleElements = hexParse( line + SZ( "VisibleElements" ) );
1125 
1126  // Does not work: each old item should be tested one by one to set
1127  // visibility of new item list
1128  GAL_SET visibles;
1129  for( size_t i = 0; i < visibles.size(); i++ )
1130  visibles.set( i, visibleElements & ( 1u << i ) );
1131 
1132  m_board->SetVisibleElements( visibles );
1133  #endif
1134  }
1135 
1136  else if( TESTLINE( "$EndSETUP" ) )
1137  {
1138  m_board->SetZoneSettings( zs );
1139 
1140  // Very old *.brd file does not have NETCLASSes
1141  // "TrackWidth", "ViaSize", "ViaDrill", "ViaMinSize", and "TrackClearence" were
1142  // defined in SETUP; these values are put into the default NETCLASS until later board
1143  // load code should override them. *.brd files which have been saved with knowledge
1144  // of NETCLASSes will override these defaults, very old boards (before 2009) will not
1145  // and use the setup values.
1146  // However these values should be the same as default NETCLASS.
1147 
1148  return; // preferred exit
1149  }
1150  }
1151 
1152  /*
1153  * Ensure tracks and vias sizes lists are ok:
1154  * Sort lists by by increasing value and remove duplicates
1155  * (the first value is not tested, because it is the netclass value)
1156  */
1157  BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings();
1158  sort( designSettings.m_ViasDimensionsList.begin() + 1, designSettings.m_ViasDimensionsList.end() );
1159  sort( designSettings.m_TrackWidthList.begin() + 1, designSettings.m_TrackWidthList.end() );
1160 
1161  for( unsigned ii = 1; ii < designSettings.m_ViasDimensionsList.size() - 1; ii++ )
1162  {
1163  if( designSettings.m_ViasDimensionsList[ii] == designSettings.m_ViasDimensionsList[ii + 1] )
1164  {
1165  designSettings.m_ViasDimensionsList.erase( designSettings.m_ViasDimensionsList.begin() + ii );
1166  ii--;
1167  }
1168  }
1169 
1170  for( unsigned ii = 1; ii < designSettings.m_TrackWidthList.size() - 1; ii++ )
1171  {
1172  if( designSettings.m_TrackWidthList[ii] == designSettings.m_TrackWidthList[ii + 1] )
1173  {
1174  designSettings.m_TrackWidthList.erase( designSettings.m_TrackWidthList.begin() + ii );
1175  ii--;
1176  }
1177  }
1178 }
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
Definition: class_board.h:563
wxPoint m_GridOrigin
origin for grid offsets
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition: class_board.h:317
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
PCB_PLOT_PARAMS_PARSER is the parser class for PCB_PLOT_PARAMS.
std::vector< int > m_TrackWidthList
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
#define READLINE(rdr)
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:240
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
void SetTrackWidth(int aWidth)
Definition: netclass.h:164
void SetViaDrill(int aSize)
Definition: netclass.h:172
wxSize m_TextSize[LAYER_CLASS_COUNT]
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
PCB_LAYER_ID
A quick note on layer IDs:
LINE_READER * m_reader
no ownership here.
int m_TextThickness[LAYER_CLASS_COUNT]
#define NULL
void SetClearance(int aClearance)
Definition: netclass.h:160
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:62
NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:49
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Helper for storing and iterating over GAL_LAYER_IDs.
void SetSize(const wxSize &aSize)
Definition: class_pad.h:230
LEGACY_PLUGIN::BIU BIU
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: class_board.h:577
void SetuViaDiameter(int aSize)
Definition: netclass.h:176
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
BOARD * m_board
which BOARD, no ownership here
int m_LineThickness[LAYER_CLASS_COUNT]
#define TESTSUBSTR(x)
C sub-string compare test for a specific length of characters.
int LAYER_NUM
This can be replaced with int and removed.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
void SetuViaDrill(int aSize)
Definition: netclass.h:180
static long hexParse(const char *next, const char **out=NULL)
Function hexParse parses an ASCII hex integer string with possible leading whitespace into a long int...
char * strtok_r(char *str, const char *delim, char **nextp)
NETCLASS * GetDefault() const
Function GetDefault.
void SetZoneSettings(const ZONE_SETTINGS &aSettings) override
Set the zone settings for this container.
Definition: class_board.h:568
std::vector< VIA_DIMENSION > m_ViasDimensionsList
void SetViaDiameter(int aDia)
Definition: netclass.h:168
bool m_MicroViasAllowed
true to allow micro vias
void Parse(PCB_PLOT_PARAMS_PARSER *aParser)
#define SZ(x)
Get the length of a string constant, at compile time.
#define TESTLINE(x)
C string compare test for a specific length of characters.
wxPoint m_AuxOrigin
origin for plot exports
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References biuParse(), delims, FROM_UTF8(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), LINE_READER::GetSource(), BOARD::GetZoneSettings(), hexParse(), intParse(), LAYER_CLASS_COPPER, LAYER_CLASS_EDGES, LAYER_CLASS_OTHERS, LAYER_CLASS_SILK, layerParse(), leg_layer2new(), BOARD_DESIGN_SETTINGS::m_AuxOrigin, m_board, m_cu_count, BOARD_DESIGN_SETTINGS::m_GridOrigin, BOARD::m_LegacyDesignSettingsLoaded, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, BOARD_DESIGN_SETTINGS::m_MicroViasMinDrill, BOARD_DESIGN_SETTINGS::m_MicroViasMinSize, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, BOARD_DESIGN_SETTINGS::m_Pad_Master, m_reader, BOARD_DESIGN_SETTINGS::m_SolderMaskMargin, BOARD_DESIGN_SETTINGS::m_SolderMaskMinWidth, BOARD_DESIGN_SETTINGS::m_SolderPasteMargin, BOARD_DESIGN_SETTINGS::m_SolderPasteMarginRatio, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, BOARD_DESIGN_SETTINGS::m_TrackWidthList, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, BOARD_DESIGN_SETTINGS::m_ViasMinSize, ZONE_SETTINGS::m_Zone_45_Only, ZONE_SETTINGS::m_ZoneClearance, NULL, PCB_PLOT_PARAMS::Parse(), LAYER::ParseType(), READLINE, GAL_SET::set(), NETCLASS::SetClearance(), D_PAD::SetDrillSize(), BOARD::SetLayerName(), BOARD::SetLayerType(), BOARD::SetPlotOptions(), D_PAD::SetSize(), NETCLASS::SetTrackWidth(), NETCLASS::SetuViaDiameter(), NETCLASS::SetuViaDrill(), NETCLASS::SetViaDiameter(), NETCLASS::SetViaDrill(), BOARD::SetVisibleElements(), BOARD::SetZoneSettings(), strtok_r(), SZ, TESTLINE, and TESTSUBSTR.

Referenced by loadAllSections().

◆ loadSHEET()

void LEGACY_PLUGIN::loadSHEET ( )
protected

Definition at line 688 of file legacy_plugin.cpp.

689 {
690  char buf[260];
691  TITLE_BLOCK tb;
692  char* line;
693  char* data;
694 
695  while( ( line = READLINE( m_reader ) ) != NULL )
696  {
697  if( TESTLINE( "Sheet" ) )
698  {
699  // e.g. "Sheet A3 16535 11700"
700  // width and height are in 1/1000th of an inch, always
701  PAGE_INFO page;
702  char* sname = strtok_r( line + SZ( "Sheet" ), delims, &data );
703 
704  if( sname )
705  {
706  wxString wname = FROM_UTF8( sname );
707 
708  if( !page.SetType( wname ) )
709  {
710  m_error.Printf( _( "Unknown sheet type \"%s\" on line:%d" ),
711  wname.GetData(),
712  m_reader->LineNumber() );
714  }
715 
716  char* width = strtok_r( NULL, delims, &data );
717  char* height = strtok_r( NULL, delims, &data );
718  char* orient = strtok_r( NULL, delims, &data );
719 
720  // only parse the width and height if page size is custom ("User")
721  if( wname == PAGE_INFO::Custom )
722  {
723  if( width && height )
724  {
725  // legacy disk file describes paper in mils
726  // (1/1000th of an inch)
727  int w = intParse( width );
728  int h = intParse( height );
729 
730  page.SetWidthMils( w );
731  page.SetHeightMils( h );
732  }
733  }
734 
735  if( orient && !strcmp( orient, "portrait" ) )
736  {
737  page.SetPortrait( true );
738  }
739 
740  m_board->SetPageSettings( page );
741  }
742  }
743 
744  else if( TESTLINE( "Title" ) )
745  {
746  ReadDelimitedText( buf, line, sizeof(buf) );
747  tb.SetTitle( FROM_UTF8( buf ) );
748  }
749 
750  else if( TESTLINE( "Date" ) )
751  {
752  ReadDelimitedText( buf, line, sizeof(buf) );
753  tb.SetDate( FROM_UTF8( buf ) );
754  }
755 
756  else if( TESTLINE( "Rev" ) )
757  {
758  ReadDelimitedText( buf, line, sizeof(buf) );
759  tb.SetRevision( FROM_UTF8( buf ) );
760  }
761 
762  else if( TESTLINE( "Comp" ) )
763  {
764  ReadDelimitedText( buf, line, sizeof(buf) );
765  tb.SetCompany( FROM_UTF8( buf ) );
766  }
767 
768  else if( TESTLINE( "Comment1" ) )
769  {
770  ReadDelimitedText( buf, line, sizeof(buf) );
771  tb.SetComment( 0, FROM_UTF8( buf ) );
772  }
773 
774  else if( TESTLINE( "Comment2" ) )
775  {
776  ReadDelimitedText( buf, line, sizeof(buf) );
777  tb.SetComment( 1, FROM_UTF8( buf ) );
778  }
779 
780  else if( TESTLINE( "Comment3" ) )
781  {
782  ReadDelimitedText( buf, line, sizeof(buf) );
783  tb.SetComment( 2, FROM_UTF8( buf ) );
784  }
785 
786  else if( TESTLINE( "Comment4" ) )
787  {
788  ReadDelimitedText( buf, line, sizeof(buf) );
789  tb.SetComment( 3, FROM_UTF8( buf ) );
790  }
791 
792  else if( TESTLINE( "Comment5" ) )
793  {
794  ReadDelimitedText( buf, line, sizeof(buf) );
795  tb.SetComment( 4, FROM_UTF8( buf ) );
796  }
797 
798  else if( TESTLINE( "Comment6" ) )
799  {
800  ReadDelimitedText( buf, line, sizeof(buf) );
801  tb.SetComment( 5, FROM_UTF8( buf ) );
802  }
803 
804  else if( TESTLINE( "Comment7" ) )
805  {
806  ReadDelimitedText( buf, line, sizeof(buf) );
807  tb.SetComment( 6, FROM_UTF8( buf ) );
808  }
809 
810  else if( TESTLINE( "Comment8" ) )
811  {
812  ReadDelimitedText( buf, line, sizeof(buf) );
813  tb.SetComment( 7, FROM_UTF8( buf ) );
814  }
815 
816  else if( TESTLINE( "Comment9" ) )
817  {
818  ReadDelimitedText( buf, line, sizeof(buf) );
819  tb.SetComment( 8, FROM_UTF8( buf ) );
820  }
821 
822  else if( TESTLINE( "$EndSHEETDESCR" ) )
823  {
824  m_board->SetTitleBlock( tb );
825  return; // preferred exit
826  }
827  }
828 
829  THROW_IO_ERROR( "Missing '$EndSHEETDESCR'" );
830 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
void SetRevision(const wxString &aRevision)
Definition: title_block.h:84
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: class_board.h:580
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: class_board.h:574
static const char delims[]
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:119
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Definition: title_block.h:74
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:79
#define READLINE(rdr)
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
LINE_READER * m_reader
no ownership here.
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:104
#define NULL
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:160
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetCompany(const wxString &aCompany)
Definition: title_block.h:94
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
BOARD * m_board
which BOARD, no ownership here
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
char * strtok_r(char *str, const char *delim, char **nextp)
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
void SetPortrait(bool aIsPortrait)
Function SetPortrait will rotate the paper page 90 degrees.
Definition: page_info.cpp:186
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References _, PAGE_INFO::Custom, delims, FROM_UTF8(), intParse(), LINE_READER::LineNumber(), m_board, m_error, m_reader, NULL, ReadDelimitedText(), READLINE, TITLE_BLOCK::SetComment(), TITLE_BLOCK::SetCompany(), TITLE_BLOCK::SetDate(), PAGE_INFO::SetHeightMils(), BOARD::SetPageSettings(), PAGE_INFO::SetPortrait(), TITLE_BLOCK::SetRevision(), TITLE_BLOCK::SetTitle(), BOARD::SetTitleBlock(), PAGE_INFO::SetType(), PAGE_INFO::SetWidthMils(), strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadTrackList()

void LEGACY_PLUGIN::loadTrackList ( int  aStructType)
protected

Function loadTrackList reads a list of segments (Tracks and Vias, or Segzones)

Parameters
aStructTypeis either PCB_TRACE_T to indicate tracks and vias, or NOT_USED to indicate oldschool zone segments (which are discarded).

Definition at line 2198 of file legacy_plugin.cpp.

2199 {
2200  char* line;
2201 
2202  while( ( line = READLINE( m_reader ) ) != NULL )
2203  {
2204  // read two lines per loop iteration, each loop is one TRACK or VIA
2205  // example first line:
2206  // e.g. "Po 0 23994 28800 24400 28800 150 -1" for a track
2207  // e.g. "Po 3 21086 17586 21086 17586 180 -1" for a via (uses sames start and end)
2208  const char* data;
2209 
2210  if( line[0] == '$' ) // $EndTRACK
2211  return; // preferred exit
2212 
2213  assert( TESTLINE( "Po" ) );
2214 
2215  VIATYPE viatype = static_cast<VIATYPE>( intParse( line + SZ( "Po" ), &data ) );
2216  BIU start_x = biuParse( data, &data );
2217  BIU start_y = biuParse( data, &data );
2218  BIU end_x = biuParse( data, &data );
2219  BIU end_y = biuParse( data, &data );
2220  BIU width = biuParse( data, &data );
2221 
2222  // optional 7th drill parameter (must be optional in an old format?)
2223  data = strtok_r( (char*) data, delims, (char**) &data );
2224 
2225  BIU drill = data ? biuParse( data ) : -1; // SetDefault() if < 0
2226 
2227  // Read the 2nd line to determine the exact type, one of:
2228  // PCB_TRACE_T, PCB_VIA_T, or PCB_SEGZONE_T. The type field in 2nd line
2229  // differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual
2230  // functions in use, it is critical to instantiate the PCB_VIA_T
2231  // exactly.
2232  READLINE( m_reader );
2233 
2234  line = m_reader->Line();
2235 
2236  // example second line:
2237  // "De 0 0 463 0 800000\r\n"
2238 
2239 #if 1
2240  assert( TESTLINE( "De" ) );
2241 #else
2242  if( !TESTLINE( "De" ) )
2243  {
2244  // mandatory 2nd line is missing
2245  THROW_IO_ERROR( "Missing 2nd line of a TRACK def" );
2246  }
2247 #endif
2248 
2249  int makeType;
2250 
2251  // parse the 2nd line to determine the type of object
2252  // e.g. "De 15 1 7 68183921-93a5-49ac-91b0-49d05a0e1647 0" for a via
2253  LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
2254  int type = intParse( data, &data );
2255  int net_code = intParse( data, &data );
2256  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2257  int flags_int = intParse( data, (const char**) &data );
2258 
2259  STATUS_FLAGS flags = static_cast<STATUS_FLAGS>( flags_int );
2260 
2261  if( aStructType == PCB_TRACE_T )
2262  {
2263  makeType = ( type == 1 ) ? PCB_VIA_T : PCB_TRACE_T;
2264  }
2265  else if (aStructType == NOT_USED )
2266  {
2267  continue;
2268  }
2269  else
2270  {
2271  wxFAIL_MSG( "Segment type unknown" );
2272  continue;
2273  }
2274 
2275  TRACK* newTrack;
2276 
2277  switch( makeType )
2278  {
2279  default:
2280  case PCB_TRACE_T: newTrack = new TRACK( m_board ); break;
2281  case PCB_VIA_T: newTrack = new VIA( m_board ); break;
2282  }
2283 
2284  const_cast<KIID&>( newTrack->m_Uuid ) = KIID( uuid );
2285  newTrack->SetPosition( wxPoint( start_x, start_y ) );
2286  newTrack->SetEnd( wxPoint( end_x, end_y ) );
2287 
2288  newTrack->SetWidth( width );
2289 
2290  if( makeType == PCB_VIA_T ) // Ensure layers are OK when possible:
2291  {
2292  VIA *via = static_cast<VIA*>( newTrack );
2293  via->SetViaType( viatype );
2294 
2295  if( drill < 0 )
2296  via->SetDrillDefault();
2297  else
2298  via->SetDrill( drill );
2299 
2300  if( via->GetViaType() == VIATYPE::THROUGH )
2301  via->SetLayerPair( F_Cu, B_Cu );
2302  else
2303  {
2304  PCB_LAYER_ID back = leg_layer2new( m_cu_count, (layer_num >> 4) & 0xf );
2305  PCB_LAYER_ID front = leg_layer2new( m_cu_count, layer_num & 0xf );
2306 
2307  if( is_leg_copperlayer_valid( m_cu_count, back ) &&
2309  via->SetLayerPair( front, back );
2310  else
2311  {
2312  delete via;
2313  newTrack = NULL;
2314  }
2315  }
2316  }
2317  else
2318  {
2319  // A few legacy boards can have tracks on non existent layers, because
2320  // reducing the number of layers does not remove tracks on removed layers
2321  // If happens, skip them
2322  if( is_leg_copperlayer_valid( m_cu_count, layer_num ) )
2323  newTrack->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2324  else
2325  {
2326  delete newTrack;
2327  newTrack = NULL;
2328  }
2329  }
2330 
2331  if( newTrack )
2332  {
2333  newTrack->SetNetCode( getNetCode( net_code ) );
2334  newTrack->SetState( flags, true );
2335 
2336  m_board->Add( newTrack );
2337  }
2338  }
2339 
2340  THROW_IO_ERROR( "Missing '$EndTRACK'" );
2341 }
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:140
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:112
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
the 3d code uses this value
Definition: typeinfo.h:80
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
bool SetNetCode(int aNetCode, bool aNoAssert)
Sets net using a net code.
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void SetWidth(int aWidth)
Definition: class_track.h:109
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
PCB_LAYER_ID
A quick note on layer IDs:
LINE_READER * m_reader
no ownership here.
bool is_leg_copperlayer_valid(int aCu_Count, LAYER_NUM aLegacyLayerNum)
#define NULL
VIATYPE
Definition: class_track.h:68
unsigned STATUS_FLAGS
Definition: eda_item.h:141
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer.
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: class_track.h:507
int LAYER_NUM
This can be replaced with int and removed.
const KIID m_Uuid
Definition: eda_item.h:151
void SetState(int type, int state)
Definition: eda_item.h:210
void SetPosition(const wxPoint &aPos) override
Definition: class_track.h:105
char * strtok_r(char *str, const char *delim, char **nextp)
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:486
VIATYPE GetViaType() const
Definition: class_track.h:384
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
#define SZ(x)
Get the length of a string constant, at compile time.
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:385
int getNetCode(int aNetCode)
Converts net code using the mapping table if available, otherwise returns unchanged net code
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.

References BOARD::Add(), B_Cu, biuParse(), delims, F_Cu, getNetCode(), VIA::GetViaType(), intParse(), is_leg_copperlayer_valid(), layerParse(), leg_layer2new(), LINE_READER::Line(), m_board, m_cu_count, m_reader, EDA_ITEM::m_Uuid, NOT_USED, NULL, PCB_TRACE_T, PCB_VIA_T, READLINE, VIA::SetDrill(), VIA::SetDrillDefault(), TRACK::SetEnd(), BOARD_ITEM::SetLayer(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), TRACK::SetPosition(), EDA_ITEM::SetState(), VIA::SetViaType(), TRACK::SetWidth(), strtok_r(), SZ, TESTLINE, THROUGH, THROW_IO_ERROR, TRACK, and VIA.

Referenced by loadAllSections().

◆ loadZONE_CONTAINER()

void LEGACY_PLUGIN::loadZONE_CONTAINER ( )
protected

Definition at line 2435 of file legacy_plugin.cpp.

2436 {
2437  std::unique_ptr<ZONE_CONTAINER> zc = std::make_unique<ZONE_CONTAINER>( m_board );
2438 
2440  bool endContour = false;
2441  int holeIndex = -1; // -1 is the main outline; holeIndex >= 0 = hole index
2442  char buf[1024];
2443  char* line;
2444 
2445  while( ( line = READLINE( m_reader ) ) != NULL )
2446  {
2447  const char* data;
2448 
2449  if( TESTLINE( "ZCorner" ) ) // new corner of the zone outlines found
2450  {
2451  // e.g. "ZCorner 25650 49500 0"
2452  BIU x = biuParse( line + SZ( "ZCorner" ), &data );
2453  BIU y = biuParse( data, &data );
2454 
2455  if( endContour )
2456  {
2457  // the previous corner was the last corner of a contour.
2458  // so this corner is the first of a new hole
2459  endContour = false;
2460  zc->NewHole();
2461  holeIndex++;
2462  }
2463 
2464  zc->AppendCorner( wxPoint( x, y ), holeIndex );
2465 
2466  // Is this corner the end of current contour?
2467  // the next corner (if any) will be stored in a new contour (a hole)
2468  // intParse( data )returns 0 = usual corner, 1 = last corner of the current contour:
2469  endContour = intParse( data );
2470  }
2471 
2472  else if( TESTLINE( "ZInfo" ) ) // general info found
2473  {
2474  // e.g. 'ZInfo 68183921-93a5-49ac-91b0-49d05a0e1647 310 "COMMON"'
2475  char* uuid = strtok_r( (char*) line + SZ( "ZInfo" ), delims, (char**) &data );
2476  int netcode = intParse( data, &data );
2477 
2478  if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) )
2479  THROW_IO_ERROR( "ZInfo netname too long" );
2480 
2481  const_cast<KIID&>( zc->m_Uuid ) = KIID( uuid );
2482  // Init the net code only, not the netname, to be sure
2483  // the zone net name is the name read in file.
2484  // (When mismatch, the user will be prompted in DRC, to fix the actual name)
2485  zc->BOARD_CONNECTED_ITEM::SetNetCode( getNetCode( netcode ) );
2486  }
2487 
2488  else if( TESTLINE( "ZLayer" ) ) // layer found
2489  {
2490  LAYER_NUM layer_num = layerParse( line + SZ( "ZLayer" ) );
2491  zc->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2492  }
2493 
2494  else if( TESTLINE( "ZAux" ) ) // aux info found
2495  {
2496  // e.g. "ZAux 7 E"
2497  int ignore = intParse( line + SZ( "ZAux" ), &data );
2498  char* hopt = strtok_r( (char*) data, delims, (char**) &data );
2499 
2500  if( !hopt )
2501  {
2502  m_error.Printf( _( "Bad ZAux for CZONE_CONTAINER \"%s\"" ),
2503  zc->GetNetname().GetData() );
2505  }
2506 
2507  switch( *hopt ) // upper case required
2508  {
2509  case 'N': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
2510  case 'E': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
2511  case 'F': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
2512  default:
2513  m_error.Printf( _( "Bad ZAux for CZONE_CONTAINER \"%s\"" ),
2514  zc->GetNetname().GetData() );
2516  }
2517 
2518  (void) ignore;
2519 
2520  // Set hatch mode later, after reading corner outline data
2521  }
2522 
2523  else if( TESTLINE( "ZSmoothing" ) )
2524  {
2525  // e.g. "ZSmoothing 0 0"
2526  int smoothing = intParse( line + SZ( "ZSmoothing" ), &data );
2527  BIU cornerRadius = biuParse( data );
2528 
2529  if( smoothing >= ZONE_SETTINGS::SMOOTHING_LAST || smoothing < 0 )
2530  {
2531  m_error.Printf( _( "Bad ZSmoothing for CZONE_CONTAINER \"%s\"" ),
2532  zc->GetNetname().GetData() );
2534  }
2535 
2536  zc->SetCornerSmoothingType( smoothing );
2537  zc->SetCornerRadius( cornerRadius );
2538  }
2539 
2540  else if( TESTLINE( "ZKeepout" ) )
2541  {
2542  char* token;
2543  zc->SetIsRuleArea( true );
2544  zc->SetDoNotAllowPads( false ); // Not supported in legacy
2545  zc->SetDoNotAllowFootprints( false ); // Not supported in legacy
2546 
2547  // e.g. "ZKeepout tracks N vias N pads Y"
2548  token = strtok_r( line + SZ( "ZKeepout" ), delims, (char**) &data );
2549 
2550  while( token )
2551  {
2552  if( !strcmp( token, "tracks" ) )
2553  {
2554  token = strtok_r( NULL, delims, (char**) &data );
2555  zc->SetDoNotAllowTracks( token && *token == 'N' );
2556  }
2557  else if( !strcmp( token, "vias" ) )
2558  {
2559  token = strtok_r( NULL, delims, (char**) &data );
2560  zc->SetDoNotAllowVias( token && *token == 'N' );
2561  }
2562  else if( !strcmp( token, "copperpour" ) )
2563  {
2564  token = strtok_r( NULL, delims, (char**) &data );
2565  zc->SetDoNotAllowCopperPour( token && *token == 'N' );
2566  }
2567 
2568  token = strtok_r( NULL, delims, (char**) &data );
2569  }
2570  }
2571 
2572  else if( TESTLINE( "ZOptions" ) )
2573  {
2574  // e.g. "ZOptions 0 32 F 200 200"
2575  int fillmode = intParse( line + SZ( "ZOptions" ), &data );
2576  static_cast<void>( intParse( data, &data ) ); // Ignored
2577  char fillstate = data[1]; // here e.g. " F"
2578  BIU thermalReliefGap = biuParse( data += 2 , &data ); // +=2 for " F"
2579  BIU thermalReliefCopperBridge = biuParse( data );
2580 
2581  if( fillmode)
2582  {
2583  // SEGMENT fill mode no longer supported. Make sure user is OK with converting them.
2585  {
2586  KIDIALOG dlg( nullptr,
2587  _( "The legacy segment fill mode is no longer supported.\n"
2588  "Convert zones to polygon fills?"),
2589  _( "Legacy Zone Warning" ),
2590  wxYES_NO | wxICON_WARNING );
2591 
2592  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2593 
2594  if( dlg.ShowModal() == wxID_NO )
2595  THROW_IO_ERROR( wxT( "CANCEL" ) );
2596 
2597  m_showLegacyZoneWarning = false;
2598  }
2599 
2600  // User OK'd; switch to polygon mode
2601  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2602  m_board->SetModified();
2603  }
2604  else
2605  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2606 
2607  zc->SetIsFilled( fillstate == 'S' );
2608  zc->SetThermalReliefGap( thermalReliefGap );
2609  zc->SetThermalReliefSpokeWidth( thermalReliefCopperBridge );
2610  }
2611 
2612  else if( TESTLINE( "ZClearance" ) ) // Clearance and pad options info found
2613  {
2614  // e.g. "ZClearance 40 I"
2615  BIU clearance = biuParse( line + SZ( "ZClearance" ), &data );
2616  char* padoption = strtok_r( (char*) data, delims, (char**) &data ); // data: " I"
2617 
2618  ZONE_CONNECTION popt;
2619  switch( *padoption )
2620  {
2621  case 'I': popt = ZONE_CONNECTION::FULL; break;
2622  case 'T': popt = ZONE_CONNECTION::THERMAL; break;
2623  case 'H': popt = ZONE_CONNECTION::THT_THERMAL; break;
2624  case 'X': popt = ZONE_CONNECTION::NONE; break;
2625  default:
2626  m_error.Printf( _( "Bad ZClearance padoption for CZONE_CONTAINER \"%s\"" ),
2627  zc->GetNetname().GetData() );
2629  }
2630 
2631  zc->SetLocalClearance( clearance );
2632  zc->SetPadConnection( popt );
2633  }
2634 
2635  else if( TESTLINE( "ZMinThickness" ) )
2636  {
2637  BIU thickness = biuParse( line + SZ( "ZMinThickness" ) );
2638  zc->SetMinThickness( thickness );
2639  }
2640 
2641  else if( TESTLINE( "ZPriority" ) )
2642  {
2643  int priority = intParse( line + SZ( "ZPriority" ) );
2644  zc->SetPriority( priority );
2645  }
2646 
2647  else if( TESTLINE( "$POLYSCORNERS" ) )
2648  {
2649  // Read the PolysList (polygons that are the solid areas in the filled zone)
2650  SHAPE_POLY_SET polysList;
2651 
2652  bool makeNewOutline = true;
2653 
2654  while( ( line = READLINE( m_reader ) ) != NULL )
2655  {
2656  if( TESTLINE( "$endPOLYSCORNERS" ) )
2657  break;
2658 
2659  // e.g. "39610 43440 0 0"
2660  BIU x = biuParse( line, &data );
2661  BIU y = biuParse( data, &data );
2662 
2663  if( makeNewOutline )
2664  polysList.NewOutline();
2665 
2666  polysList.Append( x, y );
2667 
2668  bool end_contour = intParse( data, &data ); // end_countour was a bool when file saved, so '0' or '1' here
2669  intParse( data ); // skip corner utility flag
2670 
2671  makeNewOutline = end_contour;
2672  }
2673 
2674  zc->SetFilledPolysList( zc->GetLayer(), polysList );
2675  }
2676 
2677  else if( TESTLINE( "$FILLSEGMENTS" ) )
2678  {
2679  while( ( line = READLINE( m_reader ) ) != NULL )
2680  {
2681  if( TESTLINE( "$endFILLSEGMENTS" ) )
2682  break;
2683 
2684  // e.g. ""%d %d %d %d\n"
2685  BIU sx = biuParse( line, &data );
2686  BIU sy = biuParse( data, &data );
2687  BIU ex = biuParse( data, &data );
2688  BIU ey = biuParse( data );
2689 
2690  zc->FillSegments( zc->GetLayer() )
2691  .push_back( SEG( VECTOR2I( sx, sy ), VECTOR2I( ex, ey ) ) );
2692  }
2693  }
2694 
2695  else if( TESTLINE( "$endCZONE_OUTLINE" ) )
2696  {
2697  // Ensure keepout does not have a net
2698  // (which have no sense for a keepout zone)
2699  if( zc->GetIsRuleArea() )
2700  zc->SetNetCode( NETINFO_LIST::UNCONNECTED );
2701 
2702  // should always occur, but who knows, a zone without two corners
2703  // is no zone at all, it's a spot?
2704 
2705  if( zc->GetNumCorners() > 2 )
2706  {
2707  if( !zc->IsOnCopperLayer() )
2708  {
2709  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2710  zc->SetNetCode( NETINFO_LIST::UNCONNECTED );
2711  }
2712 
2713  // HatchBorder here, after outlines corners are read
2714  // Set hatch here, after outlines corners are read
2715  zc->SetBorderDisplayStyle( outline_hatch, ZONE_CONTAINER::GetDefaultHatchPitch(),
2716  true );
2717 
2718  m_board->Add( zc.release() );
2719  }
2720 
2721  return; // preferred exit
2722  }
2723  }
2724 
2725  THROW_IO_ERROR( "Missing '$endCZONE_OUTLINE'" );
2726 }
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
void SetModified()
Definition: eda_item.cpp:79
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
bool m_showLegacyZoneWarning
static int intParse(const char *next, const char **out=NULL)
Function intParse parses an ASCII integer string with possible leading whitespace into an integer and...
static const char delims[]
static LAYER_NUM layerParse(const char *next, const char **out=NULL)
Function layerParse Like intParse but returns a LAYER_NUM.
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
BIU biuParse(const char *aValue, const char **nptrptr=NULL)
Function biuParse parses an ASCII decimal floating point value and scales it into a BIU according to ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
pads are covered by copper
#define NULL
SHAPE_POLY_SET.
LEGACY_PLUGIN::BIU BIU
int NewOutline()
Creates a new empty polygon in the set and returns its index
BOARD * m_board
which BOARD, no ownership here
Thermal relief only for THT pads.
int LAYER_NUM
This can be replaced with int and removed.
Definition: seg.h:39
Use thermal relief for pads.
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_error
for throwing exceptions
char * strtok_r(char *str, const char *delim, char **nextp)
Pads are not covered.
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
Definition: string.cpp:210
#define SZ(x)
Get the length of a string constant, at compile time.
int getNetCode(int aNetCode)
Converts net code using the mapping table if available, otherwise returns unchanged net code
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:478
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References _, BOARD::Add(), SHAPE_POLY_SET::Append(), biuParse(), delims, DIAGONAL_EDGE, DIAGONAL_FULL, KIDIALOG::DoNotShowCheckbox(), FULL, ZONE_CONTAINER::GetDefaultHatchPitch(), getNetCode(), intParse(), layerParse(), leg_layer2new(), m_board, m_cu_count, m_error, m_reader, m_showLegacyZoneWarning, SHAPE_POLY_SET::NewOutline(), NO_HATCH, NONE, NULL, POLYGONS, ReadDelimitedText(), READLINE, EDA_ITEM::SetModified(), KIDIALOG::ShowModal(), ZONE_SETTINGS::SMOOTHING_LAST, strtok_r(), SZ, TESTLINE, THERMAL, THROW_IO_ERROR, THT_THERMAL, and NETINFO_LIST::UNCONNECTED.

Referenced by loadAllSections().

◆ PluginName()

const wxString LEGACY_PLUGIN::PluginName ( ) const
inlineoverridevirtual

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

Implements PLUGIN.

Definition at line 69 of file legacy_plugin.h.

70  {
71  return wxT( "KiCad-Legacy" );
72  }

◆ 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.

Definition at line 69 of file plugin.cpp.

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

◆ Save()

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

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 in PCB_IO, and CLIPBOARD_IO.

Definition at line 54 of file plugin.cpp.

55 {
56  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
57  not_implemented( this, __FUNCTION__ );
58 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:39

References not_implemented().

Referenced by IO_MGR::Save().

◆ SaveModule3D()

void LEGACY_PLUGIN::SaveModule3D ( const MODULE aModule) const

Definition at line 3021 of file legacy_plugin.cpp.

3022 {
3023  auto sM = me->Models().begin();
3024  auto eM = me->Models().end();
3025 
3026  while( sM != eM )
3027  {
3028  if( sM->m_Filename.empty() )
3029  {
3030  ++sM;
3031  continue;
3032  }
3033 
3034  fprintf( m_fp, "$SHAPE3D\n" );
3035 
3036  fprintf( m_fp, "Na %s\n", EscapedUTF8( sM->m_Filename ).c_str() );
3037 
3038  fprintf(m_fp,
3039 #if defined(DEBUG)
3040  // use old formats for testing, just to verify compatibility
3041  // using "diff", then switch to more concise form for release builds.
3042  "Sc %lf %lf %lf\n",
3043 #else
3044  "Sc %.10g %.10g %.10g\n",
3045 #endif
3046  sM->m_Scale.x,
3047  sM->m_Scale.y,
3048  sM->m_Scale.z );
3049 
3050  fprintf(m_fp,
3051 #if defined(DEBUG)
3052  "Of %lf %lf %lf\n",
3053 #else
3054  "Of %.10g %.10g %.10g\n",
3055 #endif
3056  sM->m_Offset.x,
3057  sM->m_Offset.y,
3058  sM->m_Offset.z );
3059 
3060  fprintf(m_fp,
3061 #if defined(DEBUG)
3062  "Ro %lf %lf %lf\n",
3063 #else
3064  "Ro %.10g %.10g %.10g\n",
3065 #endif
3066  sM->m_Rotation.x,
3067  sM->m_Rotation.y,
3068  sM->m_Rotation.z );
3069 
3070  fprintf( m_fp, "$EndSHAPE3D\n" );
3071 
3072  ++sM;
3073  }
3074 }
FILE * m_fp
no ownership here.
std::string EscapedUTF8(wxString aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:304

References EscapedUTF8(), m_fp, and MODULE::Models().

◆ SetFilePtr()

void LEGACY_PLUGIN::SetFilePtr ( FILE *  aFile)
inline

Definition at line 103 of file legacy_plugin.h.

103 { m_fp = aFile; }
FILE * m_fp
no ownership here.

References m_fp.

◆ SetReader()

void LEGACY_PLUGIN::SetReader ( LINE_READER aReader)
inline

Definition at line 102 of file legacy_plugin.h.

102 { m_reader = aReader; }
LINE_READER * m_reader
no ownership here.

References m_reader.

Referenced by LP_CACHE::LoadModules().

Friends And Related Function Documentation

◆ LP_CACHE

friend struct LP_CACHE
friend

Definition at line 63 of file legacy_plugin.h.

Referenced by cacheLib().

Member Data Documentation

◆ biuToDisk

double LEGACY_PLUGIN::biuToDisk
protected

convert from BIUs to disk engineering units with this scale factor

Definition at line 135 of file legacy_plugin.h.

Referenced by init().

◆ diskToBiu

double LEGACY_PLUGIN::diskToBiu
protected

convert from disk engineering units to BIUs with this scale factor

Definition at line 138 of file legacy_plugin.h.

Referenced by biuParse(), init(), loadGENERAL(), and LP_CACHE::ReadAndVerifyHeader().

◆ m_board

◆ m_cache

LP_CACHE* LEGACY_PLUGIN::m_cache
protected

◆ m_cu_count

◆ m_error

wxString LEGACY_PLUGIN::m_error
protected

for throwing exceptions

Definition at line 116 of file legacy_plugin.h.

Referenced by biuParse(), checkVersion(), degParse(), loadMODULE_EDGE(), loadNETCLASS(), loadPAD(), loadSHEET(), and loadZONE_CONTAINER().

◆ m_field

wxString LEGACY_PLUGIN::m_field
protected

reused to stuff MODULE fields.

Definition at line 123 of file legacy_plugin.h.

Referenced by loadMODULE_TEXT().

◆ m_fp

FILE* LEGACY_PLUGIN::m_fp
protected

no ownership here.

Definition at line 121 of file legacy_plugin.h.

Referenced by SaveModule3D(), and SetFilePtr().

◆ m_loading_format_version

int LEGACY_PLUGIN::m_loading_format_version
protected

which BOARD_FORMAT_VERSION am I Load()ing?

Definition at line 124 of file legacy_plugin.h.

Referenced by checkVersion(), init(), and loadPAD().

◆ m_mapping

NETINFO_MAPPING* LEGACY_PLUGIN::m_mapping
protected

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

Definition at line 128 of file legacy_plugin.h.

Referenced by ~LEGACY_PLUGIN().

◆ m_netCodes

std::vector<int> LEGACY_PLUGIN::m_netCodes
protected

net codes mapping for boards being loaded

Definition at line 130 of file legacy_plugin.h.

Referenced by getNetCode(), loadGENERAL(), and loadNETINFO_ITEM().

◆ m_props

const PROPERTIES* LEGACY_PLUGIN::m_props
protected

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

Definition at line 118 of file legacy_plugin.h.

Referenced by init().

◆ m_reader

◆ m_showLegacyZoneWarning

bool LEGACY_PLUGIN::m_showLegacyZoneWarning
protected

Definition at line 126 of file legacy_plugin.h.

Referenced by init(), and loadZONE_CONTAINER().


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