3#include "MRViewer/exports.h"
94#define DETAIL_MR_UNIT_ENUMS(X) X(NoUnit) X(LengthUnit) X(AngleUnit) X(PixelSizeUnit) X(RatioUnit) X(TimeUnit) X(MovementSpeedUnit) X(AreaUnit) X(VolumeUnit) X(InvLengthUnit)
97#define DETAIL_MR_UNIT_VALUE_TYPES(X, ...) \
98 X(float __VA_OPT__(,)__VA_ARGS__) X(double __VA_OPT__(,)__VA_ARGS__) X(long double __VA_OPT__(,)__VA_ARGS__) \
99 X(signed char __VA_OPT__(,)__VA_ARGS__) X(unsigned char __VA_OPT__(,)__VA_ARGS__) \
100 X(short __VA_OPT__(,)__VA_ARGS__) X(unsigned short __VA_OPT__(,)__VA_ARGS__) \
101 X(int __VA_OPT__(,)__VA_ARGS__) X(unsigned int __VA_OPT__(,)__VA_ARGS__) \
102 X(long __VA_OPT__(,)__VA_ARGS__) X(unsigned long __VA_OPT__(,)__VA_ARGS__) \
103 X(long long __VA_OPT__(,)__VA_ARGS__) X(unsigned long long __VA_OPT__(,)__VA_ARGS__)
108 #define MR_X(E) || std::same_as<T, E>
132#define MR_X(E) template <> [[nodiscard]] MRVIEWER_API const UnitInfo& getUnitInfo( E unit );
143namespace detail::Units
147 template <
typename T>
148 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
150 template <
typename T>
157template <UnitEnum E,
typename T>
164 if constexpr ( std::is_same_v<T, ReturnType> )
166 if ( !needConversion )
172 for (
int i = 0; i < VectorTraits<T>::size; i++ )
177 bool needElemConversion = needConversion;
178 if constexpr ( std::is_floating_point_v<typename VectorTraits<T>::BaseType> )
180 if ( needElemConversion &&
183 target >= std::numeric_limits<typename VectorTraits<T>::BaseType>::max()
186 needElemConversion =
false;
189 if ( needElemConversion )
199struct UnitToStringParams;
206#define MR_X(E) extern template MRVIEWER_API const UnitToStringParams<E>& getDefaultUnitParams();
214#define MR_X(E) extern template MRVIEWER_API void setDefaultUnitParams( const UnitToStringParams<E>& newParams );
293 #define MR_TRIM_LEADING_COMMA(...) MR_TRIM_LEADING_COMMA_(__VA_ARGS__)
294 #define MR_TRIM_LEADING_COMMA_(x, ...) __VA_ARGS__
295 #define MR_X(E) , UnitToStringParams<E>
297 #undef MR_TRIM_LEADING_COMMA
298 #undef MR_TRIM_LEADING_COMMA_
304template <UnitEnum E, detail::Units::Scalar T>
307#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );
308#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
314template <detail::Units::Scalar T>
317#define MR_X(T) extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );
323template <detail::Units::Scalar T>
329template <detail::Units::Scalar T>
338 for (
int i = 0; i < VectorTraits<T>::size; i++ )
347 for (
int i = 0; i < VectorTraits<T>::size; i++ )
353 extern template MRVIEWER_API int guessPrecision( T value ); \
354 extern template MRVIEWER_API int guessPrecision( T min, T max );
361template <UnitEnum E, detail::Units::Scalar T>
364#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );
365#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
371template <detail::Units::Scalar T>
374#define MR_X(T) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const VarUnitToStringParams& params );
#define MR_X(E)
Definition MRUnits.h:132
#define MR_TRIM_LEADING_COMMA(...)
#define DETAIL_MR_UNIT_VALUE_TYPES(X,...)
Definition MRUnits.h:97
#define DETAIL_MR_UNIT_ENUMS(X)
Definition MRUnits.h:94
std::conditional_t< std::is_integral_v< typename VectorTraits< T >::BaseType >, typename VectorTraits< T >::template ChangeBaseType< float >, T > MakeFloatingPoint
Definition MRUnits.h:151
Definition MRCameraOrientationPlugin.h:7
PixelSizeUnit
Definition MRUnits.h:40
NumberStyle
Definition MRUnits.h:219
MRVIEWER_API int guessPrecision(T value)
Definition MRUnits.h:335
MRVIEWER_API std::string valueToString(T value, const UnitToStringParams< E > ¶ms=getDefaultUnitParams< E >())
const UnitInfo & getUnitInfo(E unit)=delete
NoUnit
Definition MRUnits.h:18
bool unitsAreEquivalent(E a, E b)
Definition MRUnits.h:138
LengthUnit
Definition MRUnits.h:24
const UnitToStringParams< E > & getDefaultUnitParams()
void setDefaultUnitParams(const UnitToStringParams< E > &newParams)
MRVIEWER_API std::string valueToImGuiFormatString(T value, const UnitToStringParams< E > ¶ms=getDefaultUnitParams< E >())
RatioUnit
Definition MRUnits.h:47
DegreesMode
Definition MRUnits.h:228
MovementSpeedUnit
Definition MRUnits.h:63
detail::Units::MakeFloatingPoint< T > convertUnits(E from, E to, const T &value)
Definition MRUnits.h:158
VolumeUnit
Definition MRUnits.h:79
AreaUnit
Definition MRUnits.h:71
TimeUnit
Definition MRUnits.h:55
InvLengthUnit
Definition MRUnits.h:87
AngleUnit
Definition MRUnits.h:32
std::variant< > VarUnitToStringParams
Definition MRUnits.h:292
std::string_view unitSuffix
Definition MRUnits.h:125
std::string_view prettyName
Definition MRUnits.h:121
float conversionFactor
Definition MRUnits.h:119
bool leadingZero
Definition MRUnits.h:278
int precision
Definition MRUnits.h:261
std::conditional_t< std::is_same_v< E, AngleUnit >, DegreesMode, detail::Units::Empty > degreesMode
Definition MRUnits.h:284
NumberStyle style
Definition MRUnits.h:258
std::optional< E > sourceUnit
Definition MRUnits.h:247
std::string_view decorationFormatString
Definition MRUnits.h:240
char thousandsSeparator
Definition MRUnits.h:273
bool unitSuffix
Definition MRUnits.h:253
bool allowNegativeZero
Definition MRUnits.h:267
E targetUnit
Definition MRUnits.h:250
char thousandsSeparatorFrac
Definition MRUnits.h:275
friend bool operator==(const UnitToStringParams &, const UnitToStringParams &)=default
bool stripTrailingZeroes
Definition MRUnits.h:281
bool unicodeMinusSign
Definition MRUnits.h:270
Definition MRMesh/MRVectorTraits.h:14
static constexpr int size
Definition MRMesh/MRVectorTraits.h:18
static constexpr auto && getElem(int i, U &&value)
Definition MRMesh/MRVectorTraits.h:27
T BaseType
Definition MRMesh/MRVectorTraits.h:17