44#include <wx/filename.h>
45#include <wx/strconv.h>
46#include <wx/tokenzr.h>
47#include <wx/txtstrm.h>
48#include <wx/wfstream.h>
50#include <fmt/format.h>
60 std::vector<wxString> tokens;
62 bool inQuotes =
false;
64 for( wxUniChar ch : aText )
69 if( !inQuotes && wxIsspace( ch ) )
71 if( !token.IsEmpty() )
73 tokens.push_back( token );
83 if( !token.IsEmpty() )
84 tokens.push_back( token );
94 wxArrayString outLines;
96 for( wxString line : wxSplit( aText,
'\n',
'\0' ) )
98 wxArrayString tok = wxSplit( line,
' ',
'\0' );
100 if( !tok.IsEmpty() && tok[0].IsSameAs( wxS(
".tran" ),
false ) )
103 wxArrayString modifiers;
105 const std::set<wxString> c_modifiers = {
"UIC",
"STEADY",
"NODISCARD",
"STARTUP",
"STEP" };
107 for(
size_t i = 1; i < tok.size(); ++i )
109 if( tok[i].IsEmpty() )
112 wxString u = tok[i].Upper();
114 if( modifiers.IsEmpty() && !c_modifiers.contains( u ) )
117 modifiers.Add( tok[i] );
120 if( !args.IsEmpty() )
128 const bool hasTstep = args.size() >= 2;
130 wxString tstepStr = hasTstep ? args[0] : wxString();
131 wxString tstopStr = hasTstep ? args[1] : args[0];
132 wxString tstartStr = ( args.size() > 2 ) ? args[2] : wxString();
133 wxString dtmaxStr = ( args.size() > 3 ) ? args[3] : wxString();
142 line = wxS(
".tran " ) + tstepStr + wxS(
" " ) + tstopStr;
144 if( !tstartStr.IsEmpty() )
145 line << wxS(
" " ) << tstartStr;
147 if( !dtmaxStr.IsEmpty() )
148 line << wxS(
" " ) << dtmaxStr;
150 for(
const wxString& mod : modifiers )
151 line << wxS(
" " ) << mod;
155 outLines.Add( line );
158 return wxJoin( outLines,
'\n',
'\0' );
167 wxFFileInputStream inputStream( aSourceFile.GetFullPath() );
169 if( !inputStream.IsOk() )
172 wxFFileOutputStream outputStream( aDestFile.GetFullPath() );
174 if( !outputStream.IsOk() )
177 wxTextInputStream textIn( inputStream, wxS(
" \t" ), wxConvUTF8 );
178 wxTextOutputStream textOut( outputStream, wxEOL_UNIX, wxConvUTF8 );
179 double prevAbsoluteTime = 0.0;
181 while( inputStream.CanRead() )
183 wxString line = textIn.ReadLine();
184 line.Trim(
true ).Trim(
false );
187 wxString commentRest;
188 if( line.StartsWith( wxS(
"*" ), &commentRest ) || line.StartsWith( wxS(
";" ), &commentRest ) )
190 textOut << wxS(
"#" ) << commentRest <<
'\n';
194 wxStringTokenizer pointTokenizer( line, wxS(
" \t" ), wxTOKEN_STRTOK );
196 if( pointTokenizer.CountTokens() < 2 )
198 textOut << line <<
'\n';
202 wxString timeToken = pointTokenizer.GetNextToken();
203 wxString valueToken = pointTokenizer.GetNextToken();
208 wxString timeRest = timeToken;
209 bool isRelative = timeToken.StartsWith( wxS(
"+" ), &timeRest );
211 if( timeRest.IsEmpty() )
213 textOut << line <<
'\n';
219 double timeValueSeconds = spiceValue.
ToDouble();
222 double absoluteTime = isRelative ? prevAbsoluteTime + timeValueSeconds : timeValueSeconds;
223 double relativeTime = absoluteTime - prevAbsoluteTime;
224 prevAbsoluteTime = absoluteTime;
227 wxString relativeTimeStr = wxS(
"0" );
229 if( relativeTime != 0.0 )
231 double absSeconds = std::fabs( relativeTime );
232 int exp10 =
static_cast<int>( std::floor( std::log10( absSeconds ) ) );
233 int engExp = exp10 - ( ( exp10 % 3 + 3 ) % 3 );
234 double mantissa = relativeTime / std::pow( 10.0, engExp );
236 relativeTimeStr = wxString::FromUTF8( fmt::format(
"{:.9g}e{}", mantissa, engExp ) );
239 textOut << relativeTimeStr <<
'\t' << valueToken <<
'\n';
242 return outputStream.IsOk();
247 const std::vector<wxString>& aUniqueAscNames,
248 std::map<wxString, SCH_SCREEN*>& aMapOfScreens,
VECTOR2I aOriginOffset )
257 if( schematic && schematic->
RootScreen() == aScreen )
261 wxString includeText;
263 if( !projectPath.IsEmpty() )
265 wxFileName cmpDir(
m_lt_schematic->GetLTspiceDataDir().GetFullPath(), wxEmptyString );
266 cmpDir.AppendDir( wxS(
"cmp" ) );
268 wxFileName outDir( projectPath, wxEmptyString );
269 outDir.AppendDir( wxS(
"ltspice_cmp" ) );
270 outDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
272 for(
const wxString
name :
273 { wxS(
"standard.dio" ), wxS(
"standard.bjt" ), wxS(
"standard.jft" ), wxS(
"standard.mos" ) } )
275 includeText << wxS(
".include ltspice_cmp/" ) <<
name << wxS(
"\n" );
277 wxFileName src = cmpDir;
278 src.SetFullName(
name );
280 if( !src.FileExists() )
283 wxFileName dst = outDir;
284 dst.SetFullName(
name );
286 if( dst.FileExists() )
289 wxFFile in( src.GetFullPath(), wxS(
"rb" ) );
294 wxFileOffset len = in.Length();
299 wxMemoryBuffer buffer(
static_cast<size_t>( len ) );
300 void* writePtr = buffer.GetWriteBuf(
static_cast<size_t>( len ) );
302 if( !writePtr || in.Read( writePtr, len ) !=
static_cast<size_t>( len ) )
305 buffer.UngetWriteBuf(
static_cast<size_t>( len ) );
307 const char* data =
static_cast<const char*
>( buffer.GetData() );
311 if( len >= 4 && ( len % 2 ) == 0 && data[1] == 0 && data[3] == 0 )
312 text = wxString( data, wxMBConvUTF16LE(), len );
314 text = wxString::FromUTF8( data, len );
317 text = wxString( data, wxCSConv( wxFONTENCODING_CP1252 ), len );
319 wxFFile out( dst.GetFullPath(), wxS(
"wb" ) );
321 if( !out.IsOpened() )
324 out.Write(
text, wxConvUTF8 );
329 includeText << wxS(
"\n" );
330 includeText << wxS(
".subckt pwl_file outp outn file=\"\" timerelative=1\n" );
331 includeText << wxS(
"Afs %vd([outp outn]) filesrc\n" );
332 includeText << wxS(
".model filesrc filesource (file={file} amploffset=[0] amplscale=[1] timeoffset=0 "
333 "timescale=1 timerelative={timerelative})\n" );
334 includeText << wxS(
".ends\n" );
336 if( !includeText.IsEmpty() )
345 aScreen->
Append( textItem );
363 const std::vector<wxString>& aUniqueAscNames,
364 std::map<wxString, SCH_SCREEN*>& aMapOfScreens )
366 std::map<wxString, LIB_SYMBOL*> existingSymbol;
376 if( existingSymbol.count( libName ) == 0 )
382 existingSymbol.emplace( libName, lib_symbol );
386 lib_symbol = existingSymbol[libName];
389 LIB_ID libId( wxS(
"ltspice" ), libName );
397 aScreen->
Append( sch_symbol );
401 for(
int j = 0; j < (int) lt_symbol.
Lines.size(); j++ )
412 for(
int j = 0; j < (int) lt_symbol.
Circles.size(); j++ )
423 for(
int j = 0; j < (int) lt_symbol.
Arcs.size(); j++ )
434 for(
int j = 0; j < (int) lt_symbol.
Rectangles.size(); j++ )
445 for(
int j = 0; j < (int) lt_symbol.
Texts.size(); j++ )
458 if( aMapOfScreens.contains( lt_symbol.
AsyKey ) )
467 for(
int j = 0; j < (int) aLtSymbol.
Lines.size(); j++ )
475 for(
int j = 0; j < (int) aLtSymbol.
Circles.size(); j++ )
483 for(
int j = 0; j < (int) aLtSymbol.
Arcs.size(); j++ )
491 for(
int j = 0; j < (int) aLtSymbol.
Rectangles.size(); j++ )
499 for(
int j = 0; j < (int) aLtSymbol.
Texts.size(); j++ )
507 for(
int j = 0; j < (int) aLtSymbol.
Pins.size(); j++ )
539 if( aLTFontSize == 0 )
return MILS_SIZE( 20 );
540 else if( aLTFontSize == 1 )
return MILS_SIZE( 36 );
541 else if( aLTFontSize == 2 )
return MILS_SIZE( 42 );
542 else if( aLTFontSize == 3 )
return MILS_SIZE( 50 );
543 else if( aLTFontSize == 4 )
return MILS_SIZE( 60 );
544 else if( aLTFontSize == 5 )
return MILS_SIZE( 72 );
545 else if( aLTFontSize == 6 )
return MILS_SIZE( 88 );
546 else if( aLTFontSize == 7 )
return MILS_SIZE( 108 );
685 for(
int j = 0; j < (int) aAscfile.
Lines.size(); j++ )
688 for(
int j = 0; j < (int) aAscfile.
Circles.size(); j++ )
691 for(
int j = 0; j < (int) aAscfile.
Arcs.size(); j++ )
694 for(
int j = 0; j < (int) aAscfile.
Rectangles.size(); j++ )
697 for(
int j = 0; j < (int) aAscfile.
Bustap.size(); j++ )
700 for(
int j = 0; j < (int) aAscfile.
Wires.size(); j++ )
703 for(
int j = 0; j < (int) aAscfile.
Iopins.size(); j++ )
708 if( lt_flag.
Value == wxS(
"0" ) )
739 for(
int k = 0; k < (int) aAscfile.
Wires.size(); k++ )
744 aAscfile.
Wires.erase( aAscfile.
Wires.begin() + k );
752 aScreen->
Append( busEntry );
772 std::set<SPIN_STYLE> preferredSpins;
781 if( !wire->IsWire() )
785 wireBox.
Merge( wire->GetStartPoint() );
786 wireBox.
Merge( wire->GetEndPoint() );
793 if( aLabelPos == minPt )
795 else if( aLabelPos == maxPt )
802 if( aLabelPos == minPt )
804 else if( aLabelPos == maxPt )
815 transform = symbol->GetTransform();
817 switch(
pin->PinDrawOrient( transform ) )
828 switch( sheetPin->GetSpinStyle() )
839 if( preferredSpins.size() == 1 )
841 return *preferredSpins.begin();
843 else if( preferredSpins.size() == 2 )
850 else if( preferredSpins.size() == 3 )
877 for(
unsigned int k = 0; k < aAscfile.
Flags.size(); k++ )
881 ioPinName = aAscfile.
Flags[k].Value;
882 aAscfile.
Flags.erase( aAscfile.
Flags.begin() + k );
894 aScreen->
Append( sheetPin );
953 aScreen->
Append( rectangle );
970 wxString sanitizedName = aLTSymbol.
Name;
974 wxString sheetName = sanitizedName +
':' + instName;
976 instNameField->
SetText( instName );
979 sheetNameField->
SetText( sheetName );
1039 sch_sheet->
AddPin( sheetPin );
1046 if( wire.
Start == absPinPosLT )
1047 wire.
Start = absPinPosNewLT;
1048 if( wire.
End == absPinPosLT )
1049 wire.
End = absPinPosNewLT;
1054 if( iopin.
Location == absPinPosLT )
1060 if(
flag.Offset == absPinPosLT )
1061 flag.Offset = absPinPosNewLT;
1065 aScreen->
Append( sch_sheet );
1084 switch( aLineStyle )
1106 switch( aJustification )
1145 switch( aJustification )
1167 if( wxSplit( aText->
GetText(),
'\n',
'\0' ).size() > 1 )
1169 switch( aJustification )
1219 aScreen->
Append( segment );
1225 std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires )
1246 pin->SetLength( 5 );
1250 LIB_ID libId( wxS(
"ltspice" ), wxS(
"GND" ) );
1260 sch_symbol->
Move( pos );
1310 UNIMPLEMENTED_FOR( wxString::Format( wxT(
"Type not supported %d" ), (
int)aType ) );
1327 wxString symbolName = aLTSymbol.
Name.Upper();
1334 if( value.IsEmpty() )
1337 value2 = wxEmptyString;
1341 [&](
const wxString& aFieldName,
const wxString& aFieldValue )
1345 newField.
SetText( aFieldValue );
1350 auto setupNonInferredPassive =
1351 [&](
const wxString& aDevice,
const wxString& aValueKey )
1353 addField( wxS(
"Sim.Device" ), aDevice );
1354 addField( wxS(
"Sim.Params" ), aValueKey + wxS(
"=${VALUE}" ) );
1357 auto setupBehavioral =
1358 [&](
const wxString& aDevice,
const wxString& aType )
1362 addField( wxS(
"Sim.Device" ), aDevice );
1363 addField( wxS(
"Sim.Type" ), aType );
1364 addField( wxS(
"Sim.Params" ), value );
1367 static const std::set<wxString> prefixWithGain = { wxS(
"E" ), wxS(
"F" ), wxS(
"G" ), wxS(
"H" ) };
1369 if( prefix == wxS(
"R" ) )
1371 setupNonInferredPassive( prefix, wxS(
"R" ) );
1373 else if( prefix == wxS(
"C" ) )
1375 setupNonInferredPassive( prefix, wxS(
"C" ) );
1377 else if( prefix == wxS(
"L" ) )
1379 setupNonInferredPassive( prefix, wxS(
"L" ) );
1381 else if( prefixWithGain.count( prefix ) > 0 )
1383 setupNonInferredPassive( prefix, wxS(
"gain" ) );
1385 else if( prefix == wxS(
"B" ) )
1387 if( symbolName.StartsWith( wxS(
"BV" ) ) )
1388 setupBehavioral( wxS(
"V" ), wxS(
"=" ) );
1389 else if( symbolName.StartsWith( wxS(
"BI" ) ) )
1390 setupBehavioral( wxS(
"I" ), wxS(
"=" ) );
1392 else if( prefix == wxS(
"T" ) )
1396 addField( wxS(
"Sim.Device" ), wxS(
"TLINE" ) );
1397 addField( wxS(
"Sim.Params" ), value );
1399 else if( prefix == wxS(
"V" ) || symbolName == wxS(
"I" ) )
1401 addField( wxS(
"Sim.Device" ), wxS(
"SPICE" ) );
1405 wxString upperValue = value.Upper();
1407 if( upperValue.StartsWith( wxS(
"PWL " ) ) && upperValue.Contains( wxS(
"FILE=" ) ) )
1412 pwlArgs = value.Mid( 4 );
1414 if( !value2.IsEmpty() )
1415 pwlArgs << wxS(
" " ) << value2;
1417 pwlArgs.Trim(
true ).Trim(
false );
1420 std::vector<wxString> ngspiceArgs;
1423 for( wxString& arg : ltspiceArgs )
1426 wxString argKey = arg.BeforeFirst(
'=', &argValue );
1429 if( argValue.length() >= 2 && argValue.StartsWith( wxS(
"\"" ) ) && argValue.EndsWith( wxS(
"\"" ) ) )
1430 argValue = argValue.Mid( 1, argValue.length() - 2 );
1432 if( argKey.Upper() == wxS(
"FILE" ) )
1434 wxString fileValue = argValue;
1436 if( fileValue.IsEmpty() )
1440 wxFileName sourceFile( fileValue );
1442 wxString sanitizedName = sourceFile.GetName();
1443 sanitizedName.MakeLower();
1444 sanitizedName.Replace( wxS(
" " ), wxS(
"_" ) );
1446 wxFileName convertedFile = sourceFile;
1447 convertedFile.SetName( sanitizedName + wxS(
"_ngspice" ) );
1448 convertedFile.SetExt( sourceFile.GetExt().Lower() );
1450 if( sourceFile.FileExists() )
1454 wxLogWarning( wxS(
"Failed to convert PWL data file to ngspice format: " )
1455 + sourceFile.GetFullPath() );
1460 fileRef = convertedFile.GetFullPath();
1461 fileRef.Replace( wxS(
"\\" ), wxS(
"/" ) );
1468 value = wxS(
"pwl_file file=\\\"" ) + fileRef + wxS(
"\\\" timerelative=1" );
1471 simParams <<
"type=" <<
'"' << prefix <<
'"' <<
' ';
1473 if( value2.IsEmpty() )
1474 simParams <<
"model=" <<
'"' <<
"${VALUE}" <<
'"' <<
' ';
1476 simParams <<
"model=" <<
'"' <<
"${VALUE} ${VALUE2}" <<
'"' <<
' ';
1478 addField( wxS(
"Sim.Params" ), simParams );
1484 if( prefix == wxS(
"X" ) )
1489 else if( libFile.IsEmpty() )
1491 if( type.IsEmpty() )
1495 if( !libFile.IsEmpty() )
1497 addField( wxS(
"Sim.Library" ), libFile );
1498 addField( wxS(
"Sim.Name" ), symbolName );
1503 if( type == wxS(
"X" ) )
1505 addField( wxS(
"Sim.Device" ), wxS(
"SUBCKT" ) );
1507 if( !spiceLine.IsEmpty() )
1508 addField( wxS(
"Sim.Params" ), spiceLine );
1512 addField( wxS(
"Sim.Device" ), wxS(
"SPICE" ) );
1514 if( !spiceLine.IsEmpty() )
1515 addField( wxS(
"Sim.Params" ), spiceLine );
1517 addField( wxS(
"Sim.Params" ),
"model=\"" + value +
"\"" );
1525 if( !value2.IsEmpty() )
1526 addField( wxS(
"Value2" ), value2 );
1548 case 38: field = aSymbol->
GetField( wxS(
"Sim.Name" ) );
break;
1549 case 39: field = aSymbol->
GetField( wxS(
"Sim.Params" ) );
break;
1680 wxString device = aLTSymbol.
Name.Lower();
1682 if( aLTSymbol.
Pins.size() == 2 && ( device == wxS(
"res" )
1683 || device == wxS(
"cap" )
1684 || device == wxS(
"ind" ) ) )
1697 aPin->
SetNumber( wxString::Format( wxS(
"%d" ), aIndex + 1 ) );
1701 long spiceOrderNum = 0;
1703 if( spiceOrder.ToLong( &spiceOrderNum ) && spiceOrderNum > 0 )
1704 aPin->
SetNumber( wxString::Format( wxS(
"%ld" ), spiceOrderNum ) );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
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 size_type GetHeight() const
constexpr const Vec & GetOrigin() const
constexpr const SizeVec & GetSize() const
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual void SetEnd(const VECTOR2I &aEnd)
virtual 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.
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.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Holds all the data relating to one schematic.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void SetSize(const VECTOR2I &aSize)
Class for a wire to bus entry.
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aBodyStyle=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
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.
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,...
virtual void MirrorHorizontally(int aCenter)
Mirror item horizontally about aCenter.
void SetLayer(SCH_LAYER_ID aLayer)
virtual void Rotate(const VECTOR2I &aCenter, bool aRotateCCW)
Rotate the item around aCenter 90 degrees in the clockwise direction.
virtual void MirrorVertically(int aCenter)
Mirror item vertically about aCenter.
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)
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
SCHEMATIC * Schematic() const
void SetPosition(const VECTOR2I &aPos) override
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
void SetStroke(const STROKE_PARAMS &aStroke) override
void AddPoint(const VECTOR2I &aPosition)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void ConstrainOnEdge(const VECTOR2I &aPos, bool aAllowEdgeSwitch)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetSize(const VECTOR2I &aSize)
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetPosition(const VECTOR2I &aPosition) override
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
void SetBorderWidth(int aWidth)
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add aFieldName to the list of fields.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
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.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
void SetSchTextSize(int aSize)
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
wxString ToSpiceString() const
Return string value in Spice format (e.g.
Spin style for labels of all kinds on schematics.
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_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
@ FILLED_WITH_BG_BODYCOLOR
#define IS_NEW
New item, just created.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SCH_LAYER_ID
Eeschema drawing layers.
#define UNIMPLEMENTED_FOR(type)
wxString get_def(const std::map< wxString, wxString > &aMap, const char *aKey, const char *aDefval="")
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)
SPIN_STYLE autoLabelOrientation(SCH_SCREEN *aScreen, VECTOR2I aLabelPos, SPIN_STYLE aDefaultSpin)
LABEL_FLAG_SHAPE
Label and flag shapes used with text objects.
bool ReplaceIllegalFileNameChars(std::string &aName, int aReplaceChar)
Checks aName for illegal file name characters.
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< LT_SYMBOL > Symbols
std::vector< TEXT > Texts
std::vector< DATAFLAG > DataFlags
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
ORIENTATION SymbolOrientation
std::vector< TEXT > Texts
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)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
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