Convert PCAD importer to EDA_ANGLE.

This commit is contained in:
Jeff Young 2022-01-18 02:05:59 +00:00
parent e37ca2f757
commit 180137baa4
10 changed files with 27 additions and 25 deletions

View File

@ -345,11 +345,11 @@ void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue,
{
str = tNode->GetNodeContent();
str.Trim( false );
aTextValue->textRotation = StrToInt1Units( str );
aTextValue->textRotation = EDA_ANGLE( StrToInt1Units( str ), TENTHS_OF_A_DEGREE_T );
}
else
{
aTextValue->textRotation = 0;
aTextValue->textRotation = ANGLE_0;
}
str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
@ -594,7 +594,7 @@ void InitTTextValue( TTEXTVALUE* aTextValue )
aTextValue->text = wxEmptyString;
aTextValue->textPositionX = 0;
aTextValue->textPositionY = 0;
aTextValue->textRotation = 0;
aTextValue->textRotation = ANGLE_0;
aTextValue->textHeight = 0;
aTextValue->textstrokeWidth = 0;
aTextValue->textIsVisible = 0;

View File

@ -56,8 +56,9 @@ enum TTEXT_JUSTIFY
struct TTEXTVALUE
{
wxString text;
int textPositionX, textPositionY,
textRotation, textHeight, textstrokeWidth;
int textPositionX, textPositionY;
int textHeight, textstrokeWidth;
EDA_ANGLE textRotation;
int textIsVisible, mirror, textUnit;
int correctedPositionX, correctedPositionY;
TTEXT_JUSTIFY justify;

View File

@ -303,7 +303,7 @@ void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString&
{
str = tNode->GetNodeContent();
str.Trim( false );
fp->m_rotation = StrToInt1Units( str );
fp->m_rotation = EDA_ANGLE( StrToInt1Units( str ), TENTHS_OF_A_DEGREE_T );
}
str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );

View File

@ -45,7 +45,7 @@ PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
m_KiCadLayer = F_Cu; // It *has* to be somewhere...
m_positionX = 0;
m_positionY = 0;
m_rotation = 0;
m_rotation = ANGLE_0;
InitTTextValue( &m_name );
m_net = wxEmptyString;
m_netCode = 0;

View File

@ -67,7 +67,7 @@ public:
KIID m_uuid;
int m_positionX;
int m_positionY;
int m_rotation;
EDA_ANGLE m_rotation;
TTEXTVALUE m_name; // name has also private positions, rotations and so on....
wxString m_net;
int m_netCode;

View File

@ -495,21 +495,21 @@ wxString PCB_FOOTPRINT::ModuleLayer( int aMirror )
void PCB_FOOTPRINT::AddToBoard()
{
int i;
int r;
EDA_ANGLE r;
// transform text positions
CorrectTextPosition( &m_name );
RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, (double) -m_rotation );
RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, -m_rotation );
CorrectTextPosition( &m_Value );
RotatePoint( &m_Value.correctedPositionX, &m_Value.correctedPositionY, (double) -m_rotation );
RotatePoint( &m_Value.correctedPositionX, &m_Value.correctedPositionY, -m_rotation );
FOOTPRINT* footprint = new FOOTPRINT( m_board );
m_board->Add( footprint, ADD_MODE::APPEND );
footprint->SetPosition( VECTOR2I( m_positionX, m_positionY ) );
footprint->SetLayer( m_Mirror ? B_Cu : F_Cu );
footprint->SetOrientation( EDA_ANGLE( m_rotation, TENTHS_OF_A_DEGREE_T ) );
footprint->SetOrientation( m_rotation );
footprint->SetLastEditTime( 0 );
LIB_ID fpID;
@ -530,7 +530,7 @@ void PCB_FOOTPRINT::AddToBoard()
SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight );
r = m_name.textRotation - m_rotation;
ref_text->SetTextAngle( EDA_ANGLE( r, TENTHS_OF_A_DEGREE_T ) );
ref_text->SetTextAngle( r );
ref_text->SetKeepUpright( false );
ref_text->SetItalic( m_name.isItalic );
@ -558,7 +558,7 @@ void PCB_FOOTPRINT::AddToBoard()
SetTextSizeFromStrokeFontHeight( val_text, m_Value.textHeight );
r = m_Value.textRotation - m_rotation;
val_text->SetTextAngle( EDA_ANGLE( r, TENTHS_OF_A_DEGREE_T ) );
val_text->SetTextAngle( r );
val_text->SetKeepUpright( false );
val_text->SetItalic( m_Value.isItalic );

View File

@ -67,7 +67,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
wxString propValue, str, emsg;
PCB_PAD_SHAPE* padShape;
m_rotation = 0;
m_rotation = ANGLE_0;
lNode = FindNode( aNode, wxT( "padNum" ) );
if( lNode )
@ -99,7 +99,7 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
{
str = lNode->GetNodeContent();
str.Trim( false );
m_rotation = StrToInt1Units( str );
m_rotation = EDA_ANGLE( StrToInt1Units( str ), TENTHS_OF_A_DEGREE_T );
}
lNode = FindNode( aNode, wxT( "netNameRef" ) );
@ -191,7 +191,8 @@ void PCB_PAD::Flip()
}
void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncapsulatedPad )
void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, const EDA_ANGLE& aRotation,
bool aEncapsulatedPad )
{
PCB_PAD_SHAPE* padShape;
wxString padShapeName = wxT( "Ellipse" );
@ -288,7 +289,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetSize( VECTOR2I( width, height ) );
pad->SetDelta( VECTOR2I( 0, 0 ) );
pad->SetOrientation( EDA_ANGLE( m_rotation + aRotation, TENTHS_OF_A_DEGREE_T ) );
pad->SetOrientation( m_rotation + aRotation );
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
pad->SetOffset( VECTOR2I( 0, 0 ) );
@ -378,7 +379,7 @@ void PCB_PAD::AddToBoard()
m_name.text = m_defaultPinDes;
footprint->SetPosition( VECTOR2I( m_positionX, m_positionY ) );
AddToFootprint( footprint, 0, true );
AddToFootprint( footprint, ANGLE_0, true );
}
}

View File

@ -48,10 +48,10 @@ public:
void AddToFootprint( FOOTPRINT* aFootprint ) override
{
AddToFootprint( aFootprint, 0, true );
AddToFootprint( aFootprint, ANGLE_0, true );
}
void AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncapsulatedPad );
void AddToFootprint( FOOTPRINT* aFootprint, const EDA_ANGLE& aRotation, bool aEncapsulatedPad );
void AddToBoard() override;

View File

@ -71,7 +71,7 @@ void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
{
str = lNode->GetNodeContent();
str.Trim( false );
m_rotation = StrToInt1Units( str );
m_rotation = EDA_ANGLE( StrToInt1Units( str ), TENTHS_OF_A_DEGREE_T );
}
aNode->GetAttribute( wxT( "Name" ), &m_name.text );
@ -122,9 +122,9 @@ void PCB_TEXT::AddToBoard()
pcbtxt->SetMirrored( m_name.mirror );
if( pcbtxt->IsMirrored() )
pcbtxt->SetTextAngle( ANGLE_360 - EDA_ANGLE( m_name.textRotation, TENTHS_OF_A_DEGREE_T ) );
pcbtxt->SetTextAngle( ANGLE_360 - m_name.textRotation );
else
pcbtxt->SetTextAngle( EDA_ANGLE( m_name.textRotation, TENTHS_OF_A_DEGREE_T ) );
pcbtxt->SetTextAngle( m_name.textRotation );
pcbtxt->SetLayer( m_KiCadLayer );
}

View File

@ -52,7 +52,7 @@ void PCB_VIA::Parse( XNODE* aNode, const wxString& aDefaultUnits,
wxString propValue;
PCB_VIA_SHAPE* viaShape;
m_rotation = 0;
m_rotation = ANGLE_0;
lNode = FindNode( aNode, wxT( "viaStyleRef" ) );
if( lNode )