1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkActor.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 vtkActor 17 * @brief represents an object (geometry & properties) in a rendered scene 18 * 19 * 20 * vtkActor is used to represent an entity in a rendering scene. It inherits 21 * functions related to the actors position, and orientation from 22 * vtkProp. The actor also has scaling and maintains a reference to the 23 * defining geometry (i.e., the mapper), rendering properties, and possibly a 24 * texture map. vtkActor combines these instance variables into one 4x4 25 * transformation matrix as follows: [x y z 1] = [x y z 1] Translate(-origin) 26 * Scale(scale) Rot(y) Rot(x) Rot (z) Trans(origin) Trans(position) 27 * 28 * @sa 29 * vtkProperty vtkTexture vtkMapper vtkAssembly vtkFollower vtkLODActor 30 */ 31 32 #ifndef vtkActor_h 33 #define vtkActor_h 34 35 #include "vtkProp3D.h" 36 #include "vtkRenderingCoreModule.h" // For export macro 37 38 class vtkRenderer; 39 class vtkPropCollection; 40 class vtkActorCollection; 41 class vtkTexture; 42 class vtkMapper; 43 class vtkProperty; 44 45 class VTKRENDERINGCORE_EXPORT vtkActor : public vtkProp3D 46 { 47 public: 48 vtkTypeMacro(vtkActor, vtkProp3D); 49 void PrintSelf(ostream& os, vtkIndent indent) override; 50 51 /** 52 * Creates an actor with the following defaults: origin(0,0,0) 53 * position=(0,0,0) scale=(1,1,1) visibility=1 pickable=1 dragable=1 54 * orientation=(0,0,0). No user defined matrix and no texture map. 55 */ 56 static vtkActor* New(); 57 58 /** 59 * For some exporters and other other operations we must be 60 * able to collect all the actors or volumes. These methods 61 * are used in that process. 62 */ 63 void GetActors(vtkPropCollection*) override; 64 65 ///@{ 66 /** 67 * Support the standard render methods. 68 */ 69 int RenderOpaqueGeometry(vtkViewport* viewport) override; 70 int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override; 71 ///@} 72 73 ///@{ 74 /** 75 * Does this prop have some opaque/translucent polygonal geometry? 76 */ 77 vtkTypeBool HasTranslucentPolygonalGeometry() override; 78 vtkTypeBool HasOpaqueGeometry() override; 79 ///@} 80 81 /** 82 * This causes the actor to be rendered. It in turn will render the actor's 83 * property, texture map and then mapper. If a property hasn't been 84 * assigned, then the actor will create one automatically. Note that a side 85 * effect of this method is that the pipeline will be updated. 86 */ Render(vtkRenderer *,vtkMapper *)87 virtual void Render(vtkRenderer*, vtkMapper*) {} 88 89 /** 90 * Shallow copy of an actor. Overloads the virtual vtkProp method. 91 */ 92 void ShallowCopy(vtkProp* prop) override; 93 94 /** 95 * Release any graphics resources that are being consumed by this actor. 96 * The parameter window could be used to determine which graphic 97 * resources to release. 98 */ 99 void ReleaseGraphicsResources(vtkWindow*) override; 100 101 ///@{ 102 /** 103 * Set/Get the property object that controls this actors surface 104 * properties. This should be an instance of a vtkProperty object. Every 105 * actor must have a property associated with it. If one isn't specified, 106 * then one will be generated automatically. Multiple actors can share one 107 * property object. 108 */ 109 void SetProperty(vtkProperty* lut); 110 vtkProperty* GetProperty(); 111 ///@} 112 113 /** 114 * Create a new property suitable for use with this type of Actor. 115 * For example, a vtkMesaActor should create a vtkMesaProperty 116 * in this function. The default is to just call vtkProperty::New. 117 */ 118 virtual vtkProperty* MakeProperty(); 119 120 ///@{ 121 /** 122 * Set/Get the property object that controls this actors backface surface 123 * properties. This should be an instance of a vtkProperty object. If one 124 * isn't specified, then the front face properties will be used. Multiple 125 * actors can share one property object. 126 */ 127 void SetBackfaceProperty(vtkProperty* lut); 128 vtkGetObjectMacro(BackfaceProperty, vtkProperty); 129 ///@} 130 131 ///@{ 132 /** 133 * Set/Get the texture object to control rendering texture maps. This will 134 * be a vtkTexture object. An actor does not need to have an associated 135 * texture map and multiple actors can share one texture. 136 */ 137 virtual void SetTexture(vtkTexture*); 138 vtkGetObjectMacro(Texture, vtkTexture); 139 ///@} 140 141 /** 142 * This is the method that is used to connect an actor to the end of a 143 * visualization pipeline, i.e. the mapper. This should be a subclass 144 * of vtkMapper. Typically vtkPolyDataMapper and vtkDataSetMapper will 145 * be used. 146 */ 147 virtual void SetMapper(vtkMapper*); 148 149 ///@{ 150 /** 151 * Returns the Mapper that this actor is getting its data from. 152 */ 153 vtkGetObjectMacro(Mapper, vtkMapper); 154 ///@} 155 156 /** 157 * Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The 158 * method GetBounds(double bounds[6]) is available from the superclass.) 159 */ 160 using Superclass::GetBounds; 161 double* GetBounds() VTK_SIZEHINT(6) override; 162 163 /** 164 * Apply the current properties to all parts that compose this actor. 165 * This method is overloaded in vtkAssembly to apply the assemblies' 166 * properties to all its parts in a recursive manner. Typically the 167 * use of this method is to set the desired properties in the assembly, 168 * and then push the properties down to the assemblies parts with 169 * ApplyProperties(). 170 */ ApplyProperties()171 virtual void ApplyProperties() {} 172 173 /** 174 * Get the actors mtime plus consider its properties and texture if set. 175 */ 176 vtkMTimeType GetMTime() override; 177 178 /** 179 * Return the mtime of anything that would cause the rendered image to 180 * appear differently. Usually this involves checking the mtime of the 181 * prop plus anything else it depends on such as properties, textures, 182 * etc. 183 */ 184 vtkMTimeType GetRedrawMTime() override; 185 186 ///@{ 187 /** 188 * Force the actor to be treated as opaque or translucent 189 */ 190 vtkGetMacro(ForceOpaque, bool); 191 vtkSetMacro(ForceOpaque, bool); 192 vtkBooleanMacro(ForceOpaque, bool); 193 vtkGetMacro(ForceTranslucent, bool); 194 vtkSetMacro(ForceTranslucent, bool); 195 vtkBooleanMacro(ForceTranslucent, bool); 196 ///@} 197 198 /** 199 * WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE 200 * DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS 201 * Used by vtkHardwareSelector to determine if the prop supports hardware 202 * selection. 203 */ 204 bool GetSupportsSelection() override; 205 206 /** 207 * allows a prop to update a selections color buffers 208 * Default just forwards to the Mapper 209 */ 210 void ProcessSelectorPixelBuffers( 211 vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets) override; 212 213 ///@{ 214 // Get if we are in the translucent polygonal geometry pass IsRenderingTranslucentPolygonalGeometry()215 bool IsRenderingTranslucentPolygonalGeometry() override { return this->InTranslucentPass; } SetIsRenderingTranslucentPolygonalGeometry(bool val)216 void SetIsRenderingTranslucentPolygonalGeometry(bool val) { this->InTranslucentPass = val; } 217 ///@} 218 219 protected: 220 vtkActor(); 221 ~vtkActor() override; 222 223 // is this actor opaque 224 int GetIsOpaque(); 225 bool ForceOpaque; 226 bool ForceTranslucent; 227 bool InTranslucentPass; 228 229 vtkProperty* Property; 230 vtkProperty* BackfaceProperty; 231 vtkTexture* Texture; 232 vtkMapper* Mapper; 233 234 // Bounds are cached in an actor - the MapperBounds are also cache to 235 // help know when the Bounds need to be recomputed. 236 double MapperBounds[6]; 237 vtkTimeStamp BoundsMTime; 238 239 private: 240 vtkActor(const vtkActor&) = delete; 241 void operator=(const vtkActor&) = delete; 242 }; 243 244 #endif 245