iMSTK
Interactive Medical Simulation Toolkit
imstkRenderer.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkEventObject.h"
10 #include "imstkMath.h"
11 #include "imstkColor.h"
12 
13 #include <unordered_map>
14 
15 namespace imstk
16 {
17 struct SSAOConfig
18 {
19  bool m_enableSSAO = false;
20  bool m_SSAOBlur = false; // blur occlusion
21  double m_SSAORadius = 0.1; // Sampling radius
22  double m_SSAOBias = 0.001; // Bias/offset
23  unsigned int m_KernelSize = 128; // Number of samples in the radius
24 };
25 
27 {
28  // Blue background
29  Color m_BGColor1 = Color(0.3285, 0.3285, 0.6525);
30  Color m_BGColor2 = Color(0.13836, 0.13836, 0.2748);
31 
32  // ScreenSpace Ambient Occlusion
33  SSAOConfig m_ssaoConfig;
34 };
35 
41 class Renderer : public EventObject, public std::enable_shared_from_this<Renderer>
42 {
43 public:
47  enum class Mode
48  {
49  Empty,
50  Debug,
51  Simulation
52  };
53 
54  Renderer() : m_config(std::make_shared<RendererConfig>()) { }
55  ~Renderer() override = default;
56 
57  virtual void initialize() = 0;
58 
59  bool getIsInitialized() const { return m_isInitialized; }
60 
64  virtual void setMode(const Renderer::Mode mode, const bool enableVR)
65  {
66  m_VrEnabled = enableVR;
67  m_currentMode = mode;
68  }
69 
73  virtual void setTimeTable(const std::unordered_map<std::string, double>&) { }
74 
78  virtual void setTimeTableVisibility(const bool) { }
79  virtual bool getTimeTableVisibility() const { return false; }
81 
85  virtual const Renderer::Mode& getMode() const { return m_currentMode; }
86 
90  virtual void updateBackground(const Vec3d color1, const Vec3d color2 = Vec3d::Zero(), const bool gradientBackground = false) = 0;
91 
95  std::shared_ptr<RendererConfig> getRenderConfig() const { return m_config; }
96 
100  virtual void setConfig(std::shared_ptr<RendererConfig> config) = 0;
101 
102 protected:
103  bool m_VrEnabled = false;
104  bool m_isInitialized = false;
105  Renderer::Mode m_currentMode = Renderer::Mode::Simulation;
106 
107  std::shared_ptr<RendererConfig> m_config;
108 };
109 } // namespace imstk
Compound Geometry.
Rendering window manager and contains user API to configure the rendering with various backends...
Definition: imstkRenderer.h:41
virtual void setMode(const Renderer::Mode mode, const bool enableVR)
Set rendering mode.
Definition: imstkRenderer.h:64
virtual void setTimeTable(const std::unordered_map< std::string, double > &)
Sets the benchmarking table using unordered_map.
Definition: imstkRenderer.h:73
Color in RGB space.
Definition: imstkColor.h:24
EventObject is the base class for all objects in iMSTK that can receive and emit events. It supports direct and queued observer functions. Direct observers receive events immediately on the same thread This can either be posted on an object or be a function pointer Queued observers receive events within their queue which they can process whenever they like. These can be connected with the connect/queuedConnect/disconnect functions Lambda recievers cannot be disconnected unless all receivers to a signal are removed.
virtual void setTimeTableVisibility(const bool)
Get/Set the visibility of the benchmark graph.
Definition: imstkRenderer.h:78
virtual const Renderer::Mode & getMode() const
Get rendering mode.
Definition: imstkRenderer.h:85
Mode
Enumerations for the render mode.
Definition: imstkRenderer.h:47
std::shared_ptr< RendererConfig > getRenderConfig() const
Get the render config.
Definition: imstkRenderer.h:95