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)
104#pragma clang diagnostic push
105#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
107#define DETAIL_MR_UNIT_VALUE_TYPES(X, ...) \
108 X(float ,##__VA_ARGS__) X(double ,##__VA_ARGS__) X(long double ,##__VA_ARGS__) \
109 X(signed char ,##__VA_ARGS__) X(unsigned char ,##__VA_ARGS__) \
110 X(short ,##__VA_ARGS__) X(unsigned short ,##__VA_ARGS__) \
111 X(int ,##__VA_ARGS__) X(unsigned int ,##__VA_ARGS__) \
112 X(long ,##__VA_ARGS__) X(unsigned long ,##__VA_ARGS__) \
113 X(long long ,##__VA_ARGS__) X(unsigned long long ,##__VA_ARGS__)
115#pragma clang diagnostic pop
121 #define MR_X(E) || std::same_as<T, E>
145#define MR_X(E) template <> [[nodiscard]] MRVIEWER_API const UnitInfo& getUnitInfo( E unit );
162namespace detail::Units
166 template <
typename T>
167 concept Scalar = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
169 template <
typename T>
176template <UnitEnum E,
typename T>
183 if constexpr ( std::is_same_v<T, ReturnType> )
185 if ( !needConversion )
191 for (
int i = 0; i < VectorTraits<T>::size; i++ )
196 bool needElemConversion = needConversion;
197 if constexpr ( std::is_floating_point_v<typename VectorTraits<T>::BaseType> )
199 if ( needElemConversion &&
202 target >= std::numeric_limits<typename VectorTraits<T>::BaseType>::max()
205 needElemConversion =
false;
208 if ( needElemConversion )
216template <UnitEnum E,
typename T>
228struct UnitToStringParams;
235#define MR_X(E) extern template MRVIEWER_API const UnitToStringParams<E>& getDefaultUnitParams();
243#define MR_X(E) extern template MRVIEWER_API void setDefaultUnitParams( const UnitToStringParams<E>& newParams );
321 #define MR_TRIM_LEADING_COMMA(...) MR_TRIM_LEADING_COMMA_(__VA_ARGS__)
322 #define MR_TRIM_LEADING_COMMA_(x, ...) __VA_ARGS__
323 #define MR_X(E) , UnitToStringParams<E>
325 #undef MR_TRIM_LEADING_COMMA
326 #undef MR_TRIM_LEADING_COMMA_
332template <UnitEnum E, detail::Units::Scalar T>
335#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );
336#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
342template <detail::Units::Scalar T>
345#define MR_X(T) extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );
351template <detail::Units::Scalar T>
357template <detail::Units::Scalar T>
366 for (
int i = 0; i < VectorTraits<T>::size; i++ )
375 for (
int i = 0; i < VectorTraits<T>::size; i++ )
381 extern template MRVIEWER_API int guessPrecision( T value ); \
382 extern template MRVIEWER_API int guessPrecision( T min, T max );
389template <UnitEnum E, detail::Units::Scalar T>
392#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );
393#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
399template <detail::Units::Scalar T>
402#define MR_X(T) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const VarUnitToStringParams& params );
#define MR_X(E)
Definition MRUnits.h:145
#define MR_TRIM_LEADING_COMMA(...)
#define DETAIL_MR_UNIT_VALUE_TYPES(X,...)
Definition MRUnits.h:107
#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:170
PixelSizeUnit
Definition MRUnits.h:41
NumberStyle
Definition MRUnits.h:248
MRVIEWER_API int guessPrecision(T value)
Definition MRUnits.h:363
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:151
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:257
MovementSpeedUnit
Definition MRUnits.h:64
detail::Units::MakeFloatingPoint< T > convertUnits(E from, E to, const T &value)
Definition MRUnits.h:177
VolumeUnit
Definition MRUnits.h:82
AreaUnit
Definition MRUnits.h:73
MRMESH_API std::string_view toString(DimensionsVisualizePropertyType value)
TimeUnit
Definition MRUnits.h:56
InvLengthUnit
Definition MRUnits.h:91
AngleUnit
Definition MRUnits.h:33
std::variant< > VarUnitToStringParams
Definition MRUnits.h:320
std::string_view unitSuffix
Definition MRUnits.h:138
std::string_view prettyName
Definition MRUnits.h:134
float conversionFactor
Definition MRUnits.h:132
bool leadingZero
Definition MRUnits.h:306
int precision
Definition MRUnits.h:289
std::conditional_t< std::is_same_v< E, AngleUnit >, DegreesMode, detail::Units::Empty > degreesMode
Definition MRUnits.h:312
NumberStyle style
Definition MRUnits.h:286
std::optional< E > sourceUnit
Definition MRUnits.h:276
std::string_view decorationFormatString
Definition MRUnits.h:271
char thousandsSeparator
Definition MRUnits.h:301
bool unitSuffix
Definition MRUnits.h:281
bool allowNegativeZero
Definition MRUnits.h:295
char thousandsSeparatorFrac
Definition MRUnits.h:303
std::optional< E > targetUnit
Definition MRUnits.h:278
friend bool operator==(const UnitToStringParams &, const UnitToStringParams &)=default
bool stripTrailingZeroes
Definition MRUnits.h:309
bool unicodeMinusSign
Definition MRUnits.h:298
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