KiCad PCB EDA Suite
Go to the documentation of this file.
4 /*
5  * This program source code file is part of KiCad, a free EDA CAD application.
6  *
7  * Copyright (C) 2016 CERN
8  * Copyright (C) 2016-2017 KiCad Developers, see change_log.txt for contributors.
9  *
10  * @author Wayne Stambaugh <>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program. If not, see <>.
24  */
26 #include <sch_io_mgr.h>
27 #include <stack>
30 class KIWAY;
31 class LINE_READER;
32 class SCH_SCREEN;
33 class SCH_SHEET;
34 class SCH_BITMAP;
35 class SCH_JUNCTION;
36 class SCH_NO_CONNECT;
37 class SCH_LINE;
39 class SCH_TEXT;
41 class SCH_FIELD;
42 class PROPERTIES;
44 class LIB_PART;
45 class PART_LIB;
46 class LIB_ALIAS;
61 {
62 public:
65  virtual ~SCH_LEGACY_PLUGIN();
67  const wxString GetName() const override
68  {
69  return wxT( "Eeschema-Legacy" );
70  }
72  const wxString GetFileExtension() const override
73  {
74  return wxT( "sch" );
75  }
84  static const char* PropBuffering;
92  static const char* PropNoDocFile;
94  int GetModifyHash() const override;
96  SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway,
97  SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL ) override;
99  void Save( const wxString& aFileName, SCH_SCREEN* aScreen, KIWAY* aKiway,
100  const PROPERTIES* aProperties = NULL ) override;
102  void Format( SCH_SCREEN* aScreen );
104  size_t GetSymbolLibCount( const wxString& aLibraryPath,
105  const PROPERTIES* aProperties = NULL ) override;
106  void EnumerateSymbolLib( wxArrayString& aAliasNameList,
107  const wxString& aLibraryPath,
108  const PROPERTIES* aProperties = NULL ) override;
109  void EnumerateSymbolLib( std::vector<LIB_ALIAS*>& aAliasList,
110  const wxString& aLibraryPath,
111  const PROPERTIES* aProperties = NULL ) override;
112  LIB_ALIAS* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
113  const PROPERTIES* aProperties = NULL ) override;
114  void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol,
115  const PROPERTIES* aProperties = NULL ) override;
116  void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
117  const PROPERTIES* aProperties = NULL ) override;
118  void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
119  const PROPERTIES* aProperties = NULL ) override;
120  void CreateSymbolLib( const wxString& aLibraryPath,
121  const PROPERTIES* aProperties = NULL ) override;
122  bool DeleteSymbolLib( const wxString& aLibraryPath,
123  const PROPERTIES* aProperties = NULL ) override;
124  void SaveLibrary( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override;
126  bool CheckHeader( const wxString& aFileName ) override;
127  bool IsSymbolLibWritable( const wxString& aLibraryPath ) override;
129  const wxString& GetError() const override { return m_error; }
131 private:
132  void loadHierarchy( SCH_SHEET* aSheet );
133  void loadHeader( FILE_LINE_READER& aReader, SCH_SCREEN* aScreen );
134  void loadPageSettings( FILE_LINE_READER& aReader, SCH_SCREEN* aScreen );
135  void loadFile( const wxString& aFileName, SCH_SCREEN* aScreen );
136  SCH_SHEET* loadSheet( FILE_LINE_READER& aReader );
140  SCH_LINE* loadWire( FILE_LINE_READER& aReader );
142  SCH_TEXT* loadText( FILE_LINE_READER& aReader );
145  void saveComponent( SCH_COMPONENT* aComponent );
146  void saveField( SCH_FIELD* aField );
147  void saveBitmap( SCH_BITMAP* aBitmap );
148  void saveSheet( SCH_SHEET* aSheet );
149  void saveJunction( SCH_JUNCTION* aJunction );
150  void saveNoConnect( SCH_NO_CONNECT* aNoConnect );
151  void saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry );
152  void saveLine( SCH_LINE* aLine );
153  void saveText( SCH_TEXT* aText );
155  void cacheLib( const wxString& aLibraryFileName );
156  bool writeDocFile( const PROPERTIES* aProperties );
157  bool isBuffering( const PROPERTIES* aProperties );
159 protected:
160  int m_version;
163  wxString m_error;
165  wxString m_path;
166  std::stack<wxString> m_currentPath;
174  void init( KIWAY* aKiway, const PROPERTIES* aProperties = NULL );
175 };
177 #endif // _SCH_LEGACY_PLUGIN_H_
The output formatter for saving SCH_SCREEN objects.
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
SCH_BITMAP * loadBitmap(FILE_LINE_READER &aReader)
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
Part library alias object definition.
wxString m_error
For throwing exceptions or errors on partial schematic loads.
void saveLine(SCH_LINE *aLine)
void SaveLibrary(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
size_t GetSymbolLibCount(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded..
void Format(SCH_SCREEN *aScreen)
void saveText(SCH_TEXT *aText)
void SaveSymbol(const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=NULL) override
Write aSymbol to an existing library located at aLibraryPath.
void DeleteSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath.
void Save(const wxString &aFileName, SCH_SCREEN *aScreen, KIWAY *aKiway, const PROPERTIES *aProperties=NULL) override
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about...
void saveNoConnect(SCH_NO_CONNECT *aNoConnect)
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
void saveSheet(SCH_SHEET *aSheet)
const wxString GetName() const override
Returns a brief hard coded name for this SCH_PLUGIN.
const wxString & GetError() const override
Return an error string to the caller.
void loadPageSettings(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
A cache assistant for the part library portion of the SCH_PLUGIN API, and only for the SCH_LEGACY_PLU...
void saveField(SCH_FIELD *aField)
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
const wxString GetFileExtension() const override
Returns the file extension for the SCH_PLUGIN.
void saveJunction(SCH_JUNCTION *aJunction)
int m_version
Version of file being loaded.
void CreateSymbolLib(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Create a new empty symbol library at aLibraryPath.
void loadFile(const wxString &aFileName, SCH_SCREEN *aScreen)
wxString m_path
Root project path for loading child sheets.
SCH_SHEET * loadSheet(FILE_LINE_READER &aReader)
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
Base class that schematic file and library loading and saving plugins should derive from...
Definition: sch_io_mgr.h:188
bool isBuffering(const PROPERTIES *aProperties)
void loadHierarchy(SCH_SHEET *aSheet)
SCH_TEXT * loadText(FILE_LINE_READER &aReader)
bool DeleteSymbolLib(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Delete an existing symbol library and returns true if successful, or if library does not exist return...
Define a library symbol object.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
void init(KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
initialize PLUGIN like a constructor would.
void saveBitmap(SCH_BITMAP *aBitmap)
static const char * PropNoDocFile
const char* PropBuffering
SCH_JUNCTION * loadJunction(FILE_LINE_READER &aReader)
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
void saveComponent(SCH_COMPONENT *aComponent)
A SCH_PLUGIN derivation for loading schematic files created before the new s-expression file format...
bool CheckHeader(const wxString &aFileName) override
Return true if the first line in aFileName begins with the expected header.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
void loadHeader(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
void EnumerateSymbolLib(wxArrayString &aAliasNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Populate a list of LIB_PART alias names contained within the library aLibraryPath.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:70
static const char * PropBuffering
const char* PropBuffering
void cacheLib(const wxString &aLibraryFileName)
Class FILE_OUTPUTFORMATTER may be used for text file output.
Definition: richio.h:492
SCH_COMPONENT * loadComponent(FILE_LINE_READER &aReader)
void DeleteAlias(const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
Delete aAliasName from the library at aLibraryPath.
int GetModifyHash() const override
Return the modification hash from the library cache.
SCH_LINE * loadWire(FILE_LINE_READER &aReader)
LIB_ALIAS * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
Load a LIB_ALIAS object having aAliasName from the aLibraryPath containing a library format that this...
KIWAY * m_kiway
Required for path to legacy component libraries.
bool IsSymbolLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
Object used to load, save, search, and otherwise manipulate symbol library files. ...
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry)
bool writeDocFile(const PROPERTIES *aProperties)
SCH_SHEET * Load(const wxString &aFileName, KIWAY *aKiway, SCH_SHEET *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL) override
Load information from some input file format that this SCH_PLUGIN implementation knows about...
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.