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 =========================================================================*/
39 #ifndef vtkCompositeDataDisplayAttributes_h
40 #define vtkCompositeDataDisplayAttributes_h
41 #include <functional> // for std::function
42 #include <unordered_map> // for std::unordered_map
43 
44 #include "vtkColor.h" // for vtkColor3d
45 #include "vtkObject.h"
46 #include "vtkRenderingCoreModule.h" // for export macro
47 
48 class vtkBoundingBox;
49 class vtkDataObject;
50 
51 class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
52 {
53 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
61  bool HasBlockVisibilities() const;
62 
64 
67  void SetBlockVisibility(vtkDataObject* data_object, bool visible);
68  bool GetBlockVisibility(vtkDataObject* data_object) const;
70 
75  bool HasBlockVisibility(vtkDataObject* data_object) const;
76 
81 
87 
91  bool HasBlockPickabilities() const;
92 
94 
97  void SetBlockPickability(vtkDataObject* data_object, bool visible);
98  bool GetBlockPickability(vtkDataObject* data_object) const;
100 
105  bool HasBlockPickability(vtkDataObject* data_object) const;
106 
111 
117 
119 
122  void SetBlockColor(vtkDataObject* data_object, const double color[3]);
123  void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
126 
130  bool HasBlockColors() const;
131 
135  bool HasBlockColor(vtkDataObject* data_object) const;
136 
140  void RemoveBlockColor(vtkDataObject* data_object);
141 
146 
148 
151  void SetBlockOpacity(vtkDataObject* data_object, double opacity);
152  double GetBlockOpacity(vtkDataObject* data_object) const;
154 
158  bool HasBlockOpacities() const;
159 
163  bool HasBlockOpacity(vtkDataObject* data_object) const;
164 
168  void RemoveBlockOpacity(vtkDataObject* data_object);
169 
174 
176 
180  void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
181  const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
183 
187  bool HasBlockMaterials() const;
188 
192  bool HasBlockMaterial(vtkDataObject* data_object) const;
193 
197  void RemoveBlockMaterial(vtkDataObject* data_object);
198 
203 
210  static void ComputeVisibleBounds(
211  vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
212 
218  const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
219 
220  void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
221  {
222  for (auto entry : this->BlockVisibilities)
223  {
224  if (visitor(entry.first, entry.second))
225  {
226  break;
227  }
228  }
229  }
230 
231 protected:
234 
235 private:
237  void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
238 
247  static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
248  vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
249 
250  using BoolMap = std::unordered_map<vtkDataObject*, bool>;
251  using DoubleMap = std::unordered_map<vtkDataObject*, double>;
252  using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
253  using StringMap = std::unordered_map<vtkDataObject*, std::string>;
254 
255  BoolMap BlockVisibilities;
256  ColorMap BlockColors;
257  DoubleMap BlockOpacities;
258  StringMap BlockMaterials;
259  BoolMap BlockPickabilities;
260 };
261 
262 #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
Definition: vtkDataObject.h:75
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:72
@ function
Definition: vtkX3D.h:255
@ color
Definition: vtkX3D.h:227
@ string
Definition: vtkX3D.h:496