UNIT_BINDER::Validate(): fix incorrect display of val min and val max.

When Validate() find an out of limits user value, it displays the limits.
However, the displayed limit value was incorrectly converter to internal units,
and strange values were displayed.
This commit is contained in:
jean-pierre charras 2020-07-08 10:27:31 +02:00
parent 5d14dc9034
commit 55daf645b6
1 changed files with 5 additions and 3 deletions

View File

@ -188,12 +188,13 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits, bool aUs
} }
// TODO: Validate() does not currently support m_dataType being anything other than DISTANCE // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE
// Note: aMin and aMax are not always given in internal units
if( GetValue() < From_User_Unit( aUnits, aMin, aUseMils ) ) if( GetValue() < From_User_Unit( aUnits, aMin, aUseMils ) )
{ {
double val_min_iu = From_User_Unit( aUnits, aMin, aUseMils );
m_errorMessage = wxString::Format( _( "%s must be at least %s." ), m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
valueDescriptionFromLabel( m_label ), valueDescriptionFromLabel( m_label ),
StringFromValue( m_units, aMin, true ) ); StringFromValue( m_units, val_min_iu, true, m_useMils ) );
textEntry->SelectAll(); textEntry->SelectAll();
// Don't focus directly; we might be inside a KillFocus event handler // Don't focus directly; we might be inside a KillFocus event handler
@ -204,9 +205,10 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits, bool aUs
if( GetValue() > From_User_Unit( aUnits, aMax, aUseMils ) ) if( GetValue() > From_User_Unit( aUnits, aMax, aUseMils ) )
{ {
double val_max_iu = From_User_Unit( aUnits, aMax, aUseMils );
m_errorMessage = wxString::Format( _( "%s must be less than %s." ), m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
valueDescriptionFromLabel( m_label ), valueDescriptionFromLabel( m_label ),
StringFromValue( m_units, aMax, true ) ); StringFromValue( m_units, val_max_iu, true, m_useMils ) );
textEntry->SelectAll(); textEntry->SelectAll();
// Don't focus directly; we might be inside a KillFocus event handler // Don't focus directly; we might be inside a KillFocus event handler