Avoid showing 0.0 if there are non-zeros
If the value we want to show is in nm but we are representing it as mm, don't show 0.00 unless it is actually 0. otherwise, convert to scientific notation to represent the value in nm.
This commit is contained in:
@@ -458,6 +458,28 @@ wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale,
|
||||
|
||||
text.Printf( format, value );
|
||||
|
||||
// Check if the formatted value shows only zeros but the actual value is non-zero
|
||||
// If so, use scientific notation instead
|
||||
if( value != 0.0 )
|
||||
{
|
||||
bool showsOnlyZeros = true;
|
||||
|
||||
// Check if the text contains only zeros (allowing for decimal point, minus sign, etc.)
|
||||
for( auto ch : text )
|
||||
{
|
||||
if( ch >= '1' && ch <= '9' )
|
||||
{
|
||||
showsOnlyZeros = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( showsOnlyZeros )
|
||||
{
|
||||
text.Printf( wxT( "%.3e" ), value );
|
||||
}
|
||||
}
|
||||
|
||||
// Trim to 2-1/2 digits after the decimal place for short-form mm
|
||||
if( short_form && aUnits == EDA_UNITS::MM )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user