KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SCH_IO_LTSPICE_PARSER Class Reference

The class is been used for loading the asc and asy files in intermediate data structure. More...

#include <sch_io_ltspice_parser.h>

Public Member Functions

 SCH_IO_LTSPICE_PARSER (LTSPICE_SCHEMATIC *aLTSchematic)
 
 ~SCH_IO_LTSPICE_PARSER ()
 
int ToKicadCoords (int aCoordinate)
 Method converts ltspice coordinate(i.e scale) to kicad coordinates.
 
VECTOR2I ToKicadCoords (const VECTOR2I &aPos)
 
VECTOR2I ToKicadFontSize (int aLTFontSize)
 
int ToLtSpiceCoords (int aCoordinate)
 Method converts kicad coordinate(i.e scale) to ltspice coordinates.
 
VECTOR2I ToLtSpiceCoords (const VECTOR2I &aPos)
 
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.
 
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.
 
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 CreateSymbol (LTSPICE_SCHEMATIC::LT_SYMBOL &aLtSymbol, LIB_SYMBOL *aLibSymbol)
 Create a library symbol 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.
 
VECTOR2I RotateMirror (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, const VECTOR2I &aPoint)
 Rotate and mirror a point according to LTspice symbol flags.
 
void AssignSymOrientation (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSchSymbol)
 Set KiCad symbol orientation based on LTspice symbol orientation.
 
void CreateKicadSCH_ITEMs (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, SCH_SCREEN *aScreen)
 Create schematic items from ASC data.
 
void AddAscBusEntry (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic bus tap from ASC data.
 
void AddAscIopin (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic I/O pin from ASC data.
 
void AddAscLine (const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic line from ASC data.
 
void AddAscCircle (const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic circle from ASC data.
 
void AddAscArc (const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic arc from ASC data.
 
void AddAscRect (const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen)
 Create a schematic rectangle from ASC data.
 
SCH_SHEET * AddAscSymAsSubsheet (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SCREEN *aScreen)
 
SCH_TEXT * CreateSCH_TEXT (const VECTOR2I &aOffset, const wxString &aText, int aFontSize, LTSPICE_SCHEMATIC::JUSTIFICATION aJustification)
 Create schematic text.
 
void AddAscWire (const LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SCREEN *aScreen, SCH_LAYER_ID aLayer)
 Create a schematic wire 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.
 
SCH_LABEL_BASE * CreateSCH_LABEL (KICAD_T aType, const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, SCH_SCREEN *aScreen)
 Create a schematic label.
 
void AddSymFields (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSymbol)
 Create and configure symbol fields from LTspice symbol data.
 
void CreateSymRect (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aRectangle)
 Create a symbol rectangle from LTspice symbol data.
 
void CreateSymPin (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_PIN *aPin)
 Create a symbol pin from LTspice symbol data.
 
void CreateSymArc (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aArc)
 Create a symbol arc from LTspice symbol data.
 
void CreateSymCircle (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aCircle)
 Create a symbol circle from LTspice symbol data.
 
void CreateSymText (const LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_TEXT *aText)
 Create a symbol text from LTspice symbol data.
 

Static Public Attributes

static constexpr const wxChar * LT_INSTNAME_FIELD = wxS( "LT_InstName" )
 

Private Member Functions

int getLineWidth (const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth)
 
LINE_STYLE getLineStyle (const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
 
STROKE_PARAMS getStroke (const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth, const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
 
void setTextJustification (EDA_TEXT *aText, LTSPICE_SCHEMATIC::JUSTIFICATION aJustification)
 

Private Attributes

LTSPICE_SCHEMATIC * m_lt_schematic
 
VECTOR2I m_originOffset
 
int m_powerSymbolIndex
 

Detailed Description

The class is been used for loading the asc and asy files in intermediate data structure.

The intermediate data structure is a structure, from where the kicad objects will be initialised.

The intermediate datastructure is been defined below in the class, with comments for individual struct is in place.

parser() - This is the main function responsible for parsing the data into intermediate datastructure.

Data Processing Methods - The individual comments for function are given. In general. these methods are been used for manipulating the data.

Data Check Methods - The individual comments for functions under this section is given. In general these methods are been used for validating the data.

Enum Conversion Methods - The individual comments for functions under this section is given. In general these methods are used to convert the string into enum.

Definition at line 64 of file sch_io_ltspice_parser.h.

Constructor & Destructor Documentation

◆ SCH_IO_LTSPICE_PARSER()

SCH_IO_LTSPICE_PARSER::SCH_IO_LTSPICE_PARSER ( LTSPICE_SCHEMATIC * aLTSchematic)
inlineexplicit

Definition at line 70 of file sch_io_ltspice_parser.h.

References m_lt_schematic, and m_powerSymbolIndex.

◆ ~SCH_IO_LTSPICE_PARSER()

SCH_IO_LTSPICE_PARSER::~SCH_IO_LTSPICE_PARSER ( )
inline

Definition at line 75 of file sch_io_ltspice_parser.h.

Member Function Documentation

◆ AddAscArc()

◆ AddAscBusEntry()

void SCH_IO_LTSPICE_PARSER::AddAscBusEntry ( LTSPICE_SCHEMATIC::LT_ASC & aAscfile,
int aIndex,
SCH_SCREEN * aScreen )

◆ AddAscCircle()

◆ AddAscIopin()

◆ AddAscLine()

◆ AddAscRect()

◆ AddAscSymAsSubsheet()

SCH_SHEET * SCH_IO_LTSPICE_PARSER::AddAscSymAsSubsheet ( LTSPICE_SCHEMATIC::LT_ASC & aAscfile,
const LTSPICE_SCHEMATIC::LT_SYMBOL & aLTSymbol,
SCH_SCREEN * aScreen )

Definition at line 957 of file sch_io_ltspice_parser.cpp.

References SCH_SHEET::AddField(), SCH_SHEET::AddPin(), SCH_SCREEN::Append(), LTSPICE_SCHEMATIC::LT_SYMBOL::Arcs, LTSPICE_SCHEMATIC::LT_SYMBOL::AsyKey, LTSPICE_SCHEMATIC::ARC::BotRight, LTSPICE_SCHEMATIC::RECTANGLE::BotRight, circle(), LTSPICE_SCHEMATIC::LT_SYMBOL::Circles, SCH_SHEET_PIN::ConstrainOnEdge(), LTSPICE_SCHEMATIC::LINE::End, LTSPICE_SCHEMATIC::WIRE::End, flag, LTSPICE_SCHEMATIC::LT_ASC::Flags, get_def(), SCH_SHEET::GetField(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), SCH_TEXT::GetPosition(), BOX2< Vec >::GetSize(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), LTSPICE_SCHEMATIC::LT_ASC::Iopins, LTSPICE_SCHEMATIC::LT_SYMBOL::Lines, LTSPICE_SCHEMATIC::IOPIN::Location, LT_INSTNAME_FIELD, m_lt_schematic, m_originOffset, BOX2< Vec >::Merge(), LTSPICE_SCHEMATIC::LT_SYMBOL::Name, name, LTSPICE_SCHEMATIC::NONE, LTSPICE_SCHEMATIC::LT_SYMBOL::Offset, pin, LTSPICE_SCHEMATIC::LT_SYMBOL::Pins, LTSPICE_SCHEMATIC::LT_SYMBOL::Rectangles, ReplaceIllegalFileNameChars(), RotateMirror(), SCH_SCREEN::Schematic(), schIUScale, SCH_SHEET::SetBorderWidth(), SCH_SHEET::SetPosition(), SCH_TEXT::SetSchTextSize(), SCH_SHEET::SetSize(), SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), SHEET_FILENAME, SHEET_NAME, SHEET_USER, LTSPICE_SCHEMATIC::LINE::Start, LTSPICE_SCHEMATIC::WIRE::Start, LTSPICE_SCHEMATIC::LT_SYMBOL::SymAttributes, ToKicadCoords(), ToLtSpiceCoords(), LTSPICE_SCHEMATIC::ARC::TopLeft, LTSPICE_SCHEMATIC::RECTANGLE::TopLeft, and LTSPICE_SCHEMATIC::LT_ASC::Wires.

Referenced by CreateKicadSymbolsAndSubsheets().

◆ AddAscWire()

◆ AddSymFields()

◆ AssignSymOrientation()

◆ CreateItems()

void SCH_IO_LTSPICE_PARSER::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.

Parameters
aAscfilethe LTspice ASC file data.
aScreenthe screen to add the items to.
aUniqueAscNamesthe symbol names to import as subsheets instead of symbols.
aMapOfScreensthe map of screens to assign screens to new subsheets.
aOriginOffsetthe offset to apply to the items (in KiCad units).

Definition at line 246 of file sch_io_ltspice_parser.cpp.

References SCH_SCREEN::Append(), CreateKicadSCH_ITEMs(), CreateKicadSymbolsAndSubsheets(), PROJECT::GetProjectPath(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_BOTTOM, m_lt_schematic, m_originOffset, name, SCHEMATIC::Project(), SCHEMATIC::RootScreen(), SCH_SCREEN::Schematic(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetMultilineAllowed(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), and text.

Referenced by LTSPICE_SCHEMATIC::Load().

◆ CreateKicadSCH_ITEMs()

◆ CreateKicadSymbolsAndSubsheets()

◆ CreatePowerSymbol()

◆ CreateSCH_LABEL()

◆ CreateSCH_TEXT()

SCH_TEXT * SCH_IO_LTSPICE_PARSER::CreateSCH_TEXT ( const VECTOR2I & aOffset,
const wxString & aText,
int aFontSize,
LTSPICE_SCHEMATIC::JUSTIFICATION aJustification )

◆ CreateSymArc()

◆ CreateSymbol()

◆ CreateSymCircle()

◆ CreateSymLine()

void SCH_IO_LTSPICE_PARSER::CreateSymLine ( LIB_SYMBOL * aSymbol,
const LTSPICE_SCHEMATIC::LT_SYMBOL & aLTSymbol,
int aIndex,
SCH_SHAPE * aShape )

◆ CreateSymPin()

◆ CreateSymRect()

◆ CreateSymText()

◆ getLineStyle()

◆ getLineWidth()

int SCH_IO_LTSPICE_PARSER::getLineWidth ( const LTSPICE_SCHEMATIC::LINEWIDTH & aLineWidth)
private

◆ getStroke()

STROKE_PARAMS SCH_IO_LTSPICE_PARSER::getStroke ( const LTSPICE_SCHEMATIC::LINEWIDTH & aLineWidth,
const LTSPICE_SCHEMATIC::LINESTYLE & aLineStyle )
private

◆ RotateMirror()

◆ RotateMirrorItem()

◆ setTextJustification()

◆ ToKicadCoords() [1/2]

VECTOR2I SCH_IO_LTSPICE_PARSER::ToKicadCoords ( const VECTOR2I & aPos)

Definition at line 525 of file sch_io_ltspice_parser.cpp.

References ToKicadCoords(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ToKicadCoords() [2/2]

int SCH_IO_LTSPICE_PARSER::ToKicadCoords ( int aCoordinate)

◆ ToKicadFontSize()

VECTOR2I SCH_IO_LTSPICE_PARSER::ToKicadFontSize ( int aLTFontSize)

◆ ToLtSpiceCoords() [1/2]

VECTOR2I SCH_IO_LTSPICE_PARSER::ToLtSpiceCoords ( const VECTOR2I & aPos)

Definition at line 557 of file sch_io_ltspice_parser.cpp.

References ToLtSpiceCoords(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ToLtSpiceCoords() [2/2]

int SCH_IO_LTSPICE_PARSER::ToLtSpiceCoords ( int aCoordinate)

Method converts kicad coordinate(i.e scale) to ltspice coordinates.

Parameters
aCoordinatecoordinate(i.e scale) in ltspice.

Definition at line 551 of file sch_io_ltspice_parser.cpp.

References rescale(), and schIUScale.

Referenced by AddAscSymAsSubsheet(), and ToLtSpiceCoords().

Member Data Documentation

◆ LT_INSTNAME_FIELD

const wxChar* SCH_IO_LTSPICE_PARSER::LT_INSTNAME_FIELD = wxS( "LT_InstName" )
staticconstexpr

Definition at line 68 of file sch_io_ltspice_parser.h.

Referenced by AddAscSymAsSubsheet().

◆ m_lt_schematic

LTSPICE_SCHEMATIC* SCH_IO_LTSPICE_PARSER::m_lt_schematic
private

◆ m_originOffset

◆ m_powerSymbolIndex

int SCH_IO_LTSPICE_PARSER::m_powerSymbolIndex
private

Definition at line 248 of file sch_io_ltspice_parser.h.

Referenced by CreatePowerSymbol(), and SCH_IO_LTSPICE_PARSER().


The documentation for this class was generated from the following files: