VTK  9.7.1
vtkPropCollection.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 vtkPropCollection_h
19 #define vtkPropCollection_h
20 
21 #include "vtkCollection.h"
22 #include "vtkRenderingCoreModule.h" // For export macro
23 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
24 
25 #include "vtkProp.h" // Needed for inline methods
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkPropCollection : public vtkCollection
29 {
30 public:
31  static vtkPropCollection* New();
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
38  void AddItem(vtkProp* a);
39 
43  vtkProp* GetNextProp();
44 
48  vtkProp* GetLastProp();
49 
56  int GetNumberOfPaths();
57 
63  {
64  return static_cast<vtkProp*>(this->GetNextItemAsObject(cookie));
65  }
66 
67 protected:
68  vtkPropCollection() = default;
69  ~vtkPropCollection() override = default;
70 
71 private:
72  // hide the standard AddItem from the user and the compiler.
73  void AddItem(vtkObject* o) { this->vtkCollection::AddItem(o); }
74 
75  vtkPropCollection(const vtkPropCollection&) = delete;
76  void operator=(const vtkPropCollection&) = delete;
77 };
78 
80 {
81  this->vtkCollection::AddItem(a);
82 }
83 
85 {
86  return static_cast<vtkProp*>(this->GetNextItemAsObject());
87 }
88 
90 {
91  int numItems = this->GetNumberOfItems();
92  if (numItems == 0)
93  {
94  return nullptr;
95  }
96  else
97  {
98  return static_cast<vtkProp*>(this->GetItemAsObject(numItems - 1));
99  }
100 }
101 
102 VTK_ABI_NAMESPACE_END
103 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:35
vtkProp * GetNextProp(vtkCollectionSimpleIterator &cookie)
Reentrant safe way to get an object in a collection.
abstract base class for most VTK objects
Definition: vtkObject.h:52
int GetNumberOfItems() VTK_FUTURE_CONST
Return the number of items in the collection.
an ordered list of Props
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkCollection * New()
Construct an empty collection.
vtkProp * GetLastProp()
Get the last Prop in the list.
vtkObject * GetItemAsObject(int i) VTK_FUTURE_CONST
Get the i'th item in the collection.
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.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:39
vtkProp * GetNextProp()
Get the next Prop in the list.
#define VTK_MARSHALAUTO
vtkObject * GetNextItemAsObject()
Get the next item in the collection.