KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_ltspice_parser.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Chetan Subhash Shinde<[email protected]>
5 * Copyright (C) 2023 CERN
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
26
27#ifndef LTSPICE_SCH_PARSER_H
28#define LTSPICE_SCH_PARSER_H
29
30#include <core/typeinfo.h>
31#include <layer_ids.h>
33#include <stroke_params.h>
34
35
36class EDA_TEXT;
37class SCH_PIN;
38class SCH_LABEL_BASE;
39class SCH_SYMBOL;
40class SCH_TEXT;
41class SCH_SHAPE;
42
65{
66public:
67 // Field for storing LTspice symbol's InstName in SCH_SHEET.
68 static constexpr const wxChar* LT_INSTNAME_FIELD = wxS( "LT_InstName" );
69
70 explicit SCH_IO_LTSPICE_PARSER( LTSPICE_SCHEMATIC* aLTSchematic ) :
71 m_lt_schematic( aLTSchematic ),
73 { }
74
76
82 int ToKicadCoords( int aCoordinate );
83 VECTOR2I ToKicadCoords( const VECTOR2I& aPos );
84 VECTOR2I ToKicadFontSize( int aLTFontSize );
85
91 int ToLtSpiceCoords( int aCoordinate );
92 VECTOR2I ToLtSpiceCoords( const VECTOR2I& aPos );
93
103 void CreateItems( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, SCH_SCREEN* aScreen,
104 const std::vector<wxString>& aUniqueAscNames, std::map<wxString, SCH_SCREEN*>& aMapOfScreens,
105 VECTOR2I aOriginOffset );
106
107
108
112 void CreateSymLine( LIB_SYMBOL* aSymbol, const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex,
113 SCH_SHAPE* aShape );
114
119 const std::vector<wxString>& aUniqueAscNames,
120 std::map<wxString, SCH_SCREEN*>& aMapOfScreens );
121
125 void CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbol, LIB_SYMBOL* aLibSymbol );
126
130 void RotateMirrorItem( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, SCH_ITEM* aItem );
131
135 VECTOR2I RotateMirror( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, const VECTOR2I& aPoint );
136
140 void AssignSymOrientation( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, SCH_SYMBOL* aSchSymbol );
141
146
150 void AddAscBusEntry( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
151
155 void AddAscIopin( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
156
160 void AddAscLine( const LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
161
165 void AddAscCircle( const LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
166
170 void AddAscArc( const LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
171
175 void AddAscRect( const LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen );
176
178 SCH_SCREEN* aScreen );
179
183 SCH_TEXT* CreateSCH_TEXT( const VECTOR2I& aOffset, const wxString& aText, int aFontSize,
184 LTSPICE_SCHEMATIC::JUSTIFICATION aJustification );
185
189 void AddAscWire( const LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SCREEN* aScreen,
190 SCH_LAYER_ID aLayer );
191
195 SCH_SYMBOL* CreatePowerSymbol( const VECTOR2I& aOffset, const wxString& aValue, int aFontSize,
196 SCH_SCREEN* aScreen,
197 std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires );
198
202 SCH_LABEL_BASE* CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset, const wxString& aValue, int aFontSize,
203 SCH_SCREEN* aScreen );
204
208 void AddSymFields( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, SCH_SYMBOL* aSymbol );
209
213 void CreateSymRect( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aRectangle );
214
218 void CreateSymPin( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_PIN* aPin );
219
223 void CreateSymArc( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aArc );
224
228 void CreateSymCircle( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHAPE* aCircle );
229
233 void CreateSymText( const LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_TEXT* aText );
234
235private:
236 int getLineWidth( const LTSPICE_SCHEMATIC::LINEWIDTH& aLineWidth );
237
239
241 const LTSPICE_SCHEMATIC::LINESTYLE& aLineStyle );
242
244
245private:
249};
250#endif // LTSPICE_SCH_PARSER_H
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
Define a library symbol object.
Definition lib_symbol.h:114
JUSTIFICATION
Defines in what ways the PIN or TEXT can be justified.
int ToLtSpiceCoords(int aCoordinate)
Method converts kicad coordinate(i.e scale) to ltspice coordinates.
void CreateKicadSymbolsAndSubsheets(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, SCH_SCREEN *aScreen, const std::vector< wxString > &aUniqueAscNames, std::map< wxString, SCH_SCREEN * > &aMapOfScreens)
Create KiCad symbol objects and subsheets from ASC data.
void setTextJustification(EDA_TEXT *aText, LTSPICE_SCHEMATIC::JUSTIFICATION aJustification)
SCH_TEXT * CreateSCH_TEXT(const VECTOR2I &aOffset, const wxString &aText, int aFontSize, LTSPICE_SCHEMATIC::JUSTIFICATION aJustification)
Create schematic text.
STROKE_PARAMS getStroke(const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth, const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
void CreateSymArc(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aArc)
Create a symbol arc from LTspice symbol data.
int getLineWidth(const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth)
void AddAscLine(const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic line from ASC data.
void CreateKicadSCH_ITEMs(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, SCH_SCREEN *aScreen)
Create schematic items from ASC data.
VECTOR2I RotateMirror(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, const VECTOR2I &aPoint)
Rotate and mirror a point according to LTspice symbol flags.
void CreateSymText(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_TEXT *aText)
Create a symbol text from LTspice symbol data.
void AddSymFields(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSymbol)
Create and configure symbol fields from LTspice symbol data.
SCH_LABEL_BASE * CreateSCH_LABEL(KICAD_T aType, const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, SCH_SCREEN *aScreen)
Create a schematic label.
void AssignSymOrientation(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSchSymbol)
Set KiCad symbol orientation based on LTspice symbol orientation.
void AddAscIopin(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic I/O pin from ASC data.
void AddAscRect(const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic rectangle from ASC data.
void AddAscArc(const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic arc from ASC data.
SCH_SYMBOL * CreatePowerSymbol(const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, SCH_SCREEN *aScreen, std::vector< LTSPICE_SCHEMATIC::WIRE > &aWires)
Create a power symbol for the schematic.
LINE_STYLE getLineStyle(const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
void CreateSymRect(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aRectangle)
Create a symbol rectangle from LTspice symbol data.
void AddAscBusEntry(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic bus tap from ASC data.
LTSPICE_SCHEMATIC * m_lt_schematic
void CreateSymCircle(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aCircle)
Create a symbol circle from LTspice symbol data.
void RotateMirrorItem(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_ITEM *aItem)
Rotate and mirror an item according to LTspice symbol flags.
static constexpr const wxChar * LT_INSTNAME_FIELD
int ToKicadCoords(int aCoordinate)
Method converts ltspice coordinate(i.e scale) to kicad coordinates.
void CreateSymPin(const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_PIN *aPin)
Create a symbol pin from LTspice symbol data.
void CreateSymLine(LIB_SYMBOL *aSymbol, const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aShape)
Create a library-symbol line from LTspice symbol data.
SCH_IO_LTSPICE_PARSER(LTSPICE_SCHEMATIC *aLTSchematic)
void AddAscCircle(const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
Create a schematic circle from ASC data.
void CreateItems(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, SCH_SCREEN *aScreen, const std::vector< wxString > &aUniqueAscNames, std::map< wxString, SCH_SCREEN * > &aMapOfScreens, VECTOR2I aOriginOffset)
Create KiCad items based on LTspice data.
SCH_SHEET * AddAscSymAsSubsheet(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SCREEN *aScreen)
VECTOR2I ToKicadFontSize(int aLTFontSize)
void CreateSymbol(LTSPICE_SCHEMATIC::LT_SYMBOL &aLtSymbol, LIB_SYMBOL *aLibSymbol)
Create a library symbol from LTspice symbol data.
void AddAscWire(const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen, SCH_LAYER_ID aLayer)
Create a schematic wire from ASC data.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
Schematic symbol object.
Definition sch_symbol.h:75
Simple container to manage line stroke parameters.
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:477
LINE_STYLE
Dashed line types.
A struct to hold .asc file definition.
A struct to hold SYMBOL definition.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708