VTK-m  2.2
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 
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 
32 {
33  struct InternalData;
34 
35 public:
36  View(const vtkm::rendering::Scene& scene,
37  const vtkm::rendering::Mapper& mapper,
38  const vtkm::rendering::Canvas& canvas,
39  const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
40  const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
41 
42  View(const vtkm::rendering::Scene& scene,
43  const vtkm::rendering::Mapper& mapper,
44  const vtkm::rendering::Canvas& canvas,
45  const vtkm::rendering::Camera& camera,
46  const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
47  const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
48 
49  virtual ~View();
50 
52  VTKM_CONT
53  const vtkm::rendering::Scene& GetScene() const;
55  VTKM_CONT
56  vtkm::rendering::Scene& GetScene();
58  VTKM_CONT
59  void SetScene(const vtkm::rendering::Scene& scene);
60 
62  VTKM_CONT
63  const vtkm::rendering::Mapper& GetMapper() const;
65  VTKM_CONT
66  vtkm::rendering::Mapper& GetMapper();
67 
69  VTKM_CONT
70  const vtkm::rendering::Canvas& GetCanvas() const;
72  VTKM_CONT
73  vtkm::rendering::Canvas& GetCanvas();
74 
75  VTKM_CONT
76  const vtkm::rendering::WorldAnnotator& GetWorldAnnotator() const;
77 
79  VTKM_CONT
80  const vtkm::rendering::Camera& GetCamera() const;
82  VTKM_CONT
83  vtkm::rendering::Camera& GetCamera();
85  VTKM_CONT
86  void SetCamera(const vtkm::rendering::Camera& camera);
87 
89  VTKM_CONT
90  const vtkm::rendering::Color& GetBackgroundColor() const;
92  VTKM_CONT
93  void SetBackgroundColor(const vtkm::rendering::Color& color);
94 
99  VTKM_CONT
100  void SetForegroundColor(const vtkm::rendering::Color& color);
101 
102  VTKM_CONT
103  bool GetWorldAnnotationsEnabled() const { return this->WorldAnnotationsEnabled; }
104 
105  VTKM_CONT
106  void SetWorldAnnotationsEnabled(bool val) { this->WorldAnnotationsEnabled = val; }
107 
108  VTKM_CONT void SetRenderAnnotationsEnabled(bool val) { this->RenderAnnotationsEnabled = val; }
109  VTKM_CONT bool GetRenderAnnotationsEnabled() const { return this->RenderAnnotationsEnabled; }
110 
112  virtual void Paint() = 0;
113  virtual void RenderScreenAnnotations() = 0;
114  virtual void RenderWorldAnnotations() = 0;
115 
116  void RenderAnnotations();
117 
119  void SaveAs(const std::string& fileName) const;
120 
121  VTKM_CONT
122  void SetAxisColor(vtkm::rendering::Color c);
123 
124  VTKM_CONT
125  void ClearTextAnnotations();
126 
127  VTKM_CONT
128  void AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
129 
130  VTKM_CONT
131  void ClearAdditionalAnnotations();
132 
133  VTKM_CONT
134  void AddAdditionalAnnotation(std::function<void(void)> ann);
135 
136 protected:
137  void SetupForWorldSpace(bool viewportClip = true);
138 
139  void SetupForScreenSpace(bool viewportClip = false);
140 
141 
143  bool WorldAnnotationsEnabled = true;
144  bool RenderAnnotationsEnabled = true;
145 
146 private:
147  std::unique_ptr<InternalData> Internal;
148 };
149 
150 } // namespace vtkm::rendering
151 } // namespace vtkm
152 
153 #endif //vtk_m_rendering_View_h
vtkm::rendering::View::SetRenderAnnotationsEnabled
void SetRenderAnnotationsEnabled(bool val)
Definition: View.h:108
vtkm::rendering::Color
Representation of a color.
Definition: Color.h:29
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_RENDERING_EXPORT
#define VTKM_RENDERING_EXPORT
Definition: vtkm_rendering_export.h:44
vtkm_rendering_export.h
vtkm::rendering::Color::white
static Color white
Definition: Color.h:141
Scene.h
vtkm::rendering::Mapper
Converts data into commands to a rendering system.
Definition: Mapper.h:29
vtkm::rendering::Canvas
Represents the image space that is the target of rendering.
Definition: Canvas.h:35
TextAnnotation.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::rendering::WorldAnnotator
Definition: WorldAnnotator.h:27
vtkm::rendering::View::GetWorldAnnotationsEnabled
bool GetWorldAnnotationsEnabled() const
Definition: View.h:103
vtkm::rendering::View
The abstract class representing the view of a rendering scene.
Definition: View.h:31
vtkm::rendering::View::GetRenderAnnotationsEnabled
bool GetRenderAnnotationsEnabled() const
Definition: View.h:109
Camera.h
Color.h
vtkm::rendering::Camera
Specifies the viewport for a rendering.
Definition: Camera.h:37
Canvas.h
Mapper.h
vtkm::rendering::Scene
A simple collection of things to render.
Definition: Scene.h:30
vtkm::rendering::View::Internal
std::unique_ptr< InternalData > Internal
Definition: View.h:147
vtkm::rendering::View::SetWorldAnnotationsEnabled
void SetWorldAnnotationsEnabled(bool val)
Definition: View.h:106