VTK  9.2.6
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 =========================================================================*/
49 #ifndef vtkTexture_h
50 #define vtkTexture_h
51 
52 #include "vtkImageAlgorithm.h"
53 #include "vtkRenderingCoreModule.h" // For export macro
54 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
55 
56 class vtkImageData;
57 class vtkScalarsToColors;
58 class vtkRenderer;
60 class vtkWindow;
61 class vtkDataArray;
62 class vtkTransform;
63 
64 #define VTK_TEXTURE_QUALITY_DEFAULT 0
65 #define VTK_TEXTURE_QUALITY_16BIT 16
66 #define VTK_TEXTURE_QUALITY_32BIT 32
67 
68 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
69 {
70 public:
71  static vtkTexture* New();
72  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
80  virtual void Render(vtkRenderer* ren);
81 
86  virtual void PostRender(vtkRenderer*) {}
87 
94 
100  virtual void Load(vtkRenderer*) {}
101 
103 
106  vtkGetMacro(Interpolate, vtkTypeBool);
107  vtkSetMacro(Interpolate, vtkTypeBool);
108  vtkBooleanMacro(Interpolate, vtkTypeBool);
110 
112 
115  vtkGetMacro(Mipmap, bool);
116  vtkSetMacro(Mipmap, bool);
117  vtkBooleanMacro(Mipmap, bool);
119 
121 
127  vtkSetMacro(MaximumAnisotropicFiltering, float);
128  vtkGetMacro(MaximumAnisotropicFiltering, float);
130 
132 
136  vtkSetMacro(Quality, int);
137  vtkGetMacro(Quality, int);
138  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
139  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
140  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
142 
144 
154  vtkSetMacro(ColorMode, int);
155  vtkGetMacro(ColorMode, int);
156  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
157  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
160 
166 
168 
171  void SetLookupTable(vtkScalarsToColors*);
172  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
174 
176 
179  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
181 
185  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
186 
188 
192  void SetTransform(vtkTransform* transform);
193  vtkGetObjectMacro(Transform, vtkTransform);
195 
201  {
202  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
208  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
209  };
210 
212 
216  vtkGetMacro(BlendingMode, int);
217  vtkSetMacro(BlendingMode, int);
219 
221 
225  vtkGetMacro(PremultipliedAlpha, bool);
226  vtkSetMacro(PremultipliedAlpha, bool);
227  vtkBooleanMacro(PremultipliedAlpha, bool);
229 
231 
238  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
239  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
240  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
242 
249  virtual int IsTranslucent();
250 
254  virtual int GetTextureUnit() { return 0; }
255 
257 
263  vtkGetMacro(CubeMap, bool);
264  vtkBooleanMacro(CubeMap, bool);
265  void SetCubeMap(bool val);
267 
269 
275  vtkGetMacro(UseSRGBColorSpace, bool);
276  vtkSetMacro(UseSRGBColorSpace, bool);
277  vtkBooleanMacro(UseSRGBColorSpace, bool);
279 
281 
289  vtkSetVector4Macro(BorderColor, float);
290  vtkGetVector4Macro(BorderColor, float);
292 
293  enum
294  {
295  ClampToEdge = 0,
299  NumberOfWrapModes
300  };
301 
303 
316  vtkGetMacro(Wrap, int);
317  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
319 
321 
325  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
326  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
327  virtual void RepeatOn() { this->SetRepeat(true); }
328  virtual void RepeatOff() { this->SetRepeat(false); }
329  virtual void SetEdgeClamp(vtkTypeBool)
330  { /* This wasn't doing anything before. */
331  }
332  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
333  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
334  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
336 
337 protected:
338  vtkTexture();
339  ~vtkTexture() override;
340 
341  // A texture is a sink, so there is no need to do anything.
342  // This definition avoids a warning when doing Update() on a vtkTexture object.
343  void ExecuteData(vtkDataObject*) override {}
344 
345  bool Mipmap;
347  int Wrap;
348  float BorderColor[4];
350  int Quality;
355 
358  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
361  bool CubeMap;
363 
364  // the result of HasTranslucentPolygonalGeometry is cached
367 
368 private:
369  vtkTexture(const vtkTexture&) = delete;
370  void operator=(const vtkTexture&) = delete;
371 };
372 
373 #endif
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:346
#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:86
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:200
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:65
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:139
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:158
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:325
virtual void EdgeClampOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:334
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:352
int TranslucentCachedResult
Definition: vtkTexture.h:366
bool PremultipliedAlpha
Definition: vtkTexture.h:360
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:93
vtkDataObject * GetInput()
Get a data object for one of the input port connections.
abstract specification for renderers
Definition: vtkRenderer.h:72
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:327
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:333
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:329
int ColorMode
Definition: vtkTexture.h:351
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:100
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:64
int vtkTypeBool
Definition: vtkABI.h:69
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:328
#define VTK_COLOR_MODE_MAP_SCALARS
bool CubeMap
Definition: vtkTexture.h:361
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:332
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTransform * Transform
Definition: vtkTexture.h:354
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:365
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
bool Mipmap
Definition: vtkTexture.h:345
handles properties associated with a texture map
Definition: vtkTexture.h:68
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:138
#define VTK_COLOR_MODE_DEFAULT
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:157
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:353
dynamic, self-adjusting array of unsigned char
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:254
int SelfAdjustingTableRange
Definition: vtkTexture.h:359
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:140
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:343
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:357
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:66
vtkTypeBool Interpolate
Definition: vtkTexture.h:349
general representation of visualization data
Definition: vtkDataObject.h:65
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:326
int BlendingMode
Definition: vtkTexture.h:356
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:156
bool UseSRGBColorSpace
Definition: vtkTexture.h:362