Vector3fWidgets.h
Go to the documentation of this file.
1#pragma once
2
3#include "Basic.h"
4
6{
7 template <typename Derived>
8 struct Vector3fMinMaxMixin : MinMaxMixin<Derived, Eigen::Vector3f>
9 {
11
12 Derived&
13 steps(const Eigen::Vector3i steps)
14 {
15 Derived& this_ = *static_cast<Derived*>(this);
16 this_.widget().steps = toIceI(steps);
17 return this_;
18 }
19
20 using Base::max;
21 using Base::min;
22
23 Derived&
24 min(float v)
25 {
26 return Base::min({v, v, v});
27 }
28
29 Derived&
30 min(std::array<float, 1> v)
31 {
32 return min(v.at(0));
33 }
34
35 Derived&
36 max(float v)
37 {
38 return Base::max({v, v, v});
39 }
40
41 Derived&
42 max(std::array<float, 1> v)
43 {
44 return max(v.at(0));
45 }
46
47 Derived&
48 steps(int v)
49 {
50 return steps(v, v, v);
51 }
52
53 Derived&
54 steps(std::array<int, 1> v)
55 {
56 return steps(v.at(0));
57 }
58
59 Derived&
60 min(float x, float y, float z)
61 {
62 return Base::min(Eigen::Vector3f{x, y, z});
63 }
64
65 Derived&
66 min(std::array<float, 3> v)
67 {
68 return min(v.at(0), v.at(1), v.at(2));
69 }
70
71 Derived&
72 max(float x, float y, float z)
73 {
74 return Base::max(Eigen::Vector3f{x, y, z});
75 }
76
77 Derived&
78 max(std::array<float, 3> v)
79 {
80 return max(v.at(0), v.at(1), v.at(2));
81 }
82
83 Derived&
84 steps(int x, int y, int z)
85 {
86 return steps(Eigen::Vector3i{x, y, z});
87 }
88
89 Derived&
90 steps(std::array<int, 3> v)
91 {
92 return steps(v.at(0), v.at(1), v.at(2));
93 }
94 };
95
97 public ValueMixin<Vector3fSpinBoxes, Eigen::Vector3f, Vector3fSpinBoxesBuilder>,
98 public Vector3fMinMaxMixin<Vector3fSpinBoxesBuilder>,
99 public ToolTipMixin<Vector3fSpinBoxesBuilder>
100 {
101 Vector3fSpinBoxesBuilder(std::string const& name, float limpos = 1000) : ValueMixin(name)
102 {
103 widget().steps = toIceI(Eigen::Vector3i::Ones() * static_cast<int>(2 * limpos + 1));
104 widget().decimals = toIceI(Eigen::Vector3i::Ones());
105 widget().min = toIceF(Eigen::Vector3f::Ones() * -limpos);
106 widget().max = toIceF(Eigen::Vector3f::Ones() * +limpos);
107 widget().defaultValue = makeValue(Eigen::Vector3f{Eigen::Vector3f::Zero()});
108 }
109
111 decimals(const Eigen::Vector3i decimals)
112 {
114 return *this;
115 }
116
118 decimals(int x, int y, int z)
119 {
120 return decimals(Eigen::Vector3i(x, y, z));
121 }
122
124 decimals(int d)
125 {
126 return decimals(Eigen::Vector3i(d, d, d));
127 }
128
130 decimals(std::array<int, 1> d)
131 {
132 return decimals(d.at(0));
133 }
134 };
135} // namespace armarx::RemoteGui::detail
136
137namespace armarx::RemoteGui
138{
139 inline detail::Vector3fSpinBoxesBuilder
140 makeVector3fSpinBoxes(std::string const& name, float limpos = 1000)
141 {
142 return {name, limpos};
143 }
144} // namespace armarx::RemoteGui
Vector3f toIceF(Eigen::Vector3f v)
Definition Storage.cpp:80
ValueVariant makeValue(bool value)
Definition Storage.cpp:144
detail::Vector3fSpinBoxesBuilder makeVector3fSpinBoxes(std::string const &name, float limpos=1000)
Vector3i toIceI(Eigen::Vector3i v)
Definition Storage.cpp:90
This file offers overloads of toIce() and fromIce() functions for STL container types.
Derived & steps(const Eigen::Vector3i steps)
Derived & steps(std::array< int, 3 > v)
Derived & max(std::array< float, 3 > v)
Derived & max(float x, float y, float z)
Derived & max(std::array< float, 1 > v)
MinMaxMixin< Derived, Eigen::Vector3f > Base
Derived & min(std::array< float, 1 > v)
Derived & steps(std::array< int, 1 > v)
Derived & min(float x, float y, float z)
Derived & min(std::array< float, 3 > v)
Vector3fSpinBoxesBuilder & decimals(int x, int y, int z)
Vector3fSpinBoxesBuilder & decimals(std::array< int, 1 > d)
Vector3fSpinBoxesBuilder(std::string const &name, float limpos=1000)
Vector3fSpinBoxesBuilder & decimals(const Eigen::Vector3i decimals)