InteractionObserver.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace 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
16 void process(viz::InteractionFeedback const& interaction);
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>
25 addObserved(viz::Layer& layer, ElementT const& element)
26 {
27 layer.add(element);
28
29 auto iterator = observedLayers.find(layer.data_.name);
30
31 if (iterator == observedLayers.end())
32 {
33 std::tie(iterator, std::ignore) = observedLayers.emplace(layer.data_.name, layer);
34 }
35
36 auto& [name, observedLayer] = *iterator;
37 return observedLayer.observations[element.data_->id];
38 }
39
40 void clearObservedLayer(viz::Layer& layer);
41
43 void process(viz::InteractionFeedbackRange const& interactions);
44
45 private:
46 struct ObservedLayer
47 {
48 explicit ObservedLayer(viz::Layer& layer) : layer(layer)
49 {
50 }
51
52 std::reference_wrapper<viz::Layer> layer;
53 std::map<std::string, Observation> observations;
54 };
55
56 std::map<std::string, ObservedLayer> observedLayers;
57 };
58} // namespace armarx
uint8_t index
Observation & onTransformEnd(std::function< void(Eigen::Matrix4f const &)> action)
void process(viz::InteractionFeedback const &interaction)
Observation & onContextMenu(size_t index, std::function< void()> action)
void clearObservedLayer(viz::Layer &layer)
void requestInteractions(viz::StagedCommit &stage)
void process(viz::InteractionFeedbackRange const &interactions)
Observation & addObserved(viz::Layer &layer, ElementT const &element)
This file offers overloads of toIce() and fromIce() functions for STL container types.
data::LayerUpdate data_
Definition Layer.h:57
void add(ElementT const &element)
Definition Layer.h:31
A staged commit prepares multiple layers to be committed.
Definition Client.h:30