VTK  9.3.20240329
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 
84  vtkGetObjectMacro(MyFactory, vtkViewNodeFactory);
86 
92 
97 
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:
134  ~vtkViewNode() override;
135 
136  static const char* operation_type_strings[];
137 
138  virtual void Apply(int operation, bool prepass);
139 
141 
148 
150 
154  void PrepareNodes();
156 
162 
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
create and manipulate ordered lists of objects
Definition: vtkCollection.h:46
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
factory that chooses vtkViewNodes to create
a node within a VTK scene graph
Definition: vtkViewNode.h:31
vtkViewNode * GetFirstChildOfType(const char *type)
Find the first child of the desired type.
virtual void SetRenderable(vtkObject *)
Allow explicit setting of the renderable for a view node.
virtual vtkViewNode * CreateViewNode(vtkObject *obj)
Create the correct ViewNode subclass for the passed in object.
virtual void Apply(int operation, bool prepass)
virtual void TraverseAllPasses()
vtkWeakPointer< vtkViewNode > Parent
Definition: vtkViewNode.h:169
void AddMissingNodes(vtkCollection *col)
convenience method to add node or nodes if missing from our current list
std::list< vtkViewNode * > Children
Definition: vtkViewNode.h:170
virtual void Render(bool)
Makes calls to make self visible.
Definition: vtkViewNode.h:56
virtual std::list< vtkViewNode * > const & GetChildren()
Access nodes that this one owns.
Definition: vtkViewNode.h:75
virtual vtkViewNode * GetParent()
Access the node that owns this one.
~vtkViewNode() override
void RemoveUnusedNodes()
Called after PrepareNodes and AddMissingNodes removes any extra leftover nodes.
vtkObject * Renderable
Definition: vtkViewNode.h:168
vtkMTimeType RenderTime
Allows smart caching.
Definition: vtkViewNode.h:118
vtkViewNodeFactory * MyFactory
Definition: vtkViewNode.h:171
operation_type
internal mechanics of graph traversal and actions
Definition: vtkViewNode.h:124
std::map< vtkObject *, vtkViewNode * > Renderables
Definition: vtkViewNode.h:172
void AddMissingNode(vtkObject *obj)
convenience method to add node or nodes if missing from our current list
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkViewNode * GetViewNodeFor(vtkObject *)
Returns the view node that corresponding to the provided object Will return NULL if a match is not fo...
void PrepareNodes()
Called first before adding missing nodes.
virtual void Traverse(int operation)
virtual void Build(bool)
Builds myself.
Definition: vtkViewNode.h:46
virtual void Invalidate(bool)
Clear any cached data.
Definition: vtkViewNode.h:61
virtual void SetMyFactory(vtkViewNodeFactory *)
A factory that creates particular subclasses for different rendering back ends.
vtkViewNode * GetFirstAncestorOfType(const char *type)
Find the first parent/grandparent of the desired type.
virtual void Synchronize(bool)
Ensures that my state agrees with my Renderable's.
Definition: vtkViewNode.h:51
virtual void SetParent(vtkViewNode *)
Access the node that owns this one.
@ type
Definition: vtkX3D.h:516
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270