VTK  9.2.6
vtkCompositeDataDisplayAttributes.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCompositeDataDisplayAttributes.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
29
30#ifndef vtkCompositeDataDisplayAttributes_h
31#define vtkCompositeDataDisplayAttributes_h
32#include <functional> // for std::function
33#include <unordered_map> // for std::unordered_map
34
35#include "vtkColor.h" // for vtkColor3d
36#include "vtkObject.h"
37#include "vtkRenderingCoreModule.h" // for export macro
38
39class vtkBoundingBox;
40class vtkDataObject;
41
42class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
43{
44public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
53
55
58 void SetBlockVisibility(vtkDataObject* data_object, bool visible);
59 bool GetBlockVisibility(vtkDataObject* data_object) const;
61
66 bool HasBlockVisibility(vtkDataObject* data_object) const;
67
72
78
83
85
88 void SetBlockPickability(vtkDataObject* data_object, bool visible);
89 bool GetBlockPickability(vtkDataObject* data_object) const;
91
96 bool HasBlockPickability(vtkDataObject* data_object) const;
97
102
108
110
113 void SetBlockColor(vtkDataObject* data_object, const double color[3]);
114 void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
117
121 bool HasBlockColors() const;
122
126 bool HasBlockColor(vtkDataObject* data_object) const;
127
131 void RemoveBlockColor(vtkDataObject* data_object);
132
137
139
142 void SetBlockOpacity(vtkDataObject* data_object, double opacity);
143 double GetBlockOpacity(vtkDataObject* data_object) const;
145
149 bool HasBlockOpacities() const;
150
154 bool HasBlockOpacity(vtkDataObject* data_object) const;
155
160
165
167
171 void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
172 const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
174
178 bool HasBlockMaterials() const;
179
183 bool HasBlockMaterial(vtkDataObject* data_object) const;
184
189
194
202 vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
203
209 const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
210
211 void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
212 {
213 for (auto entry : this->BlockVisibilities)
214 {
215 if (visitor(entry.first, entry.second))
216 {
217 break;
218 }
219 }
220 }
221
222protected:
225
226private:
228 void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
229
238 static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
239 vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
240
241 using BoolMap = std::unordered_map<vtkDataObject*, bool>;
242 using DoubleMap = std::unordered_map<vtkDataObject*, double>;
243 using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
244 using StringMap = std::unordered_map<vtkDataObject*, std::string>;
245
246 BoolMap BlockVisibilities;
247 ColorMap BlockColors;
248 DoubleMap BlockOpacities;
249 StringMap BlockMaterials;
250 BoolMap BlockPickabilities;
251};
252
253#endif // vtkCompositeDataDisplayAttributes_h
Fast, simple class for representing and operating on 3D bounds.
bool GetBlockPickability(vtkDataObject *data_object) const
Set/get the pickability for the block with data_object.
void SetBlockMaterial(vtkDataObject *data_object, const std::string &material)
Set/get the material for the block with data_object.
bool HasBlockOpacities() const
Returns true if any block has an opacity set.
bool HasBlockVisibilities() const
Returns true if any block has any block visibility is set.
bool HasBlockMaterials() const
Returns true if any block has an material set.
void SetBlockOpacity(vtkDataObject *data_object, double opacity)
Set/get the opacity for the block with data_object.
void SetBlockColor(vtkDataObject *data_object, const double color[3])
Set/get the color for the block with data_object.
void SetBlockVisibility(vtkDataObject *data_object, bool visible)
Set/get the visibility for the block with data_object.
bool GetBlockVisibility(vtkDataObject *data_object) const
Set/get the visibility for the block with data_object.
void SetBlockPickability(vtkDataObject *data_object, bool visible)
Set/get the pickability for the block with data_object.
void RemoveBlockVisibilities()
Removes all block visibility flags.
bool HasBlockOpacity(vtkDataObject *data_object) const
Returns true if the block with data_object has an opacity set.
bool HasBlockPickability(vtkDataObject *data_object) const
Returns true if the block with the given data_object has a pickability set.
static vtkCompositeDataDisplayAttributes * New()
void RemoveBlockOpacities()
Removes all block opacities.
void RemoveBlockColor(vtkDataObject *data_object)
Removes the block color for the block with data_object.
void GetBlockColor(vtkDataObject *data_object, double color[3]) const
Set/get the color for the block with data_object.
void VisitVisibilities(std::function< bool(vtkDataObject *, bool)> visitor)
double GetBlockOpacity(vtkDataObject *data_object) const
Set/get the opacity for the block with data_object.
bool HasBlockColor(vtkDataObject *data_object) const
Returns true if the block with the given data_object has a color.
void RemoveBlockMaterial(vtkDataObject *data_object)
Removes the set material for the block with data_object.
const std::string & GetBlockMaterial(vtkDataObject *data_object) const
Set/get the material for the block with data_object.
void RemoveBlockOpacity(vtkDataObject *data_object)
Removes the set opacity for the block with data_object.
bool HasBlockVisibility(vtkDataObject *data_object) const
Returns true if the block with the given data_object has a visibility set.
void RemoveBlockMaterials()
Removes all block materialss.
bool HasBlockPickabilities() const
Returns true if any block has any block pickability is set.
bool HasBlockColors() const
Returns true if any block has any block color is set.
void RemoveBlockPickabilities()
Removes all block pickability flags.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RemoveBlockVisibility(vtkDataObject *data_object)
Removes the block visibility flag for the block with data_object.
static void ComputeVisibleBounds(vtkCompositeDataDisplayAttributes *cda, vtkDataObject *dobj, double bounds[6])
If the input dobj is a vtkCompositeDataSet, we will loop over the hierarchy recursively starting from...
bool HasBlockMaterial(vtkDataObject *data_object) const
Returns true if the block with data_object has an material set.
static vtkDataObject * DataObjectFromIndex(const unsigned int flat_index, vtkDataObject *parent_obj, unsigned int current_flat_index=0)
Get the DataObject corresponding to the node with index flat_index under parent_obj.
void RemoveBlockPickability(vtkDataObject *data_object)
Removes the block pickability flag for the block with data_object.
vtkColor3d GetBlockColor(vtkDataObject *data_object) const
Set/get the color for the block with data_object.
void RemoveBlockColors()
Removes all block colors.
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:40