VTK: Rendering/CellGrid/vtkOpenGLCellGridRenderRequest.h Source File

| VTK 9.3.1

vtkOpenGLCellGridRenderRequest.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
18 #ifndef vtkOpenGLCellGridRenderRequest_h
19 #define vtkOpenGLCellGridRenderRequest_h
20 #include "vtkCellGridQuery.h"
21 #include "vtkRenderingCellGridModule.h" // For export macro
22 #include "vtkStringToken.h" // for ivars
23
24 #include <memory> // for unique_ptr
25 #include <unordered_map> // for this->State
26
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkActor;
29 class vtkOpenGLCellGridMapper;
30 class vtkRenderer;
31 class vtkWindow;
32
33 class VTKRENDERINGCELLGRID_EXPORT vtkOpenGLCellGridRenderRequest : public vtkCellGridQuery
34 {
35 public:
37 class StateBase
38 {
39 public:
40 virtual ~StateBase() = default;
41 };
42
55 enum RenderableGeometry : unsigned char
56 {
57 VERTICES = 1,
58 EDGES = 2,
59 FACES = 4,
60 VOLUMES = 8,
61 SURFACE_WITH_EDGES = EDGES | FACES,
62 ALL = VERTICES | EDGES | FACES | VOLUMES
63 };
64
65 vtkTypeMacro(vtkOpenGLCellGridRenderRequest, vtkCellGridQuery);
66 static vtkOpenGLCellGridRenderRequest* New();
67 void PrintSelf(std::ostream& os, vtkIndent indent) override;
68
74 virtual void SetMapper(vtkOpenGLCellGridMapper* mapper);
75 vtkGetObjectMacro(Mapper, vtkOpenGLCellGridMapper);
76
82 virtual void SetActor(vtkActor* actor);
83 vtkGetObjectMacro(Actor, vtkActor);
84
90 virtual void SetRenderer(vtkRenderer* renderer);
91 vtkGetObjectMacro(Renderer, vtkRenderer);
92
98 virtual void SetWindow(vtkWindow* window);
99 vtkGetObjectMacro(Window, vtkWindow);
100
108 vtkGetMacro(ShapesToDraw, char);
109 vtkSetClampMacro(ShapesToDraw, char, 1, 9);
110
112 void Initialize() override;
114 void Finalize() override;
115
124 vtkGetMacro(IsReleasingResources, bool);
125 vtkSetMacro(IsReleasingResources, bool);
126
131 template <typename StateType>
132 StateType* GetState(vtkStringToken cellType)
133 {
134 auto it = this->State.find(cellType);
135 if (it == this->State.end())
136 {
137 it = this->State.insert(std::make_pair(cellType, std::unique_ptr<StateBase>(new StateType)))
138 .first;
139 }
140 return static_cast<StateType*>(it->second.get());
141 }
142
143 protected:
144 vtkOpenGLCellGridRenderRequest();
145 ~vtkOpenGLCellGridRenderRequest() override;
146
147 vtkOpenGLCellGridMapper* Mapper{ nullptr };
148 vtkActor* Actor{ nullptr };
149 vtkRenderer* Renderer{ nullptr };
150 vtkWindow* Window{ nullptr };
151 bool IsReleasingResources{ false };
152 char ShapesToDraw{ RenderableGeometry::ALL };
153 std::unordered_map<vtkStringToken, std::unique_ptr<StateBase>> State;
154
155 private:
156 vtkOpenGLCellGridRenderRequest(const vtkOpenGLCellGridRenderRequest&) = delete;
157 void operator=(const vtkOpenGLCellGridRenderRequest&) = delete;
158 };
159
160 VTK_ABI_NAMESPACE_END
161 #endif // vtkOpenGLCellGridRenderRequest_h
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
vtkCellGridQuery
Perform an operation on cells in a vtkCellMetadata instance.
Definition: vtkCellGridQuery.h:27
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkOpenGLCellGridMapper
CellGrid mapper using OpenGL to render exotic finite element fields and cells.
Definition: vtkOpenGLCellGridMapper.h:18
vtkOpenGLCellGridRenderRequest::StateBase
An empty base class that responders should inherit to store state using GetState<Subclass>().
Definition: vtkOpenGLCellGridRenderRequest.h:38
vtkOpenGLCellGridRenderRequest::StateBase::~StateBase
virtual ~StateBase()=default
vtkOpenGLCellGridRenderRequest
State used by vtkOpenGLCellGridMapper during rendering.
Definition: vtkOpenGLCellGridRenderRequest.h:34
vtkOpenGLCellGridRenderRequest::New
static vtkOpenGLCellGridRenderRequest * New()
vtkOpenGLCellGridRenderRequest::PrintSelf
void PrintSelf(std::ostream &os, vtkIndent indent) override
vtkOpenGLCellGridRenderRequest::SetWindow
virtual void SetWindow(vtkWindow *window)
Set/get a window (used when IsReleasingResources is true).
vtkOpenGLCellGridRenderRequest::RenderableGeometry
RenderableGeometry
An enumeration of which shapes to render.
Definition: vtkOpenGLCellGridRenderRequest.h:56
vtkOpenGLCellGridRenderRequest::SetMapper
virtual void SetMapper(vtkOpenGLCellGridMapper *mapper)
Set/get the mapper which owns this request (so responders can inspect its configuration).
vtkOpenGLCellGridRenderRequest::SetRenderer
virtual void SetRenderer(vtkRenderer *renderer)
Set/get the renderer responders should use to draw cells.
vtkOpenGLCellGridRenderRequest::State
std::unordered_map< vtkStringToken, std::unique_ptr< StateBase > > State
Definition: vtkOpenGLCellGridRenderRequest.h:153
vtkOpenGLCellGridRenderRequest::Initialize
void Initialize() override
This is invoked before processing any cell types during a render.
vtkOpenGLCellGridRenderRequest::SetActor
virtual void SetActor(vtkActor *actor)
Set/get the actor which responders should use to draw cells.
vtkOpenGLCellGridRenderRequest::~vtkOpenGLCellGridRenderRequest
~vtkOpenGLCellGridRenderRequest() override
vtkOpenGLCellGridRenderRequest::Finalize
void Finalize() override
This is invoked after processing all cell types during a render.
vtkOpenGLCellGridRenderRequest::vtkOpenGLCellGridRenderRequest
vtkOpenGLCellGridRenderRequest()
vtkOpenGLCellGridRenderRequest::GetState
StateType * GetState(vtkStringToken cellType)
Return a state object of the given type.
Definition: vtkOpenGLCellGridRenderRequest.h:132
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:71
vtkStringToken
Represent a string by its integer hash.
Definition: vtkStringToken.h:34
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkCellGridQuery.h
vtkStringToken.h