Browse Source
Eeschema: implement new symbol library file s-expression formatter.
Eeschema: implement new symbol library file s-expression formatter.
CHANGES: Symbol library file format has been converted to s-expressions. Add support code for picking apart symbols at some future junction that will allow full inheritance conversion of existing symbol libraries. For now, symbols arranged by unit and body style numbers are nested for round robin testing of symbol libraries once the parser is complete.pull/16/head
34 changed files with 2747 additions and 81 deletions
-
8common/base_units.cpp
-
11common/wildcards_and_files_ext.cpp
-
9eeschema/CMakeLists.txt
-
160eeschema/class_libentry.cpp
-
40eeschema/class_libentry.h
-
11eeschema/lib_arc.cpp
-
5eeschema/lib_arc.h
-
9eeschema/lib_bezier.cpp
-
10eeschema/lib_bezier.h
-
9eeschema/lib_circle.cpp
-
5eeschema/lib_circle.h
-
21eeschema/lib_field.cpp
-
9eeschema/lib_field.h
-
21eeschema/lib_item.cpp
-
21eeschema/lib_item.h
-
41eeschema/lib_pin.cpp
-
8eeschema/lib_pin.h
-
9eeschema/lib_polyline.cpp
-
5eeschema/lib_polyline.h
-
9eeschema/lib_rectangle.cpp
-
5eeschema/lib_rectangle.h
-
13eeschema/lib_text.cpp
-
5eeschema/lib_text.h
-
10eeschema/libedit/lib_manager.cpp
-
4eeschema/libedit/lib_manager.h
-
22eeschema/libedit/libedit.cpp
-
4eeschema/sch_base_frame.cpp
-
14eeschema/sch_io_mgr.cpp
-
4eeschema/sch_io_mgr.h
-
2025eeschema/sch_sexpr_plugin.cpp
-
171eeschema/sch_sexpr_plugin.h
-
59eeschema/symbol_lib.keywords
-
4include/wildcards_and_files_ext.h
-
67qa/eeschema/test_lib_part.cpp
2025
eeschema/sch_sexpr_plugin.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,171 @@ |
|||
#ifndef _SCH_SEXPR_PLUGIN_H_ |
|||
#define _SCH_SEXPR_PLUGIN_H_ |
|||
|
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* |
|||
* @author Wayne Stambaugh <stambaughw@gmail.com> |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#include <memory> |
|||
#include <sch_io_mgr.h> |
|||
#include <stack> |
|||
#include <general.h> |
|||
|
|||
|
|||
class KIWAY; |
|||
class LINE_READER; |
|||
class SCH_SCREEN; |
|||
class SCH_SHEET; |
|||
class SCH_BITMAP; |
|||
class SCH_JUNCTION; |
|||
class SCH_NO_CONNECT; |
|||
class SCH_LINE; |
|||
class SCH_BUS_ENTRY_BASE; |
|||
class SCH_TEXT; |
|||
class SCH_COMPONENT; |
|||
class SCH_FIELD; |
|||
class PROPERTIES; |
|||
class SELECTION; |
|||
class SCH_SEXPR_PLUGIN_CACHE; |
|||
class LIB_PART; |
|||
class PART_LIB; |
|||
class BUS_ALIAS; |
|||
|
|||
|
|||
/** |
|||
* 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. |
|||
*/ |
|||
class SCH_SEXPR_PLUGIN : public SCH_PLUGIN |
|||
{ |
|||
public: |
|||
|
|||
SCH_SEXPR_PLUGIN(); |
|||
virtual ~SCH_SEXPR_PLUGIN(); |
|||
|
|||
const wxString GetName() const override |
|||
{ |
|||
return wxT( "Eeschema-Legacy" ); |
|||
} |
|||
|
|||
const wxString GetFileExtension() const override |
|||
{ |
|||
return wxT( "sch" ); |
|||
} |
|||
|
|||
/** |
|||
* 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. |
|||
*/ |
|||
static const char* PropBuffering; |
|||
|
|||
int GetModifyHash() const override; |
|||
|
|||
SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway, |
|||
SCH_SHEET* aAppendToMe = nullptr, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
|
|||
void LoadContent( LINE_READER& aReader, SCH_SCREEN* aScreen, |
|||
int version = EESCHEMA_VERSION ); |
|||
|
|||
void Save( const wxString& aFileName, SCH_SCREEN* aScreen, KIWAY* aKiway, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
|
|||
void Format( SCH_SCREEN* aScreen ); |
|||
|
|||
void Format( SELECTION* aSelection, OUTPUTFORMATTER* aFormatter ); |
|||
|
|||
void EnumerateSymbolLib( wxArrayString& aSymbolNameList, |
|||
const wxString& aLibraryPath, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
void EnumerateSymbolLib( std::vector<LIB_PART*>& aSymbolList, |
|||
const wxString& aLibraryPath, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
void CreateSymbolLib( const wxString& aLibraryPath, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
bool DeleteSymbolLib( const wxString& aLibraryPath, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
void SaveLibrary( const wxString& aLibraryPath, |
|||
const PROPERTIES* aProperties = nullptr ) override; |
|||
|
|||
bool CheckHeader( const wxString& aFileName ) override; |
|||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override; |
|||
|
|||
const wxString& GetError() const override { return m_error; } |
|||
|
|||
static LIB_PART* ParsePart( LINE_READER& aReader, int majorVersion = 0, int minorVersion = 0 ); |
|||
static void FormatPart( LIB_PART* aPart, OUTPUTFORMATTER& aFormatter ); |
|||
|
|||
private: |
|||
void loadHierarchy( SCH_SHEET* aSheet ); |
|||
void loadHeader( LINE_READER& aReader, SCH_SCREEN* aScreen ); |
|||
void loadPageSettings( LINE_READER& aReader, SCH_SCREEN* aScreen ); |
|||
void loadFile( const wxString& aFileName, SCH_SCREEN* aScreen ); |
|||
SCH_SHEET* loadSheet( LINE_READER& aReader ); |
|||
SCH_BITMAP* loadBitmap( LINE_READER& aReader ); |
|||
SCH_JUNCTION* loadJunction( LINE_READER& aReader ); |
|||
SCH_NO_CONNECT* loadNoConnect( LINE_READER& aReader ); |
|||
SCH_LINE* loadWire( LINE_READER& aReader ); |
|||
SCH_BUS_ENTRY_BASE* loadBusEntry( LINE_READER& aReader ); |
|||
SCH_TEXT* loadText( LINE_READER& aReader ); |
|||
SCH_COMPONENT* loadComponent( LINE_READER& aReader ); |
|||
std::shared_ptr<BUS_ALIAS> loadBusAlias( LINE_READER& aReader, SCH_SCREEN* aScreen ); |
|||
|
|||
void saveComponent( SCH_COMPONENT* aComponent ); |
|||
void saveField( SCH_FIELD* aField ); |
|||
void saveBitmap( SCH_BITMAP* aBitmap ); |
|||
void saveSheet( SCH_SHEET* aSheet ); |
|||
void saveJunction( SCH_JUNCTION* aJunction ); |
|||
void saveNoConnect( SCH_NO_CONNECT* aNoConnect ); |
|||
void saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry ); |
|||
void saveLine( SCH_LINE* aLine ); |
|||
void saveText( SCH_TEXT* aText ); |
|||
void saveBusAlias( std::shared_ptr<BUS_ALIAS> aAlias ); |
|||
|
|||
void cacheLib( const wxString& aLibraryFileName ); |
|||
bool isBuffering( const PROPERTIES* aProperties ); |
|||
|
|||
protected: |
|||
int m_version; ///< Version of file being loaded. |
|||
|
|||
/** For throwing exceptions or errors on partial schematic loads. */ |
|||
wxString m_error; |
|||
|
|||
wxString m_path; ///< Root project path for loading child sheets. |
|||
std::stack<wxString> m_currentPath;///< Stack to maintain nested sheet paths |
|||
const PROPERTIES* m_props; ///< Passed via Save() or Load(), no ownership, may be nullptr. |
|||
KIWAY* m_kiway; ///< Required for path to legacy component libraries. |
|||
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded.. |
|||
OUTPUTFORMATTER* m_out; ///< The output formatter for saving SCH_SCREEN objects. |
|||
SCH_SEXPR_PLUGIN_CACHE* m_cache; |
|||
|
|||
/// initialize PLUGIN like a constructor would. |
|||
void init( KIWAY* aKiway, const PROPERTIES* aProperties = nullptr ); |
|||
}; |
|||
|
|||
#endif // _SCH_SEXPR_PLUGIN_H_ |
@ -0,0 +1,59 @@ |
|||
alternate |
|||
anchor |
|||
arc |
|||
at |
|||
atomic |
|||
bezier |
|||
bidirectional |
|||
circle |
|||
clock |
|||
clock_low |
|||
color |
|||
edge_clock_high |
|||
end |
|||
extends |
|||
fill |
|||
hint_alt_swap |
|||
hint_pin_swap |
|||
input |
|||
input_low |
|||
inverted |
|||
inverted_clock |
|||
kicad_symbol_lib |
|||
length |
|||
line |
|||
mid |
|||
name |
|||
non_logic |
|||
number |
|||
open_collector |
|||
open_emitter |
|||
output_low |
|||
unconnected |
|||
output |
|||
passive |
|||
pin |
|||
pin_del |
|||
pin_merge |
|||
pin_rename |
|||
polyline |
|||
power |
|||
power_in |
|||
power_out |
|||
property |
|||
property_del |
|||
pts |
|||
radius |
|||
rectangle |
|||
required |
|||
shape |
|||
start |
|||
stroke |
|||
symbol |
|||
text |
|||
tri_state |
|||
type |
|||
unspecified |
|||
uuid |
|||
width |
|||
xy |
Write
Preview
Loading…
Cancel
Save
Reference in new issue