|
swift
|
A physical quantity such as "5m", "20s", "1500ft/s". More...
#include <physicalquantity.h>
Public Types | |
| enum | ColumnIndex { IndexUnit = CPropertyIndexRef::GlobalIndexCPhysicalQuantity , IndexValue , IndexValueRounded0DigitsWithUnit , IndexValueRounded1DigitsWithUnit , IndexValueRounded2DigitsWithUnit , IndexValueRounded3DigitsWithUnit , IndexValueRounded6DigitsWithUnit } |
| Index. More... | |
| Public Types inherited from swift::misc::mixin::Index< PQ > | |
| enum | ColumnIndex |
| Base class enums. More... | |
Public Member Functions | |
| const MU & | getUnit () const |
| Unit. | |
| void | setUnit (const MU &unit) |
| Simply set unit, do no calclulate conversion. | |
| 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. | |
| double | valueRounded (int digits=-1) const |
| Rounded value in current unit. | |
| QString | valueRoundedAsString (MU unit, int digits=-1) const |
| Rounded value in given unit. | |
| 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". | |
| QString | valueRoundedWithUnit (int digits=-1, bool withGroupSeparator=false, bool i18n=false) const |
| Value to QString with the current unit, e.g. "5.00m". | |
| void | roundToEpsilon () |
| Round current value in current unit to epsilon. | |
| 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. | |
| void | unmarshallFromDbus (const QDBusArgument &argument) |
| Unmarshall without begin/endStructure, for when composed within another object. | |
| 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. | |
| void | unmarshalFromDataStream (QDataStream &stream) |
| Unmarshal a value from a QDataStream. | |
| size_t | getValueHash () const |
| qHash overload, needed for storing value in a QSet. | |
| QJsonObject | toJson () const |
| Cast to JSON object. | |
| void | convertFromJson (const QJsonObject &json) |
| Assign from JSON object. | |
| QVariant | propertyByIndex (CPropertyIndexRef index) const |
| Property by index. | |
| void | setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant) |
| Set property by index. | |
| int | comparePropertyByIndex (CPropertyIndexRef index, const PQ &pq) const |
| Compare for index. | |
| QString | convertToQString (bool i18n=false) const |
| Cast as QString. | |
| 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. | |
| Public Member Functions inherited from swift::misc::mixin::Index< PQ > | |
| CPropertyIndexList | apply (const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false) |
| Update by variant map. | |
| 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? | |
| Public Member Functions inherited from swift::misc::mixin::MetaType< PQ > | |
| int | getMetaTypeId () const |
| Returns the Qt meta type ID of this object. | |
| 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. | |
| Public Member Functions inherited from swift::misc::mixin::String< PQ > | |
| 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. | |
| Public Member Functions inherited from swift::misc::mixin::Icon< CPhysicalQuantity< MU, PQ > > | |
| CIcons::CIcons::StandardIconUnknown16 | 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 Public Member Functions inherited from swift::misc::mixin::MetaType< PQ > | |
| 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. | |
| 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. | |
A physical quantity such as "5m", "20s", "1500ft/s".
Definition at line 106 of file physicalquantity.h.
| enum swift::misc::physical_quantities::CPhysicalQuantity::ColumnIndex |
Index.
Definition at line 120 of file physicalquantity.h.
|
protected |
Constructor with double.
Definition at line 70 of file physicalquantity.cpp.
|
protected |
Constructor by parsed string, e.g. 10m.
Definition at line 78 of file physicalquantity.cpp.
| PQ swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::abs | ( | ) | const |
Absolute value (always >=0).
Definition at line 168 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::addValueSameUnit | ( | double | value | ) |
Add to the value in the current unit.
Definition at line 103 of file physicalquantity.cpp.
|
inlinestatic |
Implementation of compare.
Definition at line 351 of file physicalquantity.h.
|
inline |
Compare with other PQ.
Definition at line 342 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 625 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::convertFromJson | ( | const QJsonObject & | json | ) |
Assign from JSON object.
Definition at line 513 of file physicalquantity.cpp.
| QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::convertToQString | ( | bool | i18n = false | ) | const |
Cast as QString.
Definition at line 451 of file physicalquantity.cpp.
| const MU & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::getUnit | ( | ) | const |
Unit.
Definition at line 46 of file physicalquantity.cpp.
| QString swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::getUnitSymbol | ( | ) | const |
Unit.
Definition at line 64 of file physicalquantity.cpp.
| size_t swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::getValueHash | ( | ) | const |
qHash overload, needed for storing value in a QSet.
Definition at line 496 of file physicalquantity.cpp.
| bool swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::isInteger | ( | ) | const |
Is value an integer.
Definition at line 415 of file physicalquantity.cpp.
| bool swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::isNegativeWithEpsilonConsidered | ( | ) | const |
Value <= 0 epsilon considered.
Definition at line 134 of file physicalquantity.cpp.
| bool swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::isNull | ( | ) | const |
Is quantity null?
Definition at line 324 of file physicalquantity.cpp.
| bool swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::isPositiveWithEpsilonConsidered | ( | ) | const |
Value >= 0 epsilon considered.
Definition at line 128 of file physicalquantity.cpp.
| bool swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::isZeroEpsilonConsidered | ( | ) | const |
Quantity value <= epsilon.
Definition at line 122 of file physicalquantity.cpp.
| const PQ & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::makeNegative | ( | ) |
Make value always negative.
Definition at line 154 of file physicalquantity.cpp.
| const PQ & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::makePositive | ( | ) |
Make value always positive.
Definition at line 140 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 183 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::marshallToDbus | ( | QDBusArgument & | argument, |
| LosslessTag | ) const |
Marshal to DBus, preserving the measurement unit.
Definition at line 201 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 215 of file physicalquantity.cpp.
|
static |
Maximum of 2 quantities.
Definition at line 461 of file physicalquantity.cpp.
|
static |
Minimum of 2 quantities.
Definition at line 475 of file physicalquantity.cpp.
|
static |
NULL PQ.
Definition at line 489 of file physicalquantity.cpp.
| PQ swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator* | ( | double | multiply | ) | const |
Operator *.
Definition at line 240 of file physicalquantity.cpp.
| CPhysicalQuantity< MU, PQ > & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator*= | ( | double | multiply | ) |
Multiply operator *=.
Definition at line 233 of file physicalquantity.cpp.
| CPhysicalQuantity< MU, PQ > & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator+= | ( | const CPhysicalQuantity< MU, PQ > & | other | ) |
Plus operator +=.
Definition at line 96 of file physicalquantity.cpp.
| PQ swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator- | ( | ) | const |
Unary operator -.
Definition at line 263 of file physicalquantity.cpp.
| CPhysicalQuantity< MU, PQ > & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator-= | ( | const CPhysicalQuantity< MU, PQ > & | other | ) |
Minus operator-=.
Definition at line 115 of file physicalquantity.cpp.
| PQ swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator/ | ( | double | divide | ) | const |
Operator /.
Definition at line 255 of file physicalquantity.cpp.
| CPhysicalQuantity< MU, PQ > & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::operator/= | ( | double | divide | ) |
Divide operator /=.
Definition at line 248 of file physicalquantity.cpp.
|
static |
Parsed from given string.
Definition at line 558 of file physicalquantity.cpp.
|
static |
Parsed from given string.
Definition at line 574 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::parseFromString | ( | const QString & | value | ) |
Parse value from string.
Definition at line 552 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::parseFromString | ( | const QString & | value, |
| CPqString::SeparatorMode | mode ) |
Parse to string, with specified separator.
Definition at line 531 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::parseFromString | ( | const QString & | value, |
| CPqString::SeparatorMode | mode, | ||
| const MU & | defaultUnitIfMissing ) |
Parse to string, with specified separator.
Definition at line 537 of file physicalquantity.cpp.
| QVariant swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::propertyByIndex | ( | CPropertyIndexRef | index | ) | const |
Property by index.
Definition at line 582 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::roundToEpsilon | ( | ) |
Round current value in current unit to epsilon.
Definition at line 384 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setCurrentUnitValue | ( | double | value | ) |
Set value in current unit.
Definition at line 347 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setNull | ( | ) |
Set null.
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 603 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.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setUnitBySymbol | ( | const QString & | unitName | ) |
Set unit by string.
Definition at line 58 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::setValueSameUnit | ( | double | value | ) |
Change value without changing unit.
Definition at line 356 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::substractValueSameUnit | ( | double | value | ) |
Substract from the value in the current unit.
Definition at line 109 of file physicalquantity.cpp.
| PQ swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::switchedUnit | ( | const MU & | newUnit | ) | const |
Return copy with switched unit.
Definition at line 312 of file physicalquantity.cpp.
| PQ & swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::switchUnit | ( | const MU & | newUnit | ) |
Change unit, and convert value to maintain the same quantity.
Definition at line 292 of file physicalquantity.cpp.
| QJsonObject swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::toJson | ( | ) | const |
Cast to JSON object.
Definition at line 504 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::unmarshalFromDataStream | ( | QDataStream & | stream | ) |
Unmarshal a value from a QDataStream.
Definition at line 222 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 190 of file physicalquantity.cpp.
| void swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::unmarshallFromDbus | ( | const QDBusArgument & | argument, |
| LosslessTag | ) |
Unmarshal from DBus, with preserved measurement unit.
Definition at line 208 of file physicalquantity.cpp.
| double swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::value | ( | ) | const |
Value in current unit.
Definition at line 337 of file physicalquantity.cpp.
| double swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::value | ( | MU | unit | ) | const |
Value in given unit.
Definition at line 444 of file physicalquantity.cpp.
| int swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueInteger | ( | ) | const |
As integer value in current unit.
Definition at line 409 of file physicalquantity.cpp.
| int swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueInteger | ( | MU | unit | ) | const |
As integer value.
Definition at line 401 of file physicalquantity.cpp.
|
inline |
As integer value in current unit.
Definition at line 175 of file physicalquantity.h.
|
inline |
As integer value.
Definition at line 169 of file physicalquantity.h.
| double swift::misc::physical_quantities::CPhysicalQuantity< MU, PQ >::valueRounded | ( | int | digits = -1 | ) | const |
Rounded value in current unit.
Definition at line 427 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 394 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 433 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 362 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 374 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 |
Not equal operator !=.
Definition at line 236 of file physicalquantity.h.
|
friend |
Operator to support commutative multiplication.
Definition at line 224 of file physicalquantity.h.
|
friend |
Plus operator +.
Definition at line 257 of file physicalquantity.h.
|
friend |
Minus operator -.
Definition at line 265 of file physicalquantity.h.
|
friend |
Less operator <.
Definition at line 248 of file physicalquantity.h.
|
friend |
Less equal operator <=.
Definition at line 251 of file physicalquantity.h.
|
friend |
Equal operator ==.
Definition at line 233 of file physicalquantity.h.
|
friend |
Greater operator >.
Definition at line 245 of file physicalquantity.h.
|
friend |
Greater equal operator >=.
Definition at line 254 of file physicalquantity.h.
|
friend |
qHash overload, needed for storing value in a QSet.
Definition at line 312 of file physicalquantity.h.