Altium Plugin updates

Handle Altium multiple display modes (e.g. DeMorgan)
Handle Altium overbar format (o\v\e\r\b\a\r\)
Transform ellipses and elliptical arcs into approximate arcs
Add remaining unknown RECORD ids
This commit is contained in:
Seth Hillbrand 2023-09-04 14:46:25 -07:00
parent 3bd745ee15
commit c7868f0832
6 changed files with 501 additions and 338 deletions

View File

@ -26,7 +26,8 @@
#include <string_utils.h>
#include <lib_id.h>
#include <trigo.h>
#include <math/util.h>
LIB_ID AltiumToKiCadLibID( const wxString& aLibName, const wxString& aLibReference )
{
@ -141,3 +142,76 @@ wxString AltiumSpecialStringsToKiCadVariables( const wxString&
return result;
}
wxString AltiumPinNamesToKiCad( wxString& aString )
{
wxString output;
wxString tempString;
bool hasPrev = false;
wxUniChar prev;
for( wxString::const_iterator it = aString.begin(); it != aString.end(); ++it )
{
char ch = 0;
if( (*it).GetAsChar( &ch ) )
{
if( ch == '\\' )
{
if( hasPrev )
{
tempString += prev;
hasPrev = false;
}
continue; // Backslash is ignored and not added to the output
}
}
if( hasPrev ) // Two letters in a row with no backslash
{
if( !tempString.empty() )
{
output += "~{" + tempString + "}";
tempString.Clear();
}
output += prev;
}
prev = *it;
hasPrev = true;
}
// Append any leftover escaped string
if( !tempString.IsEmpty() )
{
output += "~{" + tempString + "}";
}
if( hasPrev )
{
output += prev;
}
return output;
}
VECTOR2I AltiumGetEllipticalPos( double aMajor, double aMinor, double aAngleRadians )
{
if( aMajor == 0 || aMinor == 0 )
return VECTOR2I( 0, 0 );
double numerator = aMajor * aMinor;
double majorTerm = aMajor * sin( aAngleRadians );
double minorTerm = aMinor * cos( aAngleRadians );
double denominator = sqrt( majorTerm * majorTerm + minorTerm * minorTerm );
double radius = numerator / denominator;
VECTOR2I retval( KiROUND( radius * cos( aAngleRadians ) ), KiROUND( radius * sin( aAngleRadians ) ) );
return retval;
}

View File

@ -31,6 +31,7 @@
#include <lib_id.h>
#include <iostream>
#include <math/vector2d.h>
LIB_ID AltiumToKiCadLibID( const wxString& aLibName, const wxString& aLibReference );
@ -39,4 +40,6 @@ wxString AltiumPropertyToKiCadString( const wxString& aString );
wxString AltiumSpecialStringsToKiCadVariables( const wxString& aString,
const std::map<wxString, wxString>& aOverrides );
wxString AltiumPinNamesToKiCad( wxString& aString );
VECTOR2I AltiumGetEllipticalPos( double aMajor, double aMinor, double aAngleRadians );
#endif //ALTIUM_PARSER_UTILS_H

View File

@ -141,14 +141,12 @@ ASCH_SYMBOL::ASCH_SYMBOL( const std::map<wxString, wxString>& aProps )
}
ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps )
ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PIN );
isKiCadLibPin = ALTIUM_PARSER::ReadBool( aProps, "ISKICADLIBPIN", false );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" );
@ -176,7 +174,9 @@ ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps )
hidden = ( pinconglomerate & 0x04 ) != 0;
showPinName = ( pinconglomerate & 0x08 ) != 0;
showDesignator = ( pinconglomerate & 0x10 ) != 0;
// graphically locked pins are in bit 0x40, but we don't care about that
// 0x20 is unknown
locked = ( pinconglomerate & 0x40 ) != 0;
int x = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.X", 0 );
int xfrac = ALTIUM_PARSER::ReadInt( aProps, "LOCATION.X_FRAC", 0 );
@ -235,6 +235,15 @@ ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps )
}
ASCH_OWNER_INTERFACE::ASCH_OWNER_INTERFACE( const std::map<wxString, wxString>& aProps )
{
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
ownerpartdisplaymode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
}
ASCH_FILL_INTERFACE::ASCH_FILL_INTERFACE( const std::map<wxString, wxString>& aProps )
{
AreaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
@ -255,22 +264,12 @@ ASCH_BORDER_INTERFACE::ASCH_BORDER_INTERFACE( const std::map<wxString, wxString>
Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
}
ASCH_SHAPE_INTERFACE::ASCH_SHAPE_INTERFACE( const std::map<wxString, wxString>& aProps )
{
OwnerIndex = ReadOwnerIndex( aProps );
OwnerPartID = ReadOwnerPartId( aProps );
IndexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
OwnerPartDisplayMode = ALTIUM_PARSER::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
}
ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps )
ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LABEL );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
@ -287,7 +286,8 @@ ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps )
}
ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps )
ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE
|| ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEXT_FRAME );
@ -334,7 +334,7 @@ ASCH_NOTE::ASCH_NOTE( const std::map<wxString, wxString>& aProperties ) :
ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BEZIER );
@ -351,7 +351,7 @@ ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProps ) :
ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE );
@ -376,7 +376,7 @@ ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps ) :
ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_FILL_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
@ -394,7 +394,7 @@ ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProps ) :
ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_FILL_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
@ -411,7 +411,7 @@ ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>&
ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
m_IsElliptical = ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC;
@ -431,7 +431,7 @@ ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_FILL_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
@ -448,7 +448,7 @@ ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps ) :
ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE );
@ -460,11 +460,11 @@ ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps ) :
}
ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps )
ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SIGNAL_HARNESS );
OwnerPartID = ReadOwnerPartId( aProps );
int locationCount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 );
@ -475,18 +475,18 @@ ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aP
-ReadKiCadUnitFrac( aProps, "Y" + si ) );
}
IndexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
}
ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxString>& aProps )
ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_CONNECTOR );
OwnerPartID = ReadOwnerPartId( aProps );
Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
@ -495,13 +495,14 @@ ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxStrin
Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
AreaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
IndexInSheet = 0;
indexinsheet = 0;
LineWidth = 0;;
LocationPrimaryConnectionPosition = 0;
}
ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps )
ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_ENTRY );
@ -509,9 +510,8 @@ ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aPro
// does not exist in altium file!
// ownerindex = ReadOwnerIndex( aProps );
OwnerPartID = ReadOwnerPartId( aProps );
IndexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
DistanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
@ -529,12 +529,12 @@ ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aPro
}
ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps )
ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_TYPE );
//ownerindex = ReadOwnerIndex( aProps ); // use SCH_ALTIUM_PLUGIN::m_harnessEntryParent instead!
OwnerPartID = ReadOwnerPartId( aProps );
Text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
@ -544,14 +544,14 @@ ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps
IsHidden = ALTIUM_PARSER::ReadBool( aProps, "ISHIDDEN", false );
OwnerIndexAdditionalList = ALTIUM_PARSER::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
IndexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
FontID = ALTIUM_PARSER::ReadInt( aProps, "TEXTFONTID", 0 );
}
ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_FILL_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
@ -565,7 +565,8 @@ ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
}
ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps )
ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL );
@ -581,13 +582,11 @@ ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps
}
ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps )
ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_ENTRY );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
// some magic, because it stores those infos in a different unit??
distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
@ -600,11 +599,11 @@ ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps )
}
ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps )
ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT );
ownerpartid = ReadOwnerPartId( aProps );
location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
@ -620,11 +619,11 @@ ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps )
}
ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps )
ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT );
OwnerPartID = ReadOwnerPartId( aProps );
Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
@ -660,7 +659,8 @@ ASCH_NO_ERC::ASCH_NO_ERC( const std::map<wxString, wxString>& aProps )
}
ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps )
ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NET_LABEL );
@ -677,7 +677,8 @@ ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps )
}
ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps )
ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS );
@ -696,7 +697,8 @@ ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps )
}
ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps )
ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE );
@ -715,11 +717,11 @@ ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps )
}
ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps )
ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::JUNCTION );
ownerpartid = ReadOwnerPartId( aProps );
location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
@ -727,7 +729,7 @@ ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps )
ASCH_IMAGE::ASCH_IMAGE( const std::map<wxString, wxString>& aProps ) :
ASCH_SHAPE_INTERFACE( aProps ),
ASCH_OWNER_INTERFACE( aProps ),
ASCH_BORDER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMAGE );
@ -744,7 +746,8 @@ ASCH_IMAGE::ASCH_IMAGE( const std::map<wxString, wxString>& aProps ) :
}
ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProps, int aId )
ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProps, int aId ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
@ -791,7 +794,8 @@ VECTOR2I ASchSheetGetSize( ASCH_SHEET_SIZE aSheetSize )
}
ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps )
ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
@ -806,13 +810,11 @@ ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps )
}
ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps )
ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_NAME );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
@ -825,13 +827,11 @@ ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps )
}
ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps )
ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::FILE_NAME );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
@ -844,13 +844,11 @@ ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps )
}
ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps )
ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::DESIGNATOR );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" );
text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
@ -865,7 +863,8 @@ ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps )
}
ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProps )
ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
@ -877,15 +876,15 @@ ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aP
}
ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps )
ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST );
ownerindex = ReadOwnerIndex( aProps );
}
ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps )
ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS_ENTRY );
@ -896,13 +895,11 @@ ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps )
}
ASCH_PARAMETER::ASCH_PARAMETER( const std::map<wxString, wxString>& aProps )
ASCH_PARAMETER::ASCH_PARAMETER( const std::map<wxString, wxString>& aProps ) :
ASCH_OWNER_INTERFACE( aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PARAMETER );
ownerindex = ReadOwnerIndex( aProps );
ownerpartid = ReadOwnerPartId( aProps );
location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );

View File

@ -94,9 +94,9 @@ enum class ALTIUM_SCH_RECORD
PARAMETER_SET = 43,
IMPLEMENTATION_LIST = 44,
IMPLEMENTATION = 45,
RECORD_46 = 46,
RECORD_47 = 47,
RECORD_48 = 48,
MAP_DEFINER_LIST = 46,
MAP_DEFINER = 47,
IMPL_PARAMS = 48,
NOTE = 209,
COMPILE_MASK = 211,
HARNESS_CONNECTOR = 215,
@ -117,14 +117,14 @@ enum class ASCH_RECORD_ORIENTATION
};
struct ASCH_SHAPE_INTERFACE
struct ASCH_OWNER_INTERFACE
{
int OwnerIndex;
int OwnerPartID;
int OwnerPartDisplayMode;
int IndexInSheet;
int ownerindex;
int ownerpartid;
int ownerpartdisplaymode;
int indexinsheet;
explicit ASCH_SHAPE_INTERFACE( const std::map<wxString, wxString>& aProps );
explicit ASCH_OWNER_INTERFACE( const std::map<wxString, wxString>& aProps );
};
struct ASCH_FILL_INTERFACE
@ -302,12 +302,8 @@ enum class ASCH_PIN_ELECTRICAL
};
struct ASCH_PIN
struct ASCH_PIN : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
int ownerpartdisplaymode;
wxString name;
wxString text;
wxString designator;
@ -329,6 +325,7 @@ struct ASCH_PIN
bool showPinName;
bool showDesignator;
bool hidden;
bool locked;
bool isKiCadLibPin; // Tracking variable to handle LibEdit nuance
@ -360,11 +357,8 @@ enum class ASCH_TEXT_FRAME_ALIGNMENT
};
struct ASCH_LABEL
struct ASCH_LABEL : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
VECTOR2I location;
wxString text;
@ -387,7 +381,7 @@ struct ASCH_HYPERLINK : ASCH_LABEL
};
struct ASCH_TEXT_FRAME
struct ASCH_TEXT_FRAME : ASCH_OWNER_INTERFACE
{
VECTOR2I Location;
wxSize Size;
@ -423,7 +417,7 @@ struct ASCH_NOTE : ASCH_TEXT_FRAME
};
struct ASCH_BEZIER : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_BEZIER : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
{
std::vector<VECTOR2I> points;
@ -449,7 +443,7 @@ enum class ASCH_SHEET_ENTRY_SIDE
};
struct ASCH_POLYLINE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_POLYLINE : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
{
std::vector<VECTOR2I> Points;
@ -459,7 +453,7 @@ struct ASCH_POLYLINE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
};
struct ASCH_POLYGON : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_POLYGON : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
{
std::vector<VECTOR2I> points;
@ -467,7 +461,7 @@ struct ASCH_POLYGON : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INT
};
struct ASCH_ROUND_RECTANGLE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_ROUND_RECTANGLE : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
{
VECTOR2I BottomLeft;
VECTOR2I TopRight;
@ -480,7 +474,7 @@ struct ASCH_ROUND_RECTANGLE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BO
};
struct ASCH_ARC : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_ARC : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
{
bool m_IsElliptical;
VECTOR2I m_Center;
@ -493,7 +487,7 @@ struct ASCH_ARC : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
};
struct ASCH_ELLIPSE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_ELLIPSE : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
{
VECTOR2I Center;
int Radius;
@ -505,7 +499,7 @@ struct ASCH_ELLIPSE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INT
};
struct ASCH_LINE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_LINE : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
{
VECTOR2I point1;
VECTOR2I point2;
@ -514,33 +508,28 @@ struct ASCH_LINE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
};
struct ASCH_SIGNAL_HARNESS
struct ASCH_SIGNAL_HARNESS : ASCH_OWNER_INTERFACE
{
int OwnerPartID; // always -1, can be safely ignored I think
VECTOR2I Point1;
VECTOR2I Point2;
std::vector<VECTOR2I> Points;
int Color;
int IndexInSheet;
int indexinsheet;
int LineWidth;
explicit ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps );
};
struct ASCH_HARNESS_CONNECTOR
struct ASCH_HARNESS_CONNECTOR : ASCH_OWNER_INTERFACE
{
int OwnerPartID; // always -1, can be safely ignored I think
VECTOR2I Location;
VECTOR2I Size;
int AreaColor;
int Color;
int IndexInSheet; // Keeps increasing nicely
int LineWidth;
//int locationX; // keep just in case
//int locationY;
@ -552,17 +541,12 @@ struct ASCH_HARNESS_CONNECTOR
};
struct ASCH_HARNESS_ENTRY
struct ASCH_HARNESS_ENTRY : ASCH_OWNER_INTERFACE
{
// Completely random, mostly this entry exists, but not always, should not be used!
// int ownerindex;
int OwnerPartID; // always -1, can be safely ignored I think
int AreaColor;
int Color;
int DistanceFromTop;
int IndexInSheet;
int indexinsheet;
int TextColor;
int TextFontID;
int TextStyle;
@ -576,13 +560,10 @@ struct ASCH_HARNESS_ENTRY
};
struct ASCH_HARNESS_TYPE
struct ASCH_HARNESS_TYPE : ASCH_OWNER_INTERFACE
{
//int ownerindex; // use SCH_ALTIUM_PLUGIN::m_harnessEntryParent instead!
int OwnerPartID; // Always -1, presumably safe to remuve
int Color;
int IndexInSheet;
int indexinsheet;
int FontID;
bool IsHidden;
@ -596,7 +577,7 @@ struct ASCH_HARNESS_TYPE
};
struct ASCH_RECTANGLE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_RECTANGLE : ASCH_OWNER_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_INTERFACE
{
VECTOR2I BottomLeft;
VECTOR2I TopRight;
@ -607,7 +588,7 @@ struct ASCH_RECTANGLE : ASCH_SHAPE_INTERFACE, ASCH_FILL_INTERFACE, ASCH_BORDER_I
};
struct ASCH_SHEET_SYMBOL
struct ASCH_SHEET_SYMBOL : ASCH_OWNER_INTERFACE
{
VECTOR2I location;
VECTOR2I size;
@ -643,11 +624,8 @@ enum class ASCH_PORT_STYLE
};
struct ASCH_SHEET_ENTRY
struct ASCH_SHEET_ENTRY : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
int distanceFromTop;
ASCH_SHEET_ENTRY_SIDE side;
@ -678,10 +656,8 @@ enum class ASCH_POWER_PORT_STYLE
};
struct ASCH_POWER_PORT
struct ASCH_POWER_PORT : ASCH_OWNER_INTERFACE
{
int ownerpartid;
wxString text;
bool showNetName;
@ -693,10 +669,8 @@ struct ASCH_POWER_PORT
};
struct ASCH_PORT
struct ASCH_PORT : ASCH_OWNER_INTERFACE
{
int OwnerPartID;
wxString Name;
wxString HarnessType;
@ -728,7 +702,7 @@ struct ASCH_NO_ERC
};
struct ASCH_NET_LABEL
struct ASCH_NET_LABEL : ASCH_OWNER_INTERFACE
{
wxString text;
@ -741,9 +715,8 @@ struct ASCH_NET_LABEL
};
struct ASCH_BUS
struct ASCH_BUS : ASCH_OWNER_INTERFACE
{
int indexinsheet;
int lineWidth;
std::vector<VECTOR2I> points;
@ -752,9 +725,8 @@ struct ASCH_BUS
};
struct ASCH_WIRE
struct ASCH_WIRE : ASCH_OWNER_INTERFACE
{
int indexinsheet;
int lineWidth;
std::vector<VECTOR2I> points;
@ -763,17 +735,15 @@ struct ASCH_WIRE
};
struct ASCH_JUNCTION
struct ASCH_JUNCTION : ASCH_OWNER_INTERFACE
{
int ownerpartid;
VECTOR2I location;
explicit ASCH_JUNCTION( const std::map<wxString, wxString>& aProps );
};
struct ASCH_IMAGE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
struct ASCH_IMAGE : ASCH_OWNER_INTERFACE, ASCH_BORDER_INTERFACE
{
wxString filename;
VECTOR2I location;
@ -786,7 +756,7 @@ struct ASCH_IMAGE : ASCH_SHAPE_INTERFACE, ASCH_BORDER_INTERFACE
};
struct ASCH_SHEET_FONT
struct ASCH_SHEET_FONT : ASCH_OWNER_INTERFACE
{
wxString FontName;
@ -836,7 +806,7 @@ enum class ASCH_SHEET_WORKSPACEORIENTATION
};
struct ASCH_SHEET
struct ASCH_SHEET : ASCH_OWNER_INTERFACE
{
std::vector<ASCH_SHEET_FONT> fonts;
@ -847,11 +817,8 @@ struct ASCH_SHEET
};
struct ASCH_SHEET_NAME
struct ASCH_SHEET_NAME : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
wxString text;
ASCH_RECORD_ORIENTATION orientation;
@ -863,11 +830,8 @@ struct ASCH_SHEET_NAME
};
struct ASCH_FILE_NAME
struct ASCH_FILE_NAME : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
wxString text;
ASCH_RECORD_ORIENTATION orientation;
@ -879,11 +843,8 @@ struct ASCH_FILE_NAME
};
struct ASCH_DESIGNATOR
struct ASCH_DESIGNATOR : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
wxString name;
wxString text;
@ -895,10 +856,8 @@ struct ASCH_DESIGNATOR
};
struct ASCH_IMPLEMENTATION
struct ASCH_IMPLEMENTATION : ASCH_OWNER_INTERFACE
{
int ownerindex;
wxString name;
wxString type;
wxString libname;
@ -909,14 +868,13 @@ struct ASCH_IMPLEMENTATION
};
struct ASCH_IMPLEMENTATION_LIST
struct ASCH_IMPLEMENTATION_LIST : ASCH_OWNER_INTERFACE
{
int ownerindex;
explicit ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps );
};
struct ASCH_BUS_ENTRY
struct ASCH_BUS_ENTRY : ASCH_OWNER_INTERFACE
{
VECTOR2I location;
VECTOR2I corner;
@ -925,11 +883,8 @@ struct ASCH_BUS_ENTRY
};
struct ASCH_PARAMETER
struct ASCH_PARAMETER : ASCH_OWNER_INTERFACE
{
int ownerindex;
int ownerpartid;
VECTOR2I location;
ASCH_LABEL_JUSTIFICATION justification;
ASCH_RECORD_ORIENTATION orientation;

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#define _SCH_ALTIUM_PLUGIN_H_
#include <memory>
#include <vector>
#include <sch_io_mgr.h>
#include <wx/filename.h>
#include <wx/gdicmn.h>
@ -45,6 +46,9 @@ class ALTIUM_COMPOUND_FILE;
*
* As with all SCH_PLUGINs there is no UI dependencies i.e. windowing calls allowed.
*/
static std::vector<LIB_SYMBOL*> nullsym;
class SCH_ALTIUM_PLUGIN : public SCH_PLUGIN
{
public:
@ -126,28 +130,28 @@ private:
bool IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const;
const ASCH_STORAGE_FILE* GetFileFromStorage( const wxString& aFilename ) const;
void AddTextBox( const ASCH_TEXT_FRAME* aElem );
void AddLibTextBox( const ASCH_TEXT_FRAME* aElem, LIB_SYMBOL* aLibSymbol = nullptr );
void AddLibTextBox( const ASCH_TEXT_FRAME* aElem, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseComponent( int aIndex, const std::map<wxString, wxString>& aProperties );
void ParsePin( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseLabel( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseTextFrame( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParsePin( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseLabel( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseTextFrame( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseNote( const std::map<wxString, wxString>& aProperties );
void ParseBezier( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParsePolyline( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParsePolygon( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseRoundRectangle( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseArc( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseEllipse( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseCircle( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseLine( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseBezier( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParsePolyline( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParsePolygon( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseRoundRectangle( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseArc( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseEllipse( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseCircle( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseLine( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseSignalHarness( const std::map<wxString, wxString>& aProperties );
void ParseHarnessConnector( int aIndex, const std::map<wxString, wxString>& aProperties );
void ParseHarnessEntry( const std::map<wxString, wxString>& aProperties );
void ParseHarnessType( const std::map<wxString, wxString>& aProperties );
void ParseHarnessPort( const ASCH_PORT& aElem );
void ParseHyperlink( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseRectangle( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseHyperlink( 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 );
void ParsePowerPort( const std::map<wxString, wxString>& aProperties );
@ -161,15 +165,15 @@ private:
void ParseSheet( const std::map<wxString, wxString>& aProperties );
void ParseSheetName( const std::map<wxString, wxString>& aProperties );
void ParseFileName( const std::map<wxString, wxString>& aProperties );
void ParseDesignator( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseDesignator( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseBusEntry( const std::map<wxString, wxString>& aProperties );
void ParseParameter( const std::map<wxString, wxString>& aProperties, LIB_SYMBOL* aLibSymbol = nullptr );
void ParseParameter( const std::map<wxString, wxString>& aProperties, std::vector<LIB_SYMBOL*>& aSymbol = nullsym);
void ParseImplementationList( int aIndex, const std::map<wxString, wxString>& aProperties );
void ParseImplementation( const std::map<wxString, wxString>& aProperties );
void ParseLibHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchFile, wxArrayString& aLibNames );
std::map<wxString,LIB_SYMBOL*> ParseLibFile( const ALTIUM_COMPOUND_FILE& aAltiumSchFile );
LIB_SYMBOL* ParseLibComponent( const std::map<wxString, wxString>& aProperties );
std::vector<LIB_SYMBOL*> ParseLibComponent( const std::map<wxString, wxString>& aProperties );
private:
REPORTER* m_reporter; // current reporter for warnings/errors
@ -212,6 +216,9 @@ private:
std::map<wxString, long long> m_timestamps;
std::map<wxString, std::map<wxString, LIB_SYMBOL*>> m_libCache;
// List of available fonts with font name and font size in pt
std::vector<std::pair<wxString, int>> m_fonts;
};
#endif // _SCH_ALTIUM_PLUGIN_H_