1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkCompositeDataDisplayAttributesLegacy.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 =========================================================================*/ 15 /** 16 * @class vtkCompositeDataDisplayAttributesLegacy 17 * @brief rendering attributes for a 18 * multi-block dataset. 19 * 20 * The vtkCompositeDataDisplayAttributesLegacy class stores display attributes 21 * for individual blocks in a multi-block dataset. Attributes are mapped to 22 * blocks through their flat-index; This is the mechanism used in legacy 23 * OpenGL classes. 24 */ 25 26 #ifndef vtkCompositeDataDisplayAttributesLegacy_h 27 #define vtkCompositeDataDisplayAttributesLegacy_h 28 29 #include "vtkColor.h" // for vtkColor3d 30 #include "vtkObject.h" 31 #include "vtkRenderingCoreModule.h" // for export macro 32 33 #include <map> // for std::map 34 35 class vtkBoundingBox; 36 class vtkDataObject; 37 38 class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributesLegacy : public vtkObject 39 { 40 public: 41 static vtkCompositeDataDisplayAttributesLegacy* New(); 42 vtkTypeMacro(vtkCompositeDataDisplayAttributesLegacy, vtkObject) 43 void PrintSelf(ostream& os, vtkIndent indent) override; 44 45 /** 46 * Returns true if any block has any block visibility is set. 47 */ 48 bool HasBlockVisibilities() const; 49 50 //@{ 51 /** 52 * Set/get the visibility for the block with \p flat_index. 53 */ 54 void SetBlockVisibility(unsigned int flat_index, bool visible); 55 bool GetBlockVisibility(unsigned int flat_index) const; 56 //@} 57 58 /** 59 * Returns true if the block with the given flat_index has a visibility 60 * set. 61 */ 62 bool HasBlockVisibility(unsigned int flat_index) const; 63 64 /** 65 * Removes the block visibility flag for the block with flat_index. 66 */ 67 void RemoveBlockVisibility(unsigned int flat_index); 68 69 /** 70 * Removes all block visibility flags. The effectively sets the visibility 71 * for all blocks to true. 72 */ 73 void RemoveBlockVisibilities(); 74 // This method is deprecated and will be removed in VTK 8.2. It is misspelled. 75 VTK_LEGACY(void RemoveBlockVisibilites()); 76 77 /** 78 * Returns true if any block has any block visibility is set. 79 */ 80 bool HasBlockPickabilities() const; 81 82 //@{ 83 /** 84 * Set/get the visibility for the block with \p flat_index. 85 */ 86 void SetBlockPickability(unsigned int flat_index, bool visible); 87 bool GetBlockPickability(unsigned int flat_index) const; 88 //@} 89 90 /** 91 * Returns true if the block with the given flat_index has a visibility 92 * set. 93 */ 94 bool HasBlockPickability(unsigned int flat_index) const; 95 96 /** 97 * Removes the block visibility flag for the block with flat_index. 98 */ 99 void RemoveBlockPickability(unsigned int flat_index); 100 101 /** 102 * Removes all block visibility flags. The effectively sets the visibility 103 * for all blocks to true. 104 */ 105 void RemoveBlockPickabilities(); 106 107 //@{ 108 /** 109 * Set/get the color for the block with \p flat_index. 110 */ 111 void SetBlockColor(unsigned int flat_index, const double color[3]); 112 void GetBlockColor(unsigned int flat_index, double color[3]) const; 113 vtkColor3d GetBlockColor(unsigned int flat_index) const; 114 //@} 115 116 /** 117 * Returns true if any block has any block color is set. 118 */ 119 bool HasBlockColors() const; 120 121 /** 122 * Returns true if the block with the given \p flat_index has a color. 123 */ 124 bool HasBlockColor(unsigned int flat_index) const; 125 126 /** 127 * Removes the block color for the block with \p flat_index. 128 */ 129 void RemoveBlockColor(unsigned int flat_index); 130 131 /** 132 * Removes all block colors. 133 */ 134 void RemoveBlockColors(); 135 136 //@{ 137 /** 138 * Set/get the opacity for the block with flat_index. 139 */ 140 void SetBlockOpacity(unsigned int flat_index, double opacity); 141 double GetBlockOpacity(unsigned int flat_index) const; 142 //@} 143 144 /** 145 * Returns true if any block has an opacity set. 146 */ 147 bool HasBlockOpacities() const; 148 149 /** 150 * Returns true if the block with flat_index has an opacity set. 151 */ 152 bool HasBlockOpacity(unsigned int flat_index) const; 153 154 /** 155 * Removes the set opacity for the block with flat_index. 156 */ 157 void RemoveBlockOpacity(unsigned int flat_index); 158 159 /** 160 * Removes all block opacities. 161 */ 162 void RemoveBlockOpacities(); 163 164 // If the input \a dobj is a vtkCompositeDataSet, we will loop over the 165 // hierarchy recursively starting from initial index 0 and use only visible 166 // blocks, which is specified in the vtkCompositeDataDisplayAttributesLegacy \a cda, 167 // to compute the \a bounds. 168 static void ComputeVisibleBounds( 169 vtkCompositeDataDisplayAttributesLegacy* cda, 170 vtkDataObject *dobj, 171 double bounds[6]); 172 173 protected: 174 vtkCompositeDataDisplayAttributesLegacy(); 175 ~vtkCompositeDataDisplayAttributesLegacy() override; 176 177 private: 178 vtkCompositeDataDisplayAttributesLegacy(const vtkCompositeDataDisplayAttributesLegacy&) = delete; 179 void operator=(const vtkCompositeDataDisplayAttributesLegacy&) = delete; 180 181 /** 182 * If the input data \a dobj is a vtkCompositeDataSet, we will 183 * loop over the hierarchy recursively starting from initial index 184 * \a flat_index and use only visible blocks, which is 185 * specified in the vtkCompositeDataDisplayAttributesLegacy \a cda, 186 * to compute bounds and the result bounds will be set to 187 * the vtkBoundingBox \a bbox. The \a paraentVisible is the 188 * visibility for the starting flat_index. 189 */ 190 static void ComputeVisibleBoundsInternal( 191 vtkCompositeDataDisplayAttributesLegacy* cda, 192 vtkDataObject *dobj, 193 unsigned int& flat_index, 194 vtkBoundingBox* bbox, 195 bool parentVisible = true); 196 197 std::map<unsigned int, bool> BlockVisibilities; 198 std::map<unsigned int, vtkColor3d> BlockColors; 199 std::map<unsigned int, double> BlockOpacities; 200 std::map<unsigned int, bool> BlockPickabilities; 201 202 }; 203 204 #endif // vtkCompositeDataDisplayAttributesLegacy_h 205