IUToMils should return int

It was already truncating even in old code...lets just clean this up
This commit is contained in:
Marek Roszko 2022-09-17 09:22:08 -04:00
parent 60f182bcec
commit f26a6f76e4
3 changed files with 8 additions and 23 deletions

View File

@ -214,10 +214,10 @@ wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant, int aArgFla
switch( PROPERTY_MANAGER::Instance().GetUnits() )
{
case EDA_UNITS::INCHES:
return wxString::Format( wxT( "%g in" ), pcbIUScale.IUToMils( aVariant.GetLong() ) / 1000.0 );
return wxString::Format( wxT( "%d in" ), pcbIUScale.IUToMils( aVariant.GetLong() ) / 1000.0 );
case EDA_UNITS::MILS:
return wxString::Format( wxT( "%g mils" ), pcbIUScale.IUToMils( aVariant.GetLong() ) );
return wxString::Format( wxT( "%d mils" ), pcbIUScale.IUToMils( aVariant.GetLong() ) );
case EDA_UNITS::MILLIMETRES:
return wxString::Format( wxT( "%g mm" ), pcbIUScale.IUTomm( aVariant.GetLong() ) );

View File

@ -345,26 +345,11 @@ void GERBER_FILE_IMAGE::DisplayImageInfo( GERBVIEW_FRAME* aMainFrame )
msg = m_ImageJustifyYCenter ? _("Center") : _("Normal");
aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg );
switch( aMainFrame->GetUserUnits() )
{
case EDA_UNITS::MILS:
msg.Printf( wxT( "X=%f Y=%f" ), gerbIUScale.IUToMils( m_ImageJustifyOffset.x ),
gerbIUScale.IUToMils( m_ImageJustifyOffset.y ) );
break;
case EDA_UNITS::INCHES:
msg.Printf( wxT( "X=%f Y=%f" ), gerbIUScale.IUToMils( m_ImageJustifyOffset.x ) / 1000.0,
gerbIUScale.IUToMils( m_ImageJustifyOffset.y ) / 1000.0 );
break;
case EDA_UNITS::MILLIMETRES:
msg.Printf( wxT( "X=%f Y=%f" ), gerbIUScale.IUTomm( m_ImageJustifyOffset.x ),
gerbIUScale.IUTomm( m_ImageJustifyOffset.y ) );
break;
default:
wxASSERT_MSG( false, wxT( "Invalid unit" ) );
}
msg.Printf( wxT( "X=%s Y=%s" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( gerbIUScale, aMainFrame->GetUserUnits(),
m_ImageJustifyOffset.x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( gerbIUScale, aMainFrame->GetUserUnits(),
m_ImageJustifyOffset.y ) );
aMainFrame->AppendMsgPanel( _( "Image Justify Offset" ), msg );
}

View File

@ -97,7 +97,7 @@ struct EDA_IU_SCALE
return int( x < 0 ? x - 0.5 : x + 0.5 );
}
constexpr inline double IUToMils( int iu ) const
constexpr inline int IUToMils( int iu ) const
{
double mils = iu / IU_PER_MILS;