From daac74992794cfbb387ad33382bf17993fbaf72f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 5 Jan 2020 11:11:15 -0800 Subject: [PATCH] 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 --- eeschema/sch_eagle_plugin.cpp | 24 ++++++++++++------------ include/eagle_parser.h | 7 ++++++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 11781210b9..b26a511050 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -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 ); } diff --git a/include/eagle_parser.h b/include/eagle_parser.h index 5b84d4c7bc..2c01f5a9f6 100644 --- a/include/eagle_parser.h +++ b/include/eagle_parser.h @@ -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