31#include <wx/textentry.h>
32#include <wx/numformatter.h>
42 aString.Left( 1 ).ToLong( &val );
44 Range = aString.Right( aString.Length() - 1 );
56 if(
Range.GetChar( 0 ) ==
'~' )
69 if( aString.IsEmpty() )
74 if( sscanf( (
const char*) aString.c_str(),
"%lf%7s", &
m_base, buf ) == 0 )
87 for(
char* bufPtr = buf; *bufPtr; ++bufPtr )
88 *bufPtr = tolower( *bufPtr );
90 if( !strcmp( buf,
"meg" ) )
118 while( std::fabs(
m_base ) >= 1000.0 )
154 return wxEmptyString;
174 return wxEmptyString;
226 wxString range( aFormat.
Range );
228 if( range.StartsWith( wxS(
"~" ) ) )
243 while( std::fabs( mantissa ) >= 10.0 )
249 while( mantissa != 0.0 && std::fabs( mantissa ) < 1.0 )
258 wxString
res = wxString::FromCDouble( mantissa );
267 wxString
res = wxString::FromCDouble(
m_base );
288 else if( prefixDiff < 0 )
319 else if( prefixDiff < 0 )
359 if ( aString.Find(
',' ) >= 0 || aString.Find(
'.' ) >= 0 )
361 while( aString.EndsWith(
'0' ) )
362 aString.RemoveLast();
364 if( aString.EndsWith(
'.' ) || aString.EndsWith(
',' ) )
365 aString.RemoveLast();
372 wxTextEntry*
const text = GetTextEntry();
377 if(
text->IsEmpty() )
386 wxString svalue =
text->GetValue();
391 svalue.Replace(
",",
"." );
401 text->GetValue() ) );
406 if( svalue !=
text->GetValue() )
407 text->SetValue( svalue );
Hold a translatable error message and may be used when throwing exceptions containing a translated er...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
bool m_emptyAllowed
< Is it valid to get an empty value?
bool Validate(wxWindow *aParent) override
Helper class to recognize Spice formatted values.
SPICE_VALUE operator+(const SPICE_VALUE &aOther) const
SPICE_VALUE operator-(const SPICE_VALUE &aOther) const
UNIT_PREFIX m_prefix
Was the value defined using the Spice notation?
static UNIT_PREFIX ParseSIPrefix(wxChar c)
void Normalize()
Normalize the value.
double ToNormalizedDouble(wxString *aPrefix)
wxString ToString() const
Return string value as when converting double to string (e.g.
SPICE_VALUE operator/(const SPICE_VALUE &aOther) const
Remove redundant zeros from the end of a string.
wxString ToSpiceString() const
Return string value in Spice format (e.g.
SPICE_VALUE operator*(const SPICE_VALUE &aOther) const
SPICE_VALUE()
Parses the string to create a Spice value (e.g. 100n)
static void StripZeros(wxString &aString)
VECTOR3< T > Normalize()
Compute the normalized vector.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxString si_prefix(SPICE_VALUE::UNIT_PREFIX aPrefix)
wxString spice_prefix(SPICE_VALUE::UNIT_PREFIX aPrefix)
std::vector< FAB_LAYER_COLOR > dummy
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".