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 498 of file sch_sexpr_plugin.cpp.

498  :
499  m_progressReporter( nullptr )
500 {
501  init( nullptr );
502 }
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 505 of file sch_sexpr_plugin.cpp.

506 {
507  delete m_cache;
508 }
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 2125 of file sch_sexpr_plugin.cpp.

2126 {
2127  if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
2128  {
2129  // a spectacular episode in memory management:
2130  delete m_cache;
2131  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryFileName );
2132 
2133  // Because m_cache is rebuilt, increment SYMBOL_LIBS::s_modify_generation
2134  // to modify the hash value that indicate symbol to symbol links
2135  // must be updated.
2137 
2138  if( !isBuffering( aProperties ) )
2139  m_cache->Load();
2140  }
2141 }
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 2310 of file sch_sexpr_plugin.cpp.

2311 {
2312  // Open file and check first line
2313  wxTextFile tempFile;
2314 
2315  tempFile.Open( aFileName );
2316  wxString firstline;
2317  // read the first line
2318  firstline = tempFile.GetFirstLine();
2319  tempFile.Close();
2320 
2321  return firstline.StartsWith( "EESchema" );
2322 }

◆ 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 2246 of file sch_sexpr_plugin.cpp.

2248 {
2249  if( wxFileExists( aLibraryPath ) )
2250  {
2251  THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' already exists." ),
2252  aLibraryPath.GetData() ) );
2253  }
2254 
2255  LOCALE_IO toggle;
2256 
2257  delete m_cache;
2258  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryPath );
2259  m_cache->SetModified();
2260  m_cache->Save();
2261  m_cache->Load(); // update m_writable and m_mod_time
2262 }
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 2232 of file sch_sexpr_plugin.cpp.

2234 {
2235  LOCALE_IO toggle; // toggles on, then off, the C locale.
2236 
2237  cacheLib( aLibraryPath, aProperties );
2238 
2239  m_cache->DeleteSymbol( aSymbolName );
2240 
2241  if( !isBuffering( aProperties ) )
2242  m_cache->Save();
2243 }
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 2265 of file sch_sexpr_plugin.cpp.

2267 {
2268  wxFileName fn = aLibraryPath;
2269 
2270  if( !fn.FileExists() )
2271  return false;
2272 
2273  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2274  // we don't want that. we want bare metal portability with no UI here.
2275  if( wxRemove( aLibraryPath ) )
2276  {
2277  THROW_IO_ERROR( wxString::Format( _( "Symbol library '%s' cannot be deleted." ),
2278  aLibraryPath.GetData() ) );
2279  }
2280 
2281  if( m_cache && m_cache->IsFile( aLibraryPath ) )
2282  {
2283  delete m_cache;
2284  m_cache = nullptr;
2285  }
2286 
2287  return true;
2288 }
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 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  aSymbolNameList.Add( it->first );
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.

◆ 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 2181 of file sch_sexpr_plugin.cpp.

2184 {
2185  LOCALE_IO toggle; // toggles on, then off, the C locale.
2186 
2187  bool powerSymbolsOnly = ( aProperties &&
2188  aProperties->find( SYMBOL_LIB_TABLE::PropPowerSymsOnly ) != aProperties->end() );
2189 
2190  cacheLib( aLibraryPath, aProperties );
2191 
2192  const LIB_SYMBOL_MAP& symbols = m_cache->m_symbols;
2193 
2194  for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
2195  {
2196  if( !powerSymbolsOnly || it->second->IsPower() )
2197  aSymbolList.push_back( it->second );
2198  }
2199 }
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 742 of file sch_sexpr_plugin.cpp.

743 {
744  wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET* object." );
745  wxCHECK_RET( m_schematic != nullptr, "NULL SCHEMATIC* object." );
746 
747  SCH_SCREEN* screen = aSheet->GetScreen();
748 
749  wxCHECK( screen, /* void */ );
750 
751  m_out->Print( 0, "(kicad_sch (version %d) (generator eeschema)\n\n",
753 
754  m_out->Print( 1, "(uuid %s)\n\n", TO_UTF8( screen->m_uuid.AsString() ) );
755 
756  screen->GetPageSettings().Format( m_out, 1, 0 );
757  m_out->Print( 0, "\n" );
758  screen->GetTitleBlock().Format( m_out, 1, 0 );
759 
760  // Save cache library.
761  m_out->Print( 1, "(lib_symbols\n" );
762 
763  for( auto libSymbol : screen->GetLibSymbols() )
764  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( libSymbol.second, *m_out, 2, libSymbol.first );
765 
766  m_out->Print( 1, ")\n\n" );
767 
768  for( const auto& alias : screen->GetBusAliases() )
769  {
770  saveBusAlias( alias, 1 );
771  }
772 
773  // Enforce item ordering
774  auto cmp =
775  []( const SCH_ITEM* a, const SCH_ITEM* b )
776  {
777  if( a->Type() != b->Type() )
778  return a->Type() < b->Type();
779 
780  return a->m_Uuid < b->m_Uuid;
781  };
782 
783  std::multiset<SCH_ITEM*, decltype( cmp )> save_map( cmp );
784 
785  for( SCH_ITEM* item : screen->Items() )
786  save_map.insert( item );
787 
788  KICAD_T itemType = TYPE_NOT_INIT;
790 
791  for( SCH_ITEM* item : save_map )
792  {
793  if( itemType != item->Type() )
794  {
795  itemType = item->Type();
796 
797  if( itemType != SCH_SYMBOL_T
798  && itemType != SCH_JUNCTION_T
799  && itemType != SCH_SHEET_T )
800  {
801  m_out->Print( 0, "\n" );
802  }
803  }
804 
805  switch( item->Type() )
806  {
807  case SCH_SYMBOL_T:
808  m_out->Print( 0, "\n" );
809  saveSymbol( static_cast<SCH_SYMBOL*>( item ), nullptr, 1 );
810  break;
811 
812  case SCH_BITMAP_T:
813  saveBitmap( static_cast<SCH_BITMAP*>( item ), 1 );
814  break;
815 
816  case SCH_SHEET_T:
817  m_out->Print( 0, "\n" );
818  saveSheet( static_cast<SCH_SHEET*>( item ), 1 );
819  break;
820 
821  case SCH_JUNCTION_T:
822  saveJunction( static_cast<SCH_JUNCTION*>( item ), 1 );
823  break;
824 
825  case SCH_NO_CONNECT_T:
826  saveNoConnect( static_cast<SCH_NO_CONNECT*>( item ), 1 );
827  break;
828 
830  case SCH_BUS_BUS_ENTRY_T:
831  saveBusEntry( static_cast<SCH_BUS_ENTRY_BASE*>( item ), 1 );
832  break;
833 
834  case SCH_LINE_T:
835  if( layer != item->GetLayer() )
836  {
837  if( layer == SCH_LAYER_ID_START )
838  {
839  layer = item->GetLayer();
840  }
841  else
842  {
843  layer = item->GetLayer();
844  m_out->Print( 0, "\n" );
845  }
846  }
847 
848  saveLine( static_cast<SCH_LINE*>( item ), 1 );
849  break;
850 
851  case SCH_TEXT_T:
852  case SCH_LABEL_T:
853  case SCH_GLOBAL_LABEL_T:
854  case SCH_HIER_LABEL_T:
855  saveText( static_cast<SCH_TEXT*>( item ), 1 );
856  break;
857 
858  default:
859  wxASSERT( "Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
860  }
861  }
862 
863  // If this is the root sheet, save all of the sheet paths.
864  if( aSheet->IsRootSheet() )
865  {
866  SCH_SHEET_LIST sheetPaths( aSheet, true );
867 
868  SCH_REFERENCE_LIST symbolInstances;
869 
870  for( const SCH_SHEET_PATH& sheetPath : sheetPaths )
871  sheetPath.GetSymbols( symbolInstances, true, true );
872 
873  symbolInstances.SortByReferenceOnly();
874 
875  saveInstances( sheetPaths.GetSheetInstances(), symbolInstances.GetSymbolInstances(), 1 );
876  }
877  else
878  {
879  // Schematic files (SCH_SCREEN objects) can be shared so we have to save and restore
880  // symbol and sheet instance data even if the file being saved is not the root sheet
881  // because it is possible that the file is the root sheet of another project.
882  saveInstances( screen->m_sheetInstances, screen->m_symbolInstances, 1 );
883  }
884 
885  m_out->Print( 0, ")\n" );
886 }
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:571
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:230
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:105
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:572
bool IsRootSheet() const
Definition: sch_sheet.cpp:204
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:451
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...
const KIID m_Uuid
Definition: eda_item.h:474
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:481
void SortByReferenceOnly()
Sort the list of references by reference.
KIID m_uuid
A unique identifier for each schematic file.
Definition: sch_screen.h:580
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)
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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, EDA_ITEM::m_Uuid, 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, EDA_ITEM::Type(), 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 889 of file sch_sexpr_plugin.cpp.

892 {
893  wxCHECK( aSelection && aSelectionPath && aFullSheetHierarchy && aFormatter, /* void */ );
894 
895  LOCALE_IO toggle;
896 
897  m_out = aFormatter;
898 
899  size_t i;
900  SCH_ITEM* item;
901  std::map<wxString, LIB_SYMBOL*> libSymbols;
902  SCH_SCREEN* screen = aSelection->GetScreen();
903 
904  for( i = 0; i < aSelection->GetSize(); ++i )
905  {
906  item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( i ) );
907 
908  wxCHECK2( item, continue );
909 
910  if( item->Type() != SCH_SYMBOL_T )
911  continue;
912 
913  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
914 
915  wxCHECK2( symbol, continue );
916 
917  wxString libSymbolLookup = symbol->GetLibId().Format().wx_str();
918 
919  if( !symbol->UseLibIdLookup() )
920  libSymbolLookup = symbol->GetSchSymbolLibraryName();
921 
922  auto it = screen->GetLibSymbols().find( libSymbolLookup );
923 
924  if( it != screen->GetLibSymbols().end() )
925  libSymbols[ libSymbolLookup ] = it->second;
926  }
927 
928  if( !libSymbols.empty() )
929  {
930  m_out->Print( 0, "(lib_symbols\n" );
931 
932  for( auto libSymbol : libSymbols )
933  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( libSymbol.second, *m_out, 1, libSymbol.first );
934 
935  m_out->Print( 0, ")\n\n" );
936  }
937 
938  // Store the selected sheets instance information
939  SCH_SHEET_LIST selectedSheets;
940  selectedSheets.push_back( *aSelectionPath ); // Include the "root" of the selection
941 
942  SCH_REFERENCE_LIST selectedSymbols;
943 
944  for( i = 0; i < aSelection->GetSize(); ++i )
945  {
946  item = (SCH_ITEM*) aSelection->GetItem( i );
947 
948  switch( item->Type() )
949  {
950  case SCH_SYMBOL_T:
951  saveSymbol( static_cast<SCH_SYMBOL*>( item ), aSelectionPath, 0 );
952 
953  aSelectionPath->AppendSymbol( selectedSymbols, static_cast<SCH_SYMBOL*>( item ),
954  true, true );
955  break;
956 
957  case SCH_BITMAP_T:
958  saveBitmap( static_cast< SCH_BITMAP* >( item ), 0 );
959  break;
960 
961  case SCH_SHEET_T:
962  saveSheet( static_cast< SCH_SHEET* >( item ), 0 );
963 
964  {
965  SCH_SHEET_PATH subSheetPath = *aSelectionPath;
966  subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
967 
968  aFullSheetHierarchy->GetSheetsWithinPath( selectedSheets, subSheetPath );
969  aFullSheetHierarchy->GetSymbolsWithinPath( selectedSymbols, subSheetPath, true,
970  true );
971  }
972 
973  break;
974 
975  case SCH_JUNCTION_T:
976  saveJunction( static_cast< SCH_JUNCTION* >( item ), 0 );
977  break;
978 
979  case SCH_NO_CONNECT_T:
980  saveNoConnect( static_cast< SCH_NO_CONNECT* >( item ), 0 );
981  break;
982 
984  case SCH_BUS_BUS_ENTRY_T:
985  saveBusEntry( static_cast< SCH_BUS_ENTRY_BASE* >( item ), 0 );
986  break;
987 
988  case SCH_LINE_T:
989  saveLine( static_cast< SCH_LINE* >( item ), 0 );
990  break;
991 
992  case SCH_TEXT_T:
993  case SCH_LABEL_T:
994  case SCH_GLOBAL_LABEL_T:
995  case SCH_HIER_LABEL_T:
996  saveText( static_cast< SCH_TEXT* >( item ), 0 );
997  break;
998 
999  default:
1000  wxASSERT( "Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
1001  }
1002  }
1003 
1004  // Make all instance information relative to the selection path
1005  KIID_PATH selectionPath = aSelectionPath->PathWithoutRootUuid();
1006 
1007  selectedSheets.SortByPageNumbers();
1008  std::vector<SCH_SHEET_INSTANCE> sheetinstances = selectedSheets.GetSheetInstances();
1009 
1010  for( SCH_SHEET_INSTANCE& sheetInstance : sheetinstances )
1011  {
1012  wxASSERT_MSG( sheetInstance.m_Path.MakeRelativeTo( selectionPath ),
1013  "Sheet is not inside the selection path?" );
1014  }
1015 
1016 
1017  selectedSymbols.SortByReferenceOnly();
1018  std::vector<SYMBOL_INSTANCE_REFERENCE> symbolInstances = selectedSymbols.GetSymbolInstances();
1019 
1020  for( SYMBOL_INSTANCE_REFERENCE& symbolInstance : symbolInstances )
1021  {
1022  wxASSERT_MSG( symbolInstance.m_Path.MakeRelativeTo( selectionPath ),
1023  "Symbol is not inside the selection path?" );
1024  }
1025 
1026  saveInstances( sheetinstances, symbolInstances, 0 );
1027 }
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:250
A simple container for schematic symbol instance information.
std::vector< SCH_SHEET_INSTANCE > GetSheetInstances() const
Fetch the instance information for all of the sheets in the hiearchy.
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:451
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:112
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 2346 of file sch_sexpr_plugin.cpp.

2347 {
2348 
2349  LOCALE_IO toggle; // toggles on, then off, the C locale.
2350  SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( symbol, formatter );
2351 }
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 2150 of file sch_sexpr_plugin.cpp.

2151 {
2152  if( m_cache )
2153  return m_cache->GetModifyHash();
2154 
2155  // If the cache hasn't been loaded, it hasn't been modified.
2156  return 0;
2157 }
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 511 of file sch_sexpr_plugin.cpp.

512 {
513  m_version = 0;
514  m_rootSheet = nullptr;
515  m_schematic = aSchematic;
516  m_cache = nullptr;
517  m_out = nullptr;
518  m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
519 }
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 2144 of file sch_sexpr_plugin.cpp.

2145 {
2146  return ( aProperties && aProperties->Exists( SCH_SEXPR_PLUGIN::PropBuffering ) );
2147 }
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 2325 of file sch_sexpr_plugin.cpp.

2326 {
2327  wxFileName fn( aLibraryPath );
2328 
2329  return ( fn.FileExists() && fn.IsFileWritable() ) || fn.IsDirWritable();
2330 }

◆ 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 522 of file sch_sexpr_plugin.cpp.

524 {
525  wxASSERT( !aFileName || aSchematic != nullptr );
526 
527  LOCALE_IO toggle; // toggles on, then off, the C locale.
528  SCH_SHEET* sheet;
529 
530  wxFileName fn = aFileName;
531 
532  // Unfortunately child sheet file names the legacy schematic file format are not fully
533  // qualified and are always appended to the project path. The aFileName attribute must
534  // always be an absolute path so the project path can be used for load child sheet files.
535  wxASSERT( fn.IsAbsolute() );
536 
537  if( aAppendToMe )
538  {
539  wxLogTrace( traceSchLegacyPlugin, "Append \"%s\" to sheet \"%s\".",
540  aFileName, aAppendToMe->GetFileName() );
541 
542  wxFileName normedFn = aAppendToMe->GetFileName();
543 
544  if( !normedFn.IsAbsolute() )
545  {
546  if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
547  m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
548  }
549 
550  if( m_path.IsEmpty() )
551  m_path = aSchematic->Prj().GetProjectPath();
552 
553  wxLogTrace( traceSchLegacyPlugin, "Normalized append path \"%s\".", m_path );
554  }
555  else
556  {
557  m_path = aSchematic->Prj().GetProjectPath();
558  }
559 
560  m_currentPath.push( m_path );
561  init( aSchematic, aProperties );
562 
563  if( aAppendToMe == nullptr )
564  {
565  // Clean up any allocated memory if an exception occurs loading the schematic.
566  std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( aSchematic );
567 
568  wxFileName relPath( aFileName );
569  // Do not use wxPATH_UNIX as option in MakeRelativeTo(). It can create incorrect
570  // relative paths on Windows, because paths have a disk identifier (C:, D: ...)
571  relPath.MakeRelativeTo( aSchematic->Prj().GetProjectPath() );
572 
573  newSheet->SetFileName( relPath.GetFullPath() );
574  m_rootSheet = newSheet.get();
575  loadHierarchy( newSheet.get() );
576 
577  // If we got here, the schematic loaded successfully.
578  sheet = newSheet.release();
579  m_rootSheet = nullptr; // Quiet Coverity warning.
580  }
581  else
582  {
583  wxCHECK_MSG( aSchematic->IsValid(), nullptr, "Can't append to a schematic with no root!" );
584  m_rootSheet = &aSchematic->Root();
585  sheet = aAppendToMe;
586  loadHierarchy( sheet );
587  }
588 
589  wxASSERT( m_currentPath.size() == 1 ); // only the project path should remain
590 
591  m_currentPath.pop(); // Clear the path stack for next call to Load
592 
593  return sheet;
594 }
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:317
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 705 of file sch_sexpr_plugin.cpp.

706 {
707  wxCHECK( aSheet, /* void */ );
708 
709  LOCALE_IO toggle;
710  SCH_SEXPR_PARSER parser( &aReader );
711 
712  parser.ParseSchematic( aSheet, true, aFileVersion );
713 }
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 680 of file sch_sexpr_plugin.cpp.

681 {
682  FILE_LINE_READER reader( aFileName );
683 
684  size_t lineCount = 0;
685 
686  if( m_progressReporter )
687  {
688  m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
689 
691  THROW_IO_ERROR( ( "Open cancelled by user." ) );
692 
693  while( reader.ReadLine() )
694  lineCount++;
695 
696  reader.Rewind();
697  }
698 
699  SCH_SEXPR_PARSER parser( &reader, m_progressReporter, lineCount );
700 
701  parser.ParseSchematic( aSheet );
702 }
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 599 of file sch_sexpr_plugin.cpp.

600 {
601  SCH_SCREEN* screen = nullptr;
602 
603  if( !aSheet->GetScreen() )
604  {
605  // SCH_SCREEN objects store the full path and file name where the SCH_SHEET object only
606  // stores the file name and extension. Add the project path to the file name and
607  // extension to compare when calling SCH_SHEET::SearchHierarchy().
608  wxFileName fileName = aSheet->GetFileName();
609 
610  if( !fileName.IsAbsolute() )
611  fileName.MakeAbsolute( m_currentPath.top() );
612 
613  // Save the current path so that it gets restored when descending and ascending the
614  // sheet hierarchy which allows for sheet schematic files to be nested in folders
615  // relative to the last path a schematic was loaded from.
616  wxLogTrace( traceSchLegacyPlugin, "Saving path '%s'", m_currentPath.top() );
617  m_currentPath.push( fileName.GetPath() );
618  wxLogTrace( traceSchLegacyPlugin, "Current path '%s'", m_currentPath.top() );
619  wxLogTrace( traceSchLegacyPlugin, "Loading '%s'", fileName.GetFullPath() );
620 
621  m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
622 
623  if( screen )
624  {
625  aSheet->SetScreen( screen );
626  aSheet->GetScreen()->SetParent( m_schematic );
627  // Do not need to load the sub-sheets - this has already been done.
628  }
629  else
630  {
631  aSheet->SetScreen( new SCH_SCREEN( m_schematic ) );
632  aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
633 
634  try
635  {
636  loadFile( fileName.GetFullPath(), aSheet );
637  }
638  catch( const IO_ERROR& ioe )
639  {
640  // If there is a problem loading the root sheet, there is no recovery.
641  if( aSheet == m_rootSheet )
642  throw;
643 
644  // For all subsheets, queue up the error message for the caller.
645  if( !m_error.IsEmpty() )
646  m_error += "\n";
647 
648  m_error += ioe.What();
649  }
650 
651  if( fileName.FileExists() )
652  {
653  aSheet->GetScreen()->SetFileReadOnly( !fileName.IsFileWritable() );
654  aSheet->GetScreen()->SetFileExists( true );
655  }
656  else
657  {
658  aSheet->GetScreen()->SetFileReadOnly( !fileName.IsDirWritable() );
659  aSheet->GetScreen()->SetFileExists( false );
660  }
661 
662  // This was moved out of the try{} block so that any sheets definitionsthat
663  // the plugin fully parsed before the exception was raised will be loaded.
664  for( SCH_ITEM* aItem : aSheet->GetScreen()->Items().OfType( SCH_SHEET_T ) )
665  {
666  wxCHECK2( aItem->Type() == SCH_SHEET_T, /* do nothing */ );
667  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
668 
669  // Recursion starts here.
670  loadHierarchy( sheet );
671  }
672  }
673 
674  m_currentPath.pop();
675  wxLogTrace( traceSchLegacyPlugin, "Restoring path \"%s\"", m_currentPath.top() );
676  }
677 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
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:666
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:172
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:105
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
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:317
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 2202 of file sch_sexpr_plugin.cpp.

2204 {
2205  LOCALE_IO toggle; // toggles on, then off, the C locale.
2206 
2207  cacheLib( aLibraryPath, aProperties );
2208 
2209  LIB_SYMBOL_MAP::const_iterator it = m_cache->m_symbols.find( aSymbolName );
2210 
2211  if( it == m_cache->m_symbols.end() )
2212  return nullptr;
2213 
2214  return it->second;
2215 }
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 2333 of file sch_sexpr_plugin.cpp.

2334 {
2335  LOCALE_IO toggle; // toggles on, then off, the C locale.
2336  LIB_SYMBOL_MAP map;
2337  SCH_SEXPR_PARSER parser( &aReader );
2338 
2339  parser.NeedLEFT();
2340  parser.NextTok();
2341 
2342  return parser.ParseSymbol( map, aFileVersion );
2343 }
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 716 of file sch_sexpr_plugin.cpp.

718 {
719  wxCHECK_RET( aSheet != nullptr, "NULL SCH_SHEET object." );
720  wxCHECK_RET( !aFileName.IsEmpty(), "No schematic file name defined." );
721 
722  LOCALE_IO toggle; // toggles on, then off, the C locale, to write floating point values.
723 
724  init( aSchematic, aProperties );
725 
726  wxFileName fn = aFileName;
727 
728  // File names should be absolute. Don't assume everything relative to the project path
729  // works properly.
730  wxASSERT( fn.IsAbsolute() );
731 
732  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
733 
734  m_out = &formatter; // no ownership
735 
736  Format( aSheet );
737 
738  aSheet->GetScreen()->SetFileExists( true );
739 }
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:105
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 1196 of file sch_sexpr_plugin.cpp.

1197 {
1198  wxCHECK_RET( aBitmap != nullptr && m_out != nullptr, "" );
1199 
1200  const wxImage* image = aBitmap->GetImage()->GetImageData();
1201 
1202  wxCHECK_RET( image != nullptr, "wxImage* is NULL" );
1203 
1204  m_out->Print( aNestLevel, "(image (at %s %s)",
1205  FormatInternalUnits( aBitmap->GetPosition().x ).c_str(),
1206  FormatInternalUnits( aBitmap->GetPosition().y ).c_str() );
1207 
1208  if( aBitmap->GetImage()->GetScale() != 1.0 )
1209  m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
1210 
1211  m_out->Print( 0, "\n" );
1212 
1213  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBitmap->m_Uuid.AsString() ) );
1214 
1215  m_out->Print( aNestLevel + 1, "(data" );
1216 
1217  wxMemoryOutputStream stream;
1218 
1219  image->SaveFile( stream, wxBITMAP_TYPE_PNG );
1220 
1221  // Write binary data in hexadecimal form (ASCII)
1222  wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
1223  wxString out = wxBase64Encode( buffer->GetBufferStart(), buffer->GetBufferSize() );
1224 
1225  // Apparently the MIME standard character width for base64 encoding is 76 (unconfirmed)
1226  // so use it in a vein attempt to be standard like.
1227 #define MIME_BASE64_LENGTH 76
1228 
1229  size_t first = 0;
1230 
1231  while( first < out.Length() )
1232  {
1233  m_out->Print( 0, "\n" );
1234  m_out->Print( aNestLevel + 2, "%s", TO_UTF8( out( first, MIME_BASE64_LENGTH ) ) );
1235  first += MIME_BASE64_LENGTH;
1236  }
1237 
1238  m_out->Print( 0, "\n" );
1239  m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
1240  m_out->Print( aNestLevel, ")\n" ); // Closes image token.
1241 }
double GetScale() const
Definition: bitmap_base.h:79
wxImage * GetImageData()
Definition: bitmap_base.h:70
wxString AsString() const
Definition: kiid.cpp:230
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:474
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 1451 of file sch_sexpr_plugin.cpp.

1452 {
1453  wxCHECK_RET( aAlias != nullptr, "BUS_ALIAS* is NULL" );
1454 
1455  wxString members;
1456 
1457  for( auto member : aAlias->Members() )
1458  {
1459  if( members.IsEmpty() )
1460  members = m_out->Quotew( member );
1461  else
1462  members += " " + m_out->Quotew( member );
1463  }
1464 
1465  m_out->Print( aNestLevel, "(bus_alias %s (members %s))\n",
1466  m_out->Quotew( aAlias->GetName() ).c_str(),
1467  TO_UTF8( members ) );
1468 }
#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 1332 of file sch_sexpr_plugin.cpp.

1333 {
1334  wxCHECK_RET( aBusEntry != nullptr && m_out != nullptr, "" );
1335 
1336  // Bus to bus entries are converted to bus line segments.
1337  if( aBusEntry->GetClass() == "SCH_BUS_BUS_ENTRY" )
1338  {
1339  SCH_LINE busEntryLine( aBusEntry->GetPosition(), LAYER_BUS );
1340 
1341  busEntryLine.SetEndPoint( aBusEntry->GetEnd() );
1342  saveLine( &busEntryLine, aNestLevel );
1343  }
1344  else
1345  {
1346  m_out->Print( aNestLevel, "(bus_entry (at %s %s) (size %s %s)\n",
1347  FormatInternalUnits( aBusEntry->GetPosition().x ).c_str(),
1348  FormatInternalUnits( aBusEntry->GetPosition().y ).c_str(),
1349  FormatInternalUnits( aBusEntry->GetSize().GetWidth() ).c_str(),
1350  FormatInternalUnits( aBusEntry->GetSize().GetHeight() ).c_str() );
1351 
1352  formatStroke( m_out, aNestLevel + 1, aBusEntry->GetStroke() );
1353 
1354  m_out->Print( 0, "\n" );
1355 
1356  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBusEntry->m_Uuid.AsString() ) );
1357 
1358  m_out->Print( aNestLevel, ")\n" );
1359  }
1360 }
void saveLine(SCH_LINE *aLine, int aNestLevel)
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:81
wxString AsString() const
Definition: kiid.cpp:230
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:474
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
wxSize GetSize() const
Definition: sch_bus_entry.h:75
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:193
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 1145 of file sch_sexpr_plugin.cpp.

1146 {
1147  wxCHECK_RET( aField != nullptr && m_out != nullptr, "" );
1148 
1149  wxString fieldName = aField->GetName();
1150 
1151  // For some reason (bug in legacy parser?) the field ID for non-mandatory fields is -1 so
1152  // check for this in order to correctly use the field name.
1153  if( aField->GetParent()->Type() == SCH_SYMBOL_T )
1154  {
1155  if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
1156  fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), false );
1157  }
1158  else if( aField->GetParent()->Type() == SCH_SHEET_T )
1159  {
1160  if( aField->GetId() >= 0 && aField->GetId() < SHEET_MANDATORY_FIELDS )
1161  fieldName = SCH_SHEET::GetDefaultFieldName( aField->GetId(), false );
1162  }
1163 
1164  if( aField->GetId() == -1 /* undefined ID */ )
1165  {
1166  aField->SetId( m_nextFreeFieldId );
1167  m_nextFreeFieldId += 1;
1168  }
1169  else if( aField->GetId() >= m_nextFreeFieldId )
1170  {
1171  m_nextFreeFieldId = aField->GetId() + 1;
1172  }
1173 
1174  m_out->Print( aNestLevel, "(property %s %s (id %d) (at %s %s %s)",
1175  m_out->Quotew( fieldName ).c_str(),
1176  m_out->Quotew( aField->GetText() ).c_str(),
1177  aField->GetId(),
1178  FormatInternalUnits( aField->GetPosition().x ).c_str(),
1179  FormatInternalUnits( aField->GetPosition().y ).c_str(),
1180  FormatAngle( aField->GetTextAngleDegrees() * 10.0 ).c_str() );
1181 
1182  if( !aField->IsDefaultFormatting()
1183  || ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
1184  {
1185  m_out->Print( 0, "\n" );
1186  aField->Format( m_out, aNestLevel, 0 );
1187  m_out->Print( aNestLevel, ")\n" ); // Closes property token with font effects.
1188  }
1189  else
1190  {
1191  m_out->Print( 0, ")\n" ); // Closes property token without font effects.
1192  }
1193 }
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:101
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:842
int GetId() const
Definition: sch_field.h:113
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:50
int GetTextHeight() const
Definition: eda_text.h:265
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:114
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:536
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:522
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:197
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
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:154
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:112
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 1471 of file sch_sexpr_plugin.cpp.

1474 {
1475  if( aSheets.size() )
1476  {
1477  m_out->Print( 0, "\n" );
1478  m_out->Print( aNestLevel, "(sheet_instances\n" );
1479 
1480  for( const SCH_SHEET_INSTANCE& instance : aSheets )
1481  {
1482  wxString path = instance.m_Path.AsString();
1483 
1484  if( path.IsEmpty() )
1485  path = wxT( "/" ); // Root path
1486 
1487  m_out->Print( aNestLevel + 1, "(path %s (page %s))\n",
1488  m_out->Quotew( path ).c_str(),
1489  m_out->Quotew( instance.m_PageNumber ).c_str() );
1490  }
1491 
1492  m_out->Print( aNestLevel, ")\n" ); // Close sheet instances token.
1493  }
1494 
1495  if( aSymbols.size() )
1496  {
1497  m_out->Print( 0, "\n" );
1498  m_out->Print( aNestLevel, "(symbol_instances\n" );
1499 
1500  for( const SYMBOL_INSTANCE_REFERENCE& instance : aSymbols )
1501  {
1502  m_out->Print( aNestLevel + 1, "(path %s\n",
1503  m_out->Quotew( instance.m_Path.AsString() ).c_str() );
1504  m_out->Print( aNestLevel + 2, "(reference %s) (unit %d) (value %s) (footprint %s)\n",
1505  m_out->Quotew( instance.m_Reference ).c_str(),
1506  instance.m_Unit,
1507  m_out->Quotew( instance.m_Value ).c_str(),
1508  m_out->Quotew( instance.m_Footprint ).c_str() );
1509  m_out->Print( aNestLevel + 1, ")\n" );
1510  }
1511 
1512  m_out->Print( aNestLevel, ")\n" ); // Close symbol instances token.
1513  }
1514 }
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 1302 of file sch_sexpr_plugin.cpp.

1303 {
1304  wxCHECK_RET( aJunction != nullptr && m_out != nullptr, "" );
1305 
1306  m_out->Print( aNestLevel, "(junction (at %s %s) (diameter %s) (color %d %d %d %s)\n",
1307  FormatInternalUnits( aJunction->GetPosition().x ).c_str(),
1308  FormatInternalUnits( aJunction->GetPosition().y ).c_str(),
1309  FormatInternalUnits( aJunction->GetDiameter() ).c_str(),
1310  KiROUND( aJunction->GetColor().r * 255.0 ),
1311  KiROUND( aJunction->GetColor().g * 255.0 ),
1312  KiROUND( aJunction->GetColor().b * 255.0 ),
1313  Double2Str( aJunction->GetColor().a ).c_str() );
1314 
1315  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aJunction->m_Uuid.AsString() ) );
1316 
1317  m_out->Print( aNestLevel, ")\n" );
1318 }
wxString AsString() const
Definition: kiid.cpp:230
int GetDiameter() const
Definition: sch_junction.h:110
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
COLOR4D GetColor() const
Definition: sch_junction.h:115
double a
Alpha component.
Definition: color4d.h:387
wxPoint GetPosition() const override
Definition: sch_junction.h:103
const KIID m_Uuid
Definition: eda_item.h:474
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:384
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, KIID::AsString(), KIGFX::COLOR4D::b, Double2Str(), FormatInternalUnits(), KIGFX::COLOR4D::g, SCH_JUNCTION::GetColor(), SCH_JUNCTION::GetDiameter(), SCH_JUNCTION::GetPosition(), KiROUND(), m_out, EDA_ITEM::m_Uuid, OUTPUTFORMATTER::Print(), KIGFX::COLOR4D::r, and TO_UTF8.

Referenced by Format().

◆ SaveLibrary()

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

Reimplemented from SCH_PLUGIN.

Definition at line 2291 of file sch_sexpr_plugin.cpp.

2292 {
2293  if( !m_cache )
2294  m_cache = new SCH_SEXPR_PLUGIN_CACHE( aLibraryPath );
2295 
2296  wxString oldFileName = m_cache->GetFileName();
2297 
2298  if( !m_cache->IsFile( aLibraryPath ) )
2299  {
2300  m_cache->SetFileName( aLibraryPath );
2301  }
2302 
2303  // This is a forced save.
2304  m_cache->SetModified();
2305  m_cache->Save();
2306  m_cache->SetFileName( oldFileName );
2307 }
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 1363 of file sch_sexpr_plugin.cpp.

1364 {
1365  wxCHECK_RET( aLine != nullptr && m_out != nullptr, "" );
1366 
1367  wxString lineType;
1368 
1369  STROKE_PARAMS line_stroke = aLine->GetStroke();
1370 
1371  switch( aLine->GetLayer() )
1372  {
1373  case LAYER_BUS: lineType = "bus"; break;
1374  case LAYER_WIRE: lineType = "wire"; break;
1375  case LAYER_NOTES:
1376  default: lineType = "polyline"; break;
1377  }
1378 
1379  m_out->Print( aNestLevel, "(%s (pts (xy %s %s) (xy %s %s))\n",
1380  TO_UTF8( lineType ),
1381  FormatInternalUnits( aLine->GetStartPoint().x ).c_str(),
1382  FormatInternalUnits( aLine->GetStartPoint().y ).c_str(),
1383  FormatInternalUnits( aLine->GetEndPoint().x ).c_str(),
1384  FormatInternalUnits( aLine->GetEndPoint().y ).c_str() );
1385 
1386  formatStroke( m_out, aNestLevel + 1, line_stroke );
1387  m_out->Print( 0, "\n" );
1388 
1389  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aLine->m_Uuid.AsString() ) );
1390 
1391  m_out->Print( aNestLevel, ")\n" );
1392 }
wxPoint GetStartPoint() const
Definition: sch_line.h:90
wxString AsString() const
Definition: kiid.cpp:230
#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:474
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:259
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:136
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 1321 of file sch_sexpr_plugin.cpp.

1322 {
1323  wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
1324 
1325  m_out->Print( aNestLevel, "(no_connect (at %s %s) (uuid %s))\n",
1326  FormatInternalUnits( aNoConnect->GetPosition().x ).c_str(),
1327  FormatInternalUnits( aNoConnect->GetPosition().y ).c_str(),
1328  TO_UTF8( aNoConnect->m_Uuid.AsString() ) );
1329 }
wxPoint GetPosition() const override
wxString AsString() const
Definition: kiid.cpp:230
#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:474
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 1244 of file sch_sexpr_plugin.cpp.

1245 {
1246  wxCHECK_RET( aSheet != nullptr && m_out != nullptr, "" );
1247 
1248  m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)",
1249  FormatInternalUnits( aSheet->GetPosition().x ).c_str(),
1250  FormatInternalUnits( aSheet->GetPosition().y ).c_str(),
1251  FormatInternalUnits( aSheet->GetSize().GetWidth() ).c_str(),
1252  FormatInternalUnits( aSheet->GetSize().GetHeight() ).c_str() );
1253 
1254  if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1255  m_out->Print( 0, " (fields_autoplaced)" );
1256 
1257  m_out->Print( 0, "\n" );
1258 
1260  aSheet->GetBorderColor() );
1261 
1262  stroke.SetWidth( aSheet->GetBorderWidth() );
1263  formatStroke( m_out, aNestLevel + 1, stroke );
1264 
1265  m_out->Print( 0, "\n" );
1266 
1267  m_out->Print( aNestLevel + 1, "(fill (color %d %d %d %0.4f))\n",
1268  KiROUND( aSheet->GetBackgroundColor().r * 255.0 ),
1269  KiROUND( aSheet->GetBackgroundColor().g * 255.0 ),
1270  KiROUND( aSheet->GetBackgroundColor().b * 255.0 ),
1271  aSheet->GetBackgroundColor().a );
1272 
1273  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSheet->m_Uuid.AsString() ) );
1274 
1276 
1277  for( SCH_FIELD& field : aSheet->GetFields() )
1278  {
1279  saveField( &field, aNestLevel + 1 );
1280  }
1281 
1282  for( const SCH_SHEET_PIN* pin : aSheet->GetPins() )
1283  {
1284  m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)\n",
1285  EscapedUTF8( pin->GetText() ).c_str(),
1286  getSheetPinShapeToken( pin->GetShape() ),
1287  FormatInternalUnits( pin->GetPosition().x ).c_str(),
1288  FormatInternalUnits( pin->GetPosition().y ).c_str(),
1289  FormatAngle( getSheetPinAngle( pin->GetSide() ) * 10.0 ).c_str() );
1290 
1291  pin->Format( m_out, aNestLevel + 1, 0 );
1292 
1293  m_out->Print( aNestLevel + 2, "(uuid %s)\n", TO_UTF8( pin->m_Uuid.AsString() ) );
1294 
1295  m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
1296  }
1297 
1298  m_out->Print( aNestLevel, ")\n" ); // Closes sheet token.
1299 }
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:230
double g
Green component.
Definition: color4d.h:385
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:113
void saveField(SCH_FIELD *aField, int aNestLevel)
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:424
double b
Blue component.
Definition: color4d.h:386
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:116
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
#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:110
double a
Alpha component.
Definition: color4d.h:387
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:382
const KIID m_Uuid
Definition: eda_item.h:474
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:186
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:107
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:384
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 2218 of file sch_sexpr_plugin.cpp.

2220 {
2221  LOCALE_IO toggle; // toggles on, then off, the C locale.
2222 
2223  cacheLib( aLibraryPath, aProperties );
2224 
2225  m_cache->AddSymbol( aSymbol );
2226 
2227  if( !isBuffering( aProperties ) )
2228  m_cache->Save();
2229 }
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 1030 of file sch_sexpr_plugin.cpp.

1032 {
1033  wxCHECK_RET( aSymbol != nullptr && m_out != nullptr, "" );
1034 
1035  std::string libName;
1036  wxArrayString reference_fields;
1037 
1038  static wxString delimiters( wxT( " " ) );
1039 
1040  wxString symbol_name = aSymbol->GetLibId().Format();
1041 
1042  if( symbol_name.size() )
1043  {
1044  libName = toUTFTildaText( symbol_name );
1045  }
1046  else
1047  {
1048  libName = "_NONAME_";
1049  }
1050 
1051  double angle;
1052  int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
1053 
1054  if( orientation == SYM_ORIENT_90 )
1055  angle = 90.0;
1056  else if( orientation == SYM_ORIENT_180 )
1057  angle = 180.0;
1058  else if( orientation == SYM_ORIENT_270 )
1059  angle = 270.0;
1060  else
1061  angle = 0.0;
1062 
1063  m_out->Print( aNestLevel, "(symbol" );
1064 
1065  if( !aSymbol->UseLibIdLookup() )
1066  {
1067  m_out->Print( 0, " (lib_name %s)",
1068  m_out->Quotew( aSymbol->GetSchSymbolLibraryName() ).c_str() );
1069  }
1070 
1071  m_out->Print( 0, " (lib_id %s) (at %s %s %s)",
1072  m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(),
1073  FormatInternalUnits( aSymbol->GetPosition().x ).c_str(),
1074  FormatInternalUnits( aSymbol->GetPosition().y ).c_str(),
1075  FormatAngle( angle * 10.0 ).c_str() );
1076 
1077  bool mirrorX = aSymbol->GetOrientation() & SYM_MIRROR_X;
1078  bool mirrorY = aSymbol->GetOrientation() & SYM_MIRROR_Y;
1079 
1080  if( mirrorX || mirrorY )
1081  {
1082  m_out->Print( 0, " (mirror" );
1083 
1084  if( mirrorX )
1085  m_out->Print( 0, " x" );
1086 
1087  if( mirrorY )
1088  m_out->Print( 0, " y" );
1089 
1090  m_out->Print( 0, ")" );
1091  }
1092 
1093  int unit = -1;
1094 
1095  if( !( aSymbol->GetInstanceReferences().size() > 1 ) )
1096  unit = aSymbol->GetUnit();
1097  else if( aSheetPath != nullptr )
1098  unit = aSymbol->GetUnitSelection( aSheetPath );
1099  if ( unit >= 0 )
1100  m_out->Print( 0, " (unit %d)", unit );
1101 
1102  if( aSymbol->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN )
1103  m_out->Print( 0, " (convert %d)", aSymbol->GetConvert() );
1104 
1105  m_out->Print( 0, "\n" );
1106 
1107  m_out->Print( aNestLevel + 1, "(in_bom %s)", ( aSymbol->GetIncludeInBom() ) ? "yes" : "no" );
1108  m_out->Print( 0, " (on_board %s)", ( aSymbol->GetIncludeOnBoard() ) ? "yes" : "no" );
1109 
1110  if( aSymbol->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1111  m_out->Print( 0, " (fields_autoplaced)" );
1112 
1113  m_out->Print( 0, "\n" );
1114 
1115  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
1116 
1118 
1119  for( SCH_FIELD& field : aSymbol->GetFields() )
1120  {
1121  saveField( &field, aNestLevel + 1 );
1122  }
1123 
1124  for( const SCH_PIN* pin : aSymbol->GetPins() )
1125  {
1126  if( pin->GetAlt().IsEmpty() )
1127  {
1128  m_out->Print( aNestLevel + 1, "(pin %s (uuid %s))\n",
1129  m_out->Quotew( pin->GetNumber() ).c_str(),
1130  TO_UTF8( pin->m_Uuid.AsString() ) );
1131  }
1132  else
1133  {
1134  m_out->Print( aNestLevel + 1, "(pin %s (uuid %s) (alternate %s))\n",
1135  m_out->Quotew( pin->GetNumber() ).c_str(),
1136  TO_UTF8( pin->m_Uuid.AsString() ),
1137  m_out->Quotew( pin->GetAlt() ).c_str() );
1138  }
1139  }
1140 
1141  m_out->Print( aNestLevel, ")\n" );
1142 }
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:713
bool GetIncludeInBom() const
Definition: sch_symbol.h:662
wxString AsString() const
Definition: kiid.cpp:230
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:424
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:250
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:533
UTF8 Format() const
Definition: lib_id.cpp:116
const KIID m_Uuid
Definition: eda_item.h:474
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:868
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 1395 of file sch_sexpr_plugin.cpp.

1396 {
1397  wxCHECK_RET( aText != nullptr && m_out != nullptr, "" );
1398 
1399  double angle;
1400 
1401  switch( aText->GetLabelSpinStyle() )
1402  {
1403  case LABEL_SPIN_STYLE::RIGHT: angle = 0.0; break;
1404  case LABEL_SPIN_STYLE::UP: angle = 90.0; break;
1405  case LABEL_SPIN_STYLE::LEFT: angle = 180.0; break;
1406  case LABEL_SPIN_STYLE::BOTTOM: angle = 270.0; break;
1407  default: wxFAIL; angle = 0.0; break;
1408  }
1409 
1410  m_out->Print( aNestLevel, "(%s %s",
1411  getTextTypeToken( aText->Type() ),
1412  m_out->Quotew( aText->GetText() ).c_str() );
1413 
1414  if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) || ( aText->Type() == SCH_HIER_LABEL_T ) )
1415  m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( aText->GetShape() ) );
1416 
1417  if( aText->GetText().Length() < 50 )
1418  {
1419  m_out->Print( 0, " (at %s %s %s)",
1420  FormatInternalUnits( aText->GetPosition().x ).c_str(),
1421  FormatInternalUnits( aText->GetPosition().y ).c_str(),
1422  FormatAngle( angle * 10.0 ).c_str() );
1423  }
1424  else
1425  {
1426  m_out->Print( 0, "\n" );
1427  m_out->Print( aNestLevel + 1, "(at %s %s %s)",
1428  FormatInternalUnits( aText->GetPosition().x ).c_str(),
1429  FormatInternalUnits( aText->GetPosition().y ).c_str(),
1430  FormatAngle( aText->GetTextAngle() ).c_str() );
1431  }
1432 
1433  if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
1434  m_out->Print( 0, " (fields_autoplaced)" );
1435 
1436  m_out->Print( 0, "\n" );
1437  aText->Format( m_out, aNestLevel, 0 );
1438 
1439  m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
1440 
1441  if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) )
1442  {
1443  SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aText );
1444  saveField( label->GetIntersheetRefs(), aNestLevel + 1 );
1445  }
1446 
1447  m_out->Print( aNestLevel, ")\n" ); // Closes text token.
1448 }
static const char * getTextTypeToken(KICAD_T aType)
double GetTextAngle() const
Definition: eda_text.h:195
wxString AsString() const
Definition: kiid.cpp:230
void saveField(SCH_FIELD *aField, int aNestLevel)
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:424
#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:536
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:159
wxPoint GetPosition() const override
Definition: sch_text.h:241
const KIID m_Uuid
Definition: eda_item.h:474
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:415
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:154
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:112
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: