VTK  9.3.20240918
vtkCellGridRenderRequest.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 vtkCellGridRenderRequest_h
19#define vtkCellGridRenderRequest_h
20#include "vtkCellGridQuery.h"
21#include "vtkRenderingCoreModule.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
27VTK_ABI_NAMESPACE_BEGIN
28class vtkActor;
30class vtkRenderer;
31class vtkWindow;
32
33class VTKRENDERINGCORE_EXPORT vtkCellGridRenderRequest : public vtkCellGridQuery
34{
35public:
36 class VTKRENDERINGCORE_EXPORT BaseState
37 {
38 public:
39 BaseState() = default;
40 virtual ~BaseState() = default; // Force class to be polymorphic.
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
67 void PrintSelf(ostream& os, vtkIndent indent) override;
68
74 virtual void SetMapper(vtkCellGridMapper* mapper);
75 vtkGetObjectMacro(Mapper, vtkCellGridMapper);
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 bool Initialize() override;
114 bool Finalize() override;
115
124 vtkGetMacro(IsReleasingResources, bool);
125 vtkSetMacro(IsReleasingResources, bool);
126
131 template <typename StateType>
132 StateType* GetState(vtkStringToken cellType, bool create = true)
133 {
134 auto it = this->State.find(cellType);
135 if (it != this->State.end())
136 {
137 return static_cast<StateType*>(it->second.get());
138 }
139
140 if (create)
141 {
142 it = this->State.insert(std::make_pair(cellType, std::unique_ptr<BaseState>(new StateType)))
143 .first;
144 return static_cast<StateType*>(it->second.get());
145 }
146
147 return nullptr;
148 }
149
150protected:
153
154 vtkCellGridMapper* Mapper{ nullptr };
155 vtkActor* Actor{ nullptr };
156 vtkRenderer* Renderer{ nullptr };
157 vtkWindow* Window{ nullptr };
158 bool IsReleasingResources{ false };
159 char ShapesToDraw{ RenderableGeometry::ALL };
160 std::unordered_map<vtkStringToken, std::unique_ptr<BaseState>> State;
161
162private:
164 void operator=(const vtkCellGridRenderRequest&) = delete;
165};
166
167VTK_ABI_NAMESPACE_END
168#endif // vtkCellGridRenderRequest_h
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
map a vtkCellGrid to graphics primitives.
Perform an operation on cells in a vtkCellMetadata instance.
State used by vtkCellGridMapper during rendering.
virtual void SetMapper(vtkCellGridMapper *mapper)
Set/get the mapper which owns this request (so responders can inspect its configuration).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
RenderableGeometry
An enumeration of which shapes to render.
~vtkCellGridRenderRequest() override
static vtkCellGridRenderRequest * New()
virtual void SetActor(vtkActor *actor)
Set/get the actor which responders should use to draw cells.
StateType * GetState(vtkStringToken cellType, bool create=true)
Return a state object of the given type.
virtual void SetWindow(vtkWindow *window)
Set/get a window (used when IsReleasingResources is true).
vtkCellGridRenderRequest()=default
bool Initialize() override
This is invoked before processing any cell types during a render.
std::unordered_map< vtkStringToken, std::unique_ptr< BaseState > > State
bool Finalize() override
This is invoked after processing all cell types during a render.
virtual void SetRenderer(vtkRenderer *renderer)
Set/get the renderer responders should use to draw cells.
a simple class to control print indentation
Definition vtkIndent.h:108
abstract specification for renderers
Represent a string by its integer hash.
window superclass for vtkRenderWindow
Definition vtkWindow.h:48