KiCad PCB EDA Suite
|
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 |
Helper class to recognize Spice formatted values.
Definition at line 55 of file spice_value.h.
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.
|
inline |
Parses the string to create a Spice value (e.g. 100n)
Definition at line 72 of file spice_value.h.
SPICE_VALUE::SPICE_VALUE | ( | const wxString & | aString | ) |
|
inline |
Definition at line 80 of file spice_value.h.
References Normalize().
|
inline |
Definition at line 86 of file spice_value.h.
References Normalize().
|
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.
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().
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.
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.
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.
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.
|
inline |
Definition at line 145 of file spice_value.h.
References ToDouble().
|
inline |
Definition at line 155 of file spice_value.h.
|
inline |
Definition at line 135 of file spice_value.h.
|
inline |
Definition at line 140 of file spice_value.h.
References ToDouble().
|
inline |
Definition at line 150 of file spice_value.h.
|
static |
Definition at line 185 of file spice_value.cpp.
References PFX_FEMTO, PFX_GIGA, PFX_KILO, PFX_MEGA, PFX_MICRO, PFX_MILI, PFX_NANO, PFX_NONE, PFX_PICO, and PFX_TERA.
Referenced by DIALOG_SIM_FORMAT_VALUE::DIALOG_SIM_FORMAT_VALUE(), ToString(), and SPICE_VALUE_FORMAT::UpdateUnits().
|
static |
Definition at line 374 of file spice_value.cpp.
Referenced by ToSpiceString(), ToString(), and TUNER_SLIDER::updateValueText().
double SPICE_VALUE::ToDouble | ( | ) | const |
Definition at line 212 of file spice_value.cpp.
References m_base, m_prefix, PFX_NONE, and res.
Referenced by SIMULATOR_FRAME_UI::onCursorsGridCellChanged(), operator<(), operator>(), DIALOG_SIM_COMMAND::parseCommand(), SIM_PLOT_TAB::ResetScales(), ToString(), and SIMULATOR_FRAME_UI::updateTrace().
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().
|
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().
wxString SPICE_VALUE::ToSpiceString | ( | ) | const |
Return string value in Spice format (e.g.
123.3456789k).
Definition at line 282 of file spice_value.cpp.
References m_base, m_prefix, res, spice_prefix(), and StripZeros().
Referenced by DIALOG_SIM_COMMAND::evaluateDCControls(), SIMULATOR_FRAME_UI::OnSimRefresh(), DIALOG_SIM_COMMAND::parseCommand(), ToOrigString(), and DIALOG_SIM_COMMAND::TransferDataFromWindow().
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().
wxString SPICE_VALUE::ToString | ( | const SPICE_VALUE_FORMAT & | aFormat | ) |
Return string value with a particular precision and range.
aPrecision | number 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().
|
private |
Definition at line 171 of file spice_value.h.
Referenced by Normalize(), operator*(), operator+(), operator-(), operator/(), operator==(), SPICE_VALUE(), ToDouble(), ToNormalizedDouble(), ToSpiceString(), and ToString().
|
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().
|
private |
Definition at line 175 of file spice_value.h.
Referenced by IsSpiceString(), operator*(), operator+(), operator-(), operator/(), SPICE_VALUE(), and ToOrigString().