1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkAnnotatedCubeActor.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 vtkAnnotatedCubeActor 17 * @brief a 3D cube with face labels 18 * 19 * vtkAnnotatedCubeActor is a hybrid 3D actor used to represent an anatomical 20 * orientation marker in a scene. The class consists of a 3D unit cube centered 21 * on the origin with each face labelled in correspondence to a particular 22 * coordinate direction. For example, with Cartesian directions, the user 23 * defined text labels could be: +X, -X, +Y, -Y, +Z, -Z, while for anatomical 24 * directions: A, P, L, R, S, I. Text is automatically centered on each cube 25 * face and is not restriceted to single characters. In addition to or in 26 * replace of a solid text label representation, the outline edges of the labels 27 * can be displayed. The individual properties of the cube, face labels 28 * and text outlines can be manipulated as can their visibility. 29 * 30 * @warning 31 * vtkAnnotatedCubeActor is primarily intended for use with 32 * vtkOrientationMarkerWidget. The cube face text is generated by vtkVectorText 33 * and therefore the font attributes are restricted. 34 * 35 * @sa 36 * vtkAxesActor vtkOrientationMarkerWidget vtkVectorText 37 */ 38 39 #ifndef vtkAnnotatedCubeActor_h 40 #define vtkAnnotatedCubeActor_h 41 42 #include "vtkProp3D.h" 43 #include "vtkRenderingAnnotationModule.h" // For export macro 44 45 class vtkActor; 46 class vtkAppendPolyData; 47 class vtkAssembly; 48 class vtkCubeSource; 49 class vtkFeatureEdges; 50 class vtkPropCollection; 51 class vtkProperty; 52 class vtkRenderer; 53 class vtkTransform; 54 class vtkTransformFilter; 55 class vtkVectorText; 56 57 class VTKRENDERINGANNOTATION_EXPORT vtkAnnotatedCubeActor : public vtkProp3D 58 { 59 public: 60 static vtkAnnotatedCubeActor* New(); 61 vtkTypeMacro(vtkAnnotatedCubeActor, vtkProp3D); 62 void PrintSelf(ostream& os, vtkIndent indent) override; 63 64 /** 65 * For some exporters and other other operations we must be 66 * able to collect all the actors or volumes. These methods 67 * are used in that process. 68 */ 69 void GetActors(vtkPropCollection*) override; 70 71 ///@{ 72 /** 73 * Support the standard render methods. 74 */ 75 int RenderOpaqueGeometry(vtkViewport* viewport) override; 76 int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override; 77 ///@} 78 79 /** 80 * Does this prop have some translucent polygonal geometry? 81 */ 82 vtkTypeBool HasTranslucentPolygonalGeometry() override; 83 84 /** 85 * Shallow copy of an axes actor. Overloads the virtual vtkProp method. 86 */ 87 void ShallowCopy(vtkProp* prop) override; 88 89 /** 90 * Release any graphics resources that are being consumed by this actor. 91 * The parameter window could be used to determine which graphic 92 * resources to release. 93 */ 94 void ReleaseGraphicsResources(vtkWindow*) override; 95 96 ///@{ 97 /** 98 * Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The 99 * method GetBounds(double bounds[6]) is available from the superclass.) 100 */ 101 void GetBounds(double bounds[6]); 102 double* GetBounds() VTK_SIZEHINT(6) override; 103 ///@} 104 105 /** 106 * Get the actors mtime plus consider its properties and texture if set. 107 */ 108 vtkMTimeType GetMTime() override; 109 110 ///@{ 111 /** 112 * Set/Get the scale factor for the face text 113 */ 114 void SetFaceTextScale(double); 115 vtkGetMacro(FaceTextScale, double); 116 ///@} 117 118 ///@{ 119 /** 120 * Get the individual face text properties. 121 */ 122 vtkProperty* GetXPlusFaceProperty(); 123 vtkProperty* GetXMinusFaceProperty(); 124 vtkProperty* GetYPlusFaceProperty(); 125 vtkProperty* GetYMinusFaceProperty(); 126 vtkProperty* GetZPlusFaceProperty(); 127 vtkProperty* GetZMinusFaceProperty(); 128 ///@} 129 130 /** 131 * Get the cube properties. 132 */ 133 vtkProperty* GetCubeProperty(); 134 135 /** 136 * Get the text edges properties. 137 */ 138 vtkProperty* GetTextEdgesProperty(); 139 140 ///@{ 141 /** 142 * Set/get the face text. 143 */ 144 vtkSetStringMacro(XPlusFaceText); 145 vtkGetStringMacro(XPlusFaceText); 146 vtkSetStringMacro(XMinusFaceText); 147 vtkGetStringMacro(XMinusFaceText); 148 vtkSetStringMacro(YPlusFaceText); 149 vtkGetStringMacro(YPlusFaceText); 150 vtkSetStringMacro(YMinusFaceText); 151 vtkGetStringMacro(YMinusFaceText); 152 vtkSetStringMacro(ZPlusFaceText); 153 vtkGetStringMacro(ZPlusFaceText); 154 vtkSetStringMacro(ZMinusFaceText); 155 vtkGetStringMacro(ZMinusFaceText); 156 ///@} 157 158 ///@{ 159 /** 160 * Enable/disable drawing the vector text edges. 161 */ 162 void SetTextEdgesVisibility(int); 163 int GetTextEdgesVisibility(); 164 ///@} 165 166 ///@{ 167 /** 168 * Enable/disable drawing the cube. 169 */ 170 void SetCubeVisibility(int); 171 int GetCubeVisibility(); 172 ///@} 173 174 ///@{ 175 /** 176 * Enable/disable drawing the vector text. 177 */ 178 void SetFaceTextVisibility(int); 179 int GetFaceTextVisibility(); 180 ///@} 181 182 ///@{ 183 /** 184 * Augment individual face text orientations. 185 */ 186 vtkSetMacro(XFaceTextRotation, double); 187 vtkGetMacro(XFaceTextRotation, double); 188 vtkSetMacro(YFaceTextRotation, double); 189 vtkGetMacro(YFaceTextRotation, double); 190 vtkSetMacro(ZFaceTextRotation, double); 191 vtkGetMacro(ZFaceTextRotation, double); 192 ///@} 193 194 /** 195 * Get the assembly so that user supplied transforms can be applied 196 */ GetAssembly()197 vtkAssembly* GetAssembly() { return this->Assembly; } 198 199 protected: 200 vtkAnnotatedCubeActor(); 201 ~vtkAnnotatedCubeActor() override; 202 203 vtkCubeSource* CubeSource; 204 vtkActor* CubeActor; 205 206 vtkAppendPolyData* AppendTextEdges; 207 vtkFeatureEdges* ExtractTextEdges; 208 vtkActor* TextEdgesActor; 209 210 void UpdateProps(); 211 212 char* XPlusFaceText; 213 char* XMinusFaceText; 214 char* YPlusFaceText; 215 char* YMinusFaceText; 216 char* ZPlusFaceText; 217 char* ZMinusFaceText; 218 219 double FaceTextScale; 220 221 double XFaceTextRotation; 222 double YFaceTextRotation; 223 double ZFaceTextRotation; 224 225 vtkVectorText* XPlusFaceVectorText; 226 vtkVectorText* XMinusFaceVectorText; 227 vtkVectorText* YPlusFaceVectorText; 228 vtkVectorText* YMinusFaceVectorText; 229 vtkVectorText* ZPlusFaceVectorText; 230 vtkVectorText* ZMinusFaceVectorText; 231 232 vtkActor* XPlusFaceActor; 233 vtkActor* XMinusFaceActor; 234 vtkActor* YPlusFaceActor; 235 vtkActor* YMinusFaceActor; 236 vtkActor* ZPlusFaceActor; 237 vtkActor* ZMinusFaceActor; 238 239 vtkTransformFilter* InternalTransformFilter; 240 vtkTransform* InternalTransform; 241 242 vtkAssembly* Assembly; 243 244 private: 245 vtkAnnotatedCubeActor(const vtkAnnotatedCubeActor&) = delete; 246 void operator=(const vtkAnnotatedCubeActor&) = delete; 247 }; 248 249 #endif 250