CADSTAR Schematic Archive Importer: Fix orientation of components
- Fix the logic for the orientation of mirrored components - Fix loading of angles/orientations from earlier versions of CADSTAR
This commit is contained in:
parent
49a2926a34
commit
cba45ea257
|
@ -964,11 +964,26 @@ SCH_COMPONENT* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(
|
|||
|
||||
component->SetPosition( getKiCadPoint( aCadstarSymbol.Origin ) );
|
||||
|
||||
int compOrientation =
|
||||
getComponentOrientation( aCadstarSymbol.OrientAngle, aComponentOrientationDeciDeg );
|
||||
double compAngleDeciDeg = getAngleTenthDegree( aCadstarSymbol.OrientAngle );
|
||||
int compOrientation = 0;
|
||||
|
||||
if( aCadstarSymbol.Mirror )
|
||||
{
|
||||
compAngleDeciDeg = -compAngleDeciDeg;
|
||||
compOrientation += COMPONENT_ORIENTATION_T::CMP_MIRROR_Y;
|
||||
}
|
||||
|
||||
compOrientation += getComponentOrientation( compAngleDeciDeg, aComponentOrientationDeciDeg );
|
||||
|
||||
if( NormalizeAngle180( compAngleDeciDeg ) != NormalizeAngle180( aComponentOrientationDeciDeg ) )
|
||||
{
|
||||
wxLogError(
|
||||
wxString::Format( _( "Symbol '%s' is rotated by an angle of %.1f degrees in the "
|
||||
"original CADSTAR design but KiCad only supports rotation "
|
||||
"angles multiples of 90 degrees. The connecting wires will "
|
||||
"need manual fixing." ),
|
||||
aCadstarSymbol.ComponentRef.Designator, compAngleDeciDeg / 10.0 ) );
|
||||
}
|
||||
|
||||
component->SetOrientation( compOrientation );
|
||||
LIB_ID libId( mLibraryFileName.GetName(), aKiCadPart->GetName() );
|
||||
|
@ -1023,11 +1038,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute(
|
|||
|
||||
|
||||
int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation(
|
||||
long long aCadstarOrientAngle, double& aReturnedOrientationDeciDeg )
|
||||
double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg )
|
||||
{
|
||||
int compOrientation = COMPONENT_ORIENTATION_T::CMP_ORIENT_0;
|
||||
|
||||
int oDeg = (int) NormalizeAngle180( getAngleTenthDegree( aCadstarOrientAngle ) );
|
||||
int oDeg = (int) NormalizeAngle180( aOrientAngleDeciDeg );
|
||||
|
||||
if( oDeg >= -450 && oDeg <= 450 )
|
||||
{
|
||||
|
@ -1101,11 +1116,13 @@ CADSTAR_SCH_ARCHIVE_LOADER::POINT CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetEl
|
|||
wxPoint pinOffset = libpinPosition - libOrigin;
|
||||
wxPoint pinPosition = symbolOrigin + pinOffset;
|
||||
|
||||
double compAngleDeciDeg = getAngleTenthDegree( sym.OrientAngle );
|
||||
|
||||
if( sym.Mirror )
|
||||
pinPosition.x = ( 2 * symbolOrigin.x ) - pinPosition.x;
|
||||
|
||||
double adjustedOrientationDecideg;
|
||||
getComponentOrientation( sym.OrientAngle, adjustedOrientationDecideg );
|
||||
getComponentOrientation( compAngleDeciDeg, adjustedOrientationDecideg );
|
||||
|
||||
RotatePoint( &pinPosition, symbolOrigin, -adjustedOrientationDecideg );
|
||||
|
||||
|
|
|
@ -135,8 +135,7 @@ private:
|
|||
void loadSymbolFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
|
||||
const double& aComponentOrientationDeciDeg, SCH_FIELD* aKiCadField );
|
||||
|
||||
int getComponentOrientation(
|
||||
long long aCadstarOrientAngle, double& aReturnedOrientationDeciDeg );
|
||||
int getComponentOrientation( double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg );
|
||||
|
||||
//Helper functions for loading nets
|
||||
POINT getLocationOfNetElement( const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID );
|
||||
|
@ -213,7 +212,17 @@ private:
|
|||
*/
|
||||
double getAngleTenthDegree( const long long& aCadstarAngle )
|
||||
{
|
||||
return (double) aCadstarAngle / 100.0;
|
||||
// CADSTAR v6 (which outputted Schematic Format Version 8) and earlier used 1/10 degree
|
||||
// as the unit for angles/orientations. It is assumed that CADSTAR version 7 (i.e. Schematic
|
||||
// Format Version 9 and later) is the version that introduced 1/1000 degree for angles.
|
||||
if( Header.Format.Version > 8 )
|
||||
{
|
||||
return (double) aCadstarAngle / 100.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (double) aCadstarAngle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +232,7 @@ private:
|
|||
*/
|
||||
double getAngleDegrees( const long long& aCadstarAngle )
|
||||
{
|
||||
return (double) aCadstarAngle / 1000.0;
|
||||
return getAngleTenthDegree( aCadstarAngle ) / 10.0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue