VTK  9.3.1
vtkViewNode.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
17 #ifndef vtkViewNode_h
18 #define vtkViewNode_h
19 
20 #include "vtkObject.h"
21 #include "vtkRenderingSceneGraphModule.h" // For export macro
22 #include "vtkWeakPointer.h" //avoid ref loop to parent
23 #include <list> // for ivar
24 #include <map> // for ivar
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkCollection;
28 class vtkViewNodeFactory;
29 
30 class VTKRENDERINGSCENEGRAPH_EXPORT vtkViewNode : public vtkObject
31 {
32 public:
33  vtkTypeMacro(vtkViewNode, vtkObject);
34  void PrintSelf(ostream& os, vtkIndent indent) override;
35 
37 
40  vtkGetObjectMacro(Renderable, vtkObject);
42 
46  virtual void Build(bool /* prepass */) {}
47 
51  virtual void Synchronize(bool /* prepass */) {}
52 
56  virtual void Render(bool /*prepass*/) {}
57 
61  virtual void Invalidate(bool /*prepass*/) {}
62 
64 
67  virtual void SetParent(vtkViewNode*);
68  virtual vtkViewNode* GetParent();
70 
72 
75  virtual std::list<vtkViewNode*> const& GetChildren() { return this->Children; }
77 
79 
83  virtual void SetMyFactory(vtkViewNodeFactory*);
84  vtkGetObjectMacro(MyFactory, vtkViewNodeFactory);
86 
91  vtkViewNode* GetViewNodeFor(vtkObject*);
92 
96  vtkViewNode* GetFirstAncestorOfType(const char* type);
97 
101  vtkViewNode* GetFirstChildOfType(const char* type);
102 
107  virtual void SetRenderable(vtkObject*);
108 
109  // if you want to traverse your children in a specific order
110  // or way override this method
111  virtual void Traverse(int operation);
112 
113  virtual void TraverseAllPasses();
114 
119 
124  {
129  invalidate
130  };
131 
132 protected:
133  vtkViewNode();
134  ~vtkViewNode() override;
135 
136  static const char* operation_type_strings[];
137 
138  virtual void Apply(int operation, bool prepass);
139 
141 
145  void AddMissingNode(vtkObject* obj);
146  void AddMissingNodes(vtkCollection* col);
148 
150 
154  void PrepareNodes();
156 
161  void RemoveUnusedNodes();
162 
166  virtual vtkViewNode* CreateViewNode(vtkObject* obj);
167 
170  std::list<vtkViewNode*> Children;
172  std::map<vtkObject*, vtkViewNode*> Renderables;
173  friend class vtkViewNodeFactory;
174 
175  // used in the prepare/add/remove operations
176  bool Used;
177 
178 private:
179  vtkViewNode(const vtkViewNode&) = delete;
180  void operator=(const vtkViewNode&) = delete;
181 };
182 
183 VTK_ABI_NAMESPACE_END
184 #endif
virtual void Build(bool)
Builds myself.
Definition: vtkViewNode.h:46
vtkViewNodeFactory * MyFactory
Definition: vtkViewNode.h:171
std::list< vtkViewNode * > Children
Definition: vtkViewNode.h:170
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
operation_type
internal mechanics of graph traversal and actions
Definition: vtkViewNode.h:123
virtual void Synchronize(bool)
Ensures that my state agrees with my Renderable's.
Definition: vtkViewNode.h:51
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual std::list< vtkViewNode * > const & GetChildren()
Access nodes that this one owns.
Definition: vtkViewNode.h:75
vtkWeakPointer< vtkViewNode > Parent
Definition: vtkViewNode.h:169
vtkMTimeType RenderTime
Allows smart caching.
Definition: vtkViewNode.h:118
std::map< vtkObject *, vtkViewNode * > Renderables
Definition: vtkViewNode.h:172
factory that chooses vtkViewNodes to create
virtual void Render(bool)
Makes calls to make self visible.
Definition: vtkViewNode.h:56
virtual void Invalidate(bool)
Clear any cached data.
Definition: vtkViewNode.h:61
create and manipulate ordered lists of objects
Definition: vtkCollection.h:44
vtkObject * Renderable
Definition: vtkViewNode.h:168
a node within a VTK scene graph
Definition: vtkViewNode.h:30