VTK  9.3.1
vtkTexture.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 vtkTexture_h
38 #define vtkTexture_h
39 
40 #include "vtkImageAlgorithm.h"
41 #include "vtkRenderingCoreModule.h" // For export macro
42 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkImageData;
46 class vtkScalarsToColors;
47 class vtkRenderer;
49 class vtkWindow;
50 class vtkDataArray;
51 class vtkTransform;
52 
53 #define VTK_TEXTURE_QUALITY_DEFAULT 0
54 #define VTK_TEXTURE_QUALITY_16BIT 16
55 #define VTK_TEXTURE_QUALITY_32BIT 32
56 
57 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
58 {
59 public:
60  static vtkTexture* New();
61  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
69  virtual void Render(vtkRenderer* ren);
70 
75  virtual void PostRender(vtkRenderer*) {}
76 
83 
89  virtual void Load(vtkRenderer*) {}
90 
92 
95  vtkGetMacro(Interpolate, vtkTypeBool);
96  vtkSetMacro(Interpolate, vtkTypeBool);
97  vtkBooleanMacro(Interpolate, vtkTypeBool);
99 
101 
104  vtkGetMacro(Mipmap, bool);
105  vtkSetMacro(Mipmap, bool);
106  vtkBooleanMacro(Mipmap, bool);
108 
110 
116  vtkSetMacro(MaximumAnisotropicFiltering, float);
117  vtkGetMacro(MaximumAnisotropicFiltering, float);
119 
121 
125  vtkSetMacro(Quality, int);
126  vtkGetMacro(Quality, int);
127  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
128  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
129  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
131 
133 
143  vtkSetMacro(ColorMode, int);
144  vtkGetMacro(ColorMode, int);
145  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
146  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
149 
155 
157 
160  void SetLookupTable(vtkScalarsToColors*);
161  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
163 
165 
168  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
170 
174  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
175 
177 
181  void SetTransform(vtkTransform* transform);
182  vtkGetObjectMacro(Transform, vtkTransform);
184 
190  {
191  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
197  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
198  };
199 
201 
205  vtkGetMacro(BlendingMode, int);
206  vtkSetMacro(BlendingMode, int);
208 
210 
214  vtkGetMacro(PremultipliedAlpha, bool);
215  vtkSetMacro(PremultipliedAlpha, bool);
216  vtkBooleanMacro(PremultipliedAlpha, bool);
218 
220 
227  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
228  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
229  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
231 
238  virtual int IsTranslucent();
239 
243  virtual int GetTextureUnit() { return 0; }
244 
246 
252  vtkGetMacro(CubeMap, bool);
253  vtkBooleanMacro(CubeMap, bool);
254  void SetCubeMap(bool val);
256 
258 
264  vtkGetMacro(UseSRGBColorSpace, bool);
265  vtkSetMacro(UseSRGBColorSpace, bool);
266  vtkBooleanMacro(UseSRGBColorSpace, bool);
268 
270 
278  vtkSetVector4Macro(BorderColor, float);
279  vtkGetVector4Macro(BorderColor, float);
281 
282  enum
283  {
284  ClampToEdge = 0,
288  NumberOfWrapModes
289  };
290 
292 
305  vtkGetMacro(Wrap, int);
306  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
308 
310 
314  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
315  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
316  virtual void RepeatOn() { this->SetRepeat(true); }
317  virtual void RepeatOff() { this->SetRepeat(false); }
318  virtual void SetEdgeClamp(vtkTypeBool)
319  { /* This wasn't doing anything before. */
320  }
321  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
322  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
323  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
325 
326 protected:
327  vtkTexture();
328  ~vtkTexture() override;
329 
330  // A texture is a sink, so there is no need to do anything.
331  // This definition avoids a warning when doing Update() on a vtkTexture object.
332  void ExecuteData(vtkDataObject*) override {}
333 
334  bool Mipmap;
336  int Wrap;
337  float BorderColor[4];
339  int Quality;
344 
347  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
350  bool CubeMap;
352 
353  // the result of HasTranslucentPolygonalGeometry is cached
356 
357 private:
358  vtkTexture(const vtkTexture&) = delete;
359  void operator=(const vtkTexture&) = delete;
360 };
361 
362 VTK_ABI_NAMESPACE_END
363 #endif
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:335
#define VTK_COLOR_MODE_DIRECT_SCALARS
virtual void PostRender(vtkRenderer *)
Cleans up after the texture rendering to restore the state of the graphics context.
Definition: vtkTexture.h:75
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:189
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:54
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:128
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:147
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:314
virtual void EdgeClampOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:323
record modification and/or execution time
Definition: vtkTimeStamp.h:24
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:341
int TranslucentCachedResult
Definition: vtkTexture.h:355
bool PremultipliedAlpha
Definition: vtkTexture.h:349
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:82
vtkDataObject * GetInput()
Get a data object for one of the input port connections.
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:316
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:322
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:318
int ColorMode
Definition: vtkTexture.h:340
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:89
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:53
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:317
#define VTK_COLOR_MODE_MAP_SCALARS
bool CubeMap
Definition: vtkTexture.h:350
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:321
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkTransform * Transform
Definition: vtkTexture.h:343
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:354
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
bool Mipmap
Definition: vtkTexture.h:334
handles properties associated with a texture map
Definition: vtkTexture.h:57
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:127
#define VTK_COLOR_MODE_DEFAULT
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:146
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:342
dynamic, self-adjusting array of unsigned char
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:243
int SelfAdjustingTableRange
Definition: vtkTexture.h:348
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:129
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:332
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:346
Generic algorithm superclass for image algs.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:55
vtkTypeBool Interpolate
Definition: vtkTexture.h:338
general representation of visualization data
Definition: vtkDataObject.h:54
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:315
int BlendingMode
Definition: vtkTexture.h:345
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:145
bool UseSRGBColorSpace
Definition: vtkTexture.h:351