TAMSVIZ
Visualization and annotation tool for ROS
marker.h
1 // TAMSVIZ
2 // (c) 2020 Philipp Ruppel
3 
4 #pragma once
5 
6 #include "frame.h"
7 #include "text.h"
8 
9 #include "../core/topic.h"
10 #include "../core/watcher.h"
11 #include "../render/mesh.h"
12 #include "../scene/material.h"
13 #include "../scene/mesh.h"
14 
15 #include <visualization_msgs/Marker.h>
16 #include <visualization_msgs/MarkerArray.h>
17 
18 #include <unordered_map>
19 
21  std::mutex _mutex;
22  int _type = -1;
23  Eigen::Affine3d _pose = Eigen::Affine3d::Identity();
24  std::shared_ptr<Mesh> _mesh;
25  Color4 _color;
26  std::string _frame;
27  RenderOptions _render_options;
28  std::shared_ptr<Material> _material;
29  std::shared_ptr<SceneNode> _renderer;
30  std::string _text;
31  Watcher _mesh_watcher;
32  std::shared_ptr<MaterialOverride> _material_override;
33  double _scale = 1.0;
34 
35 public:
36  void update(const visualization_msgs::Marker &marker);
37  virtual void renderSync(const RenderSyncContext &context) override;
40  const std::shared_ptr<MaterialOverride> &material_override)
41  : _material_override(material_override) {}
42  VisualizationMarker(const visualization_msgs::Marker &marker) {
43  update(marker);
44  }
45 };
46 
48  std::mutex _mutex;
49  std::map<std::pair<std::string, int>, std::shared_ptr<VisualizationMarker>>
50  _markers;
51  std::vector<std::shared_ptr<VisualizationMarker>> _marker_list;
52  std::shared_ptr<MaterialOverride> _material_override;
53  void _update_nolock(const visualization_msgs::Marker &marker);
54 
55 public:
56  void update(const visualization_msgs::Marker &marker);
57  void update(const visualization_msgs::MarkerArray &marker_array);
58  virtual void renderSync(const RenderSyncContext &context) override;
61  const std::shared_ptr<MaterialOverride> &material_override)
62  : _material_override(material_override) {}
63  VisualizationMarkerArray(const visualization_msgs::Marker &marker) {
64  update(marker);
65  }
67  const visualization_msgs::MarkerArray &marker_array) {
68  update(marker_array);
69  }
70 };
71 
73 protected:
74  std::shared_ptr<MaterialOverride> _material_override =
75  std::make_shared<MaterialOverride>();
76  std::shared_ptr<VisualizationMarkerArray> _marker_array =
77  node()->create<VisualizationMarkerArray>(_material_override);
78  void update(const visualization_msgs::Marker &marker) {
79  _marker_array->update(marker);
80  }
81  void update(const visualization_msgs::MarkerArray &marker_array) {
82  _marker_array->update(marker_array);
83  }
85 
86 public:
87  PROPERTY(std::shared_ptr<MaterialOverride>, materialOverride,
88  _material_override);
89 };
90 DECLARE_TYPE(MarkerDisplayBase, MeshDisplayBase);
91 
92 class MarkerFrameDisplayBase : public GenericFrameDisplay<MarkerDisplayBase> {
93 
94 public:
95  // PROPERTY(Pose, transform);
96 };
97 
99 
100 public:
102  "visualization_marker");
103  MarkerDisplay();
104 };
105 DECLARE_TYPE_C(MarkerDisplay, MarkerDisplayBase, Marker);
106 
108 
109 public:
111  "visualization_marker_array");
113 };
114 DECLARE_TYPE_C(MarkerArrayDisplay, MarkerDisplayBase, Marker);
Definition: node.h:20
Definition: watcher.h:8