Add (limited) support for LTSpice DATAFLAGs.
Even though we can't evaluate the expressions, we should at least show the text so users can decide what to do with them.
This commit is contained in:
parent
50b916cb73
commit
744dec65d7
|
@ -55,9 +55,9 @@ set( EESCHEMA_SCH_PLUGINS_CADSTAR
|
|||
|
||||
|
||||
set( EESCHEMA_SCH_PLUGINS_LTSPICE
|
||||
sch_plugins/ltSpice/ltspice_schematic.cpp
|
||||
sch_plugins/ltSpice/ltspice_sch_parser.cpp
|
||||
sch_plugins/ltSpice/ltspice_sch_plugin.cpp
|
||||
sch_plugins/lt_spice/ltspice_schematic.cpp
|
||||
sch_plugins/lt_spice/ltspice_sch_parser.cpp
|
||||
sch_plugins/lt_spice/ltspice_sch_plugin.cpp
|
||||
)
|
||||
|
||||
set( EESCHEMA_DLGS
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <sch_plugins/altium/sch_altium_plugin.h>
|
||||
#include <sch_plugins/cadstar/cadstar_sch_archive_plugin.h>
|
||||
#include <sch_plugins/database/sch_database_plugin.h>
|
||||
#include <sch_plugins/ltSpice/ltspice_sch_plugin.h>
|
||||
#include "sch_plugins/lt_spice/ltspice_sch_plugin.h"
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
|
||||
|
|
|
@ -105,6 +105,11 @@ public:
|
|||
m_fields.insert( m_fields.end(), aFields.begin(), aFields.end() );
|
||||
}
|
||||
|
||||
void AddField( const SCH_FIELD& aField )
|
||||
{
|
||||
m_fields.push_back( aField );
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the label text, if it ends with a number.
|
||||
*
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
* schematic file.
|
||||
*/
|
||||
|
||||
#include <sch_plugins/ltSpice/ltspice_sch_parser.h>
|
||||
#include <sch_plugins/ltSpice/ltspice_schematic.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_sch_parser.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_schematic.h>
|
||||
#include <sch_io_mgr.h>
|
||||
#include <base_units.h>
|
||||
#include <core/kicad_algo.h>
|
||||
|
@ -38,7 +38,7 @@
|
|||
#include <sch_edit_frame.h>
|
||||
#include <sch_shape.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include "kiplatform/environment.h"
|
||||
#include <kiplatform/environment.h>
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::Parse( SCH_SHEET_PATH* aSheet,
|
||||
|
@ -195,9 +195,6 @@ void LTSPICE_SCH_PARSER::CreateKicadSYMBOLs( SCH_SHEET_PATH* aSheet,
|
|||
for( int j = 0; j < (int) lt_symbol.Rectangles.size(); j++ )
|
||||
CreateRect( lt_symbol, j, aSheet );
|
||||
|
||||
for( int j = 0; j < (int) lt_symbol.Windows.size(); j++ )
|
||||
CreateText( lt_symbol, j, aSheet );
|
||||
|
||||
// Calculating bounding box
|
||||
BOX2I bbox;
|
||||
|
||||
|
@ -478,8 +475,10 @@ void LTSPICE_SCH_PARSER::CreateWires( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, i
|
|||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreateKicadSCH_ITEMs( SCH_SHEET_PATH* aSheet,
|
||||
std::vector<LTSPICE_SCHEMATIC::LT_ASC>& outLT_ASCs )
|
||||
std::vector<LTSPICE_SCHEMATIC::LT_ASC>& outLT_ASCs )
|
||||
{
|
||||
SCH_SCREEN* screen = aSheet->LastScreen();
|
||||
|
||||
for( LTSPICE_SCHEMATIC::LT_ASC& lt_asc : outLT_ASCs )
|
||||
{
|
||||
for( int j = 0; j < (int) lt_asc.Lines.size(); j++ )
|
||||
|
@ -522,11 +521,31 @@ void LTSPICE_SCH_PARSER::CreateKicadSCH_ITEMs( SCH_SHEET_PATH* aSheet,
|
|||
for( int j = 0; j < (int) lt_asc.Iopins.size(); j++ )
|
||||
CreatePin( lt_asc, j, aSheet );
|
||||
|
||||
for( int j = 0; j < (int) lt_asc.Flags.size(); j++ )
|
||||
CreatePowerSymbol( lt_asc, j, aSheet );
|
||||
for( const LTSPICE_SCHEMATIC::FLAG& lt_flag : lt_asc.Flags )
|
||||
{
|
||||
if( lt_flag.Value == wxS( "0" ) )
|
||||
{
|
||||
screen->Append( CreatePowerSymbol( lt_flag.Offset, lt_flag.Value, lt_flag.FontSize,
|
||||
aSheet, lt_asc.Wires ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->Append( CreateSCH_LABEL( SCH_LABEL_T, lt_flag.Offset, lt_flag.Value,
|
||||
lt_flag.FontSize ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( int j = 0; j < (int) lt_asc.Texts.size(); j++ )
|
||||
CreateText( lt_asc, j, aSheet );
|
||||
for( const LTSPICE_SCHEMATIC::TEXT& lt_text : lt_asc.Texts )
|
||||
{
|
||||
screen->Append( CreateSCH_TEXT( lt_text.Offset, lt_text.Value, lt_text.FontSize,
|
||||
lt_text.Justification ) );
|
||||
}
|
||||
|
||||
for( const LTSPICE_SCHEMATIC::DATAFLAG& lt_flag : lt_asc.DataFlags )
|
||||
{
|
||||
screen->Append( CreateSCH_LABEL( SCH_DIRECTIVE_LABEL_T, lt_flag.Offset,
|
||||
lt_flag.Expression, lt_flag.FontSize ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -555,6 +574,17 @@ void LTSPICE_SCH_PARSER::CreateBusEntry( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, in
|
|||
}
|
||||
|
||||
|
||||
LABEL_FLAG_SHAPE getLabelShape( LTSPICE_SCHEMATIC::POLARITY aPolarity )
|
||||
{
|
||||
if( aPolarity == LTSPICE_SCHEMATIC::POLARITY::INPUT )
|
||||
return LABEL_FLAG_SHAPE::L_INPUT;
|
||||
else if( aPolarity == LTSPICE_SCHEMATIC::POLARITY::OUTPUT )
|
||||
return LABEL_FLAG_SHAPE::L_OUTPUT;
|
||||
else
|
||||
return LABEL_FLAG_SHAPE::L_BIDI;
|
||||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
|
@ -574,23 +604,11 @@ void LTSPICE_SCH_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIn
|
|||
SCH_HIERLABEL* sheetPin = new SCH_HIERLABEL( ToKicadCoords( iopin.Location ) + m_originOffset,
|
||||
ioPinName, SCH_HIER_LABEL_T );
|
||||
|
||||
sheetPin->SetShape( GetLabelShape( aAscfile, aIndex ) );
|
||||
sheetPin->SetShape( getLabelShape( iopin.Polarity ) );
|
||||
aSheet->LastScreen()->Append( sheetPin );
|
||||
}
|
||||
|
||||
|
||||
LABEL_FLAG_SHAPE LTSPICE_SCH_PARSER::GetLabelShape( LTSPICE_SCHEMATIC::LT_ASC& aAscfile,
|
||||
int aIndex )
|
||||
{
|
||||
if( aAscfile.Iopins[aIndex].Polarity == LTSPICE_SCHEMATIC::POLARITY::INPUT )
|
||||
return LABEL_FLAG_SHAPE::L_INPUT;
|
||||
else if( aAscfile.Iopins[aIndex].Polarity == LTSPICE_SCHEMATIC::POLARITY::OUTPUT )
|
||||
return LABEL_FLAG_SHAPE::L_OUTPUT;
|
||||
else
|
||||
return LABEL_FLAG_SHAPE::L_BIDI;
|
||||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreateLine( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
|
@ -683,18 +701,18 @@ STROKE_PARAMS LTSPICE_SCH_PARSER::getStroke( const LTSPICE_SCHEMATIC::LINEWIDTH&
|
|||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreateText( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet )
|
||||
SCH_TEXT* LTSPICE_SCH_PARSER::CreateSCH_TEXT( VECTOR2I aOffset, const wxString& aText,
|
||||
int aFontSize,
|
||||
LTSPICE_SCHEMATIC::JUSTIFICATION aJustification )
|
||||
{
|
||||
LTSPICE_SCHEMATIC::TEXT& lt_text = aAscfile.Texts[aIndex];
|
||||
VECTOR2I pos = ToKicadCoords( lt_text.Offset ) + m_originOffset;
|
||||
SCH_TEXT* textItem = new SCH_TEXT( pos, lt_text.Value, SCH_TEXT_T );
|
||||
VECTOR2I pos = ToKicadCoords( aOffset ) + m_originOffset;
|
||||
SCH_TEXT* textItem = new SCH_TEXT( pos, aText, SCH_TEXT_T );
|
||||
|
||||
textItem->SetTextSize( ToKicadFontSize( lt_text.FontSize ) );
|
||||
textItem->SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
textItem->SetVisible( true );
|
||||
textItem->SetMultilineAllowed( true );
|
||||
|
||||
switch( lt_text.Justification )
|
||||
switch( aJustification )
|
||||
{
|
||||
case LTSPICE_SCHEMATIC::JUSTIFICATION::VLEFT:
|
||||
textItem->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
|
||||
|
@ -740,7 +758,7 @@ void LTSPICE_SCH_PARSER::CreateText( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aI
|
|||
break;
|
||||
}
|
||||
|
||||
aSheet->LastScreen()->Append( textItem );
|
||||
return textItem;
|
||||
}
|
||||
|
||||
|
||||
|
@ -760,100 +778,125 @@ void LTSPICE_SCH_PARSER::CreateWire( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aI
|
|||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreatePowerSymbol( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet )
|
||||
SCH_SYMBOL* LTSPICE_SCH_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset, const wxString& aValue,
|
||||
int aFontSize, SCH_SHEET_PATH* aSheet,
|
||||
std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires )
|
||||
{
|
||||
LTSPICE_SCHEMATIC::FLAG& flag = aAscfile.Flags[aIndex];
|
||||
LIB_SYMBOL* lib_symbol = new LIB_SYMBOL( wxS( "GND" ) );
|
||||
LIB_SHAPE* shape = new LIB_SHAPE( lib_symbol, SHAPE_T::POLY );
|
||||
|
||||
if( flag.Value == wxS( "0" ) )
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { -16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 0, 15 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { -16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 0, 15 } ) );
|
||||
|
||||
shape->SetStroke( STROKE_PARAMS( getLineWidth( LTSPICE_SCHEMATIC::LINEWIDTH::Normal ),
|
||||
PLOT_DASH_TYPE::SOLID ) );
|
||||
|
||||
lib_symbol->AddDrawItem( shape );
|
||||
lib_symbol->SetPower();
|
||||
|
||||
LIB_PIN* pin = new LIB_PIN( lib_symbol );
|
||||
|
||||
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||
pin->SetPosition( ToInvertedKicadCoords( { 0, 0 } ) );
|
||||
pin->SetLength( 5 );
|
||||
pin->SetShape( GRAPHIC_PINSHAPE::LINE );
|
||||
lib_symbol->AddDrawItem( pin );
|
||||
|
||||
LIB_ID libId( wxS( "ltspice" ), wxS( "GND" ) );
|
||||
SCH_SYMBOL* sch_symbol = new SCH_SYMBOL( *lib_symbol, libId, aSheet, 1 );
|
||||
|
||||
sch_symbol->SetRef( aSheet, wxString::Format( wxS( "#GND%03d" ), m_powerSymbolIndex++ ) );
|
||||
sch_symbol->GetField( REFERENCE_FIELD )->SetVisible( false );
|
||||
sch_symbol->SetValueFieldText( wxS( "0" ) );
|
||||
sch_symbol->GetField( VALUE_FIELD )->SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
sch_symbol->GetField( VALUE_FIELD )->SetVisible( false );
|
||||
|
||||
sch_symbol->Move( ToKicadCoords( aOffset ) + m_originOffset );
|
||||
|
||||
for( LTSPICE_SCHEMATIC::WIRE& wire : aWires )
|
||||
{
|
||||
LIB_SYMBOL* lib_symbol = new LIB_SYMBOL( wxS( "GND" ) );
|
||||
LIB_SHAPE* shape = new LIB_SHAPE( lib_symbol, SHAPE_T::POLY );
|
||||
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { -16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 0, 15 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { -16, 0 } ) );
|
||||
shape->AddPoint( ToInvertedKicadCoords( { 0, 15 } ) );
|
||||
|
||||
shape->SetStroke( STROKE_PARAMS( getLineWidth( LTSPICE_SCHEMATIC::LINEWIDTH::Normal ),
|
||||
PLOT_DASH_TYPE::SOLID ) );
|
||||
|
||||
lib_symbol->AddDrawItem( shape );
|
||||
lib_symbol->SetPower();
|
||||
|
||||
LIB_PIN* pin = new LIB_PIN( lib_symbol );
|
||||
|
||||
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||
pin->SetPosition( ToInvertedKicadCoords( { 0, 0 } ) );
|
||||
pin->SetLength( 5 );
|
||||
pin->SetShape( GRAPHIC_PINSHAPE::LINE );
|
||||
lib_symbol->AddDrawItem( pin );
|
||||
|
||||
LIB_ID libId( wxS( "ltspice" ), wxS( "GND" ) );
|
||||
SCH_SYMBOL* sch_symbol = new SCH_SYMBOL( *lib_symbol, libId, aSheet, 1 );
|
||||
|
||||
sch_symbol->SetRef( aSheet, wxString::Format( wxS( "#GND%03d" ), aIndex ) );
|
||||
sch_symbol->GetField( REFERENCE_FIELD )->SetVisible( false );
|
||||
sch_symbol->SetValueFieldText( wxS( "0" ) );
|
||||
sch_symbol->GetField( VALUE_FIELD )->SetVisible( false );
|
||||
|
||||
sch_symbol->Move( ToKicadCoords( aAscfile.Flags[aIndex].Offset ) + m_originOffset );
|
||||
|
||||
for( LTSPICE_SCHEMATIC::WIRE& wire : aAscfile.Wires )
|
||||
if( aOffset == wire.Start )
|
||||
{
|
||||
if( flag.Offset == wire.Start )
|
||||
if( wire.Start.x == wire.End.x )
|
||||
{
|
||||
if( wire.Start.x == wire.End.x )
|
||||
if( wire.Start.y < wire.End.y )
|
||||
{
|
||||
if( wire.Start.y < wire.End.y )
|
||||
{
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( wire.Start.x < wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_CLOCKWISE );
|
||||
else if( wire.Start.x > wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
}
|
||||
}
|
||||
else if( flag.Offset == wire.End )
|
||||
else
|
||||
{
|
||||
if( wire.Start.x == wire.End.x )
|
||||
{
|
||||
if( wire.Start.y > wire.End.y )
|
||||
{
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( wire.Start.x < wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
else if( wire.Start.x > wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_CLOCKWISE );
|
||||
}
|
||||
if( wire.Start.x < wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_CLOCKWISE );
|
||||
else if( wire.Start.x > wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
}
|
||||
}
|
||||
else if( aOffset == wire.End )
|
||||
{
|
||||
if( wire.Start.x == wire.End.x )
|
||||
{
|
||||
if( wire.Start.y > wire.End.y )
|
||||
{
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( wire.Start.x < wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
||||
else if( wire.Start.x > wire.End.x )
|
||||
sch_symbol->SetOrientation( SYM_ROTATE_CLOCKWISE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aSheet->LastScreen()->Append( sch_symbol );
|
||||
return sch_symbol;
|
||||
}
|
||||
|
||||
|
||||
SCH_LABEL_BASE* LTSPICE_SCH_PARSER::CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset,
|
||||
const wxString& aValue, int aFontSize )
|
||||
{
|
||||
SCH_LABEL_BASE* label = nullptr;
|
||||
|
||||
if( aType == SCH_LABEL_T )
|
||||
{
|
||||
label = new SCH_LABEL();
|
||||
|
||||
label->SetText( aValue );
|
||||
label->SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
|
||||
}
|
||||
else if( aType == SCH_DIRECTIVE_LABEL_T )
|
||||
{
|
||||
label = new SCH_DIRECTIVE_LABEL();
|
||||
|
||||
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
|
||||
|
||||
SCH_FIELD field( { 0, 0 }, -1, label, wxS( "DATAFLAG" ) );
|
||||
field.SetText( aValue );
|
||||
field.SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
field.SetVisible( true );
|
||||
|
||||
label->AddField( field );
|
||||
label->AutoplaceFields( nullptr, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_LABEL* label = new SCH_LABEL();
|
||||
|
||||
label->SetText( flag.Value );
|
||||
label->SetTextSize( ToKicadFontSize( flag.FontSize ) );
|
||||
label->SetPosition( ToKicadCoords( flag.Offset ) + m_originOffset );
|
||||
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
|
||||
label->SetVisible( true );
|
||||
aSheet->LastScreen()->Append( label );
|
||||
UNIMPLEMENTED_FOR( aType );
|
||||
}
|
||||
|
||||
label->SetPosition( ToKicadCoords( aOffset ) + m_originOffset );
|
||||
label->SetVisible( true );
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
@ -962,11 +1005,119 @@ void LTSPICE_SCH_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol,
|
|||
|
||||
switch( lt_window.WindowNumber )
|
||||
{
|
||||
case 0: field = aSymbol->GetField( REFERENCE_FIELD ); break;
|
||||
case 3: field = aSymbol->GetField( VALUE_FIELD ); break;
|
||||
case 38: field = aSymbol->FindField( wxS( "Sim.Name" ) ); break;
|
||||
case 39: field = aSymbol->FindField( wxS( "Sim.Params" ) ); break;
|
||||
default: break;
|
||||
case -1: /* PartNum */ break;
|
||||
case 0: /* InstName */ field = aSymbol->GetField( REFERENCE_FIELD ); break;
|
||||
case 1: /* Type */ break;
|
||||
case 2: /* RefName */ break;
|
||||
case 3: /* Value */ field = aSymbol->GetField( VALUE_FIELD ); break;
|
||||
|
||||
case 5: /* QArea */ break;
|
||||
|
||||
case 8: /* Width */ break;
|
||||
case 9: /* Length */ break;
|
||||
case 10: /* Multi */ break;
|
||||
|
||||
case 16: /* Nec */ break;
|
||||
|
||||
case 38: /* SpiceModel */ field = aSymbol->FindField( wxS( "Sim.Name" ) ); break;
|
||||
case 39: /* SpiceLine */ field = aSymbol->FindField( wxS( "Sim.Params" ) ); break;
|
||||
case 40: /* SpiceLine2 */ break;
|
||||
|
||||
/*
|
||||
47 Def_Sub
|
||||
|
||||
50 Digital_Timing_Model
|
||||
51 Digital_Extracts
|
||||
52 Digital_IO_Model
|
||||
53 Digital_Line
|
||||
54 Digital_Primitive
|
||||
55 Digital_MNTYMXDLY
|
||||
56 Digital_IO_LEVEL
|
||||
57 Digital_StdCell
|
||||
58 Digital_File
|
||||
|
||||
105 Cell
|
||||
106 W/L
|
||||
107 PSIZE
|
||||
108 NSIZE
|
||||
109 sheets
|
||||
110 sh#
|
||||
111 Em_Scale
|
||||
112 Epi
|
||||
113 Sinker
|
||||
114 Multi5
|
||||
|
||||
118 AQ
|
||||
119 AQSUB
|
||||
120 ZSIZE
|
||||
121 ESR
|
||||
123 Value2
|
||||
124 COUPLE
|
||||
125 Voltage
|
||||
126 Area1
|
||||
127 Area2
|
||||
128 Area3
|
||||
129 Area4
|
||||
130 Multi1
|
||||
131 Multi2
|
||||
132 Multi3
|
||||
133 Multi4
|
||||
134 DArea
|
||||
135 DPerim
|
||||
136 CArea
|
||||
137 CPerim
|
||||
138 Shrink
|
||||
139 Gate_Resize
|
||||
|
||||
142 BP
|
||||
143 BN
|
||||
144 Sim_Level
|
||||
|
||||
146 G_Voltage
|
||||
|
||||
150 SpiceLine3
|
||||
|
||||
153 D_VOLTAGES
|
||||
|
||||
156 Version
|
||||
157 Comment
|
||||
158 XDef_Sub
|
||||
159 LVS_Area
|
||||
|
||||
162 User1
|
||||
163 User2
|
||||
164 User3
|
||||
165 User4
|
||||
166 User5
|
||||
167 Root
|
||||
168 Class
|
||||
169 Geometry
|
||||
170 WL_Delimiter
|
||||
|
||||
175 T1
|
||||
176 T2
|
||||
|
||||
184 DsgnName
|
||||
185 Designer
|
||||
|
||||
190 RTN
|
||||
191 PWR
|
||||
192 BW
|
||||
|
||||
201 CAPROWS
|
||||
202 CAPCOLS
|
||||
203 NF
|
||||
204 SLICES
|
||||
205 CUR
|
||||
206 TEMPRISE
|
||||
207 STRIPS
|
||||
208 WEM
|
||||
209 LEM
|
||||
210 BASES
|
||||
211 COLS
|
||||
212 XDef_Tub
|
||||
*/
|
||||
default: break;
|
||||
}
|
||||
|
||||
if( field )
|
||||
|
@ -1026,136 +1177,6 @@ void LTSPICE_SCH_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol,
|
|||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreateText( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
/*
|
||||
* TODO
|
||||
*
|
||||
-1 PartNum
|
||||
0 InstName
|
||||
1 Type
|
||||
2 RefName
|
||||
3 Value
|
||||
|
||||
5 QArea
|
||||
|
||||
8 Width
|
||||
9 Length
|
||||
10 Multi
|
||||
|
||||
16 Nec
|
||||
|
||||
38 SpiceModel
|
||||
39 SpiceLine
|
||||
40 SpiceLine2
|
||||
|
||||
47 Def_Sub
|
||||
|
||||
50 Digital_Timing_Model
|
||||
51 Digital_Extracts
|
||||
52 Digital_IO_Model
|
||||
53 Digital_Line
|
||||
54 Digital_Primitive
|
||||
55 Digital_MNTYMXDLY
|
||||
56 Digital_IO_LEVEL
|
||||
57 Digital_StdCell
|
||||
58 Digital_File
|
||||
|
||||
105 Cell
|
||||
106 W/L
|
||||
107 PSIZE
|
||||
108 NSIZE
|
||||
109 sheets
|
||||
110 sh#
|
||||
111 Em_Scale
|
||||
112 Epi
|
||||
113 Sinker
|
||||
114 Multi5
|
||||
|
||||
118 AQ
|
||||
119 AQSUB
|
||||
120 ZSIZE
|
||||
121 ESR
|
||||
123 Value2
|
||||
124 COUPLE
|
||||
125 Voltage
|
||||
126 Area1
|
||||
127 Area2
|
||||
128 Area3
|
||||
129 Area4
|
||||
130 Multi1
|
||||
131 Multi2
|
||||
132 Multi3
|
||||
133 Multi4
|
||||
134 DArea
|
||||
135 DPerim
|
||||
136 CArea
|
||||
137 CPerim
|
||||
138 Shrink
|
||||
139 Gate_Resize
|
||||
|
||||
142 BP
|
||||
143 BN
|
||||
144 Sim_Level
|
||||
|
||||
146 G_Voltage
|
||||
|
||||
150 SpiceLine3
|
||||
|
||||
153 D_VOLTAGES
|
||||
|
||||
156 Version
|
||||
157 Comment
|
||||
158 XDef_Sub
|
||||
159 LVS_Area
|
||||
|
||||
162 User1
|
||||
163 User2
|
||||
164 User3
|
||||
165 User4
|
||||
166 User5
|
||||
167 Root
|
||||
168 Class
|
||||
169 Geometry
|
||||
170 WL_Delimiter
|
||||
|
||||
175 T1
|
||||
176 T2
|
||||
|
||||
184 DsgnName
|
||||
185 Designer
|
||||
|
||||
190 RTN
|
||||
191 PWR
|
||||
192 BW
|
||||
|
||||
201 CAPROWS
|
||||
202 CAPCOLS
|
||||
203 NF
|
||||
204 SLICES
|
||||
205 CUR
|
||||
206 TEMPRISE
|
||||
207 STRIPS
|
||||
208 WEM
|
||||
209 LEM
|
||||
210 BASES
|
||||
211 COLS
|
||||
212 XDef_Tub
|
||||
|
||||
LTSPICE_SCHEMATIC::LT_WINDOW& lt_window = aLTSymbol.Windows[aIndex];
|
||||
|
||||
SCH_TEXT* textItem = new SCH_TEXT( { 0, 0 }, ??? );
|
||||
|
||||
textItem->SetPosition( ToKicadCoords( lt_window.Position ) + m_originOffset );
|
||||
textItem->SetTextSize( ToKicadFontSize( lt_window.FontSize ) );
|
||||
textItem->SetVisible( true );
|
||||
|
||||
aSheet->LastScreen()->Append( textItem );
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void LTSPICE_SCH_PARSER::CreateRect( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex,
|
||||
LIB_SHAPE* aRectangle )
|
||||
{
|
|
@ -32,13 +32,16 @@
|
|||
#include <layer_ids.h>
|
||||
#include <wx/filename.h>
|
||||
#include <plotters/plotter.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <sch_text.h>
|
||||
#include <sch_shape.h>
|
||||
#include <lib_shape.h>
|
||||
#include "ltspice_schematic.h"
|
||||
#include <sch_plugins/lt_spice/ltspice_schematic.h>
|
||||
|
||||
|
||||
class LIB_SHAPE;
|
||||
class LIB_PIN;
|
||||
class SCH_LABEL_BASE;
|
||||
class SCH_SYMBOL;
|
||||
class SCH_TEXT;
|
||||
class SCH_SHAPE;
|
||||
|
||||
/**
|
||||
* The class is been used for loading the asc and asy files in intermediate data structure.
|
||||
* <p>
|
||||
|
@ -67,7 +70,8 @@ public:
|
|||
const int SMALL_LABEL_SIZE = KiROUND( (double) SCH_IU_PER_MM * 0.4 );
|
||||
|
||||
explicit LTSPICE_SCH_PARSER( const wxString& aFilename, LTSPICE_SCHEMATIC* aLTSchematic ) :
|
||||
m_lt_schematic( aLTSchematic )
|
||||
m_lt_schematic( aLTSchematic ),
|
||||
m_powerSymbolIndex( 0 )
|
||||
{ }
|
||||
|
||||
~LTSPICE_SCH_PARSER() {}
|
||||
|
@ -173,14 +177,6 @@ public:
|
|||
*/
|
||||
void CreatePin( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SHEET_PATH* aSheet );
|
||||
|
||||
/**
|
||||
* Method to get Label Shape in kicad
|
||||
*
|
||||
* @param aAscfile object representing asc file.
|
||||
* @param aIndex index.
|
||||
*/
|
||||
LABEL_FLAG_SHAPE GetLabelShape( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex );
|
||||
|
||||
/**
|
||||
* Method for plotting Line from Asc files
|
||||
*
|
||||
|
@ -220,7 +216,8 @@ public:
|
|||
/**
|
||||
* Create schematic text.
|
||||
*/
|
||||
void CreateText( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex, SCH_SHEET_PATH* aSheet );
|
||||
SCH_TEXT* CreateSCH_TEXT( VECTOR2I aOffset, const wxString& aText, int aFontSize,
|
||||
LTSPICE_SCHEMATIC::JUSTIFICATION aJustification );
|
||||
|
||||
/**
|
||||
* Create a schematic wire.
|
||||
|
@ -229,19 +226,23 @@ public:
|
|||
SCH_LAYER_ID aLayer );
|
||||
|
||||
/**
|
||||
* Create a power symbol from an LTspice flag
|
||||
* Create a power symbol.
|
||||
* @param aWires Schematic wires. (Allows us to correctly orient the power symbol.)
|
||||
*/
|
||||
void CreatePowerSymbol( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIndex,
|
||||
SCH_SHEET_PATH* aSheet );
|
||||
SCH_SYMBOL* CreatePowerSymbol( const VECTOR2I& aOffset, const wxString& aValue, int aFontSize,
|
||||
SCH_SHEET_PATH* aSheet,
|
||||
std::vector<LTSPICE_SCHEMATIC::WIRE>& aWires );
|
||||
|
||||
/**
|
||||
* Create a label.
|
||||
* @param aType Currently supported types: SCH_LABEL_T, SCH_DIRECTIVE_LABEL_T
|
||||
*/
|
||||
SCH_LABEL_BASE* CreateSCH_LABEL( KICAD_T aType, const VECTOR2I& aOffset, const wxString& aValue,
|
||||
int aFontSize );
|
||||
|
||||
void CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, SCH_SYMBOL* aSymbol,
|
||||
SCH_SHEET_PATH* aSheet );
|
||||
|
||||
/**
|
||||
* Method for plotting Window(i.e flags which are shown on screen ) from Asy files
|
||||
*/
|
||||
void CreateText( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_SHEET_PATH* aSheet );
|
||||
|
||||
/**
|
||||
* Create a symbol rect.
|
||||
*/
|
||||
|
@ -302,5 +303,6 @@ private:
|
|||
wxFileName m_libraryFileName;
|
||||
VECTOR2I m_originOffset;
|
||||
std::map<wxString, wxString> m_includes;
|
||||
int m_powerSymbolIndex;
|
||||
};
|
||||
#endif // LTSPICE_SCH_PARSER_H
|
|
@ -19,9 +19,9 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sch_plugins/ltSpice/ltspice_schematic.h>
|
||||
#include <sch_plugins/ltSpice/ltspice_sch_plugin.h>
|
||||
#include <sch_plugins/ltSpice/ltspice_sch_parser.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_schematic.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_sch_plugin.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_sch_parser.h>
|
||||
|
||||
#include <schematic.h>
|
||||
#include <sch_sheet.h>
|
|
@ -23,16 +23,16 @@
|
|||
* @brief Loads the asc file and asy files.
|
||||
*/
|
||||
|
||||
#include <sch_plugins/ltSpice/ltspice_schematic.h>
|
||||
#include <sch_plugins/ltSpice/ltspice_sch_parser.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_schematic.h>
|
||||
#include <sch_plugins/lt_spice/ltspice_sch_parser.h>
|
||||
#include <sch_io_mgr.h>
|
||||
#include <sch_screen.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/dir.h>
|
||||
#include <kiplatform/environment.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <schematic.h>
|
||||
#include "wx/dir.h"
|
||||
|
||||
|
||||
void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
||||
|
@ -677,7 +677,7 @@ LTSPICE_SCHEMATIC::LT_SYMBOL LTSPICE_SCHEMATIC::SymbolBuilder( const wxString& a
|
|||
|
||||
lt_symbol.Pins.back().PinAttribute.insert( { name, Value } );
|
||||
}
|
||||
else if( element == "SymbolType" )
|
||||
else if( element == "SYMBOLTYPE" )
|
||||
{
|
||||
tokensSizeRangeCheck( tokens.size(), 2, 2, lineNumber, aAscFileName );
|
||||
|
||||
|
@ -685,20 +685,6 @@ LTSPICE_SCHEMATIC::LT_SYMBOL LTSPICE_SCHEMATIC::SymbolBuilder( const wxString& a
|
|||
|
||||
lt_symbol.SymbolType = getSymbolType( symbolType );
|
||||
}
|
||||
else if( element == "FLAG" )
|
||||
{
|
||||
tokensSizeRangeCheck( tokens.size(), 4, 4, lineNumber, aAscFileName );
|
||||
|
||||
wxString locationPointX = tokens[1];
|
||||
wxString locationPointY = tokens[2];
|
||||
wxString name = tokens[3];
|
||||
|
||||
FLAG flag;
|
||||
flag.Offset = pointCheck( locationPointX, locationPointY, lineNumber, aAscFileName );
|
||||
flag.Value = name;
|
||||
|
||||
aAscFile.Flags.push_back( flag );
|
||||
}
|
||||
|
||||
lineNumber++;
|
||||
}
|
||||
|
@ -796,6 +782,22 @@ std::vector<LTSPICE_SCHEMATIC::LT_ASC> LTSPICE_SCHEMATIC::StructureBuilder()
|
|||
ascFile.Flags.push_back( flag );
|
||||
ascFile.BoundingBox.Merge( flag.Offset );
|
||||
}
|
||||
else if( element == "DATAFLAG" )
|
||||
{
|
||||
tokensSizeRangeCheck( tokens.size(), 4, 4, lineNumber, fileName );
|
||||
|
||||
wxString posX = tokens[1];
|
||||
wxString posY = tokens[2];
|
||||
wxString expression = tokens[3];
|
||||
|
||||
DATAFLAG flag;
|
||||
flag.Offset = pointCheck( posX, posY, lineNumber, fileName );
|
||||
flag.Expression = expression;
|
||||
flag.FontSize = 2;
|
||||
|
||||
ascFile.DataFlags.push_back( flag );
|
||||
ascFile.BoundingBox.Merge( flag.Offset );
|
||||
}
|
||||
else if( element == "WINDOW" )
|
||||
{
|
||||
tokensSizeRangeCheck( tokens.size(), 6, 6, lineNumber, fileName );
|
|
@ -193,9 +193,6 @@ public:
|
|||
VECTOR2I End;
|
||||
};
|
||||
|
||||
/**
|
||||
* A marker. used to specify certain position.
|
||||
*/
|
||||
struct FLAG
|
||||
{
|
||||
VECTOR2I Offset;
|
||||
|
@ -203,6 +200,13 @@ public:
|
|||
wxString Value;
|
||||
};
|
||||
|
||||
struct DATAFLAG
|
||||
{
|
||||
VECTOR2I Offset;
|
||||
int FontSize;
|
||||
wxString Expression;
|
||||
};
|
||||
|
||||
struct TEXT
|
||||
{
|
||||
VECTOR2I Offset;
|
||||
|
@ -261,6 +265,7 @@ public:
|
|||
std::vector<RECTANGLE> Rectangles;
|
||||
std::vector<WIRE> Wires;
|
||||
std::vector<FLAG> Flags;
|
||||
std::vector<DATAFLAG> DataFlags;
|
||||
std::vector<IOPIN> Iopins;
|
||||
std::vector<BUSTAP> Bustap;
|
||||
std::vector<TEXT> Texts;
|
Loading…
Reference in New Issue