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>
29 class KIWAY;
30 class LINE_READER;
31 class SCH_SCREEN;
32 class SCH_SHEET;
33 class SCH_BITMAP;
34 class SCH_JUNCTION;
35 class SCH_NO_CONNECT;
36 class SCH_LINE;
38 class SCH_TEXT;
40 class SCH_FIELD;
41 class PROPERTIES;
43 class LIB_PART;
44 class PART_LIB;
45 class LIB_ALIAS;
62 {
63 public:
66  virtual ~SCH_LEGACY_PLUGIN();
68  const wxString GetName() const override
69  {
70  return wxT( "Eeschema-Legacy" );
71  }
73  const wxString GetFileExtension() const override
74  {
75  return wxT( "sch" );
76  }
85  static const char* PropBuffering;
93  static const char* PropNoDocFile;
95  int GetModifyHash() const override;
97  SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway,
98  SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL ) override;
100  void Save( const wxString& aFileName, SCH_SCREEN* aScreen, KIWAY* aKiway,
101  const PROPERTIES* aProperties = NULL ) override;
103  void Format( SCH_SCREEN* aScreen );
105  size_t GetSymbolLibCount( const wxString& aLibraryPath,
106  const PROPERTIES* aProperties = NULL ) override;
107  void EnumerateSymbolLib( wxArrayString& aAliasNameList,
108  const wxString& aLibraryPath,
109  const PROPERTIES* aProperties = NULL ) override;
110  void EnumerateSymbolLib( std::vector<LIB_ALIAS*>& aAliasList,
111  const wxString& aLibraryPath,
112  const PROPERTIES* aProperties = NULL ) override;
113  LIB_ALIAS* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
114  const PROPERTIES* aProperties = NULL ) override;
115  void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol,
116  const PROPERTIES* aProperties = NULL ) override;
117  void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
118  const PROPERTIES* aProperties = NULL ) override;
119  void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
120  const PROPERTIES* aProperties = NULL ) override;
121  void CreateSymbolLib( const wxString& aLibraryPath,
122  const PROPERTIES* aProperties = NULL ) override;
123  bool DeleteSymbolLib( const wxString& aLibraryPath,
124  const PROPERTIES* aProperties = NULL ) override;
125  void SaveLibrary( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override;
127 private:
128  void loadHierarchy( SCH_SHEET* aSheet );
129  void loadHeader( FILE_LINE_READER& aReader, SCH_SCREEN* aScreen );
130  void loadPageSettings( FILE_LINE_READER& aReader, SCH_SCREEN* aScreen );
131  void loadFile( const wxString& aFileName, SCH_SCREEN* aScreen );
132  SCH_SHEET* loadSheet( FILE_LINE_READER& aReader );
136  SCH_LINE* loadWire( FILE_LINE_READER& aReader );
138  SCH_TEXT* loadText( FILE_LINE_READER& aReader );
141  void saveComponent( SCH_COMPONENT* aComponent );
142  void saveField( SCH_FIELD* aField );
143  void saveBitmap( SCH_BITMAP* aBitmap );
144  void saveSheet( SCH_SHEET* aSheet );
145  void saveJunction( SCH_JUNCTION* aJunction );
146  void saveNoConnect( SCH_NO_CONNECT* aNoConnect );
147  void saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry );
148  void saveLine( SCH_LINE* aLine );
149  void saveText( SCH_TEXT* aText );
151  void cacheLib( const wxString& aLibraryFileName );
152  bool writeDocFile( const PROPERTIES* aProperties );
153  bool isBuffering( const PROPERTIES* aProperties );
155 protected:
156  int m_version;
157  wxString m_error;
158  wxString m_path;
166  void init( KIWAY* aKiway, const PROPERTIES* aProperties = NULL );
167 };
169 #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'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.
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
Function SaveSymbol.
void DeleteSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
Function DeleteSymbol.
void Save(const wxString &aFileName, SCH_SCREEN *aScreen, KIWAY *aKiway, const PROPERTIES *aProperties=NULL) override
Function Save.
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
Function GetName returns a brief hard coded name for this SCH_PLUGIN.
void loadPageSettings(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
Class SCH_LEGACY_PLUGIN_CACHE is a cache assistant for the part library portion of the SCH_PLUGIN API...
void saveField(SCH_FIELD *aField)
Definition: sch_bus_entry.h:43
const wxString GetFileExtension() const override
Function GetFileExtension 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
Function CreateSymbolLib.
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
Class SCH_PLUGIN is a base class that SCHEMATIC loading and saving plugins should derive from...
Definition: sch_io_mgr.h:187
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
Function DeleteSymbolLib.
Class LIB_PART defines a library part object.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
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)
void saveComponent(SCH_COMPONENT *aComponent)
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
Class SCH_LINE is a segment description base class to describe items which have 2 end points (track...
Definition: sch_line.h:42
void loadHeader(FILE_LINE_READER &aReader, SCH_SCREEN *aScreen)
void EnumerateSymbolLib(wxArrayString &aAliasNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Function EnumerateSymbolLib.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
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
Function DeleteAlias.
int GetModifyHash() const override
Function GetModifyHash.
SCH_LINE * loadWire(FILE_LINE_READER &aReader)
LIB_ALIAS * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL) override
Function LoadSymbol.
KIWAY * m_kiway
Required for path to legacy component libraries.
Class PART_LIB is used to load, save, search, and otherwise manipulate part 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
Function Load.
const PROPERTIES * m_props
Passed via Save() or Load(), no ownership, may be NULL.