KiCad PCB EDA Suite
SCH_SEXPR_PLUGIN Class Reference

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

#include <sch_sexpr_plugin.h>

Inheritance diagram for SCH_SEXPR_PLUGIN:
SCH_PLUGIN

Public Member Functions

 SCH_SEXPR_PLUGIN ()
 
virtual ~SCH_SEXPR_PLUGIN ()
 
const wxString GetName () const override
 Return a brief hard coded name for this SCH_PLUGIN. More...
 
const wxString GetFileExtension () const override
 Return the file extension for the SCH_PLUGIN. More...
 
const wxString GetLibraryFileExtension () const override
 Return the library file extension for the SCH_PLUGIN object. More...
 
void SetProgressReporter (PROGRESS_REPORTER *aReporter) override
 Set an optional progress reporter. More...
 
int GetModifyHash () const override
 Return the modification hash from the library cache. More...
 
SCH_SHEETLoad (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr) 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 LoadContent (LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
 
void Save (const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr) 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_SHEET *aSheet)
 
void Format (EE_SELECTION *aSelection, SCH_SHEET_PATH *aSelectionPath, SCH_SHEET_LIST *aFullSheetHierarchy, OUTPUTFORMATTER *aFormatter)
 
void EnumerateSymbolLib (wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath. More...
 
void EnumerateSymbolLib (std::vector< LIB_SYMBOL * > &aSymbolList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Populate a list of LIB_SYMBOL aliases contained within the library aLibraryPath. More...
 
LIB_SYMBOLLoadSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=nullptr) override
 Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. More...
 
void SaveSymbol (const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const PROPERTIES *aProperties=nullptr) override
 Write aSymbol to an existing library located at aLibraryPath. More...
 
void DeleteSymbol (const wxString &aLibraryPath, const wxString &aSymbolName, const PROPERTIES *aProperties=nullptr) override
 Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath. More...
 
void CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
 Create a new empty symbol library at aLibraryPath. More...
 
bool DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) 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=nullptr) 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 SetReporter (REPORTER *aReporter)
 Set an optional reporter for warnings/errors. More...
 
virtual void SymbolLibOptions (PROPERTIES *aListToAppendTo) const
 Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Static Public Member Functions

static LIB_SYMBOLParseLibSymbol (LINE_READER &aReader, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
 
static void FormatLibSymbol (LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
 

Static Public Attributes

static const char * PropBuffering = "buffering"
 The property used internally by the plugin to enable cache buffering which prevents the library file from being written every time the cache is changed. More...
 

Protected Member Functions

void init (SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
 initialize PLUGIN like a constructor would. More...
 

Protected Attributes

int m_version
 Version of file being loaded. More...
 
int m_nextFreeFieldId
 
wxString m_error
 For throwing exceptions or errors on partial loads. More...
 
PROGRESS_REPORTERm_progressReporter
 
wxString m_path
 Root project path for loading child sheets. More...
 
std::stack< wxString > m_currentPath
 Stack to maintain nested sheet paths. More...
 
SCH_SHEETm_rootSheet
 The root sheet of the schematic being loaded. More...
 
SCHEMATICm_schematic
 
OUTPUTFORMATTERm_out
 The formatter for saving SCH_SCREEN objects. More...
 
SCH_SEXPR_PLUGIN_CACHEm_cache
 

Private Member Functions

void loadHierarchy (SCH_SHEET *aSheet)
 
void loadFile (const wxString &aFileName, SCH_SHEET *aSheet)
 
void saveSymbol (SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, int aNestLevel)
 
void saveField (SCH_FIELD *aField, int aNestLevel)
 
void saveBitmap (SCH_BITMAP *aBitmap, int aNestLevel)
 
void saveSheet (SCH_SHEET *aSheet, int aNestLevel)
 
void saveJunction (SCH_JUNCTION *aJunction, int aNestLevel)
 
void saveNoConnect (SCH_NO_CONNECT *aNoConnect, int aNestLevel)
 
void saveBusEntry (SCH_BUS_ENTRY_BASE *aBusEntry, int aNestLevel)
 
void saveLine (SCH_LINE *aLine, int aNestLevel)
 
void saveText (SCH_TEXT *aText, int aNestLevel)
 
void saveBusAlias (std::shared_ptr< BUS_ALIAS > aAlias, int aNestLevel)
 
void saveInstances (const std::vector< SCH_SHEET_INSTANCE > &aSheets, const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbols, int aNestLevel)
 
void cacheLib (const wxString &aLibraryFileName, const PROPERTIES *aProperties)
 
bool isBuffering (const PROPERTIES *aProperties)
 

Detailed Description

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

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

Definition at line 60 of file sch_sexpr_plugin.h.

Constructor & Destructor Documentation

◆ SCH_SEXPR_PLUGIN()

SCH_SEXPR_PLUGIN::SCH_SEXPR_PLUGIN ( )

Definition at line 505 of file sch_sexpr_plugin.cpp.

505  :
506  m_progressReporter( nullptr )
507 {
508  init( nullptr );
509 }
PROGRESS_REPORTER * m_progressReporter
void init(SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
initialize PLUGIN like a constructor would.

References init().

◆ ~SCH_SEXPR_PLUGIN()

SCH_SEXPR_PLUGIN::~SCH_SEXPR_PLUGIN ( )
virtual

Definition at line 512 of file sch_sexpr_plugin.cpp.

513 {
514  delete m_cache;
515 }
SCH_SEXPR_PLUGIN_CACHE * m_cache

References m_cache.

Member Function Documentation

◆ cacheLib()

void SCH_SEXPR_PLUGIN::cacheLib ( const wxString &  aLibraryFileName,
const PROPERTIES aProperties 
)
private

Definition at line 2104 of file sch_sexpr_plugin.cpp.

2105 {
2106  if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
2107  {
2108  // a spectacular episode in memory management:
2109  delete m_cache;
2110  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryFileName );
2111 
2112  // Because m_cache is rebuilt, increment SYMBOL_LIBS::s_modify_generation
2113  // to modify the hash value that indicate symbol to symbol links
2114  // must be updated.
2116 
2117  if( !isBuffering( aProperties ) )
2118  m_cache->Load();
2119  }
2120 }
SCH_SEXPR_PLUGIN_CACHE * m_cache
A cache assistant for the symbol library portion of the SCH_PLUGIN API, and only for the SCH_SEXPR_PL...
bool IsFile(const wxString &aFullPathAndFileName) const
static void IncrementModifyGeneration()
bool isBuffering(const PROPERTIES *aProperties)

References SYMBOL_LIBS::IncrementModifyGeneration(), isBuffering(), SCH_SEXPR_PLUGIN_CACHE::IsFile(), SCH_SEXPR_PLUGIN_CACHE::IsFileChanged(), SCH_SEXPR_PLUGIN_CACHE::Load(), and m_cache.

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

◆ CheckHeader()

bool SCH_SEXPR_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 2289 of file sch_sexpr_plugin.cpp.

2290 {
2291  // Open file and check first line
2292  wxTextFile tempFile;
2293 
2294  tempFile.Open( aFileName );
2295  wxString firstline;
2296  // read the first line
2297  firstline = tempFile.GetFirstLine();
2298  tempFile.Close();
2299 
2300  return firstline.StartsWith( "EESchema" );
2301 }

◆ CreateSymbolLib()

void SCH_SEXPR_PLUGIN::CreateSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
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 2225 of file sch_sexpr_plugin.cpp.

2227 {
2228  if( wxFileExists( aLibraryPath ) )
2229  {
2230  THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' already exists." ),
2231  aLibraryPath.GetData() ) );
2232  }
2233 
2234  LOCALE_IO toggle;
2235 
2236  delete m_cache;
2237  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryPath );
2238  m_cache->SetModified();
2239  m_cache->Save();
2240  m_cache->Load(); // update m_writable and m_mod_time
2241 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Save()
Save the entire library to file m_libFileName;.
SCH_SEXPR_PLUGIN_CACHE * m_cache
A cache assistant for the symbol library portion of the SCH_PLUGIN API, and only for the SCH_SEXPR_PL...
void SetModified(bool aModified=true)
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), SCH_SEXPR_PLUGIN_CACHE::Load(), m_cache, SCH_SEXPR_PLUGIN_CACHE::Save(), SCH_SEXPR_PLUGIN_CACHE::SetModified(), and THROW_IO_ERROR.

◆ DeleteSymbol()

void SCH_SEXPR_PLUGIN::DeleteSymbol ( const wxString &  aLibraryPath,
const wxString &  aSymbolName,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

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

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolNameis the name of a LIB_SYMBOL associated with it's root LIB_SYMBOL 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 2211 of file sch_sexpr_plugin.cpp.

2213 {
2214  LOCALE_IO toggle; // toggles on, then off, the C locale.
2215 
2216  cacheLib( aLibraryPath, aProperties );
2217 
2218  m_cache->DeleteSymbol( aSymbolName );
2219 
2220  if( !isBuffering( aProperties ) )
2221  m_cache->Save();
2222 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Save()
Save the entire library to file m_libFileName;.
SCH_SEXPR_PLUGIN_CACHE * m_cache
void DeleteSymbol(const wxString &aName)
void cacheLib(const wxString &aLibraryFileName, const PROPERTIES *aProperties)
bool isBuffering(const PROPERTIES *aProperties)

References cacheLib(), SCH_SEXPR_PLUGIN_CACHE::DeleteSymbol(), isBuffering(), m_cache, and SCH_SEXPR_PLUGIN_CACHE::Save().

◆ DeleteSymbolLib()

bool SCH_SEXPR_PLUGIN::DeleteSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
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 2244 of file sch_sexpr_plugin.cpp.

2246 {
2247  wxFileName fn = aLibraryPath;
2248 
2249  if( !fn.FileExists() )
2250  return false;
2251 
2252  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2253  // we don't want that. we want bare metal portability with no UI here.
2254  if( wxRemove( aLibraryPath ) )
2255  {
2256  THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' cannot be deleted." ),
2257  aLibraryPath.GetData() ) );
2258  }
2259 
2260  if( m_cache && m_cache->IsFile( aLibraryPath ) )
2261  {
2262  delete m_cache;
2263  m_cache = nullptr;
2264  }
2265 
2266  return true;
2267 }
SCH_SEXPR_PLUGIN_CACHE * m_cache
bool IsFile(const wxString &aFullPathAndFileName) const
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), SCH_SEXPR_PLUGIN_CACHE::IsFile(), m_cache, and THROW_IO_ERROR.

◆ EnumerateSymbolLib() [1/2]

void SCH_SEXPR_PLUGIN::EnumerateSymbolLib ( wxArrayString &  aSymbolNameList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

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

Parameters
aSymbolNameListis an array to populate with the LIB_SYMBOL names associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL 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 2139 of file sch_sexpr_plugin.cpp.

2142 {
2143  LOCALE_IO toggle; // toggles on, then off, the C locale.
2144 
2145  bool powerSymbolsOnly = ( aProperties &&
2146  aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
2147 
2148  cacheLib( aLibraryPath, aProperties );
2149 
2150  const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
2151 
2152  for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
2153  {
2154  if( !powerSymbolsOnly || it->second->IsPower() )
2155  aSymbolNameList.Add( it->first );
2156  }
2157 }
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
Symbol map used by symbol library object.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
SCH_SEXPR_PLUGIN_CACHE * m_cache
void cacheLib(const wxString &aLibraryFileName, const PROPERTIES *aProperties)
static const char * PropPowerSymsOnly

References cacheLib(), m_cache, SCH_SEXPR_PLUGIN_CACHE::m_symbols, and SYMBOL_LIB_TABLE::PropPowerSymsOnly.

◆ EnumerateSymbolLib() [2/2]

void SCH_SEXPR_PLUGIN::EnumerateSymbolLib ( std::vector< LIB_SYMBOL * > &  aSymbolList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

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

Note
It is the responsibility of the caller to delete the returned object from the heap. Failure to do this will result in memory leaks.
Parameters
aSymbolListis an array to populate with the LIB_SYMBOL pointers associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL 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 2160 of file sch_sexpr_plugin.cpp.

2163 {
2164  LOCALE_IO toggle; // toggles on, then off, the C locale.
2165 
2166  bool powerSymbolsOnly = ( aProperties &&
2167  aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
2168 
2169  cacheLib( aLibraryPath, aProperties );
2170 
2171  const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
2172 
2173  for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
2174  {
2175  if( !powerSymbolsOnly || it->second->IsPower() )
2176  aSymbolList.push_back( it->second );
2177  }
2178 }
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
Symbol map used by symbol library object.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
SCH_SEXPR_PLUGIN_CACHE * m_cache
void cacheLib(const wxString &aLibraryFileName, const PROPERTIES *aProperties)
static const char * PropPowerSymsOnly

References cacheLib(), m_cache, SCH_SEXPR_PLUGIN_CACHE::m_symbols, and SYMBOL_LIB_TABLE::PropPowerSymsOnly.

◆ Format() [1/2]

void SCH_SEXPR_PLUGIN::Format ( SCH_SHEET aSheet)

Definition at line 741 of file sch_sexpr_plugin.cpp.

742 {
743  wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET* object." );
744  wxCHECK_RET( m_schematic != nullptr, "NULL SCHEMATIC* object." );
745 
746  SCH_SCREEN* screen = aSheet->GetScreen();
747 
748  wxCHECK( screen, /* void */ );
749 
750  m_out->Print( 0, "(kicad_sch (version %d) (generator eeschema)\n\n",
752 
753  m_out->Print( 1, "(uuid %s)\n\n", TO_UTF8( screen->m_uuid.AsString() ) );
754 
755  screen->GetPageSettings().Format( m_out, 1, 0 );
756  m_out->Print( 0, "\n" );
757  screen->GetTitleBlock().Format( m_out, 1, 0 );
758 
759  // Save cache library.
760  m_out->Print( 1, "(lib_symbols\n" );
761 
762  for( auto libSymbol : screen->GetLibSymbols() )
763  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( libSymbol.second, *m_out, 2, libSymbol.first );
764 
765  m_out->Print( 1, ")\n\n" );
766 
767  for( const auto& alias : screen->GetBusAliases() )
768  {
769  saveBusAlias( alias, 1 );
770  }
771 
772  // Enforce item ordering
773  auto cmp = []( const SCH_ITEM* a, const SCH_ITEM* b )
774  {
775  return *a < *b;
776  };
777 
778  std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
779 
780  for( SCH_ITEM* item : screen->Items() )
781  save_map.insert( item );
782 
783  KICAD_T itemType = TYPE_NOT_INIT;
785 
786  for( SCH_ITEM* item : save_map )
787  {
788  if( itemType != item->Type() )
789  {
790  itemType = item->Type();
791 
792  if( itemType != SCH_SYMBOL_T
793  && itemType != SCH_JUNCTION_T
794  && itemType != SCH_SHEET_T )
795  m_out->Print( 0, "\n" );
796  }
797 
798  switch( item->Type() )
799  {
800  case SCH_SYMBOL_T:
801  m_out->Print( 0, "\n" );
802  saveSymbol( static_cast<SCH_SYMBOL*>( item ), nullptr, 1 );
803  break;
804 
805  case SCH_BITMAP_T:
806  saveBitmap( static_cast<SCH_BITMAP*>( item ), 1 );
807  break;
808 
809  case SCH_SHEET_T:
810  m_out->Print( 0, "\n" );
811  saveSheet( static_cast<SCH_SHEET*>( item ), 1 );
812  break;
813 
814  case SCH_JUNCTION_T:
815  saveJunction( static_cast<SCH_JUNCTION*>( item ), 1 );
816  break;
817 
818  case SCH_NO_CONNECT_T:
819  saveNoConnect( static_cast<SCH_NO_CONNECT*>( item ), 1 );
820  break;
821 
823  case SCH_BUS_BUS_ENTRY_T:
824  saveBusEntry( static_cast<SCH_BUS_ENTRY_BASE*>( item ), 1 );
825  break;
826 
827  case SCH_LINE_T:
828  if( layer != item->GetLayer() )
829  {
830  if( layer == SCH_LAYER_ID_START )
831  {
832  layer = item->GetLayer();
833  }
834  else
835  {
836  layer = item->GetLayer();
837  m_out->Print( 0, "\n" );
838  }
839  }
840 
841  saveLine( static_cast<SCH_LINE*>( item ), 1 );
842  break;
843 
844  case SCH_TEXT_T:
845  case SCH_LABEL_T:
846  case SCH_GLOBAL_LABEL_T:
847  case SCH_HIER_LABEL_T:
848  saveText( static_cast<SCH_TEXT*>( item ), 1 );
849  break;
850 
851  default:
852  wxASSERT( "Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
853  }
854  }
855 
856  // If this is the root sheet, save all of the sheet paths.
857  if( aSheet->IsRootSheet() )
858  {
859  SCH_SHEET_LIST sheetPaths( aSheet, true );
860 
861  SCH_REFERENCE_LIST symbolInstances;
862 
863  for( const SCH_SHEET_PATH& sheetPath : sheetPaths )
864  sheetPath.GetSymbols( symbolInstances, true, true );
865 
866  symbolInstances.SortByReferenceOnly();
867 
868  saveInstances( sheetPaths.GetSheetInstances(), symbolInstances.GetSymbolInstances(), 1 );
869  }
870  else
871  {
872  // Schematic files (SCH_SCREEN objects) can be shared so we have to save and restore
873  // symbol and sheet instance data even if the file being saved is not the root sheet
874  // because it is possible that the file is the root sheet of another project.
875  saveInstances( screen->m_sheetInstances, screen->m_symbolInstances, 1 );
876  }
877 
878  m_out->Print( 0, ")\n" );
879 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCHEMATIC * m_schematic
void saveLine(SCH_LINE *aLine, int aNestLevel)
void saveNoConnect(SCH_NO_CONNECT *aNoConnect, int aNestLevel)
std::vector< SYMBOL_INSTANCE_REFERENCE > m_symbolInstances
The list of symbol instances loaded from the schematic file.
Definition: sch_screen.h:546
void saveJunction(SCH_JUNCTION *aJunction, int aNestLevel)
std::vector< SYMBOL_INSTANCE_REFERENCE > GetSymbolInstances() const
void saveText(SCH_TEXT *aText, int aNestLevel)
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheets, const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbols, int aNestLevel)
wxString AsString() const
Definition: kiid.cpp:218
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:156
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:271
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry, int aNestLevel)
void saveBusAlias(std::shared_ptr< BUS_ALIAS > aAlias, int aNestLevel)
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:324
std::vector< SCH_SHEET_INSTANCE > m_sheetInstances
Definition: sch_screen.h:547
bool IsRootSheet() const
Definition: sch_sheet.cpp:188
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:430
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: title_block.cpp:29
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
std::unordered_set< std::shared_ptr< BUS_ALIAS > > GetBusAliases() const
Return a list of bus aliases defined in this screen.
Definition: sch_screen.h:460
void SortByReferenceOnly()
Sort the list of references by reference.
KIID m_uuid
A unique identifier for each schematic file.
Definition: sch_screen.h:555
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
void saveSheet(SCH_SHEET *aSheet, int aNestLevel)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)
void saveSymbol(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, int aNestLevel)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
void saveBitmap(SCH_BITMAP *aBitmap, int aNestLevel)

References KIID::AsString(), TITLE_BLOCK::Format(), PAGE_INFO::Format(), SCH_SCREEN::GetBusAliases(), SCH_SCREEN::GetLibSymbols(), SCH_SCREEN::GetPageSettings(), SCH_SHEET::GetScreen(), SCH_REFERENCE_LIST::GetSymbolInstances(), SCH_SCREEN::GetTitleBlock(), SCH_SHEET::IsRootSheet(), SCH_SCREEN::Items(), m_out, m_schematic, SCH_SCREEN::m_sheetInstances, SCH_SCREEN::m_symbolInstances, SCH_SCREEN::m_uuid, OUTPUTFORMATTER::Print(), saveBitmap(), saveBusAlias(), saveBusEntry(), saveInstances(), saveJunction(), saveLine(), saveNoConnect(), saveSheet(), saveSymbol(), SCH_SEXPR_PLUGIN_CACHE::SaveSymbol(), saveText(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LAYER_ID_START, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SEXPR_SCHEMATIC_FILE_VERSION, SCH_REFERENCE_LIST::SortByReferenceOnly(), TO_UTF8, and TYPE_NOT_INIT.

Referenced by SCH_EDITOR_CONTROL::doCopy(), and Save().

◆ Format() [2/2]

void SCH_SEXPR_PLUGIN::Format ( EE_SELECTION aSelection,
SCH_SHEET_PATH aSelectionPath,
SCH_SHEET_LIST aFullSheetHierarchy,
OUTPUTFORMATTER aFormatter 
)

Definition at line 882 of file sch_sexpr_plugin.cpp.

885 {
886  wxCHECK( aSelection && aSelectionPath && aFullSheetHierarchy && aFormatter, /* void */ );
887 
888  LOCALE_IO toggle;
889 
890  m_out = aFormatter;
891 
892  size_t i;
893  SCH_ITEM* item;
894  std::map<wxString, LIB_SYMBOL*> libSymbols;
895  SCH_SCREEN* screen = aSelection->GetScreen();
896 
897  for( i = 0; i < aSelection->GetSize(); ++i )
898  {
899  item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( i ) );
900 
901  wxCHECK2( item, continue );
902 
903  if( item->Type() != SCH_SYMBOL_T )
904  continue;
905 
906  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
907 
908  wxCHECK2( symbol, continue );
909 
910  wxString libSymbolLookup = symbol->GetLibId().Format().wx_str();
911 
912  if( !symbol->UseLibIdLookup() )
913  libSymbolLookup = symbol->GetSchSymbolLibraryName();
914 
915  auto it = screen->GetLibSymbols().find( libSymbolLookup );
916 
917  if( it != screen->GetLibSymbols().end() )
918  libSymbols[ libSymbolLookup ] = it->second;
919  }
920 
921  if( !libSymbols.empty() )
922  {
923  m_out->Print( 0, "(lib_symbols\n" );
924 
925  for( auto libSymbol : libSymbols )
926  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( libSymbol.second, *m_out, 1, libSymbol.first );
927 
928  m_out->Print( 0, ")\n\n" );
929  }
930 
931  // Store the selected sheets instance information
932  SCH_SHEET_LIST selectedSheets;
933  selectedSheets.push_back( *aSelectionPath ); // Include the "root" of the selection
934 
935  SCH_REFERENCE_LIST selectedSymbols;
936 
937  for( i = 0; i < aSelection->GetSize(); ++i )
938  {
939  item = (SCH_ITEM*) aSelection->GetItem( i );
940 
941  switch( item->Type() )
942  {
943  case SCH_SYMBOL_T:
944  saveSymbol( static_cast<SCH_SYMBOL*>( item ), aSelectionPath, 0 );
945 
946  aSelectionPath->AppendSymbol( selectedSymbols, static_cast<SCH_SYMBOL*>( item ),
947  true, true );
948  break;
949 
950  case SCH_BITMAP_T:
951  saveBitmap( static_cast< SCH_BITMAP* >( item ), 0 );
952  break;
953 
954  case SCH_SHEET_T:
955  saveSheet( static_cast< SCH_SHEET* >( item ), 0 );
956 
957  {
958  SCH_SHEET_PATH subSheetPath = *aSelectionPath;
959  subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
960 
961  aFullSheetHierarchy->GetSheetsWithinPath( selectedSheets, subSheetPath );
962  aFullSheetHierarchy->GetSymbolsWithinPath( selectedSymbols, subSheetPath, true,
963  true );
964  }
965 
966  break;
967 
968  case SCH_JUNCTION_T:
969  saveJunction( static_cast< SCH_JUNCTION* >( item ), 0 );
970  break;
971 
972  case SCH_NO_CONNECT_T:
973  saveNoConnect( static_cast< SCH_NO_CONNECT* >( item ), 0 );
974  break;
975 
977  case SCH_BUS_BUS_ENTRY_T:
978  saveBusEntry( static_cast< SCH_BUS_ENTRY_BASE* >( item ), 0 );
979  break;
980 
981  case SCH_LINE_T:
982  saveLine( static_cast< SCH_LINE* >( item ), 0 );
983  break;
984 
985  case SCH_TEXT_T:
986  case SCH_LABEL_T:
987  case SCH_GLOBAL_LABEL_T:
988  case SCH_HIER_LABEL_T:
989  saveText( static_cast< SCH_TEXT* >( item ), 0 );
990  break;
991 
992  default:
993  wxASSERT( "Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
994  }
995  }
996 
997  // Make all instance information relative to the selection path
998  KIID_PATH selectionPath = aSelectionPath->PathWithoutRootUuid();
999 
1000  selectedSheets.SortByPageNumbers();
1001  std::vector<SCH_SHEET_INSTANCE> sheetinstances = selectedSheets.GetSheetInstances();
1002 
1003  for( SCH_SHEET_INSTANCE& sheetInstance : sheetinstances )
1004  {
1005  wxASSERT_MSG( sheetInstance.m_Path.MakeRelativeTo( selectionPath ),
1006  "Sheet is not inside the selection path?" );
1007  }
1008 
1009 
1010  selectedSymbols.SortByReferenceOnly();
1011  std::vector<SYMBOL_INSTANCE_REFERENCE> symbolInstances = selectedSymbols.GetSymbolInstances();
1012 
1013  for( SYMBOL_INSTANCE_REFERENCE& symbolInstance : symbolInstances )
1014  {
1015  wxASSERT_MSG( symbolInstance.m_Path.MakeRelativeTo( selectionPath ),
1016  "Symbol is not inside the selection path?" );
1017  }
1018 
1019  saveInstances( sheetinstances, symbolInstances, 0 );
1020 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void saveLine(SCH_LINE *aLine, int aNestLevel)
void saveNoConnect(SCH_NO_CONNECT *aNoConnect, int aNestLevel)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
SCH_SCREEN * GetScreen()
Definition: ee_selection.h:51
void saveJunction(SCH_JUNCTION *aJunction, int aNestLevel)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
std::vector< SYMBOL_INSTANCE_REFERENCE > GetSymbolInstances() const
void saveText(SCH_TEXT *aText, int aNestLevel)
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheets, const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbols, int aNestLevel)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry, int aNestLevel)
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:248
A simple container for schematic symbol instance information.
std::vector< SCH_SHEET_INSTANCE > GetSheetInstances() const
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:430
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
KIID_PATH PathWithoutRootUuid() const
Get the sheet path as an KIID_PATH without the root sheet UUID prefix.
UTF8 Format() const
Definition: lib_id.cpp:116
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
A simple container for sheet instance information.
Schematic symbol object.
Definition: sch_symbol.h:78
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:53
void SortByReferenceOnly()
Sort the list of references by reference.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
wxString wx_str() const
Definition: utf8.cpp:46
void saveSheet(SCH_SHEET *aSheet, int aNestLevel)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)
void saveSymbol(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, int aNestLevel)
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
void saveBitmap(SCH_BITMAP *aBitmap, int aNestLevel)
bool UseLibIdLookup() const
Definition: sch_symbol.h:162
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
void GetSheetsWithinPath(SCH_SHEET_PATHS &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...

References SCH_SHEET_PATH::AppendSymbol(), LIB_ID::Format(), SELECTION::GetItem(), SCH_SYMBOL::GetLibId(), SCH_SCREEN::GetLibSymbols(), SCH_SYMBOL::GetSchSymbolLibraryName(), EE_SELECTION::GetScreen(), SCH_SHEET_LIST::GetSheetInstances(), SCH_SHEET_LIST::GetSheetsWithinPath(), SELECTION::GetSize(), SCH_REFERENCE_LIST::GetSymbolInstances(), SCH_SHEET_LIST::GetSymbolsWithinPath(), m_out, SCH_SHEET_PATH::PathWithoutRootUuid(), OUTPUTFORMATTER::Print(), SCH_SHEET_PATH::push_back(), saveBitmap(), saveBusEntry(), saveInstances(), saveJunction(), saveLine(), saveNoConnect(), saveSheet(), saveSymbol(), SCH_SEXPR_PLUGIN_CACHE::SaveSymbol(), saveText(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_SHEET_LIST::SortByPageNumbers(), SCH_REFERENCE_LIST::SortByReferenceOnly(), EDA_ITEM::Type(), SCH_SYMBOL::UseLibIdLookup(), and UTF8::wx_str().

◆ FormatLibSymbol()

void SCH_SEXPR_PLUGIN::FormatLibSymbol ( LIB_SYMBOL aPart,
OUTPUTFORMATTER aFormatter 
)
static

Definition at line 2325 of file sch_sexpr_plugin.cpp.

2326 {
2327 
2328  LOCALE_IO toggle; // toggles on, then off, the C locale.
2329  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( symbol, formatter );
2330 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)

References SCH_SEXPR_PLUGIN_CACHE::SaveSymbol().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Copy(), and SYMBOL_EDIT_FRAME::CopySymbolToClipboard().

◆ GetError()

const wxString& SCH_SEXPR_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 133 of file sch_sexpr_plugin.h.

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

References m_error.

◆ GetFileExtension()

const wxString SCH_SEXPR_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Return the file extension for the SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 72 of file sch_sexpr_plugin.h.

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

◆ GetLibraryFileExtension()

const wxString SCH_SEXPR_PLUGIN::GetLibraryFileExtension ( ) const
inlineoverridevirtual

Return the library file extension for the SCH_PLUGIN object.

Implements SCH_PLUGIN.

Definition at line 77 of file sch_sexpr_plugin.h.

78  {
79  return wxT( "kicad_sym" );
80  }

◆ GetModifyHash()

int SCH_SEXPR_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 2129 of file sch_sexpr_plugin.cpp.

2130 {
2131  if( m_cache )
2132  return m_cache->GetModifyHash();
2133 
2134  // If the cache hasn't been loaded, it hasn't been modified.
2135  return 0;
2136 }
SCH_SEXPR_PLUGIN_CACHE * m_cache

References SCH_SEXPR_PLUGIN_CACHE::GetModifyHash(), and m_cache.

◆ GetName()

const wxString SCH_SEXPR_PLUGIN::GetName ( ) const
inlineoverridevirtual

Return a brief hard coded name for this SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 67 of file sch_sexpr_plugin.h.

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

◆ init()

void SCH_SEXPR_PLUGIN::init ( SCHEMATIC aSchematic,
const PROPERTIES aProperties = nullptr 
)
protected

initialize PLUGIN like a constructor would.

Definition at line 518 of file sch_sexpr_plugin.cpp.

519 {
520  m_version = 0;
521  m_rootSheet = nullptr;
522  m_schematic = aSchematic;
523  m_cache = nullptr;
524  m_out = nullptr;
525  m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
526 }
SCHEMATIC * m_schematic
int m_version
Version of file being loaded.
SCH_SEXPR_PLUGIN_CACHE * m_cache
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.

References m_cache, m_nextFreeFieldId, m_out, m_rootSheet, m_schematic, and m_version.

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

◆ isBuffering()

bool SCH_SEXPR_PLUGIN::isBuffering ( const PROPERTIES aProperties)
private

Definition at line 2123 of file sch_sexpr_plugin.cpp.

2124 {
2125  return ( aProperties && aProperties->Exists( SCH_SEXPR_PLUGIN::PropBuffering ) );
2126 }
bool Exists(const std::string &aProperty) const
Definition: properties.h:41
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...

References PROPERTIES::Exists(), and PropBuffering.

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

◆ IsSymbolLibWritable()

bool SCH_SEXPR_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 2304 of file sch_sexpr_plugin.cpp.

2305 {
2306  wxFileName fn( aLibraryPath );
2307 
2308  return ( fn.FileExists() && fn.IsFileWritable() ) || fn.IsDirWritable();
2309 }

◆ Load()

SCH_SHEET * SCH_SEXPR_PLUGIN::Load ( const wxString &  aFileName,
SCHEMATIC aSchematic,
SCH_SHEET aAppendToMe = nullptr,
const PROPERTIES aProperties = nullptr 
)
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 symbol 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 529 of file sch_sexpr_plugin.cpp.

531 {
532  wxASSERT( !aFileName || aSchematic != nullptr );
533 
534  LOCALE_IO toggle; // toggles on, then off, the C locale.
535  SCH_SHEET* sheet;
536 
537  wxFileName fn = aFileName;
538 
539  // Unfortunately child sheet file names the legacy schematic file format are not fully
540  // qualified and are always appended to the project path. The aFileName attribute must
541  // always be an absolute path so the project path can be used for load child sheet files.
542  wxASSERT( fn.IsAbsolute() );
543 
544  if( aAppendToMe )
545  {
546  wxLogTrace( traceSchLegacyPlugin, "Append \"%s\" to sheet \"%s\".",
547  aFileName, aAppendToMe->GetFileName() );
548 
549  wxFileName normedFn = aAppendToMe->GetFileName();
550 
551  if( !normedFn.IsAbsolute() )
552  {
553  if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
554  m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
555  }
556 
557  if( m_path.IsEmpty() )
558  m_path = aSchematic->Prj().GetProjectPath();
559 
560  wxLogTrace( traceSchLegacyPlugin, "Normalized append path \"%s\".", m_path );
561  }
562  else
563  {
564  m_path = aSchematic->Prj().GetProjectPath();
565  }
566 
567  m_currentPath.push( m_path );
568  init( aSchematic, aProperties );
569 
570  if( aAppendToMe == nullptr )
571  {
572  // Clean up any allocated memory if an exception occurs loading the schematic.
573  std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( aSchematic );
574 
575  wxFileName relPath( aFileName );
576  // Do not use wxPATH_UNIX as option in MakeRelativeTo(). It can create incorrect
577  // relative paths on Windows, because paths have a disk identifier (C:, D: ...)
578  relPath.MakeRelativeTo( aSchematic->Prj().GetProjectPath() );
579 
580  newSheet->SetFileName( relPath.GetFullPath() );
581  m_rootSheet = newSheet.get();
582  loadHierarchy( newSheet.get() );
583 
584  // If we got here, the schematic loaded successfully.
585  sheet = newSheet.release();
586  m_rootSheet = nullptr; // Quiet Coverity warning.
587  }
588  else
589  {
590  wxCHECK_MSG( aSchematic->IsValid(), nullptr, "Can't append to a schematic with no root!" );
591  m_rootSheet = &aSchematic->Root();
592  sheet = aAppendToMe;
593  loadHierarchy( sheet );
594  }
595 
596  wxASSERT( m_currentPath.size() == 1 ); // only the project path should remain
597 
598  m_currentPath.pop(); // Clear the path stack for next call to Load
599 
600  return sheet;
601 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:108
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:315
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
SCH_SHEET & Root() const
Definition: schematic.h:92
wxString m_path
Root project path for loading child sheets.
void loadHierarchy(SCH_SHEET *aSheet)
void init(SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
initialize PLUGIN like a constructor would.

References SCH_SHEET::GetFileName(), PROJECT::GetProjectPath(), init(), SCHEMATIC::IsValid(), loadHierarchy(), m_currentPath, m_path, m_rootSheet, SCHEMATIC::Prj(), SCHEMATIC::Root(), and traceSchLegacyPlugin.

◆ LoadContent()

void SCH_SEXPR_PLUGIN::LoadContent ( LINE_READER aReader,
SCH_SHEET aSheet,
int  aVersion = SEXPR_SCHEMATIC_FILE_VERSION 
)

Definition at line 704 of file sch_sexpr_plugin.cpp.

705 {
706  wxCHECK( aSheet, /* void */ );
707 
708  LOCALE_IO toggle;
709  SCH_SEXPR_PARSER parser( &aReader );
710 
711  parser.ParseSchematic( aSheet, true, aFileVersion );
712 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Object to parser s-expression symbol library and schematic file formats.

References SCH_SEXPR_PARSER::ParseSchematic().

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ loadFile()

void SCH_SEXPR_PLUGIN::loadFile ( const wxString &  aFileName,
SCH_SHEET aSheet 
)
private

Definition at line 679 of file sch_sexpr_plugin.cpp.

680 {
681  FILE_LINE_READER reader( aFileName );
682 
683  size_t lineCount = 0;
684 
685  if( m_progressReporter )
686  {
687  m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
688 
690  THROW_IO_ERROR( ( "Open cancelled by user." ) );
691 
692  while( reader.ReadLine() )
693  lineCount++;
694 
695  reader.Rewind();
696  }
697 
698  SCH_SEXPR_PARSER parser( &reader, m_progressReporter, lineCount );
699 
700  parser.ParseSchematic( aSheet );
701 }
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
A LINE_READER that reads from an open file.
Definition: richio.h:172
#define _(s)
Object to parser s-expression symbol library and schematic file formats.
PROGRESS_REPORTER * m_progressReporter
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), PROGRESS_REPORTER::KeepRefreshing(), m_progressReporter, SCH_SEXPR_PARSER::ParseSchematic(), FILE_LINE_READER::ReadLine(), PROGRESS_REPORTER::Report(), FILE_LINE_READER::Rewind(), and THROW_IO_ERROR.

Referenced by loadHierarchy().

◆ loadHierarchy()

void SCH_SEXPR_PLUGIN::loadHierarchy ( SCH_SHEET aSheet)
private

Definition at line 606 of file sch_sexpr_plugin.cpp.

607 {
608  SCH_SCREEN* screen = nullptr;
609 
610  if( !aSheet->GetScreen() )
611  {
612  // SCH_SCREEN objects store the full path and file name where the SCH_SHEET object only
613  // stores the file name and extension. Add the project path to the file name and
614  // extension to compare when calling SCH_SHEET::SearchHierarchy().
615  wxFileName fileName = aSheet->GetFileName();
616 
617  if( !fileName.IsAbsolute() )
618  fileName.MakeAbsolute( m_currentPath.top() );
619 
620  // Save the current path so that it gets restored when descending and ascending the
621  // sheet hierarchy which allows for sheet schematic files to be nested in folders
622  // relative to the last path a schematic was loaded from.
623  wxLogTrace( traceSchLegacyPlugin, "Saving path '%s'", m_currentPath.top() );
624  m_currentPath.push( fileName.GetPath() );
625  wxLogTrace( traceSchLegacyPlugin, "Current path '%s'", m_currentPath.top() );
626  wxLogTrace( traceSchLegacyPlugin, "Loading '%s'", fileName.GetFullPath() );
627 
628  m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
629 
630  if( screen )
631  {
632  aSheet->SetScreen( screen );
633  aSheet->GetScreen()->SetParent( m_schematic );
634  // Do not need to load the sub-sheets - this has already been done.
635  }
636  else
637  {
638  aSheet->SetScreen( new SCH_SCREEN( m_schematic ) );
639  aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
640 
641  try
642  {
643  loadFile( fileName.GetFullPath(), aSheet );
644  }
645  catch( const IO_ERROR& ioe )
646  {
647  // If there is a problem loading the root sheet, there is no recovery.
648  if( aSheet == m_rootSheet )
649  throw;
650 
651  // For all subsheets, queue up the error message for the caller.
652  if( !m_error.IsEmpty() )
653  m_error += "\n";
654 
655  m_error += ioe.What();
656  }
657 
658  aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
659  aSheet->GetScreen()->SetFileExists( true );
660 
661  // This was moved out of the try{} block so that any sheets definitionsthat
662  // the plugin fully parsed before the exception was raised will be loaded.
663  for( SCH_ITEM* aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
664  {
665  wxCHECK2( aItem->Type() == SCH_SHEET_T, /* do nothing */ );
666  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
667 
668  // Recursion starts here.
669  loadHierarchy( sheet );
670  }
671  }
672 
673  m_currentPath.pop();
674  wxLogTrace( traceSchLegacyPlugin, "Restoring path \"%s\"", m_currentPath.top() );
675  }
676 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
SCHEMATIC * m_schematic
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:636
wxString m_error
For throwing exceptions or errors on partial loads.
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
void SetFileExists(bool aFileExists)
Definition: sch_screen.h:150
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
void SetFileReadOnly(bool aIsReadOnly)
Definition: sch_screen.h:147
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:315
void loadFile(const wxString &aFileName, SCH_SHEET *aSheet)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
void loadHierarchy(SCH_SHEET *aSheet)
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), loadFile(), m_currentPath, m_error, m_rootSheet, m_schematic, EE_RTREE::OfType(), SCH_SHEET_T, SCH_SHEET::SearchHierarchy(), SCH_SCREEN::SetFileExists(), SCH_SCREEN::SetFileName(), SCH_SCREEN::SetFileReadOnly(), EDA_ITEM::SetParent(), SCH_SHEET::SetScreen(), traceSchLegacyPlugin, and IO_ERROR::What().

Referenced by Load().

◆ LoadSymbol()

LIB_SYMBOL * SCH_SEXPR_PLUGIN::LoadSymbol ( const wxString &  aLibraryPath,
const wxString &  aPartName,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

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

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aPartNameis the name of the LIB_SYMBOL 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 part created on the heap 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 2181 of file sch_sexpr_plugin.cpp.

2183 {
2184  LOCALE_IO toggle; // toggles on, then off, the C locale.
2185 
2186  cacheLib( aLibraryPath, aProperties );
2187 
2188  LIB_SYMBOL_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName );
2189 
2190  if( it == m_cache->m_symbols.end() )
2191  return nullptr;
2192 
2193  return it->second;
2194 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
SCH_SEXPR_PLUGIN_CACHE * m_cache
void cacheLib(const wxString &aLibraryFileName, const PROPERTIES *aProperties)

References cacheLib(), m_cache, and SCH_SEXPR_PLUGIN_CACHE::m_symbols.

◆ ParseLibSymbol()

LIB_SYMBOL * SCH_SEXPR_PLUGIN::ParseLibSymbol ( LINE_READER aReader,
int  aVersion = SEXPR_SCHEMATIC_FILE_VERSION 
)
static

Definition at line 2312 of file sch_sexpr_plugin.cpp.

2313 {
2314  LOCALE_IO toggle; // toggles on, then off, the C locale.
2315  LIB_SYMBOL_MAP map;
2316  SCH_SEXPR_PARSER parser( &aReader );
2317 
2318  parser.NeedLEFT();
2319  parser.NextTok();
2320 
2321  return parser.ParseSymbol( map, aFileVersion );
2322 }
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
Symbol map used by symbol library object.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Object to parser s-expression symbol library and schematic file formats.

References SCH_SEXPR_PARSER::ParseSymbol().

Referenced by SYMBOL_EDIT_FRAME::DuplicateSymbol(), and SYMBOL_EDITOR_EDIT_TOOL::Paste().

◆ Save()

void SCH_SEXPR_PLUGIN::Save ( const wxString &  aFileName,
SCH_SHEET aSheet,
SCHEMATIC aSchematic,
const PROPERTIES aProperties = nullptr 
)
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.
aSheetis the class SCH_SHEET 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.
aSchematicis the SCHEMATIC object used to access any schematic-wide or project information needed to save the document.
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. Set the #PropSaveCurrentSheetOnly property to only save the current sheet. Otherwise, all hierarchical sheets are saved.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented from SCH_PLUGIN.

Definition at line 715 of file sch_sexpr_plugin.cpp.

717 {
718  wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET object." );
719  wxCHECK_RET( !aFileName.IsEmpty(), "No schematic file name defined." );
720 
721  LOCALE_IO toggle; // toggles on, then off, the C locale, to write floating point values.
722 
723  init( aSchematic, aProperties );
724 
725  wxFileName fn = aFileName;
726 
727  // File names should be absolute. Don't assume everything relative to the project path
728  // works properly.
729  wxASSERT( fn.IsAbsolute() );
730 
731  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
732 
733  m_out = &formatter; // no ownership
734 
735  Format( aSheet );
736 
737  aSheet->GetScreen()->SetFileExists( true );
738 }
void Format(SCH_SHEET *aSheet)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void SetFileExists(bool aFileExists)
Definition: sch_screen.h:150
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
Used for text file output.
Definition: richio.h:456
void init(SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
initialize PLUGIN like a constructor would.

References Format(), SCH_SHEET::GetScreen(), init(), m_out, and SCH_SCREEN::SetFileExists().

◆ saveBitmap()

void SCH_SEXPR_PLUGIN::saveBitmap ( SCH_BITMAP aBitmap,
int  aNestLevel 
)
private

Definition at line 1189 of file sch_sexpr_plugin.cpp.

1190 {
1191  wxCHECK_RET( aBitmap != nullptr && m_out != nullptr, "" );
1192 
1193  const wxImage* image = aBitmap->GetImage()->GetImageData();
1194 
1195  wxCHECK_RET( image != nullptr, "wxImage* is NULL" );
1196 
1197  m_out->Print( aNestLevel, "(image (at %s %s)",
1198  FormatInternalUnits( aBitmap->GetPosition().x ).c_str(),
1199  FormatInternalUnits( aBitmap->GetPosition().y ).c_str() );
1200 
1201  if( aBitmap->GetImage()->GetScale() != 1.0 )
1202  m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
1203 
1204  m_out->Print( 0, "\n" );
1205 
1206  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBitmap->m_Uuid.AsString() ) );
1207 
1208  m_out->Print( aNestLevel + 1, "(data" );
1209 
1210  wxMemoryOutputStream stream;
1211 
1212  image->SaveFile( stream, wxBITMAP_TYPE_PNG );
1213 
1214  // Write binary data in hexadecimal form (ASCII)
1215  wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
1216  wxString out = wxBase64Encode( buffer->GetBufferStart(), buffer->GetBufferSize() );
1217 
1218  // Apparently the MIME standard character width for base64 encoding is 76 (unconfirmed)
1219  // so use it in a vein attempt to be standard like.
1220 #define MIME_BASE64_LENGTH 76
1221 
1222  size_t first = 0;
1223 
1224  while( first < out.Length() )
1225  {
1226  m_out->Print( 0, "\n" );
1227  m_out->Print( aNestLevel + 2, "%s", TO_UTF8( out( first, MIME_BASE64_LENGTH ) ) );
1228  first += MIME_BASE64_LENGTH;
1229  }
1230 
1231  m_out->Print( 0, "\n" );
1232  m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
1233  m_out->Print( aNestLevel, ")\n" ); // Closes image token.
1234 }
double GetScale() const
Definition: bitmap_base.h:79
wxImage * GetImageData()
Definition: bitmap_base.h:70
wxString AsString() const
Definition: kiid.cpp:218
wxPoint GetPosition() const override
Definition: sch_bitmap.h:136
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
#define MIME_BASE64_LENGTH
const KIID m_Uuid
Definition: eda_item.h:475
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References KIID::AsString(), FormatInternalUnits(), SCH_BITMAP::GetImage(), BITMAP_BASE::GetImageData(), SCH_BITMAP::GetPosition(), BITMAP_BASE::GetScale(), image, m_out, EDA_ITEM::m_Uuid, MIME_BASE64_LENGTH, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by Format().

◆ saveBusAlias()

void SCH_SEXPR_PLUGIN::saveBusAlias ( std::shared_ptr< BUS_ALIAS aAlias,
int  aNestLevel 
)
private

Definition at line 1440 of file sch_sexpr_plugin.cpp.

1441 {
1442  wxCHECK_RET( aAlias != nullptr, "BUS_ALIAS* is NULL" );
1443 
1444  wxString members;
1445 
1446  for( auto member : aAlias->Members() )
1447  {
1448  if( members.IsEmpty() )
1449  members = m_out->Quotew( member );
1450  else
1451  members += " " + m_out->Quotew( member );
1452  }
1453 
1454  m_out->Print( aNestLevel, "(bus_alias %s (members %s))\n",
1455  m_out->Quotew( aAlias->GetName() ).c_str(),
1456  TO_UTF8( members ) );
1457 }
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References m_out, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and TO_UTF8.

Referenced by Format().

◆ saveBusEntry()

void SCH_SEXPR_PLUGIN::saveBusEntry ( SCH_BUS_ENTRY_BASE aBusEntry,
int  aNestLevel 
)
private

Definition at line 1321 of file sch_sexpr_plugin.cpp.

1322 {
1323  wxCHECK_RET( aBusEntry != nullptr && m_out != nullptr, "" );
1324 
1325  // Bus to bus entries are converted to bus line segments.
1326  if( aBusEntry->GetClass() == "SCH_BUS_BUS_ENTRY" )
1327  {
1328  SCH_LINE busEntryLine( aBusEntry->GetPosition(), LAYER_BUS );
1329 
1330  busEntryLine.SetEndPoint( aBusEntry->GetEnd() );
1331  saveLine( &busEntryLine, aNestLevel );
1332  }
1333  else
1334  {
1335  m_out->Print( aNestLevel, "(bus_entry (at %s %s) (size %s %s)\n",
1336  FormatInternalUnits( aBusEntry->GetPosition().x ).c_str(),
1337  FormatInternalUnits( aBusEntry->GetPosition().y ).c_str(),
1338  FormatInternalUnits( aBusEntry->GetSize().GetWidth() ).c_str(),
1339  FormatInternalUnits( aBusEntry->GetSize().GetHeight() ).c_str() );
1340 
1341  formatStroke( m_out, aNestLevel + 1, aBusEntry->GetStroke() );
1342 
1343  m_out->Print( 0, "\n" );
1344 
1345  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBusEntry->m_Uuid.AsString() ) );
1346 
1347  m_out->Print( aNestLevel, ")\n" );
1348  }
1349 }
void saveLine(SCH_LINE *aLine, int aNestLevel)
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:69
wxString AsString() const
Definition: kiid.cpp:218
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
const KIID m_Uuid
Definition: eda_item.h:475
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
wxSize GetSize() const
Definition: sch_bus_entry.h:63
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:191
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
wxPoint GetEnd() const
wxPoint GetPosition() const override

References KIID::AsString(), FormatInternalUnits(), formatStroke(), SCH_ITEM::GetClass(), SCH_BUS_ENTRY_BASE::GetEnd(), SCH_BUS_ENTRY_BASE::GetPosition(), SCH_BUS_ENTRY_BASE::GetSize(), SCH_BUS_ENTRY_BASE::GetStroke(), LAYER_BUS, m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), saveLine(), SCH_LINE::SetEndPoint(), and TO_UTF8.

Referenced by Format().

◆ saveField()

void SCH_SEXPR_PLUGIN::saveField ( SCH_FIELD aField,
int  aNestLevel 
)
private

Definition at line 1138 of file sch_sexpr_plugin.cpp.

1139 {
1140  wxCHECK_RET( aField != nullptr && m_out != nullptr, "" );
1141 
1142  wxString fieldName = aField->GetName();
1143 
1144  // For some reason (bug in legacy parser?) the field ID for non-mandatory fields is -1 so
1145  // check for this in order to correctly use the field name.
1146  if( aField->GetParent()->Type() == SCH_SYMBOL_T )
1147  {
1148  if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
1149  fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), false );
1150  }
1151  else if( aField->GetParent()->Type() == SCH_SHEET_T )
1152  {
1153  if( aField->GetId() >= 0 && aField->GetId() < SHEET_MANDATORY_FIELDS )
1154  fieldName = SCH_SHEET::GetDefaultFieldName( aField->GetId() );
1155  }
1156 
1157  if( aField->GetId() == -1 /* undefined ID */ )
1158  {
1159  aField->SetId( m_nextFreeFieldId );
1160  m_nextFreeFieldId += 1;
1161  }
1162  else if( aField->GetId() >= m_nextFreeFieldId )
1163  {
1164  m_nextFreeFieldId = aField->GetId() + 1;
1165  }
1166 
1167  m_out->Print( aNestLevel, "(property %s %s (id %d) (at %s %s %s)",
1168  m_out->Quotew( fieldName ).c_str(),
1169  m_out->Quotew( aField->GetText() ).c_str(),
1170  aField->GetId(),
1171  FormatInternalUnits( aField->GetPosition().x ).c_str(),
1172  FormatInternalUnits( aField->GetPosition().y ).c_str(),
1173  FormatAngle( aField->GetTextAngleDegrees() * 10.0 ).c_str() );
1174 
1175  if( !aField->IsDefaultFormatting()
1176  || ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
1177  {
1178  m_out->Print( 0, "\n" );
1179  aField->Format( m_out, aNestLevel, 0 );
1180  m_out->Print( aNestLevel, ")\n" ); // Closes property token with font effects.
1181  }
1182  else
1183  {
1184  m_out->Print( 0, ")\n" ); // Closes property token without font effects.
1185  }
1186 }
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:80
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
wxPoint GetPosition() const override
Definition: sch_field.cpp:747
int GetId() const
Definition: sch_field.h:113
int GetTextHeight() const
Definition: eda_text.h:244
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:520
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:46
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:526
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
bool IsDefaultFormatting() const
Definition: eda_text.cpp:512
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
double GetTextAngleDegrees() const
Definition: eda_text.h:176
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:582
void SetId(int aId)
Definition: sch_field.cpp:80
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References DEFAULT_SIZE_TEXT, EDA_TEXT::Format(), FormatAngle(), FormatInternalUnits(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), SCH_SHEET::GetDefaultFieldName(), SCH_FIELD::GetId(), SCH_FIELD::GetName(), EDA_ITEM::GetParent(), SCH_FIELD::GetPosition(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleDegrees(), EDA_TEXT::GetTextHeight(), EDA_TEXT::IsDefaultFormatting(), m_nextFreeFieldId, m_out, MANDATORY_FIELDS, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), SCH_SHEET_T, SCH_SYMBOL_T, SCH_FIELD::SetId(), SHEET_MANDATORY_FIELDS, and EDA_ITEM::Type().

Referenced by saveSheet(), saveSymbol(), and saveText().

◆ saveInstances()

void SCH_SEXPR_PLUGIN::saveInstances ( const std::vector< SCH_SHEET_INSTANCE > &  aSheets,
const std::vector< SYMBOL_INSTANCE_REFERENCE > &  aSymbols,
int  aNestLevel 
)
private

Definition at line 1460 of file sch_sexpr_plugin.cpp.

1463 {
1464  if( aSheets.size() )
1465  {
1466  m_out->Print( 0, "\n" );
1467  m_out->Print( aNestLevel, "(sheet_instances\n" );
1468 
1469  for( const SCH_SHEET_INSTANCE& instance : aSheets )
1470  {
1471  wxString path = instance.m_Path.AsString();
1472 
1473  if( path.IsEmpty() )
1474  path = wxT( "/" ); // Root path
1475 
1476  m_out->Print( aNestLevel + 1, "(path %s (page %s))\n",
1477  m_out->Quotew( path ).c_str(),
1478  m_out->Quotew( instance.m_PageNumber ).c_str() );
1479  }
1480 
1481  m_out->Print( aNestLevel, ")\n" ); // Close sheet instances token.
1482  }
1483 
1484  if( aSymbols.size() )
1485  {
1486  m_out->Print( 0, "\n" );
1487  m_out->Print( aNestLevel, "(symbol_instances\n" );
1488 
1489  for( const SYMBOL_INSTANCE_REFERENCE& instance : aSymbols )
1490  {
1491  m_out->Print( aNestLevel + 1, "(path %s\n",
1492  m_out->Quotew( instance.m_Path.AsString() ).c_str() );
1493  m_out->Print( aNestLevel + 2, "(reference %s) (unit %d) (value %s) (footprint %s)\n",
1494  m_out->Quotew( instance.m_Reference ).c_str(),
1495  instance.m_Unit,
1496  m_out->Quotew( instance.m_Value ).c_str(),
1497  m_out->Quotew( instance.m_Footprint ).c_str() );
1498  m_out->Print( aNestLevel + 1, ")\n" );
1499  }
1500 
1501  m_out->Print( aNestLevel, ")\n" ); // Close symbol instances token.
1502  }
1503 }
A simple container for schematic symbol instance information.
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
A simple container for sheet instance information.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References m_out, path, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by Format().

◆ saveJunction()

void SCH_SEXPR_PLUGIN::saveJunction ( SCH_JUNCTION aJunction,
int  aNestLevel 
)
private

Definition at line 1295 of file sch_sexpr_plugin.cpp.

1296 {
1297  wxCHECK_RET( aJunction != nullptr && m_out != nullptr, "" );
1298 
1299  m_out->Print( aNestLevel, "(junction (at %s %s) (diameter %s) (color %d %d %d %s))\n",
1300  FormatInternalUnits( aJunction->GetPosition().x ).c_str(),
1301  FormatInternalUnits( aJunction->GetPosition().y ).c_str(),
1302  FormatInternalUnits( aJunction->GetDiameter() ).c_str(),
1303  KiROUND( aJunction->GetColor().r * 255.0 ),
1304  KiROUND( aJunction->GetColor().g * 255.0 ),
1305  KiROUND( aJunction->GetColor().b * 255.0 ),
1306  Double2Str( aJunction->GetColor().a ).c_str() );
1307 }
int GetDiameter() const
Definition: sch_junction.h:99
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
COLOR4D GetColor() const
Definition: sch_junction.h:104
double a
Alpha component.
Definition: color4d.h:380
wxPoint GetPosition() const override
Definition: sch_junction.h:92
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
double r
Red component.
Definition: color4d.h:377
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, Double2Str(), FormatInternalUnits(), KIGFX::COLOR4D::g, SCH_JUNCTION::GetColor(), SCH_JUNCTION::GetDiameter(), SCH_JUNCTION::GetPosition(), KiROUND(), m_out, OUTPUTFORMATTER::Print(), and KIGFX::COLOR4D::r.

Referenced by Format().

◆ SaveLibrary()

void SCH_SEXPR_PLUGIN::SaveLibrary ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Reimplemented from SCH_PLUGIN.

Definition at line 2270 of file sch_sexpr_plugin.cpp.

2271 {
2272  if( !m_cache )
2273  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryPath );
2274 
2275  wxString oldFileName = m_cache->GetFileName();
2276 
2277  if( !m_cache->IsFile( aLibraryPath ) )
2278  {
2279  m_cache->SetFileName( aLibraryPath );
2280  }
2281 
2282  // This is a forced save.
2283  m_cache->SetModified();
2284  m_cache->Save();
2285  m_cache->SetFileName( oldFileName );
2286 }
void Save()
Save the entire library to file m_libFileName;.
wxString GetFileName() const
SCH_SEXPR_PLUGIN_CACHE * m_cache
void SetFileName(const wxString &aFileName)
A cache assistant for the symbol library portion of the SCH_PLUGIN API, and only for the SCH_SEXPR_PL...
void SetModified(bool aModified=true)
bool IsFile(const wxString &aFullPathAndFileName) const

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

◆ saveLine()

void SCH_SEXPR_PLUGIN::saveLine ( SCH_LINE aLine,
int  aNestLevel 
)
private

Definition at line 1352 of file sch_sexpr_plugin.cpp.

1353 {
1354  wxCHECK_RET( aLine != nullptr && m_out != nullptr, "" );
1355 
1356  wxString lineType;
1357 
1358  STROKE_PARAMS line_stroke = aLine->GetStroke();
1359 
1360  switch( aLine->GetLayer() )
1361  {
1362  case LAYER_BUS: lineType = "bus"; break;
1363  case LAYER_WIRE: lineType = "wire"; break;
1364  case LAYER_NOTES:
1365  default: lineType = "polyline"; break;
1366  }
1367 
1368  m_out->Print( aNestLevel, "(%s (pts (xy %s %s) (xy %s %s))\n",
1369  TO_UTF8( lineType ),
1370  FormatInternalUnits( aLine->GetStartPoint().x ).c_str(),
1371  FormatInternalUnits( aLine->GetStartPoint().y ).c_str(),
1372  FormatInternalUnits( aLine->GetEndPoint().x ).c_str(),
1373  FormatInternalUnits( aLine->GetEndPoint().y ).c_str() );
1374 
1375  formatStroke( m_out, aNestLevel + 1, line_stroke );
1376  m_out->Print( 0, "\n" );
1377 
1378  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aLine->m_Uuid.AsString() ) );
1379 
1380  m_out->Print( aNestLevel, ")\n" );
1381 }
wxPoint GetStartPoint() const
Definition: sch_line.h:90
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
const KIID m_Uuid
Definition: eda_item.h:475
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:257
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
Simple container to manage line stroke parameters.
Definition: sch_item.h:140
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_line.h:124
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References KIID::AsString(), FormatInternalUnits(), formatStroke(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), SCH_LINE::GetStartPoint(), SCH_LINE::GetStroke(), LAYER_BUS, LAYER_NOTES, LAYER_WIRE, m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by Format(), and saveBusEntry().

◆ saveNoConnect()

void SCH_SEXPR_PLUGIN::saveNoConnect ( SCH_NO_CONNECT aNoConnect,
int  aNestLevel 
)
private

Definition at line 1310 of file sch_sexpr_plugin.cpp.

1311 {
1312  wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
1313 
1314  m_out->Print( aNestLevel, "(no_connect (at %s %s) (uuid %s))\n",
1315  FormatInternalUnits( aNoConnect->GetPosition().x ).c_str(),
1316  FormatInternalUnits( aNoConnect->GetPosition().y ).c_str(),
1317  TO_UTF8( aNoConnect->m_Uuid.AsString() ) );
1318 }
wxPoint GetPosition() const override
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const KIID m_Uuid
Definition: eda_item.h:475
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References KIID::AsString(), FormatInternalUnits(), SCH_NO_CONNECT::GetPosition(), m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by Format().

◆ saveSheet()

void SCH_SEXPR_PLUGIN::saveSheet ( SCH_SHEET aSheet,
int  aNestLevel 
)
private

Definition at line 1237 of file sch_sexpr_plugin.cpp.

1238 {
1239  wxCHECK_RET( aSheet != nullptr && m_out != nullptr, "" );
1240 
1241  m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)",
1242  FormatInternalUnits( aSheet->GetPosition().x ).c_str(),
1243  FormatInternalUnits( aSheet->GetPosition().y ).c_str(),
1244  FormatInternalUnits( aSheet->GetSize().GetWidth() ).c_str(),
1245  FormatInternalUnits( aSheet->GetSize().GetHeight() ).c_str() );
1246 
1247  if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1248  m_out->Print( 0, " (fields_autoplaced)" );
1249 
1250  m_out->Print( 0, "\n" );
1251 
1253  aSheet->GetBorderColor() );
1254 
1255  stroke.SetWidth( aSheet->GetBorderWidth() );
1256  formatStroke( m_out, aNestLevel + 1, stroke );
1257 
1258  m_out->Print( 0, "\n" );
1259 
1260  m_out->Print( aNestLevel + 1, "(fill (color %d %d %d %0.4f))\n",
1261  KiROUND( aSheet->GetBackgroundColor().r * 255.0 ),
1262  KiROUND( aSheet->GetBackgroundColor().g * 255.0 ),
1263  KiROUND( aSheet->GetBackgroundColor().b * 255.0 ),
1264  aSheet->GetBackgroundColor().a );
1265 
1266  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSheet->m_Uuid.AsString() ) );
1267 
1269 
1270  for( SCH_FIELD& field : aSheet->GetFields() )
1271  {
1272  saveField( &field, aNestLevel + 1 );
1273  }
1274 
1275  for( const SCH_SHEET_PIN* pin : aSheet->GetPins() )
1276  {
1277  m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)\n",
1278  EscapedUTF8( pin->GetText() ).c_str(),
1279  getSheetPinShapeToken( pin->GetShape() ),
1280  FormatInternalUnits( pin->GetPosition().x ).c_str(),
1281  FormatInternalUnits( pin->GetPosition().y ).c_str(),
1282  FormatAngle( getSheetPinAngle( pin->GetEdge() ) * 10.0 ).c_str() );
1283 
1284  pin->Format( m_out, aNestLevel + 1, 0 );
1285 
1286  m_out->Print( aNestLevel + 2, "(uuid %s)\n", TO_UTF8( pin->m_Uuid.AsString() ) );
1287 
1288  m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
1289  }
1290 
1291  m_out->Print( aNestLevel, ")\n" ); // Closes sheet token.
1292 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SetWidth(int aWidth)
Definition: sch_item.h:153
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
wxString AsString() const
Definition: kiid.cpp:218
double g
Green component.
Definition: color4d.h:378
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:111
void saveField(SCH_FIELD *aField, int aNestLevel)
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:418
double b
Blue component.
Definition: color4d.h:379
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:114
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:520
int GetBorderWidth() const
Definition: sch_sheet.h:108
double a
Alpha component.
Definition: color4d.h:380
static double getSheetPinAngle(SHEET_SIDE aSide)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
wxPoint GetPosition() const override
Definition: sch_sheet.h:380
const KIID m_Uuid
Definition: eda_item.h:475
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
Simple container to manage line stroke parameters.
Definition: sch_item.h:140
wxSize GetSize() const
Definition: sch_sheet.h:105
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
double r
Red component.
Definition: color4d.h:377
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
static const char * getSheetPinShapeToken(PINSHEETLABEL_SHAPE aShape)

References KIGFX::COLOR4D::a, KIID::AsString(), KIGFX::COLOR4D::b, EscapedUTF8(), FIELDS_AUTOPLACED_NO, FormatAngle(), FormatInternalUnits(), formatStroke(), KIGFX::COLOR4D::g, SCH_SHEET::GetBackgroundColor(), SCH_SHEET::GetBorderColor(), SCH_SHEET::GetBorderWidth(), SCH_SHEET::GetFields(), SCH_ITEM::GetFieldsAutoplaced(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getSheetPinAngle(), getSheetPinShapeToken(), SCH_SHEET::GetSize(), KiROUND(), m_nextFreeFieldId, m_out, EDA_ITEM::m_Uuid, pin, OUTPUTFORMATTER::Print(), KIGFX::COLOR4D::r, saveField(), STROKE_PARAMS::SetWidth(), SHEET_MANDATORY_FIELDS, SOLID, and TO_UTF8.

Referenced by Format().

◆ SaveSymbol()

void SCH_SEXPR_PLUGIN::SaveSymbol ( const wxString &  aLibraryPath,
const LIB_SYMBOL aSymbol,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Write aSymbol to an existing library located at aLibraryPath.

If a LIB_SYMBOL by the same name already exists or there are any conflicting alias names, the new LIB_SYMBOL will silently overwrite any existing aliases and/or part because 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_SYMBOL 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 2197 of file sch_sexpr_plugin.cpp.

2199 {
2200  LOCALE_IO toggle; // toggles on, then off, the C locale.
2201 
2202  cacheLib( aLibraryPath, aProperties );
2203 
2204  m_cache->AddSymbol( aSymbol );
2205 
2206  if( !isBuffering( aProperties ) )
2207  m_cache->Save();
2208 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void Save()
Save the entire library to file m_libFileName;.
SCH_SEXPR_PLUGIN_CACHE * m_cache
void AddSymbol(const LIB_SYMBOL *aSymbol)
void cacheLib(const wxString &aLibraryFileName, const PROPERTIES *aProperties)
bool isBuffering(const PROPERTIES *aProperties)

References SCH_SEXPR_PLUGIN_CACHE::AddSymbol(), cacheLib(), isBuffering(), m_cache, and SCH_SEXPR_PLUGIN_CACHE::Save().

◆ saveSymbol()

void SCH_SEXPR_PLUGIN::saveSymbol ( SCH_SYMBOL aSymbol,
SCH_SHEET_PATH aSheetPath,
int  aNestLevel 
)
private

Definition at line 1023 of file sch_sexpr_plugin.cpp.

1025 {
1026  wxCHECK_RET( aSymbol != nullptr && m_out != nullptr, "" );
1027 
1028  std::string libName;
1029  wxArrayString reference_fields;
1030 
1031  static wxString delimiters( wxT( " " ) );
1032 
1033  wxString symbol_name = aSymbol->GetLibId().Format();
1034 
1035  if( symbol_name.size() )
1036  {
1037  libName = toUTFTildaText( symbol_name );
1038  }
1039  else
1040  {
1041  libName = "_NONAME_";
1042  }
1043 
1044  double angle;
1045  int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
1046 
1047  if( orientation == SYM_ORIENT_90 )
1048  angle = 90.0;
1049  else if( orientation == SYM_ORIENT_180 )
1050  angle = 180.0;
1051  else if( orientation == SYM_ORIENT_270 )
1052  angle = 270.0;
1053  else
1054  angle = 0.0;
1055 
1056  m_out->Print( aNestLevel, "(symbol" );
1057 
1058  if( !aSymbol->UseLibIdLookup() )
1059  {
1060  m_out->Print( 0, " (lib_name %s)",
1061  m_out->Quotew( aSymbol->GetSchSymbolLibraryName() ).c_str() );
1062  }
1063 
1064  m_out->Print( 0, " (lib_id %s) (at %s %s %s)",
1065  m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(),
1066  FormatInternalUnits( aSymbol->GetPosition().x ).c_str(),
1067  FormatInternalUnits( aSymbol->GetPosition().y ).c_str(),
1068  FormatAngle( angle * 10.0 ).c_str() );
1069 
1070  bool mirrorX = aSymbol->GetOrientation() & SYM_MIRROR_X;
1071  bool mirrorY = aSymbol->GetOrientation() & SYM_MIRROR_Y;
1072 
1073  if( mirrorX || mirrorY )
1074  {
1075  m_out->Print( 0, " (mirror" );
1076 
1077  if( mirrorX )
1078  m_out->Print( 0, " x" );
1079 
1080  if( mirrorY )
1081  m_out->Print( 0, " y" );
1082 
1083  m_out->Print( 0, ")" );
1084  }
1085 
1086  int unit = -1;
1087 
1088  if( !( aSymbol->GetInstanceReferences().size() > 1 ) )
1089  unit = aSymbol->GetUnit();
1090  else if( aSheetPath != nullptr )
1091  unit = aSymbol->GetUnitSelection( aSheetPath );
1092  if ( unit >= 0 )
1093  m_out->Print( 0, " (unit %d)", unit );
1094 
1095  if( aSymbol->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN )
1096  m_out->Print( 0, " (convert %d)", aSymbol->GetConvert() );
1097 
1098  m_out->Print( 0, "\n" );
1099 
1100  m_out->Print( aNestLevel + 1, "(in_bom %s)", ( aSymbol->GetIncludeInBom() ) ? "yes" : "no" );
1101  m_out->Print( 0, " (on_board %s)", ( aSymbol->GetIncludeOnBoard() ) ? "yes" : "no" );
1102 
1103  if( aSymbol->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1104  m_out->Print( 0, " (fields_autoplaced)" );
1105 
1106  m_out->Print( 0, "\n" );
1107 
1108  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
1109 
1111 
1112  for( SCH_FIELD& field : aSymbol->GetFields() )
1113  {
1114  saveField( &field, aNestLevel + 1 );
1115  }
1116 
1117  for( const SCH_PIN* pin : aSymbol->GetPins() )
1118  {
1119  if( pin->GetAlt().IsEmpty() )
1120  {
1121  m_out->Print( aNestLevel + 1, "(pin %s (uuid %s))\n",
1122  m_out->Quotew( pin->GetNumber() ).c_str(),
1123  TO_UTF8( pin->m_Uuid.AsString() ) );
1124  }
1125  else
1126  {
1127  m_out->Print( aNestLevel + 1, "(pin %s (uuid %s) (alternate %s))\n",
1128  m_out->Quotew( pin->GetNumber() ).c_str(),
1129  TO_UTF8( pin->m_Uuid.AsString() ),
1130  m_out->Quotew( pin->GetAlt() ).c_str() );
1131  }
1132  }
1133 
1134  m_out->Print( aNestLevel, ")\n" );
1135 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:711
bool GetIncludeInBom() const
Definition: sch_symbol.h:662
wxString AsString() const
Definition: kiid.cpp:218
void saveField(SCH_FIELD *aField, int aNestLevel)
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
Definition: sch_symbol.cpp:46
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:418
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences()
Definition: sch_symbol.h:123
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:520
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:248
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:531
UTF8 Format() const
Definition: lib_id.cpp:116
const KIID m_Uuid
Definition: eda_item.h:475
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
wxString wx_str() const
Definition: utf8.cpp:46
wxPoint GetPosition() const override
Definition: sch_symbol.h:644
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:665
int GetOrientation()
Get the display symbol orientation.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
int GetUnit() const
Definition: sch_symbol.h:195
int GetConvert() const
Definition: sch_symbol.h:223
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
Definition: sch_symbol.cpp:866
bool UseLibIdLookup() const
Definition: sch_symbol.h:162
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147

References PNS::angle(), KIID::AsString(), FIELDS_AUTOPLACED_NO, LIB_ID::Format(), FormatAngle(), FormatInternalUnits(), SCH_SYMBOL::GetConvert(), SCH_SYMBOL::GetFields(), SCH_ITEM::GetFieldsAutoplaced(), SCH_SYMBOL::GetIncludeInBom(), SCH_SYMBOL::GetIncludeOnBoard(), SCH_SYMBOL::GetInstanceReferences(), SCH_SYMBOL::GetLibId(), SCH_SYMBOL::GetOrientation(), SCH_SYMBOL::GetPins(), SCH_SYMBOL::GetPosition(), SCH_SYMBOL::GetSchSymbolLibraryName(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitSelection(), m_nextFreeFieldId, m_out, EDA_ITEM::m_Uuid, MANDATORY_FIELDS, pin, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), saveField(), SYM_MIRROR_X, SYM_MIRROR_Y, SYM_ORIENT_180, SYM_ORIENT_270, SYM_ORIENT_90, TO_UTF8, toUTFTildaText(), SCH_SYMBOL::UseLibIdLookup(), and UTF8::wx_str().

Referenced by Format().

◆ saveText()

void SCH_SEXPR_PLUGIN::saveText ( SCH_TEXT aText,
int  aNestLevel 
)
private

Definition at line 1384 of file sch_sexpr_plugin.cpp.

1385 {
1386  wxCHECK_RET( aText != nullptr && m_out != nullptr, "" );
1387 
1388  double angle;
1389 
1390  switch( aText->GetLabelSpinStyle() )
1391  {
1392  case LABEL_SPIN_STYLE::RIGHT: angle = 0.0; break;
1393  case LABEL_SPIN_STYLE::UP: angle = 90.0; break;
1394  case LABEL_SPIN_STYLE::LEFT: angle = 180.0; break;
1395  case LABEL_SPIN_STYLE::BOTTOM: angle = 270.0; break;
1396  default: wxFAIL; angle = 0.0; break;
1397  }
1398 
1399  m_out->Print( aNestLevel, "(%s %s",
1400  getTextTypeToken( aText->Type() ),
1401  m_out->Quotew( aText->GetText() ).c_str() );
1402 
1403  if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) || ( aText->Type() == SCH_HIER_LABEL_T ) )
1404  m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( aText->GetShape() ) );
1405 
1406  if( aText->GetText().Length() < 50 )
1407  {
1408  m_out->Print( 0, " (at %s %s %s)",
1409  FormatInternalUnits( aText->GetPosition().x ).c_str(),
1410  FormatInternalUnits( aText->GetPosition().y ).c_str(),
1411  FormatAngle( angle * 10.0 ).c_str() );
1412  }
1413  else
1414  {
1415  m_out->Print( 0, "\n" );
1416  m_out->Print( aNestLevel + 1, "(at %s %s %s)",
1417  FormatInternalUnits( aText->GetPosition().x ).c_str(),
1418  FormatInternalUnits( aText->GetPosition().y ).c_str(),
1419  FormatAngle( aText->GetTextAngle() ).c_str() );
1420  }
1421 
1422  if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1423  m_out->Print( 0, " (fields_autoplaced)" );
1424 
1425  m_out->Print( 0, "\n" );
1426  aText->Format( m_out, aNestLevel, 0 );
1427 
1428  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
1429 
1430  if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) )
1431  {
1432  SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aText );
1433  saveField( label->GetIntersheetRefs(), aNestLevel + 1 );
1434  }
1435 
1436  m_out->Print( aNestLevel, ")\n" ); // Closes text token.
1437 }
static const char * getTextTypeToken(KICAD_T aType)
double GetTextAngle() const
Definition: eda_text.h:174
wxString AsString() const
Definition: kiid.cpp:218
void saveField(SCH_FIELD *aField, int aNestLevel)
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:418
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::string FormatAngle(double aAngle)
Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.
Definition: base_units.cpp:520
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:526
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:159
wxPoint GetPosition() const override
Definition: sch_text.h:239
const KIID m_Uuid
Definition: eda_item.h:475
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:413
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485
static const char * getSheetPinShapeToken(PINSHEETLABEL_SHAPE aShape)
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:494

References PNS::angle(), KIID::AsString(), LABEL_SPIN_STYLE::BOTTOM, FIELDS_AUTOPLACED_NO, EDA_TEXT::Format(), FormatAngle(), FormatInternalUnits(), SCH_ITEM::GetFieldsAutoplaced(), SCH_GLOBALLABEL::GetIntersheetRefs(), SCH_TEXT::GetLabelSpinStyle(), SCH_TEXT::GetPosition(), SCH_TEXT::GetShape(), getSheetPinShapeToken(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), getTextTypeToken(), LABEL_SPIN_STYLE::LEFT, m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), LABEL_SPIN_STYLE::RIGHT, saveField(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, TO_UTF8, EDA_ITEM::Type(), and LABEL_SPIN_STYLE::UP.

Referenced by Format().

◆ SetProgressReporter()

void SCH_SEXPR_PLUGIN::SetProgressReporter ( PROGRESS_REPORTER aReporter)
inlineoverridevirtual

Set an optional progress reporter.

Reimplemented from SCH_PLUGIN.

Definition at line 82 of file sch_sexpr_plugin.h.

83  {
84  m_progressReporter = aReporter;
85  }
PROGRESS_REPORTER * m_progressReporter

References m_progressReporter.

◆ SetReporter()

virtual void SCH_PLUGIN::SetReporter ( REPORTER aReporter)
inlinevirtualinherited

Set an optional reporter for warnings/errors.

Reimplemented in SCH_EAGLE_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.

Definition at line 166 of file sch_io_mgr.h.

166 {}

◆ 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 133 of file sch_plugin.cpp.

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

References _.

Member Data Documentation

◆ m_cache

◆ m_currentPath

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

Stack to maintain nested sheet paths.

Definition at line 168 of file sch_sexpr_plugin.h.

Referenced by Load(), and loadHierarchy().

◆ m_error

wxString SCH_SEXPR_PLUGIN::m_error
protected

For throwing exceptions or errors on partial loads.

Definition at line 163 of file sch_sexpr_plugin.h.

Referenced by GetError(), and loadHierarchy().

◆ m_nextFreeFieldId

int SCH_SEXPR_PLUGIN::m_nextFreeFieldId
protected

Definition at line 161 of file sch_sexpr_plugin.h.

Referenced by init(), saveField(), saveSheet(), and saveSymbol().

◆ m_out

OUTPUTFORMATTER* SCH_SEXPR_PLUGIN::m_out
protected

◆ m_path

wxString SCH_SEXPR_PLUGIN::m_path
protected

Root project path for loading child sheets.

Definition at line 167 of file sch_sexpr_plugin.h.

Referenced by Load().

◆ m_progressReporter

PROGRESS_REPORTER* SCH_SEXPR_PLUGIN::m_progressReporter
protected

Definition at line 165 of file sch_sexpr_plugin.h.

Referenced by loadFile(), and SetProgressReporter().

◆ m_rootSheet

SCH_SHEET* SCH_SEXPR_PLUGIN::m_rootSheet
protected

The root sheet of the schematic being loaded.

Definition at line 169 of file sch_sexpr_plugin.h.

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

◆ m_schematic

SCHEMATIC* SCH_SEXPR_PLUGIN::m_schematic
protected

Definition at line 170 of file sch_sexpr_plugin.h.

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

◆ m_version

int SCH_SEXPR_PLUGIN::m_version
protected

Version of file being loaded.

Definition at line 160 of file sch_sexpr_plugin.h.

Referenced by init().

◆ PropBuffering

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

The 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 92 of file sch_sexpr_plugin.h.

Referenced by isBuffering().


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