Altium sch: Import polyline color
This commit is contained in:
parent
325a6ec8bd
commit
56e4b3b2c3
|
@ -309,24 +309,25 @@ ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps )
|
|||
{
|
||||
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE );
|
||||
|
||||
ownerindex = ReadOwnerIndex( aProps );
|
||||
ownerpartid = ReadOwnerPartId( aProps );
|
||||
ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
|
||||
OwnerIndex = ReadOwnerIndex( aProps );
|
||||
OwnerPartID = ReadOwnerPartId( aProps );
|
||||
OwnerPartDisplayMode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
|
||||
|
||||
int locationCount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 );
|
||||
|
||||
for( int i = 1; i <= locationCount; i++ )
|
||||
{
|
||||
const wxString si = std::to_string( i );
|
||||
points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
|
||||
Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
|
||||
-ReadKiCadUnitFrac( aProps, "Y" + si ) );
|
||||
}
|
||||
|
||||
lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
|
||||
LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
|
||||
Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
|
||||
|
||||
int linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLEEXT", 0 );
|
||||
linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLE", linestyleVar ); // overwrite if present
|
||||
linestyle = linestyleVar >= 0 && linestyleVar <= 3 ?
|
||||
LineStyle = linestyleVar >= 0 && linestyleVar <= 3 ?
|
||||
static_cast<ASCH_POLYLINE_LINESTYLE>( linestyleVar ) :
|
||||
ASCH_POLYLINE_LINESTYLE::SOLID;
|
||||
}
|
||||
|
|
|
@ -354,15 +354,16 @@ enum class ASCH_SHEET_ENTRY_SIDE
|
|||
|
||||
struct ASCH_POLYLINE
|
||||
{
|
||||
int ownerindex;
|
||||
int ownerpartid;
|
||||
int ownerpartdisplaymode;
|
||||
int OwnerIndex;
|
||||
int OwnerPartID;
|
||||
int OwnerPartDisplayMode;
|
||||
|
||||
std::vector<VECTOR2I> points;
|
||||
std::vector<VECTOR2I> Points;
|
||||
|
||||
int lineWidth;
|
||||
int LineWidth;
|
||||
int Color;
|
||||
|
||||
ASCH_POLYLINE_LINESTYLE linestyle;
|
||||
ASCH_POLYLINE_LINESTYLE LineStyle;
|
||||
|
||||
explicit ASCH_POLYLINE( const std::map<wxString, wxString>& aProps );
|
||||
};
|
||||
|
|
|
@ -1194,44 +1194,46 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
|
|||
{
|
||||
ASCH_POLYLINE elem( aProperties );
|
||||
|
||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||
if( elem.OwnerPartID == ALTIUM_COMPONENT_NONE )
|
||||
{
|
||||
SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY );
|
||||
|
||||
for( VECTOR2I& point : elem.points )
|
||||
for( VECTOR2I& point : elem.Points )
|
||||
poly->AddPoint( point + m_sheetOffset );
|
||||
|
||||
poly->SetStroke( STROKE_PARAMS( elem.lineWidth, GetPlotDashType( elem.linestyle ) ) );
|
||||
poly->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ),
|
||||
GetColorFromInt( elem.Color ) ) );
|
||||
poly->SetFlags( IS_NEW );
|
||||
|
||||
m_currentSheet->GetScreen()->Append( poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& libSymbolIt = m_libSymbols.find( elem.ownerindex );
|
||||
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( _( "Polyline's owner (%d) not found." ),
|
||||
elem.ownerindex ),
|
||||
elem.OwnerIndex ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
|
||||
if( !IsComponentPartVisible( elem.OwnerIndex, elem.OwnerPartDisplayMode ) )
|
||||
return;
|
||||
|
||||
SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first );
|
||||
LIB_SHAPE* line = new LIB_SHAPE( libSymbolIt->second, SHAPE_T::POLY );
|
||||
libSymbolIt->second->AddDrawItem( line );
|
||||
|
||||
line->SetUnit( elem.ownerpartid );
|
||||
line->SetUnit( elem.OwnerPartID );
|
||||
|
||||
for( VECTOR2I& point : elem.points )
|
||||
for( VECTOR2I& point : elem.Points )
|
||||
line->AddPoint( GetRelativePosition( point + m_sheetOffset, symbol ) );
|
||||
|
||||
line->SetStroke( STROKE_PARAMS( elem.lineWidth, GetPlotDashType( elem.linestyle ) ) );
|
||||
line->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ),
|
||||
GetColorFromInt( elem.Color ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue