3#include "MRViewer/exports.h"
99#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)
102#define DETAIL_MR_UNIT_VALUE_TYPES(X, ...) \
103 X(float __VA_OPT__(,)__VA_ARGS__) X(double __VA_OPT__(,)__VA_ARGS__) X(long double __VA_OPT__(,)__VA_ARGS__) \
104 X(signed char __VA_OPT__(,)__VA_ARGS__) X(unsigned char __VA_OPT__(,)__VA_ARGS__) \
105 X(short __VA_OPT__(,)__VA_ARGS__) X(unsigned short __VA_OPT__(,)__VA_ARGS__) \
106 X(int __VA_OPT__(,)__VA_ARGS__) X(unsigned int __VA_OPT__(,)__VA_ARGS__) \
107 X(long __VA_OPT__(,)__VA_ARGS__) X(unsigned long __VA_OPT__(,)__VA_ARGS__) \
108 X(long long __VA_OPT__(,)__VA_ARGS__) X(unsigned long long __VA_OPT__(,)__VA_ARGS__)
113 #define MR_X(E) || std::same_as<T, E>
137#define MR_X(E) template <> [[nodiscard]] MRVIEWER_API const UnitInfo& getUnitInfo( E unit );
154namespace detail::Units
158 template <
typename T>
159 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
161 template <
typename T>
168template <UnitEnum E,
typename T>
175 if constexpr ( std::is_same_v<T, ReturnType> )
177 if ( !needConversion )
183 for (
int i = 0; i < VectorTraits<T>::size; i++ )
188 bool needElemConversion = needConversion;
189 if constexpr ( std::is_floating_point_v<typename VectorTraits<T>::BaseType> )
191 if ( needElemConversion &&
194 target >= std::numeric_limits<typename VectorTraits<T>::BaseType>::max()
197 needElemConversion =
false;
200 if ( needElemConversion )
208template <UnitEnum E,
typename T>
220struct UnitToStringParams;
227#define MR_X(E) extern template MRVIEWER_API const UnitToStringParams<E>& getDefaultUnitParams();
235#define MR_X(E) extern template MRVIEWER_API void setDefaultUnitParams( const UnitToStringParams<E>& newParams );
311 #define MR_TRIM_LEADING_COMMA(...) MR_TRIM_LEADING_COMMA_(__VA_ARGS__)
312 #define MR_TRIM_LEADING_COMMA_(x, ...) __VA_ARGS__
313 #define MR_X(E) , UnitToStringParams<E>
315 #undef MR_TRIM_LEADING_COMMA
316 #undef MR_TRIM_LEADING_COMMA_
322template <UnitEnum E, detail::Units::Scalar T>
325#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );
326#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
332template <detail::Units::Scalar T>
335#define MR_X(T) extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );
341template <detail::Units::Scalar T>
347template <detail::Units::Scalar T>
356 for (
int i = 0; i < VectorTraits<T>::size; i++ )
365 for (
int i = 0; i < VectorTraits<T>::size; i++ )
371 extern template MRVIEWER_API int guessPrecision( T value ); \
372 extern template MRVIEWER_API int guessPrecision( T min, T max );
379template <UnitEnum E, detail::Units::Scalar T>
382#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );
383#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
389template <detail::Units::Scalar T>
392#define MR_X(T) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const VarUnitToStringParams& params );
#define MR_X(E)
Definition MRUnits.h:137
#define MR_TRIM_LEADING_COMMA(...)
#define DETAIL_MR_UNIT_VALUE_TYPES(X,...)
Definition MRUnits.h:102
#define DETAIL_MR_UNIT_ENUMS(X)
Definition MRUnits.h:99
std::conditional_t< std::is_integral_v< typename VectorTraits< T >::BaseType >, typename VectorTraits< T >::template ChangeBaseType< float >, T > MakeFloatingPoint
Definition MRUnits.h:162
Definition MRCameraOrientationPlugin.h:8
PixelSizeUnit
Definition MRUnits.h:41
NumberStyle
Definition MRUnits.h:240
MRVIEWER_API int guessPrecision(T value)
Definition MRUnits.h:353
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:143
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:48
DegreesMode
Definition MRUnits.h:249
MovementSpeedUnit
Definition MRUnits.h:64
detail::Units::MakeFloatingPoint< T > convertUnits(E from, E to, const T &value)
Definition MRUnits.h:169
VolumeUnit
Definition MRUnits.h:82
AreaUnit
Definition MRUnits.h:73
TimeUnit
Definition MRUnits.h:56
InvLengthUnit
Definition MRUnits.h:91
AngleUnit
Definition MRUnits.h:33
std::variant< > VarUnitToStringParams
Definition MRUnits.h:310
std::string_view unitSuffix
Definition MRUnits.h:130
std::string_view prettyName
Definition MRUnits.h:126
float conversionFactor
Definition MRUnits.h:124
bool leadingZero
Definition MRUnits.h:296
int precision
Definition MRUnits.h:279
std::conditional_t< std::is_same_v< E, AngleUnit >, DegreesMode, detail::Units::Empty > degreesMode
Definition MRUnits.h:302
NumberStyle style
Definition MRUnits.h:276
std::optional< E > sourceUnit
Definition MRUnits.h:266
std::string_view decorationFormatString
Definition MRUnits.h:261
char thousandsSeparator
Definition MRUnits.h:291
bool unitSuffix
Definition MRUnits.h:271
bool allowNegativeZero
Definition MRUnits.h:285
char thousandsSeparatorFrac
Definition MRUnits.h:293
std::optional< E > targetUnit
Definition MRUnits.h:268
friend bool operator==(const UnitToStringParams &, const UnitToStringParams &)=default
bool stripTrailingZeroes
Definition MRUnits.h:299
bool unicodeMinusSign
Definition MRUnits.h:288
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:28
T BaseType
Definition MRMesh/MRVectorTraits.h:17