ADDED: Handle PIECHART in Altium import
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16895
(cherry picked from commit 5bd94f118d
)
This commit is contained in:
parent
e308d65108
commit
489f345fb2
|
@ -460,7 +460,8 @@ ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>&
|
|||
|
||||
ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
|
||||
ASCH_OWNER_INTERFACE( aProps ),
|
||||
ASCH_BORDER_INTERFACE( aProps )
|
||||
ASCH_BORDER_INTERFACE( aProps ),
|
||||
ASCH_FILL_INTERFACE( aProps )
|
||||
{
|
||||
m_IsElliptical = ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC;
|
||||
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ARC || m_IsElliptical );
|
||||
|
@ -478,6 +479,11 @@ ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
|
|||
}
|
||||
|
||||
|
||||
ASCH_PIECHART::ASCH_PIECHART( const std::map<wxString, wxString>& aProps ) :
|
||||
ASCH_ARC( aProps )
|
||||
{}
|
||||
|
||||
|
||||
ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps ) :
|
||||
ASCH_OWNER_INTERFACE( aProps ),
|
||||
ASCH_FILL_INTERFACE( aProps ),
|
||||
|
|
|
@ -482,7 +482,7 @@ struct ASCH_ROUND_RECTANGLE : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BO
|
|||
};
|
||||
|
||||
|
||||
struct ASCH_ARC : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
|
||||
struct ASCH_ARC : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE, ASCH_FILL_INTERFACE
|
||||
{
|
||||
bool m_IsElliptical;
|
||||
VECTOR2I m_Center;
|
||||
|
@ -495,6 +495,12 @@ struct ASCH_ARC : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
|
|||
};
|
||||
|
||||
|
||||
struct ASCH_PIECHART : ASCH_ARC
|
||||
{
|
||||
explicit ASCH_PIECHART( const std::map<wxString, wxString>& aProps );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_ELLIPSE : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
|
||||
{
|
||||
VECTOR2I Center;
|
||||
|
|
|
@ -897,7 +897,7 @@ void SCH_IO_ALTIUM::ParseRecord( int index, std::map<wxString, wxString>& proper
|
|||
break;
|
||||
|
||||
case ALTIUM_SCH_RECORD::PIECHART:
|
||||
m_reporter->Report( _( "Record 'PIECHART' not handled." ), RPT_SEVERITY_INFO );
|
||||
ParsePieChart( properties );
|
||||
break;
|
||||
|
||||
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
|
||||
|
@ -2156,7 +2156,9 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
|
|||
|
||||
circle->SetPosition( elem.m_Center + m_sheetOffset );
|
||||
circle->SetEnd( circle->GetPosition() + VECTOR2I( arc_radius, 0 ) );
|
||||
circle->SetStroke( STROKE_PARAMS( elem.LineWidth, LINE_STYLE::SOLID ) );
|
||||
|
||||
SetSchShapeLine( elem, circle );
|
||||
SetSchShapeFillAndColor( elem, circle );
|
||||
|
||||
currentScreen->Append( circle );
|
||||
}
|
||||
|
@ -2172,7 +2174,8 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
|
|||
arc->SetStart( elem.m_Center + startOffset + m_sheetOffset );
|
||||
arc->SetArcAngleAndEnd( includedAngle.Normalize(), true );
|
||||
|
||||
arc->SetStroke( STROKE_PARAMS( elem.LineWidth, LINE_STYLE::SOLID ) );
|
||||
SetSchShapeLine( elem, arc );
|
||||
SetSchShapeFillAndColor( elem, arc );
|
||||
|
||||
currentScreen->Append( arc );
|
||||
}
|
||||
|
@ -2218,6 +2221,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
|
|||
|
||||
circle->SetEnd( circle->GetPosition() + VECTOR2I( arc_radius, 0 ) );
|
||||
SetLibShapeLine( elem, circle, ALTIUM_SCH_RECORD::ARC );
|
||||
SetLibShapeFillAndColor( elem, circle, ALTIUM_SCH_RECORD::ARC, elem.Color );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2245,6 +2249,7 @@ void SCH_IO_ALTIUM::ParseArc( const std::map<wxString, wxString>& aProperties,
|
|||
arc->SetArcAngleAndEnd( includedAngle.Normalize(), true );
|
||||
|
||||
SetLibShapeLine( elem, arc, ALTIUM_SCH_RECORD::ARC );
|
||||
SetLibShapeFillAndColor( elem, arc, ALTIUM_SCH_RECORD::ARC, elem.Color );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2345,6 +2350,92 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map<wxString, wxString>& aPro
|
|||
}
|
||||
|
||||
|
||||
void SCH_IO_ALTIUM::ParsePieChart( const std::map<wxString, wxString>& aProperties,
|
||||
std::vector<LIB_SYMBOL*>& aSymbol )
|
||||
{
|
||||
ParseArc( aProperties, aSymbol );
|
||||
|
||||
ASCH_PIECHART elem( aProperties );
|
||||
|
||||
int arc_radius = elem.m_Radius;
|
||||
VECTOR2I center = elem.m_Center;
|
||||
EDA_ANGLE startAngle( elem.m_EndAngle, DEGREES_T );
|
||||
EDA_ANGLE endAngle( elem.m_StartAngle, DEGREES_T );
|
||||
VECTOR2I startOffset( KiROUND( arc_radius * startAngle.Cos() ),
|
||||
-KiROUND( arc_radius * startAngle.Sin() ) );
|
||||
VECTOR2I endOffset( KiROUND( arc_radius * endAngle.Cos() ),
|
||||
-KiROUND( arc_radius * endAngle.Sin() ) );
|
||||
|
||||
if( aSymbol.empty() && ShouldPutItemOnSheet( elem.ownerindex ) )
|
||||
{
|
||||
SCH_SCREEN* screen = getCurrentScreen();
|
||||
wxCHECK( screen, /* void */ );
|
||||
|
||||
// close polygon
|
||||
SCH_LINE* line = new SCH_LINE( center + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
|
||||
line->SetEndPoint( center + startOffset + m_sheetOffset );
|
||||
line->SetStroke( STROKE_PARAMS( elem.LineWidth, LINE_STYLE::SOLID ) );
|
||||
|
||||
line->SetFlags( IS_NEW );
|
||||
screen->Append( line );
|
||||
|
||||
line = new SCH_LINE( center + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
|
||||
line->SetEndPoint( center + endOffset + m_sheetOffset );
|
||||
line->SetStroke( STROKE_PARAMS( elem.LineWidth, LINE_STYLE::SOLID ) );
|
||||
|
||||
line->SetFlags( IS_NEW );
|
||||
screen->Append( line );
|
||||
}
|
||||
else
|
||||
{
|
||||
LIB_SYMBOL* symbol = (int) aSymbol.size() <= elem.ownerpartdisplaymode
|
||||
? nullptr
|
||||
: aSymbol[elem.ownerpartdisplaymode];
|
||||
SCH_SYMBOL* schsym = nullptr;
|
||||
|
||||
if( !symbol )
|
||||
{
|
||||
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( wxT( "Piechart's owner (%d) not found." ),
|
||||
elem.ownerindex ),
|
||||
RPT_SEVERITY_DEBUG );
|
||||
return;
|
||||
}
|
||||
|
||||
symbol = libSymbolIt->second;
|
||||
schsym = m_symbols.at( libSymbolIt->first );
|
||||
}
|
||||
|
||||
if( aSymbol.empty() && !IsComponentPartVisible( elem ) )
|
||||
return;
|
||||
|
||||
SCH_SHAPE* line = new SCH_SHAPE( SHAPE_T::POLY, LAYER_DEVICE );
|
||||
symbol->AddDrawItem( line, false );
|
||||
|
||||
line->SetUnit( std::max( 0, elem.ownerpartid ) );
|
||||
|
||||
if( !schsym )
|
||||
{
|
||||
line->AddPoint( center + startOffset );
|
||||
line->AddPoint( center );
|
||||
line->AddPoint( center + endOffset );
|
||||
}
|
||||
else
|
||||
{
|
||||
line->AddPoint( GetRelativePosition( center + startOffset + m_sheetOffset, schsym ) );
|
||||
line->AddPoint( GetRelativePosition( center + m_sheetOffset, schsym ) );
|
||||
line->AddPoint( GetRelativePosition( center + endOffset + m_sheetOffset, schsym ) );
|
||||
}
|
||||
|
||||
SetLibShapeLine( elem, line, ALTIUM_SCH_RECORD::LINE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_ALTIUM::ParseEllipse( const std::map<wxString, wxString>& aProperties,
|
||||
std::vector<LIB_SYMBOL*>& aSymbol )
|
||||
{
|
||||
|
@ -4214,6 +4305,8 @@ std::map<wxString,LIB_SYMBOL*> SCH_IO_ALTIUM::ParseLibFile( const ALTIUM_COMPOUN
|
|||
|
||||
case ALTIUM_SCH_RECORD::ELLIPSE: ParseEllipse( properties, symbols ); break;
|
||||
|
||||
case ALTIUM_SCH_RECORD::PIECHART: ParsePieChart( properties, symbols ); break;
|
||||
|
||||
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE: ParseRoundRectangle( properties, symbols ); break;
|
||||
|
||||
case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC: ParseEllipticalArc( properties, symbols ); break;
|
||||
|
|
|
@ -152,6 +152,7 @@ private:
|
|||
void ParseHarnessType( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseHarnessPort( const ASCH_PORT& aElem );
|
||||
void ParseHyperlink( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
|
||||
void ParsePieChart( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
|
||||
void ParseRectangle( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
|
||||
void ParseSheetSymbol( int aIndex, const std::map<wxString, wxString>& aProperties );
|
||||
void ParseSheetEntry( const std::map<wxString, wxString>& aProperties );
|
||||
|
|
Loading…
Reference in New Issue