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 );
313 #define MR_TRIM_LEADING_COMMA(...) MR_TRIM_LEADING_COMMA_(__VA_ARGS__)
314 #define MR_TRIM_LEADING_COMMA_(x, ...) __VA_ARGS__
315 #define MR_X(E) , UnitToStringParams<E>
317 #undef MR_TRIM_LEADING_COMMA
318 #undef MR_TRIM_LEADING_COMMA_
324template <UnitEnum E, detail::Units::Scalar T>
327#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );
328#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
334template <detail::Units::Scalar T>
337#define MR_X(T) extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );
343template <detail::Units::Scalar T>
349template <detail::Units::Scalar T>
358 for (
int i = 0; i < VectorTraits<T>::size; i++ )
367 for (
int i = 0; i < VectorTraits<T>::size; i++ )
373 extern template MRVIEWER_API int guessPrecision( T value ); \
374 extern template MRVIEWER_API int guessPrecision( T min, T max );
381template <UnitEnum E, detail::Units::Scalar T>
384#define MR_Y(T, E) extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );
385#define MR_X(E) DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
391template <detail::Units::Scalar T>
394#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:355
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
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:312
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:298
int precision
Definition MRUnits.h:281
std::conditional_t< std::is_same_v< E, AngleUnit >, DegreesMode, detail::Units::Empty > degreesMode
Definition MRUnits.h:304
NumberStyle style
Definition MRUnits.h:278
std::optional< E > sourceUnit
Definition MRUnits.h:268
std::string_view decorationFormatString
Definition MRUnits.h:263
char thousandsSeparator
Definition MRUnits.h:293
bool unitSuffix
Definition MRUnits.h:273
bool allowNegativeZero
Definition MRUnits.h:287
char thousandsSeparatorFrac
Definition MRUnits.h:295
std::optional< E > targetUnit
Definition MRUnits.h:270
friend bool operator==(const UnitToStringParams &, const UnitToStringParams &)=default
bool stripTrailingZeroes
Definition MRUnits.h:301
bool unicodeMinusSign
Definition MRUnits.h:290
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