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 =========================================================================*/
46 #ifndef vtkCompositeDataDisplayAttributes_h
47 #define vtkCompositeDataDisplayAttributes_h
48 #include <functional> // for std::function
49 #include <unordered_map> // for std::unordered_map
50 
51 #include "vtkColor.h" // for vtkColor3d
52 #include "vtkObject.h"
53 #include "vtkRenderingCoreModule.h" // for export macro
54 
55 class vtkBoundingBox;
56 class vtkDataObject;
57 
58 class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
59 {
60 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
68  bool HasBlockVisibilities() const;
69 
71 
74  void SetBlockVisibility(vtkDataObject* data_object, bool visible);
75  bool GetBlockVisibility(vtkDataObject* data_object) const;
77 
82  bool HasBlockVisibility(vtkDataObject* data_object) const;
83 
88 
94 
98  bool HasBlockPickabilities() const;
99 
101 
104  void SetBlockPickability(vtkDataObject* data_object, bool visible);
105  bool GetBlockPickability(vtkDataObject* data_object) const;
107 
112  bool HasBlockPickability(vtkDataObject* data_object) const;
113 
118 
124 
126 
129  void SetBlockColor(vtkDataObject* data_object, const double color[3]);
130  void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
133 
137  bool HasBlockColors() const;
138 
142  bool HasBlockColor(vtkDataObject* data_object) const;
143 
147  void RemoveBlockColor(vtkDataObject* data_object);
148 
153 
155 
158  void SetBlockOpacity(vtkDataObject* data_object, double opacity);
159  double GetBlockOpacity(vtkDataObject* data_object) const;
161 
165  bool HasBlockOpacities() const;
166 
170  bool HasBlockOpacity(vtkDataObject* data_object) const;
171 
175  void RemoveBlockOpacity(vtkDataObject* data_object);
176 
181 
183 
187  void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
188  const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
190 
194  bool HasBlockMaterials() const;
195 
199  bool HasBlockMaterial(vtkDataObject* data_object) const;
200 
204  void RemoveBlockMaterial(vtkDataObject* data_object);
205 
210 
217  static void ComputeVisibleBounds(
218  vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
219 
225  const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
226 
227  void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
228  {
229  for (auto entry : this->BlockVisibilities)
230  {
231  if (visitor(entry.first, entry.second))
232  {
233  break;
234  }
235  }
236  }
237 
238 protected:
241 
242 private:
244  void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
245 
254  static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
255  vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
256 
257  using BoolMap = std::unordered_map<vtkDataObject*, bool>;
258  using DoubleMap = std::unordered_map<vtkDataObject*, double>;
259  using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
260  using StringMap = std::unordered_map<vtkDataObject*, std::string>;
261 
262  BoolMap BlockVisibilities;
263  ColorMap BlockColors;
264  DoubleMap BlockOpacities;
265  StringMap BlockMaterials;
266  BoolMap BlockPickabilities;
267 };
268 
269 #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:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
@ function
Definition: vtkX3D.h:255
@ color
Definition: vtkX3D.h:227
@ string
Definition: vtkX3D.h:496