-
Notifications
You must be signed in to change notification settings - Fork 0
/
InteractiveMarker.h
71 lines (56 loc) · 1.74 KB
/
InteractiveMarker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <SpaceVecAlg/SpaceVecAlg>
#include <memory>
#include <type_traits>
namespace mc_rtc::imgui
{
enum class ControlAxis
{
NONE = 0,
TX = (1u << 0),
TY = (1u << 1),
TZ = (1u << 2),
RX = (1u << 3),
RY = (1u << 4),
RZ = (1u << 5),
TRANSLATION = TX | TY | TZ,
ROTATION = RX | RY | RZ,
XYTHETA = TX | TY | RZ,
XYZTHETA = TX | TY | TZ | RZ,
ALL = TRANSLATION | ROTATION
};
inline ControlAxis operator|(ControlAxis lhs, ControlAxis rhs)
{
using enum_t = std::underlying_type_t<ControlAxis>;
return static_cast<ControlAxis>(static_cast<enum_t>(lhs) | static_cast<enum_t>(rhs));
}
inline ControlAxis operator&(ControlAxis lhs, ControlAxis rhs)
{
using enum_t = std::underlying_type_t<ControlAxis>;
return static_cast<ControlAxis>(static_cast<enum_t>(lhs) & static_cast<enum_t>(rhs));
}
/** Abstract interface for an interactive marker in the 3D GUI */
struct InteractiveMarker
{
/** Create an interactive marker at the given position with the provided axis controllable */
inline InteractiveMarker(const sva::PTransformd & pose, ControlAxis mask = ControlAxis::NONE)
: pose_(pose), mask_(mask)
{
}
virtual ~InteractiveMarker() = 0;
inline const sva::PTransformd & pose() const noexcept { return pose_; }
/** Change the interaction mask of the marker */
virtual void mask(ControlAxis mask) = 0;
/** Change the position of the marker */
virtual void pose(const sva::PTransformd & pose) = 0;
/** Draw the marker
*
* \returns True if the user moved the marker in which case \ref pose() has the new position
*/
virtual bool draw() = 0;
protected:
sva::PTransformd pose_;
ControlAxis mask_;
};
using InteractiveMarkerPtr = std::unique_ptr<InteractiveMarker>;
} // namespace mc_rtc::imgui