KiCad PCB EDA Suite
LEGACY_PLUGIN Class Reference

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

 LEGACY_PLUGIN ()
 
 ~LEGACY_PLUGIN ()
 
const wxString PluginName () const override
 Return a brief hard coded name for this PLUGIN. More...
 
const wxString GetFileExtension () const override
 Returns the file extension for the PLUGIN. More...
 
BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
 Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one. More...
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
FOOTPRINTFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override
 Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Delete an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More...
 
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
 Return true if the library at aLibraryPath is writable. More...
 
void SetReader (LINE_READER *aReader)
 
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints ()
 Return a container with the cached library footprints generated in the last call to Load. More...
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr)
 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=nullptr)
 If possible, prefetches the specified library (e.g. More...
 
virtual const FOOTPRINTGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr)
 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=nullptr)
 Check for the existence of a footprint. More...
 
virtual void FootprintSave (const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const PROPERTIES *aProperties=nullptr)
 Write aFootprint to an existing library located at aLibraryPath. More...
 
virtual void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr)
 Delete aFootprintName from the library at aLibraryPath. More...
 
virtual void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Create a new empty footprint library at aLibraryPath empty. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Append 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...
 
void checkpoint ()
 Converts net code using the mapping table if available, otherwise returns unchanged net code. More...
 
int getNetCode (int aNetCode)
 
BIU biuParse (const char *aValue, const char **nptrptr=nullptr)
 Parse 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=nullptr)
 Parse 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 (FOOTPRINT *aFootprint)
 
void loadPAD (FOOTPRINT *aFootprint)
 
void loadMODULE_TEXT (FP_TEXT *aText)
 
void loadFP_SHAPE (FOOTPRINT *aFootprint)
 
void loadPCB_LINE ()
 
void loadNETINFO_ITEM ()
 
void loadPCB_TEXT ()
 
void loadNETCLASS ()
 
void loadFOOTPRINT (FOOTPRINT *aFootprint)
 
void loadTrackList (int aStructType)
 Read 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...
 
PROGRESS_REPORTERm_progressReporter
 may be NULL, no ownership More...
 
unsigned m_lastProgressLine
 
unsigned m_lineCount
 for progress reporting More...
 
LINE_READERm_reader
 no ownership here. More...
 
FILE * m_fp
 no ownership here. More...
 
wxString m_field
 reused to stuff FOOTPRINT fields. More...
 
int m_loading_format_version
 which BOARD_FORMAT_VERSION am I Load()ing? More...
 
LP_CACHEm_cache
 
bool m_showLegacyZoneWarning
 
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

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 58 of file legacy_plugin.h.

Member Typedef Documentation

◆ BIU

typedef int LEGACY_PLUGIN::BIU

Definition at line 95 of file legacy_plugin.h.

Constructor & Destructor Documentation

◆ LEGACY_PLUGIN()

LEGACY_PLUGIN::LEGACY_PLUGIN ( )

Definition at line 3251 of file legacy_plugin.cpp.

3251  :
3252  m_cu_count( 16 ), // for FootprintLoad()
3253  m_board( nullptr ),
3254  m_props( nullptr ),
3255  m_progressReporter( nullptr ),
3256  m_lastProgressLine( 0 ),
3257  m_lineCount( 0 ),
3258  m_reader( nullptr ),
3259  m_fp( nullptr ),
3260  m_cache( nullptr )
3261 {
3262  init( nullptr );
3263 }
FILE * m_fp
no ownership here.
unsigned m_lineCount
for progress reporting
LINE_READER * m_reader
no ownership here.
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
unsigned m_lastProgressLine
PROGRESS_REPORTER * m_progressReporter
may be NULL, no ownership
LP_CACHE * m_cache
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.

References init().

◆ ~LEGACY_PLUGIN()

LEGACY_PLUGIN::~LEGACY_PLUGIN ( )

Definition at line 3266 of file legacy_plugin.cpp.

3267 {
3268  delete m_cache;
3269 }
LP_CACHE * m_cache

References m_cache.

Member Function Documentation

◆ biuParse()

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

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

This function 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
the converted Board Internal Unit.

Definition at line 2795 of file legacy_plugin.cpp.

2796 {
2797  char* nptr;
2798 
2799  errno = 0;
2800 
2801  double fval = strtod( aValue, &nptr );
2802 
2803  if( errno )
2804  {
2805  m_error.Printf( _( "Invalid floating point number in file: '%s'\nline: %d, offset: %d" ),
2806  m_reader->GetSource().GetData(),
2807  m_reader->LineNumber(),
2808  aValue - m_reader->Line() + 1 );
2809 
2811  }
2812 
2813  if( aValue == nptr )
2814  {
2815  m_error.Printf( _( "Missing floating point number in file: '%s'\nline: %d, offset: %d" ),
2816  m_reader->GetSource().GetData(),
2817  m_reader->LineNumber(),
2818  aValue - m_reader->Line() + 1 );
2819 
2821  }
2822 
2823  if( nptrptr )
2824  *nptrptr = nptr;
2825 
2826  fval *= diskToBiu;
2827 
2828  // fval is up into the whole number realm here, and should be bounded
2829  // within INT_MIN to INT_MAX since BIU's are nanometers.
2830  return KiROUND( fval );
2831 }
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
Definition: richio.h:109
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
#define _(s)
double diskToBiu
convert from disk engineering units to BIUs with this scale factor
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:73
#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(), loadFOOTPRINT(), loadFP_SHAPE(), loadGENERAL(), 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 3144 of file legacy_plugin.cpp.

3145 {
3146  if( !m_cache || m_cache->m_lib_path != aLibraryPath || m_cache->IsModified() )
3147  {
3148  // a spectacular episode in memory management:
3149  delete m_cache;
3150  m_cache = new LP_CACHE( this, aLibraryPath );
3151  m_cache->Load();
3152  }
3153 }
friend struct LP_CACHE
Definition: legacy_plugin.h:60
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().

◆ checkpoint()

void LEGACY_PLUGIN::checkpoint ( )
protected

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

Definition at line 200 of file legacy_plugin.cpp.

201 {
202  const unsigned PROGRESS_DELTA = 250;
203 
204  if( m_progressReporter )
205  {
206  unsigned curLine = m_reader->LineNumber();
207 
208  if( curLine > m_lastProgressLine + PROGRESS_DELTA )
209  {
210  m_progressReporter->SetCurrentProgress( ( (double) curLine )
211  / std::max( 1U, m_lineCount ) );
212 
214  THROW_IO_ERROR( ( "Open cancelled by user." ) );
215 
216  m_lastProgressLine = curLine;
217  }
218  }
219 }
unsigned m_lineCount
for progress reporting
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
unsigned m_lastProgressLine
PROGRESS_REPORTER * m_progressReporter
may be NULL, no ownership
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).

References PROGRESS_REPORTER::KeepRefreshing(), LINE_READER::LineNumber(), m_lastProgressLine, m_lineCount, m_progressReporter, m_reader, PROGRESS_REPORTER::SetCurrentProgress(), and THROW_IO_ERROR.

Referenced by loadAllSections(), and loadTrackList().

◆ checkVersion()

void LEGACY_PLUGIN::checkVersion ( )
protected

Definition at line 576 of file legacy_plugin.cpp.

577 {
578  // Read first line and TEST if it is a PCB file format header like this:
579  // "PCBNEW-BOARD Version 1 ...."
580 
581  m_reader->ReadLine();
582 
583  char* line = m_reader->Line();
584 
585  if( !TESTLINE( "PCBNEW-BOARD" ) )
586  {
587  THROW_IO_ERROR( "Unknown file type" );
588  }
589 
590  int ver = 1; // if sccanf fails
591  sscanf( line, "PCBNEW-BOARD Version %d", &ver );
592 
593 #if !defined(DEBUG)
594  if( ver > LEGACY_BOARD_FILE_VERSION )
595  {
596  m_error.Printf( _( "File '%s' has an unrecognized version: %d." ),
597  m_reader->GetSource().GetData(),
598  ver );
600  }
601 #endif
602 
605 }
void SetFileFormatVersionAtLoad(int aVersion)
Definition: board.h:289
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
Definition: richio.h:109
int m_loading_format_version
which BOARD_FORMAT_VERSION am I Load()ing?
LINE_READER * m_reader
no ownership here.
#define _(s)
BOARD * m_board
which BOARD, no ownership here
virtual char * ReadLine()=0
Read a line of text into the buffer and increments the line number counter.
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, and THROW_IO_ERROR.

Referenced by Load().

◆ degParse()

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

Parse 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
the string converted to a primitive double type

Definition at line 2834 of file legacy_plugin.cpp.

2835 {
2836  char* nptr;
2837 
2838  errno = 0;
2839 
2840  double fval = strtod( aValue, &nptr );
2841 
2842  if( errno )
2843  {
2844  m_error.Printf( _( "Invalid floating point number in file: '%s'\nline: %d, offset: %d" ),
2845  m_reader->GetSource().GetData(),
2846  m_reader->LineNumber(),
2847  aValue - m_reader->Line() + 1 );
2848 
2850  }
2851 
2852  if( aValue == nptr )
2853  {
2854  m_error.Printf( _( "Missing floating point number in file: '%s'\nline: %d, offset: %d" ),
2855  m_reader->GetSource().GetData(),
2856  m_reader->LineNumber(),
2857  aValue - m_reader->Line() + 1 );
2858 
2860  }
2861 
2862  if( nptrptr )
2863  *nptrptr = nptr;
2864 
2865  return fval;
2866 }
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
Definition: richio.h:109
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
#define _(s)
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(), loadFP_SHAPE(), loadMODULE_TEXT(), loadPAD(), loadPCB_LINE(), and loadPCB_TEXT().

◆ FootprintDelete()

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

Delete aFootprintName from the library at aLibraryPath.

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

Reimplemented in PCB_PLUGIN, and GPCB_PLUGIN.

Definition at line 116 of file plugin.cpp.

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

References not_implemented().

◆ FootprintEnumerate()

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

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

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

Reimplemented from PLUGIN.

Definition at line 3156 of file legacy_plugin.cpp.

3158 {
3159  LOCALE_IO toggle; // toggles on, then off, the C locale.
3160  wxString errorMsg;
3161 
3162  init( aProperties );
3163 
3164  try
3165  {
3166  cacheLib( aLibPath );
3167  }
3168  catch( const IO_ERROR& ioe )
3169  {
3170  errorMsg = ioe.What();
3171  }
3172 
3173  // Some of the files may have been parsed correctly so we want to add the valid files to
3174  // the library.
3175 
3176  for( const auto& footprint : m_cache->m_footprints )
3177  aFootprintNames.Add( FROM_UTF8( footprint.first.c_str() ) );
3178 
3179  if( !errorMsg.IsEmpty() && !aBestEfforts )
3180  THROW_IO_ERROR( errorMsg );
3181 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
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:30
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
FOOTPRINT_MAP m_footprints
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
LP_CACHE * m_cache

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

◆ FootprintExists()

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

Check for the existence of a footprint.

Reimplemented in PCB_PLUGIN.

Definition at line 89 of file plugin.cpp.

91 {
92  // default implementation
93  return FootprintLoad( aLibraryPath, aFootprintName, true, aProperties ) != nullptr;
94 }
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
Definition: plugin.cpp:97

References PLUGIN::FootprintLoad().

◆ FootprintLibCreate()

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

Create a new empty footprint library at aLibraryPath empty.

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

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

Reimplemented in PCB_PLUGIN.

Definition at line 124 of file plugin.cpp.

125 {
126  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
127  not_implemented( this, __FUNCTION__ );
128 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Throw an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:38

References not_implemented().

◆ FootprintLibDelete()

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

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

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

Reimplemented from PLUGIN.

Definition at line 3209 of file legacy_plugin.cpp.

3211 {
3212  wxFileName fn = aLibraryPath;
3213 
3214  if( !fn.FileExists() )
3215  return false;
3216 
3217  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
3218  // we don't want that. we want bare metal portability with no UI here.
3219  if( wxRemove( aLibraryPath ) )
3220  {
3221  THROW_IO_ERROR( wxString::Format( _( "Footprint library '%s' cannot be deleted." ),
3222  aLibraryPath.GetData() ) );
3223  }
3224 
3225  if( m_cache && m_cache->m_lib_path == aLibraryPath )
3226  {
3227  delete m_cache;
3228  m_cache = nullptr;
3229  }
3230 
3231  return true;
3232 }
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
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

Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.

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

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

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

Reimplemented in EAGLE_PLUGIN.

Definition at line 147 of file plugin.cpp.

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

References _.

Referenced by EAGLE_PLUGIN::FootprintLibOptions().

◆ FootprintLoad()

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

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

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

Reimplemented from PLUGIN.

Definition at line 3184 of file legacy_plugin.cpp.

3187 {
3188  LOCALE_IO toggle; // toggles on, then off, the C locale.
3189 
3190  init( aProperties );
3191 
3192  cacheLib( aLibraryPath );
3193 
3194  const FOOTPRINT_MAP& footprints = m_cache->m_footprints;
3195  FOOTPRINT_MAP::const_iterator it = footprints.find( TO_UTF8( aFootprintName ) );
3196 
3197  if( it == footprints.end() )
3198  {
3199  return nullptr;
3200  }
3201 
3202  // Return copy of already loaded FOOTPRINT
3203  FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate();
3204  copy->SetParent( nullptr );
3205  return copy;
3206 }
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 TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
std::map< wxString, FOOTPRINT * > FOOTPRINT_MAP
Definition: eagle_parser.h:50
FOOTPRINT_MAP m_footprints
LP_CACHE * m_cache

References cacheLib(), copy, init(), m_cache, LP_CACHE::m_footprints, and TO_UTF8.

◆ FootprintSave()

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

Write aFootprint to an existing library located at aLibraryPath.

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

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

Reimplemented in PCB_PLUGIN.

Definition at line 108 of file plugin.cpp.

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

References not_implemented().

◆ GetEnumeratedFootprint()

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

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

Reimplemented in PCB_PLUGIN, and GPCB_PLUGIN.

Definition at line 80 of file plugin.cpp.

83 {
84  // default implementation
85  return FootprintLoad( aLibraryPath, aFootprintName, false, aProperties );
86 }
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
Definition: plugin.cpp:97

References PLUGIN::FootprintLoad().

◆ GetFileExtension()

const wxString LEGACY_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 71 of file legacy_plugin.h.

72  {
73  return wxT( "brd" );
74  }

◆ GetImportedCachedLibraryFootprints()

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

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

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

Returns
Footprints (caller owns the objects)

Reimplemented in EAGLE_PLUGIN, and CADSTAR_PCB_ARCHIVE_PLUGIN.

Definition at line 54 of file plugin.cpp.

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

References not_implemented().

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ GetLibraryTimestamp()

long long 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 3138 of file legacy_plugin.cpp.

3139 {
3140  return LP_CACHE::GetTimestamp( aLibraryPath );
3141 }
static long long GetTimestamp(const wxString &aLibPath)

References LP_CACHE::GetTimestamp().

◆ getNetCode()

int LEGACY_PLUGIN::getNetCode ( int  aNetCode)
inlineprotected

Definition at line 112 of file legacy_plugin.h.

113  {
114  if( (unsigned int) aNetCode < m_netCodes.size() )
115  return m_netCodes[aNetCode];
116 
117  return aNetCode;
118  }
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 2869 of file legacy_plugin.cpp.

2870 {
2872  m_cu_count = 16;
2873  m_board = nullptr;
2874  m_showLegacyZoneWarning = true;
2875  m_props = aProperties;
2876 
2877  // conversion factor for saving RAM BIUs to KICAD legacy file format.
2878  biuToDisk = 1.0/IU_PER_MM; // BIUs are nanometers & file is mm
2879 
2880  // Conversion factor for loading KICAD legacy file format into BIUs in RAM
2881  // Start by assuming the *.brd file is in deci-mils.
2882  // If we see "Units mm" in the $GENERAL section, set diskToBiu to 1000000.0
2883  // then, during the file loading process, to start a conversion from
2884  // mm to nanometers. The deci-mil legacy files have no such "Units" marker
2885  // so we must assume the file is in deci-mils until told otherwise.
2886 
2887  diskToBiu = IU_PER_MILS / 10; // BIUs are nanometers
2888 }
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
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:136
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, and m_showLegacyZoneWarning.

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

◆ IsFootprintLibWritable()

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

Return true if the library at aLibraryPath is writable.

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

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

Reimplemented from PLUGIN.

Definition at line 3235 of file legacy_plugin.cpp.

3236 {
3237 #if 0 // no support for 32 Cu layers in legacy format
3238  return false;
3239 #else
3240  LOCALE_IO toggle;
3241 
3242  init( nullptr );
3243 
3244  cacheLib( aLibraryPath );
3245 
3246  return m_cache->m_writable;
3247 #endif
3248 }
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
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, and LP_CACHE::m_writable.

◆ leg_layer2new()

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

Definition at line 303 of file legacy_plugin.cpp.

304 {
305  int newid;
306  unsigned old = aLayerNum;
307 
308  // this is a speed critical function, be careful.
309 
310  if( unsigned( old ) <= unsigned( LAYER_N_FRONT ) )
311  {
312  // In .brd files, the layers are numbered from back to front
313  // (the opposite of the .kicad_pcb files)
314  if( old == LAYER_N_FRONT )
315  {
316  newid = F_Cu;
317  }
318  else if( old == LAYER_N_BACK )
319  {
320  newid = B_Cu;
321  }
322  else
323  {
324  newid = cu_count - 1 - old;
325  wxASSERT( newid >= 0 );
326 
327  // This is of course incorrect, but at least it avoid crashing pcbnew:
328  if( newid < 0 )
329  newid = 0;
330  }
331  }
332  else
333  {
334  switch( old )
335  {
336  case ADHESIVE_N_BACK: newid = B_Adhes; break;
337  case ADHESIVE_N_FRONT: newid = F_Adhes; break;
338  case SOLDERPASTE_N_BACK: newid = B_Paste; break;
339  case SOLDERPASTE_N_FRONT: newid = F_Paste; break;
340  case SILKSCREEN_N_BACK: newid = B_SilkS; break;
341  case SILKSCREEN_N_FRONT: newid = F_SilkS; break;
342  case SOLDERMASK_N_BACK: newid = B_Mask; break;
343  case SOLDERMASK_N_FRONT: newid = F_Mask; break;
344  case DRAW_N: newid = Dwgs_User; break;
345  case COMMENT_N: newid = Cmts_User; break;
346  case ECO1_N: newid = Eco1_User; break;
347  case ECO2_N: newid = Eco2_User; break;
348  case EDGE_N: newid = Edge_Cuts; break;
349  default:
350  // Remap all illegal non copper layers to comment layer
351  newid = Cmts_User;
352  }
353  }
354 
355  return PCB_LAYER_ID( newid );
356 }
#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
#define ECO1_N
#define LAYER_N_FRONT
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
#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(), loadFOOTPRINT(), loadFP_SHAPE(), 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 359 of file legacy_plugin.cpp.

360 {
361  LSET ret;
362 
363  if( ( aMask & ALL_CU_LAYERS ) == ALL_CU_LAYERS )
364  {
365  ret = LSET::AllCuMask();
366 
367  aMask &= ~ALL_CU_LAYERS;
368  }
369 
370  for( int i=0; aMask; ++i, aMask >>= 1 )
371  {
372  if( aMask & 1 )
373  ret.set( leg_layer2new( cu_count, i ) );
374  }
375 
376  return ret;
377 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
#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 = nullptr,
PROJECT aProject = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
overridevirtual

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

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

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

Reimplemented from PLUGIN.

Definition at line 415 of file legacy_plugin.cpp.

418 {
419  LOCALE_IO toggle; // toggles on, then off, the C locale.
420 
421  init( aProperties );
422 
423  std::unique_ptr<BOARD> boardDeleter;
424 
425  if( aAppendToMe )
426  {
427  m_board = aAppendToMe;
428  }
429  else
430  {
431  boardDeleter = std::make_unique<BOARD>();
432  m_board = boardDeleter.get();
433  }
434 
435  // Give the filename to the board if it's new
436  if( !aAppendToMe )
437  m_board->SetFileName( aFileName );
438 
439  FILE_LINE_READER reader( aFileName );
440 
441  m_reader = &reader;
442  m_progressReporter = aProgressReporter;
443 
444  checkVersion();
445 
446  if( m_progressReporter )
447  {
448  m_lineCount = 0;
449 
450  m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
451 
453  THROW_IO_ERROR( ( "Open cancelled by user." ) );
454 
455  while( reader.ReadLine() )
456  m_lineCount++;
457 
458  reader.Rewind();
459  }
460 
461  loadAllSections( bool( aAppendToMe ) );
462 
463  ignore_unused( boardDeleter.release() ); // give it up so we dont delete it on exit
464  m_progressReporter = nullptr;
465  return m_board;
466 }
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
unsigned m_lineCount
for progress reporting
LINE_READER * m_reader
no ownership here.
A LINE_READER that reads from an open file.
Definition: richio.h:172
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
#define _(s)
void SetFileName(const wxString &aFileName)
Definition: board.h:227
BOARD * m_board
which BOARD, no ownership here
void loadAllSections(bool doAppend)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
PROGRESS_REPORTER * m_progressReporter
may be NULL, no ownership
void ignore_unused(const T &)
Definition: ignore.h:24
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, checkVersion(), Format(), ignore_unused(), init(), PROGRESS_REPORTER::KeepRefreshing(), loadAllSections(), m_board, m_lineCount, m_progressReporter, m_reader, FILE_LINE_READER::ReadLine(), PROGRESS_REPORTER::Report(), FILE_LINE_READER::Rewind(), BOARD::SetFileName(), and THROW_IO_ERROR.

◆ load3D()

void LEGACY_PLUGIN::load3D ( FOOTPRINT aFootprint)
protected

Definition at line 1777 of file legacy_plugin.cpp.

1778 {
1779  FP_3DMODEL t3D;
1780 
1781  char* line;
1782 
1783  while( ( line = READLINE( m_reader ) ) != nullptr )
1784  {
1785  if( TESTLINE( "Na" ) ) // Shape File Name
1786  {
1787  char buf[512];
1788  ReadDelimitedText( buf, line + SZ( "Na" ), sizeof(buf) );
1789  t3D.m_Filename = buf;
1790  }
1791  else if( TESTLINE( "Sc" ) ) // Scale
1792  {
1793  sscanf( line + SZ( "Sc" ), "%lf %lf %lf\n", &t3D.m_Scale.x, &t3D.m_Scale.y,
1794  &t3D.m_Scale.z );
1795  }
1796  else if( TESTLINE( "Of" ) ) // Offset
1797  {
1798  sscanf( line + SZ( "Of" ), "%lf %lf %lf\n", &t3D.m_Offset.x, &t3D.m_Offset.y,
1799  &t3D.m_Offset.z );
1800  }
1801  else if( TESTLINE( "Ro" ) ) // Rotation
1802  {
1803  sscanf( line + SZ( "Ro" ), "%lf %lf %lf\n", &t3D.m_Rotation.x, &t3D.m_Rotation.y,
1804  &t3D.m_Rotation.z );
1805  }
1806  else if( TESTLINE( "$EndSHAPE3D" ) )
1807  {
1808  aFootprint->Models().push_back( t3D );
1809  return; // preferred exit
1810  }
1811  }
1812 
1813  THROW_IO_ERROR( "Missing '$EndSHAPE3D'" );
1814 }
std::list< FP_3DMODEL > & Models()
Definition: footprint.h:182
#define READLINE(rdr)
VECTOR3D m_Offset
3D model offset (mm)
Definition: footprint.h:95
LINE_READER * m_reader
no ownership here.
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: footprint.h:93
wxString m_Filename
The 3D shape filename in 3D library.
Definition: footprint.h:97
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: footprint.h:94
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#define TESTLINE(x)
C string compare test for a specific length of characters.

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

Referenced by loadFOOTPRINT().

◆ loadAllSections()

void LEGACY_PLUGIN::loadAllSections ( bool  doAppend)
protected

Definition at line 469 of file legacy_plugin.cpp.

470 {
471  // $GENERAL section is first
472 
473  // $SHEETDESCR section is next
474 
475  // $SETUP section is next
476 
477  // Then follows $EQUIPOT and all the rest
478  char* line;
479 
480  while( ( line = READLINE( m_reader ) ) != nullptr )
481  {
482  checkpoint();
483 
484  // put the more frequent ones at the top, but realize TRACKs are loaded as a group
485 
486  if( TESTLINE( "$MODULE" ) )
487  {
488  std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( m_board );
489 
490  LIB_ID fpid;
491  std::string fpName = StrPurge( line + SZ( "$MODULE" ) );
492 
493  // The footprint names in legacy libraries can contain the '/' and ':'
494  // characters which will cause the FPID parser to choke.
495  ReplaceIllegalFileNameChars( &fpName );
496 
497  if( !fpName.empty() )
498  fpid.Parse( fpName, true );
499 
500  footprint->SetFPID( fpid );
501 
502  loadFOOTPRINT( footprint.get());
503  m_board->Add( footprint.release(), ADD_MODE::APPEND );
504  }
505  else if( TESTLINE( "$DRAWSEGMENT" ) )
506  {
507  loadPCB_LINE();
508  }
509  else if( TESTLINE( "$EQUIPOT" ) )
510  {
512  }
513  else if( TESTLINE( "$TEXTPCB" ) )
514  {
515  loadPCB_TEXT();
516  }
517  else if( TESTLINE( "$TRACK" ) )
518  {
520  }
521  else if( TESTLINE( "$NCLASS" ) )
522  {
523  loadNETCLASS();
524  }
525  else if( TESTLINE( "$CZONE_OUTLINE" ) )
526  {
528  }
529  else if( TESTLINE( "$COTATION" ) )
530  {
531  loadDIMENSION();
532  }
533  else if( TESTLINE( "$PCB_TARGET" ) || TESTLINE( "$MIREPCB" ) )
534  {
535  loadPCB_TARGET();
536  }
537  else if( TESTLINE( "$ZONE" ) )
538  {
539  // No longer supported; discard segment fills
541  }
542  else if( TESTLINE( "$GENERAL" ) )
543  {
544  loadGENERAL();
545  }
546  else if( TESTLINE( "$SHEETDESCR" ) )
547  {
548  loadSHEET();
549  }
550  else if( TESTLINE( "$SETUP" ) )
551  {
552  if( !doAppend )
553  {
554  loadSETUP();
555  }
556  else
557  {
558  while( ( line = READLINE( m_reader ) ) != nullptr )
559  {
560  // gobble until $EndSetup
561  if( TESTLINE( "$EndSETUP" ) )
562  break;
563  }
564  }
565  }
566  else if( TESTLINE( "$EndBOARD" ) )
567  {
568  return; // preferred exit
569  }
570  }
571 
572  THROW_IO_ERROR( "Missing '$EndBOARD'" );
573 }
the 3d code uses this value
Definition: typeinfo.h:79
#define READLINE(rdr)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
LINE_READER * m_reader
no ownership here.
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
BOARD * m_board
which BOARD, no ownership here
void checkpoint()
Converts net code using the mapping table if available, otherwise returns unchanged net code.
void loadFOOTPRINT(FOOTPRINT *aFootprint)
void loadZONE_CONTAINER()
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:49
#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)
Read a list of segments (Tracks and Vias, or Segzones)

References BOARD::Add(), APPEND, checkpoint(), loadDIMENSION(), loadFOOTPRINT(), loadGENERAL(), loadNETCLASS(), loadNETINFO_ITEM(), loadPCB_LINE(), loadPCB_TARGET(), loadPCB_TEXT(), loadSETUP(), loadSHEET(), loadTrackList(), loadZONE_CONTAINER(), m_board, m_reader, NOT_USED, 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 2622 of file legacy_plugin.cpp.

2623 {
2624  std::unique_ptr<PCB_DIM_ALIGNED> dim = std::make_unique<PCB_DIM_ALIGNED>( m_board );
2625 
2626  char* line;
2627 
2628  while( ( line = READLINE( m_reader ) ) != nullptr )
2629  {
2630  const char* data;
2631 
2632  if( TESTLINE( "$endCOTATION" ) )
2633  {
2634  m_board->Add( dim.release(), ADD_MODE::APPEND );
2635  return; // preferred exit
2636  }
2637  else if( TESTLINE( "Va" ) )
2638  {
2639  BIU value = biuParse( line + SZ( "Va" ) );
2640 
2641  // unused; dimension value is calculated from coordinates
2642  ( void )value;
2643  }
2644  else if( TESTLINE( "Ge" ) )
2645  {
2646  // e.g. "Ge 1 21 68183921-93a5-49ac-91b0-49d05a0e1647\r\n"
2647  int shape = intParse( line + SZ( "De" ), (const char**) &data );
2648  LAYER_NUM layer_num = layerParse( data, &data );
2649  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2650 
2651  dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2652  const_cast<KIID&>( dim->m_Uuid ) = KIID( uuid );
2653 
2654  // not used
2655  ( void )shape;
2656  }
2657  else if( TESTLINE( "Te" ) )
2658  {
2659  char buf[2048];
2660 
2661  ReadDelimitedText( buf, line + SZ( "Te" ), sizeof(buf) );
2662  dim->SetText( FROM_UTF8( buf ) );
2663  }
2664  else if( TESTLINE( "Po" ) )
2665  {
2666  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
2667  BIU pos_y = biuParse( data, &data );
2668  BIU width = biuParse( data, &data );
2669  BIU height = biuParse( data, &data );
2670  BIU thickn = biuParse( data, &data );
2671  double orient = degParse( data, &data );
2672  char* mirror = strtok_r( (char*) data, delims, (char**) &data );
2673 
2674  // This sets both DIMENSION's position and internal m_Text's.
2675  // @todo: But why do we even know about internal m_Text?
2676  dim->SetPosition( wxPoint( pos_x, pos_y ) );
2677  dim->SetTextSize( wxSize( width, height ) );
2678 
2679  dim->Text().SetMirrored( mirror && *mirror == '0' );
2680  dim->Text().SetTextThickness( thickn );
2681  dim->Text().SetTextAngle( orient );
2682  }
2683  else if( TESTLINE( "Sb" ) )
2684  {
2685  ignore_unused( biuParse( line + SZ( "Sb" ), &data ) );
2686  BIU crossBarOx = biuParse( data, &data );
2687  BIU crossBarOy = biuParse( data, &data );
2688  BIU crossBarFx = biuParse( data, &data );
2689  BIU crossBarFy = biuParse( data, &data );
2690  BIU width = biuParse( data );
2691 
2692  dim->SetLineThickness( width );
2693  dim->UpdateHeight( wxPoint( crossBarFx, crossBarFy ),
2694  wxPoint( crossBarOx, crossBarOy ) );
2695  }
2696  else if( TESTLINE( "Sd" ) )
2697  {
2698  ignore_unused( intParse( line + SZ( "Sd" ), &data ) );
2699  BIU featureLineDOx = biuParse( data, &data );
2700  BIU featureLineDOy = biuParse( data, &data );
2701 
2702  ignore_unused( biuParse( data, &data ) );
2703  ignore_unused( biuParse( data ) );
2704 
2705  dim->SetStart( wxPoint( featureLineDOx, featureLineDOy ) );
2706  }
2707  else if( TESTLINE( "Sg" ) )
2708  {
2709  ignore_unused( intParse( line + SZ( "Sg" ), &data ) );
2710  BIU featureLineGOx = biuParse( data, &data );
2711  BIU featureLineGOy = biuParse( data, &data );
2712 
2713  ignore_unused( biuParse( data, &data ) );
2714  ignore_unused( biuParse( data ) );
2715 
2716  dim->SetEnd( wxPoint( featureLineGOx, featureLineGOy ) );
2717  }
2718  else if( TESTLINE( "S1" ) ) // Arrow: no longer imported
2719  {
2720  ignore_unused( intParse( line + SZ( "S1" ), &data ) );
2721  biuParse( data, &data ); // skipping excessive data
2722  biuParse( data, &data ); // skipping excessive data
2723  biuParse( data, &data );
2724  biuParse( data );
2725  }
2726  else if( TESTLINE( "S2" ) ) // Arrow: no longer imported
2727  {
2728  ignore_unused( intParse( line + SZ( "S2" ), &data ) );
2729  biuParse( data, &data ); // skipping excessive data
2730  biuParse( data, &data ); // skipping excessive data
2731  biuParse( data, &data );
2732  biuParse( data, &data );
2733  }
2734  else if( TESTLINE( "S3" ) ) // Arrow: no longer imported
2735  {
2736  ignore_unused( intParse( line + SZ( "S3" ), &data ) );
2737  biuParse( data, &data ); // skipping excessive data
2738  biuParse( data, &data ); // skipping excessive data
2739  biuParse( data, &data );
2740  biuParse( data, &data );
2741  }
2742  else if( TESTLINE( "S4" ) ) // Arrow: no longer imported
2743  {
2744  ignore_unused( intParse( line + SZ( "S4" ), &data ) );
2745  biuParse( data, &data ); // skipping excessive data
2746  biuParse( data, &data ); // skipping excessive data
2747  biuParse( data, &data );
2748  biuParse( data, &data );
2749  }
2750  }
2751 
2752  THROW_IO_ERROR( "Missing '$endCOTATION'" );
2753 }
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
char * strtok_r(char *str, const char *delim, char **nextp)
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
void ignore_unused(const T &)
Definition: ignore.h:24
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#define TESTLINE(x)
C string compare test for a specific length of characters.

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

Referenced by loadAllSections().

◆ loadFOOTPRINT()

void LEGACY_PLUGIN::loadFOOTPRINT ( FOOTPRINT aFootprint)
protected

Definition at line 1140 of file legacy_plugin.cpp.

1141 {
1142  char* line;
1143 
1144  while( ( line = READLINE( m_reader ) ) != nullptr )
1145  {
1146  const char* data;
1147 
1148  // most frequently encountered ones at the top
1149 
1150  if( TESTSUBSTR( "D" ) && strchr( "SCAP", line[1] ) ) // read a drawing item, e.g. "DS"
1151  {
1152  loadFP_SHAPE( aFootprint );
1153  }
1154  else if( TESTLINE( "$PAD" ) )
1155  {
1156  loadPAD( aFootprint );
1157  }
1158  else if( TESTSUBSTR( "T" ) ) // Read a footprint text description (ref, value, or drawing)
1159  {
1160  // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n"
1161  int tnum = intParse( line + SZ( "T" ) );
1162 
1163  FP_TEXT* text = nullptr;
1164 
1165  switch( tnum )
1166  {
1168  text = &aFootprint->Reference();
1169  break;
1170 
1172  text = &aFootprint->Value();
1173  break;
1174 
1175  // All other fields greater than 1.
1176  default:
1177  text = new FP_TEXT( aFootprint );
1178  aFootprint->Add( text );
1179  }
1180 
1181  loadMODULE_TEXT( text );
1182  }
1183  else if( TESTLINE( "Po" ) )
1184  {
1185  // e.g. "Po 19120 39260 900 0 4E823D06 68183921-93a5-49ac-91b0-49d05a0e1647 ~~\r\n"
1186  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
1187  BIU pos_y = biuParse( data, &data );
1188  int orient = intParse( data, &data );
1189  LAYER_NUM layer_num = layerParse( data, &data );
1190  PCB_LAYER_ID layer_id = leg_layer2new( m_cu_count, layer_num );
1191  long edittime = hexParse( data, &data );
1192  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
1193 
1194  data = strtok_r( (char*) data+1, delims, (char**) &data );
1195 
1196  // data is now a two character long string
1197  // Note: some old files do not have this field
1198  if( data && data[0] == 'F' )
1199  aFootprint->SetLocked( true );
1200 
1201  if( data && data[1] == 'P' )
1202  aFootprint->SetIsPlaced( true );
1203 
1204  aFootprint->SetPosition( wxPoint( pos_x, pos_y ) );
1205  aFootprint->SetLayer( layer_id );
1206  aFootprint->SetOrientation( orient );
1207  const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid );
1208  aFootprint->SetLastEditTime( edittime );
1209  }
1210  else if( TESTLINE( "Sc" ) ) // timestamp
1211  {
1212  char* uuid = strtok_r( (char*) line + SZ( "Sc" ), delims, (char**) &data );
1213  const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid );
1214  }
1215  else if( TESTLINE( "Op" ) ) // (Op)tions for auto placement
1216  {
1217  int itmp1 = hexParse( line + SZ( "Op" ), &data );
1218  int itmp2 = hexParse( data );
1219 
1220  int cntRot180 = itmp2 & 0x0F;
1221 
1222  if( cntRot180 > 10 )
1223  cntRot180 = 10;
1224 
1225  aFootprint->SetPlacementCost180( cntRot180 );
1226 
1227  int cntRot90 = itmp1 & 0x0F;
1228 
1229  if( cntRot90 > 10 )
1230  cntRot90 = 0;
1231 
1232  itmp1 = (itmp1 >> 4) & 0x0F;
1233 
1234  if( itmp1 > 10 )
1235  itmp1 = 0;
1236 
1237  aFootprint->SetPlacementCost90((itmp1 << 4) | cntRot90 );
1238  }
1239  else if( TESTLINE( "At" ) ) // (At)tributes of footprint
1240  {
1241  int attrs = 0;
1242 
1243  data = line + SZ( "At" );
1244 
1245  if( strstr( data, "SMD" ) )
1246  attrs |= FP_SMD;
1247  else if( strstr( data, "VIRTUAL" ) )
1249  else
1251 
1252  aFootprint->SetAttributes( attrs );
1253  }
1254  else if( TESTLINE( "AR" ) ) // Alternate Reference
1255  {
1256  // e.g. "AR /68183921-93a5-49ac-e164-49d05a0e1647/93a549d0-49d0-e164-91b0-49d05a0e1647"
1257  data = strtok_r( line + SZ( "AR" ), delims, (char**) &data );
1258 
1259  if( data )
1260  aFootprint->SetPath( KIID_PATH( FROM_UTF8( data ) ) );
1261  }
1262  else if( TESTLINE( "$SHAPE3D" ) )
1263  {
1264  load3D( aFootprint );
1265  }
1266  else if( TESTLINE( "Cd" ) )
1267  {
1268  // e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n"
1269  aFootprint->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) );
1270  }
1271  else if( TESTLINE( "Kw" ) ) // Key words
1272  {
1273  aFootprint->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) );
1274  }
1275  else if( TESTLINE( ".SolderPasteRatio" ) )
1276  {
1277  double tmp = atof( line + SZ( ".SolderPasteRatio" ) );
1278 
1279  // Due to a bug in dialog editor in Footprint Editor, fixed in BZR version 3565
1280  // this parameter can be broken.
1281  // It should be >= -50% (no solder paste) and <= 0% (full area of the pad)
1282 
1283  if( tmp < -0.50 )
1284  tmp = -0.50;
1285 
1286  if( tmp > 0.0 )
1287  tmp = 0.0;
1288 
1289  aFootprint->SetLocalSolderPasteMarginRatio( tmp );
1290  }
1291  else if( TESTLINE( ".SolderPaste" ) )
1292  {
1293  BIU tmp = biuParse( line + SZ( ".SolderPaste" ) );
1294  aFootprint->SetLocalSolderPasteMargin( tmp );
1295  }
1296  else if( TESTLINE( ".SolderMask" ) )
1297  {
1298  BIU tmp = biuParse( line + SZ( ".SolderMask" ) );
1299  aFootprint->SetLocalSolderMaskMargin( tmp );
1300  }
1301  else if( TESTLINE( ".LocalClearance" ) )
1302  {
1303  BIU tmp = biuParse( line + SZ( ".LocalClearance" ) );
1304  aFootprint->SetLocalClearance( tmp );
1305  }
1306  else if( TESTLINE( ".ZoneConnection" ) )
1307  {
1308  int tmp = intParse( line + SZ( ".ZoneConnection" ) );
1309  aFootprint->SetZoneConnection((ZONE_CONNECTION) tmp );
1310  }
1311  else if( TESTLINE( ".ThermalWidth" ) )
1312  {
1313  BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) );
1314  aFootprint->SetThermalWidth( tmp );
1315  }
1316  else if( TESTLINE( ".ThermalGap" ) )
1317  {
1318  BIU tmp = biuParse( line + SZ( ".ThermalGap" ) );
1319  aFootprint->SetThermalGap( tmp );
1320  }
1321  else if( TESTLINE( "$EndMODULE" ) )
1322  {
1323  return; // preferred exit
1324  }
1325  }
1326 
1327  wxString msg = wxString::Format( _( "Missing '$EndMODULE' for MODULE '%s'." ),
1328  aFootprint->GetFPID().GetLibItemName().wx_str() );
1329  THROW_IO_ERROR( msg );
1330 }
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
char * strtok_r(char *str, const char *delim, char **nextp)
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:226
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:204
void SetIsPlaced(bool isPlaced)
Definition: footprint.h:312
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: footprint.h:224
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
void SetThermalGap(int aGap)
Definition: footprint.h:232
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void SetAttributes(int aAttributes)
Definition: footprint.h:236
void SetPlacementCost180(int aCost)
Definition: footprint.h:579
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:499
void SetThermalWidth(int aWidth)
Definition: footprint.h:229
void SetDescription(const wxString &aDoc)
Definition: footprint.h:198
FP_TEXT & Reference()
Definition: footprint.h:500
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1680
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
void loadFP_SHAPE(FOOTPRINT *aFootprint)
void loadMODULE_TEXT(FP_TEXT *aText)
void SetLocalClearance(int aClearance)
Definition: footprint.h:210
#define _(s)
const LIB_ID & GetFPID() const
Definition: footprint.h:194
LEGACY_PLUGIN::BIU BIU
#define TESTSUBSTR(x)
C sub-string compare test for a specific length of characters.
const KIID m_Uuid
Definition: eda_item.h:474
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
void SetLastEditTime(timestamp_t aTime)
Definition: footprint.h:341
static long hexParse(const char *next, const char **out=nullptr)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
wxString wx_str() const
Definition: utf8.cpp:46
void SetKeywords(const wxString &aKeywords)
Definition: footprint.h:201
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:303
void load3D(FOOTPRINT *aFootprint)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1561
#define SZ(x)
Get the length of a string constant, at compile time.
void loadPAD(FOOTPRINT *aFootprint)
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define TESTLINE(x)
C string compare test for a specific length of characters.
void SetPlacementCost90(int aCost)
Definition: footprint.h:582
void SetLocalSolderMaskMargin(int aMargin)
Definition: footprint.h:207
void SetLocalSolderPasteMargin(int aMargin)
Definition: footprint.h:221

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

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

◆ loadFP_SHAPE()

void LEGACY_PLUGIN::loadFP_SHAPE ( FOOTPRINT aFootprint)
protected

Definition at line 1555 of file legacy_plugin.cpp.

1556 {
1557  SHAPE_T shape;
1558  char* line = m_reader->Line(); // obtain current (old) line
1559 
1560  switch( line[1] )
1561  {
1562  case 'S': shape = SHAPE_T::SEGMENT; break;
1563  case 'C': shape = SHAPE_T::CIRCLE; break;
1564  case 'A': shape = SHAPE_T::ARC; break;
1565  case 'P': shape = SHAPE_T::POLY; break;
1566  default:
1567  m_error.Printf( _( "Unknown FP_SHAPE type:'%c=0x%02x' on line %d of footprint '%s'." ),
1568  (unsigned char) line[1], (unsigned char) line[1], m_reader->LineNumber(),
1569  aFootprint->GetFPID().GetLibItemName().wx_str() );
1571  }
1572 
1573  std::unique_ptr<FP_SHAPE> dwg = std::make_unique<FP_SHAPE>( aFootprint, shape ); // a drawing
1574 
1575  const char* data;
1576 
1577  // common to all cases, and we have to check their values uniformly at end
1578  BIU width = 1;
1580 
1581  switch( shape )
1582  {
1583  case SHAPE_T::ARC:
1584  {
1585  BIU center0_x = biuParse( line + SZ( "DA" ), &data );
1586  BIU center0_y = biuParse( data, &data );
1587  BIU start0_x = biuParse( data, &data );
1588  BIU start0_y = biuParse( data, &data );
1589  double angle = degParse( data, &data );
1590 
1591  width = biuParse( data, &data );
1592  layer = layerParse( data );
1593 
1594  dwg->SetCenter0( wxPoint( center0_x, center0_y ) );
1595  dwg->SetStart0( wxPoint( start0_x, start0_y ) );
1596  dwg->SetArcAngleAndEnd0( angle );
1597  break;
1598  }
1599 
1600  case SHAPE_T::SEGMENT:
1601  case SHAPE_T::CIRCLE:
1602  {
1603  // e.g. "DS -7874 -10630 7874 -10630 50 20\r\n"
1604  BIU start0_x = biuParse( line + SZ( "DS" ), &data );
1605  BIU start0_y = biuParse( data, &data );
1606  BIU end0_x = biuParse( data, &data );
1607  BIU end0_y = biuParse( data, &data );
1608 
1609  width = biuParse( data, &data );
1610  layer = layerParse( data );
1611 
1612  dwg->SetStart0( wxPoint( start0_x, start0_y ) );
1613  dwg->SetEnd0( wxPoint( end0_x, end0_y ) );
1614  break;
1615  }
1616 
1617  case SHAPE_T::POLY:
1618  {
1619  // e.g. "DP %d %d %d %d %d %d %d\n"
1620  BIU start0_x = biuParse( line + SZ( "DP" ), &data );
1621  BIU start0_y = biuParse( data, &data );
1622  BIU end0_x = biuParse( data, &data );
1623  BIU end0_y = biuParse( data, &data );
1624  int ptCount = intParse( data, &data );
1625 
1626  width = biuParse( data, &data );
1627  layer = layerParse( data );
1628 
1629  dwg->SetStart0( wxPoint( start0_x, start0_y ) );
1630  dwg->SetEnd0( wxPoint( end0_x, end0_y ) );
1631 
1632  std::vector<wxPoint> pts;
1633  pts.reserve( ptCount );
1634 
1635  for( int ii = 0; ii < ptCount; ++ii )
1636  {
1637  if( ( line = READLINE( m_reader ) ) == nullptr )
1638  {
1639  THROW_IO_ERROR( "S_POLGON point count mismatch." );
1640  }
1641 
1642  // e.g. "Dl 23 44\n"
1643 
1644  if( !TESTLINE( "Dl" ) )
1645  {
1646  THROW_IO_ERROR( "Missing Dl point def" );
1647  }
1648 
1649  BIU x = biuParse( line + SZ( "Dl" ), &data );
1650  BIU y = biuParse( data );
1651 
1652  pts.emplace_back( x, y );
1653  }
1654 
1655  dwg->SetPolyPoints( pts );
1656  break;
1657  }
1658 
1659  default:
1660  // first switch code above prevents us from getting here.
1661  break;
1662  }
1663 
1664  // Check for a reasonable layer:
1665  // layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints can use the
1666  // copper layers, layer < FIRST_NON_COPPER_LAYER is allowed.
1667  if( layer < FIRST_LAYER || layer > LAST_NON_COPPER_LAYER )
1668  layer = SILKSCREEN_N_FRONT;
1669 
1670  dwg->SetWidth( width );
1671  dwg->SetLayer( leg_layer2new( m_cu_count, layer ) );
1672 
1673  FP_SHAPE* fpShape = dwg.release();
1674 
1675  aFootprint->Add( fpShape );
1676 
1677  // this had been done at the FOOTPRINT level before, presumably because the FP_SHAPE needs
1678  // to be already added to a footprint before this function will work.
1679  fpShape->SetDrawCoord();
1680 }
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
#define SILKSCREEN_N_FRONT
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
SHAPE_T
Definition: eda_shape.h:40
#define _(s)
const LIB_ID & GetFPID() const
Definition: footprint.h:194
LEGACY_PLUGIN::BIU BIU
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:81
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:46
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
#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 _, FOOTPRINT::Add(), PNS::angle(), ARC, biuParse(), CIRCLE, degParse(), FIRST_NON_COPPER_LAYER, FOOTPRINT::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, POLY, READLINE, SEGMENT, FP_SHAPE::SetDrawCoord(), SILKSCREEN_N_FRONT, SZ, TESTLINE, THROW_IO_ERROR, and UTF8::wx_str().

Referenced by loadFOOTPRINT().

◆ loadGENERAL()

void LEGACY_PLUGIN::loadGENERAL ( )
protected

Definition at line 608 of file legacy_plugin.cpp.

609 {
610  char* line;
611  char* saveptr;
612  bool saw_LayerCount = false;
613 
614  while( ( line = READLINE( m_reader ) ) != nullptr )
615  {
616  const char* data;
617 
618  if( TESTLINE( "Units" ) )
619  {
620  // what are the engineering units of the lengths in the BOARD?
621  data = strtok_r( line + SZ("Units"), delims, &saveptr );
622 
623  if( !strcmp( data, "mm" ) )
624  {
626  }
627  }
628  else if( TESTLINE( "LayerCount" ) )
629  {
630  int tmp = intParse( line + SZ( "LayerCount" ) );
631 
633 
634  // This has to be set early so that leg_layer2new() works OK, and
635  // that means before parsing "EnabledLayers" and "VisibleLayers".
636  m_cu_count = tmp;
637 
638  saw_LayerCount = true;
639  }
640  else if( TESTLINE( "EnabledLayers" ) )
641  {
642  if( !saw_LayerCount )
643  THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
644 
645  LEG_MASK enabledLayers = hexParse( line + SZ( "EnabledLayers" ) );
646  LSET new_mask = leg_mask2new( m_cu_count, enabledLayers );
647 
648  m_board->SetEnabledLayers( new_mask );
649 
650  // layer visibility equals layer usage, unless overridden later via "VisibleLayers"
651  // Must call SetEnabledLayers() before calling SetVisibleLayers().
652  m_board->SetVisibleLayers( new_mask );
653 
654  // Ensure copper layers count is not modified:
656  }
657  else if( TESTLINE( "VisibleLayers" ) )
658  {
659  // Keep all enabled layers visible.
660  // the old visibility control does not make sense in current Pcbnew version
661  // However, this code works.
662  #if 0
663  if( !saw_LayerCount )
664  THROW_IO_ERROR( "Missing '$GENERAL's LayerCount" );
665 
666  LEG_MASK visibleLayers = hexParse( line + SZ( "VisibleLayers" ) );
667 
668  LSET new_mask = leg_mask2new( m_cu_count, visibleLayers );
669 
670  m_board->SetVisibleLayers( new_mask );
671  #endif
672  }
673  else if( TESTLINE( "Ly" ) ) // Old format for Layer count
674  {
675  if( !saw_LayerCount )
676  {
677  LEG_MASK layer_mask = hexParse( line + SZ( "Ly" ) );
678 
679  m_cu_count = layerMaskCountSet( layer_mask & ALL_CU_LAYERS );
681 
682  saw_LayerCount = true;
683  }
684  }
685  else if( TESTLINE( "BoardThickness" ) )
686  {
687  BIU thickn = biuParse( line + SZ( "BoardThickness" ) );
689  }
690  else if( TESTLINE( "NoConn" ) )
691  {
692  // ignore
693  intParse( line + SZ( "NoConn" ) );
694  }
695  else if( TESTLINE( "Di" ) )
696  {
697  biuParse( line + SZ( "Di" ), &data );
698  biuParse( data, &data );
699  biuParse( data, &data );
700  biuParse( data );
701  }
702  else if( TESTLINE( "Nnets" ) )
703  {
704  m_netCodes.resize( intParse( line + SZ( "Nnets" ) ) );
705  }
706  else if( TESTLINE( "Nn" ) ) // id "Nnets" for old .brd files
707  {
708  m_netCodes.resize( intParse( line + SZ( "Nn" ) ) );
709  }
710  else if( TESTLINE( "$EndGENERAL" ) )
711  {
712  return; // preferred exit
713  }
714  }
715 
716  THROW_IO_ERROR( "Missing '$EndGENERAL'" );
717 }
char * strtok_r(char *str, const char *delim, char **nextp)
static constexpr double IU_PER_MM
Mock up a conversion function.
static const char delims[]
void SetCopperLayerCount(int aCount)
Definition: board.cpp:461
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
#define READLINE(rdr)
void SetBoardThickness(int aThickness)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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.
Definition: layer_ids.h:504
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:499
#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=nullptr)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
#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.
Definition: board.cpp:487

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, READLINE, BOARD_DESIGN_SETTINGS::SetBoardThickness(), BOARD::SetCopperLayerCount(), BOARD::SetEnabledLayers(), BOARD::SetVisibleLayers(), strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadMODULE_TEXT()

void LEGACY_PLUGIN::loadMODULE_TEXT ( FP_TEXT aText)
protected

Definition at line 1683 of file legacy_plugin.cpp.

1684 {
1685  const char* data;
1686  const char* txt_end;
1687  const char* line = m_reader->Line(); // current (old) line
1688 
1689  // sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
1690  // &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x,
1691  // &m_Orient, &m_Thickness, BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
1692 
1693  // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n"
1694  // or T1 0 500 600 400 900 80 M V 20 N"74LS245"
1695  // ouch, the last example has no space between N and "74LS245" !
1696  // that is an older version.
1697 
1698  int type = intParse( line+1, &data );
1699  BIU pos0_x = biuParse( data, &data );
1700  BIU pos0_y = biuParse( data, &data );
1701  BIU size0_y = biuParse( data, &data );
1702  BIU size0_x = biuParse( data, &data );
1703  double orient = degParse( data, &data );
1704  BIU thickn = biuParse( data, &data );
1705 
1706  // read the quoted text before the first call to strtok() which introduces
1707  // NULs into the string and chops it into multiple C strings, something
1708  // ReadDelimitedText() cannot traverse.
1709 
1710  // convert the "quoted, escaped, UTF8, text" to a wxString, find it by skipping
1711  // as far forward as needed until the first double quote.
1712  txt_end = data + ReadDelimitedText( &m_field, data );
1713  m_field.Replace( "%V", "${VALUE}" );
1714  m_field.Replace( "%R", "${REFERENCE}" );
1716  aText->SetText( m_field );
1717 
1718  // after switching to strtok, there's no easy coming back because of the
1719  // embedded nul(s?) placed to the right of the current field.
1720  // (that's the reason why strtok was deprecated...)
1721  char* mirror = strtok_r( (char*) data, delims, (char**) &data );
1722  char* hide = strtok_r( nullptr, delims, (char**) &data );
1723  char* tmp = strtok_r( nullptr, delims, (char**) &data );
1724 
1725  LAYER_NUM layer_num = tmp ? layerParse( tmp ) : SILKSCREEN_N_FRONT;
1726 
1727  char* italic = strtok_r( nullptr, delims, (char**) &data );
1728 
1729  char* hjust = strtok_r( (char*) txt_end, delims, (char**) &data );
1730  char* vjust = strtok_r( nullptr, delims, (char**) &data );
1731 
1732  if( type != FP_TEXT::TEXT_is_REFERENCE && type != FP_TEXT::TEXT_is_VALUE )
1733  type = FP_TEXT::TEXT_is_DIVERS;
1734 
1735  aText->SetType( static_cast<FP_TEXT::TEXT_TYPE>( type ) );
1736 
1737  aText->SetPos0( wxPoint( pos0_x, pos0_y ) );
1738  aText->SetTextSize( wxSize( size0_x, size0_y ) );
1739 
1740  orient -= ( static_cast<FOOTPRINT*>( aText->GetParent() ) )->GetOrientation();
1741 
1742  aText->SetTextAngle( orient );
1743 
1744  aText->SetTextThickness( thickn < 1 ? 0 : thickn );
1745 
1746  aText->SetMirrored( mirror && *mirror == 'M' );
1747 
1748  aText->SetVisible( !(hide && *hide == 'I') );
1749 
1750  aText->SetItalic( italic && *italic == 'I' );
1751 
1752  if( hjust )
1753  aText->SetHorizJustify( horizJustify( hjust ) );
1754 
1755  if( vjust )
1756  aText->SetVertJustify( vertJustify( vjust ) );
1757 
1758  // A protection against mal formed (or edited by hand) files:
1759  if( layer_num < FIRST_LAYER )
1760  layer_num = FIRST_LAYER;
1761  else if( layer_num > LAST_NON_COPPER_LAYER )
1762  layer_num = LAST_NON_COPPER_LAYER;
1763  else if( layer_num == LAYER_N_BACK )
1764  layer_num = SILKSCREEN_N_BACK;
1765  else if( layer_num == LAYER_N_FRONT )
1766  layer_num = SILKSCREEN_N_FRONT;
1767  else if( layer_num < LAYER_N_FRONT ) // this case is a internal layer
1768  layer_num = SILKSCREEN_N_FRONT;
1769 
1770  aText->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
1771 
1772  // Calculate the actual position.
1773  aText->SetDrawCoord();
1774 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:209
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
#define SILKSCREEN_N_BACK
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
char * strtok_r(char *str, const char *delim, char **nextp)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
#define LAYER_N_BACK
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:73
void SetItalic(bool isItalic)
Definition: eda_text.h:200
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
void SetDrawCoord()
Set relative coordinates.
Definition: fp_text.cpp:190
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
wxString m_field
reused to stuff FOOTPRINT fields.
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:140
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
#define SILKSCREEN_N_FRONT
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
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:124
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
LEGACY_PLUGIN::BIU BIU
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:165
#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:222
#define LAST_NON_COPPER_LAYER
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.

References biuParse(), ConvertToNewOverbarNotation(), 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, 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 loadFOOTPRINT().

◆ loadNETCLASS()

void LEGACY_PLUGIN::loadNETCLASS ( )
protected

Definition at line 2256 of file legacy_plugin.cpp.

2257 {
2258  char buf[1024];
2259  wxString netname;
2260  char* line;
2261 
2262  // create an empty NETCLASS without a name, but do not add it to the BOARD
2263  // yet since that would bypass duplicate netclass name checking within the BOARD.
2264  // store it temporarily in an unique_ptr until successfully inserted into the BOARD
2265  // just before returning.
2266  NETCLASSPTR nc = std::make_shared<NETCLASS>( wxEmptyString );
2267 
2268  while( ( line = READLINE( m_reader ) ) != nullptr )
2269  {
2270  if( TESTLINE( "AddNet" ) ) // most frequent type of line
2271  {
2272  // e.g. "AddNet "V3.3D"\n"
2273  ReadDelimitedText( buf, line + SZ( "AddNet" ), sizeof(buf) );
2274  netname = ConvertToNewOverbarNotation( FROM_UTF8( buf ) );
2275  nc->Add( netname );
2276  }
2277  else if( TESTLINE( "Clearance" ) )
2278  {
2279  BIU tmp = biuParse( line + SZ( "Clearance" ) );
2280  nc->SetClearance( tmp );
2281  }
2282  else if( TESTLINE( "TrackWidth" ) )
2283  {
2284  BIU tmp = biuParse( line + SZ( "TrackWidth" ) );
2285  nc->SetTrackWidth( tmp );
2286  }
2287  else if( TESTLINE( "ViaDia" ) )
2288  {
2289  BIU tmp = biuParse( line + SZ( "ViaDia" ) );
2290  nc->SetViaDiameter( tmp );
2291  }
2292  else if( TESTLINE( "ViaDrill" ) )
2293  {
2294  BIU tmp = biuParse( line + SZ( "ViaDrill" ) );
2295  nc->SetViaDrill( tmp );
2296  }
2297  else if( TESTLINE( "uViaDia" ) )
2298  {
2299  BIU tmp = biuParse( line + SZ( "uViaDia" ) );
2300  nc->SetuViaDiameter( tmp );
2301  }
2302  else if( TESTLINE( "uViaDrill" ) )
2303  {
2304  BIU tmp = biuParse( line + SZ( "uViaDrill" ) );
2305  nc->SetuViaDrill( tmp );
2306  }
2307  else if( TESTLINE( "Name" ) )
2308  {
2309  ReadDelimitedText( buf, line + SZ( "Name" ), sizeof(buf) );
2310  nc->SetName( FROM_UTF8( buf ) );
2311  }
2312  else if( TESTLINE( "Desc" ) )
2313  {
2314  ReadDelimitedText( buf, line + SZ( "Desc" ), sizeof(buf) );
2315  nc->SetDescription( FROM_UTF8( buf ) );
2316  }
2317  else if( TESTLINE( "$EndNCLASS" ) )
2318  {
2319  if( !m_board->GetDesignSettings().GetNetClasses().Add( nc ) )
2320  {
2321  // Must have been a name conflict, this is a bad board file.
2322  // User may have done a hand edit to the file.
2323 
2324  // unique_ptr will delete nc on this code path
2325 
2326  m_error.Printf( _( "Duplicate NETCLASS name '%s'." ), nc->GetName().GetData() );
2328  }
2329 
2330  return; // preferred exit
2331  }
2332  }
2333 
2334  THROW_IO_ERROR( "Missing '$EndNCLASS'" );
2335 }
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
#define READLINE(rdr)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
LINE_READER * m_reader
no ownership here.
#define _(s)
NETCLASSES & GetNetClasses() const
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
bool Add(const NETCLASSPTR &aNetclass)
Add aNetclass and puts it into this NETCLASSES container.
Definition: netclass.cpp:90
wxString m_error
for throwing exceptions
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#define TESTLINE(x)
C string compare test for a specific length of characters.

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

Referenced by loadAllSections().

◆ loadNETINFO_ITEM()

void LEGACY_PLUGIN::loadNETINFO_ITEM ( )
protected

Definition at line 1925 of file legacy_plugin.cpp.

1926 {
1927  /* a net description is something like
1928  * $EQUIPOT
1929  * Na 5 "/BIT1"
1930  * St ~
1931  * $EndEQUIPOT
1932  */
1933 
1934  char buf[1024];
1935 
1936  NETINFO_ITEM* net = nullptr;
1937  char* line;
1938  int netCode = 0;
1939 
1940  while( ( line = READLINE( m_reader ) ) != nullptr )
1941  {
1942  const char* data;
1943 
1944  if( TESTLINE( "Na" ) )
1945  {
1946  // e.g. "Na 58 "/cpu.sch/PAD7"\r\n"
1947 
1948  netCode = intParse( line + SZ( "Na" ), &data );
1949 
1950  ReadDelimitedText( buf, data, sizeof(buf) );
1951 
1952  if( net == nullptr )
1953  {
1955  netCode );
1956  }
1957  else
1958  {
1959  THROW_IO_ERROR( "Two net definitions in '$EQUIPOT' block" );
1960  }
1961  }
1962  else if( TESTLINE( "$EndEQUIPOT" ) )
1963  {
1964  // net 0 should be already in list, so store this net
1965  // if it is not the net 0, or if the net 0 does not exists.
1966  if( net && ( net->GetNetCode() > 0 || m_board->FindNet( 0 ) == nullptr ) )
1967  {
1968  m_board->Add( net );
1969 
1970  // Be sure we have room to store the net in m_netCodes
1971  if( (int)m_netCodes.size() <= netCode )
1972  m_netCodes.resize( netCode+1 );
1973 
1974  m_netCodes[netCode] = net->GetNetCode();
1975  net = nullptr;
1976  }
1977  else
1978  {
1979  delete net;
1980  net = nullptr; // Avoid double deletion.
1981  }
1982 
1983  return; // preferred exit
1984  }
1985  }
1986 
1987  // If we are here, there is an error.
1988  delete net;
1989  THROW_IO_ERROR( "Missing '$EndEQUIPOT'" );
1990 }
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1325
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
#define READLINE(rdr)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
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.
Definition: board.cpp:608
LINE_READER * m_reader
no ownership here.
BOARD * m_board
which BOARD, no ownership here
Handle the data for a net.
Definition: netinfo.h:66
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#define TESTLINE(x)
C string compare test for a specific length of characters.
int GetNetCode() const
Definition: netinfo.h:120

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

Referenced by loadAllSections().

◆ loadPAD()

void LEGACY_PLUGIN::loadPAD ( FOOTPRINT aFootprint)
protected

Definition at line 1333 of file legacy_plugin.cpp.

1334 {
1335  std::unique_ptr<PAD> pad = std::make_unique<PAD>( aFootprint );
1336  char* line;
1337  char* saveptr;
1338 
1339  while( ( line = READLINE( m_reader ) ) != nullptr )
1340  {
1341  const char* data;
1342 
1343  if( TESTLINE( "Sh" ) ) // (Sh)ape and padname
1344  {
1345  // e.g. "Sh "A2" C 520 520 0 0 900"
1346  // or "Sh "1" R 157 1378 0 0 900"
1347 
1348  // mypadnumber is LATIN1/CRYLIC for BOARD_FORMAT_VERSION 1, but for
1349  // BOARD_FORMAT_VERSION 2, it is UTF8 from disk.
1350  // Moving forward padnumbers will be in UTF8 on disk, as are all KiCad strings on disk.
1351  char mypadnumber[50];
1352 
1353  data = line + SZ( "Sh" ) + 1; // +1 skips trailing whitespace
1354 
1355  // +1 trailing whitespace.
1356  data = data + ReadDelimitedText( mypadnumber, data, sizeof( mypadnumber ) ) + 1;
1357 
1358  while( isSpace( *data ) )
1359  ++data;
1360 
1361  unsigned char padchar = (unsigned char) *data++;
1362  int padshape;
1363 
1364  BIU size_x = biuParse( data, &data );
1365  BIU size_y = biuParse( data, &data );
1366  BIU delta_x = biuParse( data, &data );
1367  BIU delta_y = biuParse( data, &data );
1368  double orient = degParse( data );
1369 
1370  switch( padchar )
1371  {
1372  case 'C': padshape = static_cast<int>( PAD_SHAPE::CIRCLE ); break;
1373  case 'R': padshape = static_cast<int>( PAD_SHAPE::RECT ); break;
1374  case 'O': padshape = static_cast<int>( PAD_SHAPE::OVAL ); break;
1375  case 'T': padshape = static_cast<int>( PAD_SHAPE::TRAPEZOID ); break;
1376  default:
1377  m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line: %d of footprint: '%s'." ),
1378  padchar, padchar, m_reader->LineNumber(),
1379  aFootprint->GetFPID().GetLibItemName().wx_str() );
1381  }
1382 
1383  // go through a wxString to establish a universal character set properly
1384  wxString padNumber;
1385 
1386  if( m_loading_format_version == 1 )
1387  {
1388  // add 8 bit bytes, file format 1 was KiCad font type byte,
1389  // simply promote those 8 bit bytes up into UNICODE. (subset of LATIN1)
1390  const unsigned char* cp = (unsigned char*) mypadnumber;
1391 
1392  while( *cp )
1393  padNumber += *cp++; // unsigned, ls 8 bits only
1394  }
1395  else
1396  {
1397  // version 2, which is UTF8.
1398  padNumber = FROM_UTF8( mypadnumber );
1399  }
1400 
1401  // chances are both were ASCII, but why take chances?
1402 
1403  pad->SetNumber( padNumber );
1404  pad->SetShape( static_cast<PAD_SHAPE>( padshape ) );
1405  pad->SetSize( wxSize( size_x, size_y ) );
1406  pad->SetDelta( wxSize( delta_x, delta_y ) );
1407  pad->SetOrientation( orient );
1408  }
1409  else if( TESTLINE( "Dr" ) ) // (Dr)ill
1410  {
1411  // e.g. "Dr 350 0 0" or "Dr 0 0 0 O 0 0"
1412  BIU drill_x = biuParse( line + SZ( "Dr" ), &data );
1413  BIU drill_y = drill_x;
1414  BIU offs_x = biuParse( data, &data );
1415  BIU offs_y = biuParse( data, &data );
1416 
1418 
1419  data = strtok_r( (char*) data, delims, &saveptr );
1420 
1421  if( data ) // optional shape
1422  {
1423  if( data[0] == 'O' )
1424  {
1425  drShape = PAD_DRILL_SHAPE_OBLONG;
1426 
1427  data = strtok_r( nullptr, delims, &saveptr );
1428  drill_x = biuParse( data );
1429 
1430  data = strtok_r( nullptr, delims, &saveptr );
1431  drill_y = biuParse( data );
1432  }
1433  }
1434 
1435  pad->SetDrillShape( drShape );
1436  pad->SetOffset( wxPoint( offs_x, offs_y ) );
1437  pad->SetDrillSize( wxSize( drill_x, drill_y ) );
1438  }
1439  else if( TESTLINE( "At" ) ) // (At)tribute
1440  {
1441  // e.g. "At SMD N 00888000"
1442  // sscanf( PtLine, "%s %s %X", BufLine, BufCar, &m_layerMask );
1443 
1444  PAD_ATTRIB attribute;
1445 
1446  data = strtok_r( line + SZ( "At" ), delims, &saveptr );
1447 
1448  if( !strcmp( data, "SMD" ) )
1449  attribute = PAD_ATTRIB::SMD;
1450  else if( !strcmp( data, "CONN" ) )
1451  attribute = PAD_ATTRIB::CONN;
1452  else if( !strcmp( data, "HOLE" ) )
1453  attribute = PAD_ATTRIB::NPTH;
1454  else
1455  attribute = PAD_ATTRIB::PTH;
1456 
1457  strtok_r( nullptr, delims, &saveptr ); // skip unused prm
1458  data = strtok_r( nullptr, delims, &saveptr );
1459 
1460  LEG_MASK layer_mask = hexParse( data );
1461 
1462  pad->SetLayerSet( leg_mask2new( m_cu_count, layer_mask ) );
1463  pad->SetAttribute( attribute );
1464  }
1465  else if( TESTLINE( "Ne" ) ) // (Ne)tname
1466  {
1467  // e.g. "Ne 461 "V5.0"
1468 
1469  char buf[1024]; // can be fairly long
1470  int netcode = intParse( line + SZ( "Ne" ), &data );
1471 
1472  // Store the new code mapping
1473  pad->SetNetCode( getNetCode( netcode ) );
1474 
1475  // read Netname
1476  ReadDelimitedText( buf, data, sizeof(buf) );
1477 
1478  if( m_board )
1479  {
1480  wxASSERT( m_board->FindNet( getNetCode( netcode ) )->GetNetname()
1482  }
1483  }
1484  else if( TESTLINE( "Po" ) ) // (Po)sition
1485  {
1486  // e.g. "Po 500 -500"
1487  wxPoint pos;
1488 
1489  pos.x = biuParse( line + SZ( "Po" ), &data );
1490  pos.y = biuParse( data );
1491 
1492  pad->SetPos0( pos );
1493  // pad->SetPosition( pos ); set at function return
1494  }
1495  else if( TESTLINE( "Le" ) )
1496  {
1497  BIU tmp = biuParse( line + SZ( "Le" ) );
1498  pad->SetPadToDieLength( tmp );
1499  }
1500  else if( TESTLINE( ".SolderMask" ) )
1501  {
1502  BIU tmp = biuParse( line + SZ( ".SolderMask" ) );
1503  pad->SetLocalSolderMaskMargin( tmp );
1504  }
1505  else if( TESTLINE( ".SolderPasteRatio" ) )
1506  {
1507  double tmp = atof( line + SZ( ".SolderPasteRatio" ) );
1508  pad->SetLocalSolderPasteMarginRatio( tmp );
1509  }
1510  else if( TESTLINE( ".SolderPaste" ) )
1511  {
1512  BIU tmp = biuParse( line + SZ( ".SolderPaste" ) );
1513  pad->SetLocalSolderPasteMargin( tmp );
1514  }
1515  else if( TESTLINE( ".LocalClearance" ) )
1516  {
1517  BIU tmp = biuParse( line + SZ( ".LocalClearance" ) );
1518  pad->SetLocalClearance( tmp );
1519  }
1520  else if( TESTLINE( ".ZoneConnection" ) )
1521  {
1522  int tmp = intParse( line + SZ( ".ZoneConnection" ) );
1523  pad->SetZoneConnection( (ZONE_CONNECTION) tmp );
1524  }
1525  else if( TESTLINE( ".ThermalWidth" ) )
1526  {
1527  BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) );
1528  pad->SetThermalSpokeWidth( tmp );
1529  }
1530  else if( TESTLINE( ".ThermalGap" ) )
1531  {
1532  BIU tmp = biuParse( line + SZ( ".ThermalGap" ) );
1533  pad->SetThermalGap( tmp );
1534  }
1535  else if( TESTLINE( "$EndPAD" ) )
1536  {
1537  // pad's "Position" is not relative to the footprint's, whereas Pos0 is relative
1538  // to the footprint's but is the unrotated coordinate.
1539 
1540  wxPoint padpos = pad->GetPos0();
1541 
1542  RotatePoint( &padpos, aFootprint->GetOrientation() );
1543 
1544  pad->SetPosition( padpos + aFootprint->GetPosition() );
1545 
1546  aFootprint->Add( pad.release() );
1547  return; // preferred exit
1548  }
1549  }
1550 
1551  THROW_IO_ERROR( "Missing '$EndPAD'" );
1552 }
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1325
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
char * strtok_r(char *str, const char *delim, char **nextp)
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
static const char delims[]
double GetOrientation() const
Definition: footprint.h:190
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
#define READLINE(rdr)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:67
int m_loading_format_version
which BOARD_FORMAT_VERSION am I Load()ing?
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
Plated through hole pad.
like PAD_PTH, but not plated
LINE_READER * m_reader
no ownership here.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
const wxString & GetNetname() const
Definition: netinfo.h:126
#define _(s)
const LIB_ID & GetFPID() const
Definition: footprint.h:194
unsigned LEG_MASK
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: pad_shapes.h:79
static bool isSpace(int c)
static LSET leg_mask2new(int cu_count, unsigned aMask)
wxString m_error
for throwing exceptions
static long hexParse(const char *next, const char **out=nullptr)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
wxString wx_str() const
Definition: utf8.cpp:46
wxPoint GetPosition() const override
Definition: footprint.h:186
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
#define SZ(x)
Get the length of a string constant, at compile time.
int getNetCode(int aNetCode)
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#define TESTLINE(x)
C string compare test for a specific length of characters.

References _, FOOTPRINT::Add(), biuParse(), CIRCLE, CONN, ConvertToNewOverbarNotation(), degParse(), delims, BOARD::FindNet(), FROM_UTF8(), FOOTPRINT::GetFPID(), LIB_ID::GetLibItemName(), getNetCode(), NETINFO_ITEM::GetNetname(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), hexParse(), intParse(), isSpace(), leg_mask2new(), LINE_READER::LineNumber(), m_board, m_cu_count, m_error, m_loading_format_version, m_reader, NPTH, OVAL, pad, PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG, PTH, ReadDelimitedText(), READLINE, RECT, RotatePoint(), SMD, StrPurge(), strtok_r(), SZ, TESTLINE, THROW_IO_ERROR, TRAPEZOID, and UTF8::wx_str().

Referenced by loadFOOTPRINT().

◆ loadPCB_LINE()

void LEGACY_PLUGIN::loadPCB_LINE ( )
protected

Definition at line 1817 of file legacy_plugin.cpp.

1818 {
1819  /* example:
1820  $DRAWSEGMENT
1821  Po 0 57500 -1000 57500 0 150
1822  De 24 0 900 0 0
1823  $EndDRAWSEGMENT
1824  */
1825 
1826  std::unique_ptr<PCB_SHAPE> dseg = std::make_unique<PCB_SHAPE>( m_board );
1827 
1828  char* line;
1829  char* saveptr;
1830 
1831  while( ( line = READLINE( m_reader ) ) != nullptr )
1832  {
1833  const char* data;
1834 
1835  if( TESTLINE( "Po" ) )
1836  {
1837  int shape = intParse( line + SZ( "Po" ), &data );
1838  BIU start_x = biuParse( data, &data );
1839  BIU start_y = biuParse( data, &data );
1840  BIU end_x = biuParse( data, &data );
1841  BIU end_y = biuParse( data, &data );
1842  BIU width = biuParse( data );
1843 
1844  if( width < 0 )
1845  width = 0;
1846 
1847  dseg->SetShape( static_cast<SHAPE_T>( shape ) );
1848  dseg->SetFilled( false );
1849  dseg->SetWidth( width );
1850  dseg->SetStart( wxPoint( start_x, start_y ) );
1851  dseg->SetEnd( wxPoint( end_x, end_y ) );
1852  }
1853  else if( TESTLINE( "De" ) )
1854  {
1855  BIU x = 0;
1856  BIU y;
1857 
1858  data = strtok_r( line + SZ( "De" ), delims, &saveptr );
1859 
1860  for( int i = 0; data; ++i, data = strtok_r( nullptr, delims, &saveptr ) )
1861  {
1862  switch( i )
1863  {
1864  case 0:
1865  LAYER_NUM layer;
1866  layer = layerParse( data );
1867 
1868  if( layer < FIRST_NON_COPPER_LAYER )
1869  layer = FIRST_NON_COPPER_LAYER;
1870 
1871  else if( layer > LAST_NON_COPPER_LAYER )
1872  layer = LAST_NON_COPPER_LAYER;
1873 
1874  dseg->SetLayer( leg_layer2new( m_cu_count, layer ) );
1875  break;
1876  case 1:
1877  ignore_unused( intParse( data ) );
1878  break;
1879  case 2:
1880  double angle;
1881  angle = degParse( data );
1882  dseg->SetArcAngleAndEnd( angle ); // m_Angle
1883  break;
1884  case 3:
1885  const_cast<KIID&>( dseg->m_Uuid ) = KIID( data );
1886  break;
1887  case 4:
1888  EDA_ITEM_FLAGS state;
1889  state = static_cast<EDA_ITEM_FLAGS>( hexParse( data ) );
1890  dseg->SetState( state, true );
1891  break;
1892 
1893  // Bezier Control Points
1894  case 5:
1895  x = biuParse( data );
1896  break;
1897  case 6:
1898  y = biuParse( data );
1899  dseg->SetBezierC1( wxPoint( x, y ));
1900  break;
1901 
1902  case 7:
1903  x = biuParse( data );
1904  break;
1905  case 8:
1906  y = biuParse( data );
1907  dseg->SetBezierC2( wxPoint( x, y ));
1908  break;
1909 
1910  default:
1911  break;
1912  }
1913  }
1914  }
1915  else if( TESTLINE( "$EndDRAWSEGMENT" ) )
1916  {
1917  m_board->Add( dseg.release(), ADD_MODE::APPEND );
1918  return; // preferred exit
1919  }
1920  }
1921 
1922  THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" );
1923 }
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
char * strtok_r(char *str, const char *delim, char **nextp)
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
std::uint32_t EDA_ITEM_FLAGS
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
#define LAST_NON_COPPER_LAYER
static long hexParse(const char *next, const char **out=nullptr)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void ignore_unused(const T &)
Definition: ignore.h:24
#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(), ignore_unused(), intParse(), LAST_NON_COPPER_LAYER, layerParse(), leg_layer2new(), m_board, m_cu_count, m_reader, READLINE, strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadPCB_TARGET()

void LEGACY_PLUGIN::loadPCB_TARGET ( )
protected

Definition at line 2756 of file legacy_plugin.cpp.

2757 {
2758  char* line;
2759 
2760  while( ( line = READLINE( m_reader ) ) != nullptr )
2761  {
2762  const char* data;
2763 
2764  if( TESTLINE( "$EndPCB_TARGET" ) || TESTLINE( "$EndMIREPCB" ) )
2765  {
2766  return; // preferred exit
2767  }
2768  else if( TESTLINE( "Po" ) )
2769  {
2770  int shape = intParse( line + SZ( "Po" ), &data );
2771  LAYER_NUM layer_num = layerParse( data, &data );
2772  BIU pos_x = biuParse( data, &data );
2773  BIU pos_y = biuParse( data, &data );
2774  BIU size = biuParse( data, &data );
2775  BIU width = biuParse( data, &data );
2776  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2777 
2778  if( layer_num < FIRST_NON_COPPER_LAYER )
2779  layer_num = FIRST_NON_COPPER_LAYER;
2780  else if( layer_num > LAST_NON_COPPER_LAYER )
2781  layer_num = LAST_NON_COPPER_LAYER;
2782 
2783  PCB_TARGET* t = new PCB_TARGET( m_board, shape, leg_layer2new( m_cu_count, layer_num ),
2784  wxPoint( pos_x, pos_y ), size, width );
2785  m_board->Add( t, ADD_MODE::APPEND );
2786 
2787  const_cast<KIID&>( t->m_Uuid ) = KIID( uuid );
2788  }
2789  }
2790 
2791  THROW_IO_ERROR( "Missing '$EndDIMENSION'" );
2792 }
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
char * strtok_r(char *str, const char *delim, char **nextp)
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
const KIID m_Uuid
Definition: eda_item.h:474
#define LAST_NON_COPPER_LAYER
#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, READLINE, strtok_r(), SZ, TESTLINE, and THROW_IO_ERROR.

Referenced by loadAllSections().

◆ loadPCB_TEXT()

void LEGACY_PLUGIN::loadPCB_TEXT ( )
protected

Definition at line 1993 of file legacy_plugin.cpp.

1994 {
1995  /* examples:
1996  For a single line text:
1997  ----------------------
1998  $TEXTPCB
1999  Te "Text example"
2000  Po 66750 53450 600 800 150 0
2001  De 24 1 0 Italic
2002  $EndTEXTPCB
2003 
2004  For a multi line text:
2005  ---------------------
2006  $TEXTPCB
2007  Te "Text example"
2008  Nl "Line 2"
2009  Po 66750 53450 600 800 150 0
2010  De 24 1 0 Italic
2011  $EndTEXTPCB
2012  Nl "line nn" is a line added to the current text
2013  */
2014 
2015  char text[1024];
2016 
2017  // maybe someday a constructor that takes all this data in one call?
2018  PCB_TEXT* pcbtxt = new PCB_TEXT( m_board );
2019  m_board->Add( pcbtxt, ADD_MODE::APPEND );
2020 
2021  char* line;
2022 
2023  while( ( line = READLINE( m_reader ) ) != nullptr )
2024  {
2025  const char* data;
2026 
2027  if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts)
2028  {
2029  ReadDelimitedText( text, line + SZ( "Te" ), sizeof(text) );
2031  }
2032  else if( TESTLINE( "nl" ) ) // next line of the current text
2033  {
2034  ReadDelimitedText( text, line + SZ( "nl" ), sizeof(text) );
2035  pcbtxt->SetText( pcbtxt->GetText() + wxChar( '\n' ) + FROM_UTF8( text ) );
2036  }
2037  else if( TESTLINE( "Po" ) )
2038  {
2039  wxSize size;
2040 
2041  BIU pos_x = biuParse( line + SZ( "Po" ), &data );
2042  BIU pos_y = biuParse( data, &data );
2043  size.x = biuParse( data, &data );
2044  size.y = biuParse( data, &data );
2045  BIU thickn = biuParse( data, &data );
2046  double angle = degParse( data );
2047 
2048  pcbtxt->SetTextSize( size );
2049  pcbtxt->SetTextThickness( thickn );
2050  pcbtxt->SetTextAngle( angle );
2051 
2052  pcbtxt->SetTextPos( wxPoint( pos_x, pos_y ) );
2053  }
2054  else if( TESTLINE( "De" ) )
2055  {
2056  // e.g. "De 21 1 68183921-93a5-49ac-91b0-49d05a0e1647 Normal C\r\n"
2057  LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
2058  int notMirrored = intParse( data, &data );
2059  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2060  char* style = strtok_r( nullptr, delims, (char**) &data );
2061  char* hJustify = strtok_r( nullptr, delims, (char**) &data );
2062  char* vJustify = strtok_r( nullptr, delims, (char**) &data );
2063 
2064  pcbtxt->SetMirrored( !notMirrored );
2065  const_cast<KIID&>( pcbtxt->m_Uuid ) = KIID( uuid );
2066  pcbtxt->SetItalic( !strcmp( style, "Italic" ) );
2067 
2068  if( hJustify )
2069  {
2070  pcbtxt->SetHorizJustify( horizJustify( hJustify ) );
2071  }
2072  else
2073  {
2074  // boom, somebody changed a constructor, I was relying on this:
2075  wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER );
2076  }
2077 
2078  if( vJustify )
2079  pcbtxt->SetVertJustify( vertJustify( vJustify ) );
2080 
2081  if( layer_num < FIRST_COPPER_LAYER )
2082  layer_num = FIRST_COPPER_LAYER;
2083  else if( layer_num > LAST_NON_COPPER_LAYER )
2084  layer_num = LAST_NON_COPPER_LAYER;
2085 
2086  if( layer_num >= FIRST_NON_COPPER_LAYER ||
2087  is_leg_copperlayer_valid( m_cu_count, layer_num ) )
2088  pcbtxt->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2089  else // not perfect, but putting this text on front layer is a workaround
2090  pcbtxt->SetLayer( F_Cu );
2091  }
2092  else if( TESTLINE( "$EndTEXTPCB" ) )
2093  {
2094  return; // preferred exit
2095  }
2096  }
2097 
2098  THROW_IO_ERROR( "Missing '$EndTEXTPCB'" );
2099 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:209
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
char * strtok_r(char *str, const char *delim, char **nextp)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
void SetTextAngle(double aAngle) override
Definition: pcb_text.cpp:104
void SetItalic(bool isItalic)
Definition: eda_text.h:200
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:267
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
#define READLINE(rdr)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
double degParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value which is certainly an angle.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
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:219
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
const KIID m_Uuid
Definition: eda_item.h:474
static EDA_TEXT_VJUSTIFY_T vertJustify(const char *vertical)
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:222
#define LAST_NON_COPPER_LAYER
Definition: layer_ids.h:71
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
#define FIRST_COPPER_LAYER
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
#define SZ(x)
Get the length of a string constant, at compile time.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
#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(), ConvertToNewOverbarNotation(), 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, 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, text, THROW_IO_ERROR, and vertJustify().

Referenced by loadAllSections().

◆ loadSETUP()

void LEGACY_PLUGIN::loadSETUP ( )
protected

Definition at line 851 of file legacy_plugin.cpp.

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

721 {
722  char buf[260];
723  TITLE_BLOCK tb;
724  char* line;
725  char* data;
726 
727  while( ( line = READLINE( m_reader ) ) != nullptr )
728  {
729  if( TESTLINE( "Sheet" ) )
730  {
731  // e.g. "Sheet A3 16535 11700"
732  // width and height are in 1/1000th of an inch, always
733  PAGE_INFO page;
734  char* sname = strtok_r( line + SZ( "Sheet" ), delims, &data );
735 
736  if( sname )
737  {
738  wxString wname = FROM_UTF8( sname );
739 
740  if( !page.SetType( wname ) )
741  {
742  m_error.Printf( _( "Unknown sheet type '%s' on line: %d." ),
743  wname.GetData(),
744  m_reader->LineNumber() );
746  }
747 
748  char* width = strtok_r( nullptr, delims, &data );
749  char* height = strtok_r( nullptr, delims, &data );
750  char* orient = strtok_r( nullptr, delims, &data );
751 
752  // only parse the width and height if page size is custom ("User")
753  if( wname == PAGE_INFO::Custom )
754  {
755  if( width && height )
756  {
757  // legacy disk file describes paper in mils
758  // (1/1000th of an inch)
759  int w = intParse( width );
760  int h = intParse( height );
761 
762  page.SetWidthMils( w );
763  page.SetHeightMils( h );
764  }
765  }
766 
767  if( orient && !strcmp( orient, "portrait" ) )
768  {
769  page.SetPortrait( true );
770  }
771 
772  m_board->SetPageSettings( page );
773  }
774  }
775  else if( TESTLINE( "Title" ) )
776  {
777  ReadDelimitedText( buf, line, sizeof(buf) );
778  tb.SetTitle( FROM_UTF8( buf ) );
779  }
780  else if( TESTLINE( "Date" ) )
781  {
782  ReadDelimitedText( buf, line, sizeof(buf) );
783  tb.SetDate( FROM_UTF8( buf ) );
784  }
785  else if( TESTLINE( "Rev" ) )
786  {
787  ReadDelimitedText( buf, line, sizeof(buf) );
788  tb.SetRevision( FROM_UTF8( buf ) );
789  }
790  else if( TESTLINE( "Comp" ) )
791  {
792  ReadDelimitedText( buf, line, sizeof(buf) );
793  tb.SetCompany( FROM_UTF8( buf ) );
794  }
795  else if( TESTLINE( "Comment1" ) )
796  {
797  ReadDelimitedText( buf, line, sizeof(buf) );
798  tb.SetComment( 0, FROM_UTF8( buf ) );
799  }
800  else if( TESTLINE( "Comment2" ) )
801  {
802  ReadDelimitedText( buf, line, sizeof(buf) );
803  tb.SetComment( 1, FROM_UTF8( buf ) );
804  }
805  else if( TESTLINE( "Comment3" ) )
806  {
807  ReadDelimitedText( buf, line, sizeof(buf) );
808  tb.SetComment( 2, FROM_UTF8( buf ) );
809  }
810  else if( TESTLINE( "Comment4" ) )
811  {
812  ReadDelimitedText( buf, line, sizeof(buf) );
813  tb.SetComment( 3, FROM_UTF8( buf ) );
814  }
815  else if( TESTLINE( "Comment5" ) )
816  {
817  ReadDelimitedText( buf, line, sizeof(buf) );
818  tb.SetComment( 4, FROM_UTF8( buf ) );
819  }
820  else if( TESTLINE( "Comment6" ) )
821  {
822  ReadDelimitedText( buf, line, sizeof(buf) );
823  tb.SetComment( 5, FROM_UTF8( buf ) );
824  }
825  else if( TESTLINE( "Comment7" ) )
826  {
827  ReadDelimitedText( buf, line, sizeof(buf) );
828  tb.SetComment( 6, FROM_UTF8( buf ) );
829  }
830  else if( TESTLINE( "Comment8" ) )
831  {
832  ReadDelimitedText( buf, line, sizeof(buf) );
833  tb.SetComment( 7, FROM_UTF8( buf ) );
834  }
835  else if( TESTLINE( "Comment9" ) )
836  {
837  ReadDelimitedText( buf, line, sizeof(buf) );
838  tb.SetComment( 8, FROM_UTF8( buf ) );
839  }
840  else if( TESTLINE( "$EndSHEETDESCR" ) )
841  {
842  m_board->SetTitleBlock( tb );
843  return; // preferred exit
844  }
845  }
846 
847  THROW_IO_ERROR( "Missing '$EndSHEETDESCR'" );
848 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
char * strtok_r(char *str, const char *delim, char **nextp)
void SetRevision(const wxString &aRevision)
Definition: title_block.h:81
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:544
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:537
static const char delims[]
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:119
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
#define READLINE(rdr)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
LINE_READER * m_reader
no ownership here.
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:101
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Definition: richio.h:135
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
void SetCompany(const wxString &aCompany)
Definition: title_block.h:91
#define _(s)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
BOARD * m_board
which BOARD, no ownership here
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
wxString m_error
for throwing exceptions
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
#define SZ(x)
Get the length of a string constant, at compile time.
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:186
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#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, 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

Read 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 2102 of file legacy_plugin.cpp.

2103 {
2104  char* line;
2105 
2106  while( ( line = READLINE( m_reader ) ) != nullptr )
2107  {
2108  checkpoint();
2109 
2110  // read two lines per loop iteration, each loop is one TRACK or VIA
2111  // example first line:
2112  // e.g. "Po 0 23994 28800 24400 28800 150 -1" for a track
2113  // e.g. "Po 3 21086 17586 21086 17586 180 -1" for a via (uses sames start and end)
2114  const char* data;
2115 
2116  if( line[0] == '$' ) // $EndTRACK
2117  return; // preferred exit
2118 
2119  assert( TESTLINE( "Po" ) );
2120 
2121  VIATYPE viatype = static_cast<VIATYPE>( intParse( line + SZ( "Po" ), &data ) );
2122  BIU start_x = biuParse( data, &data );
2123  BIU start_y = biuParse( data, &data );
2124  BIU end_x = biuParse( data, &data );
2125  BIU end_y = biuParse( data, &data );
2126  BIU width = biuParse( data, &data );
2127 
2128  // optional 7th drill parameter (must be optional in an old format?)
2129  data = strtok_r( (char*) data, delims, (char**) &data );
2130 
2131  BIU drill = data ? biuParse( data ) : -1; // SetDefault() if < 0
2132 
2133  // Read the 2nd line to determine the exact type, one of:
2134  // PCB_TRACE_T, PCB_VIA_T, or PCB_SEGZONE_T. The type field in 2nd line
2135  // differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual
2136  // functions in use, it is critical to instantiate the PCB_VIA_T
2137  // exactly.
2138  READLINE( m_reader );
2139 
2140  line = m_reader->Line();
2141 
2142  // example second line:
2143  // "De 0 0 463 0 800000\r\n"
2144 
2145 #if 1
2146  assert( TESTLINE( "De" ) );
2147 #else
2148  if( !TESTLINE( "De" ) )
2149  {
2150  // mandatory 2nd line is missing
2151  THROW_IO_ERROR( "Missing 2nd line of a TRACK def" );
2152  }
2153 #endif
2154 
2155  int makeType;
2156 
2157  // parse the 2nd line to determine the type of object
2158  // e.g. "De 15 1 7 68183921-93a5-49ac-91b0-49d05a0e1647 0" for a via
2159  LAYER_NUM layer_num = layerParse( line + SZ( "De" ), &data );
2160  int type = intParse( data, &data );
2161  int net_code = intParse( data, &data );
2162  char* uuid = strtok_r( (char*) data, delims, (char**) &data );
2163  int flags_int = intParse( data, (const char**) &data );
2164 
2165  EDA_ITEM_FLAGS flags = static_cast<EDA_ITEM_FLAGS>( flags_int );
2166 
2167  if( aStructType == PCB_TRACE_T )
2168  {
2169  makeType = ( type == 1 ) ? PCB_VIA_T : PCB_TRACE_T;
2170  }
2171  else if (aStructType == NOT_USED )
2172  {
2173  continue;
2174  }
2175  else
2176  {
2177  wxFAIL_MSG( "Segment type unknown" );
2178  continue;
2179  }
2180 
2181  PCB_TRACK* newTrack;
2182 
2183  switch( makeType )
2184  {
2185  default:
2186  case PCB_TRACE_T: newTrack = new PCB_TRACK( m_board ); break;
2187  case PCB_VIA_T: newTrack = new PCB_VIA( m_board ); break;
2188  }
2189 
2190  const_cast<KIID&>( newTrack->m_Uuid ) = KIID( uuid );
2191  newTrack->SetPosition( wxPoint( start_x, start_y ) );
2192  newTrack->SetEnd( wxPoint( end_x, end_y ) );
2193 
2194  newTrack->SetWidth( width );
2195 
2196  if( makeType == PCB_VIA_T ) // Ensure layers are OK when possible:
2197  {
2198  PCB_VIA *via = static_cast<PCB_VIA*>( newTrack );
2199  via->SetViaType( viatype );
2200 
2201  if( drill < 0 )
2202  via->SetDrillDefault();
2203  else
2204  via->SetDrill( drill );
2205 
2206  if( via->GetViaType() == VIATYPE::THROUGH )
2207  {
2208  via->SetLayerPair( F_Cu, B_Cu );
2209  }
2210  else
2211  {
2212  PCB_LAYER_ID back = leg_layer2new( m_cu_count, (layer_num >> 4) & 0xf );
2213  PCB_LAYER_ID front = leg_layer2new( m_cu_count, layer_num & 0xf );
2214 
2215  if( is_leg_copperlayer_valid( m_cu_count, back ) &&
2217  {
2218  via->SetLayerPair( front, back );
2219  }
2220  else
2221  {
2222  delete via;
2223  newTrack = nullptr;
2224  }
2225  }
2226  }
2227  else
2228  {
2229  // A few legacy boards can have tracks on non existent layers, because
2230  // reducing the number of layers does not remove tracks on removed layers
2231  // If happens, skip them
2232  if( is_leg_copperlayer_valid( m_cu_count, layer_num ) )
2233  {
2234  newTrack->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2235  }
2236  else
2237  {
2238  delete newTrack;
2239  newTrack = nullptr;
2240  }
2241  }
2242 
2243  if( newTrack )
2244  {
2245  newTrack->SetNetCode( getNetCode( net_code ) );
2246  newTrack->SetState( flags, true );
2247 
2248  m_board->Add( newTrack );
2249  }
2250  }
2251 
2252  THROW_IO_ERROR( "Missing '$EndTRACK'" );
2253 }
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
char * Line() const
Return a pointer to the last line that was read in.
Definition: richio.h:117
char * strtok_r(char *str, const char *delim, char **nextp)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
the 3d code uses this value
Definition: typeinfo.h:79
static const char delims[]
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
std::uint32_t EDA_ITEM_FLAGS
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
void SetState(EDA_ITEM_FLAGS type, bool state)
Definition: eda_item.h:141
bool is_leg_copperlayer_valid(int aCu_Count, LAYER_NUM aLegacyLayerNum)
LEGACY_PLUGIN::BIU BIU
BOARD * m_board
which BOARD, no ownership here
void checkpoint()
Converts net code using the mapping table if available, otherwise returns unchanged net code.
void SetPosition(const wxPoint &aPos) override
Definition: pcb_track.h:97
const KIID m_Uuid
Definition: eda_item.h:474
void SetWidth(int aWidth)
Definition: pcb_track.h:101
VIATYPE
Definition: pcb_track.h:60
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
#define SZ(x)
Get the length of a string constant, at compile time.
int getNetCode(int aNetCode)
#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(), checkpoint(), delims, F_Cu, getNetCode(), intParse(), is_leg_copperlayer_valid(), layerParse(), leg_layer2new(), LINE_READER::Line(), m_board, m_cu_count, m_reader, EDA_ITEM::m_Uuid, NOT_USED, PCB_TRACE_T, PCB_VIA_T, READLINE, PCB_TRACK::SetEnd(), BOARD_ITEM::SetLayer(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_TRACK::SetPosition(), EDA_ITEM::SetState(), PCB_TRACK::SetWidth(), strtok_r(), SZ, TESTLINE, THROUGH, THROW_IO_ERROR, and via.

Referenced by loadAllSections().

◆ loadZONE_CONTAINER()

void LEGACY_PLUGIN::loadZONE_CONTAINER ( )
protected

Definition at line 2338 of file legacy_plugin.cpp.

2339 {
2340  std::unique_ptr<ZONE> zc = std::make_unique<ZONE>( m_board );
2341 
2343  bool endContour = false;
2344  int holeIndex = -1; // -1 is the main outline; holeIndex >= 0 = hole index
2345  char buf[1024];
2346  char* line;
2347 
2348  while( ( line = READLINE( m_reader ) ) != nullptr )
2349  {
2350  const char* data;
2351 
2352  if( TESTLINE( "ZCorner" ) ) // new corner of the zone outlines found
2353  {
2354  // e.g. "ZCorner 25650 49500 0"
2355  BIU x = biuParse( line + SZ( "ZCorner" ), &data );
2356  BIU y = biuParse( data, &data );
2357 
2358  if( endContour )
2359  {
2360  // the previous corner was the last corner of a contour.
2361  // so this corner is the first of a new hole
2362  endContour = false;
2363  zc->NewHole();
2364  holeIndex++;
2365  }
2366 
2367  zc->AppendCorner( wxPoint( x, y ), holeIndex );
2368 
2369  // Is this corner the end of current contour?
2370  // the next corner (if any) will be stored in a new contour (a hole)
2371  // intParse( data )returns 0 = usual corner, 1 = last corner of the current contour:
2372  endContour = intParse( data );
2373  }
2374  else if( TESTLINE( "ZInfo" ) ) // general info found
2375  {
2376  // e.g. 'ZInfo 68183921-93a5-49ac-91b0-49d05a0e1647 310 "COMMON"'
2377  char* uuid = strtok_r( (char*) line + SZ( "ZInfo" ), delims, (char**) &data );
2378  int netcode = intParse( data, &data );
2379 
2380  if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) )
2381  THROW_IO_ERROR( "ZInfo netname too long" );
2382 
2383  const_cast<KIID&>( zc->m_Uuid ) = KIID( uuid );
2384 
2385  // Init the net code only, not the netname, to be sure
2386  // the zone net name is the name read in file.
2387  // (When mismatch, the user will be prompted in DRC, to fix the actual name)
2388  zc->BOARD_CONNECTED_ITEM::SetNetCode( getNetCode( netcode ) );
2389  }
2390  else if( TESTLINE( "ZLayer" ) ) // layer found
2391  {
2392  LAYER_NUM layer_num = layerParse( line + SZ( "ZLayer" ) );
2393  zc->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
2394  }
2395  else if( TESTLINE( "ZAux" ) ) // aux info found
2396  {
2397  // e.g. "ZAux 7 E"
2398  ignore_unused( intParse( line + SZ( "ZAux" ), &data ) );
2399  char* hopt = strtok_r( (char*) data, delims, (char**) &data );
2400 
2401  if( !hopt )
2402  {
2403  m_error.Printf( _( "Bad ZAux for CZONE_CONTAINER \"%s\"" ),
2404  zc->GetNetname().GetData() );
2406  }
2407 
2408  switch( *hopt ) // upper case required
2409  {
2410  case 'N': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
2411  case 'E': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
2412  case 'F': outline_hatch = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
2413  default:
2414  m_error.Printf( _( "Bad ZAux for CZONE_CONTAINER \"%s\"" ),
2415  zc->GetNetname().GetData() );
2417  }
2418 
2419  // Set hatch mode later, after reading corner outline data
2420  }
2421  else if( TESTLINE( "ZSmoothing" ) )
2422  {
2423  // e.g. "ZSmoothing 0 0"
2424  int smoothing = intParse( line + SZ( "ZSmoothing" ), &data );
2425  BIU cornerRadius = biuParse( data );
2426 
2427  if( smoothing >= ZONE_SETTINGS::SMOOTHING_LAST || smoothing < 0 )
2428  {
2429  m_error.Printf( _( "Bad ZSmoothing for CZONE_CONTAINER \"%s\"" ),
2430  zc->GetNetname().GetData() );
2432  }
2433 
2434  zc->SetCornerSmoothingType( smoothing );
2435  zc->SetCornerRadius( cornerRadius );
2436  }
2437  else if( TESTLINE( "ZKeepout" ) )
2438  {
2439  char* token;
2440  zc->SetIsRuleArea( true );
2441  zc->SetDoNotAllowPads( false ); // Not supported in legacy
2442  zc->SetDoNotAllowFootprints( false ); // Not supported in legacy
2443 
2444  // e.g. "ZKeepout tracks N vias N pads Y"
2445  token = strtok_r( line + SZ( "ZKeepout" ), delims, (char**) &data );
2446 
2447  while( token )
2448  {
2449  if( !strcmp( token, "tracks" ) )
2450  {
2451  token = strtok_r( nullptr, delims, (char**) &data );
2452  zc->SetDoNotAllowTracks( token && *token == 'N' );
2453  }
2454  else if( !strcmp( token, "vias" ) )
2455  {
2456  token = strtok_r( nullptr, delims, (char**) &data );
2457  zc->SetDoNotAllowVias( token && *token == 'N' );
2458  }
2459  else if( !strcmp( token, "copperpour" ) )
2460  {
2461  token = strtok_r( nullptr, delims, (char**) &data );
2462  zc->SetDoNotAllowCopperPour( token && *token == 'N' );
2463  }
2464 
2465  token = strtok_r( nullptr, delims, (char**) &data );
2466  }
2467  }
2468  else if( TESTLINE( "ZOptions" ) )
2469  {
2470  // e.g. "ZOptions 0 32 F 200 200"
2471  int fillmode = intParse( line + SZ( "ZOptions" ), &data );
2472  ignore_unused( intParse( data, &data ) );
2473  char fillstate = data[1]; // here e.g. " F"
2474  BIU thermalReliefGap = biuParse( data += 2 , &data ); // +=2 for " F"
2475  BIU thermalReliefCopperBridge = biuParse( data );
2476 
2477  if( fillmode)
2478  {
2479  // SEGMENT fill mode no longer supported. Make sure user is OK with converting
2480  // them.
2482  {
2483  KIDIALOG dlg( nullptr,
2484  _( "The legacy segment fill mode is no longer supported.\n"
2485  "Convert zones to polygon fills?"),
2486  _( "Legacy Zone Warning" ),
2487  wxYES_NO | wxICON_WARNING );
2488 
2489  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2490 
2491  if( dlg.ShowModal() == wxID_NO )
2492  THROW_IO_ERROR( wxT( "CANCEL" ) );
2493 
2494  m_showLegacyZoneWarning = false;
2495  }
2496 
2497  // User OK'd; switch to polygon mode
2498  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2499  m_board->SetModified();
2500  }
2501  else
2502  {
2503  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2504  }
2505 
2506  zc->SetIsFilled( fillstate == 'S' );
2507  zc->SetThermalReliefGap( thermalReliefGap );
2508  zc->SetThermalReliefSpokeWidth( thermalReliefCopperBridge );
2509  }
2510  else if( TESTLINE( "ZClearance" ) ) // Clearance and pad options info found
2511  {
2512  // e.g. "ZClearance 40 I"
2513  BIU clearance = biuParse( line + SZ( "ZClearance" ), &data );
2514  char* padoption = strtok_r( (char*) data, delims, (char**) &data ); // data: " I"
2515 
2516  ZONE_CONNECTION popt;
2517  switch( *padoption )
2518  {
2519  case 'I': popt = ZONE_CONNECTION::FULL; break;
2520  case 'T': popt = ZONE_CONNECTION::THERMAL; break;
2521  case 'H': popt = ZONE_CONNECTION::THT_THERMAL; break;
2522  case 'X': popt = ZONE_CONNECTION::NONE; break;
2523  default:
2524  m_error.Printf( _( "Bad ZClearance padoption for CZONE_CONTAINER \"%s\"" ),
2525  zc->GetNetname().GetData() );
2527  }
2528 
2529  zc->SetLocalClearance( clearance );
2530  zc->SetPadConnection( popt );
2531  }
2532  else if( TESTLINE( "ZMinThickness" ) )
2533  {
2534  BIU thickness = biuParse( line + SZ( "ZMinThickness" ) );
2535  zc->SetMinThickness( thickness );
2536  }
2537  else if( TESTLINE( "ZPriority" ) )
2538  {
2539  int priority = intParse( line + SZ( "ZPriority" ) );
2540  zc->SetPriority( priority );
2541  }
2542  else if( TESTLINE( "$POLYSCORNERS" ) )
2543  {
2544  // Read the PolysList (polygons that are the solid areas in the filled zone)
2545  SHAPE_POLY_SET polysList;
2546 
2547  bool makeNewOutline = true;
2548 
2549  while( ( line = READLINE( m_reader ) ) != nullptr )
2550  {
2551  if( TESTLINE( "$endPOLYSCORNERS" ) )
2552  break;
2553 
2554  // e.g. "39610 43440 0 0"
2555  BIU x = biuParse( line, &data );
2556  BIU y = biuParse( data, &data );
2557 
2558  if( makeNewOutline )
2559  polysList.NewOutline();
2560 
2561  polysList.Append( x, y );
2562 
2563  // end_countour was a bool when file saved, so '0' or '1' here
2564  bool end_contour = intParse( data, &data );
2565  intParse( data ); // skip corner utility flag
2566 
2567  makeNewOutline = end_contour;
2568  }
2569 
2570  zc->SetFilledPolysList( zc->GetLayer(), polysList );
2571  }
2572  else if( TESTLINE( "$FILLSEGMENTS" ) )
2573  {
2574  while( ( line = READLINE( m_reader ) ) != nullptr )
2575  {
2576  if( TESTLINE( "$endFILLSEGMENTS" ) )
2577  break;
2578 
2579  // e.g. ""%d %d %d %d\n"
2580  BIU sx = biuParse( line, &data );
2581  BIU sy = biuParse( data, &data );
2582  BIU ex = biuParse( data, &data );
2583  BIU ey = biuParse( data );
2584 
2585  zc->FillSegments( zc->GetLayer() )
2586  .push_back( SEG( VECTOR2I( sx, sy ), VECTOR2I( ex, ey ) ) );
2587  }
2588  }
2589  else if( TESTLINE( "$endCZONE_OUTLINE" ) )
2590  {
2591  // Ensure keepout does not have a net
2592  // (which have no sense for a keepout zone)
2593  if( zc->GetIsRuleArea() )
2594  zc->SetNetCode( NETINFO_LIST::UNCONNECTED );
2595 
2596  // should always occur, but who knows, a zone without two corners
2597  // is no zone at all, it's a spot?
2598 
2599  if( zc->GetNumCorners() > 2 )
2600  {
2601  if( !zc->IsOnCopperLayer() )
2602  {
2603  zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
2604  zc->SetNetCode( NETINFO_LIST::UNCONNECTED );
2605  }
2606 
2607  // HatchBorder here, after outlines corners are read
2608  // Set hatch here, after outlines corners are read
2609  zc->SetBorderDisplayStyle( outline_hatch, ZONE::GetDefaultHatchPitch(), true );
2610 
2611  m_board->Add( zc.release() );
2612  }
2613 
2614  return; // preferred exit
2615  }
2616  }
2617 
2618  THROW_IO_ERROR( "Missing '$endCZONE_OUTLINE'" );
2619 }
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
void SetModified()
Definition: eda_item.cpp:65
static LAYER_NUM layerParse(const char *next, const char **out=nullptr)
Like intParse but returns a LAYER_NUM.
char * strtok_r(char *str, const char *delim, char **nextp)
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
bool m_showLegacyZoneWarning
static const char delims[]
BIU biuParse(const char *aValue, const char **nptrptr=nullptr)
Parse an ASCII decimal floating point value and scales it into a BIU according to the current value o...
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
#define READLINE(rdr)
static PCB_LAYER_ID leg_layer2new(int cu_count, LAYER_NUM aLayerNum)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
static int intParse(const char *next, const char **out=nullptr)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
Definition: kiid.h:44
LINE_READER * m_reader
no ownership here.
pads are covered by copper
static int GetDefaultHatchPitch()
Definition: zone.cpp:1102
Represent a set of closed polygons.
#define _(s)
LEGACY_PLUGIN::BIU BIU
int NewOutline()
Creates a new hole in a given outline.
BOARD * m_board
which BOARD, no ownership here
Thermal relief only for THT pads.
Definition: seg.h:40
Use thermal relief for pads.
wxString m_error
for throwing exceptions
void ignore_unused(const T &)
Definition: ignore.h:24
Pads are not covered.
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
#define SZ(x)
Get the length of a string constant, at compile time.
int getNetCode(int aNetCode)
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:372
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
#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)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References _, BOARD::Add(), SHAPE_POLY_SET::Append(), biuParse(), delims, DIAGONAL_EDGE, DIAGONAL_FULL, KIDIALOG::DoNotShowCheckbox(), FULL, ZONE::GetDefaultHatchPitch(), getNetCode(), ignore_unused(), intParse(), layerParse(), leg_layer2new(), m_board, m_cu_count, m_error, m_reader, m_showLegacyZoneWarning, SHAPE_POLY_SET::NewOutline(), NO_HATCH, NONE, 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

Return a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 66 of file legacy_plugin.h.

67  {
68  return wxT( "KiCad-Legacy" );
69  }

◆ PrefetchLib()

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

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

performing downloads). Does not parse. Threadsafe.

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

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

Definition at line 75 of file plugin.cpp.

76 {
77 }

◆ Save()

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

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

Definition at line 60 of file plugin.cpp.

61 {
62  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
63  not_implemented( this, __FUNCTION__ );
64 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Throw an IO_ERROR and complains of an API function not being implemented.
Definition: plugin.cpp:38

References not_implemented().

Referenced by IO_MGR::Save().

◆ SetReader()

void LEGACY_PLUGIN::SetReader ( LINE_READER aReader)
inline

Definition at line 97 of file legacy_plugin.h.

97 { 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 60 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 203 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 206 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 185 of file legacy_plugin.h.

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

◆ m_field

wxString LEGACY_PLUGIN::m_field
protected

reused to stuff FOOTPRINT fields.

Definition at line 196 of file legacy_plugin.h.

Referenced by loadMODULE_TEXT().

◆ m_fp

FILE* LEGACY_PLUGIN::m_fp
protected

no ownership here.

Definition at line 194 of file legacy_plugin.h.

◆ m_lastProgressLine

unsigned LEGACY_PLUGIN::m_lastProgressLine
protected

Definition at line 190 of file legacy_plugin.h.

Referenced by checkpoint().

◆ m_lineCount

unsigned LEGACY_PLUGIN::m_lineCount
protected

for progress reporting

Definition at line 191 of file legacy_plugin.h.

Referenced by checkpoint(), and Load().

◆ m_loading_format_version

int LEGACY_PLUGIN::m_loading_format_version
protected

which BOARD_FORMAT_VERSION am I Load()ing?

Definition at line 197 of file legacy_plugin.h.

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

◆ m_netCodes

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

net codes mapping for boards being loaded

Definition at line 201 of file legacy_plugin.h.

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

◆ m_progressReporter

PROGRESS_REPORTER* LEGACY_PLUGIN::m_progressReporter
protected

may be NULL, no ownership

Definition at line 189 of file legacy_plugin.h.

Referenced by checkpoint(), and Load().

◆ m_props

const PROPERTIES* LEGACY_PLUGIN::m_props
protected

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

Definition at line 187 of file legacy_plugin.h.

Referenced by init().

◆ m_reader

◆ m_showLegacyZoneWarning

bool LEGACY_PLUGIN::m_showLegacyZoneWarning
protected

Definition at line 199 of file legacy_plugin.h.

Referenced by init(), and loadZONE_CONTAINER().


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