eagle import: Convert to new eeschema units

This adjusts most (hopefully all) of the eagle conversion hard-coded mil
values into the new eeschema internal unit values
This commit is contained in:
Seth Hillbrand 2020-01-05 11:11:15 -08:00
parent 1e843922cd
commit daac749927
2 changed files with 18 additions and 13 deletions

View File

@ -775,7 +775,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// Calculate the new sheet size.
EDA_RECT sheetBoundingBox = getSheetBbox( m_currentSheet );
wxSize targetSheetSize = sheetBoundingBox.GetSize();
targetSheetSize.IncBy( 1500, 1500 );
targetSheetSize.IncBy( Mils2iu( 1500 ), Mils2iu( 1500 ) );
// Get current Eeschema sheet size.
wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU();
@ -783,10 +783,10 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// Increase if necessary
if( pageSizeIU.x < targetSheetSize.x )
pageInfo.SetWidthMils( targetSheetSize.x );
pageInfo.SetWidthMils( Iu2Mils( targetSheetSize.x ) );
if( pageSizeIU.y < targetSheetSize.y )
pageInfo.SetHeightMils( targetSheetSize.y );
pageInfo.SetHeightMils( Iu2Mils( targetSheetSize.y ) );
// Set the new sheet size.
m_currentSheet->GetScreen()->SetPageSettings( pageInfo );
@ -797,8 +797,8 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
// round the translation to nearest 100mil to place it on the grid.
wxPoint translation = sheetcentre - itemsCentre;
translation.x = translation.x - translation.x % 100;
translation.y = translation.y - translation.y % 100;
translation.x = translation.x - translation.x % Mils2iu( 100 );
translation.y = translation.y - translation.y % Mils2iu( 100 );
// Add global net labels for the named power input pins in this sheet
for( SCH_ITEM* item = m_currentSheet->GetScreen()->GetDrawItems(); item; item = item->Next() )
@ -929,7 +929,7 @@ void SCH_EAGLE_PLUGIN::loadSegments(
{
label->SetPosition( firstWire->GetStartPoint() );
label->SetText( escapeName( netName ) );
label->SetTextSize( wxSize( 10, 10 ) );
label->SetTextSize( wxSize( Mils2iu( 10 ), Mils2iu( 10 ) ) );
label->SetLabelSpinStyle( 0 );
screen->Append( label.release() );
}
@ -1730,19 +1730,19 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin(
if( length == "short" )
{
pin->SetLength( 100 );
pin->SetLength( Mils2iu( 100 ) );
}
else if( length == "middle" )
{
pin->SetLength( 200 );
pin->SetLength( Mils2iu( 200 ) );
}
else if( length == "long" )
{
pin->SetLength( 300 );
pin->SetLength( Mils2iu( 300 ) );
}
else if( length == "point" )
{
pin->SetLength( 0 );
pin->SetLength( Mils2iu( 0 ) );
}
}
@ -1905,7 +1905,7 @@ void SCH_EAGLE_PLUGIN::adjustNetLabels()
// Create a vector pointing in the direction of the wire, 50 mils long
VECTOR2I wireDirection( segAttached->B - segAttached->A );
wireDirection = wireDirection.Resize( 50 );
wireDirection = wireDirection.Resize( Mils2iu( 50 ) );
const VECTOR2I origPos( labelPos );
// Flags determining the search direction
@ -2579,7 +2579,7 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections(
SCH_GLOBALLABEL* netLabel = new SCH_GLOBALLABEL;
netLabel->SetPosition( aComponent->GetPinPhysicalPosition( pin ) );
netLabel->SetText( extractNetName( pin->GetName() ) );
netLabel->SetTextSize( wxSize( 10, 10 ) );
netLabel->SetTextSize( wxSize( Mils2iu( 10 ), Mils2iu( 10 ) ) );
netLabel->SetLabelSpinStyle( 0 );
aScreen->Append( netLabel );
}

View File

@ -425,6 +425,11 @@ struct ECOORD
return value / 25400;
}
int To100NanoMeters() const
{
return value / 100;
}
int ToNanoMeters() const
{
return value;
@ -435,7 +440,7 @@ struct ECOORD
return value / 1000000.0;
}
int ToSchUnits() const { return ToMils(); }
int ToSchUnits() const { return To100NanoMeters(); }
int ToPcbUnits() const { return ToNanoMeters(); }
ECOORD operator+( const ECOORD& aOther ) const