MeshLib Documentation
Loading...
Searching...
No Matches
MRUnits.h File Reference
#include "MRViewer/exports.h"
#include "MRViewer/MRVectorTraits.h"
#include <cassert>
#include <optional>
#include <string>
#include <variant>

Go to the source code of this file.

Classes

struct  MR::UnitInfo
 
struct  MR::detail::Units::Empty
 
struct  MR::UnitToStringParams< E >
 

Namespaces

namespace  MR
 
namespace  MR::detail
 
namespace  MR::detail::Units
 

Concepts

concept  MR::UnitEnum
 
concept  MR::detail::Units::Scalar
 

Macros

#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)
 
#define DETAIL_MR_UNIT_VALUE_TYPES(X, ...)
 
#define MR_X(E)   || std::same_as<T, E>
 
#define MR_X(E)   template <> [[nodiscard]] MRVIEWER_API const UnitInfo& getUnitInfo( E unit );
 
#define MR_X(E)   extern template MRVIEWER_API const UnitToStringParams<E>& getDefaultUnitParams();
 
#define MR_X(E)   extern template MRVIEWER_API void setDefaultUnitParams( const UnitToStringParams<E>& newParams );
 
#define MR_TRIM_LEADING_COMMA(...)   MR_TRIM_LEADING_COMMA_(__VA_ARGS__)
 
#define MR_TRIM_LEADING_COMMA_(x, ...)   __VA_ARGS__
 
#define MR_X(E)   , UnitToStringParams<E>
 
#define MR_Y(T, E)   extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );
 
#define MR_X(E)   DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
 
#define MR_X(T)   extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );
 
#define MR_X(T)
 
#define MR_Y(T, E)   extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );
 
#define MR_X(E)   DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)
 
#define MR_X(T)   extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const VarUnitToStringParams& params );
 

Typedefs

template<typename T >
using MR::detail::Units::MakeFloatingPoint = std::conditional_t<std::is_integral_v<typename VectorTraits<T>::BaseType>, typename VectorTraits<T>::template ChangeBaseType<float>, T>
 
using MR::VarUnitToStringParams
 

Enumerations

enum class  MR::NoUnit { MR::_count }
 
enum class  MR::LengthUnit { MR::mm , MR::meters , MR::inches , MR::_count }
 
enum class  MR::AngleUnit { MR::radians , MR::degrees , MR::_count }
 
enum class  MR::PixelSizeUnit { MR::pixels , MR::_count }
 
enum class  MR::RatioUnit { MR::factor , MR::percents , MR::_count }
 
enum class  MR::TimeUnit { MR::seconds , MR::milliseconds , MR::_count }
 
enum class  MR::MovementSpeedUnit { MR::mmPerSecond , MR::metersPerSecond , MR::inchesPerSecond , MR::_count }
 
enum class  MR::AreaUnit { MR::mm2 , MR::meters2 , MR::inches2 , MR::_count }
 
enum class  MR::VolumeUnit { MR::mm3 , MR::meters3 , MR::inches3 , MR::_count }
 
enum class  MR::InvLengthUnit { MR::inv_mm , MR::inv_meters , MR::inv_inches , MR::_count }
 
enum class  MR::NumberStyle { MR::normal , MR::distributePrecision , MR::exponential , MR::maybeExponential }
 
enum class  MR::DegreesMode { MR::degrees , MR::degreesMinutes , MR::degreesMinutesSeconds , MR::_count }
 

Functions

template<UnitEnum E>
const UnitInfoMR::getUnitInfo (E unit)=delete
 
template<UnitEnum E>
bool MR::unitsAreEquivalent (E a, E b)
 
template<UnitEnum E>
bool MR::unitsAreEquivalent (const std::optional< E > &a, const std::optional< E > &b)
 
template<UnitEnum E, typename T >
detail::Units::MakeFloatingPoint< T > MR::convertUnits (E from, E to, const T &value)
 
template<UnitEnum E, typename T >
detail::Units::MakeFloatingPoint< T > MR::convertUnits (const std::optional< E > &from, const std::optional< E > &to, const T &value)
 
template<UnitEnum E>
const UnitToStringParams< E > & MR::getDefaultUnitParams ()
 
template<UnitEnum E>
void MR::setDefaultUnitParams (const UnitToStringParams< E > &newParams)
 
MRVIEWER_API std::string_view MR::toString (DegreesMode mode)
 
template<UnitEnum E, detail::Units::Scalar T>
MRVIEWER_API std::string MR::valueToString (T value, const UnitToStringParams< E > &params=getDefaultUnitParams< E >())
 
template<detail::Units::Scalar T>
MRVIEWER_API std::string MR::valueToString (T value, const VarUnitToStringParams &params)
 
template<detail::Units::Scalar T>
MRVIEWER_API int MR::guessPrecision (T value)
 
template<detail::Units::Scalar T>
MRVIEWER_API int MR::guessPrecision (T min, T max)
 
template<typename T >
requires (VectorTraits<T>::size > 1 && detail::Units::Scalar<typename VectorTraits<T>::BaseType>)
int MR::guessPrecision (T value)
 
template<typename T >
requires (VectorTraits<T>::size > 1 && detail::Units::Scalar<typename VectorTraits<T>::BaseType>)
int MR::guessPrecision (T min, T max)
 
template<UnitEnum E, detail::Units::Scalar T>
MRVIEWER_API std::string MR::valueToImGuiFormatString (T value, const UnitToStringParams< E > &params=getDefaultUnitParams< E >())
 
template<detail::Units::Scalar T>
MRVIEWER_API std::string MR::valueToImGuiFormatString (T value, const VarUnitToStringParams &params)
 

Macro Definition Documentation

◆ DETAIL_MR_UNIT_ENUMS

#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)

◆ DETAIL_MR_UNIT_VALUE_TYPES

#define DETAIL_MR_UNIT_VALUE_TYPES ( X,
... )
Value:
X(float __VA_OPT__(,)__VA_ARGS__) X(double __VA_OPT__(,)__VA_ARGS__) X(long double __VA_OPT__(,)__VA_ARGS__) \
X(signed char __VA_OPT__(,)__VA_ARGS__) X(unsigned char __VA_OPT__(,)__VA_ARGS__) \
X(short __VA_OPT__(,)__VA_ARGS__) X(unsigned short __VA_OPT__(,)__VA_ARGS__) \
X(int __VA_OPT__(,)__VA_ARGS__) X(unsigned int __VA_OPT__(,)__VA_ARGS__) \
X(long __VA_OPT__(,)__VA_ARGS__) X(unsigned long __VA_OPT__(,)__VA_ARGS__) \
X(long long __VA_OPT__(,)__VA_ARGS__) X(unsigned long long __VA_OPT__(,)__VA_ARGS__)

◆ MR_TRIM_LEADING_COMMA

#define MR_TRIM_LEADING_COMMA ( ...)    MR_TRIM_LEADING_COMMA_(__VA_ARGS__)

◆ MR_TRIM_LEADING_COMMA_

#define MR_TRIM_LEADING_COMMA_ ( x,
... )   __VA_ARGS__

◆ MR_X [1/10]

#define MR_X ( E)    || std::same_as<T, E>

◆ MR_X [2/10]

#define MR_X ( E)    template <> [[nodiscard]] MRVIEWER_API const UnitInfo& getUnitInfo( E unit );

◆ MR_X [3/10]

#define MR_X ( E)    extern template MRVIEWER_API const UnitToStringParams<E>& getDefaultUnitParams();

◆ MR_X [4/10]

#define MR_X ( E)    extern template MRVIEWER_API void setDefaultUnitParams( const UnitToStringParams<E>& newParams );

◆ MR_X [5/10]

#define MR_X ( E)    , UnitToStringParams<E>

◆ MR_X [6/10]

#define MR_X ( E)    DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)

◆ MR_X [7/10]

#define MR_X ( E)    DETAIL_MR_UNIT_VALUE_TYPES(MR_Y, E)

◆ MR_X [8/10]

#define MR_X ( T)    extern template MRVIEWER_API std::string valueToString( T value, const VarUnitToStringParams& params );

◆ MR_X [9/10]

#define MR_X ( T)
Value:
extern template MRVIEWER_API int guessPrecision( T value ); \
extern template MRVIEWER_API int guessPrecision( T min, T max );

◆ MR_X [10/10]

#define MR_X ( T)    extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const VarUnitToStringParams& params );

◆ MR_Y [1/2]

#define MR_Y ( T,
E )   extern template MRVIEWER_API std::string valueToString<E, T>( T value, const UnitToStringParams<E>& params );

◆ MR_Y [2/2]

#define MR_Y ( T,
E )   extern template MRVIEWER_API std::string valueToImGuiFormatString( T value, const UnitToStringParams<E>& params );