swift
|
A physical quantity such as "5m", "20s", "1500ft/s". More...
Public Types | |
enum | ColumnIndex { IndexUnit = CPropertyIndexRef::GlobalIndexCPhysicalQuantity , IndexValue , IndexValueRounded0DigitsWithUnit , IndexValueRounded1DigitsWithUnit , IndexValueRounded2DigitsWithUnit , IndexValueRounded3DigitsWithUnit , IndexValueRounded6DigitsWithUnit } |
Index. | |
![]() | |
enum | ColumnIndex |
Base class enums. | |
Public Member Functions | |
const MU & | getUnit () const |
Unit. | |
void | setUnit (const MU &unit) |
Simply set unit, do no calclulate conversion. More... | |
void | setUnitBySymbol (const QString &unitName) |
Set unit by string. | |
QString | getUnitSymbol () const |
Unit. | |
PQ & | switchUnit (const MU &newUnit) |
Change unit, and convert value to maintain the same quantity. | |
PQ | switchedUnit (const MU &newUnit) const |
Return copy with switched unit. | |
bool | isNull () const |
Is quantity null? | |
void | setNull () |
Set null. | |
double | value (MU unit) const |
Value in given unit. | |
double | value () const |
Value in current unit. | |
void | setCurrentUnitValue (double value) |
Set value in current unit. | |
int | valueInteger (MU unit) const |
As integer value. | |
QString | valueIntegerAsString (MU unit) const |
As integer value. | |
int | valueInteger () const |
As integer value in current unit. | |
QString | valueIntegerAsString () const |
As integer value in current unit. | |
bool | isInteger () const |
Is value an integer. | |
double | valueRounded (MU unit, int digits=-1) const |
Rounded value in given unit. More... | |
double | valueRounded (int digits=-1) const |
Rounded value in current unit. More... | |
QString | valueRoundedAsString (MU unit, int digits=-1) const |
Rounded value in given unit. More... | |
QString | valueRoundedWithUnit (const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const |
Value to QString with the given unit, e.g. "5.00m". More... | |
QString | valueRoundedWithUnit (int digits=-1, bool withGroupSeparator=false, bool i18n=false) const |
Value to QString with the current unit, e.g. "5.00m". More... | |
void | roundToEpsilon () |
Round current value in current unit to epsilon. More... | |
void | setValueSameUnit (double value) |
Change value without changing unit. | |
void | addValueSameUnit (double value) |
Add to the value in the current unit. | |
void | substractValueSameUnit (double value) |
Substract from the value in the current unit. | |
CPhysicalQuantity & | operator*= (double multiply) |
Multiply operator *=. | |
CPhysicalQuantity & | operator/= (double divide) |
Divide operator /=. | |
PQ | operator* (double multiply) const |
Operator *. | |
PQ | operator/ (double divide) const |
Operator /. | |
PQ | operator- () const |
Unary operator -. | |
CPhysicalQuantity & | operator+= (const CPhysicalQuantity &other) |
Plus operator +=. | |
CPhysicalQuantity & | operator-= (const CPhysicalQuantity &other) |
Minus operator-=. | |
bool | isZeroEpsilonConsidered () const |
Quantity value <= epsilon. | |
bool | isPositiveWithEpsilonConsidered () const |
Value >= 0 epsilon considered. | |
bool | isNegativeWithEpsilonConsidered () const |
Value <= 0 epsilon considered. | |
const PQ & | makePositive () |
Make value always positive. | |
const PQ & | makeNegative () |
Make value always negative. | |
PQ | abs () const |
Absolute value (always >=0) | |
void | marshallToDbus (QDBusArgument &argument) const |
Marshall without begin/endStructure, for when composed within another object. More... | |
void | unmarshallFromDbus (const QDBusArgument &argument) |
Unmarshall without begin/endStructure, for when composed within another object. More... | |
void | marshallToDbus (QDBusArgument &argument, LosslessTag) const |
Marshal to DBus, preserving the measurement unit. | |
void | unmarshallFromDbus (const QDBusArgument &argument, LosslessTag) |
Unmarshal from DBus, with preserved measurement unit. | |
void | marshalToDataStream (QDataStream &stream) const |
Marshal a value to a QDataStream. More... | |
void | unmarshalFromDataStream (QDataStream &stream) |
Unmarshal a value from a QDataStream. More... | |
size_t | getValueHash () const |
qHash overload, needed for storing value in a QSet. More... | |
QJsonObject | toJson () const |
Cast to JSON object. More... | |
void | convertFromJson (const QJsonObject &json) |
Assign from JSON object. More... | |
QVariant | propertyByIndex (CPropertyIndexRef index) const |
Property by index. More... | |
void | setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant) |
Set property by index. More... | |
int | comparePropertyByIndex (CPropertyIndexRef index, const PQ &pq) const |
Compare for index. More... | |
QString | convertToQString (bool i18n=false) const |
Cast as QString. More... | |
void | parseFromString (const QString &value) |
Parse value from string. | |
void | parseFromString (const QString &value, CPqString::SeparatorMode mode) |
Parse to string, with specified separator. | |
void | parseFromString (const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing) |
Parse to string, with specified separator. | |
int | compare (const PQ &other) const |
Compare with other PQ. | |
![]() | |
CPropertyIndexList | apply (const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false) |
Update by variant map. More... | |
void | setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant) |
Set property by index. | |
QVariant | propertyByIndex (CPropertyIndexRef index) const |
Property by index. | |
int | comparePropertyByIndex (CPropertyIndexRef index, const PQ &compareValue) const |
Compare for index. | |
bool | equalsPropertyByIndex (const QVariant &compareValue, CPropertyIndexRef index) const |
Is given variant equal to value of property index? | |
![]() | |
int | getMetaTypeId () const |
Returns the Qt meta type ID of this object. More... | |
QString | getClassName () const |
Class name. | |
bool | isA (int metaTypeId) const |
Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses. | |
![]() | |
QString | toQString (bool i18n=false) const |
Cast as QString. | |
std::string | toStdString (bool i18n=false) const |
To std string. | |
QString | stringForStreaming () const |
String for streaming operators. | |
![]() | |
CIcons::IconIndex | toIcon () const |
As icon, not implemented by all classes. | |
Static Public Member Functions | |
static const PQ & | maxValue (const PQ &pq1, const PQ &pq2) |
Maximum of 2 quantities. | |
static const PQ & | minValue (const PQ &pq1, const PQ &pq2) |
Minimum of 2 quantities. | |
static int | compare (const PQ &a, const PQ &b) |
Implementation of compare. | |
static const PQ & | null () |
NULL PQ. | |
static PQ | parsedFromString (const QString &value, CPqString::SeparatorMode mode=CPqString::SeparatorBestGuess) |
Parsed from given string. | |
static PQ | parsedFromString (const QString &value, CPqString::SeparatorMode mode, const MU &defaultUnitIfMissing) |
Parsed from given string. | |
![]() | |
static void | registerMetadata () |
Register metadata. | |
Protected Member Functions | |
CPhysicalQuantity (double value, MU unit) | |
Constructor with double. | |
CPhysicalQuantity (const QString &unitString) | |
Constructor by parsed string, e.g. 10m. | |
Friends | |
int | compare (const PQ &a, const PQ &b) |
Return negative, zero, or positive if a is less than, equal to, or greater than b. More... | |
PQ | operator* (double factor, const PQ &other) |
Operator to support commutative multiplication. | |
bool | operator== (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Equal operator ==. | |
bool | operator!= (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Not equal operator !=. | |
bool | operator> (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Greater operator > | |
bool | operator< (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Less operator <. | |
bool | operator<= (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Less equal operator <=. | |
bool | operator>= (const CPhysicalQuantity &a, const CPhysicalQuantity &b) |
Greater equal operator >=. | |
PQ | operator+ (const PQ &a, const PQ &b) |
Plus operator +. | |
PQ | operator- (const PQ &a, const PQ &b) |
Minus operator -. | |
size_t | qHash (const PQ &pq) |
qHash overload, needed for storing value in a QSet. More... | |
A physical quantity such as "5m", "20s", "1500ft/s".
Definition at line 106 of file physicalquantity.h.
int swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::comparePropertyByIndex | ( | CPropertyIndexRef | index, |
const PQ & | pq | ||
) | const |
Compare for index.
Definition at line 532 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::convertFromJson | ( | const QJsonObject & | json | ) |
Assign from JSON object.
Definition at line 435 of file physicalquantity.cpp.
QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::convertToQString | ( | bool | i18n = false | ) | const |
Cast as QString.
Definition at line 388 of file physicalquantity.cpp.
size_t swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::getValueHash |
qHash overload, needed for storing value in a QSet.
Definition at line 418 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::marshallToDbus | ( | QDBusArgument & | argument | ) | const |
Marshall without begin/endStructure, for when composed within another object.
Definition at line 165 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::marshalToDataStream | ( | QDataStream & | stream | ) | const |
Marshal a value to a QDataStream.
Definition at line 194 of file physicalquantity.cpp.
QVariant swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::propertyByIndex | ( | CPropertyIndexRef | index | ) | const |
Property by index.
Definition at line 492 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::roundToEpsilon |
Round current value in current unit to epsilon.
Definition at line 330 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setPropertyByIndex | ( | CPropertyIndexRef | index, |
const QVariant & | variant | ||
) |
Set property by index.
Definition at line 510 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setUnit | ( | const MU & | unit | ) |
Simply set unit, do no calclulate conversion.
Definition at line 52 of file physicalquantity.cpp.
QJsonObject swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::toJson |
Cast to JSON object.
Definition at line 426 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::unmarshalFromDataStream | ( | QDataStream & | stream | ) |
Unmarshal a value from a QDataStream.
Definition at line 201 of file physicalquantity.cpp.
void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::unmarshallFromDbus | ( | const QDBusArgument & | argument | ) |
Unmarshall without begin/endStructure, for when composed within another object.
Definition at line 172 of file physicalquantity.cpp.
double swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRounded | ( | int | digits = -1 | ) | const |
Rounded value in current unit.
Definition at line 367 of file physicalquantity.cpp.
double swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRounded | ( | MU | unit, |
int | digits = -1 |
||
) | const |
Rounded value in given unit.
Definition at line 337 of file physicalquantity.cpp.
QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRoundedAsString | ( | MU | unit, |
int | digits = -1 |
||
) | const |
Rounded value in given unit.
Definition at line 373 of file physicalquantity.cpp.
QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRoundedWithUnit | ( | const MU & | unit, |
int | digits = -1 , |
||
bool | withGroupSeparator = false , |
||
bool | i18n = false |
||
) | const |
Value to QString with the given unit, e.g. "5.00m".
Definition at line 314 of file physicalquantity.cpp.
QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRoundedWithUnit | ( | int | digits = -1 , |
bool | withGroupSeparator = false , |
||
bool | i18n = false |
||
) | const |
Value to QString with the current unit, e.g. "5.00m".
Definition at line 323 of file physicalquantity.cpp.
|
friend |
Return negative, zero, or positive if a is less than, equal to, or greater than b.
Definition at line 116 of file physicalquantity.h.
|
friend |
qHash overload, needed for storing value in a QSet.
Definition at line 312 of file physicalquantity.h.