altium: add support for bezier (symbol only) and polyline
This commit is contained in:
parent
19cfd7bd3a
commit
fa8208182a
|
@ -153,6 +153,48 @@ ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProperties )
|
|||
}
|
||||
|
||||
|
||||
ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::BEZIER );
|
||||
|
||||
ownerindex =
|
||||
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
|
||||
ownerpartid =
|
||||
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE );
|
||||
|
||||
int locationCount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 );
|
||||
for( int i = 1; i <= locationCount; i++ )
|
||||
{
|
||||
const wxString si = std::to_string( i );
|
||||
points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ),
|
||||
-PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) );
|
||||
}
|
||||
|
||||
lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" );
|
||||
}
|
||||
|
||||
|
||||
ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::POLYLINE );
|
||||
|
||||
ownerindex =
|
||||
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
|
||||
ownerpartid =
|
||||
ALTIUM_PARSER::PropertiesReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE );
|
||||
|
||||
int locationCount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "LOCATIONCOUNT", 0 );
|
||||
for( int i = 1; i <= locationCount; i++ )
|
||||
{
|
||||
const wxString si = std::to_string( i );
|
||||
points.emplace_back( PropertiesReadKiCadUnitFrac( aProperties, "X" + si ),
|
||||
-PropertiesReadKiCadUnitFrac( aProperties, "Y" + si ) );
|
||||
}
|
||||
|
||||
lineWidth = PropertiesReadKiCadUnitFrac( aProperties, "LINEWIDTH" );
|
||||
}
|
||||
|
||||
|
||||
ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::POLYGON );
|
||||
|
|
|
@ -196,6 +196,32 @@ struct ASCH_PIN
|
|||
};
|
||||
|
||||
|
||||
struct ASCH_BEZIER
|
||||
{
|
||||
int ownerindex;
|
||||
int ownerpartid;
|
||||
|
||||
std::vector<wxPoint> points;
|
||||
|
||||
int lineWidth;
|
||||
|
||||
explicit ASCH_BEZIER( const std::map<wxString, wxString>& aProperties );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_POLYLINE
|
||||
{
|
||||
int ownerindex;
|
||||
int ownerpartid;
|
||||
|
||||
std::vector<wxPoint> points;
|
||||
|
||||
int lineWidth;
|
||||
|
||||
explicit ASCH_POLYLINE( const std::map<wxString, wxString>& aProperties );
|
||||
};
|
||||
|
||||
|
||||
struct ASCH_POLYGON
|
||||
{
|
||||
int ownerindex;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <schematic.h>
|
||||
|
||||
#include <lib_arc.h>
|
||||
#include <lib_bezier.h>
|
||||
#include <lib_circle.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_item.h>
|
||||
|
@ -308,8 +309,10 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
|||
case ALTIUM_SCH_RECORD::LABEL:
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::BEZIER:
|
||||
ParseBezier( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::POLYLINE:
|
||||
ParsePolyline( properties );
|
||||
break;
|
||||
case ALTIUM_SCH_RECORD::POLYGON:
|
||||
ParsePolygon( properties );
|
||||
|
@ -591,6 +594,83 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
|
|||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_BEZIER elem( aProperties );
|
||||
|
||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||
{
|
||||
wxLogError( "Bezier drawing is not possible for now on schematic." );
|
||||
}
|
||||
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(
|
||||
"Rectangle tries to access symbol with ownerindex %d which does not exist",
|
||||
elem.ownerindex ) );
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& component = m_components.at( symbol->first );
|
||||
|
||||
LIB_BEZIER* bezier = new LIB_BEZIER( symbol->second );
|
||||
symbol->second->AddDrawItem( bezier );
|
||||
|
||||
for( wxPoint& point : elem.points )
|
||||
{
|
||||
bezier->AddPoint( GetRelativePosition( point, component ) );
|
||||
}
|
||||
|
||||
bezier->SetWidth( elem.lineWidth );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_POLYLINE elem( aProperties );
|
||||
|
||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||
{
|
||||
for( int i = 0; i < (int) 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->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( line );
|
||||
}
|
||||
}
|
||||
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(
|
||||
"Rectangle tries to access symbol with ownerindex %d which does not exist",
|
||||
elem.ownerindex ) );
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& component = m_components.at( symbol->first );
|
||||
|
||||
LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
|
||||
symbol->second->AddDrawItem( line );
|
||||
|
||||
for( wxPoint& point : elem.points )
|
||||
{
|
||||
line->AddPoint( GetRelativePosition( point, component ) );
|
||||
}
|
||||
|
||||
line->SetWidth( elem.lineWidth );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_POLYGON elem( aProperties );
|
||||
|
|
|
@ -100,6 +100,8 @@ public:
|
|||
private:
|
||||
void ParseComponent( int index, const std::map<wxString, wxString>& aProperties );
|
||||
void ParsePin( const std::map<wxString, wxString>& aProperties );
|
||||
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 ParseRectangle( const std::map<wxString, wxString>& aProperties );
|
||||
void ParseNetLabel( const std::map<wxString, wxString>& aProperties );
|
||||
|
|
Loading…
Reference in New Issue