VTK  9.0.20201124
vtkTexture.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTexture.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 =========================================================================*/
46 #ifndef vtkTexture_h
47 #define vtkTexture_h
48 
49 #include "vtkImageAlgorithm.h"
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
52 
53 class vtkImageData;
54 class vtkScalarsToColors;
55 class vtkRenderer;
57 class vtkWindow;
58 class vtkDataArray;
59 class vtkTransform;
60 
61 #define VTK_TEXTURE_QUALITY_DEFAULT 0
62 #define VTK_TEXTURE_QUALITY_16BIT 16
63 #define VTK_TEXTURE_QUALITY_32BIT 32
64 
65 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
66 {
67 public:
68  static vtkTexture* New();
69  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
77  virtual void Render(vtkRenderer* ren);
78 
83  virtual void PostRender(vtkRenderer*) {}
84 
91 
97  virtual void Load(vtkRenderer*) {}
98 
100 
103  vtkGetMacro(Interpolate, vtkTypeBool);
104  vtkSetMacro(Interpolate, vtkTypeBool);
105  vtkBooleanMacro(Interpolate, vtkTypeBool);
107 
109 
112  vtkGetMacro(Mipmap, bool);
113  vtkSetMacro(Mipmap, bool);
114  vtkBooleanMacro(Mipmap, bool);
116 
118 
124  vtkSetMacro(MaximumAnisotropicFiltering, float);
125  vtkGetMacro(MaximumAnisotropicFiltering, float);
127 
129 
133  vtkSetMacro(Quality, int);
134  vtkGetMacro(Quality, int);
135  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
136  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
137  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
139 
141 
151  vtkSetMacro(ColorMode, int);
152  vtkGetMacro(ColorMode, int);
153  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
154  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
157 
163 
165 
168  void SetLookupTable(vtkScalarsToColors*);
169  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
171 
173 
176  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
178 
182  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
183 
185 
189  void SetTransform(vtkTransform* transform);
190  vtkGetObjectMacro(Transform, vtkTransform);
192 
198  {
199  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
205  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
206  };
207 
209 
213  vtkGetMacro(BlendingMode, int);
214  vtkSetMacro(BlendingMode, int);
216 
218 
222  vtkGetMacro(PremultipliedAlpha, bool);
223  vtkSetMacro(PremultipliedAlpha, bool);
224  vtkBooleanMacro(PremultipliedAlpha, bool);
226 
228 
235  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
236  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
237  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
239 
246  virtual int IsTranslucent();
247 
251  virtual int GetTextureUnit() { return 0; }
252 
254 
260  vtkGetMacro(CubeMap, bool);
261  vtkBooleanMacro(CubeMap, bool);
262  void SetCubeMap(bool val);
264 
266 
272  vtkGetMacro(UseSRGBColorSpace, bool);
273  vtkSetMacro(UseSRGBColorSpace, bool);
274  vtkBooleanMacro(UseSRGBColorSpace, bool);
276 
278 
286  vtkSetVector4Macro(BorderColor, float);
287  vtkGetVector4Macro(BorderColor, float);
289 
290  enum
291  {
292  ClampToEdge = 0,
296  NumberOfWrapModes
297  };
298 
300 
313  vtkGetMacro(Wrap, int);
314  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
316 
318 
322  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
323  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
324  virtual void RepeatOn() { this->SetRepeat(true); }
325  virtual void RepeatOff() { this->SetRepeat(false); }
326  virtual void SetEdgeClamp(vtkTypeBool)
327  { /* This wasn't doing anything before. */
328  }
329  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
330  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
331  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
333 
334 protected:
335  vtkTexture();
336  ~vtkTexture() override;
337 
338  // A texture is a sink, so there is no need to do anything.
339  // This definition avoids a warning when doing Update() on a vtkTexture object.
340  void ExecuteData(vtkDataObject*) override {}
341 
342  bool Mipmap;
344  int Wrap;
345  float BorderColor[4];
347  int Quality;
352 
355  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
358  bool CubeMap;
360 
361  // the result of HasTranslucentPolygonalGeometry is cached
364 
365 private:
366  vtkTexture(const vtkTexture&) = delete;
367  void operator=(const vtkTexture&) = delete;
368 };
369 
370 #endif
vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:203
vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:202
vtkTexture::SelfAdjustingTableRange
int SelfAdjustingTableRange
Definition: vtkTexture.h:356
vtkTexture::Wrap
int Wrap
Definition: vtkTexture.h:344
VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_MAP_SCALARS
Definition: vtkSystemIncludes.h:90
vtkTexture::ClampToBorder
Definition: vtkTexture.h:295
vtkTexture::EdgeClampOn
virtual void EdgeClampOn()
Definition: vtkTexture.h:330
vtkTexture::ColorMode
int ColorMode
Definition: vtkTexture.h:348
vtkTexture::SetColorModeToDefault
void SetColorModeToDefault()
Definition: vtkTexture.h:153
vtkTexture::Interpolate
vtkTypeBool Interpolate
Definition: vtkTexture.h:346
vtkTexture::RestrictPowerOf2ImageSmaller
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:354
vtkTexture::ExecuteData
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:340
vtkTexture::TranslucentComputationTime
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:362
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkImageAlgorithm.h
vtkTexture::Quality
int Quality
Definition: vtkTexture.h:347
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkTexture::MappedScalars
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:350
vtkTexture::SetQualityTo32Bit
void SetQualityTo32Bit()
Definition: vtkTexture.h:137
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkImageAlgorithm::GetInput
vtkDataObject * GetInput()
Definition: vtkImageAlgorithm.h:77
vtkX3D::Transform
Definition: vtkX3D.h:47
vtkTexture::SetColorModeToDirectScalars
void SetColorModeToDirectScalars()
Definition: vtkTexture.h:155
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkTexture::BlendingMode
int BlendingMode
Definition: vtkTexture.h:353
vtkTexture::EdgeClampOff
virtual void EdgeClampOff()
Definition: vtkTexture.h:331
VTK_TEXTURE_QUALITY_DEFAULT
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:61
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:65
vtkTexture::SetColorModeToMapScalars
void SetColorModeToMapScalars()
Definition: vtkTexture.h:154
vtkTexture::MaximumAnisotropicFiltering
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:343
vtkTexture::SetQualityTo16Bit
void SetQualityTo16Bit()
Definition: vtkTexture.h:136
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:47
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTexture::RepeatOn
virtual void RepeatOn()
Definition: vtkTexture.h:324
vtkTexture::VTKTextureBlendingMode
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:197
vtkTexture::GetRepeat
virtual vtkTypeBool GetRepeat()
Definition: vtkTexture.h:323
vtkTexture::PremultipliedAlpha
bool PremultipliedAlpha
Definition: vtkTexture.h:357
vtkTexture::SetEdgeClamp
virtual void SetEdgeClamp(vtkTypeBool)
Definition: vtkTexture.h:326
vtkTexture::RepeatOff
virtual void RepeatOff()
Definition: vtkTexture.h:325
vtkTexture::PostRender
virtual void PostRender(vtkRenderer *)
Cleans up after the texture rendering to restore the state of the graphics context.
Definition: vtkTexture.h:83
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:59
vtkTexture::Load
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:97
vtkTexture::VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:204
vtkTexture::SetRepeat
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:322
vtkTexture::Transform
vtkTransform * Transform
Definition: vtkTexture.h:351
vtkTexture::UseSRGBColorSpace
bool UseSRGBColorSpace
Definition: vtkTexture.h:359
vtkTexture::TranslucentCachedResult
int TranslucentCachedResult
Definition: vtkTexture.h:363
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkSystemIncludes.h:89
VTK_TEXTURE_QUALITY_32BIT
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:63
vtkTexture::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:349
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_COLOR_MODE_DIRECT_SCALARS
Definition: vtkSystemIncludes.h:91
vtkTexture::GetEdgeClamp
virtual vtkTypeBool GetEdgeClamp()
Definition: vtkTexture.h:329
vtkTexture::Mipmap
bool Mipmap
Definition: vtkTexture.h:342
vtkTexture::GetTextureUnit
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:251
vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:200
vtkTexture::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:90
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkTexture::CubeMap
bool CubeMap
Definition: vtkTexture.h:358
vtkTexture::Repeat
Definition: vtkTexture.h:293
vtkTexture::MirroredRepeat
Definition: vtkTexture.h:294
vtkTexture::VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:201
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkTexture::SetQualityToDefault
void SetQualityToDefault()
Definition: vtkTexture.h:135
vtkSystemIncludes.h
VTK_TEXTURE_QUALITY_16BIT
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:62