KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SPICE_VALUE Class Reference

Helper class to recognize Spice formatted values. More...

#include <spice_value.h>

Public Types

enum  UNIT_PREFIX {
  PFX_FEMTO = -15 , PFX_PICO = -12 , PFX_NANO = -9 , PFX_MICRO = -6 ,
  PFX_MILI = -3 , PFX_NONE = 0 , PFX_KILO = 3 , PFX_MEGA = 6 ,
  PFX_GIGA = 9 , PFX_TERA = 12
}
 

Public Member Functions

 SPICE_VALUE ()
 Parses the string to create a Spice value (e.g. 100n)
 
 SPICE_VALUE (const wxString &aString)
 
 SPICE_VALUE (int aInt, UNIT_PREFIX aPrefix=PFX_NONE)
 
 SPICE_VALUE (double aDouble, UNIT_PREFIX aPrefix=PFX_NONE)
 
void Normalize ()
 Normalize the value.
 
double ToNormalizedDouble (wxString *aPrefix)
 
double ToDouble () const
 
wxString ToString () const
 Return string value as when converting double to string (e.g.
 
wxString ToString (const SPICE_VALUE_FORMAT &aFormat)
 Return string value with a particular precision and range.
 
wxString ToSpiceString () const
 Return string value in Spice format (e.g.
 
wxString ToOrigString () const
 Return either a normal string or Spice format string, depending on the original value format.
 
bool IsSpiceString () const
 Return true if the object was initiated with a Spice formatted string value.
 
bool operator== (const SPICE_VALUE &aOther) const
 
bool operator> (const SPICE_VALUE &aOther) const
 
bool operator< (const SPICE_VALUE &aOther) const
 
bool operator>= (const SPICE_VALUE &aOther) const
 
bool operator<= (const SPICE_VALUE &aOther) const
 
SPICE_VALUE operator- (const SPICE_VALUE &aOther) const
 
SPICE_VALUE operator+ (const SPICE_VALUE &aOther) const
 
SPICE_VALUE operator* (const SPICE_VALUE &aOther) const
 
SPICE_VALUE operator/ (const SPICE_VALUE &aOther) const
 Remove redundant zeros from the end of a string.
 

Static Public Member Functions

static void StripZeros (wxString &aString)
 
static UNIT_PREFIX ParseSIPrefix (wxChar c)
 

Private Attributes

double m_base
 
UNIT_PREFIX m_prefix
 Was the value defined using the Spice notation?
 
bool m_spiceStr
 

Detailed Description

Helper class to recognize Spice formatted values.

Definition at line 55 of file spice_value.h.

Member Enumeration Documentation

◆ UNIT_PREFIX

Enumerator
PFX_FEMTO 
PFX_PICO 
PFX_NANO 
PFX_MICRO 
PFX_MILI 
PFX_NONE 
PFX_KILO 
PFX_MEGA 
PFX_GIGA 
PFX_TERA 

Definition at line 58 of file spice_value.h.

Constructor & Destructor Documentation

◆ SPICE_VALUE() [1/4]

SPICE_VALUE::SPICE_VALUE ( )
inline

Parses the string to create a Spice value (e.g. 100n)

Definition at line 72 of file spice_value.h.

◆ SPICE_VALUE() [2/4]

SPICE_VALUE::SPICE_VALUE ( const wxString &  aString)

◆ SPICE_VALUE() [3/4]

SPICE_VALUE::SPICE_VALUE ( int  aInt,
UNIT_PREFIX  aPrefix = PFX_NONE 
)
inline

Definition at line 80 of file spice_value.h.

References Normalize().

◆ SPICE_VALUE() [4/4]

SPICE_VALUE::SPICE_VALUE ( double  aDouble,
UNIT_PREFIX  aPrefix = PFX_NONE 
)
inline

Definition at line 86 of file spice_value.h.

References Normalize().

Member Function Documentation

◆ IsSpiceString()

bool SPICE_VALUE::IsSpiceString ( ) const
inline

Return true if the object was initiated with a Spice formatted string value.

Definition at line 130 of file spice_value.h.

References m_spiceStr.

◆ Normalize()

void SPICE_VALUE::Normalize ( )

Normalize the value.

The unit prefix is picked so the base is (0.001 <= base < 1000).

Definition at line 123 of file spice_value.cpp.

References m_base, m_prefix, PFX_FEMTO, and PFX_TERA.

Referenced by SPICE_VALUE(), ToNormalizedDouble(), and ToString().

◆ operator*()

SPICE_VALUE SPICE_VALUE::operator* ( const SPICE_VALUE aOther) const

Definition at line 354 of file spice_value.cpp.

References m_base, m_prefix, m_spiceStr, VECTOR3< T >::Normalize(), and res.

◆ operator+()

SPICE_VALUE SPICE_VALUE::operator+ ( const SPICE_VALUE aOther) const

Definition at line 292 of file spice_value.cpp.

References m_base, m_prefix, m_spiceStr, VECTOR3< T >::Normalize(), and res.

◆ operator-()

SPICE_VALUE SPICE_VALUE::operator- ( const SPICE_VALUE aOther) const

Definition at line 323 of file spice_value.cpp.

References m_base, m_prefix, m_spiceStr, VECTOR3< T >::Normalize(), and res.

◆ operator/()

SPICE_VALUE SPICE_VALUE::operator/ ( const SPICE_VALUE aOther) const

Remove redundant zeros from the end of a string.

Definition at line 364 of file spice_value.cpp.

References m_base, m_prefix, m_spiceStr, VECTOR3< T >::Normalize(), and res.

◆ operator<()

bool SPICE_VALUE::operator< ( const SPICE_VALUE aOther) const
inline

Definition at line 145 of file spice_value.h.

References ToDouble().

◆ operator<=()

bool SPICE_VALUE::operator<= ( const SPICE_VALUE aOther) const
inline

Definition at line 155 of file spice_value.h.

◆ operator==()

bool SPICE_VALUE::operator== ( const SPICE_VALUE aOther) const
inline

Definition at line 135 of file spice_value.h.

References m_base, and m_prefix.

◆ operator>()

bool SPICE_VALUE::operator> ( const SPICE_VALUE aOther) const
inline

Definition at line 140 of file spice_value.h.

References ToDouble().

◆ operator>=()

bool SPICE_VALUE::operator>= ( const SPICE_VALUE aOther) const
inline

Definition at line 150 of file spice_value.h.

◆ ParseSIPrefix()

◆ StripZeros()

void SPICE_VALUE::StripZeros ( wxString &  aString)
static

Definition at line 374 of file spice_value.cpp.

Referenced by ToSpiceString(), ToString(), and TUNER_SLIDER::updateValueText().

◆ ToDouble()

◆ ToNormalizedDouble()

double SPICE_VALUE::ToNormalizedDouble ( wxString *  aPrefix)

Definition at line 203 of file spice_value.cpp.

References m_base, m_prefix, Normalize(), and spice_prefix().

Referenced by TUNER_SLIDER::updateValueText().

◆ ToOrigString()

wxString SPICE_VALUE::ToOrigString ( ) const
inline

Return either a normal string or Spice format string, depending on the original value format.

Definition at line 122 of file spice_value.h.

References m_spiceStr, ToSpiceString(), and ToString().

Referenced by TUNER_SLIDER::SetMax(), TUNER_SLIDER::SetMin(), TUNER_SLIDER::TUNER_SLIDER(), TUNER_SLIDER::updateMax(), TUNER_SLIDER::updateMin(), and TUNER_SLIDER::updateValue().

◆ ToSpiceString()

wxString SPICE_VALUE::ToSpiceString ( ) const

◆ ToString() [1/2]

wxString SPICE_VALUE::ToString ( ) const

Return string value as when converting double to string (e.g.

123456.789).

Definition at line 222 of file spice_value.cpp.

References res, StripZeros(), and ToDouble().

Referenced by SCHEMATIC::GetOperatingPoint(), ToOrigString(), SIMULATOR_FRAME_UI::UpdateMeasurement(), and SIMULATOR_FRAME_UI::updatePlotCursors().

◆ ToString() [2/2]

wxString SPICE_VALUE::ToString ( const SPICE_VALUE_FORMAT aFormat)

Return string value with a particular precision and range.

Parameters
aPrecisionnumber of significant digits
aRange"~" + unit for autorage; otherwise SI prefix + unit

Definition at line 231 of file spice_value.cpp.

References EDA_ANGLE::AsDegrees(), DEGREES_T, KiROUND(), m_base, m_prefix, Normalize(), EDA_ANGLE::Normalize180(), ParseSIPrefix(), SPICE_VALUE_FORMAT::Precision, SPICE_VALUE_FORMAT::Range, res, scale, and si_prefix().

Member Data Documentation

◆ m_base

double SPICE_VALUE::m_base
private

◆ m_prefix

UNIT_PREFIX SPICE_VALUE::m_prefix
private

Was the value defined using the Spice notation?

Definition at line 172 of file spice_value.h.

Referenced by Normalize(), operator*(), operator+(), operator-(), operator/(), operator==(), SPICE_VALUE(), ToDouble(), ToNormalizedDouble(), ToSpiceString(), and ToString().

◆ m_spiceStr

bool SPICE_VALUE::m_spiceStr
private

The documentation for this class was generated from the following files: