InteractionObserver.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace armarx
6 {
8  {
9  public:
11  {
12  public:
13  Observation& onContextMenu(size_t index, std::function<void()> action);
14  Observation& onTransformEnd(std::function<void(Eigen::Matrix4f const&)> action);
15 
17 
18  private:
19  std::map<size_t, std::function<void()>> contextMenuActions;
20  std::optional<std::function<void(Eigen::Matrix4f const&)>> transformEndAction;
21  };
22 
23  template <typename ElementT>
24  Observation& addObserved(viz::Layer & layer, ElementT const& element)
25  {
26  layer.add(element);
27 
28  auto iterator = observedLayers.find(layer.data_.name);
29 
30  if (iterator == observedLayers.end())
31  {
32  std::tie(iterator, std::ignore) = observedLayers.emplace(layer.data_.name, layer);
33  }
34 
35  auto& [name, observedLayer] = *iterator;
36  return observedLayer.observations[element.data_->id];
37  }
38 
39  void clearObservedLayer(viz::Layer & layer);
40 
42  void process(viz::InteractionFeedbackRange const& interactions);
43 
44  private:
45  struct ObservedLayer
46  {
47  explicit ObservedLayer(viz::Layer & layer) : layer(layer) {}
48 
49  std::reference_wrapper<viz::Layer> layer;
50  std::map<std::string, Observation> observations;
51  };
52 
53  std::map<std::string, ObservedLayer> observedLayers;
54  };
55 } // namespace armarx
armarx::InteractionObserver::Observation::onTransformEnd
Observation & onTransformEnd(std::function< void(Eigen::Matrix4f const &)> action)
Definition: InteractionObserver.cpp:13
ArVizComponentPlugin.h
armarx::InteractionObserver::addObserved
Observation & addObserved(viz::Layer &layer, ElementT const &element)
Definition: InteractionObserver.h:24
armarx::InteractionObserver::Observation::onContextMenu
Observation & onContextMenu(size_t index, std::function< void()> action)
Definition: InteractionObserver.cpp:6
armarx::viz::interaction
InteractionDescription interaction()
Definition: ElementOps.h:101
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::InteractionObserver::process
void process(viz::InteractionFeedbackRange const &interactions)
Definition: InteractionObserver.cpp:55
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::InteractionObserver::Observation
Definition: InteractionObserver.h:10
armarx::viz::Layer::data_
data::LayerUpdate data_
Definition: Layer.h:53
armarx::viz::InteractionFeedbackRange
Definition: Interaction.h:135
armarx::viz::InteractionFeedback
Definition: Interaction.h:57
armarx::InteractionObserver::requestInteractions
void requestInteractions(viz::StagedCommit &stage)
Definition: InteractionObserver.cpp:47
armarx::InteractionObserver
Definition: InteractionObserver.h:7
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::InteractionObserver::clearObservedLayer
void clearObservedLayer(viz::Layer &layer)
Definition: InteractionObserver.cpp:41
armarx::viz::Layer
Definition: Layer.h:12
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::InteractionObserver::Observation::process
void process(viz::InteractionFeedback const &interaction)
Definition: InteractionObserver.cpp:19