38#include <wx/filename.h>
39#include <wx/strconv.h>
40#include <wx/tokenzr.h>
41#include <wx/txtstrm.h>
42#include <wx/wfstream.h>
44#include <fmt/format.h>
54 std::vector<wxString> tokens;
56 bool inQuotes =
false;
58 for( wxUniChar ch : aText )
63 if( !inQuotes && wxIsspace( ch ) )
65 if( !token.IsEmpty() )
67 tokens.push_back( token );
77 if( !token.IsEmpty() )
78 tokens.push_back( token );
88 wxArrayString outLines;
90 for( wxString line : wxSplit( aText,
'\n',
'\0' ) )
92 wxArrayString tok = wxSplit( line,
' ',
'\0' );
94 if( !tok.IsEmpty() && tok[0].IsSameAs( wxS(
".tran" ),
false ) )
97 wxArrayString modifiers;
99 const std::set<wxString> c_modifiers = {
"UIC",
"STEADY",
"NODISCARD",
"STARTUP",
"STEP" };
101 for(
size_t i = 1; i < tok.size(); ++i )
103 if( tok[i].IsEmpty() )
106 wxString u = tok[i].Upper();
108 if( modifiers.IsEmpty() && !c_modifiers.contains( u ) )
111 modifiers.Add( tok[i] );
114 if( !args.IsEmpty() )
122 const bool hasTstep = args.size() >= 2;
124 wxString tstepStr = hasTstep ? args[0] : wxString();
125 wxString tstopStr = hasTstep ? args[1] : args[0];
126 wxString tstartStr = ( args.size() > 2 ) ? args[2] : wxString();
127 wxString dtmaxStr = ( args.size() > 3 ) ? args[3] : wxString();
136 line = wxS(
".tran " ) + tstepStr + wxS(
" " ) + tstopStr;
138 if( !tstartStr.IsEmpty() )
139 line << wxS(
" " ) << tstartStr;
141 if( !dtmaxStr.IsEmpty() )
142 line << wxS(
" " ) << dtmaxStr;
144 for(
const wxString& mod : modifiers )
145 line << wxS(
" " ) << mod;
149 outLines.Add( line );
152 return wxJoin( outLines,
'\n',
'\0' );
161 wxFFileInputStream inputStream( aSourceFile.GetFullPath() );
163 if( !inputStream.IsOk() )
166 wxFFileOutputStream outputStream( aDestFile.GetFullPath() );
168 if( !outputStream.IsOk() )
171 wxTextInputStream textIn( inputStream, wxS(
" \t" ), wxConvUTF8 );
172 wxTextOutputStream textOut( outputStream, wxEOL_UNIX, wxConvUTF8 );
173 double prevAbsoluteTime = 0.0;
175 while( inputStream.CanRead() )
177 wxString line = textIn.ReadLine();
178 line.Trim(
true ).Trim(
false );
181 wxString commentRest;
182 if( line.StartsWith( wxS(
"*" ), &commentRest ) || line.StartsWith( wxS(
";" ), &commentRest ) )
184 textOut << wxS(
"#" ) << commentRest <<
'\n';
188 wxStringTokenizer pointTokenizer( line, wxS(
" \t" ), wxTOKEN_STRTOK );
190 if( pointTokenizer.CountTokens() < 2 )
192 textOut << line <<
'\n';
196 wxString timeToken = pointTokenizer.GetNextToken();
197 wxString valueToken = pointTokenizer.GetNextToken();
202 wxString timeRest = timeToken;
203 bool isRelative = timeToken.StartsWith( wxS(
"+" ), &timeRest );
205 if( timeRest.IsEmpty() )
207 textOut << line <<
'\n';
213 double timeValueSeconds = spiceValue.
ToDouble();
216 double absoluteTime = isRelative ? prevAbsoluteTime + timeValueSeconds : timeValueSeconds;
217 double relativeTime = absoluteTime - prevAbsoluteTime;
218 prevAbsoluteTime = absoluteTime;
221 wxString relativeTimeStr = wxS(
"0" );
223 if( relativeTime != 0.0 )
225 double absSeconds = std::fabs( relativeTime );
226 int exp10 =
static_cast<int>( std::floor( std::log10( absSeconds ) ) );
227 int engExp = exp10 - ( ( exp10 % 3 + 3 ) % 3 );
228 double mantissa = relativeTime / std::pow( 10.0, engExp );
230 relativeTimeStr = wxString::FromUTF8( fmt::format(
"{:.9g}e{}", mantissa, engExp ) );
233 textOut << relativeTimeStr <<
'\t' << valueToken <<
'\n';
236 return outputStream.IsOk();
241 std::vector<LTSPICE_SCHEMATIC::LT_ASC>& outLT_ASCs,
242 const std::vector<wxString>& aAsyFileNames )
248 bbox.
Merge( asc.BoundingBox );
256 int margin =
grid * 10;
260 if( bbox.
GetWidth() > pageSize.
x - margin )
272 wxString projectPath;
273 wxString includeText;
276 projectPath = schematic->Project().GetProjectPath();
278 if( !projectPath.IsEmpty() )
280 wxFileName cmpDir(
m_lt_schematic->GetLTspiceDataDir().GetFullPath(), wxEmptyString );
281 cmpDir.AppendDir( wxS(
"cmp" ) );
283 wxFileName outDir( projectPath, wxEmptyString );
284 outDir.AppendDir( wxS(
"ltspice_cmp" ) );
285 outDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
287 for(
const wxString
name :
288 { wxS(
"standard.dio" ), wxS(
"standard.bjt" ), wxS(
"standard.jft" ), wxS(
"standard.mos" ) } )
290 includeText << wxS(
".include ltspice_cmp/" ) <<
name << wxS(
"\n" );
292 wxFileName src = cmpDir;
293 src.SetFullName(
name );
295 if( !src.FileExists() )
298 wxFileName dst = outDir;
299 dst.SetFullName(
name );
301 if( dst.FileExists() )
304 wxFFile in( src.GetFullPath(), wxS(
"rb" ) );
309 wxFileOffset len = in.Length();
314 wxMemoryBuffer buffer(
static_cast<size_t>( len ) );
315 void* writePtr = buffer.GetWriteBuf(
static_cast<size_t>( len ) );
317 if( !writePtr || in.Read( writePtr, len ) !=
static_cast<size_t>( len ) )
320 buffer.UngetWriteBuf(
static_cast<size_t>( len ) );
322 const char* data =
static_cast<const char*
>( buffer.GetData() );
326 if( len >= 4 && ( len % 2 ) == 0 && data[1] == 0 && data[3] == 0 )
327 text = wxString( data, wxMBConvUTF16LE(), len );
329 text = wxString::FromUTF8( data, len );
332 text = wxString( data, wxCSConv( wxFONTENCODING_CP1252 ), len );
334 wxFFile out( dst.GetFullPath(), wxS(
"wb" ) );
336 if( !out.IsOpened() )
339 out.Write(
text, wxConvUTF8 );
344 includeText << wxS(
"\n" );
345 includeText << wxS(
".subckt pwl_file outp outn file=\"\" timerelative=1\n" );
346 includeText << wxS(
"Afs %vd([outp outn]) filesrc\n" );
347 includeText << wxS(
".model filesrc filesource (file={file} amploffset=[0] amplscale=[1] timeoffset=0 "
348 "timescale=1 timerelative={timerelative})\n" );
349 includeText << wxS(
".ends\n" );
351 if( !includeText.IsEmpty() )
395 std::vector<LTSPICE_SCHEMATIC::LT_ASC>& outLT_ASCs,
396 const std::vector<wxString>& aAsyFiles )
400 std::vector<LTSPICE_SCHEMATIC::LT_SYMBOL> symbols = lt_asc.Symbols;
401 std::map<wxString, LIB_SYMBOL*> existingSymbol;
402 std::map<wxString, SCH_SYMBOL*> existingSchematicSymbol;
410 if( existingSymbol.count( lt_symbol.Name ) == 0 )
412 lib_symbol =
new LIB_SYMBOL( lt_symbol.Name );
416 existingSymbol.emplace( lt_symbol.Name, lib_symbol );
420 lib_symbol = existingSymbol[lt_symbol.Name];
423 LIB_ID libId( wxS(
"ltspice" ), lt_symbol.Name );
428 for(
int j = 0; j < (int) lt_symbol.Wires.size(); j++ )
438 for(
int j = 0; j < (int) lt_symbol.Lines.size(); j++ )
441 for(
int j = 0; j < (int) lt_symbol.Circles.size(); j++ )
444 for(
int j = 0; j < (int) lt_symbol.Arcs.size(); j++ )
447 for(
int j = 0; j < (int) lt_symbol.Rectangles.size(); j++ )
454 LTSPICE_FILE tempAsyFile( lt_symbol.Name +
".asy", { 0, 0 } );
457 tempSymbol =
m_lt_schematic->SymbolBuilder( lt_symbol.Name, dummyAsc );
466 int botRightX = lt_symbol.Offset.x
469 int botRightY = lt_symbol.Offset.y
479 if( wire.
Start == ( pinPos + lt_symbol.Offset ) )
482 if( wire.
End.
x == ( pinPos + lt_symbol.Offset ).x )
484 if( wire.
End.
y <= topLeftY )
486 else if( wire.
End.
y >= botRightY )
488 else if( wire.
End.
y < botRightY && wire.
End.
y > topLeftY )
492 else if( wire.
End.
y == ( pinPos + lt_symbol.Offset ).y )
494 if( wire.
End.
x <= topLeftX )
496 else if( wire.
End.
x >= botRightX )
498 else if( wire.
End.
x < botRightX && wire.
End.
x > topLeftX )
502 else if( wire.
End == ( pinPos + lt_symbol.Offset ) )
505 if( wire.
Start.
x == ( pinPos + lt_symbol.Offset ).x )
507 if( wire.
Start.
y <= topLeftY )
509 else if( wire.
Start.
y > botRightY )
511 else if( wire.
Start.
y < botRightY && wire.
End.
y > topLeftY )
515 else if( wire.
Start.
y == ( pinPos + lt_symbol.Offset ).y )
517 if( wire.
Start.
x <= topLeftX )
519 else if( wire.
Start.
x >= botRightX )
521 else if( wire.
Start.
x < botRightX && wire.
Start.
x > topLeftX )
536 for(
int j = 0; j < (int) aLtSymbol.
Lines.size(); j++ )
544 for(
int j = 0; j < (int) aLtSymbol.
Circles.size(); j++ )
552 for(
int j = 0; j < (int) aLtSymbol.
Arcs.size(); j++ )
560 for(
int j = 0; j < (int) aLtSymbol.
Rectangles.size(); j++ )
568 for(
int j = 0; j < (int) aLtSymbol.
Pins.size(); j++ )
600 if( aLTFontSize == 1 )
return MILS_SIZE( 36 );
601 else if( aLTFontSize == 2 )
return MILS_SIZE( 42 );
602 else if( aLTFontSize == 3 )
return MILS_SIZE( 50 );
603 else if( aLTFontSize == 4 )
return MILS_SIZE( 60 );
604 else if( aLTFontSize == 5 )
return MILS_SIZE( 72 );
605 else if( aLTFontSize == 6 )
return MILS_SIZE( 88 );
606 else if( aLTFontSize == 7 )
return MILS_SIZE( 108 );
711 std::vector<LTSPICE_SCHEMATIC::LT_ASC>& outLT_ASCs )
717 for(
int j = 0; j < (int) lt_asc.Lines.size(); j++ )
720 for(
int j = 0; j < (int) lt_asc.Circles.size(); j++ )
723 for(
int j = 0; j < (int) lt_asc.Arcs.size(); j++ )
726 for(
int j = 0; j < (int) lt_asc.Rectangles.size(); j++ )
729 for(
int j = 0; j < (int) lt_asc.Bustap.size(); j++ )
751 for(
int j = 0; j < (int) lt_asc.Wires.size(); j++ )
754 for(
int j = 0; j < (int) lt_asc.Iopins.size(); j++ )
759 if( lt_flag.
Value == wxS(
"0" ) )
762 aSheet, lt_asc.Wires ) );
780 lt_flag.Expression, lt_flag.
FontSize, lt_asc.Wires ) );
791 for(
int k = 0; k < (int) aAscfile.
Wires.size(); k++ )
793 if( ( aAscfile.
Wires[k].Start == bustap.
Start )
794 || ( aAscfile.
Wires[k].End == bustap.
Start ) )
797 aAscfile.
Wires.erase( aAscfile.
Wires.begin() + k );
802 bustap.
Start.
y - 16 } ) );
827 for(
unsigned int k = 0; k < aAscfile.
Flags.size(); k++ )
832 ioPinName = aAscfile.
Flags[k].Value;
833 aAscfile.
Flags.erase( aAscfile.
Flags.begin() + k );
945 switch( aJustification )
984 switch( aJustification )
1006 if( wxSplit( aText->
GetText(),
'\n',
'\0' ).size() > 1 )
1008 switch( aJustification )
1064 const wxString& aValue,
1066 std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires )
1088 pin->SetLength( 5 );
1092 LIB_ID libId( wxS(
"ltspice" ), wxS(
"GND" ) );
1105 if( aOffset == wire.Start )
1107 if( wire.Start.x == wire.End.x )
1109 if( wire.Start.y < wire.End.y )
1117 if( wire.Start.x < wire.End.x )
1119 else if( wire.Start.x > wire.End.x )
1123 else if( aOffset == wire.End )
1125 if( wire.Start.x == wire.End.x )
1127 if( wire.Start.y > wire.End.y )
1135 if( wire.Start.x < wire.End.x )
1137 else if( wire.Start.x > wire.End.x )
1149 const wxString& aValue,
int aFontSize,
1150 std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires )
1178 UNIMPLEMENTED_FOR( wxString::Format( wxT(
"Type not supported %d" ), (
int)aType ) );
1187 std::vector<SPIN_STYLE> preferredSpins;
1191 if( aOffset == wire.Start )
1193 if( wire.Start.x == wire.End.x )
1195 if( wire.Start.y < wire.End.y )
1197 else if( wire.Start.y > wire.End.y )
1202 if( wire.Start.x < wire.End.x )
1204 else if( wire.Start.x > wire.End.x )
1208 else if( aOffset == wire.End )
1210 if( wire.Start.x == wire.End.x )
1212 if( wire.Start.y > wire.End.y )
1214 else if( wire.Start.y < wire.End.y )
1219 if( wire.Start.x > wire.End.x )
1221 else if( wire.Start.x < wire.End.x )
1227 if( preferredSpins.size() == 1 )
1237 wxString symbolName = aLTSymbol.
Name.Upper();
1238 wxString type = aLTSymbol.
SymAttributes[wxS(
"TYPE" )].Upper();
1239 wxString prefix = aLTSymbol.
SymAttributes[wxS(
"PREFIX" )].Upper();
1240 wxString instName = aLTSymbol.
SymAttributes[wxS(
"INSTNAME" )].Upper();
1244 if( value.IsEmpty() )
1247 value2 = wxEmptyString;
1251 [&](
const wxString& aFieldName,
const wxString& aFieldValue )
1255 newField.
SetText( aFieldValue );
1260 auto setupNonInferredPassive =
1261 [&](
const wxString& aDevice,
const wxString& aValueKey )
1263 addField( wxS(
"Sim.Device" ), aDevice );
1264 addField( wxS(
"Sim.Params" ), aValueKey + wxS(
"=${VALUE}" ) );
1267 auto setupBehavioral =
1268 [&](
const wxString& aDevice,
const wxString& aType )
1272 addField( wxS(
"Sim.Device" ), aDevice );
1273 addField( wxS(
"Sim.Type" ), aType );
1274 addField( wxS(
"Sim.Params" ), value );
1277 static const std::set<wxString> prefixWithGain = { wxS(
"E" ), wxS(
"F" ), wxS(
"G" ), wxS(
"H" ) };
1279 if( prefix == wxS(
"R" ) )
1281 setupNonInferredPassive( prefix, wxS(
"R" ) );
1283 else if( prefix == wxS(
"C" ) )
1285 setupNonInferredPassive( prefix, wxS(
"C" ) );
1287 else if( prefix == wxS(
"L" ) )
1289 setupNonInferredPassive( prefix, wxS(
"L" ) );
1291 else if( prefixWithGain.count( prefix ) > 0 )
1293 setupNonInferredPassive( prefix, wxS(
"gain" ) );
1295 else if( prefix == wxS(
"B" ) )
1297 if( symbolName.StartsWith( wxS(
"BV" ) ) )
1298 setupBehavioral( wxS(
"V" ), wxS(
"=" ) );
1299 else if( symbolName.StartsWith( wxS(
"BI" ) ) )
1300 setupBehavioral( wxS(
"I" ), wxS(
"=" ) );
1302 else if( prefix == wxS(
"T" ) )
1306 addField( wxS(
"Sim.Device" ), wxS(
"TLINE" ) );
1307 addField( wxS(
"Sim.Params" ), value );
1309 else if( prefix == wxS(
"V" ) || symbolName == wxS(
"I" ) )
1311 addField( wxS(
"Sim.Device" ), wxS(
"SPICE" ) );
1315 wxString upperValue = value.Upper();
1317 if( upperValue.StartsWith( wxS(
"PWL " ) ) && upperValue.Contains( wxS(
"FILE=" ) ) )
1322 pwlArgs = value.Mid( 4 );
1324 if( !value2.IsEmpty() )
1325 pwlArgs << wxS(
" " ) << value2;
1327 pwlArgs.Trim(
true ).Trim(
false );
1330 std::vector<wxString> ngspiceArgs;
1333 for( wxString& arg : ltspiceArgs )
1336 wxString argKey = arg.BeforeFirst(
'=', &argValue );
1339 if( argValue.length() >= 2 && argValue.StartsWith( wxS(
"\"" ) ) && argValue.EndsWith( wxS(
"\"" ) ) )
1340 argValue = argValue.Mid( 1, argValue.length() - 2 );
1342 if( argKey.Upper() == wxS(
"FILE" ) )
1344 wxString fileValue = argValue;
1346 if( fileValue.IsEmpty() )
1350 wxFileName sourceFile( fileValue );
1352 wxString sanitizedName = sourceFile.GetName();
1353 sanitizedName.MakeLower();
1354 sanitizedName.Replace( wxS(
" " ), wxS(
"_" ) );
1356 wxFileName convertedFile = sourceFile;
1357 convertedFile.SetName( sanitizedName + wxS(
"_ngspice" ) );
1358 convertedFile.SetExt( sourceFile.GetExt().Lower() );
1360 if( sourceFile.FileExists() )
1364 wxLogWarning( wxS(
"Failed to convert PWL data file to ngspice format: " )
1365 + sourceFile.GetFullPath() );
1370 fileRef = convertedFile.GetFullPath();
1371 fileRef.Replace( wxS(
"\\" ), wxS(
"/" ) );
1378 value = wxS(
"pwl_file file=\\\"" ) + fileRef + wxS(
"\\\" timerelative=1" );
1381 simParams <<
"type=" <<
'"' << prefix <<
'"' <<
' ';
1383 if( value2.IsEmpty() )
1384 simParams <<
"model=" <<
'"' <<
"${VALUE}" <<
'"' <<
' ';
1386 simParams <<
"model=" <<
'"' <<
"${VALUE} ${VALUE2}" <<
'"' <<
' ';
1388 addField( wxS(
"Sim.Params" ), simParams );
1392 wxString libFile = aLTSymbol.
SymAttributes[wxS(
"MODELFILE" )];
1394 if( prefix == wxS(
"X" ) )
1399 else if( libFile.IsEmpty() )
1401 if( type.IsEmpty() )
1405 if( !libFile.IsEmpty() )
1407 addField( wxS(
"Sim.Library" ), libFile );
1408 addField( wxS(
"Sim.Name" ), symbolName );
1411 wxString spiceLine = aLTSymbol.
SymAttributes[wxS(
"SPICELINE" )];
1413 if( type == wxS(
"X" ) )
1415 addField( wxS(
"Sim.Device" ), wxS(
"SUBCKT" ) );
1417 if( !spiceLine.IsEmpty() )
1418 addField( wxS(
"Sim.Params" ), spiceLine );
1422 addField( wxS(
"Sim.Device" ), wxS(
"SPICE" ) );
1424 if( !spiceLine.IsEmpty() )
1425 addField( wxS(
"Sim.Params" ), spiceLine );
1427 addField( wxS(
"Sim.Params" ),
"model=\"" + value +
"\"" );
1432 aSymbol->
SetRef( aSheet, instName );
1435 if( !value2.IsEmpty() )
1436 addField( wxS(
"Value2" ), value2 );
1458 case 38: field = aSymbol->
GetField( wxS(
"Sim.Name" ) );
break;
1459 case 39: field = aSymbol->
GetField( wxS(
"Sim.Params" ) );
break;
1582 if( aLTSymbol.
SymAttributes[wxS(
"Prefix" )] == wxS(
"X" ) )
1608 wxString device = aLTSymbol.
Name.Lower();
1610 if( aLTSymbol.
Pins.size() == 2 && ( device == wxS(
"res" )
1611 || device == wxS(
"cap" )
1612 || device == wxS(
"ind" ) ) )
1625 aPin->
SetNumber( wxString::Format( wxS(
"%d" ), aIndex + 1 ) );
1628 wxString spiceOrder = lt_pin.
PinAttribute[ wxS(
"SpiceOrder" ) ];
1629 long spiceOrderNum = 0;
1631 if( spiceOrder.ToLong( &spiceOrderNum ) && spiceOrderNum > 0 )
1632 aPin->
SetNumber( wxString::Format( wxS(
"%ld" ), spiceOrderNum ) );
constexpr EDA_IU_SCALE schIUScale
constexpr void SetOrigin(const Vec &pos)
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr void SetSize(const SizeVec &size)
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr const Vec & GetOrigin() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetTop() const
constexpr void Offset(coord_type dx, coord_type dy)
virtual void SetEnd(const VECTOR2I &aEnd)
void SetCenter(const VECTOR2I &aCenter)
void SetFillMode(FILL_T aFill)
virtual void SetStart(const VECTOR2I &aStart)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual int GetTextHeight() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void Offset(const VECTOR2I &aOffset)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetMultilineAllowed(bool aAllow)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
POLARITY
Polarity enum represents polarity of pin.
JUSTIFICATION
Defines in what ways the PIN or TEXT can be justified.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Holds all the data relating to one schematic.
void SetSize(const VECTOR2I &aSize)
Class for a wire to bus entry.
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
int ToLtSpiceCoords(int aCoordinate)
Method converts kicad coordinate(i.e scale) to ltspice coordinates.
void CreateCircle(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting circle from Asc files.
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.
void CreateWires(LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting wires.
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.
STROKE_PARAMS getStroke(const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth, const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
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.
SCH_SYMBOL * CreatePowerSymbol(const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, SCH_SHEET_PATH *aSheet, std::vector< LTSPICE_SCHEMATIC::WIRE > &aWires)
Create a power symbol.
void CreateLine(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting Line from Asc files.
int getLineWidth(const LTSPICE_SCHEMATIC::LINEWIDTH &aLineWidth)
void RotateMirror(LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSchSymbol)
Methods for rotating and mirroring objects.
void CreateBusEntry(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting Bustap from Asc files.
void CreateRect(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting rectangle from Asc files.
void CreateWire(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet, SCH_LAYER_ID aLayer)
Create a schematic wire.
void CreateLines(LIB_SYMBOL *aSymbol, LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, int aIndex, SCH_SHAPE *aShape)
Method for plotting Lines from Asy files.
void CreatePin(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting Iopin from Asc files.
void CreateArc(LTSPICE_SCHEMATIC::LT_ASC &aAscfile, int aIndex, SCH_SHEET_PATH *aSheet)
Method for plotting Arc from Asc files.
LINE_STYLE getLineStyle(const LTSPICE_SCHEMATIC::LINESTYLE &aLineStyle)
LTSPICE_SCHEMATIC * m_lt_schematic
int ToKicadCoords(int aCoordinate)
Method converts ltspice coordinate(i.e scale) to kicad coordinates.
void CreateFields(LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheet)
void RotateMirrorShape(LTSPICE_SCHEMATIC::LT_SYMBOL &aLTSymbol, SCH_SHAPE *aShape)
SCH_LABEL_BASE * CreateSCH_LABEL(KICAD_T aType, const VECTOR2I &aOffset, const wxString &aValue, int aFontSize, std::vector< LTSPICE_SCHEMATIC::WIRE > &aWires)
Create a label.
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.
VECTOR2I ToKicadFontSize(int aLTFontSize)
void CreateSymbol(LTSPICE_SCHEMATIC::LT_SYMBOL &aLtSymbol, LIB_SYMBOL *aLibSymbol)
void SetLayer(SCH_LAYER_ID aLayer)
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void AddField(const SCH_FIELD &aField)
void SetShape(LABEL_FLAG_SHAPE aShape)
void SetPosition(const VECTOR2I &aPosition) override
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
void SetLineWidth(const int aSize)
void SetLineStyle(const LINE_STYLE aStyle)
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
void SetEndPoint(const VECTOR2I &aPosition)
void SetNumber(const wxString &aNumber)
void SetOrientation(PIN_ORIENTATION aOrientation)
void SetName(const wxString &aName)
void SetPosition(const VECTOR2I &aPos) override
void SetLength(int aLength)
void SetShape(GRAPHIC_PINSHAPE aShape)
void SetType(ELECTRICAL_PINTYPE aType)
void SetNameTextSize(int aSize)
const PAGE_INFO & GetPageSettings() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
SCHEMATIC * Schematic() const
void SetPosition(const VECTOR2I &aPos) override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
void SetStroke(const STROKE_PARAMS &aStroke) override
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void AddPoint(const VECTOR2I &aPosition)
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Helper class to recognize Spice formatted values.
wxString ToSpiceString() const
Return string value in Spice format (e.g.
Simple container to manage line stroke parameters.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
@ FILLED_WITH_BG_BODYCOLOR
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SCH_LAYER_ID
Eeschema drawing layers.
#define UNIMPLEMENTED_FOR(type)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
static wxString convertLtSpiceTextToNgspice(const wxString &aText)
static std::vector< wxString > tokenizeQuoted(const wxString &aText)
Parses the datastructure produced by the LTSPICE_SCHEMATIC into a KiCad schematic file.
static bool convertPwlFileToNgspice(const wxFileName &aSourceFile, const wxFileName &aDestFile)
LABEL_FLAG_SHAPE getLabelShape(LTSPICE_SCHEMATIC::POLARITY aPolarity)
LINE_STYLE
Dashed line types.
The ARC is represented inside a rectangle whose opposite site are given.
The CIRCLE is represented in Ltpsice inside a rectangle whose two opposite points and line style are ...
IOPIN is special contact on symbol used for IO operations.
A struct to hold .asc file definition.
std::vector< CIRCLE > Circles
std::vector< IOPIN > Iopins
std::vector< BUSTAP > Bustap
std::vector< LINE > Lines
std::vector< WIRE > Wires
std::vector< RECTANGLE > Rectangles
std::vector< FLAG > Flags
JUSTIFICATION PinJustification
std::map< wxString, wxString > PinAttribute
A struct to hold SYMBOL definition.
std::map< wxString, wxString > SymAttributes
std::vector< RECTANGLE > Rectangles
std::vector< LT_WINDOW > Windows
std::vector< LT_PIN > Pins
std::vector< WIRE > Wires
ORIENTATION SymbolOrientation
std::vector< CIRCLE > Circles
std::vector< LINE > Lines
JUSTIFICATION Justification
A 4-sided polygon with opposite equal sides, used in representing shapes.
JUSTIFICATION Justification
A metallic connection, used for transfer, between two points or pin.
@ SYM_ROTATE_COUNTERCLOCKWISE
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
T rescale(T aNumerator, T aValue, T aDenominator)
Scale a number (value) by rational (numerator/denominator).
VECTOR2< int32_t > VECTOR2I