VTK  9.1.0
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=========================================================================*/
36#ifndef vtkCompositeDataDisplayAttributes_h
37#define vtkCompositeDataDisplayAttributes_h
38#include <functional> // for std::function
39#include <unordered_map> // for std::unordered_map
40
41#include "vtkColor.h" // for vtkColor3d
42#include "vtkObject.h"
43#include "vtkRenderingCoreModule.h" // for export macro
44
45class vtkBoundingBox;
46class vtkDataObject;
47
48class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
49{
50public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
59
61
64 void SetBlockVisibility(vtkDataObject* data_object, bool visible);
65 bool GetBlockVisibility(vtkDataObject* data_object) const;
67
72 bool HasBlockVisibility(vtkDataObject* data_object) const;
73
78
84
89
91
94 void SetBlockPickability(vtkDataObject* data_object, bool visible);
95 bool GetBlockPickability(vtkDataObject* data_object) const;
97
102 bool HasBlockPickability(vtkDataObject* data_object) const;
103
108
114
116
119 void SetBlockColor(vtkDataObject* data_object, const double color[3]);
120 void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
123
127 bool HasBlockColors() const;
128
132 bool HasBlockColor(vtkDataObject* data_object) const;
133
137 void RemoveBlockColor(vtkDataObject* data_object);
138
143
145
148 void SetBlockOpacity(vtkDataObject* data_object, double opacity);
149 double GetBlockOpacity(vtkDataObject* data_object) const;
151
155 bool HasBlockOpacities() const;
156
160 bool HasBlockOpacity(vtkDataObject* data_object) const;
161
166
171
173
177 void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
178 const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
180
184 bool HasBlockMaterials() const;
185
189 bool HasBlockMaterial(vtkDataObject* data_object) const;
190
195
200
208 vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
209
215 const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
216
218 {
219 for (auto entry : this->BlockVisibilities)
220 {
221 if (visitor(entry.first, entry.second))
222 {
223 break;
224 }
225 }
226 }
227
228protected:
231
232private:
234 void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
235
244 static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
245 vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
246
247 using BoolMap = std::unordered_map<vtkDataObject*, bool>;
248 using DoubleMap = std::unordered_map<vtkDataObject*, double>;
249 using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
250 using StringMap = std::unordered_map<vtkDataObject*, std::string>;
251
252 BoolMap BlockVisibilities;
253 ColorMap BlockColors;
254 DoubleMap BlockOpacities;
255 StringMap BlockMaterials;
256 BoolMap BlockPickabilities;
257};
258
259#endif // vtkCompositeDataDisplayAttributes_h
Fast, simple class for representing and operating on 3D bounds.
Rendering attributes for a multi-block dataset.
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
Definition: vtkDataObject.h:69
a simple class to control print indentation
Definition: vtkIndent.h:43
abstract base class for most VTK objects
Definition: vtkObject.h:63
@ function
Definition: vtkX3D.h:255
@ color
Definition: vtkX3D.h:227
@ string
Definition: vtkX3D.h:496