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 ToInvertedKicadCoords (const VECTOR2I &aPos)
 
VECTOR2I ToKicadFontSize (int aLTFontSize)
 
int ToLtSpiceCoords (int aCoordinate)
 Method converts kicad coordinate(i.e scale) to ltspice coordinates.
 
void Parse (SCH_SHEET_PATH *aSheet, std::vector< LTSPICE_SCHEMATIC::LT_ASC > &outLT_ASCs, const std::vector< wxString > &aAsyFileNames)
 Function responsible for loading the .asc and .asy files in intermediate data structure.
 
void CreateLines (LIB_SYMBOL *aSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aShape)
 Method for plotting Lines from Asy files.
 
void CreateLines (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting Schematic Lines from Asy files.
 
void CreateKicadSYMBOLs (SCH_SHEET_PATH *aSheet, std::vector< LTSPICE_SCHEMATIC::LT_ASC > &outLT_ASCs, const std::vector< wxString > &aAsyFiles)
 Main Method for loading indermediate data to kicacd object from asy files.
 
void CreateSymbol (LTSPICE_SCHEMATIC::LT_SYMBOL &aLtSymbol, LIB_SYMBOL *aLibSymbol)
 
void RotateMirror (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSchSymbol)
 Methods for rotating and mirroring objects.
 
void RotateMirrorShape (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SHAPE *aShape)
 
void CreateWires (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting wires.
 
void CreateKicadSCH_ITEMs (SCH_SHEET_PATH *aSheet, std::vector< LTSPICE_SCHEMATIC::LT_ASC > &outLT_ASCs)
 Main method for loading intermediate data structure from Asc file to kicad.
 
void CreateBusEntry (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting Bustap from Asc files.
 
void CreatePin (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting Iopin from Asc files.
 
void CreateLine (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting Line from Asc files.
 
void CreateCircle (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting circle from Asc files.
 
void CreateArc (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting Arc from Asc files.
 
void CreateRect (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
 Method for plotting rectangle from Asc files.
 
SCH_TEXTCreateSCH_TEXT (VECTOR2I aOffset, const wxString &aText, int aFontSize, LTSPICE_SCHEMATIC::JUSTIFICATION aJustification)
 Create schematic text.
 
void CreateWire (LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet, SCH_LAYER_ID aLayer)
 Create a schematic wire.
 
SCH_SYMBOLCreatePowerSymbol (const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, SCH_SHEET_PATH *aSheet, std::vector< LTSPICE_SCHEMATIC::WIRE > &aWires)
 Create a power symbol.
 
SCH_LABEL_BASECreateSCH_LABEL (KICAD_T aType, const VECTOR2I &aOffset, const wxString &aValue, int aFontSize)
 Create a label.
 
void CreateFields (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheet)
 
void CreateRect (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aRectangle)
 Create a symbol rect.
 
void CreateRect (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
 Create a schematic rect.
 
void CreatePin (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_PIN *aPin)
 Create a pin from an asy file.
 
void CreateArc (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aArc)
 Create a symbol arc.
 
void CreateArc (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
 Create a schematic arc.
 
void CreateCircle (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aCircle)
 Create a symbol circle.
 
void CreateCircle (LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
 Create a schematic circle.
 

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)
 
void readIncludes (std::vector< LTSPICE_SCHEMATIC::LT_ASC > &outLT_ASCs)
 

Private Attributes

LTSPICE_SCHEMATICm_lt_schematic
 
VECTOR2I m_originOffset
 
std::map< wxString, wxString > m_includes
 
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 66 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 69 of file sch_io_ltspice_parser.h.

◆ ~SCH_IO_LTSPICE_PARSER()

SCH_IO_LTSPICE_PARSER::~SCH_IO_LTSPICE_PARSER ( )
inline

Definition at line 74 of file sch_io_ltspice_parser.h.

Member Function Documentation

◆ CreateArc() [1/3]

◆ CreateArc() [2/3]

◆ CreateArc() [3/3]

◆ CreateBusEntry()

void SCH_IO_LTSPICE_PARSER::CreateBusEntry ( LTSPICE_SCHEMATIC::LT_ASC aAscfile,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

Method for plotting Bustap from Asc files.

Parameters
aAscfileobject representing asc file.
aIndexindex.
aSheeta object on which the circle is represented.

Definition at line 542 of file sch_io_ltspice_parser.cpp.

References SCH_SCREEN::Append(), LTSPICE_SCHEMATIC::LT_ASC::Bustap, CreateWire(), SCH_SHEET_PATH::LastScreen(), SCH_BUS_ENTRY_BASE::SetSize(), LTSPICE_SCHEMATIC::BUSTAP::Start, ToKicadCoords(), LTSPICE_SCHEMATIC::LT_ASC::Wires, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CreateKicadSCH_ITEMs().

◆ CreateCircle() [1/3]

void SCH_IO_LTSPICE_PARSER::CreateCircle ( LTSPICE_SCHEMATIC::LT_ASC aAscfile,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

◆ CreateCircle() [2/3]

◆ CreateCircle() [3/3]

◆ CreateFields()

◆ CreateKicadSCH_ITEMs()

void SCH_IO_LTSPICE_PARSER::CreateKicadSCH_ITEMs ( SCH_SHEET_PATH aSheet,
std::vector< LTSPICE_SCHEMATIC::LT_ASC > &  outLT_ASCs 
)

Main method for loading intermediate data structure from Asc file to kicad.

Parameters
outLT_ASCs
aSheeta object on which the circle is represented.

NOTE: This current code is used for plotting sch sheet pins on the sheet, we are working on finding how to place the pin on the intersection of line and sheet.

if( aSubSchematicStructure ) { SCH_HIERLABEL* sheetPin = new SCH_SHEET_PIN( aRootSheet, VECTOR2I(), lt_asc.Flags[index].Value );

sheetPin->SetText( "PIN" ); sheetPin->SetPosition( VECTOR2I( schIUScale.MilsToIU( rescale( 50, 592, 16 ) ), schIUScale.MilsToIU( rescale( 50, 133, 16 ) ) ) ); sheetPin->SetVisible( true ); aRootSheet->AddPin( (SCH_SHEET_PIN*) sheetPin ); }

Definition at line 457 of file sch_io_ltspice_parser.cpp.

References SCH_SCREEN::Append(), CreateArc(), CreateBusEntry(), CreateCircle(), CreateLine(), CreatePin(), CreatePowerSymbol(), CreateRect(), CreateSCH_LABEL(), CreateSCH_TEXT(), CreateWire(), LTSPICE_SCHEMATIC::FLAG::FontSize, LTSPICE_SCHEMATIC::TEXT::FontSize, LTSPICE_SCHEMATIC::TEXT::Justification, SCH_SHEET_PATH::LastScreen(), LTSPICE_SCHEMATIC::FLAG::Offset, LTSPICE_SCHEMATIC::TEXT::Offset, SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, LTSPICE_SCHEMATIC::FLAG::Value, and LTSPICE_SCHEMATIC::TEXT::Value.

Referenced by Parse().

◆ CreateKicadSYMBOLs()

void SCH_IO_LTSPICE_PARSER::CreateKicadSYMBOLs ( SCH_SHEET_PATH aSheet,
std::vector< LTSPICE_SCHEMATIC::LT_ASC > &  outLT_ASCs,
const std::vector< wxString > &  aAsyFiles 
)

◆ CreateLine()

void SCH_IO_LTSPICE_PARSER::CreateLine ( LTSPICE_SCHEMATIC::LT_ASC aAscfile,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

Method for plotting Line from Asc files.

Parameters
aAscfileobject representing asc file.
aIndexindex.
aSheeta object on which the circle is represented.

Definition at line 603 of file sch_io_ltspice_parser.cpp.

References SCH_SCREEN::Append(), LTSPICE_SCHEMATIC::LINE::End, getStroke(), SCH_SHEET_PATH::LastScreen(), LTSPICE_SCHEMATIC::LT_ASC::Lines, LTSPICE_SCHEMATIC::LINE::LineStyle, LTSPICE_SCHEMATIC::LINE::LineWidth, m_originOffset, SCH_LINE::Move(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStroke(), LTSPICE_SCHEMATIC::LINE::Start, and ToKicadCoords().

Referenced by CreateKicadSCH_ITEMs().

◆ CreateLines() [1/2]

void SCH_IO_LTSPICE_PARSER::CreateLines ( LIB_SYMBOL aSymbol,
LTSPICE_SCHEMATIC::LT_SYMBOL aLTSymbol,
int  aIndex,
SCH_SHAPE aShape 
)

◆ CreateLines() [2/2]

void SCH_IO_LTSPICE_PARSER::CreateLines ( LTSPICE_SCHEMATIC::LT_SYMBOL aLTSymbol,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

◆ CreatePin() [1/2]

void SCH_IO_LTSPICE_PARSER::CreatePin ( LTSPICE_SCHEMATIC::LT_ASC aAscfile,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

◆ CreatePin() [2/2]

◆ CreatePowerSymbol()

◆ CreateRect() [1/3]

void SCH_IO_LTSPICE_PARSER::CreateRect ( LTSPICE_SCHEMATIC::LT_ASC aAscfile,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

◆ CreateRect() [2/3]

◆ CreateRect() [3/3]

◆ CreateSCH_LABEL()

SCH_LABEL_BASE * SCH_IO_LTSPICE_PARSER::CreateSCH_LABEL ( KICAD_T  aType,
const VECTOR2I aOffset,
const wxString &  aValue,
int  aFontSize 
)

◆ CreateSCH_TEXT()

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

◆ CreateSymbol()

◆ CreateWire()

◆ CreateWires()

void SCH_IO_LTSPICE_PARSER::CreateWires ( LTSPICE_SCHEMATIC::LT_SYMBOL aLTSymbol,
int  aIndex,
SCH_SHEET_PATH aSheet 
)

Method for plotting wires.

Parameters
aLTSymbolobject representing asc file.
aIndexindex.
aSheeta object on which the symbols is represented.

Definition at line 442 of file sch_io_ltspice_parser.cpp.

References SCH_SCREEN::Append(), getLineWidth(), SCH_SHEET_PATH::LastScreen(), LTSPICE_SCHEMATIC::Normal, SCH_LINE::SetEndPoint(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), SCH_LINE::SetStartPoint(), and LTSPICE_SCHEMATIC::LT_SYMBOL::Wires.

Referenced by CreateKicadSYMBOLs().

◆ getLineStyle()

LINE_STYLE SCH_IO_LTSPICE_PARSER::getLineStyle ( const LTSPICE_SCHEMATIC::LINESTYLE aLineStyle)
private

◆ 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

◆ Parse()

void SCH_IO_LTSPICE_PARSER::Parse ( SCH_SHEET_PATH aSheet,
std::vector< LTSPICE_SCHEMATIC::LT_ASC > &  outLT_ASCs,
const std::vector< wxString > &  aAsyFileNames 
)

Function responsible for loading the .asc and .asy files in intermediate data structure.

Parses the datastructure produced by the LTSPICE_SCHEMATIC into a KiCad schematic file.

Parameters
aSheetvariable representing the current sheet.
mapOfFilesa string map containing all the data from .asc and .asy files.

Definition at line 37 of file sch_io_ltspice_parser.cpp.

References CreateKicadSCH_ITEMs(), CreateKicadSYMBOLs(), BOX2< Vec >::GetCenter(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetOrigin(), SCH_SCREEN::GetPageSettings(), BOX2< Vec >::GetSize(), PAGE_INFO::GetSizeIU(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), grid, EDA_IU_SCALE::IU_PER_MILS, SCH_SHEET_PATH::LastScreen(), m_originOffset, BOX2< Vec >::Merge(), EDA_IU_SCALE::MilsToIU(), readIncludes(), schIUScale, BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), ToKicadCoords(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by LTSPICE_SCHEMATIC::Load().

◆ readIncludes()

void SCH_IO_LTSPICE_PARSER::readIncludes ( std::vector< LTSPICE_SCHEMATIC::LT_ASC > &  outLT_ASCs)
private

◆ RotateMirror()

◆ RotateMirrorShape()

◆ setTextJustification()

◆ ToInvertedKicadCoords()

VECTOR2I SCH_IO_LTSPICE_PARSER::ToInvertedKicadCoords ( const VECTOR2I aPos)

◆ ToKicadCoords() [1/2]

VECTOR2I SCH_IO_LTSPICE_PARSER::ToKicadCoords ( const VECTOR2I aPos)

Definition at line 327 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)

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

Parameters
aCoordinatecoordinate(i.e scale) in ltspice.

Definition at line 321 of file sch_io_ltspice_parser.cpp.

References EDA_IU_SCALE::MilsToIU(), rescale(), and schIUScale.

Referenced by CreateArc(), CreateBusEntry(), CreateCircle(), CreateFields(), CreateKicadSYMBOLs(), CreateLine(), CreateLines(), CreatePin(), CreatePowerSymbol(), CreateRect(), CreateSCH_LABEL(), CreateSCH_TEXT(), CreateWire(), LTSPICE_SCHEMATIC::Load(), Parse(), ToInvertedKicadCoords(), and ToKicadCoords().

◆ ToKicadFontSize()

VECTOR2I SCH_IO_LTSPICE_PARSER::ToKicadFontSize ( int  aLTFontSize)

◆ ToLtSpiceCoords()

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 358 of file sch_io_ltspice_parser.cpp.

References EDA_IU_SCALE::IUToMils(), rescale(), and schIUScale.

Referenced by CreateKicadSYMBOLs().

Member Data Documentation

◆ m_includes

std::map<wxString, wxString> SCH_IO_LTSPICE_PARSER::m_includes
private

Definition at line 293 of file sch_io_ltspice_parser.h.

Referenced by CreateFields(), and readIncludes().

◆ m_lt_schematic

LTSPICE_SCHEMATIC* SCH_IO_LTSPICE_PARSER::m_lt_schematic
private

Definition at line 291 of file sch_io_ltspice_parser.h.

Referenced by CreateFields(), CreateKicadSYMBOLs(), and readIncludes().

◆ m_originOffset

◆ m_powerSymbolIndex

int SCH_IO_LTSPICE_PARSER::m_powerSymbolIndex
private

Definition at line 294 of file sch_io_ltspice_parser.h.

Referenced by CreatePowerSymbol().


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