VTK-m  2.0
View.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_rendering_View_h
11 #define vtk_m_rendering_View_h
12 
13 #include <vtkm/rendering/vtkm_rendering_export.h>
14 
15 #include <vtkm/rendering/Camera.h>
16 #include <vtkm/rendering/Canvas.h>
17 #include <vtkm/rendering/Color.h>
18 #include <vtkm/rendering/Mapper.h>
19 #include <vtkm/rendering/Scene.h>
21 
22 #include <functional>
23 #include <memory>
24 
25 namespace vtkm
26 {
27 namespace rendering
28 {
29 
30 class VTKM_RENDERING_EXPORT View
31 {
32  struct InternalData;
33 
34 public:
35  View(const vtkm::rendering::Scene& scene,
36  const vtkm::rendering::Mapper& mapper,
37  const vtkm::rendering::Canvas& canvas,
38  const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
39  const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
40 
41  View(const vtkm::rendering::Scene& scene,
42  const vtkm::rendering::Mapper& mapper,
43  const vtkm::rendering::Canvas& canvas,
44  const vtkm::rendering::Camera& camera,
45  const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
46  const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
47 
48  virtual ~View();
49 
50  VTKM_CONT
51  const vtkm::rendering::Scene& GetScene() const;
52  VTKM_CONT
53  vtkm::rendering::Scene& GetScene();
54  VTKM_CONT
55  void SetScene(const vtkm::rendering::Scene& scene);
56 
57  VTKM_CONT
58  const vtkm::rendering::Mapper& GetMapper() const;
59  VTKM_CONT
60  vtkm::rendering::Mapper& GetMapper();
61 
62  VTKM_CONT
63  const vtkm::rendering::Canvas& GetCanvas() const;
64  VTKM_CONT
65  vtkm::rendering::Canvas& GetCanvas();
66 
67  VTKM_CONT
68  const vtkm::rendering::WorldAnnotator& GetWorldAnnotator() const;
69 
70  VTKM_CONT
71  const vtkm::rendering::Camera& GetCamera() const;
72  VTKM_CONT
73  vtkm::rendering::Camera& GetCamera();
74  VTKM_CONT
75  void SetCamera(const vtkm::rendering::Camera& camera);
76 
77  VTKM_CONT
78  const vtkm::rendering::Color& GetBackgroundColor() const;
79 
80  VTKM_CONT
81  void SetBackgroundColor(const vtkm::rendering::Color& color);
82 
83  VTKM_CONT
84  void SetForegroundColor(const vtkm::rendering::Color& color);
85 
86  VTKM_CONT
87  bool GetWorldAnnotationsEnabled() const { return this->WorldAnnotationsEnabled; }
88 
89  VTKM_CONT
90  void SetWorldAnnotationsEnabled(bool val) { this->WorldAnnotationsEnabled = val; }
91 
92  VTKM_CONT void SetRenderAnnotationsEnabled(bool val) { this->RenderAnnotationsEnabled = val; }
93  VTKM_CONT bool GetRenderAnnotationsEnabled() { return this->RenderAnnotationsEnabled; }
94 
95  virtual void Paint() = 0;
96  virtual void RenderScreenAnnotations() = 0;
97  virtual void RenderWorldAnnotations() = 0;
98 
99  void RenderAnnotations();
100 
101  void SaveAs(const std::string& fileName) const;
102 
103  VTKM_CONT
104  void SetAxisColor(vtkm::rendering::Color c);
105 
106  VTKM_CONT
107  void ClearTextAnnotations();
108 
109  VTKM_CONT
110  void AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
111 
112  VTKM_CONT
113  void ClearAdditionalAnnotations();
114 
115  VTKM_CONT
116  void AddAdditionalAnnotation(std::function<void(void)> ann);
117 
118 protected:
119  void SetupForWorldSpace(bool viewportClip = true);
120 
121  void SetupForScreenSpace(bool viewportClip = false);
122 
123 
125  bool WorldAnnotationsEnabled = true;
126  bool RenderAnnotationsEnabled = true;
127 
128 private:
129  std::shared_ptr<InternalData> Internal;
130 };
131 
132 } // namespace vtkm::rendering
133 } // namespace vtkm
134 
135 #endif //vtk_m_rendering_View_h
vtkm::rendering::View::GetRenderAnnotationsEnabled
VTKM_CONT bool GetRenderAnnotationsEnabled()
Definition: View.h:93
vtkm::rendering::Color
It's a color!
Definition: Color.h:28
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::rendering::View::GetWorldAnnotationsEnabled
VTKM_CONT bool GetWorldAnnotationsEnabled() const
Definition: View.h:87
vtkm::rendering::Color::white
static VTKM_RENDERING_EXPORT Color white
Definition: Color.h:130
Scene.h
vtkm::rendering::Mapper
Definition: Mapper.h:24
vtkm::rendering::Canvas
Definition: Canvas.h:34
TextAnnotation.h
vtkm::rendering::View::Internal
std::shared_ptr< InternalData > Internal
Definition: View.h:129
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::rendering::View::SetRenderAnnotationsEnabled
VTKM_CONT void SetRenderAnnotationsEnabled(bool val)
Definition: View.h:92
vtkm::rendering::WorldAnnotator
Definition: WorldAnnotator.h:27
vtkm::rendering::View
Definition: View.h:30
Camera.h
Color.h
vtkm::rendering::Camera
Definition: Camera.h:28
Canvas.h
Mapper.h
vtkm::rendering::Scene
Definition: Scene.h:27
vtkm::rendering::View::SetWorldAnnotationsEnabled
VTKM_CONT void SetWorldAnnotationsEnabled(bool val)
Definition: View.h:90