VTK  9.7.1
vtkActorCollection.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 vtkActorCollection_h
19 #define vtkActorCollection_h
20 
21 #include "vtkActor.h" // For inline methods
22 #include "vtkPropCollection.h"
23 #include "vtkRenderingCoreModule.h" // For export macro
24 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkProperty;
28 
29 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkActorCollection : public vtkPropCollection
30 {
31 public:
32  static vtkActorCollection* New();
34  void PrintSelf(ostream& os, vtkIndent indent) override;
35 
39  void AddItem(vtkActor* a);
40 
44  vtkActor* GetNextActor();
45 
49  vtkActor* GetLastActor();
50 
52 
57  vtkActor* GetNextItem();
58  vtkActor* GetLastItem();
60 
64  void ApplyProperties(vtkProperty* p);
65 
71  {
72  return static_cast<vtkActor*>(this->GetNextItemAsObject(cookie));
73  }
74 
75 protected:
76  vtkActorCollection() = default;
77  ~vtkActorCollection() override = default;
78 
79 private:
80  // hide the standard AddItem from the user and the compiler.
81  void AddItem(vtkObject* o) { this->vtkCollection::AddItem(o); }
82  void AddItem(vtkProp* o) { this->vtkPropCollection::AddItem(o); }
83 
84  vtkActorCollection(const vtkActorCollection&) = delete;
85  void operator=(const vtkActorCollection&) = delete;
86 };
87 
89 {
90  this->vtkCollection::AddItem(a);
91 }
92 
94 {
95  return static_cast<vtkActor*>(this->GetNextItemAsObject());
96 }
97 
99 {
100  int numItems = this->GetNumberOfItems();
101  if (numItems == 0)
102  {
103  return nullptr;
104  }
105  else
106  {
107  return static_cast<vtkActor*>(this->GetItemAsObject(numItems - 1));
108  }
109 }
110 
112 {
113  return this->GetNextActor();
114 }
115 
117 {
118  return this->GetLastActor();
119 }
120 
121 VTK_ABI_NAMESPACE_END
122 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:35
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
abstract base class for most VTK objects
Definition: vtkObject.h:52
vtkActor * GetLastItem()
Access routines that are provided for compatibility with previous version of VTK. ...
represent surface properties of a geometric object
Definition: vtkProperty.h:59
int GetNumberOfItems() VTK_FUTURE_CONST
Return the number of items in the collection.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
an ordered list of Props
void AddItem(vtkActor *a)
Add an actor to the bottom of the list.
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkActor * GetLastActor()
Get the last actor in the list.
vtkActor * GetNextActor(vtkCollectionSimpleIterator &cookie)
Reentrant safe way to get an object in a collection.
vtkObject * GetItemAsObject(int i) VTK_FUTURE_CONST
Get the i'th item in the collection.
vtkActor * GetNextItem()
Access routines that are provided for compatibility with previous version of VTK. ...
an ordered list of actors
void AddItem(vtkObject *)
Add given item to the bottom (end) of the collection.
void AddItem(vtkProp *a)
Add a Prop to the bottom of the list.
#define VTK_MARSHALAUTO
vtkActor * GetNextActor()
Get the next actor in the list.
vtkObject * GetNextItemAsObject()
Get the next item in the collection.
static vtkPropCollection * New()