Altium sch: Import circle-like ellipses as circles for now
This commit is contained in:
parent
0b233d593a
commit
758ba5ab18
|
@ -402,6 +402,25 @@ ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps )
|
|||
}
|
||||
|
||||
|
||||
ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps )
|
||||
{
|
||||
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPSE );
|
||||
|
||||
OwnerIndex = ReadOwnerIndex( aProps );
|
||||
OwnerPartID = ReadOwnerPartId( aProps );
|
||||
|
||||
Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
|
||||
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
|
||||
|
||||
Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
|
||||
SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
|
||||
|
||||
AreaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
|
||||
IsNotAccesible = ALTIUM_PARSER::ReadBool( aProps, "ISNOTACCESIBLE", false );
|
||||
IsSolid = ALTIUM_PARSER::ReadBool( aProps, "ISSOLID", false );
|
||||
}
|
||||
|
||||
|
||||
ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps )
|
||||
{
|
||||
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE );
|
||||
|
|
|
@ -407,6 +407,23 @@ struct ASCH_ARC
|
|||
};
|
||||
|
||||
|
||||
struct ASCH_ELLIPSE
|
||||
{
|
||||
int OwnerIndex;
|
||||
int OwnerPartID;
|
||||
|
||||
VECTOR2I Center;
|
||||
int Radius;
|
||||
double SecondaryRadius;
|
||||
|
||||
int AreaColor;
|
||||
bool IsSolid;
|
||||
bool IsNotAccesible;
|
||||
|
||||
explicit ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_LINE
|
||||
{
|
||||
int ownerindex;
|
||||
|
|
|
@ -478,6 +478,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF
|
|||
ParsePolygon( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::ELLIPSE:
|
||||
ParseEllipse( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::PIECHART:
|
||||
break;
|
||||
|
@ -1421,6 +1422,71 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
|
|||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParseEllipse( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_ELLIPSE elem( aProperties );
|
||||
|
||||
// To do: Import true ellipses when KiCad supports them
|
||||
if( elem.Radius != elem.SecondaryRadius )
|
||||
{
|
||||
m_reporter->Report(
|
||||
wxString::Format( _( "Yet unsupported ellipse was not imported at (X = %d; Y = %d)." ),
|
||||
( elem.Center + m_sheetOffset ).x, ( elem.Center + m_sheetOffset ).y ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return;
|
||||
}
|
||||
|
||||
if( elem.OwnerPartID == ALTIUM_COMPONENT_NONE )
|
||||
{
|
||||
SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE );
|
||||
|
||||
circle->SetPosition( elem.Center + m_sheetOffset );
|
||||
circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.Radius, 0 ) );
|
||||
circle->SetStroke( STROKE_PARAMS( 0.1, PLOT_DASH_TYPE::SOLID ) );
|
||||
|
||||
circle->SetFillColor( GetColorFromInt( elem.AreaColor ) );
|
||||
|
||||
if( elem.IsSolid )
|
||||
circle->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
||||
else
|
||||
circle->SetFilled( false );
|
||||
|
||||
m_currentSheet->GetScreen()->Append( circle );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& libSymbolIt = m_libSymbols.find( elem.OwnerIndex );
|
||||
|
||||
if( libSymbolIt == m_libSymbols.end() )
|
||||
{
|
||||
// TODO: e.g. can depend on Template (RECORD=39
|
||||
m_reporter->Report(
|
||||
wxString::Format( _( "Ellipse's owner (%d) not found." ), elem.OwnerIndex ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first );
|
||||
|
||||
LIB_SHAPE* circle = new LIB_SHAPE( libSymbolIt->second, SHAPE_T::CIRCLE );
|
||||
libSymbolIt->second->AddDrawItem( circle );
|
||||
|
||||
circle->SetUnit( elem.OwnerPartID );
|
||||
|
||||
circle->SetPosition( GetRelativePosition( elem.Center + m_sheetOffset, symbol ) );
|
||||
circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.Radius, 0 ) );
|
||||
circle->SetStroke( STROKE_PARAMS( 0.1, PLOT_DASH_TYPE::SOLID ) );
|
||||
|
||||
circle->SetFillColor( GetColorFromInt( elem.AreaColor ) );
|
||||
|
||||
if( elem.IsSolid )
|
||||
circle->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
||||
else
|
||||
circle->SetFilled( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParseLine( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_LINE elem( aProperties );
|
||||
|
|
|
@ -121,6 +121,7 @@ private:
|
|||
void ParsePolygon( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseRoundRectangle( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseArc( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseEllipse( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseLine( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseSignalHarness( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseHarnessConnector( int aIndex, const std::map<wxString, wxString>& aProperties );
|
||||
|
|
Loading…
Reference in New Issue