KiCad PCB EDA Suite
SCH_LEGACY_PLUGIN Class Reference

A SCH_PLUGIN derivation for loading schematic files created before the new s-expression file format. More...

#include <sch_legacy_plugin.h>

Inheritance diagram for SCH_LEGACY_PLUGIN:
SCH_PLUGIN

Public Member Functions

 SCH_LEGACY_PLUGIN ()
 
virtual ~SCH_LEGACY_PLUGIN ()
 
const wxString GetName () const override
 Returns a brief hard coded name for this SCH_PLUGIN. More...
 
const wxString GetFileExtension () const override
 Returns the file extension for the SCH_PLUGIN. More...
 
int GetModifyHash () const override
 Return the modification hash from the library cache. More...
 
SCH_SHEETLoad (const wxString &aFileName, KIWAY *aKiway, SCH_SHEET *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL) override
 Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one. More...
 
void Save (const wxString &aFileName, SCH_SCREEN *aScreen, KIWAY *aKiway, const PROPERTIES *aProperties=NULL) override
 Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file. More...
 
void Format (SCH_SCREEN *aScreen)
 
size_t GetSymbolLibCount (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 
void EnumerateSymbolLib (wxArrayString &aAliasNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Populate a list of LIB_PART alias names contained within the library aLibraryPath. More...
 
void EnumerateSymbolLib (std::vector< LIB_ALIAS *> &aAliasList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Populate a list of LIB_PART aliases contained within the library aLibraryPath. More...
 
LIB_ALIASLoadSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
 Load a LIB_ALIAS object having aAliasName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. More...
 
void SaveSymbol (const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=NULL) override
 Write aSymbol to an existing library located at aLibraryPath. More...
 
void DeleteAlias (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
 Delete aAliasName from the library at aLibraryPath. More...
 
void DeleteSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
 Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath. More...
 
void CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Create a new empty symbol library at aLibraryPath. More...
 
bool DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Delete an existing symbol library and returns true if successful, 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...
 
void SaveLibrary (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 
bool CheckHeader (const wxString &aFileName) override
 Return true if the first line in aFileName begins with the expected header. More...
 
bool IsSymbolLibWritable (const wxString &aLibraryPath) override
 Return true if the library at aLibraryPath is writable. More...
 
const wxString & GetError () const override
 Return an error string to the caller. More...
 
virtual void SymbolLibOptions (PROPERTIES *aListToAppendTo) const
 Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Static Public Attributes

static const char * PropBuffering = "buffering"
 const char* PropBuffering More...
 
static const char * PropNoDocFile = "no_doc_file"
 const char* PropBuffering More...
 

Protected Member Functions

void init (KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
 initialize PLUGIN like a constructor would. More...
 

Protected Attributes

int m_version
 Version of file being loaded. More...
 
wxString m_error
 For throwing exceptions or errors on partial schematic loads. More...
 
wxString m_path
 Root project path for loading child sheets. More...
 
std::stack< wxString > m_currentPath
 Stack to maintain nested sheet paths. More...
 
const PROPERTIESm_props
 Passed via Save() or Load(), no ownership, may be NULL. More...
 
KIWAYm_kiway
 Required for path to legacy component libraries. More...
 
SCH_SHEETm_rootSheet
 The root sheet of the schematic being loaded.. More...
 
FILE_OUTPUTFORMATTERm_out
 The output formatter for saving SCH_SCREEN objects. More...
 
SCH_LEGACY_PLUGIN_CACHEm_cache
 

Private Member Functions

void loadHierarchy (SCH_SHEET *aSheet)
 
void loadHeader (FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
 
void loadPageSettings (FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
 
void loadFile (const wxString &aFileName, SCH_SCREEN *aScreen)
 
SCH_SHEETloadSheet (FILE_LINE_READER &aReader)
 
SCH_BITMAPloadBitmap (FILE_LINE_READER &aReader)
 
SCH_JUNCTIONloadJunction (FILE_LINE_READER &aReader)
 
SCH_NO_CONNECTloadNoConnect (FILE_LINE_READER &aReader)
 
SCH_LINEloadWire (FILE_LINE_READER &aReader)
 
SCH_BUS_ENTRY_BASEloadBusEntry (FILE_LINE_READER &aReader)
 
SCH_TEXTloadText (FILE_LINE_READER &aReader)
 
SCH_COMPONENTloadComponent (FILE_LINE_READER &aReader)
 
void saveComponent (SCH_COMPONENT *aComponent)
 
void saveField (SCH_FIELD *aField)
 
void saveBitmap (SCH_BITMAP *aBitmap)
 
void saveSheet (SCH_SHEET *aSheet)
 
void saveJunction (SCH_JUNCTION *aJunction)
 
void saveNoConnect (SCH_NO_CONNECT *aNoConnect)
 
void saveBusEntry (SCH_BUS_ENTRY_BASE *aBusEntry)
 
void saveLine (SCH_LINE *aLine)
 
void saveText (SCH_TEXT *aText)
 
void cacheLib (const wxString &aLibraryFileName)
 
bool writeDocFile (const PROPERTIES *aProperties)
 
bool isBuffering (const PROPERTIES *aProperties)
 

Detailed Description

A SCH_PLUGIN derivation for loading schematic files created before the new s-expression file format.

The legacy parser and formatter attempt to be compatible with the legacy file format. The original parser was very forgiving in that it would parse only part of a keyword. So "$C", "$Co", and "$Com" could be used for "$Comp" and the old parser would allow this. This parser is not that forgiving and sticks to the legacy file format document.

As with all SCH_PLUGINs there is no UI dependencies i.e. windowing calls allowed.

Definition at line 60 of file sch_legacy_plugin.h.

Constructor & Destructor Documentation

◆ SCH_LEGACY_PLUGIN()

SCH_LEGACY_PLUGIN::SCH_LEGACY_PLUGIN ( )

Definition at line 561 of file sch_legacy_plugin.cpp.

References init().

562 {
563  init( NULL );
564 }
void init(KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
initialize PLUGIN like a constructor would.

◆ ~SCH_LEGACY_PLUGIN()

SCH_LEGACY_PLUGIN::~SCH_LEGACY_PLUGIN ( )
virtual

Definition at line 567 of file sch_legacy_plugin.cpp.

References m_cache.

568 {
569  delete m_cache;
570 }
SCH_LEGACY_PLUGIN_CACHE * m_cache

Member Function Documentation

◆ cacheLib()

void SCH_LEGACY_PLUGIN::cacheLib ( const wxString &  aLibraryFileName)
private

Definition at line 4111 of file sch_legacy_plugin.cpp.

References isBuffering(), SCH_LEGACY_PLUGIN_CACHE::IsFile(), SCH_LEGACY_PLUGIN_CACHE::IsFileChanged(), SCH_LEGACY_PLUGIN_CACHE::Load(), m_cache, m_props, and PART_LIBS::s_modify_generation.

Referenced by DeleteAlias(), DeleteSymbol(), EnumerateSymbolLib(), GetSymbolLibCount(), LoadSymbol(), and SaveSymbol().

4112 {
4113  if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
4114  {
4115  // a spectacular episode in memory management:
4116  delete m_cache;
4117  m_cache = new SCH_LEGACY_PLUGIN_CACHE( aLibraryFileName );
4118 
4119  // Because m_cache is rebuilt, increment PART_LIBS::s_modify_generation
4120  // to modify the hash value that indicate component to symbol links
4121  // must be updated.
4123 
4124  if( !isBuffering( m_props ) )
4125  m_cache->Load();
4126  }
4127 }
static int s_modify_generation
helper for GetModifyHash()
SCH_LEGACY_PLUGIN_CACHE * m_cache
A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLU...
bool isBuffering(const PROPERTIES *aProperties)
bool IsFile(const wxString &aFullPathAndFileName) const
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ CheckHeader()

bool SCH_LEGACY_PLUGIN::CheckHeader ( const wxString &  aFileName)
overridevirtual

Return true if the first line in aFileName begins with the expected header.

Parameters
aFileNameis the name of the file to use as input

Reimplemented from SCH_PLUGIN.

Definition at line 4341 of file sch_legacy_plugin.cpp.

4342 {
4343  // Open file and check first line
4344  wxTextFile tempFile;
4345 
4346  tempFile.Open( aFileName );
4347  wxString firstline;
4348  // read the first line
4349  firstline = tempFile.GetFirstLine();
4350  tempFile.Close();
4351 
4352  return firstline.StartsWith( "EESchema" );
4353 }

◆ CreateSymbolLib()

void SCH_LEGACY_PLUGIN::CreateSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Create a new empty symbol library at aLibraryPath.

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

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

Reimplemented from SCH_PLUGIN.

Definition at line 4274 of file sch_legacy_plugin.cpp.

References Format(), SCH_LEGACY_PLUGIN_CACHE::Load(), m_cache, m_props, SCH_LEGACY_PLUGIN_CACHE::Save(), SCH_LEGACY_PLUGIN_CACHE::SetModified(), THROW_IO_ERROR, and writeDocFile().

4276 {
4277  if( wxFileExists( aLibraryPath ) )
4278  {
4280  _( "symbol library \"%s\" already exists, cannot create a new library" ),
4281  aLibraryPath.GetData() ) );
4282  }
4283 
4284  LOCALE_IO toggle;
4285 
4286  m_props = aProperties;
4287 
4288  delete m_cache;
4289  m_cache = new SCH_LEGACY_PLUGIN_CACHE( aLibraryPath );
4290  m_cache->SetModified();
4291  m_cache->Save( writeDocFile( aProperties ) );
4292  m_cache->Load(); // update m_writable and m_mod_time
4293 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
SCH_LEGACY_PLUGIN_CACHE * m_cache
A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLU...
#define THROW_IO_ERROR(msg)
void SetModified(bool aModified=true)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void Save(bool aSaveDocFile=true)
Save the entire library to file m_libFileName;.
bool writeDocFile(const PROPERTIES *aProperties)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ DeleteAlias()

void SCH_LEGACY_PLUGIN::DeleteAlias ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Delete aAliasName from the library at aLibraryPath.

If aAliasName refers the the root LIB_PART object, the part is renamed to the next or previous LIB_ALIAS in the LIB_PART if one exists. If the LIB_ALIAS is the last alias referring to the root LIB_PART, the LIB_PART is also removed from the library.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the name of a LIB_ALIAS 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 alias or the library or deleting it.

Reimplemented from SCH_PLUGIN.

Definition at line 4246 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::DeleteAlias(), isBuffering(), m_cache, m_props, SCH_LEGACY_PLUGIN_CACHE::Save(), and writeDocFile().

4248 {
4249  m_props = aProperties;
4250 
4251  cacheLib( aLibraryPath );
4252 
4253  m_cache->DeleteAlias( aAliasName );
4254 
4255  if( !isBuffering( aProperties ) )
4256  m_cache->Save( writeDocFile( aProperties ) );
4257 }
SCH_LEGACY_PLUGIN_CACHE * m_cache
bool isBuffering(const PROPERTIES *aProperties)
void DeleteAlias(const wxString &aAliasName)
void cacheLib(const wxString &aLibraryFileName)
void Save(bool aSaveDocFile=true)
Save the entire library to file m_libFileName;.
bool writeDocFile(const PROPERTIES *aProperties)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ DeleteSymbol()

void SCH_LEGACY_PLUGIN::DeleteSymbol ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the name of a LIB_ALIAS associated with it's root LIB_PART object 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 alias or the library or deleting it.

Reimplemented from SCH_PLUGIN.

Definition at line 4260 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol(), isBuffering(), m_cache, m_props, SCH_LEGACY_PLUGIN_CACHE::Save(), and writeDocFile().

4262 {
4263  m_props = aProperties;
4264 
4265  cacheLib( aLibraryPath );
4266 
4267  m_cache->DeleteSymbol( aAliasName );
4268 
4269  if( !isBuffering( aProperties ) )
4270  m_cache->Save( writeDocFile( aProperties ) );
4271 }
SCH_LEGACY_PLUGIN_CACHE * m_cache
bool isBuffering(const PROPERTIES *aProperties)
void cacheLib(const wxString &aLibraryFileName)
void Save(bool aSaveDocFile=true)
Save the entire library to file m_libFileName;.
void DeleteSymbol(const wxString &aAliasName)
bool writeDocFile(const PROPERTIES *aProperties)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ DeleteSymbolLib()

bool SCH_LEGACY_PLUGIN::DeleteSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Delete an existing symbol library and returns true if successful, 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 symbols.
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 or false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented from SCH_PLUGIN.

Definition at line 4296 of file sch_legacy_plugin.cpp.

References Format(), SCH_LEGACY_PLUGIN_CACHE::IsFile(), m_cache, and THROW_IO_ERROR.

4298 {
4299  wxFileName fn = aLibraryPath;
4300 
4301  if( !fn.FileExists() )
4302  return false;
4303 
4304  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
4305  // we don't want that. we want bare metal portability with no UI here.
4306  if( wxRemove( aLibraryPath ) )
4307  {
4308  THROW_IO_ERROR( wxString::Format( _( "library \"%s\" cannot be deleted" ),
4309  aLibraryPath.GetData() ) );
4310  }
4311 
4312  if( m_cache && m_cache->IsFile( aLibraryPath ) )
4313  {
4314  delete m_cache;
4315  m_cache = 0;
4316  }
4317 
4318  return true;
4319 }
SCH_LEGACY_PLUGIN_CACHE * m_cache
#define THROW_IO_ERROR(msg)
bool IsFile(const wxString &aFullPathAndFileName) const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

◆ EnumerateSymbolLib() [1/2]

void SCH_LEGACY_PLUGIN::EnumerateSymbolLib ( wxArrayString &  aAliasNameList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Populate a list of LIB_PART alias names contained within the library aLibraryPath.

Parameters
aAliasNameListis an array to populate with the LIB_ALIAS names associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
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 the library cannot be found, the part library cannot be loaded.

Reimplemented from SCH_PLUGIN.

Definition at line 4170 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::m_aliases, m_cache, m_props, and SYMBOL_LIB_TABLE::PropPowerSymsOnly.

4173 {
4174  LOCALE_IO toggle; // toggles on, then off, the C locale.
4175 
4176  m_props = aProperties;
4177 
4178  bool powerSymbolsOnly = ( aProperties &&
4179  aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
4180  cacheLib( aLibraryPath );
4181 
4182  const LIB_ALIAS_MAP& aliases = m_cache->m_aliases;
4183 
4184  for( LIB_ALIAS_MAP::const_iterator it = aliases.begin(); it != aliases.end(); ++it )
4185  {
4186  if( !powerSymbolsOnly || it->second->GetPart()->IsPower() )
4187  aAliasNameList.Add( it->first );
4188  }
4189 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
SCH_LEGACY_PLUGIN_CACHE * m_cache
std::map< wxString, LIB_ALIAS *, AliasMapSort > LIB_ALIAS_MAP
Alias map used by part library object.
void cacheLib(const wxString &aLibraryFileName)
static const char * PropPowerSymsOnly
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ EnumerateSymbolLib() [2/2]

void SCH_LEGACY_PLUGIN::EnumerateSymbolLib ( std::vector< LIB_ALIAS *> &  aAliasList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Populate a list of LIB_PART aliases contained within the library aLibraryPath.

Parameters
aAliasListis an array to populate with the LIB_ALIAS pointers associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
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 the library cannot be found, the part library cannot be loaded.

Reimplemented from SCH_PLUGIN.

Definition at line 4192 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::m_aliases, m_cache, m_props, and SYMBOL_LIB_TABLE::PropPowerSymsOnly.

4195 {
4196  LOCALE_IO toggle; // toggles on, then off, the C locale.
4197 
4198  m_props = aProperties;
4199 
4200  bool powerSymbolsOnly = ( aProperties &&
4201  aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
4202  cacheLib( aLibraryPath );
4203 
4204  const LIB_ALIAS_MAP& aliases = m_cache->m_aliases;
4205 
4206  for( LIB_ALIAS_MAP::const_iterator it = aliases.begin(); it != aliases.end(); ++it )
4207  {
4208  if( !powerSymbolsOnly || it->second->GetPart()->IsPower() )
4209  aAliasList.push_back( it->second );
4210  }
4211 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
SCH_LEGACY_PLUGIN_CACHE * m_cache
std::map< wxString, LIB_ALIAS *, AliasMapSort > LIB_ALIAS_MAP
Alias map used by part library object.
void cacheLib(const wxString &aLibraryFileName)
static const char * PropPowerSymsOnly
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ Format()

void SCH_LEGACY_PLUGIN::Format ( SCH_SCREEN aScreen)

Definition at line 1735 of file sch_legacy_plugin.cpp.

References EESCHEMA_VERSION, EscapedUTF8(), TITLE_BLOCK::GetComment1(), TITLE_BLOCK::GetComment2(), TITLE_BLOCK::GetComment3(), TITLE_BLOCK::GetComment4(), TITLE_BLOCK::GetCompany(), TITLE_BLOCK::GetDate(), SCH_SCREEN::GetDrawItems(), PAGE_INFO::GetHeightMils(), SCH_SCREEN::GetPageSettings(), TITLE_BLOCK::GetRevision(), TITLE_BLOCK::GetTitle(), SCH_SCREEN::GetTitleBlock(), PAGE_INFO::GetType(), PAGE_INFO::GetWidthMils(), PAGE_INFO::IsCustom(), PAGE_INFO::IsPortrait(), m_kiway, BASE_SCREEN::m_NumberOfScreens, m_out, BASE_SCREEN::m_ScreenNumber, SCH_ITEM::Next(), OUTPUTFORMATTER::Print(), KIWAY::Prj(), saveBitmap(), saveBusEntry(), saveComponent(), saveJunction(), saveLine(), saveNoConnect(), saveSheet(), saveText(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_GLOBAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LAYER_ID_COUNT, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SHEET_T, SCH_TEXT_T, SCHEMATIC_HEAD_STRING, and TO_UTF8.

Referenced by Save().

1736 {
1737  wxCHECK_RET( aScreen != NULL, "NULL SCH_SCREEN* object." );
1738  wxCHECK_RET( m_kiway != NULL, "NULL KIWAY* object." );
1739 
1740  // Write the header
1741  m_out->Print( 0, "%s %s %d\n", "EESchema", SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION );
1742 
1743  // Write the project libraries.
1744  for( const PART_LIB& lib : *m_kiway->Prj().SchLibs() )
1745  m_out->Print( 0, "LIBS:%s\n", TO_UTF8( lib.GetName() ) );
1746 
1747  // This section is not used, but written for file compatibility
1748  m_out->Print( 0, "EELAYER %d %d\n", SCH_LAYER_ID_COUNT, 0 );
1749  m_out->Print( 0, "EELAYER END\n" );
1750 
1751  /* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for
1752  * SheetNumber and Sheet Count in a complex hierarchy, but useful in
1753  * simple hierarchy and flat hierarchy. Used also to search the root
1754  * sheet ( ScreenNumber = 1 ) within the files
1755  */
1756  const TITLE_BLOCK& tb = aScreen->GetTitleBlock();
1757  const PAGE_INFO& page = aScreen->GetPageSettings();
1758 
1759  m_out->Print( 0, "$Descr %s %d %d%s\n", TO_UTF8( page.GetType() ),
1760  page.GetWidthMils(),
1761  page.GetHeightMils(),
1762  !page.IsCustom() && page.IsPortrait() ? " portrait" : "" );
1763  m_out->Print( 0, "encoding utf-8\n" );
1764  m_out->Print( 0, "Sheet %d %d\n", aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens );
1765  m_out->Print( 0, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() );
1766  m_out->Print( 0, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() );
1767  m_out->Print( 0, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() );
1768  m_out->Print( 0, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() );
1769  m_out->Print( 0, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() );
1770  m_out->Print( 0, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() );
1771  m_out->Print( 0, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() );
1772  m_out->Print( 0, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() );
1773  m_out->Print( 0, "$EndDescr\n" );
1774 
1775  for( SCH_ITEM* item = aScreen->GetDrawItems(); item; item = item->Next() )
1776  {
1777  switch( item->Type() )
1778  {
1779  case SCH_COMPONENT_T:
1780  saveComponent( static_cast< SCH_COMPONENT* >( item ) );
1781  break;
1782  case SCH_BITMAP_T:
1783  saveBitmap( static_cast< SCH_BITMAP* >( item ) );
1784  break;
1785  case SCH_SHEET_T:
1786  saveSheet( static_cast< SCH_SHEET* >( item ) );
1787  break;
1788  case SCH_JUNCTION_T:
1789  saveJunction( static_cast< SCH_JUNCTION* >( item ) );
1790  break;
1791  case SCH_NO_CONNECT_T:
1792  saveNoConnect( static_cast< SCH_NO_CONNECT* >( item ) );
1793  break;
1794  case SCH_BUS_WIRE_ENTRY_T:
1795  case SCH_BUS_BUS_ENTRY_T:
1796  saveBusEntry( static_cast< SCH_BUS_ENTRY_BASE* >( item ) );
1797  break;
1798  case SCH_LINE_T:
1799  saveLine( static_cast< SCH_LINE* >( item ) );
1800  break;
1801  case SCH_TEXT_T:
1802  case SCH_LABEL_T:
1803  case SCH_GLOBAL_LABEL_T:
1805  saveText( static_cast< SCH_TEXT* >( item ) );
1806  break;
1807  default:
1808  wxASSERT( "Unexpected schematic object type in SCH_LEGACY_PLUGIN::Format()" );
1809  }
1810  }
1811 
1812  m_out->Print( 0, "$EndSCHEMATC\n" );
1813 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
int m_ScreenNumber
Definition: base_screen.h:216
SCH_ITEM * Next() const
void saveLine(SCH_LINE *aLine)
int GetHeightMils() const
Definition: page_info.h:140
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:142
const wxString & GetComment4() const
Definition: title_block.h:124
void saveText(SCH_TEXT *aText)
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:136
const wxString & GetType() const
Definition: page_info.h:97
#define SCH_LAYER_ID_COUNT
void saveNoConnect(SCH_NO_CONNECT *aNoConnect)
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
Definition: page_info.cpp:176
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:126
void saveSheet(SCH_SHEET *aSheet)
void saveJunction(SCH_JUNCTION *aJunction)
#define SCHEMATIC_HEAD_STRING
Definition: general.h:41
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:214
#define EESCHEMA_VERSION
Definition: general.h:40
const wxString & GetRevision() const
Definition: title_block.h:89
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
const wxString & GetCompany() const
Definition: title_block.h:99
const wxString & GetComment3() const
Definition: title_block.h:123
void saveBitmap(SCH_BITMAP *aBitmap)
void saveComponent(SCH_COMPONENT *aComponent)
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetComment2() const
Definition: title_block.h:122
bool IsPortrait() const
Definition: page_info.h:121
const wxString & GetComment1() const
Definition: title_block.h:121
int m_NumberOfScreens
Definition: base_screen.h:217
const wxString & GetTitle() const
Definition: title_block.h:65
KIWAY * m_kiway
Required for path to legacy component libraries.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
Object used to load, save, search, and otherwise manipulate symbol library files. ...
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry)
int GetWidthMils() const
Definition: page_info.h:137
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160

◆ GetError()

const wxString& SCH_LEGACY_PLUGIN::GetError ( ) const
inlineoverridevirtual

Return an error string to the caller.

This is useful for schematic loaders that can load partial schematics where throwing an exception would be problematic such as the KiCad legacy plugin.

Returns
an unformatted string containing errors if any.

Reimplemented from SCH_PLUGIN.

Definition at line 129 of file sch_legacy_plugin.h.

References m_error.

129 { return m_error; }
wxString m_error
For throwing exceptions or errors on partial schematic loads.

◆ GetFileExtension()

const wxString SCH_LEGACY_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Returns the file extension for the SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 72 of file sch_legacy_plugin.h.

73  {
74  return wxT( "sch" );
75  }

◆ GetModifyHash()

int SCH_LEGACY_PLUGIN::GetModifyHash ( ) const
overridevirtual

Return the modification hash from the library cache.

Note
This is temporary until the new s-expr file format is implement. The new file format will embed symbols instead of referencing them from the library. This function can be removed when the new file format is implemented.
Returns
the modification hash of the library cache.

Implements SCH_PLUGIN.

Definition at line 4147 of file sch_legacy_plugin.cpp.

References SCH_LEGACY_PLUGIN_CACHE::GetModifyHash(), and m_cache.

4148 {
4149  if( m_cache )
4150  return m_cache->GetModifyHash();
4151 
4152  // If the cache hasn't been loaded, it hasn't been modified.
4153  return 0;
4154 }
SCH_LEGACY_PLUGIN_CACHE * m_cache

◆ GetName()

const wxString SCH_LEGACY_PLUGIN::GetName ( ) const
inlineoverridevirtual

Returns a brief hard coded name for this SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 67 of file sch_legacy_plugin.h.

68  {
69  return wxT( "Eeschema-Legacy" );
70  }

◆ GetSymbolLibCount()

size_t SCH_LEGACY_PLUGIN::GetSymbolLibCount ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Reimplemented from SCH_PLUGIN.

Definition at line 4157 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::m_aliases, m_cache, and m_props.

4159 {
4160  LOCALE_IO toggle;
4161 
4162  m_props = aProperties;
4163 
4164  cacheLib( aLibraryPath );
4165 
4166  return m_cache->m_aliases.size();
4167 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
SCH_LEGACY_PLUGIN_CACHE * m_cache
void cacheLib(const wxString &aLibraryFileName)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ init()

void SCH_LEGACY_PLUGIN::init ( KIWAY aKiway,
const PROPERTIES aProperties = NULL 
)
protected

initialize PLUGIN like a constructor would.

Definition at line 573 of file sch_legacy_plugin.cpp.

References m_cache, m_kiway, m_out, m_props, m_rootSheet, and m_version.

Referenced by Load(), Save(), and SCH_LEGACY_PLUGIN().

574 {
575  m_version = 0;
576  m_rootSheet = NULL;
577  m_props = aProperties;
578  m_kiway = aKiway;
579  m_cache = NULL;
580  m_out = NULL;
581 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
SCH_LEGACY_PLUGIN_CACHE * m_cache
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded..
int m_version
Version of file being loaded.
KIWAY * m_kiway
Required for path to legacy component libraries.
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ isBuffering()

bool SCH_LEGACY_PLUGIN::isBuffering ( const PROPERTIES aProperties)
private

Definition at line 4141 of file sch_legacy_plugin.cpp.

References PROPERTIES::Exists(), and PropBuffering.

Referenced by cacheLib(), DeleteAlias(), DeleteSymbol(), and SaveSymbol().

4142 {
4143  return ( aProperties && aProperties->Exists( SCH_LEGACY_PLUGIN::PropBuffering ) );
4144 }
bool Exists(const std::string &aProperty) const
Definition: properties.h:44
static const char * PropBuffering
const char* PropBuffering

◆ IsSymbolLibWritable()

bool SCH_LEGACY_PLUGIN::IsSymbolLibWritable ( const wxString &  aLibraryPath)
overridevirtual

Return true if the library at aLibraryPath is writable.

(Often system libraries are read only because of where they are installed.)

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

Reimplemented from SCH_PLUGIN.

Definition at line 4356 of file sch_legacy_plugin.cpp.

4357 {
4358  return wxFileName::IsFileWritable( aLibraryPath );
4359 }

◆ Load()

SCH_SHEET * SCH_LEGACY_PLUGIN::Load ( const wxString &  aFileName,
KIWAY aKiway,
SCH_SHEET aAppendToMe = NULL,
const PROPERTIES aProperties = NULL 
)
overridevirtual

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

This may be used to load an entire new SCH_SHEET, 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.
aKiwayis the KIWAY object used to access the component libraries loaded by the project.
aAppendToMeis an existing SCH_SHEET to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the successfully loaded schematic, or the same one as aAppendToMe if aAppendToMe was not NULL, and the 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 SCH_PLUGIN.

Definition at line 584 of file sch_legacy_plugin.cpp.

References SCH_SHEET::GetFileName(), PROJECT::GetProjectPath(), SCH_SHEET::GetRootSheet(), init(), loadHierarchy(), m_currentPath, m_path, m_rootSheet, KIWAY::Prj(), and traceSchLegacyPlugin.

586 {
587  wxASSERT( !aFileName || aKiway != NULL );
588 
589  LOCALE_IO toggle; // toggles on, then off, the C locale.
590  SCH_SHEET* sheet;
591 
592  wxFileName fn = aFileName;
593 
594  // Unfortunately child sheet file names the legacy schematic file format are not fully
595  // qualified and are always appended to the project path. The aFileName attribute must
596  // always be an absolute path so the project path can be used for load child sheet files.
597  wxASSERT( fn.IsAbsolute() );
598 
599  if( aAppendToMe )
600  {
601  wxLogTrace( traceSchLegacyPlugin, "Append \"%s\" to sheet \"%s\".",
602  aFileName, aAppendToMe->GetFileName() );
603 
604  wxFileName normedFn = aAppendToMe->GetFileName();
605 
606  if( !normedFn.IsAbsolute() )
607  {
608  if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
609  m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
610  }
611 
612  if( m_path.IsEmpty() )
613  m_path = aKiway->Prj().GetProjectPath();
614 
615  wxLogTrace( traceSchLegacyPlugin, "Normalized append path \"%s\".", m_path );
616  }
617  else
618  {
619  m_path = aKiway->Prj().GetProjectPath();
620  }
621 
622  m_currentPath.push( m_path );
623  init( aKiway, aProperties );
624 
625  if( aAppendToMe == NULL )
626  {
627  // Clean up any allocated memory if an exception occurs loading the schematic.
628  std::unique_ptr< SCH_SHEET > newSheet( new SCH_SHEET );
629  newSheet->SetFileName( aFileName );
630  m_rootSheet = newSheet.get();
631  loadHierarchy( newSheet.get() );
632 
633  // If we got here, the schematic loaded successfully.
634  sheet = newSheet.release();
635  }
636  else
637  {
638  m_rootSheet = aAppendToMe->GetRootSheet();
639  wxASSERT( m_rootSheet != NULL );
640  sheet = aAppendToMe;
641  loadHierarchy( sheet );
642  }
643 
644  wxASSERT( m_currentPath.size() == 1 ); // only the project path should remain
645 
646  return sheet;
647 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:142
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded..
SCH_SHEET * GetRootSheet()
Return the root sheet of this SCH_SHEET object.
Definition: sch_sheet.cpp:136
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
wxString m_path
Root project path for loading child sheets.
void loadHierarchy(SCH_SHEET *aSheet)
void init(KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
initialize PLUGIN like a constructor would.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:662
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.

◆ loadBitmap()

SCH_BITMAP * SCH_LEGACY_PLUGIN::loadBitmap ( FILE_LINE_READER aReader)
private

Definition at line 1056 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), parseDouble(), parseInt(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, strCompare(), and THROW_IO_ERROR.

Referenced by loadFile().

1057 {
1058  std::unique_ptr< SCH_BITMAP > bitmap( new SCH_BITMAP );
1059 
1060  const char* line = aReader.Line();
1061 
1062  wxCHECK( strCompare( "$Bitmap", line, &line ), NULL );
1063 
1064  line = aReader.ReadLine();
1065 
1066  while( line != NULL )
1067  {
1068  if( strCompare( "Pos", line, &line ) )
1069  {
1070  wxPoint position;
1071 
1072  position.x = parseInt( aReader, line, &line );
1073  position.y = parseInt( aReader, line, &line );
1074  bitmap->SetPosition( position );
1075  }
1076  else if( strCompare( "Scale", line, &line ) )
1077  {
1078  auto scalefactor = parseDouble( aReader, line, &line );
1079 
1080  // Prevent scalefactor values that cannot be displayed.
1081  // In the case of a bad value, we accept that the image might be mis-scaled
1082  // rather than removing the full image. Users can then edit the scale factor in
1083  // Eeschema to the appropriate value
1084  if( !std::isnormal( scalefactor ) )
1085  scalefactor = 1.0;
1086 
1087  bitmap->GetImage()->SetScale( scalefactor );
1088  }
1089  else if( strCompare( "Data", line, &line ) )
1090  {
1091  wxMemoryOutputStream stream;
1092 
1093  while( line )
1094  {
1095  if( !aReader.ReadLine() )
1096  SCH_PARSE_ERROR( _( "Unexpected end of file" ), aReader, line );
1097 
1098  line = aReader.Line();
1099 
1100  if( strCompare( "EndData", line ) )
1101  {
1102  // all the PNG date is read.
1103  // We expect here m_image and m_bitmap are void
1104  wxImage* image = new wxImage();
1105  wxMemoryInputStream istream( stream );
1106  image->LoadFile( istream, wxBITMAP_TYPE_PNG );
1107  bitmap->GetImage()->SetImage( image );
1108  bitmap->GetImage()->SetBitmap( new wxBitmap( *image ) );
1109  break;
1110  }
1111 
1112  // Read PNG data, stored in hexadecimal,
1113  // each byte = 2 hexadecimal digits and a space between 2 bytes
1114  // and put it in memory stream buffer
1115  int len = strlen( line );
1116 
1117  for( ; len > 0 && !isspace( *line ); len -= 3, line += 3 )
1118  {
1119  int value = 0;
1120 
1121  if( sscanf( line, "%X", &value ) == 1 )
1122  stream.PutC( (char) value );
1123  else
1124  THROW_IO_ERROR( "invalid PNG data" );
1125  }
1126  }
1127 
1128  if( line == NULL )
1129  THROW_IO_ERROR( _( "unexpected end of file" ) );
1130  }
1131  else if( strCompare( "$EndBitmap", line ) )
1132  return bitmap.release();
1133 
1134  line = aReader.ReadLine();
1135  }
1136 
1137  THROW_IO_ERROR( _( "unexpected end of file" ) );
1138 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static double parseDouble(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parses an ASCII point string with possible leading whitespace into a double precision floating point ...
#define THROW_IO_ERROR(msg)
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
#define SCH_PARSE_ERROR(text, reader, pos)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ loadBusEntry()

SCH_BUS_ENTRY_BASE * SCH_LEGACY_PLUGIN::loadBusEntry ( FILE_LINE_READER aReader)
private

Definition at line 1283 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), parseInt(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, and strCompare().

Referenced by loadFile().

1284 {
1285  const char* line = aReader.Line();
1286 
1287  wxCHECK( strCompare( "Entry", line, &line ), NULL );
1288 
1289  std::unique_ptr< SCH_BUS_ENTRY_BASE > busEntry;
1290 
1291  if( strCompare( "Wire", line, &line ) )
1292  {
1293  busEntry.reset( new SCH_BUS_WIRE_ENTRY );
1294 
1295  if( !strCompare( "Line", line, &line ) )
1296  SCH_PARSE_ERROR( "invalid bus entry definition expected 'Line'", aReader, line );
1297  }
1298  else if( strCompare( "Bus", line, &line ) )
1299  {
1300  busEntry.reset( new SCH_BUS_BUS_ENTRY );
1301 
1302  if( !strCompare( "Bus", line, &line ) )
1303  SCH_PARSE_ERROR( "invalid bus entry definition expected 'Bus'", aReader, line );
1304  }
1305  else
1306  SCH_PARSE_ERROR( "invalid bus entry type", aReader, line );
1307 
1308  line = aReader.ReadLine();
1309 
1310  wxPoint pos;
1311  wxSize size;
1312 
1313  pos.x = parseInt( aReader, line, &line );
1314  pos.y = parseInt( aReader, line, &line );
1315  size.x = parseInt( aReader, line, &line );
1316  size.y = parseInt( aReader, line, &line );
1317 
1318  size.x -= pos.x;
1319  size.y -= pos.y;
1320 
1321  busEntry->SetPosition( pos );
1322  busEntry->SetSize( size );
1323 
1324  return busEntry.release();
1325 }
Class for a bus to bus entry.
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
#define SCH_PARSE_ERROR(text, reader, pos)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
Class for a wire to bus entry.

◆ loadComponent()

SCH_COMPONENT * SCH_LEGACY_PLUGIN::loadComponent ( FILE_LINE_READER aReader)
private

Definition at line 1428 of file sch_legacy_plugin.cpp.

References TEMPLATE_FIELDNAME::GetDefaultFieldName(), SCH_SHEET::GetScreen(), LINE_READER::GetSource(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, LIB_ID::ID_SCH, LINE_READER::Line(), LINE_READER::LineNumber(), m_rootSheet, m_version, MANDATORY_FIELDS, MAX_UNIT_COUNT_PER_PACKAGE, name, LIB_ID::Parse(), parseChar(), parseHex(), parseInt(), parseQuotedString(), parseUnquotedString(), FILE_LINE_READER::ReadLine(), REFERENCE, SCH_PARSE_ERROR, LIB_ID::SetLibItemName(), BASE_SCREEN::SetModify(), strCompare(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, THROW_PARSE_ERROR, TRANSFORM::x1, TRANSFORM::x2, TRANSFORM::y1, and TRANSFORM::y2.

Referenced by loadFile().

1429 {
1430  const char* line = aReader.Line();
1431 
1432  wxCHECK( strCompare( "$Comp", line, &line ), NULL );
1433 
1434  std::unique_ptr< SCH_COMPONENT > component( new SCH_COMPONENT() );
1435 
1436  line = aReader.ReadLine();
1437 
1438  while( line != NULL )
1439  {
1440  if( strCompare( "L", line, &line ) )
1441  {
1442  wxString libName;
1443  size_t pos = 2; // "X" plus ' ' space character.
1444  wxString utf8Line = wxString::FromUTF8( line );
1445  wxStringTokenizer tokens( utf8Line, " \r\n\t" );
1446 
1447  if( tokens.CountTokens() < 2 )
1448  THROW_PARSE_ERROR( "invalid symbol library definition", aReader.GetSource(),
1449  aReader.Line(), aReader.LineNumber(), pos );
1450 
1451  libName = tokens.GetNextToken();
1452  libName.Replace( "~", " " );
1453 
1454  LIB_ID libId;
1455 
1456  // Prior to schematic version 4, library IDs did not have a library nickname so
1457  // parsing the symbol name with LIB_ID::Parse() would break symbol library links
1458  // that contained '/' and ':' characters.
1459  if( m_version > 3 )
1460  libId.Parse( libName, LIB_ID::ID_SCH, true );
1461  else
1462  libId.SetLibItemName( libName, false );
1463 
1464  component->SetLibId( libId );
1465 
1466  wxString refDesignator = tokens.GetNextToken();
1467 
1468  refDesignator.Replace( "~", " " );
1469 
1470  wxString prefix = refDesignator;
1471 
1472  while( prefix.Length() )
1473  {
1474  if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' )
1475  break;
1476 
1477  prefix.RemoveLast();
1478  }
1479 
1480  // Avoid a prefix containing trailing/leading spaces
1481  prefix.Trim( true );
1482  prefix.Trim( false );
1483 
1484  if( prefix.IsEmpty() )
1485  component->SetPrefix( wxString( "U" ) );
1486  else
1487  component->SetPrefix( prefix );
1488  }
1489  else if( strCompare( "U", line, &line ) )
1490  {
1491  // This fixes a potentially buggy files caused by unit being set to zero which
1492  // causes netlist issues. See https://bugs.launchpad.net/kicad/+bug/1677282.
1493  int unit = parseInt( aReader, line, &line );
1494 
1495  if( unit == 0 )
1496  {
1497  unit = 1;
1498 
1499  // Set the file as modified so the user can be warned.
1500  if( m_rootSheet && m_rootSheet->GetScreen() )
1502  }
1503 
1504  component->SetUnit( unit );
1505  component->SetConvert( parseInt( aReader, line, &line ) );
1506  component->SetTimeStamp( parseHex( aReader, line, &line ) );
1507  }
1508  else if( strCompare( "P", line, &line ) )
1509  {
1510  wxPoint pos;
1511 
1512  pos.x = parseInt( aReader, line, &line );
1513  pos.y = parseInt( aReader, line, &line );
1514  component->SetPosition( pos );
1515  }
1516  else if( strCompare( "AR", line, &line ) )
1517  {
1518  const char* strCompare = "Path=";
1519  int len = strlen( strCompare );
1520 
1521  if( strncasecmp( strCompare, line, len ) != 0 )
1522  SCH_PARSE_ERROR( "missing 'Path=' token", aReader, line );
1523 
1524  line += len;
1525  wxString path, reference, unit;
1526 
1527  parseQuotedString( path, aReader, line, &line );
1528 
1529  strCompare = "Ref=";
1530  len = strlen( strCompare );
1531 
1532  if( strncasecmp( strCompare, line, len ) != 0 )
1533  SCH_PARSE_ERROR( "missing 'Ref=' token", aReader, line );
1534 
1535  line+= len;
1536  parseQuotedString( reference, aReader, line, &line );
1537 
1538  strCompare = "Part=";
1539  len = strlen( strCompare );
1540 
1541  if( strncasecmp( strCompare, line, len ) != 0 )
1542  SCH_PARSE_ERROR( "missing 'Part=' token", aReader, line );
1543 
1544  line+= len;
1545  parseQuotedString( unit, aReader, line, &line );
1546 
1547  long tmp;
1548 
1549  if( !unit.ToLong( &tmp, 10 ) )
1550  SCH_PARSE_ERROR( "expected integer value", aReader, line );
1551 
1552  if( tmp < 0 || tmp > MAX_UNIT_COUNT_PER_PACKAGE )
1553  SCH_PARSE_ERROR( "unit value out of range", aReader, line );
1554 
1555  component->AddHierarchicalReference( path, reference, (int)tmp );
1556  component->GetField( REFERENCE )->SetText( reference );
1557 
1558  }
1559  else if( strCompare( "F", line, &line ) )
1560  {
1561  int index = parseInt( aReader, line, &line );
1562 
1563  wxString text, name;
1564 
1565  parseQuotedString( text, aReader, line, &line, true );
1566 
1567  char orientation = parseChar( aReader, line, &line );
1568  wxPoint pos;
1569  pos.x = parseInt( aReader, line, &line );
1570  pos.y = parseInt( aReader, line, &line );
1571  int size = parseInt( aReader, line, &line );
1572  int attributes = parseHex( aReader, line, &line );
1573 
1574  if( index >= component->GetFieldCount() )
1575  {
1576  // The first MANDATOR_FIELDS _must_ be constructed within
1577  // the SCH_COMPONENT constructor. This assert is simply here
1578  // to guard against a change in that constructor.
1579  wxASSERT( component->GetFieldCount() >= MANDATORY_FIELDS );
1580 
1581  // Ignore the _supplied_ fieldNdx. It is not important anymore
1582  // if within the user defined fields region (i.e. >= MANDATORY_FIELDS).
1583  // We freely renumber the index to fit the next available field slot.
1584  index = component->GetFieldCount(); // new has this index after insertion
1585 
1586  SCH_FIELD field( wxPoint( 0, 0 ), -1, component.get(), name );
1587  component->AddField( field );
1588  }
1589 
1590  // Prior to version 2 of the schematic file format, none of the following existed.
1591  if( m_version > 1 )
1592  {
1593  wxString textAttrs;
1594  char hjustify = parseChar( aReader, line, &line );
1595 
1596  parseUnquotedString( textAttrs, aReader, line, &line );
1597 
1598  // The name of the field is optional.
1599  parseQuotedString( name, aReader, line, &line, true );
1600 
1601  if( hjustify == 'L' )
1602  component->GetField( index )->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1603  else if( hjustify == 'R' )
1604  component->GetField( index )->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
1605  else if( hjustify != 'C' )
1606  SCH_PARSE_ERROR( "component field text horizontal justification must be "
1607  "L, R, or C", aReader, line );
1608 
1609  // We are guaranteed to have a least one character here for older file formats
1610  // otherwise an exception would have been raised..
1611  if( textAttrs[0] == 'T' )
1612  component->GetField( index )->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
1613  else if( textAttrs[0] == 'B' )
1614  component->GetField( index )->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
1615  else if( textAttrs[0] != 'C' )
1616  SCH_PARSE_ERROR( "component field text vertical justification must be "
1617  "B, T, or C", aReader, line );
1618 
1619  // Newer file formats include the bold and italics text attribute.
1620  if( textAttrs.Length() > 1 )
1621  {
1622  if( textAttrs.Length() != 3 )
1623  SCH_PARSE_ERROR( _( "component field text attributes must be 3 characters wide" ),
1624  aReader, line );
1625 
1626  if( textAttrs[1] == 'I' )
1627  component->GetField( index )->SetItalic( true );
1628  else if( textAttrs[1] != 'N' )
1629  SCH_PARSE_ERROR( "component field text italics indicator must be I or N",
1630  aReader, line );
1631 
1632  if( textAttrs[2] == 'B' )
1633  component->GetField( index )->SetBold( true );
1634  else if( textAttrs[2] != 'N' )
1635  SCH_PARSE_ERROR( "component field text bold indicator must be B or N",
1636  aReader, line );
1637  }
1638  }
1639 
1640  component->GetField( index )->SetText( text );
1641  component->GetField( index )->SetTextPos( pos );
1642  component->GetField( index )->SetVisible( !attributes );
1643  component->GetField( index )->SetTextSize( wxSize( size, size ) );
1644 
1645  if( orientation == 'H' )
1646  component->GetField( index )->SetTextAngle( TEXT_ANGLE_HORIZ );
1647  else if( orientation == 'V' )
1648  component->GetField( index )->SetTextAngle( TEXT_ANGLE_VERT );
1649  else
1650  SCH_PARSE_ERROR( "component field orientation must be H or V",
1651  aReader, line );
1652 
1653  if( name.IsEmpty() )
1655 
1656  component->GetField( index )->SetName( name );
1657  }
1658  else if( strCompare( "$EndComp", line ) )
1659  {
1660  // Ensure all flags (some are set by previous initializations) are reset:
1661  component->ClearFlags();
1662  return component.release();
1663  }
1664  else
1665  {
1666  // There are two lines that begin with a tab or spaces that includes a line with the
1667  // redundant position information and the transform matrix settings.
1668 
1669  // Parse the redundant position information just the same to check for formatting
1670  // errors.
1671  parseInt( aReader, line, &line ); // Always 1.
1672  parseInt( aReader, line, &line ); // The X coordinate.
1673  parseInt( aReader, line, &line ); // The Y coordinate.
1674 
1675  line = aReader.ReadLine();
1676 
1677  TRANSFORM transform;
1678 
1679  transform.x1 = parseInt( aReader, line, &line );
1680 
1681  if( transform.x1 < -1 || transform.x1 > 1 )
1682  SCH_PARSE_ERROR( "invalid component X1 transform value", aReader, line );
1683 
1684  transform.y1 = parseInt( aReader, line, &line );
1685 
1686  if( transform.y1 < -1 || transform.y1 > 1 )
1687  SCH_PARSE_ERROR( "invalid component Y1 transform value", aReader, line );
1688 
1689  transform.x2 = parseInt( aReader, line, &line );
1690 
1691  if( transform.x2 < -1 || transform.x2 > 1 )
1692  SCH_PARSE_ERROR( "invalid component X2 transform value", aReader, line );
1693 
1694  transform.y2 = parseInt( aReader, line, &line );
1695 
1696  if( transform.y2 < -1 || transform.y2 > 1 )
1697  SCH_PARSE_ERROR( "invalid component Y2 transform value", aReader, line );
1698 
1699  component->SetTransform( transform );
1700  }
1701 
1702  line = aReader.ReadLine();
1703  }
1704 
1705  SCH_PARSE_ERROR( "invalid component line", aReader, line );
1706 
1707  return NULL; // Prevents compiler warning. Should never get here.
1708 }
#define TEXT_ANGLE_HORIZ
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
int y2
Definition: transform.h:51
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:130
#define TEXT_ANGLE_VERT
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
int x2
Definition: transform.h:50
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded..
int x1
Definition: transform.h:48
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
#define MAX_UNIT_COUNT_PER_PACKAGE
The maximum number of units per package.
Definition: eeschema_id.h:49
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
Field Reference of part, i.e. "IC21".
int m_version
Version of file being loaded.
int y1
Definition: transform.h:49
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:159
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
static unsigned long parseHex(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:206
#define SCH_PARSE_ERROR(text, reader, pos)
const char * name
Definition: DXF_plotter.cpp:61
static void parseQuotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:70
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
void SetModify()
Definition: base_screen.h:324
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122

◆ loadFile()

void SCH_LEGACY_PLUGIN::loadFile ( const wxString &  aFileName,
SCH_SCREEN aScreen 
)
private

Definition at line 733 of file sch_legacy_plugin.cpp.

References SCH_SCREEN::Append(), LINE_READER::Line(), loadBitmap(), loadBusEntry(), loadComponent(), loadHeader(), loadJunction(), loadNoConnect(), loadPageSettings(), loadSheet(), loadText(), loadWire(), m_version, FILE_LINE_READER::ReadLine(), strCompare(), and THROW_IO_ERROR.

Referenced by loadHierarchy().

734 {
735  FILE_LINE_READER reader( aFileName );
736 
737  loadHeader( reader, aScreen );
738 
739  while( reader.ReadLine() )
740  {
741  char* line = reader.Line();
742 
743  while( *line && *line == ' ' )
744  line++;
745 
746  // Either an object will be loaded properly or the file load will fail and raise
747  // an exception.
748  if( strCompare( "$Descr", line ) )
749  loadPageSettings( reader, aScreen );
750  else if( strCompare( "$Comp", line ) )
751  aScreen->Append( loadComponent( reader ) );
752  else if( strCompare( "$Sheet", line ) )
753  aScreen->Append( loadSheet( reader ) );
754  else if( strCompare( "$Bitmap", line ) )
755  aScreen->Append( loadBitmap( reader ) );
756  else if( strCompare( "Connection", line ) )
757  aScreen->Append( loadJunction( reader ) );
758  else if( strCompare( "NoConn", line ) )
759  aScreen->Append( loadNoConnect( reader ) );
760  else if( strCompare( "Wire", line ) )
761  aScreen->Append( loadWire( reader ) );
762  else if( strCompare( "Entry", line ) )
763  aScreen->Append( loadBusEntry( reader ) );
764  else if( strCompare( "Text", line ) )
765  aScreen->Append( loadText( reader ) );
766  else if( strCompare( "$EndSCHEMATC", line ) )
767  return;
768  }
769 
770  // Unfortunately schematic files prior to version 2 are not terminated with $EndSCHEMATC
771  // so checking for it's existance will fail so just exit here and take our chances. :(
772  if( m_version > 1 )
773  THROW_IO_ERROR( "'$EndSCHEMATC' not found" );
774 }
SCH_BITMAP * loadBitmap(FILE_LINE_READER &aReader)
void loadPageSettings(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
int m_version
Version of file being loaded.
SCH_SHEET * loadSheet(FILE_LINE_READER &aReader)
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
SCH_TEXT * loadText(FILE_LINE_READER &aReader)
#define THROW_IO_ERROR(msg)
SCH_JUNCTION * loadJunction(FILE_LINE_READER &aReader)
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:162
void loadHeader(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
SCH_BUS_ENTRY_BASE * loadBusEntry(FILE_LINE_READER &aReader)
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
SCH_COMPONENT * loadComponent(FILE_LINE_READER &aReader)
SCH_LINE * loadWire(FILE_LINE_READER &aReader)
SCH_NO_CONNECT * loadNoConnect(FILE_LINE_READER &aReader)

◆ loadHeader()

void SCH_LEGACY_PLUGIN::loadHeader ( FILE_LINE_READER aReader,
SCH_SCREEN aScreen 
)
private

Definition at line 777 of file sch_legacy_plugin.cpp.

References GetChars(), SCH_SCREEN::GetFileName(), LINE_READER::Line(), m_error, m_version, parseInt(), FILE_LINE_READER::ReadLine(), strCompare(), and THROW_IO_ERROR.

Referenced by loadFile().

778 {
779  const char* line = aReader.ReadLine();
780 
781  if( !line || !strCompare( "Eeschema Schematic File Version", line, &line ) )
782  {
783  m_error.Printf( _( "\"%s\" does not appear to be an Eeschema file" ),
784  GetChars( aScreen->GetFileName() ) );
786  }
787 
788  // get the file version here.
789  m_version = parseInt( aReader, line, &line );
790 
791  // The next lines are the lib list section, and are mainly comments, like:
792  // LIBS:power
793  // the lib list is not used, but is in schematic file just in case.
794  // It is usually not empty, but we accept empty list.
795  // If empty, there is a legacy section, not used
796  // EELAYER i j
797  // and the last line is
798  // EELAYER END
799  // Skip all lines until the end of header "EELAYER END" is found
800  while( aReader.ReadLine() )
801  {
802  line = aReader.Line();
803 
804  while( *line == ' ' )
805  line++;
806 
807  if( strCompare( "EELAYER END", line ) )
808  return;
809  }
810 
811  THROW_IO_ERROR( _( "Missing 'EELAYER END'" ) );
812 }
const wxString & GetFileName() const
Definition: sch_screen.h:131
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
wxString m_error
For throwing exceptions or errors on partial schematic loads.
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
int m_version
Version of file being loaded.
#define THROW_IO_ERROR(msg)
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ loadHierarchy()

void SCH_LEGACY_PLUGIN::loadHierarchy ( SCH_SHEET aSheet)
private

Definition at line 652 of file sch_legacy_plugin.cpp.

References SCH_SCREEN::GetDrawItems(), SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), loadFile(), m_currentPath, m_error, m_kiway, m_rootSheet, SCH_SHEET_T, SCH_SHEET::SearchHierarchy(), SCH_SCREEN::SetFileName(), EDA_ITEM::SetParent(), SCH_SHEET::SetScreen(), traceSchLegacyPlugin, and IO_ERROR::What().

Referenced by Load().

653 {
654  SCH_SCREEN* screen = NULL;
655 
656  if( !aSheet->GetScreen() )
657  {
658  // SCH_SCREEN objects store the full path and file name where the SCH_SHEET object only
659  // stores the file name and extension. Add the project path to the file name and
660  // extension to compare when calling SCH_SHEET::SearchHierarchy().
661  wxFileName fileName = aSheet->GetFileName();
662 
663  if( !fileName.IsAbsolute() )
664  fileName.MakeAbsolute( m_currentPath.top() );
665 
666  // Save the current path so that it gets restored when decending and ascending the
667  // sheet hierarchy which allows for sheet schematic files to be nested in folders
668  // relative to the last path a schematic was loaded from.
669  wxLogTrace( traceSchLegacyPlugin, "Saving path \"%s\"", m_currentPath.top() );
670  m_currentPath.push( fileName.GetPath() );
671  wxLogTrace( traceSchLegacyPlugin, "Current path \"%s\"", m_currentPath.top() );
672  wxLogTrace( traceSchLegacyPlugin, "Loading \"%s\"", fileName.GetFullPath() );
673 
674  m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
675 
676  if( screen )
677  {
678  aSheet->SetScreen( screen );
679 
680  // Do not need to load the sub-sheets - this has already been done.
681  }
682  else
683  {
684  aSheet->SetScreen( new SCH_SCREEN( m_kiway ) );
685  aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
686 
687  try
688  {
689  loadFile( fileName.GetFullPath(), aSheet->GetScreen() );
690 
691  EDA_ITEM* item = aSheet->GetScreen()->GetDrawItems();
692 
693  while( item )
694  {
695  if( item->Type() == SCH_SHEET_T )
696  {
697  SCH_SHEET* sheet = (SCH_SHEET*) item;
698 
699  // Set the parent to aSheet. This effectively creates a method to find
700  // the root sheet from any sheet so a pointer to the root sheet does not
701  // need to be stored globally. Note: this is not the same as a hierarchy.
702  // Complex hierarchies can have multiple copies of a sheet. This only
703  // provides a simple tree to find the root sheet.
704  sheet->SetParent( aSheet );
705 
706  // Recursion starts here.
707  loadHierarchy( sheet );
708  }
709 
710  item = item->Next();
711  }
712  }
713  catch( const IO_ERROR& ioe )
714  {
715  // If there is a problem loading the root sheet, there is no recovery.
716  if( aSheet == m_rootSheet )
717  throw( ioe );
718 
719  // For all subsheets, queue up the error message for the caller.
720  if( !m_error.IsEmpty() )
721  m_error += "\n";
722 
723  m_error += ioe.What();
724  }
725  }
726 
727  m_currentPath.pop();
728  wxLogTrace( traceSchLegacyPlugin, "Restoring path \"%s\"", m_currentPath.top() );
729  }
730 }
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:579
wxString m_error
For throwing exceptions or errors on partial schematic loads.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded..
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
void loadFile(const wxString &aFileName, SCH_SCREEN *aScreen)
void loadHierarchy(SCH_SHEET *aSheet)
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:662
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:129
KIWAY * m_kiway
Required for path to legacy component libraries.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160

◆ loadJunction()

SCH_JUNCTION * SCH_LEGACY_PLUGIN::loadJunction ( FILE_LINE_READER aReader)
private

Definition at line 1141 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), name, parseInt(), parseUnquotedString(), and strCompare().

Referenced by loadFile().

1142 {
1143  std::unique_ptr< SCH_JUNCTION > junction( new SCH_JUNCTION );
1144 
1145  const char* line = aReader.Line();
1146 
1147  wxCHECK( strCompare( "Connection", line, &line ), NULL );
1148 
1149  wxString name;
1150 
1151  parseUnquotedString( name, aReader, line, &line );
1152 
1153  wxPoint position;
1154 
1155  position.x = parseInt( aReader, line, &line );
1156  position.y = parseInt( aReader, line, &line );
1157  junction->SetPosition( position );
1158 
1159  return junction.release();
1160 }
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
const char * name
Definition: DXF_plotter.cpp:61
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ loadNoConnect()

SCH_NO_CONNECT * SCH_LEGACY_PLUGIN::loadNoConnect ( FILE_LINE_READER aReader)
private

Definition at line 1163 of file sch_legacy_plugin.cpp.

References LINE_READER::Line(), name, parseInt(), parseUnquotedString(), and strCompare().

Referenced by loadFile().

1164 {
1165  std::unique_ptr< SCH_NO_CONNECT > no_connect( new SCH_NO_CONNECT );
1166 
1167  const char* line = aReader.Line();
1168 
1169  wxCHECK( strCompare( "NoConn", line, &line ), NULL );
1170 
1171  wxString name;
1172 
1173  parseUnquotedString( name, aReader, line, &line );
1174 
1175  wxPoint position;
1176 
1177  position.x = parseInt( aReader, line, &line );
1178  position.y = parseInt( aReader, line, &line );
1179  no_connect->SetPosition( position );
1180 
1181  return no_connect.release();
1182 }
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
const char * name
Definition: DXF_plotter.cpp:61
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ loadPageSettings()

void SCH_LEGACY_PLUGIN::loadPageSettings ( FILE_LINE_READER aReader,
SCH_SCREEN aScreen 
)
private

Definition at line 815 of file sch_legacy_plugin.cpp.

References PAGE_INFO::Custom, LINE_READER::Line(), BASE_SCREEN::m_NumberOfScreens, BASE_SCREEN::m_ScreenNumber, parseInt(), parseQuotedString(), parseUnquotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, TITLE_BLOCK::SetComment1(), TITLE_BLOCK::SetComment2(), TITLE_BLOCK::SetComment3(), TITLE_BLOCK::SetComment4(), TITLE_BLOCK::SetCompany(), TITLE_BLOCK::SetDate(), PAGE_INFO::SetHeightMils(), SCH_SCREEN::SetPageSettings(), PAGE_INFO::SetPortrait(), TITLE_BLOCK::SetRevision(), TITLE_BLOCK::SetTitle(), SCH_SCREEN::SetTitleBlock(), PAGE_INFO::SetType(), PAGE_INFO::SetWidthMils(), and strCompare().

Referenced by loadFile().

816 {
817  wxASSERT( aScreen != NULL );
818 
819  wxString buf;
820  const char* line = aReader.Line();
821 
822  PAGE_INFO pageInfo;
823  TITLE_BLOCK tb;
824 
825  wxCHECK_RET( strCompare( "$Descr", line, &line ), "Invalid sheet description" );
826 
827  parseUnquotedString( buf, aReader, line, &line );
828 
829  if( !pageInfo.SetType( buf ) )
830  SCH_PARSE_ERROR( "invalid page size", aReader, line );
831 
832  int pagew = parseInt( aReader, line, &line );
833  int pageh = parseInt( aReader, line, &line );
834 
835  if( buf == PAGE_INFO::Custom )
836  {
837  pageInfo.SetWidthMils( pagew );
838  pageInfo.SetHeightMils( pageh );
839  }
840  else
841  {
842  wxString orientation;
843 
844  // Non custom size, set portrait if its present. Can be empty string which defaults
845  // to landscape.
846  parseUnquotedString( orientation, aReader, line, &line, true );
847 
848  if( orientation == "portrait" )
849  pageInfo.SetPortrait( true );
850  }
851 
852  aScreen->SetPageSettings( pageInfo );
853 
854  while( line != NULL )
855  {
856  buf.clear();
857 
858  if( !aReader.ReadLine() )
859  SCH_PARSE_ERROR( _( "unexpected end of file" ), aReader, line );
860 
861  line = aReader.Line();
862 
863  if( strCompare( "Sheet", line, &line ) )
864  {
865  aScreen->m_ScreenNumber = parseInt( aReader, line, &line );
866  aScreen->m_NumberOfScreens = parseInt( aReader, line, &line );
867  }
868  else if( strCompare( "Title", line, &line ) )
869  {
870  parseQuotedString( buf, aReader, line, &line, true );
871  tb.SetTitle( buf );
872  }
873  else if( strCompare( "Date", line, &line ) )
874  {
875  parseQuotedString( buf, aReader, line, &line, true );
876  tb.SetDate( buf );
877  }
878  else if( strCompare( "Rev", line, &line ) )
879  {
880  parseQuotedString( buf, aReader, line, &line, true );
881  tb.SetRevision( buf );
882  }
883  else if( strCompare( "Comp", line, &line ) )
884  {
885  parseQuotedString( buf, aReader, line, &line, true );
886  tb.SetCompany( buf );
887  }
888  else if( strCompare( "Comment1", line, &line ) )
889  {
890  parseQuotedString( buf, aReader, line, &line, true );
891  tb.SetComment1( buf );
892  }
893  else if( strCompare( "Comment2", line, &line ) )
894  {
895  parseQuotedString( buf, aReader, line, &line, true );
896  tb.SetComment2( buf );
897  }
898  else if( strCompare( "Comment3", line, &line ) )
899  {
900  parseQuotedString( buf, aReader, line, &line, true );
901  tb.SetComment3( buf );
902  }
903  else if( strCompare( "Comment4", line, &line ) )
904  {
905  parseQuotedString( buf, aReader, line, &line, true );
906  tb.SetComment4( buf );
907  }
908  else if( strCompare( "$EndDescr", line ) )
909  {
910  aScreen->SetTitleBlock( tb );
911  return;
912  }
913  }
914 
915  SCH_PARSE_ERROR( "missing 'EndDescr'", aReader, line );
916 }
void SetComment1(const wxString &aComment)
Definition: title_block.h:117
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
int m_ScreenNumber
Definition: base_screen.h:216
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
void SetRevision(const wxString &aRevision)
Definition: title_block.h:84
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Definition: title_block.h:74
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:127
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:78
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void SetComment4(const wxString &aComment)
Definition: title_block.h:120
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
void SetCompany(const wxString &aCompany)
Definition: title_block.h:94
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:138
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:253
void SetComment2(const wxString &aComment)
Definition: title_block.h:118
#define SCH_PARSE_ERROR(text, reader, pos)
static void parseQuotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:239
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
int m_NumberOfScreens
Definition: base_screen.h:217
void SetComment3(const wxString &aComment)
Definition: title_block.h:119
void SetPortrait(bool aIsPortrait)
Function SetPortrait will rotate the paper page 90 degrees.
Definition: page_info.cpp:182

◆ loadSheet()

SCH_SHEET * SCH_LEGACY_PLUGIN::loadSheet ( FILE_LINE_READER aReader)
private

Definition at line 919 of file sch_legacy_plugin.cpp.

References GetNewTimeStamp(), NET_BIDI, NET_INPUT, NET_OUTPUT, NET_TRISTATE, NET_UNSPECIFIED, parseChar(), parseHex(), parseInt(), parseQuotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, SCH_SHEET_PIN::SHEET_BOTTOM_SIDE, SCH_SHEET_PIN::SHEET_LEFT_SIDE, SCH_SHEET_PIN::SHEET_RIGHT_SIDE, SCH_SHEET_PIN::SHEET_TOP_SIDE, strCompare(), and THROW_IO_ERROR.

Referenced by loadFile().

920 {
921  std::unique_ptr< SCH_SHEET > sheet( new SCH_SHEET() );
922 
923  sheet->SetTimeStamp( GetNewTimeStamp() );
924 
925  const char* line = aReader.ReadLine();
926 
927  while( line != NULL )
928  {
929  if( strCompare( "S", line, &line ) ) // Sheet dimensions.
930  {
931  wxPoint position;
932 
933  position.x = parseInt( aReader, line, &line );
934  position.y = parseInt( aReader, line, &line );
935  sheet->SetPosition( position );
936 
937  wxSize size;
938 
939  size.SetWidth( parseInt( aReader, line, &line ) );
940  size.SetHeight( parseInt( aReader, line, &line ) );
941  sheet->SetSize( size );
942  }
943  else if( strCompare( "U", line, &line ) ) // Sheet time stamp.
944  {
945  sheet->SetTimeStamp( parseHex( aReader, line ) );
946  }
947  else if( *line == 'F' ) // Sheet field.
948  {
949  line++;
950 
951  wxString text;
952  int size;
953  int fieldId = parseInt( aReader, line, &line );
954 
955  if( fieldId == 0 || fieldId == 1 ) // Sheet name and file name.
956  {
957  parseQuotedString( text, aReader, line, &line );
958  size = parseInt( aReader, line, &line );
959 
960  if( fieldId == 0 )
961  {
962  sheet->SetName( text );
963  sheet->SetSheetNameSize( size );
964  }
965  else
966  {
967  sheet->SetFileName( text );
968  sheet->SetFileNameSize( size );
969  }
970  }
971  else // Sheet pin.
972  {
973  std::unique_ptr< SCH_SHEET_PIN > sheetPin( new SCH_SHEET_PIN( sheet.get() ) );
974 
975  sheetPin->SetNumber( fieldId );
976 
977  // Can be empty fields.
978  parseQuotedString( text, aReader, line, &line, true );
979 
980  sheetPin->SetText( text );
981 
982  if( line == NULL )
983  THROW_IO_ERROR( _( "unexpected end of line" ) );
984 
985  switch( parseChar( aReader, line, &line ) )
986  {
987  case 'I':
988  sheetPin->SetShape( NET_INPUT );
989  break;
990 
991  case 'O':
992  sheetPin->SetShape( NET_OUTPUT );
993  break;
994 
995  case 'B':
996  sheetPin->SetShape( NET_BIDI );
997  break;
998 
999  case 'T':
1000  sheetPin->SetShape( NET_TRISTATE );
1001  break;
1002 
1003  case 'U':
1004  sheetPin->SetShape( NET_UNSPECIFIED );
1005  break;
1006  default:
1007  SCH_PARSE_ERROR( "invalid sheet pin type", aReader, line );
1008  }
1009 
1010  switch( parseChar( aReader, line, &line ) )
1011  {
1012  case 'R': /* pin on right side */
1013  sheetPin->SetEdge( SCH_SHEET_PIN::SHEET_RIGHT_SIDE );
1014  break;
1015 
1016  case 'T': /* pin on top side */
1017  sheetPin->SetEdge( SCH_SHEET_PIN::SHEET_TOP_SIDE );
1018  break;
1019 
1020  case 'B': /* pin on bottom side */
1021  sheetPin->SetEdge( SCH_SHEET_PIN::SHEET_BOTTOM_SIDE );
1022  break;
1023 
1024  case 'L': /* pin on left side */
1025  sheetPin->SetEdge( SCH_SHEET_PIN::SHEET_LEFT_SIDE );
1026  break;
1027  default:
1028  SCH_PARSE_ERROR( "invalid sheet pin side", aReader, line );
1029  }
1030 
1031  wxPoint position;
1032 
1033  position.x = parseInt( aReader, line, &line );
1034  position.y = parseInt( aReader, line, &line );
1035  sheetPin->SetPosition( position );
1036 
1037  size = parseInt( aReader, line, &line );
1038 
1039  sheetPin->SetTextSize( wxSize( size, size ) );
1040 
1041  sheet->AddPin( sheetPin.release() );
1042  }
1043  }
1044  else if( strCompare( "$EndSheet", line ) )
1045  return sheet.release();
1046 
1047  line = aReader.ReadLine();
1048  }
1049 
1050  SCH_PARSE_ERROR( "missing '$EndSheet`", aReader, line );
1051 
1052  return NULL; // Prevents compiler warning. Should never get here.
1053 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
static char parseChar(FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL)
Parse a single ASCII character and updates the pointer at aOutput if it is not NULL.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:216
static unsigned long parseHex(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates th...
#define THROW_IO_ERROR(msg)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
#define SCH_PARSE_ERROR(text, reader, pos)
static void parseQuotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an quoted ASCII utf8 and updates the pointer at aOutput if it is not NULL.
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ LoadSymbol()

LIB_ALIAS * SCH_LEGACY_PLUGIN::LoadSymbol ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Load a LIB_ALIAS object having aAliasName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about.

The LIB_PART should be accessed indirectly using the LIB_ALIAS it is associated with.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the alias name of the LIB_PART to load.
aPropertiesis an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the alias if found caller shares it or NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found.

Reimplemented from SCH_PLUGIN.

Definition at line 4214 of file sch_legacy_plugin.cpp.

References cacheLib(), SCH_LEGACY_PLUGIN_CACHE::m_aliases, m_cache, and m_props.

4216 {
4217  LOCALE_IO toggle; // toggles on, then off, the C locale.
4218 
4219  m_props = aProperties;
4220 
4221  cacheLib( aLibraryPath );
4222 
4223  LIB_ALIAS_MAP::const_iterator it = m_cache->m_aliases.find( aAliasName );
4224 
4225  if( it == m_cache->m_aliases.end() )
4226  return NULL;
4227 
4228  return it->second;
4229 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
SCH_LEGACY_PLUGIN_CACHE * m_cache
void cacheLib(const wxString &aLibraryFileName)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ loadText()

SCH_TEXT * SCH_LEGACY_PLUGIN::loadText ( FILE_LINE_READER aReader)
private

Definition at line 1328 of file sch_legacy_plugin.cpp.

References FROM_UTF8(), GetPenSizeForBold(), i, LINE_READER::Line(), m_version, NET_BIDI, NET_INPUT, NET_OUTPUT, NET_TRISTATE, NET_UNSPECIFIED, parseInt(), FILE_LINE_READER::ReadLine(), SCH_GLOBAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T, SCH_PARSE_ERROR, SheetLabelType, and strCompare().

Referenced by loadFile().

1329 {
1330  const char* line = aReader.Line();
1331 
1332  wxCHECK( strCompare( "Text", line, &line ), NULL );
1333 
1334  std::unique_ptr< SCH_TEXT> text;
1335 
1336  if( strCompare( "Notes", line, &line ) )
1337  text.reset( new SCH_TEXT );
1338  else if( strCompare( "Label", line, &line ) )
1339  text.reset( new SCH_LABEL );
1340  else if( strCompare( "HLabel", line, &line ) )
1341  text.reset( new SCH_HIERLABEL );
1342  else if( strCompare( "GLabel", line, &line ) )
1343  {
1344  // Prior to version 2, the SCH_GLOBALLABEL object did not exist.
1345  if( m_version == 1 )
1346  text.reset( new SCH_HIERLABEL );
1347  else
1348  text.reset( new SCH_GLOBALLABEL );
1349  }
1350  else
1351  SCH_PARSE_ERROR( "unknown Text type", aReader, line );
1352 
1353  // Parse the parameters common to all text objects.
1354  wxPoint position;
1355 
1356  position.x = parseInt( aReader, line, &line );
1357  position.y = parseInt( aReader, line, &line );
1358  text->SetPosition( position );
1359  text->SetLabelSpinStyle( parseInt( aReader, line, &line ) );
1360 
1361  int size = parseInt( aReader, line, &line );
1362 
1363  text->SetTextSize( wxSize( size, size ) );
1364 
1365  // Parse the global and hierarchical label type.
1366  if( text->Type() == SCH_HIERARCHICAL_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T )
1367  {
1368  if( strCompare( SheetLabelType[NET_INPUT], line, &line ) )
1369  text->SetShape( NET_INPUT );
1370  else if( strCompare( SheetLabelType[NET_OUTPUT], line, &line ) )
1371  text->SetShape( NET_OUTPUT );
1372  else if( strCompare( SheetLabelType[NET_BIDI], line, &line ) )
1373  text->SetShape( NET_BIDI );
1374  else if( strCompare( SheetLabelType[NET_TRISTATE], line, &line ) )
1375  text->SetShape( NET_TRISTATE );
1376  else if( strCompare( SheetLabelType[NET_UNSPECIFIED], line, &line ) )
1377  text->SetShape( NET_UNSPECIFIED );
1378  else
1379  SCH_PARSE_ERROR( "invalid label type", aReader, line );
1380  }
1381 
1382  int thickness = 0;
1383 
1384  // The following tokens do not exist in version 1 schematic files,
1385  // and not always in version 2 for HLabels and GLabels
1386  if( m_version > 1 )
1387  {
1388  if( m_version > 2 || *line >= ' ' )
1389  {
1390  if( strCompare( "Italic", line, &line ) )
1391  text->SetItalic( true );
1392  else if( !strCompare( "~", line, &line ) )
1393  SCH_PARSE_ERROR( _( "expected 'Italics' or '~'" ), aReader, line );
1394  }
1395 
1396  // The thickness token does not exist in older versions of the schematic file format
1397  // so calling parseInt will be made only if the EOL is not reached.
1398  if( *line >= ' ' )
1399  thickness = parseInt( aReader, line, &line );
1400  }
1401 
1402  text->SetBold( thickness != 0 );
1403  text->SetThickness( thickness != 0 ? GetPenSizeForBold( size ) : 0 );
1404 
1405  // Read the text string for the text.
1406  char* tmp = aReader.ReadLine();
1407 
1408  tmp = strtok( tmp, "\r\n" );
1409  wxString val = FROM_UTF8( tmp );
1410 
1411  for( ; ; )
1412  {
1413  int i = val.find( wxT( "\\n" ) );
1414 
1415  if( i == wxNOT_FOUND )
1416  break;
1417 
1418  val.erase( i, 2 );
1419  val.insert( i, wxT( "\n" ) );
1420  }
1421 
1422  text->SetText( val );
1423 
1424  return text.release();
1425 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
const char * SheetLabelType[]
Definition: sch_text.cpp:58
int m_version
Version of file being loaded.
#define SCH_PARSE_ERROR(text, reader, pos)
size_t i
Definition: json11.cpp:597
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...

◆ loadWire()

SCH_LINE * SCH_LEGACY_PLUGIN::loadWire ( FILE_LINE_READER aReader)
private

Definition at line 1185 of file sch_legacy_plugin.cpp.

References color, SCH_LINE::GetLineStyleInternalId(), is_eol(), LAYER_BUS, LAYER_NOTES, LAYER_WIRE, LINE_READER::Line(), parseInt(), parseUnquotedString(), FILE_LINE_READER::ReadLine(), SCH_PARSE_ERROR, strCompare(), T_COLOR, T_COLORA, T_STYLE, and T_WIDTH.

Referenced by loadFile().

1186 {
1187  std::unique_ptr< SCH_LINE > wire( new SCH_LINE );
1188 
1189  const char* line = aReader.Line();
1190 
1191  wxCHECK( strCompare( "Wire", line, &line ), NULL );
1192 
1193  if( strCompare( "Wire", line, &line ) )
1194  wire->SetLayer( LAYER_WIRE );
1195  else if( strCompare( "Bus", line, &line ) )
1196  wire->SetLayer( LAYER_BUS );
1197  else if( strCompare( "Notes", line, &line ) )
1198  wire->SetLayer( LAYER_NOTES );
1199  else
1200  SCH_PARSE_ERROR( "invalid line type", aReader, line );
1201 
1202  if( !strCompare( "Line", line, &line ) )
1203  SCH_PARSE_ERROR( "invalid wire definition", aReader, line );
1204 
1205  // Since Sept 15, 2017, a line style is alloved (width, style, color)
1206  // Only non default values are stored
1207  while( !is_eol( *line ) )
1208  {
1209  wxString buf;
1210 
1211  parseUnquotedString( buf, aReader, line, &line );
1212 
1213  if( buf == ")" )
1214  continue;
1215 
1216  else if( buf == T_WIDTH )
1217  {
1218  int size = parseInt( aReader, line, &line );
1219  wire->SetLineWidth( size );
1220  }
1221  else if( buf == T_STYLE )
1222  {
1223  parseUnquotedString( buf, aReader, line, &line );
1224  int style = SCH_LINE::GetLineStyleInternalId( buf );
1225  wire->SetLineStyle( style );
1226  }
1227  else // should be the color parameter.
1228  {
1229  // The color param is something like rgb(150, 40, 191)
1230  // and because there is no space between ( and 150
1231  // the first param is inside buf.
1232  // So break keyword and the first param into 2 separate strings.
1233  wxString prm, keyword;
1234  keyword = buf.BeforeLast( '(', &prm );
1235 
1236  if( ( keyword == T_COLOR ) || ( keyword == T_COLORA ) )
1237  {
1238  long color[4] = { 0 };
1239 
1240  int ii = 0;
1241 
1242  if( !prm.IsEmpty() )
1243  {
1244  prm.ToLong( &color[ii] );
1245  ii++;
1246  }
1247 
1248  int prm_count = ( keyword == T_COLORA ) ? 4 : 3;
1249  // fix opacity to 1.0 or 255, when not exists in file
1250  color[3] = 255;
1251 
1252  for(; ii < prm_count && !is_eol( *line ); ii++ )
1253  {
1254  color[ii] = parseInt( aReader, line, &line );
1255 
1256  // Skip the separator between values
1257  if( *line == ',' || *line == ' ')
1258  line++;
1259  }
1260 
1261  wire->SetLineColor( color[0]/255.0, color[1]/255.0, color[2]/255.0,color[3]/255.0 );
1262  }
1263  }
1264  }
1265 
1266  // Read the segment en points coordinates:
1267  line = aReader.ReadLine();
1268 
1269  wxPoint begin, end;
1270 
1271  begin.x = parseInt( aReader, line, &line );
1272  begin.y = parseInt( aReader, line, &line );
1273  end.x = parseInt( aReader, line, &line );
1274  end.y = parseInt( aReader, line, &line );
1275 
1276  wire->SetStartPoint( begin );
1277  wire->SetEndPoint( end );
1278 
1279  return wire.release();
1280 }
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
Definition: richio.cpp:194
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
static int parseInt(FILE_LINE_READER &aReader, const char *aLine, const char **aOutput=NULL)
Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointe...
int color
Definition: DXF_plotter.cpp:62
#define T_WIDTH
#define T_STYLE
static void parseUnquotedString(wxString &aString, FILE_LINE_READER &aReader, const char *aCurrentToken, const char **aNextToken=NULL, bool aCanBeEmpty=false)
Parse an unquoted utf8 string and updates the pointer at aOutput if it is not NULL.
static bool is_eol(char c)
#define T_COLOR
static int GetLineStyleInternalId(const wxString &aStyleName)
Definition: sch_line.cpp:140
#define SCH_PARSE_ERROR(text, reader, pos)
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
static bool strCompare(const char *aString, const char *aLine, const char **aOutput=NULL)
Compare aString to the string starting at aLine and advances the character point to the end of String...
#define T_COLORA

◆ Save()

void SCH_LEGACY_PLUGIN::Save ( const wxString &  aFileName,
SCH_SCREEN aSchematic,
KIWAY aKiway,
const PROPERTIES aProperties = NULL 
)
overridevirtual

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

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

Reimplemented from SCH_PLUGIN.

Definition at line 1711 of file sch_legacy_plugin.cpp.

References Format(), init(), and m_out.

1713 {
1714  wxCHECK_RET( aScreen != NULL, "NULL SCH_SCREEN object." );
1715  wxCHECK_RET( !aFileName.IsEmpty(), "No schematic file name defined." );
1716 
1717  LOCALE_IO toggle; // toggles on, then off, the C locale, to write floating point values.
1718 
1719  init( aKiway, aProperties );
1720 
1721  wxFileName fn = aFileName;
1722 
1723  // File names should be absolute. Don't assume everything relative to the project path
1724  // works properly.
1725  wxASSERT( fn.IsAbsolute() );
1726 
1727  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
1728 
1729  m_out = &formatter; // no ownership
1730 
1731  Format( aScreen );
1732 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:180
void Format(SCH_SCREEN *aScreen)
void init(KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
initialize PLUGIN like a constructor would.
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492

◆ saveBitmap()

void SCH_LEGACY_PLUGIN::saveBitmap ( SCH_BITMAP aBitmap)
private

Definition at line 1953 of file sch_legacy_plugin.cpp.

References SCH_BITMAP::GetImage(), BITMAP_BASE::GetImageData(), SCH_BITMAP::GetPosition(), BITMAP_BASE::GetScale(), m_out, and OUTPUTFORMATTER::Print().

Referenced by Format().

1954 {
1955  wxCHECK_RET( aBitmap != NULL, "SCH_BITMAP* is NULL" );
1956 
1957  wxImage* image = aBitmap->GetImage()->GetImageData();
1958 
1959  wxCHECK_RET( image != NULL, "wxImage* is NULL" );
1960 
1961  m_out->Print( 0, "$Bitmap\n" );
1962  m_out->Print( 0, "Pos %-4d %-4d\n", aBitmap->GetPosition().x, aBitmap->GetPosition().y );
1963  m_out->Print( 0, "Scale %f\n", aBitmap->GetImage()->GetScale() );
1964  m_out->Print( 0, "Data\n" );
1965 
1966  wxMemoryOutputStream stream;
1967 
1968  image->SaveFile( stream, wxBITMAP_TYPE_PNG );
1969 
1970  // Write binary data in hexadecimal form (ASCII)
1971  wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
1972  char* begin = (char*) buffer->GetBufferStart();
1973 
1974  for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ )
1975  {
1976  if( ii >= 32 )
1977  {
1978  ii = 0;
1979 
1980  m_out->Print( 0, "\n" );
1981  }
1982 
1983  m_out->Print( 0, "%2.2X ", *begin & 0xFF );
1984  }
1985 
1986  m_out->Print( 0, "\nEndData\n" );
1987  m_out->Print( 0, "$EndBitmap\n" );
1988 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
double GetScale() const
Definition: bitmap_base.h:84
wxImage * GetImageData()
Definition: bitmap_base.h:77
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:157
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:65
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

◆ saveBusEntry()

void SCH_LEGACY_PLUGIN::saveBusEntry ( SCH_BUS_ENTRY_BASE aBusEntry)
private

Definition at line 2084 of file sch_legacy_plugin.cpp.

References SCH_ITEM::GetLayer(), SCH_BUS_ENTRY_BASE::GetPosition(), LAYER_WIRE, SCH_BUS_ENTRY_BASE::m_End(), m_out, and OUTPUTFORMATTER::Print().

Referenced by Format().

2085 {
2086  wxCHECK_RET( aBusEntry != NULL, "SCH_BUS_ENTRY_BASE* is NULL" );
2087 
2088  if( aBusEntry->GetLayer() == LAYER_WIRE )
2089  m_out->Print( 0, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n",
2090  aBusEntry->GetPosition().x, aBusEntry->GetPosition().y,
2091  aBusEntry->m_End().x, aBusEntry->m_End().y );
2092  else
2093  m_out->Print( 0, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n",
2094  aBusEntry->GetPosition().x, aBusEntry->GetPosition().y,
2095  aBusEntry->m_End().x, aBusEntry->m_End().y );
2096 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
wxPoint m_End() const
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
wxPoint GetPosition() const override
Function GetPosition.

◆ saveComponent()

void SCH_LEGACY_PLUGIN::saveComponent ( SCH_COMPONENT aComponent)
private

Definition at line 1816 of file sch_legacy_plugin.cpp.

References LIB_ID::Format(), SCH_COMPONENT::GetConvert(), SCH_COMPONENT::GetField(), SCH_COMPONENT::GetFieldCount(), SCH_COMPONENT::GetLibId(), SCH_COMPONENT::GetPathsAndReferences(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetPrefix(), EDA_TEXT::GetText(), EDA_ITEM::GetTimeStamp(), SCH_COMPONENT::GetTransform(), SCH_COMPONENT::GetUnit(), i, m_out, MANDATORY_FIELDS, OUTPUTFORMATTER::Print(), REFERENCE, saveField(), SCH_FIELD::SetId(), TO_UTF8, toUTFTildaText(), TRANSFORM::x1, TRANSFORM::x2, TRANSFORM::y1, and TRANSFORM::y2.

Referenced by Format().

1817 {
1818  std::string name1;
1819  std::string name2;
1820  wxArrayString reference_fields;
1821 
1822  static wxString delimiters( wxT( " " ) );
1823 
1824  // This is redundant with the AR entries below, but it makes the files backwards-compatible.
1825  if( aComponent->GetPathsAndReferences().GetCount() > 0 )
1826  {
1827  reference_fields = wxStringTokenize( aComponent->GetPathsAndReferences()[0], delimiters );
1828  name1 = toUTFTildaText( reference_fields[1] );
1829  }
1830  else
1831  {
1832  if( aComponent->GetField( REFERENCE )->GetText().IsEmpty() )
1833  name1 = toUTFTildaText( aComponent->GetPrefix() );
1834  else
1835  name1 = toUTFTildaText( aComponent->GetField( REFERENCE )->GetText() );
1836  }
1837 
1838  wxString part_name = aComponent->GetLibId().Format();
1839 
1840  if( part_name.size() )
1841  {
1842  name2 = toUTFTildaText( part_name );
1843  }
1844  else
1845  {
1846  name2 = "_NONAME_";
1847  }
1848 
1849  m_out->Print( 0, "$Comp\n" );
1850  m_out->Print( 0, "L %s %s\n", name2.c_str(), name1.c_str() );
1851 
1852  // Generate unit number, convert and time stamp
1853  m_out->Print( 0, "U %d %d %8.8lX\n", aComponent->GetUnit(), aComponent->GetConvert(),
1854  (unsigned long)aComponent->GetTimeStamp() );
1855 
1856  // Save the position
1857  m_out->Print( 0, "P %d %d\n", aComponent->GetPosition().x, aComponent->GetPosition().y );
1858 
1859  /* If this is a complex hierarchy; save hierarchical references.
1860  * but for simple hierarchies it is not necessary.
1861  * the reference inf is already saved
1862  * this is useful for old Eeschema version compatibility
1863  */
1864  if( aComponent->GetPathsAndReferences().GetCount() > 1 )
1865  {
1866  for( unsigned int ii = 0; ii < aComponent->GetPathsAndReferences().GetCount(); ii++ )
1867  {
1868  /*format:
1869  * AR Path="/140/2" Ref="C99" Part="1"
1870  * where 140 is the uid of the containing sheet
1871  * and 2 is the timestamp of this component.
1872  * (timestamps are actually 8 hex chars)
1873  * Ref is the conventional component reference for this 'path'
1874  * Part is the conventional component part selection for this 'path'
1875  */
1876  reference_fields = wxStringTokenize( aComponent->GetPathsAndReferences()[ii],
1877  delimiters );
1878 
1879  m_out->Print( 0, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
1880  TO_UTF8( reference_fields[0] ),
1881  TO_UTF8( reference_fields[1] ),
1882  TO_UTF8( reference_fields[2] ) );
1883  }
1884  }
1885 
1886  // update the ugly field index, which I would like to see go away someday soon.
1887  for( int i = 0; i < aComponent->GetFieldCount(); ++i )
1888  aComponent->GetField( i )->SetId( i );
1889 
1890  // Fixed fields:
1891  // Save mandatory fields even if they are blank,
1892  // because the visibility, size and orientation are set from libary editor.
1893  for( unsigned i = 0; i < MANDATORY_FIELDS; ++i )
1894  saveField( aComponent->GetField( i ) );
1895 
1896  // User defined fields:
1897  // The *policy* about which user defined fields are part of a symbol is now
1898  // only in the dialog editors. No policy should be enforced here, simply
1899  // save all the user defined fields, they are present because a dialog editor
1900  // thought they should be. If you disagree, go fix the dialog editors.
1901  for( int i = MANDATORY_FIELDS; i < aComponent->GetFieldCount(); ++i )
1902  saveField( aComponent->GetField( i ) );
1903 
1904  // Unit number, position, box ( old standard )
1905  m_out->Print( 0, "\t%-4d %-4d %-4d\n", aComponent->GetUnit(), aComponent->GetPosition().x,
1906  aComponent->GetPosition().y );
1907 
1908  TRANSFORM transform = aComponent->GetTransform();
1909 
1910  m_out->Print( 0, "\t%-4d %-4d %-4d %-4d\n",
1911  transform.x1, transform.y1, transform.x2, transform.y2 );
1912  m_out->Print( 0, "$EndComp\n" );
1913 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
int y2
Definition: transform.h:51
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
int x2
Definition: transform.h:50
wxString GetPrefix() const
int x1
Definition: transform.h:48
Field Reference of part, i.e. "IC21".
const wxArrayString & GetPathsAndReferences() const
void saveField(SCH_FIELD *aField)
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
int y1
Definition: transform.h:49
int GetUnit() const
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
TRANSFORM & GetTransform() const
std::string toUTFTildaText(const wxString &txt)
Function toUTFTildaText convert a wxString to UTF8 and replace any control characters with a ~...
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
int GetFieldCount() const
Return the number of fields in this symbol.
UTF8 Format() const
Definition: lib_id.cpp:237
size_t i
Definition: json11.cpp:597
wxPoint GetPosition() const override
Function GetPosition.
int GetConvert() const
void SetId(int aId)
Definition: sch_field.h:89
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
const LIB_ID & GetLibId() const

◆ saveField()

void SCH_LEGACY_PLUGIN::saveField ( SCH_FIELD aField)
private

Definition at line 1916 of file sch_legacy_plugin.cpp.

References EscapedUTF8(), FIELD1, EDA_TEXT::GetHorizJustify(), SCH_FIELD::GetId(), SCH_FIELD::GetLibPosition(), SCH_FIELD::GetName(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), m_out, OUTPUTFORMATTER::Print(), and TEXT_ANGLE_HORIZ.

Referenced by saveComponent().

1917 {
1918  char hjustify = 'C';
1919 
1920  if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
1921  hjustify = 'L';
1922  else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
1923  hjustify = 'R';
1924 
1925  char vjustify = 'C';
1926 
1927  if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
1928  vjustify = 'B';
1929  else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
1930  vjustify = 'T';
1931 
1932  m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
1933  aField->GetId(),
1934  EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too
1935  aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
1936  aField->GetLibPosition().x, aField->GetLibPosition().y,
1937  aField->GetTextWidth(),
1938  !aField->IsVisible(),
1939  hjustify, vjustify,
1940  aField->IsItalic() ? 'I' : 'N',
1941  aField->IsBold() ? 'B' : 'N' );
1942 
1943  // Save field name, if the name is user definable
1944  if( aField->GetId() >= FIELD1 )
1945  {
1946  m_out->Print( 0, " %s", EscapedUTF8( aField->GetName() ).c_str() );
1947  }
1948 
1949  m_out->Print( 0, "\n" );
1950 }
#define TEXT_ANGLE_HORIZ
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
bool IsBold() const
Definition: eda_text.h:186
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsVisible() const
Definition: eda_text.h:189
double GetTextAngle() const
Definition: eda_text.h:177
int GetId() const
Definition: sch_field.h:87
bool IsItalic() const
Definition: eda_text.h:183
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:214
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
wxPoint GetLibPosition() const
Definition: sch_field.h:187
int GetTextWidth() const
Definition: eda_text.h:231
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:435
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

◆ saveJunction()

void SCH_LEGACY_PLUGIN::saveJunction ( SCH_JUNCTION aJunction)
private

Definition at line 2066 of file sch_legacy_plugin.cpp.

References SCH_JUNCTION::GetPosition(), m_out, and OUTPUTFORMATTER::Print().

Referenced by Format().

2067 {
2068  wxCHECK_RET( aJunction != NULL, "SCH_JUNCTION* is NULL" );
2069 
2070  m_out->Print( 0, "Connection ~ %-4d %-4d\n",
2071  aJunction->GetPosition().x, aJunction->GetPosition().y );
2072 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:104
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

◆ SaveLibrary()

void SCH_LEGACY_PLUGIN::SaveLibrary ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Reimplemented from SCH_PLUGIN.

Definition at line 4322 of file sch_legacy_plugin.cpp.

References SCH_LEGACY_PLUGIN_CACHE::GetFileName(), SCH_LEGACY_PLUGIN_CACHE::IsFile(), m_cache, SCH_LEGACY_PLUGIN_CACHE::Save(), SCH_LEGACY_PLUGIN_CACHE::SetFileName(), SCH_LEGACY_PLUGIN_CACHE::SetModified(), and writeDocFile().

4323 {
4324  if( !m_cache )
4325  m_cache = new SCH_LEGACY_PLUGIN_CACHE( aLibraryPath );
4326 
4327  wxString oldFileName = m_cache->GetFileName();
4328 
4329  if( !m_cache->IsFile( aLibraryPath ) )
4330  {
4331  m_cache->SetFileName( aLibraryPath );
4332  }
4333 
4334  // This is a forced save.
4335  m_cache->SetModified();
4336  m_cache->Save( writeDocFile( aProperties ) );
4337  m_cache->SetFileName( oldFileName );
4338 }
SCH_LEGACY_PLUGIN_CACHE * m_cache
A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLU...
void SetModified(bool aModified=true)
void SetFileName(const wxString &aFileName)
bool IsFile(const wxString &aFullPathAndFileName) const
void Save(bool aSaveDocFile=true)
Save the entire library to file m_libFileName;.
bool writeDocFile(const PROPERTIES *aProperties)

◆ saveLine()

void SCH_LEGACY_PLUGIN::saveLine ( SCH_LINE aLine)
private

Definition at line 2099 of file sch_legacy_plugin.cpp.

References SCH_LINE::GetDefaultColor(), SCH_LINE::GetDefaultStyle(), SCH_LINE::GetDefaultWidth(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), SCH_LINE::GetLineColor(), SCH_LINE::GetLineSize(), SCH_LINE::GetLineStyle(), SCH_LINE::GetLineStyleName(), SCH_LINE::GetPenSize(), SCH_LINE::GetStartPoint(), LAYER_BUS, LAYER_NOTES, LAYER_WIRE, m_out, OUTPUTFORMATTER::Print(), T_STYLE, T_WIDTH, and TO_UTF8.

Referenced by Format().

2100 {
2101  wxCHECK_RET( aLine != NULL, "SCH_LINE* is NULL" );
2102 
2103  const char* layer = "Notes";
2104  const char* width = "Line";
2105 
2106  if( aLine->GetLayer() == LAYER_WIRE )
2107  layer = "Wire";
2108  else if( aLine->GetLayer() == LAYER_BUS )
2109  layer = "Bus";
2110 
2111  m_out->Print( 0, "Wire %s %s", layer, width );
2112 
2113  // Write line style (width, type, color) only for non default values
2114  if( aLine->GetLayer() == LAYER_NOTES )
2115  {
2116  if( aLine->GetPenSize() != aLine->GetDefaultWidth() )
2117  m_out->Print( 0, " %s %d", T_WIDTH, aLine->GetLineSize() );
2118 
2119  if( aLine->GetLineStyle() != aLine->GetDefaultStyle() )
2120  m_out->Print( 0, " %s %s", T_STYLE, SCH_LINE::GetLineStyleName( aLine->GetLineStyle() ) );
2121 
2122  if( aLine->GetLineColor() != aLine->GetDefaultColor() )
2123  m_out->Print( 0, " %s",
2124  TO_UTF8( aLine->GetLineColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) ) );
2125  }
2126 
2127  m_out->Print( 0, "\n" );
2128 
2129  m_out->Print( 0, "\t%-4d %-4d %-4d %-4d",
2130  aLine->GetStartPoint().x, aLine->GetStartPoint().y,
2131  aLine->GetEndPoint().x, aLine->GetEndPoint().y );
2132 
2133  m_out->Print( 0, "\n");
2134 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
COLOR4D GetLineColor() const
Definition: sch_line.cpp:243
wxPoint GetStartPoint() const
Definition: sch_line.h:76
#define T_WIDTH
int GetDefaultWidth() const
Definition: sch_line.cpp:278
#define T_STYLE
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
int GetDefaultStyle() const
Definition: sch_line.cpp:251
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
int GetLineSize() const
Definition: sch_line.h:110
COLOR4D GetDefaultColor() const
Definition: sch_line.cpp:213
static const char * GetLineStyleName(int aStyle)
Definition: sch_line.cpp:112
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:296
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
int GetLineStyle() const
Definition: sch_line.cpp:269
wxPoint GetEndPoint() const
Definition: sch_line.h:80

◆ saveNoConnect()

void SCH_LEGACY_PLUGIN::saveNoConnect ( SCH_NO_CONNECT aNoConnect)
private

Definition at line 2075 of file sch_legacy_plugin.cpp.

References SCH_NO_CONNECT::GetPosition(), m_out, and OUTPUTFORMATTER::Print().

Referenced by Format().

2076 {
2077  wxCHECK_RET( aNoConnect != NULL, "SCH_NOCONNECT* is NULL" );
2078 
2079  m_out->Print( 0, "NoConn ~ %-4d %-4d\n", aNoConnect->GetPosition().x,
2080  aNoConnect->GetPosition().y );
2081 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
wxPoint GetPosition() const override
Function GetPosition.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

◆ saveSheet()

void SCH_LEGACY_PLUGIN::saveSheet ( SCH_SHEET aSheet)
private

Definition at line 1991 of file sch_legacy_plugin.cpp.

References EscapedUTF8(), SCH_SHEET::GetFileName(), SCH_SHEET::GetFileNameSize(), SCH_SHEET::GetName(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), SCH_SHEET::GetSheetNameSize(), SCH_SHEET::GetSize(), EDA_ITEM::GetTimeStamp(), m_out, NET_BIDI, NET_INPUT, NET_OUTPUT, NET_TRISTATE, NET_UNSPECIFIED, OUTPUTFORMATTER::Print(), SCH_SHEET_PIN::SHEET_BOTTOM_SIDE, SCH_SHEET_PIN::SHEET_LEFT_SIDE, SCH_SHEET_PIN::SHEET_RIGHT_SIDE, and SCH_SHEET_PIN::SHEET_TOP_SIDE.

Referenced by Format().

1992 {
1993  wxCHECK_RET( aSheet != NULL, "SCH_SHEET* is NULL" );
1994 
1995  m_out->Print( 0, "$Sheet\n" );
1996  m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n",
1997  aSheet->GetPosition().x, aSheet->GetPosition().y,
1998  aSheet->GetSize().x, aSheet->GetSize().y );
1999 
2000  m_out->Print( 0, "U %8.8lX\n", (unsigned long) aSheet->GetTimeStamp() );
2001 
2002  if( !aSheet->GetName().IsEmpty() )
2003  m_out->Print( 0, "F0 %s %d\n", EscapedUTF8( aSheet->GetName() ).c_str(),
2004  aSheet->GetSheetNameSize() );
2005 
2006  if( !aSheet->GetFileName().IsEmpty() )
2007  m_out->Print( 0, "F1 %s %d\n", EscapedUTF8( aSheet->GetFileName() ).c_str(),
2008  aSheet->GetFileNameSize() );
2009 
2010  for( const SCH_SHEET_PIN& pin : aSheet->GetPins() )
2011  {
2012  int type, side;
2013 
2014  if( pin.GetText().IsEmpty() )
2015  break;
2016 
2017  switch( pin.GetEdge() )
2018  {
2019  default:
2021  side = 'L';
2022  break;
2023 
2025  side = 'R';
2026  break;
2027 
2029  side = 'T';
2030  break;
2031 
2033  side = 'B';
2034  break;
2035  }
2036 
2037  switch( pin.GetShape() )
2038  {
2039  case NET_INPUT:
2040  type = 'I'; break;
2041 
2042  case NET_OUTPUT:
2043  type = 'O'; break;
2044 
2045  case NET_BIDI:
2046  type = 'B'; break;
2047 
2048  case NET_TRISTATE:
2049  type = 'T'; break;
2050 
2051  default:
2052  case NET_UNSPECIFIED:
2053  type = 'U'; break;
2054  }
2055 
2056  m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(),
2057  EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes
2058  type, side, pin.GetPosition().x, pin.GetPosition().y,
2059  pin.GetTextWidth() );
2060  }
2061 
2062  m_out->Print( 0, "$EndSheet\n" );
2063 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
SCH_SHEET_PINS & GetPins()
Definition: sch_sheet.h:334
int GetFileNameSize() const
Definition: sch_sheet.h:275
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:214
int GetSheetNameSize() const
Definition: sch_sheet.h:271
wxString GetName() const
Definition: sch_sheet.h:267
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:547
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:662
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
wxSize GetSize()
Definition: sch_sheet.h:281

◆ SaveSymbol()

void SCH_LEGACY_PLUGIN::SaveSymbol ( const wxString &  aLibraryPath,
const LIB_PART aSymbol,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Write aSymbol to an existing library located at aLibraryPath.

If a LIB_PART by the same name already exists or there are any conflicting alias names, the new LIB_PART will silently overwrite any existing aliases and/or part becaue libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.

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

Reimplemented from SCH_PLUGIN.

Definition at line 4232 of file sch_legacy_plugin.cpp.

References SCH_LEGACY_PLUGIN_CACHE::AddSymbol(), cacheLib(), isBuffering(), m_cache, m_props, SCH_LEGACY_PLUGIN_CACHE::Save(), and writeDocFile().

4234 {
4235  m_props = aProperties;
4236 
4237  cacheLib( aLibraryPath );
4238 
4239  m_cache->AddSymbol( aSymbol );
4240 
4241  if( !isBuffering( aProperties ) )
4242  m_cache->Save( writeDocFile( aProperties ) );
4243 }
SCH_LEGACY_PLUGIN_CACHE * m_cache
bool isBuffering(const PROPERTIES *aProperties)
void cacheLib(const wxString &aLibraryFileName)
void Save(bool aSaveDocFile=true)
Save the entire library to file m_libFileName;.
void AddSymbol(const LIB_PART *aPart)
bool writeDocFile(const PROPERTIES *aProperties)
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.

◆ saveText()

void SCH_LEGACY_PLUGIN::saveText ( SCH_TEXT aText)
private

Definition at line 2137 of file sch_legacy_plugin.cpp.

References SCH_TEXT::GetLabelSpinStyle(), SCH_ITEM::GetLayer(), SCH_TEXT::GetPosition(), SCH_TEXT::GetShape(), EDA_TEXT::GetText(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetThickness(), EDA_TEXT::IsItalic(), LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, m_out, OUTPUTFORMATTER::Print(), SheetLabelType, and TO_UTF8.

Referenced by Format().

2138 {
2139  wxCHECK_RET( aText != NULL, "SCH_TEXT* is NULL" );
2140 
2141  const char* italics = "~";
2142  const char* textType = "Notes";
2143 
2144  if( aText->IsItalic() )
2145  italics = "Italic";
2146 
2147  wxString text = aText->GetText();
2148 
2149  SCH_LAYER_ID layer = aText->GetLayer();
2150 
2151  if( layer == LAYER_NOTES || layer == LAYER_LOCLABEL )
2152  {
2153  if( layer == LAYER_NOTES )
2154  {
2155  // For compatibility reasons, the text must be saved in only one text line
2156  // so replace all EOLs with \\n
2157  text.Replace( wxT( "\n" ), wxT( "\\n" ) );
2158 
2159  // Here we should have no CR or LF character in line
2160  // This is not always the case if a multiline text was copied (using a copy/paste
2161  // function) from a text that uses E.O.L characters that differs from the current
2162  // EOL format. This is mainly the case under Linux using LF symbol when copying
2163  // a text from Windows (using CRLF symbol) so we must just remove the extra CR left
2164  // (or LF left under MacOSX)
2165  for( unsigned ii = 0; ii < text.Len(); )
2166  {
2167  if( text[ii] == 0x0A || text[ii] == 0x0D )
2168  text.erase( ii, 1 );
2169  else
2170  ii++;
2171  }
2172  }
2173  else
2174  {
2175  textType = "Label";
2176  }
2177 
2178  m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType,
2179  aText->GetPosition().x, aText->GetPosition().y,
2180  aText->GetLabelSpinStyle(),
2181  aText->GetTextWidth(),
2182  italics, aText->GetThickness(), TO_UTF8( text ) );
2183  }
2184  else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL )
2185  {
2186  textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel";
2187 
2188  m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType,
2189  aText->GetPosition().x, aText->GetPosition().y,
2190  aText->GetLabelSpinStyle(),
2191  aText->GetTextWidth(),
2192  SheetLabelType[aText->GetShape()],
2193  italics,
2194  aText->GetThickness(), TO_UTF8( text ) );
2195  }
2196 }
FILE_OUTPUTFORMATTER * m_out
The output formatter for saving SCH_SCREEN objects.
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
const char * SheetLabelType[]
Definition: sch_text.cpp:58
bool IsItalic() const
Definition: eda_text.h:183
int GetLabelSpinStyle() const
Definition: sch_text.h:116
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
SCH_LAYER_ID
Eeschema drawing layers.
virtual wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_text.h:194
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
int GetTextWidth() const
Definition: eda_text.h:231
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118

◆ SymbolLibOptions()

void SCH_PLUGIN::SymbolLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions.

Options are typically appended so that a derived SCH_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 Symbol*() functions in all derived SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.

Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_SCH_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 SCH_PLUGIN, which has been avoided to date.

Definition at line 149 of file sch_plugin.cpp.

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

◆ writeDocFile()

bool SCH_LEGACY_PLUGIN::writeDocFile ( const PROPERTIES aProperties)
private

Definition at line 4130 of file sch_legacy_plugin.cpp.

References PropNoDocFile.

Referenced by CreateSymbolLib(), DeleteAlias(), DeleteSymbol(), SaveLibrary(), and SaveSymbol().

4131 {
4132  std::string propName( SCH_LEGACY_PLUGIN::PropNoDocFile );
4133 
4134  if( aProperties && aProperties->find( propName ) != aProperties->end() )
4135  return false;
4136 
4137  return true;
4138 }
static const char * PropNoDocFile
const char* PropBuffering

Member Data Documentation

◆ m_cache

◆ m_currentPath

std::stack<wxString> SCH_LEGACY_PLUGIN::m_currentPath
protected

Stack to maintain nested sheet paths.

Definition at line 166 of file sch_legacy_plugin.h.

Referenced by Load(), and loadHierarchy().

◆ m_error

wxString SCH_LEGACY_PLUGIN::m_error
protected

For throwing exceptions or errors on partial schematic loads.

Definition at line 163 of file sch_legacy_plugin.h.

Referenced by GetError(), loadHeader(), and loadHierarchy().

◆ m_kiway

KIWAY* SCH_LEGACY_PLUGIN::m_kiway
protected

Required for path to legacy component libraries.

Definition at line 168 of file sch_legacy_plugin.h.

Referenced by Format(), init(), and loadHierarchy().

◆ m_out

FILE_OUTPUTFORMATTER* SCH_LEGACY_PLUGIN::m_out
protected

The output formatter for saving SCH_SCREEN objects.

Definition at line 170 of file sch_legacy_plugin.h.

Referenced by Format(), init(), Save(), saveBitmap(), saveBusEntry(), saveComponent(), saveField(), saveJunction(), saveLine(), saveNoConnect(), saveSheet(), and saveText().

◆ m_path

wxString SCH_LEGACY_PLUGIN::m_path
protected

Root project path for loading child sheets.

Definition at line 165 of file sch_legacy_plugin.h.

Referenced by Load().

◆ m_props

const PROPERTIES* SCH_LEGACY_PLUGIN::m_props
protected

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

Definition at line 167 of file sch_legacy_plugin.h.

Referenced by cacheLib(), CreateSymbolLib(), DeleteAlias(), DeleteSymbol(), EnumerateSymbolLib(), GetSymbolLibCount(), init(), LoadSymbol(), and SaveSymbol().

◆ m_rootSheet

SCH_SHEET* SCH_LEGACY_PLUGIN::m_rootSheet
protected

The root sheet of the schematic being loaded..

Definition at line 169 of file sch_legacy_plugin.h.

Referenced by init(), Load(), loadComponent(), and loadHierarchy().

◆ m_version

int SCH_LEGACY_PLUGIN::m_version
protected

Version of file being loaded.

Definition at line 160 of file sch_legacy_plugin.h.

Referenced by init(), loadComponent(), loadFile(), loadHeader(), and loadText().

◆ PropBuffering

const char * SCH_LEGACY_PLUGIN::PropBuffering = "buffering"
static

const char* PropBuffering

is a property used internally by the plugin to enable cache buffering which prevents the library file from being written every time the cache is changed. This is useful when writing the schematic cache library file or saving a library to a new file name.

Definition at line 84 of file sch_legacy_plugin.h.

Referenced by PART_LIB::EnableBuffering(), isBuffering(), PART_LIB::IsBuffering(), SCH_EAGLE_PLUGIN::Load(), SYMBOL_LIB_TABLE_RESCUER::OpenRescueLibrary(), LIB_MANAGER::LIB_BUFFER::SaveBuffer(), and LIB_MANAGER::SaveLibrary().

◆ PropNoDocFile

const char * SCH_LEGACY_PLUGIN::PropNoDocFile = "no_doc_file"
static

const char* PropBuffering

is a property used internally by the plugin to disable writing the library documentation (.dcm) file when saving the library cache.

Definition at line 92 of file sch_legacy_plugin.h.

Referenced by PART_LIB::IsCache(), PART_LIB::Save(), LIB_EDIT_FRAME::SaveOneSymbol(), PART_LIB::SetCache(), and writeDocFile().


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