altium: fix line style and filling

This commit is contained in:
Thomas Pointhuber 2020-10-14 21:04:53 +02:00 committed by Jon Evans
parent 06df80a88d
commit 9199d1ff63
4 changed files with 70 additions and 13 deletions

View File

@ -144,7 +144,10 @@ bool ALTIUM_PARSER::PropertiesReadBool(
const std::map<wxString, wxString>& aProperties, const wxString& aKey, bool aDefault )
{
const std::map<wxString, wxString>::const_iterator& value = aProperties.find( aKey );
return value == aProperties.end() ? aDefault : value->second == "TRUE";
if( value == aProperties.end() )
return aDefault;
else
return value->second == "T" || value->second == "TRUE";
}
int32_t ALTIUM_PARSER::PropertiesReadKicadUnit( const std::map<wxString, wxString>& aProperties,

View File

@ -192,6 +192,13 @@ ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProperties )
}
lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" );
int linestyleVar = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LINESTYLEEXT", 0 );
linestyleVar = ALTIUM_PARSER::PropertiesReadInt(
aProperties, "LINESTYLE", linestyleVar ); // overwrite if present
linestyle = linestyleVar >= 0 && linestyleVar <= 3 ?
static_cast<ASCH_POLYLINE_LINESTYLE>( linestyleVar ) :
ASCH_POLYLINE_LINESTYLE::SOLID;
}
@ -214,6 +221,9 @@ ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProperties )
lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" );
isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false );
color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 );
areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 );
}
@ -272,6 +282,9 @@ ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProperties
lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" );
isSolid = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISSOLID", false );
isTransparent = ALTIUM_PARSER::PropertiesReadBool( aProperties, "TRANSPARENT", false );
color = ALTIUM_PARSER::PropertiesReadInt( aProperties, "COLOR", 0 );
areacolor = ALTIUM_PARSER::PropertiesReadInt( aProperties, "AREACOLOR", 0 );
}

View File

@ -210,6 +210,15 @@ struct ASCH_BEZIER
};
enum class ASCH_POLYLINE_LINESTYLE
{
SOLID = 0,
DASHED = 1,
DOTTED = 2,
DASH_DOTTED = 3
};
struct ASCH_POLYLINE
{
int ownerindex;
@ -219,6 +228,8 @@ struct ASCH_POLYLINE
int lineWidth;
ASCH_POLYLINE_LINESTYLE linestyle;
explicit ASCH_POLYLINE( const std::map<wxString, wxString>& aProperties );
};
@ -233,6 +244,9 @@ struct ASCH_POLYGON
int lineWidth;
bool isSolid;
int color;
int areacolor;
explicit ASCH_POLYGON( const std::map<wxString, wxString>& aProperties );
};
@ -279,6 +293,9 @@ struct ASCH_RECTANGLE
bool isSolid;
bool isTransparent;
int color;
int areacolor;
explicit ASCH_RECTANGLE( const std::map<wxString, wxString>& aProperties );
};

View File

@ -620,6 +620,7 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
SCH_LINE* line = new SCH_LINE( elem.points.at( i ), SCH_LAYER_ID::LAYER_NOTES );
line->SetEndPoint( elem.points.at( i + 1 ) );
line->SetLineWidth( elem.lineWidth );
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
line->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( line );
@ -702,11 +703,30 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
{
PLOT_DASH_TYPE dashType = PLOT_DASH_TYPE::DEFAULT;
switch( elem.linestyle )
{
default:
case ASCH_POLYLINE_LINESTYLE::SOLID:
dashType = PLOT_DASH_TYPE::SOLID;
break;
case ASCH_POLYLINE_LINESTYLE::DASHED:
dashType = PLOT_DASH_TYPE::DASH;
break;
case ASCH_POLYLINE_LINESTYLE::DOTTED:
dashType = PLOT_DASH_TYPE::DOT;
break;
case ASCH_POLYLINE_LINESTYLE::DASH_DOTTED:
dashType = PLOT_DASH_TYPE::DASHDOT;
break;
}
for( size_t i = 0; i < elem.points.size() - 1; i++ )
{
SCH_LINE* line = new SCH_LINE( elem.points.at( i ), SCH_LAYER_ID::LAYER_NOTES );
line->SetEndPoint( elem.points.at( i + 1 ) );
line->SetLineWidth( elem.lineWidth );
line->SetLineStyle( dashType );
line->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( line );
@ -751,6 +771,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
SCH_LINE* line = new SCH_LINE( elem.points.at( i ), SCH_LAYER_ID::LAYER_NOTES );
line->SetEndPoint( elem.points.at( i + 1 ) );
line->SetLineWidth( elem.lineWidth );
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
line->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( line );
@ -760,6 +781,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
SCH_LINE* line = new SCH_LINE( elem.points.front(), SCH_LAYER_ID::LAYER_NOTES );
line->SetEndPoint( elem.points.back() );
line->SetLineWidth( elem.lineWidth );
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
line->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( line );
@ -781,7 +803,6 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
symbol->second->AddDrawItem( line );
// TODO: we cannot fill this polygon, only draw it for now?
for( wxPoint& point : elem.points )
{
line->AddPoint( GetRelativePosition( point, component ) );
@ -789,10 +810,13 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
line->AddPoint( GetRelativePosition( elem.points.front(), component ) );
line->SetWidth( elem.lineWidth );
if( elem.isSolid )
{
if( !elem.isSolid )
line->SetFillMode( FILL_TYPE::NO_FILL );
else if( elem.color == elem.areacolor )
line->SetFillMode( FILL_TYPE::FILLED_SHAPE );
}
else
line->SetFillMode( FILL_TYPE::FILLED_WITH_BG_BODYCOLOR );
}
}
@ -853,6 +877,7 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map<wxString, wxString>& aProperti
SCH_LINE* line = new SCH_LINE( elem.point1, SCH_LAYER_ID::LAYER_NOTES );
line->SetEndPoint( elem.point2 );
line->SetLineWidth( elem.lineWidth );
line->SetLineStyle( PLOT_DASH_TYPE::SOLID ); // TODO?
line->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( line );
@ -895,24 +920,28 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aPro
SCH_LINE* lineTop = new SCH_LINE( elem.topRight, SCH_LAYER_ID::LAYER_NOTES );
lineTop->SetEndPoint( topLeft );
lineTop->SetLineWidth( elem.lineWidth );
lineTop->SetLineStyle( PLOT_DASH_TYPE::SOLID );
lineTop->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( lineTop );
SCH_LINE* lineBottom = new SCH_LINE( elem.bottomLeft, SCH_LAYER_ID::LAYER_NOTES );
lineBottom->SetEndPoint( bottomRight );
lineBottom->SetLineWidth( elem.lineWidth );
lineBottom->SetLineStyle( PLOT_DASH_TYPE::SOLID );
lineBottom->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( lineBottom );
SCH_LINE* lineRight = new SCH_LINE( elem.topRight, SCH_LAYER_ID::LAYER_NOTES );
lineRight->SetEndPoint( bottomRight );
lineRight->SetLineWidth( elem.lineWidth );
lineRight->SetLineStyle( PLOT_DASH_TYPE::SOLID );
lineRight->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( lineRight );
SCH_LINE* lineLeft = new SCH_LINE( elem.bottomLeft, SCH_LAYER_ID::LAYER_NOTES );
lineLeft->SetEndPoint( topLeft );
lineLeft->SetLineWidth( elem.lineWidth );
lineLeft->SetLineStyle( PLOT_DASH_TYPE::SOLID );
lineLeft->SetFlags( IS_NEW );
m_currentSheet->GetScreen()->Append( lineLeft );
}
@ -935,20 +964,15 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aPro
rect->SetPosition( GetRelativePosition( elem.topRight, component ) );
rect->SetEnd( GetRelativePosition( elem.bottomLeft, component ) );
rect->SetWidth( elem.lineWidth );
if( elem.isTransparent )
{
if( !elem.isSolid )
rect->SetFillMode( FILL_TYPE::NO_FILL );
}
else if( elem.isSolid )
{
else if( elem.color == elem.areacolor )
rect->SetFillMode( FILL_TYPE::FILLED_SHAPE );
}
else
{
rect->SetFillMode( FILL_TYPE::FILLED_WITH_BG_BODYCOLOR );
}
}
}
void SCH_ALTIUM_PLUGIN::ParseNetLabel( const std::map<wxString, wxString>& aProperties )