PoseGizmo.cpp
Go to the documentation of this file.
1#include "PoseGizmo.h"
2
3
4namespace viz = armarx::viz;
5
6namespace armarx::viz
7{
8
10 {
11 box.enable(viz::interaction().selection().transform().hideDuringTransform());
12 }
13
14 void
16 {
17 this->layer = layer_;
18 this->layer.add(box);
19 this->layer.add(pose);
20 }
21
22 void
24 {
25 const Eigen::Matrix4f current = getCurrent();
26 box.pose(current);
27 pose.pose(current);
28 }
29
30 void
32 {
33 const Eigen::Matrix4f current = getCurrent();
34 box.pose(initial);
35 pose.pose(current);
36 }
37
38 bool
40 {
41 if (interaction.element() != box.data_->id)
42 {
43 return false;
44 }
45
46 switch (interaction.type())
47 {
49 {
50 // Nothing to do.
51 }
52 break;
53
55 {
56 // Update state of tcp object
57 transform = interaction.transformation();
58
59 if (interaction.isTransformDuring())
60 {
62 }
63
64 stage->add(layer);
65 return true;
66 }
67 break;
68
70 {
71 // If an object is deselected, we apply the transformation
72
74 transform.setIdentity();
75
76 update();
77 stage->add(layer);
78
79 return true;
80 }
81 break;
82
84 {
85 }
86
87 default:
88 {
89 // Ignore other interaction types
90 }
91 break;
92 }
93
94 return false;
95 }
96
97 Eigen::Matrix4f
99 {
100 return transform * initial;
101 }
102
103} // namespace armarx::viz
Eigen::Matrix4f getCurrent() const
Definition PoseGizmo.cpp:98
void setLayer(const viz::Layer &layer)
Definition PoseGizmo.cpp:15
bool handleInteraction(const viz::InteractionFeedback &interaction, viz::StagedCommit *stage)
Definition PoseGizmo.cpp:39
Eigen::Matrix4f transform
Definition PoseGizmo.h:28
Eigen::Matrix4f initial
Definition PoseGizmo.h:27
This file is part of ArmarX.
InteractionDescription interaction()
Definition ElementOps.h:109
@ Transform
The element was transformed (translated or rotated).
Definition Interaction.h:24
@ ContextMenuChosen
A context menu entry was chosen.
Definition Interaction.h:21
@ Deselect
An element was deselected.
Definition Interaction.h:18
@ Select
An element was selected.
Definition Interaction.h:16
A staged commit prepares multiple layers to be committed.
Definition Client.h:30
void add(Layer const &layer)
Stage a layer to be committed later via client.apply(*this)
Definition Client.h:36