TAMSVIZ
Visualization and annotation tool for ROS
scenewindow.h
1 // TAMSVIZ
2 // (c) 2020 Philipp Ruppel
3 
4 #pragma once
5 
6 #include "renderwindow.h"
7 
8 #include "../core/interaction.h"
9 
10 #include "../render/renderer.h"
11 
12 class MeshDisplayBase;
13 class Interaction;
14 
15 class SceneWindow : public RenderWindowBase {
16  Eigen::Vector4f _bgcolor;
17  std::shared_ptr<UniformBufferBase> _uniform_buffer;
18  CameraBlock _camera_block;
19  Eigen::Matrix4d _view_matrix;
20  Eigen::Matrix4d _projection_matrix;
21  QPoint _mouse_position;
22  bool _left_dragged = false;
23  int _mouse_buttons = 0;
24  int _multi_sampling = 0;
25  std::mutex _action_mutex;
26  std::vector<std::function<void(const RenderWindowAsyncContext &)>>
27  _action_queue;
28  std::string _action_tag;
29  std::weak_ptr<Object> _picked;
30  Interaction _interaction;
31  double _pick_depth = 1.0;
32  uint32_t _pick_id = 0;
33  RenderTarget _render_target;
34  void interact(const Interaction &interaction);
35  void updateViewMatrix();
36  void pushAction(
37  const std::function<void(const RenderWindowAsyncContext &)> &action,
38  const std::string &tag = "");
39 
40 public:
41  SceneWindow();
42  virtual void
43  renderWindowSync(const RenderWindowSyncContext &context) override;
44  virtual void
45  renderWindowAsync(const RenderWindowAsyncContext &context) override;
46  virtual void handleEvent(QEvent *event) override;
47  virtual void paintHUD(QPainter *painter) override;
48  RenderTarget &renderTarget() { return _render_target; }
49  virtual void composite(int target) override;
50  PROPERTY(Eigen::Vector3d, viewPosition, Eigen::Vector3d(3, 3, 3));
51  PROPERTY(Eigen::Vector3d, viewTarget, Eigen::Vector3d(0, 0, 0));
52 };
53 DECLARE_TYPE(SceneWindow, RenderWindowBase);