VTK  9.4.20241222
vtkCompositeDataDisplayAttributes.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
37#ifndef vtkCompositeDataDisplayAttributes_h
38#define vtkCompositeDataDisplayAttributes_h
39
40#include "vtkObject.h"
41
42#include "vtkColor.h" // for vtkColor3d
43#include "vtkRenderingCoreModule.h" // for export macro
44#include "vtkSmartPointer.h" // for arg
45#include "vtkVector.h" // for vtkVector2d
46#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
47
48#include <functional> // for std::function
49#include <unordered_map> // for std::unordered_map
50
51// clang-format off
52#include "vtk_nlohmannjson.h"
53#include VTK_NLOHMANN_JSON(json.hpp)
54// clang-format on
55
56VTK_ABI_NAMESPACE_BEGIN
57class vtkBoundingBox;
58class vtkDataObject;
59class vtkDeserializer;
61class vtkSerializer;
62
64{
65public:
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
74
76
79 void SetBlockVisibility(vtkDataObject* data_object, bool visible);
80 bool GetBlockVisibility(vtkDataObject* data_object) const;
82
87 bool HasBlockVisibility(vtkDataObject* data_object) const;
88
93
99
104
106
109 void SetBlockPickability(vtkDataObject* data_object, bool visible);
110 bool GetBlockPickability(vtkDataObject* data_object) const;
112
117 bool HasBlockPickability(vtkDataObject* data_object) const;
118
123
129
131
134 void SetBlockScalarVisibility(vtkDataObject* data_object, bool value);
135 bool GetBlockScalarVisibility(vtkDataObject* data_object) const;
136 bool HasBlockScalarVisibility(vtkDataObject* data_object) const;
141
143
146 void SetBlockUseLookupTableScalarRange(vtkDataObject* data_object, bool value);
153
155
165
167
170 void SetBlockColor(vtkDataObject* data_object, const double color[3]);
171 void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
174
178 bool HasBlockColors() const;
179
183 bool HasBlockColor(vtkDataObject* data_object) const;
184
188 void RemoveBlockColor(vtkDataObject* data_object);
189
194
196
199 void SetBlockOpacity(vtkDataObject* data_object, double opacity);
200 double GetBlockOpacity(vtkDataObject* data_object) const;
202
206 bool HasBlockOpacities() const;
207
211 bool HasBlockOpacity(vtkDataObject* data_object) const;
212
217
222
224
228 void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
229 const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
231
235 bool HasBlockMaterials() const;
236
240 bool HasBlockMaterial(vtkDataObject* data_object) const;
241
246
251
253
256 void SetBlockColorMode(vtkDataObject* data_object, int value);
257 int GetBlockColorMode(vtkDataObject* data_object) const;
258 bool HasBlockColorMode(vtkDataObject* data_object) const;
259 bool HasBlockColorModes() const;
263
265
268 void SetBlockScalarMode(vtkDataObject* data_object, int value);
269 int GetBlockScalarMode(vtkDataObject* data_object) const;
270 bool HasBlockScalarMode(vtkDataObject* data_object) const;
275
277
280 void SetBlockArrayAccessMode(vtkDataObject* data_object, int value);
281 int GetBlockArrayAccessMode(vtkDataObject* data_object) const;
282 bool HasBlockArrayAccessMode(vtkDataObject* data_object) const;
287
289
292 void SetBlockArrayComponent(vtkDataObject* data_object, int value);
293 int GetBlockArrayComponent(vtkDataObject* data_object) const;
294 bool HasBlockArrayComponent(vtkDataObject* data_object) const;
299
301
304 void SetBlockArrayId(vtkDataObject* data_object, int value);
305 int GetBlockArrayId(vtkDataObject* data_object) const;
306 bool HasBlockArrayId(vtkDataObject* data_object) const;
307 bool HasBlockArrayIds() const;
311
313
316 void SetBlockScalarRange(vtkDataObject* data_object, const vtkVector2d& value);
318 bool HasBlockScalarRange(vtkDataObject* data_object) const;
323
325
328 void SetBlockArrayName(vtkDataObject* data_object, const std::string& value);
329 std::string GetBlockArrayName(vtkDataObject* data_object) const;
330 bool HasBlockArrayName(vtkDataObject* data_object) const;
331 bool HasBlockArrayNames() const;
335
337
342 bool HasBlockFieldDataTupleId(vtkDataObject* data_object) const;
347
349
354 bool HasBlockLookupTable(vtkDataObject* data_object) const;
359
367 vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);
368
374 unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);
375
376 void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
377 {
378 for (auto entry : this->BlockVisibilities)
379 {
380 if (visitor(entry.first, entry.second))
381 {
382 break;
383 }
384 }
385 }
386
387 nlohmann::json Serialize(vtkSerializer* serializer);
388 void Deserialize(const nlohmann::json& state, vtkDeserializer* deserializer);
389
390protected:
393
394private:
396 void operator=(const vtkCompositeDataDisplayAttributes&) = delete;
397
406 static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
407 vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);
408
409 using BoolMap = std::unordered_map<vtkDataObject*, bool>;
410 using DoubleMap = std::unordered_map<vtkDataObject*, double>;
411 using IntMap = std::unordered_map<vtkDataObject*, int>;
412 using VtkIdTypeMap = std::unordered_map<vtkDataObject*, vtkIdType>;
413 using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
414 using RangeMap = std::unordered_map<vtkDataObject*, vtkVector2d>;
415 using StringMap = std::unordered_map<vtkDataObject*, std::string>;
416 using LookupTableMap = std::unordered_map<vtkDataObject*, vtkSmartPointer<vtkScalarsToColors>>;
417
418 BoolMap BlockVisibilities;
419 ColorMap BlockColors;
420 DoubleMap BlockOpacities;
421 StringMap BlockMaterials;
422 BoolMap BlockPickabilities;
423 BoolMap BlockScalarVisibilities;
424 BoolMap BlockUseLookupTableScalarRanges;
425 BoolMap BlockInterpolateScalarsBeforeMappings;
426 IntMap BlockColorModes;
427 IntMap BlockScalarModes;
428 IntMap BlockArrayAccessModes;
429 IntMap BlockArrayComponents;
430 IntMap BlockArrayIds;
431 RangeMap BlockScalarRanges;
432 StringMap BlockArrayNames;
433 LookupTableMap BlockLookupTables;
434 VtkIdTypeMap BlockFieldDataTupleIds;
435};
436
437VTK_ABI_NAMESPACE_END
438#endif // vtkCompositeDataDisplayAttributes_h
Fast, simple class for representing and operating on 3D bounds.
Rendering attributes for a multi-block dataset.
void SetBlockColorMode(vtkDataObject *data_object, int value)
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.
void SetBlockScalarVisibility(vtkDataObject *data_object, bool value)
bool HasBlockOpacities() const
Returns true if any block has an opacity set.
int GetBlockArrayId(vtkDataObject *data_object) const
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 RemoveBlockArrayId(vtkDataObject *data_object)
void RemoveBlockFieldDataTupleId(vtkDataObject *data_object)
bool HasBlockScalarRange(vtkDataObject *data_object) const
vtkIdType GetBlockFieldDataTupleId(vtkDataObject *data_object) const
void SetBlockOpacity(vtkDataObject *data_object, double opacity)
Set/get the opacity for the block with data_object.
void SetBlockUseLookupTableScalarRange(vtkDataObject *data_object, bool value)
void RemoveBlockArrayName(vtkDataObject *data_object)
void SetBlockColor(vtkDataObject *data_object, const double color[3])
Set/get the color for the block with data_object.
bool HasBlockArrayName(vtkDataObject *data_object) const
void SetBlockScalarMode(vtkDataObject *data_object, int value)
void SetBlockVisibility(vtkDataObject *data_object, bool visible)
Set/get the visibility for the block with data_object.
void RemoveBlockLookupTable(vtkDataObject *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 SetBlockArrayComponent(vtkDataObject *data_object, int value)
void RemoveBlockVisibilities()
Removes all block visibility flags.
bool HasBlockArrayId(vtkDataObject *data_object) const
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 RemoveBlockScalarVisibility(vtkDataObject *data_object)
void GetBlockColor(vtkDataObject *data_object, double color[3]) const
Set/get the color for the block with data_object.
std::string GetBlockArrayName(vtkDataObject *data_object) const
void VisitVisibilities(std::function< bool(vtkDataObject *, bool)> visitor)
bool GetBlockScalarVisibility(vtkDataObject *data_object) const
void RemoveBlockInterpolateScalarsBeforeMapping(vtkDataObject *data_object)
void SetBlockArrayName(vtkDataObject *data_object, const std::string &value)
double GetBlockOpacity(vtkDataObject *data_object) const
Set/get the opacity for the block with data_object.
bool HasBlockInterpolateScalarsBeforeMapping(vtkDataObject *data_object) const
nlohmann::json Serialize(vtkSerializer *serializer)
void SetBlockFieldDataTupleId(vtkDataObject *data_object, vtkIdType value)
bool HasBlockUseLookupTableScalarRange(vtkDataObject *data_object) const
bool HasBlockUseLookupTableScalarRanges() const
bool HasBlockColor(vtkDataObject *data_object) const
Returns true if the block with the given data_object has a color.
void Deserialize(const nlohmann::json &state, vtkDeserializer *deserializer)
void SetBlockArrayAccessMode(vtkDataObject *data_object, int value)
bool GetBlockUseLookupTableScalarRange(vtkDataObject *data_object) const
void SetBlockLookupTable(vtkDataObject *data_object, vtkSmartPointer< vtkScalarsToColors > lut)
bool HasBlockInterpolateScalarsBeforeMappings() const
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 RemoveBlockUseLookupTableScalarRange(vtkDataObject *data_object)
void RemoveBlockScalarRange(vtkDataObject *data_object)
bool HasBlockLookupTable(vtkDataObject *data_object) const
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.
int GetBlockColorMode(vtkDataObject *data_object) const
int GetBlockArrayAccessMode(vtkDataObject *data_object) const
void RemoveBlockMaterials()
Removes all block materialss.
vtkVector2d GetBlockScalarRange(vtkDataObject *data_object) const
bool HasBlockFieldDataTupleId(vtkDataObject *data_object) const
bool HasBlockPickabilities() const
Returns true if any block has any block pickability is set.
bool HasBlockArrayAccessMode(vtkDataObject *data_object) const
int GetBlockScalarMode(vtkDataObject *data_object) const
bool GetBlockInterpolateScalarsBeforeMapping(vtkDataObject *data_object) const
void SetBlockScalarRange(vtkDataObject *data_object, const vtkVector2d &value)
void RemoveBlockScalarMode(vtkDataObject *data_object)
void RemoveBlockColorMode(vtkDataObject *data_object)
bool HasBlockColors() const
Returns true if any block has any block color is set.
bool HasBlockScalarVisibility(vtkDataObject *data_object) const
void RemoveBlockPickabilities()
Removes all block pickability flags.
bool HasBlockScalarMode(vtkDataObject *data_object) const
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...
static vtkDataObject * DataObjectFromIndex(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 SetBlockInterpolateScalarsBeforeMapping(vtkDataObject *data_object, bool value)
bool HasBlockColorMode(vtkDataObject *data_object) const
bool HasBlockMaterial(vtkDataObject *data_object) const
Returns true if the block with data_object has an material set.
int GetBlockArrayComponent(vtkDataObject *data_object) const
void RemoveBlockArrayComponent(vtkDataObject *data_object)
void SetBlockArrayId(vtkDataObject *data_object, int value)
void RemoveBlockPickability(vtkDataObject *data_object)
Removes the block pickability flag for the block with data_object.
vtkSmartPointer< vtkScalarsToColors > GetBlockLookupTable(vtkDataObject *data_object) const
void RemoveBlockArrayAccessMode(vtkDataObject *data_object)
bool HasBlockArrayComponent(vtkDataObject *data_object) const
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
Deserialize VTK objects from JSON.
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Superclass for mapping scalar values to colors.
Serialize VTK objects to JSON.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:315
#define VTK_MARSHALMANUAL