VTK  9.7.1
vtkActor2DCollection.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
16 #ifndef vtkActor2DCollection_h
17 #define vtkActor2DCollection_h
18 
19 #include "vtkPropCollection.h"
20 #include "vtkRenderingCoreModule.h" // For export macro
21 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
22 
23 #include "vtkActor2D.h" // Needed for inline methods
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkViewport;
27 
28 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkActor2DCollection : public vtkPropCollection
29 {
30 public:
35  static vtkActor2DCollection* New();
36 
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
44  void Sort();
45 
50  void AddItem(vtkActor2D* a);
51 
53 
56  int IsItemPresent(vtkActor2D* a);
58  vtkActor2D* GetNextActor2D();
59  vtkActor2D* GetLastActor2D();
61 
63 
68  vtkActor2D* GetNextItem();
69  vtkActor2D* GetLastItem();
71 
75  void RenderOverlay(vtkViewport* viewport);
76 
82  {
83  return static_cast<vtkActor2D*>(this->GetNextItemAsObject(cookie));
84  }
85 
86 protected:
87  vtkActor2DCollection() = default;
88  ~vtkActor2DCollection() override;
89 
90 private:
91  // hide the standard AddItem from the user and the compiler.
92  void AddItem(vtkObject* o) { this->vtkCollection::AddItem(o); }
93  void AddItem(vtkProp* o) { this->vtkPropCollection::AddItem(o); }
94  int IsItemPresent(vtkObject* o) { return this->vtkCollection::IsItemPresent(o); }
96  {
98  }
99 
101  void operator=(const vtkActor2DCollection&) = delete;
102 };
103 
105 {
106  return this->vtkCollection::IsItemPresent(a);
107 }
108 
110 {
112 }
113 
115 {
116  return static_cast<vtkActor2D*>(this->GetNextItemAsObject());
117 }
118 
120 {
121  int numItems = this->GetNumberOfItems();
122  if (numItems == 0)
123  {
124  return nullptr;
125  }
126  else
127  {
128  return static_cast<vtkActor2D*>(this->GetItemAsObject(numItems - 1));
129  }
130 }
131 
133 {
134  return this->GetNextActor2D();
135 }
136 
138 {
139  return this->GetLastActor2D();
140 }
141 
142 VTK_ABI_NAMESPACE_END
143 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:35
a list of 2D actors
abstract base class for most VTK objects
Definition: vtkObject.h:52
int IndexOfFirstOccurrence(vtkActor2D *a)
Standard Collection methods.
abstract specification for Viewports
Definition: vtkViewport.h:46
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.
a actor that draws 2D data
Definition: vtkActor2D.h:35
vtkActor2D * GetLastActor2D()
Standard Collection methods.
an ordered list of Props
a simple class to control print indentation
Definition: vtkIndent.h:28
int IndexOfFirstOccurrence(vtkObject *a) const
Search for the given item and return the 0-based index of its first occurrence in the collection...
vtkActor2D * GetNextItem()
Access routines that are provided for compatibility with previous version of VTK. ...
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.
int IsItemPresent(vtkActor2D *a)
Standard Collection methods.
void AddItem(vtkProp *a)
Add a Prop to the bottom of the list.
void Sort(std::function< bool(vtkObject *, vtkObject *)> f)
Sort the collection according to a given std::function that should return true if the first vtkObject...
vtkActor2D * GetNextActor2D(vtkCollectionSimpleIterator &cookie)
Reentrant safe way to get an object in a collection.
vtkActor2D * GetNextActor2D()
Standard Collection methods.
int IsItemPresent(vtkObject *a) VTK_FUTURE_CONST
Search for the given item and return the 1-based index of its first occurrence in the collection...
#define VTK_MARSHALAUTO
vtkObject * GetNextItemAsObject()
Get the next item in the collection.
static vtkPropCollection * New()
vtkActor2D * GetLastItem()
Access routines that are provided for compatibility with previous version of VTK. ...