From 19cfd7bd3a60ee58a764cfba142e49811881b95d Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sat, 10 Oct 2020 16:43:33 +0200 Subject: [PATCH] altium: add non working fix for rounding error --- .../sch_plugins/altium/altium_parser_sch.cpp | 31 +++++++++++++++++++ .../sch_plugins/altium/altium_parser_sch.h | 2 ++ .../sch_plugins/altium/sch_altium_plugin.cpp | 3 ++ 3 files changed, 36 insertions(+) diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.cpp b/eeschema/sch_plugins/altium/altium_parser_sch.cpp index f45db71924..e2294b8f35 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.cpp +++ b/eeschema/sch_plugins/altium/altium_parser_sch.cpp @@ -119,6 +119,37 @@ ASCH_PIN::ASCH_PIN( const std::map& aProperties ) int p = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINLENGTH", 0 ); int pfrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINLENGTH_FRAC", 0 ); pinlength = Altium2KiCadUnit( p, pfrac ); + + // this code calculates the location as required by KiCad without rounding error attached + int kicadX = x; + int kicadXfrac = xfrac; + int kicadY = y; + int kicadYfrac = yfrac; + + switch( orientation ) + { + case ASCH_PIN_ORIENTATION::RIGHTWARDS: + kicadX += p; + kicadXfrac += pfrac; + break; + case ASCH_PIN_ORIENTATION::UPWARDS: + kicadY += p; + kicadYfrac += pfrac; + break; + case ASCH_PIN_ORIENTATION::LEFTWARDS: + kicadX -= p; + kicadXfrac -= pfrac; + break; + case ASCH_PIN_ORIENTATION::DOWNWARDS: + kicadY -= p; + kicadYfrac -= pfrac; + break; + default: + wxLogWarning( "Pin has unexpected orientation" ); + break; + } + kicadLocation = wxPoint( + Altium2KiCadUnit( kicadX, kicadXfrac ), -Altium2KiCadUnit( kicadY, kicadYfrac ) ); } diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.h b/eeschema/sch_plugins/altium/altium_parser_sch.h index 7f8edfb84c..ed118fb7fe 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.h +++ b/eeschema/sch_plugins/altium/altium_parser_sch.h @@ -187,6 +187,8 @@ struct ASCH_PIN wxPoint location; int pinlength; + wxPoint kicadLocation; // location of pin in KiCad without rounding error + bool showPinName; bool showDesignator; diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index a4a25860ff..73df58436e 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -504,7 +504,10 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map& aPropertie break; } + // TODO: position can be sometimes off a little bit! pin->SetPosition( GetRelativePosition( pinLocation, component ) ); + // TODO: the following fix is even worse for now? + // pin->SetPosition( GetRelativePosition( elem.kicadLocation, component ) ); switch( elem.electrical ) {