altium: initial version for rounded rectangle (without rounded corners for now)

This commit is contained in:
Thomas Pointhuber 2020-10-14 21:15:09 +02:00 committed by Jon Evans
parent 9199d1ff63
commit 79a02d7997
4 changed files with 124 additions and 0 deletions

View File

@ -227,6 +227,32 @@ ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProperties )
}
ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProperties )
{
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::RECTANGLE );
ownerindex =
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
ownerpartid =
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE );
bottomLeft = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ),
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
topRight = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNER.X" ),
-PropertiesReadKiCadUnitFrac( aProperties, "CORNER.Y" ) );
topRight = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "CORNERXRADIUS" ),
-PropertiesReadKiCadUnitFrac( aProperties, "CORNERYRADIUS" ) );
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 );
}
ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProperties )
{
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::ARC );

View File

@ -251,6 +251,27 @@ struct ASCH_POLYGON
};
struct ASCH_ROUND_RECTANGLE
{
int ownerindex;
int ownerpartid;
wxPoint bottomLeft;
wxPoint topRight;
wxSize cornerradius;
int lineWidth;
bool isSolid;
bool isTransparent;
int color;
int areacolor;
explicit ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProperties );
};
struct ASCH_ARC
{
int ownerindex;

View File

@ -323,6 +323,7 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
case ALTIUM_SCH_RECORD::PIECHART:
break;
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
ParseRoundRectangle( properties );
break;
case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
break;
@ -821,6 +822,81 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aPrope
}
void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map<wxString, wxString>& aProperties )
{
ASCH_ROUND_RECTANGLE elem( aProperties );
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
{
const wxPoint topLeft = { elem.bottomLeft.x, elem.topRight.y };
const wxPoint bottomRight = { elem.topRight.x, elem.bottomLeft.y };
// TODO: we cannot fill this rectangle, only draw it for now
// TODO: misses rounded edges
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 );
}
else
{
const auto& symbol = m_symbols.find( elem.ownerindex );
if( symbol == m_symbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
wxLogWarning( wxString::Format(
"Rounded Rectangle tries to access symbol with ownerindex %d which does not exist",
elem.ownerindex ) );
return;
}
const auto& component = m_components.at( symbol->first );
// TODO: misses rounded edges
LIB_RECTANGLE* rect = new LIB_RECTANGLE( symbol->second );
symbol->second->AddDrawItem( rect );
rect->SetPosition( GetRelativePosition( elem.topRight, component ) );
rect->SetEnd( GetRelativePosition( elem.bottomLeft, component ) );
rect->SetWidth( elem.lineWidth );
if( elem.isSolid )
{
if( elem.color == elem.areacolor )
rect->SetFillMode( FILLED_SHAPE );
else
rect->SetFillMode( FILLED_WITH_BG_BODYCOLOR );
}
else
{
rect->SetFillMode( NO_FILL );
}
}
}
void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aProperties )
{
ASCH_ARC elem( aProperties );

View File

@ -103,6 +103,7 @@ private:
void ParseBezier( const std::map<wxString, wxString>& aProperties );
void ParsePolyline( const std::map<wxString, wxString>& aProperties );
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 ParseLine( const std::map<wxString, wxString>& aProperties );
void ParseRectangle( const std::map<wxString, wxString>& aProperties );