1 #ifndef unitofmeasure_h 2 #define unitofmeasure_h 15 #include "generalmod.h" 44 : NamedObject(n), symbol_(s)
48 : NamedObject(uom.name())
52 const char*
symbol()
const {
return symbol_.buf(); }
63 bool isImperial()
const;
67 {
return ( T ) scaler_.scale(inp); }
70 {
return ( T ) scaler_.unScale(inp); }
72 T internalValue(T inp)
const;
74 T userValue(T inp)
const;
92 static uiString surveyDefZUnitAnnot(
bool symbol,
bool withparens);
93 static uiString surveyDefTimeUnitAnnot(
bool symbol,
bool withparens);
94 static uiString surveyDefDepthUnitAnnot(
bool symbol,
bool withparens);
95 static uiString surveyDefVelUnitAnnot(
bool symbol,
bool withparens);
96 static uiString zUnitAnnot(
bool time,
bool symbol,
bool withparens);
98 static IOPar& currentDefaults();
101 static void saveCurrentDefaults();
117 template <
class T>
void convValue(T& val,
163 const char* nm)
const;
166 friend mGlobal(General) UnitOfMeasureRepository&
UoMR();
174 if (
SI().zInFeet() )
176 if ( symbol_.contains(
"ft") )
178 else if ( symbol_.contains(
"m") )
185 return getSIValue( inp );
191 if (
SI().zInFeet() )
198 return feetunit ? feetunit->
getSIValue( inp ) : inp;
214 if ( oldunit == newunit ||
mIsUdf(val) )
#define mExpClass(module)
Definition: commondefs.h:160
void setSource(Repos::Source s)
Definition: unitofmeasure.h:78
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
bool add(const UnitOfMeasure &)
returns false when already present
const UnitOfMeasure * getInternalFor(PropertyRef::StdType) const
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
#define mGlobal(module)
Definition: commondefs.h:163
Repository of all Units of Measure in the system.
Definition: unitofmeasure.h:135
Ref Data for a (usually petrophysical) property.
Definition: propertyref.h:42
UnitOfMeasure(const char *n, const char *s, double f, PropertyRef::StdType t=PropertyRef::Other)
Definition: unitofmeasure.h:42
bool contains(char) const
Definition: uistring.h:89
const UnitOfMeasure * findBest(const ObjectSet< const UnitOfMeasure > &, const char *nm) const
Will try names first, then symbols, otherwise null.
const UnitOfMeasure * getDefault(const char *key, PropertyRef::StdType) const
PropertyRef::StdType proptype_
Definition: unitofmeasure.h:109
T getSIValue(T inp) const
Definition: unitofmeasure.h:66
Definition: propertyref.h:49
T getConvertedValue(T val, const UnitOfMeasure *oldunit, const UnitOfMeasure *newunit)
Definition: unitofmeasure.h:211
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
T userValue(T inp) const
Definition: unitofmeasure.h:189
const char * symbol() const
Definition: unitofmeasure.h:52
Source
Definition: repos.h:25
const UnitOfMeasure * getCurDefaultFor(const char *key) const
void addUnitsFromFile(const char *, Repos::Source)
Repos::Source source_
Definition: unitofmeasure.h:110
void setScaler(const LinScaler &s)
Definition: unitofmeasure.h:58
const UnitOfMeasure * get(PropertyRef::StdType, const char *nm) const
Repos::Source source() const
Definition: unitofmeasure.h:77
PropertyRef::StdType propType() const
Definition: unitofmeasure.h:53
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Object with a name.
Definition: namedobj.h:35
T internalValue(T inp) const
Definition: unitofmeasure.h:172
UnitOfMeasure(const UnitOfMeasure &uom)
Definition: unitofmeasure.h:47
bool write(Repos::Source) const
void getRelevant(PropertyRef::StdType, ObjectSet< const UnitOfMeasure > &) const
LinScaler scaler_
Definition: unitofmeasure.h:108
const LinScaler & scaler() const
Definition: unitofmeasure.h:54
T getUserValueFromSI(T inp) const
Definition: unitofmeasure.h:69
ManagedObjectSet< const UnitOfMeasure > entries
Definition: unitofmeasure.h:159
void setSymbol(const char *s)
Definition: unitofmeasure.h:56
StdType
Definition: propertyref.h:46
UnitOfMeasureRepository()
const ObjectSet< const UnitOfMeasure > & all() const
Definition: unitofmeasure.h:144
void setPropType(PropertyRef::StdType t)
Definition: unitofmeasure.h:60
BufferString symbol_
Definition: unitofmeasure.h:107
UnitOfMeasure()
Definition: unitofmeasure.h:39
void convValue(T &val, const UnitOfMeasure *oldunit, const UnitOfMeasure *newunit)
Definition: unitofmeasure.h:206
static const char * guessedStdName(const char *)
May return null.
Unit of Measure.
Definition: unitofmeasure.h:35
Linear scaling.
Definition: scaler.h:55
UnitOfMeasureRepository & UoMR()