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

#include <ltspice_schematic.h>

Classes

struct  ARC
 The ARC is represented inside a rectangle whose opposite site are given. More...
 
struct  BUSTAP
 
struct  CIRCLE
 The CIRCLE is represented in Ltpsice inside a rectangle whose two opposite points and line style are given. More...
 
struct  DATAFLAG
 
struct  FLAG
 
struct  IOPIN
 IOPIN is special contact on symbol used for IO operations. More...
 
struct  LINE
 
struct  LT_ASC
 A struct to hold .asc file definition. More...
 
struct  LT_PIN
 
struct  LT_SYMBOL
 A struct to hold SYMBOL definition. More...
 
struct  LT_WINDOW
 
struct  RECTANGLE
 A 4-sided polygon with opposite equal sides, used in representing shapes. More...
 
struct  TEXT
 
struct  WIRE
 A metallic connection, used for transfer, between two points or pin. More...
 

Public Types

enum class  LINESTYLE {
  SOLID = 0 , DASH = 1 , DOT = 2 , DASHDOT = 3 ,
  DASHDOTDOT = 4
}
 
enum class  LINEWIDTH { Normal = 5 , Wide = 10 }
 
enum class  POLARITY { INPUT , OUTPUT , BIDIR }
 Polarity enum represents polarity of pin. More...
 
enum class  SYMBOLTYPE { CELL , BLOCK }
 Type of Symbol loaded from asc and asy file. More...
 
enum class  JUSTIFICATION {
  NONE , BOTTOM , LEFT , RIGHT ,
  CENTER , TOP , VBOTTOM , VLEFT ,
  VRIGHT , VCENTER , VTOP
}
 Defines in what ways the PIN or TEXT can be justified. More...
 
enum class  ORIENTATION {
  R0 , R90 , R180 , R270 ,
  M0 , M90 , M180 , M270
}
 Defines different types or rotation and mirror operation can be applied to a LT_SYMBOL. More...
 

Public Member Functions

 LTSPICE_SCHEMATIC (const wxString &aFilename, const wxFileName &aLTspiceDataDir, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter)
 
 ~LTSPICE_SCHEMATIC ()
 
void Load (SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxFileName &aLibraryFileName, REPORTER *aReporter)
 The main function responsible for loading the .asc and .asy files.
 
void GetAscAndAsyFilePaths (const wxDir &aDir, bool aRecursive, std::map< wxString, wxString > &aMapOfAscFiles, std::map< wxString, wxString > &aMapOfAsyFiles, const wxString &aBase=wxEmptyString)
 Used to get file path for Asc and Asy files.
 
std::vector< LTSPICE_FILEGetSchematicElements (const wxString &aAscFile)
 Used to get symbols list present in asc file.
 
bool IsAsySubsheet (const wxString &aAsyFile)
 Check if the asy file content indicates that we need to load subsheet.
 
std::map< wxString, wxString > ReadAsyFiles (const std::vector< LTSPICE_FILE > &aSourceFiles, const std::map< wxString, wxString > &aAsyFileMap)
 The function returns a map.
 
std::map< wxString, wxString > ReadAsyFile (const LTSPICE_FILE &aSourceFile, const std::map< wxString, wxString > &aAsyFileMap)
 
std::vector< LT_ASCStructureBuilder ()
 Build Intermediate data structure.
 
LT_SYMBOL SymbolBuilder (const wxString &aAscFileName, LT_ASC &aAscFile)
 
LT_SYMBOL SymbolBuilder (const wxString &aAscFileName, const wxString &aAsyFileContent, LT_ASC &aAscFile)
 
const wxFileName & GetLTspiceDataDir ()
 

Static Private Member Functions

static void aggregateAttributeValue (wxArrayString &aTokens, int aIndex)
 Join value present across multiple tokens into one.
 
static int integerCheck (const wxString &aToken, int aLineNumber, const wxString &aFileName)
 Used to check if the given token in integer or not.
 
static VECTOR2I pointCheck (const wxString &aTokenX, const wxString &aTokenY, int aLineNumber, const wxString &aFileName)
 
static void tokensSizeRangeCheck (size_t aActualSize, int aExpectedMin, int aExpectedMax, int aLineNumber, const wxString &aFileName)
 Used to check size of the token generated from split function.
 
static void removeCarriageReturn (wxString &elementFromLine)
 
static LINESTYLE getLineStyle (int aValue)
 
static LINEWIDTH getLineWidth (const wxString &aValue)
 
static POLARITY getPolarity (const wxString &aValue)
 
static ORIENTATION getSymbolRotationOrMirror (const wxString &aValue)
 
static JUSTIFICATION getTextJustification (const wxString &aValue)
 
static JUSTIFICATION getPinJustification (const wxString &aValue)
 
static SYMBOLTYPE getSymbolType (const wxString &aValue)
 

Private Attributes

REPORTERm_reporter
 
SCHEMATICm_schematic
 
wxFileName m_ltspiceDataDir
 
PROGRESS_REPORTERm_progressReporter
 
std::map< wxString, std::map< wxString, wxString > > m_fileCache
 

Detailed Description

Definition at line 58 of file ltspice_schematic.h.

Member Enumeration Documentation

◆ JUSTIFICATION

Defines in what ways the PIN or TEXT can be justified.

Enumerator
NONE 
BOTTOM 
LEFT 
RIGHT 
CENTER 
TOP 
VBOTTOM 
VLEFT 
VRIGHT 
VCENTER 
VTOP 

Definition at line 101 of file ltspice_schematic.h.

◆ LINESTYLE

enum class LTSPICE_SCHEMATIC::LINESTYLE
strong
Enumerator
SOLID 
DASH 
DOT 
DASHDOT 
DASHDOTDOT 

Definition at line 61 of file ltspice_schematic.h.

◆ LINEWIDTH

enum class LTSPICE_SCHEMATIC::LINEWIDTH
strong
Enumerator
Normal 
Wide 

Definition at line 70 of file ltspice_schematic.h.

◆ ORIENTATION

enum class LTSPICE_SCHEMATIC::ORIENTATION
strong

Defines different types or rotation and mirror operation can be applied to a LT_SYMBOL.

Enumerator
R0 
R90 
R180 
R270 
M0 
M90 
M180 
M270 

Definition at line 119 of file ltspice_schematic.h.

◆ POLARITY

enum class LTSPICE_SCHEMATIC::POLARITY
strong

Polarity enum represents polarity of pin.

Enumerator
INPUT 
OUTPUT 
BIDIR 

Definition at line 79 of file ltspice_schematic.h.

◆ SYMBOLTYPE

enum class LTSPICE_SCHEMATIC::SYMBOLTYPE
strong

Type of Symbol loaded from asc and asy file.

NOTE: Currently we have only found CELL and BLOCK type of symbol components others, we are not able to reproduce till now.

Enumerator
CELL 
BLOCK 

Definition at line 92 of file ltspice_schematic.h.

Constructor & Destructor Documentation

◆ LTSPICE_SCHEMATIC()

LTSPICE_SCHEMATIC::LTSPICE_SCHEMATIC ( const wxString &  aFilename,
const wxFileName &  aLTspiceDataDir,
REPORTER aReporter,
PROGRESS_REPORTER aProgressReporter 
)
inlineexplicit

Definition at line 280 of file ltspice_schematic.h.

◆ ~LTSPICE_SCHEMATIC()

LTSPICE_SCHEMATIC::~LTSPICE_SCHEMATIC ( )
inline

Definition at line 288 of file ltspice_schematic.h.

Member Function Documentation

◆ aggregateAttributeValue()

void LTSPICE_SCHEMATIC::aggregateAttributeValue ( wxArrayString &  aTokens,
int  aIndex 
)
staticprivate

Join value present across multiple tokens into one.

Parameters
aTokensan array of tokenised data.
aIndexfrom where the tokens should be concatenated.

Definition at line 399 of file ltspice_schematic.cpp.

Referenced by StructureBuilder(), and SymbolBuilder().

◆ GetAscAndAsyFilePaths()

void LTSPICE_SCHEMATIC::GetAscAndAsyFilePaths ( const wxDir &  aDir,
bool  aRecursive,
std::map< wxString, wxString > &  aMapOfAscFiles,
std::map< wxString, wxString > &  aMapOfAsyFiles,
const wxString &  aBase = wxEmptyString 
)

Used to get file path for Asc and Asy files.

Parameters
aMapOfAscFilesmap of string containing content from asc files.
aMapOfAsyFilesmap of string containing content from asy files.

Definition at line 202 of file ltspice_schematic.cpp.

References _, GetAscAndAsyFilePaths(), m_reporter, path, and REPORTER::Report().

Referenced by GetAscAndAsyFilePaths(), and Load().

◆ getLineStyle()

LTSPICE_SCHEMATIC::LINESTYLE LTSPICE_SCHEMATIC::getLineStyle ( int  aValue)
staticprivate
Parameters
aValueinteger value between 0-3
Returns
LINESTYLE enum

Definition at line 407 of file ltspice_schematic.cpp.

References _, DASH, DASHDOT, DASHDOTDOT, DOT, SOLID, and THROW_IO_ERROR.

Referenced by StructureBuilder(), and SymbolBuilder().

◆ getLineWidth()

LTSPICE_SCHEMATIC::LINEWIDTH LTSPICE_SCHEMATIC::getLineWidth ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
LINEWIDTH enum

Definition at line 424 of file ltspice_schematic.cpp.

References _, Normal, THROW_IO_ERROR, and Wide.

Referenced by StructureBuilder(), and SymbolBuilder().

◆ GetLTspiceDataDir()

const wxFileName & LTSPICE_SCHEMATIC::GetLTspiceDataDir ( )
inline

◆ getPinJustification()

LTSPICE_SCHEMATIC::JUSTIFICATION LTSPICE_SCHEMATIC::getPinJustification ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
JUSTIFICATION enum

Definition at line 499 of file ltspice_schematic.cpp.

References _, BOTTOM, LEFT, NONE, RIGHT, THROW_IO_ERROR, TOP, VBOTTOM, VCENTER, VLEFT, VRIGHT, and VTOP.

Referenced by SymbolBuilder().

◆ getPolarity()

LTSPICE_SCHEMATIC::POLARITY LTSPICE_SCHEMATIC::getPolarity ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
POLARITY enum

Definition at line 438 of file ltspice_schematic.cpp.

References _, BIDIR, INPUT, OUTPUT, and THROW_IO_ERROR.

Referenced by StructureBuilder().

◆ GetSchematicElements()

std::vector< LTSPICE_FILE > LTSPICE_SCHEMATIC::GetSchematicElements ( const wxString &  aAscFile)

Used to get symbols list present in asc file.

Parameters
aFilePathpath where file to be read is kept.
aReadTypespecifies in which type the file is to be read eg. r specifies file is use open for reading.

Definition at line 308 of file ltspice_schematic.cpp.

Referenced by Load().

◆ getSymbolRotationOrMirror()

LTSPICE_SCHEMATIC::ORIENTATION LTSPICE_SCHEMATIC::getSymbolRotationOrMirror ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
ORIENTATION enum

Definition at line 456 of file ltspice_schematic.cpp.

References _, M0, M180, M270, M90, R0, R180, R270, R90, and THROW_IO_ERROR.

Referenced by StructureBuilder().

◆ getSymbolType()

LTSPICE_SCHEMATIC::SYMBOLTYPE LTSPICE_SCHEMATIC::getSymbolType ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
SYMBOLTYPE enum

Definition at line 521 of file ltspice_schematic.cpp.

References _, BLOCK, CELL, and THROW_IO_ERROR.

Referenced by SymbolBuilder().

◆ getTextJustification()

LTSPICE_SCHEMATIC::JUSTIFICATION LTSPICE_SCHEMATIC::getTextJustification ( const wxString &  aValue)
staticprivate
Parameters
aValuestring value
Returns
JUSTIFICATION enum

Definition at line 477 of file ltspice_schematic.cpp.

References _, BOTTOM, CENTER, LEFT, RIGHT, THROW_IO_ERROR, TOP, VBOTTOM, VCENTER, VLEFT, VRIGHT, and VTOP.

Referenced by StructureBuilder(), and SymbolBuilder().

◆ integerCheck()

int LTSPICE_SCHEMATIC::integerCheck ( const wxString &  aToken,
int  aLineNumber,
const wxString &  aFileName 
)
staticprivate

Used to check if the given token in integer or not.

Parameters
aTokentoken to be verified.
aLineNumbergives on which line number the check is called.
aFileNamegives in which file the check is been called.
Returns
the integer value.
Exceptions
IO_ERRORif the token is not an integer.

Definition at line 356 of file ltspice_schematic.cpp.

References _, and THROW_IO_ERROR.

Referenced by pointCheck(), StructureBuilder(), and SymbolBuilder().

◆ IsAsySubsheet()

bool LTSPICE_SCHEMATIC::IsAsySubsheet ( const wxString &  aAsyFile)

Check if the asy file content indicates that we need to load subsheet.

Parameters
aAsyFilecontents of .asy file.

Definition at line 337 of file ltspice_schematic.cpp.

Referenced by Load().

◆ Load()

◆ pointCheck()

VECTOR2I LTSPICE_SCHEMATIC::pointCheck ( const wxString &  aTokenX,
const wxString &  aTokenY,
int  aLineNumber,
const wxString &  aFileName 
)
staticprivate

Definition at line 372 of file ltspice_schematic.cpp.

References integerCheck().

Referenced by StructureBuilder(), and SymbolBuilder().

◆ ReadAsyFile()

std::map< wxString, wxString > LTSPICE_SCHEMATIC::ReadAsyFile ( const LTSPICE_FILE aSourceFile,
const std::map< wxString, wxString > &  aAsyFileMap 
)

Definition at line 276 of file ltspice_schematic.cpp.

References LTSPICE_FILE::ElementName, and SafeReadFile().

Referenced by Load().

◆ ReadAsyFiles()

std::map< wxString, wxString > LTSPICE_SCHEMATIC::ReadAsyFiles ( const std::vector< LTSPICE_FILE > &  aSourceFiles,
const std::map< wxString, wxString > &  aAsyFileMap 
)

The function returns a map.

This map has all the asy files in form of string. For asy files the key will be symbol name.

Parameters
aFilenamescontains all the symbols for which we we have to load the .asy files
Returns
a map of String having all .asy files

Definition at line 291 of file ltspice_schematic.cpp.

References SafeReadFile().

Referenced by Load().

◆ removeCarriageReturn()

void LTSPICE_SCHEMATIC::removeCarriageReturn ( wxString &  elementFromLine)
staticprivate

Definition at line 535 of file ltspice_schematic.cpp.

Referenced by StructureBuilder(), and SymbolBuilder().

◆ StructureBuilder()

std::vector< LTSPICE_SCHEMATIC::LT_ASC > LTSPICE_SCHEMATIC::StructureBuilder ( )

Build Intermediate data structure.

Returns
LT_ASC struct filled with all info from asc and asy files.

The Arc is enclosed in the square given by above coordinates and its start and end coordinates are given. The arc is drawn counterclockwise from the starting point to the ending point.

Definition at line 777 of file ltspice_schematic.cpp.

References aggregateAttributeValue(), LTSPICE_SCHEMATIC::ARC::ArcEnd, LTSPICE_SCHEMATIC::LT_ASC::Arcs, LTSPICE_SCHEMATIC::ARC::ArcStart, LTSPICE_SCHEMATIC::CIRCLE::BotRight, LTSPICE_SCHEMATIC::ARC::BotRight, LTSPICE_SCHEMATIC::RECTANGLE::BotRight, LTSPICE_SCHEMATIC::LT_ASC::BoundingBox, LTSPICE_SCHEMATIC::LT_ASC::Bustap, LTSPICE_SCHEMATIC::LT_ASC::Circles, LTSPICE_SCHEMATIC::LT_ASC::DataFlags, LTSPICE_SCHEMATIC::LINE::End, LTSPICE_SCHEMATIC::WIRE::End, LTSPICE_SCHEMATIC::BUSTAP::End, flag, LTSPICE_SCHEMATIC::LT_ASC::Flags, LTSPICE_SCHEMATIC::LT_WINDOW::FontSize, getLineStyle(), getLineWidth(), getPolarity(), getSymbolRotationOrMirror(), getTextJustification(), integerCheck(), LTSPICE_SCHEMATIC::LT_ASC::Iopins, LTSPICE_SCHEMATIC::LT_WINDOW::Justification, LTSPICE_SCHEMATIC::LT_ASC::Lines, LTSPICE_SCHEMATIC::LINE::LineStyle, LTSPICE_SCHEMATIC::CIRCLE::LineStyle, LTSPICE_SCHEMATIC::ARC::LineStyle, LTSPICE_SCHEMATIC::RECTANGLE::LineStyle, LTSPICE_SCHEMATIC::LINE::LineWidth, LTSPICE_SCHEMATIC::CIRCLE::LineWidth, LTSPICE_SCHEMATIC::ARC::LineWidth, LTSPICE_SCHEMATIC::RECTANGLE::LineWidth, LTSPICE_SCHEMATIC::IOPIN::Location, m_fileCache, BOX2< Vec >::Merge(), name, LTSPICE_SCHEMATIC::LT_SYMBOL::Offset, pointCheck(), LTSPICE_SCHEMATIC::IOPIN::Polarity, LTSPICE_SCHEMATIC::LT_WINDOW::Position, LTSPICE_SCHEMATIC::LT_ASC::Rectangles, removeCarriageReturn(), LTSPICE_SCHEMATIC::LT_ASC::SheetNumber, LTSPICE_SCHEMATIC::LT_ASC::SheetSize, LTSPICE_SCHEMATIC::LINE::Start, LTSPICE_SCHEMATIC::WIRE::Start, LTSPICE_SCHEMATIC::BUSTAP::Start, SymbolBuilder(), LTSPICE_SCHEMATIC::LT_SYMBOL::SymbolOrientation, LTSPICE_SCHEMATIC::LT_ASC::Symbols, text, LTSPICE_SCHEMATIC::LT_ASC::Texts, tokensSizeRangeCheck(), LTSPICE_SCHEMATIC::CIRCLE::TopLeft, LTSPICE_SCHEMATIC::ARC::TopLeft, LTSPICE_SCHEMATIC::RECTANGLE::TopLeft, LTSPICE_SCHEMATIC::LT_ASC::Version, LTSPICE_SCHEMATIC::LT_WINDOW::WindowNumber, and LTSPICE_SCHEMATIC::LT_ASC::Wires.

Referenced by Load().

◆ SymbolBuilder() [1/2]

LTSPICE_SCHEMATIC::LT_SYMBOL LTSPICE_SCHEMATIC::SymbolBuilder ( const wxString &  aAscFileName,
const wxString &  aAsyFileContent,
LT_ASC aAscFile 
)

The Circle is enclosed in the square which is represented by bottomRight and topLeft coordinates.

The Arc is enclosed in the square given by above coordinates and its start and end coordinates are given. The arc is drawn counterclockwise from the starting point to the ending point.

Definition at line 553 of file ltspice_schematic.cpp.

References aggregateAttributeValue(), LTSPICE_SCHEMATIC::ARC::ArcEnd, LTSPICE_SCHEMATIC::LT_SYMBOL::Arcs, LTSPICE_SCHEMATIC::ARC::ArcStart, LTSPICE_SCHEMATIC::CIRCLE::BotRight, LTSPICE_SCHEMATIC::ARC::BotRight, LTSPICE_SCHEMATIC::RECTANGLE::BotRight, CELL, LTSPICE_SCHEMATIC::LT_SYMBOL::Circles, LTSPICE_SCHEMATIC::LINE::End, LTSPICE_SCHEMATIC::LT_WINDOW::FontSize, getLineStyle(), getLineWidth(), getPinJustification(), getSymbolType(), getTextJustification(), integerCheck(), LTSPICE_SCHEMATIC::LT_WINDOW::Justification, LTSPICE_SCHEMATIC::LT_SYMBOL::Lines, LTSPICE_SCHEMATIC::LINE::LineStyle, LTSPICE_SCHEMATIC::CIRCLE::LineStyle, LTSPICE_SCHEMATIC::ARC::LineStyle, LTSPICE_SCHEMATIC::RECTANGLE::LineStyle, LTSPICE_SCHEMATIC::LINE::LineWidth, LTSPICE_SCHEMATIC::CIRCLE::LineWidth, LTSPICE_SCHEMATIC::ARC::LineWidth, LTSPICE_SCHEMATIC::RECTANGLE::LineWidth, name, LTSPICE_SCHEMATIC::LT_SYMBOL::Name, pin, LTSPICE_SCHEMATIC::LT_SYMBOL::Pins, pointCheck(), LTSPICE_SCHEMATIC::LT_WINDOW::Position, R0, LTSPICE_SCHEMATIC::LT_SYMBOL::Rectangles, removeCarriageReturn(), LTSPICE_SCHEMATIC::LINE::Start, LTSPICE_SCHEMATIC::LT_SYMBOL::SymAttributes, LTSPICE_SCHEMATIC::LT_SYMBOL::SymbolOrientation, LTSPICE_SCHEMATIC::LT_SYMBOL::SymbolType, tokensSizeRangeCheck(), LTSPICE_SCHEMATIC::CIRCLE::TopLeft, LTSPICE_SCHEMATIC::ARC::TopLeft, LTSPICE_SCHEMATIC::RECTANGLE::TopLeft, LTSPICE_SCHEMATIC::LT_WINDOW::WindowNumber, and LTSPICE_SCHEMATIC::LT_SYMBOL::Windows.

◆ SymbolBuilder() [2/2]

LTSPICE_SCHEMATIC::LT_SYMBOL LTSPICE_SCHEMATIC::SymbolBuilder ( const wxString &  aAscFileName,
LT_ASC aAscFile 
)

◆ tokensSizeRangeCheck()

void LTSPICE_SCHEMATIC::tokensSizeRangeCheck ( size_t  aActualSize,
int  aExpectedMin,
int  aExpectedMax,
int  aLineNumber,
const wxString &  aFileName 
)
staticprivate

Used to check size of the token generated from split function.

Parameters
aActualSizeactual size of array of token.
aExpectedMinexpected lower range(i.e size) of array of token.
aExpectedMaxexpected higher range(i.e size) of array of token.
aLineNumbergives on which line number the check is called.
aFileNamegives in which file the check is been called.
Exceptions
IO_ERRORif the actualSize is not within expected lower range..higher range.

Definition at line 380 of file ltspice_schematic.cpp.

References _, and THROW_IO_ERROR.

Referenced by StructureBuilder(), and SymbolBuilder().

Member Data Documentation

◆ m_fileCache

std::map<wxString, std::map<wxString, wxString> > LTSPICE_SCHEMATIC::m_fileCache
private

Definition at line 439 of file ltspice_schematic.h.

Referenced by Load(), StructureBuilder(), and SymbolBuilder().

◆ m_ltspiceDataDir

wxFileName LTSPICE_SCHEMATIC::m_ltspiceDataDir
private

Definition at line 436 of file ltspice_schematic.h.

Referenced by GetLTspiceDataDir(), and Load().

◆ m_progressReporter

PROGRESS_REPORTER* LTSPICE_SCHEMATIC::m_progressReporter
private

Definition at line 437 of file ltspice_schematic.h.

◆ m_reporter

REPORTER* LTSPICE_SCHEMATIC::m_reporter
private

Definition at line 434 of file ltspice_schematic.h.

Referenced by GetAscAndAsyFilePaths().

◆ m_schematic

SCHEMATIC* LTSPICE_SCHEMATIC::m_schematic
private

Definition at line 435 of file ltspice_schematic.h.

Referenced by Load().


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