PoseGizmo.cpp
Go to the documentation of this file.
1 #include "PoseGizmo.h"
2 
3 
4 namespace viz = armarx::viz;
5 
6 
7 namespace armarx::viz
8 {
9 
11  {
12  box.enable(viz::interaction().selection().transform().hideDuringTransform());
13  }
14 
15  void PoseGizmo::setLayer(const Layer& layer_)
16  {
17  this->layer = layer_;
18  this->layer.add(box);
19  this->layer.add(pose);
20  }
21 
23  {
24  const Eigen::Matrix4f current = getCurrent();
25  box.pose(current);
26  pose.pose(current);
27  }
28 
30  {
31  const Eigen::Matrix4f current = getCurrent();
32  box.pose(initial);
33  pose.pose(current);
34  }
35 
36  bool
39  StagedCommit* stage)
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  } break;
52 
54  {
55  // Update state of tcp object
56  transform = interaction.transformation();
57 
58  if (interaction.isTransformDuring())
59  {
61  }
62 
63  stage->add(layer);
64  return true;
65  } break;
66 
68  {
69  // If an object is deselected, we apply the transformation
70 
71  initial = getCurrent();
72  transform.setIdentity();
73 
74  update();
75  stage->add(layer);
76 
77  return true;
78  } break;
79 
81  {
82  }
83 
84  default:
85  {
86  // Ignore other interaction types
87  } break;
88 
89  }
90 
91  return false;
92  }
93 
94 
96  {
97  return transform * initial;
98  }
99 
100 }
101 
102 
armarx::viz::StagedCommit::add
void add(Layer const &layer)
Stage a layer to be committed later via client.apply(*this)
Definition: Client.h:37
armarx::viz::PoseGizmo::box
viz::Box box
Definition: PoseGizmo.h:35
armarx::viz::InteractionFeedbackType::ContextMenuChosen
@ ContextMenuChosen
A context menu entry was chosen.
armarx::viz::interaction
InteractionDescription interaction()
Definition: ElementOps.h:101
armarx::viz::PoseGizmo::PoseGizmo
PoseGizmo()
Definition: PoseGizmo.cpp:10
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::viz::StagedCommit
A staged commit prepares multiple layers to be committed.
Definition: Client.h:31
armarx::viz::ElementOps::data_
IceInternal::Handle< ElementT > data_
Definition: ElementOps.h:281
armarx::viz::InteractionFeedbackType::Select
@ Select
An element was selected.
armarx::viz::PoseGizmo::initial
Eigen::Matrix4f initial
Definition: PoseGizmo.h:30
armarx::viz::InteractionFeedbackType::Transform
@ Transform
The element was transformed (translated or rotated).
armarx::viz::InteractionFeedback
Definition: Interaction.h:57
armarx::viz::PoseGizmo::updateDuringTransform
void updateDuringTransform()
Definition: PoseGizmo.cpp:29
armarx::viz::PoseGizmo::update
void update()
Definition: PoseGizmo.cpp:22
armarx::viz::PoseGizmo::getCurrent
Eigen::Matrix4f getCurrent() const
Definition: PoseGizmo.cpp:95
PoseGizmo.h
armarx::viz::PoseGizmo::handleInteraction
bool handleInteraction(const viz::InteractionFeedback &interaction, viz::StagedCommit *stage)
Definition: PoseGizmo.cpp:37
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::viz::InteractionFeedbackType::Deselect
@ Deselect
An element was deselected.
armarx::viz::ElementOps::pose
DerivedT & pose(Eigen::Matrix4f const &pose)
Definition: ElementOps.h:159
armarx::viz::PoseGizmo::pose
viz::Pose pose
Definition: PoseGizmo.h:36
armarx::viz::PoseGizmo::setLayer
void setLayer(const viz::Layer &layer)
Definition: PoseGizmo.cpp:15
armarx::viz::PoseGizmo::layer
viz::Layer layer
Definition: PoseGizmo.h:33
armarx::viz::PoseGizmo::transform
Eigen::Matrix4f transform
Definition: PoseGizmo.h:31
armarx::viz::Layer
Definition: Layer.h:12
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:416
armarx::viz::ElementOps::enable
DerivedT & enable(InteractionDescription const &interactionDescription)
Definition: ElementOps.h:274