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=========================================================================*/
27#ifndef vtkCompositeDataDisplayAttributes_h
28#define vtkCompositeDataDisplayAttributes_h
29#include <functional> // for std::function
30#include <unordered_map> // for std::unordered_map
31
32#include "vtkColor.h" // for vtkColor3d
33#include "vtkObject.h"
34#include "vtkRenderingCoreModule.h" // for export macro
35
36class vtkBoundingBox;
37class vtkDataObject;
38
39class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
50
52
55 void SetBlockVisibility(vtkDataObject* data_object, bool visible);
56 bool GetBlockVisibility(vtkDataObject* data_object) const;
58
63 bool HasBlockVisibility(vtkDataObject* data_object) const;
64
69
75
80
82
85 void SetBlockPickability(vtkDataObject* data_object, bool visible);
86 bool GetBlockPickability(vtkDataObject* data_object) const;
88
93 bool HasBlockPickability(vtkDataObject* data_object) const;
94
99
105
107
110 void SetBlockColor(vtkDataObject* data_object, const double color[3]);
111 void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
114
118 bool HasBlockColors() const;
119
123 bool HasBlockColor(vtkDataObject* data_object) const;
124
128 void RemoveBlockColor(vtkDataObject* data_object);
129
134
136
139 void SetBlockOpacity(vtkDataObject* data_object, double opacity);
140 double GetBlockOpacity(vtkDataObject* data_object) const;
142
146 bool HasBlockOpacities() const;
147
151 bool HasBlockOpacity(vtkDataObject* data_object) const;
152
157
162
164
168 void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
169 const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
171
175 bool HasBlockMaterials() const;
176
180 bool HasBlockMaterial(vtkDataObject* data_object) const;
181
186
191
199 vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
200
206 const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
207
209 {
210 for (auto entry : this->BlockVisibilities)
211 {
212 if (visitor(entry.first, entry.second))
213 {
214 break;
215 }
216 }
217 }
218
219protected:
222
223private:
225 void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
226
235 static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
236 vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
237
238 using BoolMap = std::unordered_map<vtkDataObject*, bool>;
239 using DoubleMap = std::unordered_map<vtkDataObject*, double>;
240 using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
241 using StringMap = std::unordered_map<vtkDataObject*, std::string>;
242
243 BoolMap BlockVisibilities;
244 ColorMap BlockColors;
245 DoubleMap BlockOpacities;
246 StringMap BlockMaterials;
247 BoolMap BlockPickabilities;
248};
249
250#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:60
a simple class to control print indentation
Definition: vtkIndent.h:34
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