2#include <ossia/network/dataspace/dataspace_base.hpp>
3#include <ossia/network/domain/domain.hpp>
12using meter_u = distance_ratio<std::ratio<1>>;
13using kilometer_u = distance_ratio<std::kilo>;
14using decimeter_u = distance_ratio<std::deci>;
15using centimeter_u = distance_ratio<std::centi>;
16using millimeter_u = distance_ratio<std::milli>;
17using micrometer_u = distance_ratio<std::micro>;
18using nanometer_u = distance_ratio<std::nano>;
19using picometer_u = distance_ratio<std::pico>;
20using inch_u = distance_ratio<std::ratio<254, 10000>>;
21using foot_u = distance_ratio<std::ratio<254 * 12, 10000>>;
22using mile_u = distance_ratio<std::ratio<254 * 12 * 5280, 10000>>;
24template <
typename Impl>
27 using is_unit = std::true_type;
28 using neutral_unit = meter_u;
29 using value_type = float;
30 using concrete_type = Impl;
31 using dataspace_type = distance_u;
32 using is_multidimensional = std::false_type;
36struct distance_ratio :
public linear_unit<distance_unit<distance_ratio<T>>, T>
38 using linear_unit<distance_unit<distance_ratio<T>>, T>::linear_unit;
43struct OSSIA_EXPORT pixel_u :
public distance_unit<pixel_u>
45 static constexpr auto text()
47 constexpr_return(ossia::make_string_array(
"px",
"pixels"));
49 using value_type = float;
52 void set_ppcm(
float v) { ppm = v * 100.f; }
53 void set_dpi(
float v) { ppm = v / 254.f; }
54 strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
56 return float(self.dataspace_value / ppm);
59 value_type from_neutral(strong_value<neutral_unit> self)
61 return float(self.dataspace_value * ppm);
66 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
70struct unit_traits<meter_u>
72 static constexpr auto text()
74 constexpr_return(ossia::make_string_array(
"m",
"meters"));
79struct unit_traits<kilometer_u>
81 static constexpr auto text()
83 constexpr_return(ossia::make_string_array(
"km",
"kilometers"));
87struct unit_traits<decimeter_u>
89 static constexpr auto text()
91 constexpr_return(ossia::make_string_array(
"dm",
"decimeters"));
95struct unit_traits<centimeter_u>
97 static constexpr auto text()
99 constexpr_return(ossia::make_string_array(
"cm",
"centimeters"));
103struct unit_traits<millimeter_u>
105 static constexpr auto text()
107 constexpr_return(ossia::make_string_array(
"mm",
"millimeters"));
111struct unit_traits<micrometer_u>
113 static constexpr auto text()
115 constexpr_return(ossia::make_string_array(
"um",
"micrometers"));
119struct unit_traits<nanometer_u>
121 static constexpr auto text()
123 constexpr_return(ossia::make_string_array(
"nm",
"nanometers"));
127struct unit_traits<picometer_u>
129 static constexpr auto text()
131 constexpr_return(ossia::make_string_array(
"pm",
"picometers"));
136struct unit_traits<inch_u>
138 static constexpr auto text()
140 constexpr_return(ossia::make_string_array(
"inches",
"\""));
144struct unit_traits<foot_u>
146 static constexpr auto text()
148 constexpr_return(ossia::make_string_array(
"feet",
"'"));
152struct unit_traits<mile_u>
154 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"miles")); }
domain A domain of values
Definition domain_base.hpp:23