VTK
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 =========================================================================*/
30 #ifndef vtkCompositeDataDisplayAttributes_h
31 #define vtkCompositeDataDisplayAttributes_h
32 #include <functional> // for std::function
33 #include <unordered_map> // for std::unordered_map
34 
35 #include "vtkColor.h" // for vtkColor3d
36 #include "vtkObject.h"
37 #include "vtkRenderingCoreModule.h" // for export macro
38 
39 
40 class vtkBoundingBox;
41 class vtkDataObject;
42 
43 class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
44 {
45 public:
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
53  bool HasBlockVisibilities() const;
54 
56 
59  void SetBlockVisibility(vtkDataObject* data_object, bool visible);
60  bool GetBlockVisibility(vtkDataObject* data_object) const;
62 
67  bool HasBlockVisibility(vtkDataObject* data_object) const;
68 
72  void RemoveBlockVisibility(vtkDataObject* data_object);
73 
78  void RemoveBlockVisibilities();
79  // This method is deprecated and will be removed in VTK 8.2. It is misspelled.
80  VTK_LEGACY(void RemoveBlockVisibilites());
81 
85  bool HasBlockPickabilities() const;
86 
88 
91  void SetBlockPickability(vtkDataObject* data_object, bool visible);
92  bool GetBlockPickability(vtkDataObject* data_object) const;
94 
99  bool HasBlockPickability(vtkDataObject* data_object) const;
100 
104  void RemoveBlockPickability(vtkDataObject* data_object);
105 
110  void RemoveBlockPickabilities();
111 
113 
116  void SetBlockColor(vtkDataObject* data_object, const double color[3]);
117  void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
118  vtkColor3d GetBlockColor(vtkDataObject* data_object) const;
120 
124  bool HasBlockColors() const;
125 
129  bool HasBlockColor(vtkDataObject* data_object) const;
130 
134  void RemoveBlockColor(vtkDataObject* data_object);
135 
139  void RemoveBlockColors();
140 
142 
145  void SetBlockOpacity(vtkDataObject* data_object, double opacity);
146  double GetBlockOpacity(vtkDataObject* data_object) const;
148 
152  bool HasBlockOpacities() const;
153 
157  bool HasBlockOpacity(vtkDataObject* data_object) const;
158 
162  void RemoveBlockOpacity(vtkDataObject* data_object);
163 
167  void RemoveBlockOpacities();
168 
170 
174  void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
175  const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
177 
181  bool HasBlockMaterials() const;
182 
186  bool HasBlockMaterial(vtkDataObject* data_object) const;
187 
191  void RemoveBlockMaterial(vtkDataObject* data_object);
192 
196  void RemoveBlockMaterials();
197 
204  static void ComputeVisibleBounds(
206  vtkDataObject *dobj,
207  double bounds[6]);
208 
213  static vtkDataObject* DataObjectFromIndex(const unsigned int flat_index,
214  vtkDataObject* parent_obj, unsigned int& current_flat_index);
215 
216  void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
217  {
218  for (auto entry : this->BlockVisibilities)
219  {
220  if (visitor(entry.first, entry.second))
221  {
222  break;
223  }
224  }
225  }
226 protected:
229 
230 private:
232  void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
233 
242  static void ComputeVisibleBoundsInternal(
244  vtkDataObject *dobj,
245  vtkBoundingBox* bbox,
246  bool parentVisible = true);
247 
248  using BoolMap = std::unordered_map<vtkDataObject*, bool>;
249  using DoubleMap = std::unordered_map<vtkDataObject*, double>;
250  using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
251  using StringMap = std::unordered_map<vtkDataObject*, std::string>;
252 
253  BoolMap BlockVisibilities;
254  ColorMap BlockColors;
255  DoubleMap BlockOpacities;
256  StringMap BlockMaterials;
257  BoolMap BlockPickabilities;
258 };
259 
260 #endif // vtkCompositeDataDisplayAttributes_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
Rendering attributes for a multi-block dataset.
a simple class to control print indentation
Definition: vtkIndent.h:39
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
general representation of visualization data
Definition: vtkDataObject.h:64
Fast Simple Class for dealing with 3D bounds.