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 =========================================================================*/
49 #ifndef vtkCompositeDataDisplayAttributes_h
50 #define vtkCompositeDataDisplayAttributes_h
51 #include <functional> // for std::function
52 #include <unordered_map> // for std::unordered_map
53 
54 #include "vtkColor.h" // for vtkColor3d
55 #include "vtkObject.h"
56 #include "vtkRenderingCoreModule.h" // for export macro
57 
58 class vtkBoundingBox;
59 class vtkDataObject;
60 
61 class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
62 {
63 public:
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
71  bool HasBlockVisibilities() const;
72 
74 
77  void SetBlockVisibility(vtkDataObject* data_object, bool visible);
78  bool GetBlockVisibility(vtkDataObject* data_object) const;
80 
85  bool HasBlockVisibility(vtkDataObject* data_object) const;
86 
91 
97 
101  bool HasBlockPickabilities() const;
102 
104 
107  void SetBlockPickability(vtkDataObject* data_object, bool visible);
108  bool GetBlockPickability(vtkDataObject* data_object) const;
110 
115  bool HasBlockPickability(vtkDataObject* data_object) const;
116 
121 
127 
129 
132  void SetBlockColor(vtkDataObject* data_object, const double color[3]);
133  void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
136 
140  bool HasBlockColors() const;
141 
145  bool HasBlockColor(vtkDataObject* data_object) const;
146 
150  void RemoveBlockColor(vtkDataObject* data_object);
151 
156 
158 
161  void SetBlockOpacity(vtkDataObject* data_object, double opacity);
162  double GetBlockOpacity(vtkDataObject* data_object) const;
164 
168  bool HasBlockOpacities() const;
169 
173  bool HasBlockOpacity(vtkDataObject* data_object) const;
174 
178  void RemoveBlockOpacity(vtkDataObject* data_object);
179 
184 
186 
190  void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
191  const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
193 
197  bool HasBlockMaterials() const;
198 
202  bool HasBlockMaterial(vtkDataObject* data_object) const;
203 
207  void RemoveBlockMaterial(vtkDataObject* data_object);
208 
213 
220  static void ComputeVisibleBounds(
221  vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
222 
228  const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
229 
230  void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
231  {
232  for (auto entry : this->BlockVisibilities)
233  {
234  if (visitor(entry.first, entry.second))
235  {
236  break;
237  }
238  }
239  }
240 
241 protected:
244 
245 private:
247  void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
248 
257  static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
258  vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
259 
260  using BoolMap = std::unordered_map<vtkDataObject*, bool>;
261  using DoubleMap = std::unordered_map<vtkDataObject*, double>;
262  using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
263  using StringMap = std::unordered_map<vtkDataObject*, std::string>;
264 
265  BoolMap BlockVisibilities;
266  ColorMap BlockColors;
267  DoubleMap BlockOpacities;
268  StringMap BlockMaterials;
269  BoolMap BlockPickabilities;
270 };
271 
272 #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.
const std::string & GetBlockMaterial(vtkDataObject *data_object) const
Set/get the material for the block with data_object.
static vtkCompositeDataDisplayAttributes * New()
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.
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.
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.
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.
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.
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:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
@ function
Definition: vtkX3D.h:255
@ color
Definition: vtkX3D.h:227
@ string
Definition: vtkX3D.h:496