VTK
vtkProperty.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkProperty.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 =========================================================================*/
37 #ifndef vtkProperty_h
38 #define vtkProperty_h
39 
40 #include "vtkRenderingCoreModule.h" // For export macro
41 #include "vtkObject.h"
42 
43 // shading models
44 #define VTK_FLAT 0
45 #define VTK_GOURAUD 1
46 #define VTK_PHONG 2
47 
48 // representation models
49 #define VTK_POINTS 0
50 #define VTK_WIREFRAME 1
51 #define VTK_SURFACE 2
52 
53 class vtkActor;
54 class vtkRenderer;
55 class vtkShaderProgram;
57 class vtkTexture;
58 class vtkWindow;
59 class vtkXMLDataElement;
60 class vtkXMLMaterial;
61 
62 class vtkPropertyInternals;
63 
64 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
65 {
66 public:
67  vtkTypeMacro(vtkProperty,vtkObject);
68  void PrintSelf(ostream& os, vtkIndent indent);
69 
76  static vtkProperty *New();
77 
81  void DeepCopy(vtkProperty *p);
82 
90  virtual void Render(vtkActor *, vtkRenderer *);
91 
98  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
99 
105  virtual void PostRender(vtkActor*, vtkRenderer*);
106 
108 
111  vtkGetMacro(Lighting, bool);
112  vtkSetMacro(Lighting, bool);
113  vtkBooleanMacro(Lighting, bool);
115 
117 
123  vtkGetMacro(RenderPointsAsSpheres, bool);
124  vtkSetMacro(RenderPointsAsSpheres, bool);
125  vtkBooleanMacro(RenderPointsAsSpheres, bool);
127 
129 
136  vtkGetMacro(RenderLinesAsTubes, bool);
137  vtkSetMacro(RenderLinesAsTubes, bool);
138  vtkBooleanMacro(RenderLinesAsTubes, bool);
140 
142 
145  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
146  vtkGetMacro(Interpolation,int);
148  { this->SetInterpolation(VTK_FLAT); }
150  { this->SetInterpolation(VTK_GOURAUD); }
152  { this->SetInterpolation(VTK_PHONG); }
153  const char *GetInterpolationAsString();
155 
157 
160  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
161  vtkGetMacro(Representation,int);
163  { this->SetRepresentation(VTK_POINTS); }
165  { this->SetRepresentation(VTK_WIREFRAME); }
167  { this->SetRepresentation(VTK_SURFACE); }
168  const char *GetRepresentationAsString();
170 
172 
177  virtual void SetColor(double r, double g, double b);
178  virtual void SetColor(double a[3]);
179  double *GetColor();
180  void GetColor(double rgb[3]);
181  void GetColor(double &r, double &g, double &b);
183 
185 
188  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
189  vtkGetMacro(Ambient, double);
191 
193 
196  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
197  vtkGetMacro(Diffuse, double);
199 
201 
204  vtkSetClampMacro(Specular, double, 0.0, 1.0);
205  vtkGetMacro(Specular, double);
207 
209 
212  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
213  vtkGetMacro(SpecularPower, double);
215 
217 
221  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
222  vtkGetMacro(Opacity, double);
224 
226 
232  vtkSetVector3Macro(AmbientColor, double);
233  vtkGetVector3Macro(AmbientColor, double);
235 
237 
240  vtkSetVector3Macro(DiffuseColor, double);
241  vtkGetVector3Macro(DiffuseColor, double);
243 
245 
248  vtkSetVector3Macro(SpecularColor, double);
249  vtkGetVector3Macro(SpecularColor, double);
251 
253 
258  vtkGetMacro(EdgeVisibility, int);
259  vtkSetMacro(EdgeVisibility, int);
260  vtkBooleanMacro(EdgeVisibility, int);
262 
264 
267  vtkSetVector3Macro(EdgeColor, double);
268  vtkGetVector3Macro(EdgeColor, double);
270 
272 
276  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
277  vtkGetMacro(LineWidth, float);
279 
281 
286  vtkSetMacro(LineStipplePattern, int);
287  vtkGetMacro(LineStipplePattern, int);
289 
291 
296  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
297  vtkGetMacro(LineStippleRepeatFactor, int);
299 
301 
305  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
306  vtkGetMacro(PointSize, float);
308 
310 
315  vtkGetMacro(BackfaceCulling, int);
316  vtkSetMacro(BackfaceCulling, int);
317  vtkBooleanMacro(BackfaceCulling, int);
319 
321 
326  vtkGetMacro(FrontfaceCulling, int);
327  vtkSetMacro(FrontfaceCulling, int);
328  vtkBooleanMacro(FrontfaceCulling, int);
330 
332 
335  vtkGetStringMacro(MaterialName);
337 
339 
343  vtkSetMacro(Shading, int);
344  vtkGetMacro(Shading, int);
345  vtkBooleanMacro(Shading, int);
347 
352  { return NULL; }
353 
355 
363  virtual void AddShaderVariable(const char *name, int numVars, int *x);
364  virtual void AddShaderVariable(const char *name, int numVars, float *x);
365  virtual void AddShaderVariable(const char *name, int numVars, double *x);
367 
369 
372  void AddShaderVariable(const char* name, int v)
373  { this->AddShaderVariable(name, 1, &v); }
374  void AddShaderVariable(const char* name, float v)
375  { this->AddShaderVariable(name, 1, &v); }
376  void AddShaderVariable(const char* name, double v)
377  { this->AddShaderVariable(name, 1, &v); }
378  void AddShaderVariable(const char* name, int v1, int v2)
379  {
380  int v[2] = {v1, v2};
381  this->AddShaderVariable(name, 2, v);
382  }
383  void AddShaderVariable(const char* name, float v1, float v2)
384  {
385  float v[2] = {v1, v2};
386  this->AddShaderVariable(name, 2, v);
387  }
388  void AddShaderVariable(const char* name, double v1, double v2)
389  {
390  double v[2] = {v1, v2};
391  this->AddShaderVariable(name, 2, v);
392  }
393  void AddShaderVariable(const char* name, int v1, int v2, int v3)
394  {
395  int v[3] = {v1, v2, v3};
396  this->AddShaderVariable(name, 3, v);
397  }
398  void AddShaderVariable(const char* name, float v1, float v2, float v3)
399  {
400  float v[3] = {v1, v2, v3};
401  this->AddShaderVariable(name, 3, v);
402  }
403  void AddShaderVariable(const char* name, double v1, double v2, double v3)
404  {
405  double v[3] = {v1, v2, v3};
406  this->AddShaderVariable(name, 3, v);
407  }
409 
411 
417  void SetTexture(const char* name, vtkTexture* texture);
418  vtkTexture* GetTexture(const char* name);
420 
422 
428  void SetTexture(int unit, vtkTexture* texture);
429  vtkTexture* GetTexture(int unit);
430  void RemoveTexture(int unit);
432 
437  void RemoveTexture(const char* name);
438 
442  void RemoveAllTextures();
443 
447  int GetNumberOfTextures();
448 
454  virtual void ReleaseGraphicsResources(vtkWindow *win);
455 
461  {
462  VTK_TEXTURE_UNIT_0 = 0,
469  VTK_TEXTURE_UNIT_7
470  };
471 
472 protected:
473  vtkProperty();
474  ~vtkProperty();
475 
479  static void ComputeCompositeColor(double result[3],
480  double ambient, const double ambient_color[3],
481  double diffuse, const double diffuse_color[3],
482  double specular, const double specular_color[3]);
483 
484  double Color[3];
485  double AmbientColor[3];
486  double DiffuseColor[3];
487  double SpecularColor[3];
488  double EdgeColor[3];
489  double Ambient;
490  double Diffuse;
491  double Specular;
493  double Opacity;
494  float PointSize;
495  float LineWidth;
503  bool Lighting;
506 
507  int Shading;
508 
510  vtkSetStringMacro(MaterialName);
511 
512  // FIXME:
513  // Don't use these methods. They will be removed. They are provided only
514  // for the time-being.
515  vtkTexture* GetTextureAtIndex(int index);
516  int GetTextureUnitAtIndex(int index);
517  int GetTextureUnit(const char* name);
518 
519 private:
520  vtkProperty(const vtkProperty&) VTK_DELETE_FUNCTION;
521  void operator=(const vtkProperty&) VTK_DELETE_FUNCTION;
522 
523  vtkPropertyInternals* Internals;
524 };
525 
527 
530 inline const char *vtkProperty::GetInterpolationAsString(void)
531 {
532  if (this->Interpolation == VTK_FLAT)
533  {
534  return "Flat";
535  }
536  else if (this->Interpolation == VTK_GOURAUD)
537  {
538  return "Gouraud";
539  }
540  else
541  {
542  return "Phong";
543  }
544 }
546 
548 
552 {
553  if (this->Representation == VTK_POINTS)
554  {
555  return "Points";
556  }
557  else if (this->Representation == VTK_WIREFRAME)
558  {
559  return "Wireframe";
560  }
561  else
562  {
563  return "Surface";
564  }
565 }
567 
568 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:398
double Opacity
Definition: vtkProperty.h:493
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:151
abstract base class for most VTK objects
Definition: vtkObject.h:59
float PointSize
Definition: vtkProperty.h:494
VTKTextureUnit
Used to specify which texture unit a texture will use.
Definition: vtkProperty.h:460
bool RenderLinesAsTubes
Definition: vtkProperty.h:505
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:376
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Represents an XML element and those nested inside.
int LineStipplePattern
Definition: vtkProperty.h:496
float LineWidth
Definition: vtkProperty.h:495
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:403
represent surface properties of a geometric object
Definition: vtkProperty.h:64
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:551
#define VTK_SURFACE
Definition: vtkProperty.h:51
#define VTK_INT_MAX
Definition: vtkType.h:153
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:147
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:393
double Ambient
Definition: vtkProperty.h:489
double SpecularPower
Definition: vtkProperty.h:492
char * MaterialName
Definition: vtkProperty.h:509
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int FrontfaceCulling
Definition: vtkProperty.h:502
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:374
abstract specification for renderers
Definition: vtkRenderer.h:63
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:388
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:162
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:149
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double Diffuse
Definition: vtkProperty.h:490
#define VTK_FLOAT_MAX
Definition: vtkType.h:161
int EdgeVisibility
Definition: vtkProperty.h:500
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:383
a simple class to control print indentation
Definition: vtkIndent.h:39
int BackfaceCulling
Definition: vtkProperty.h:501
#define VTK_FLAT
Definition: vtkProperty.h:44
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:164
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Get the vtkShaderDeviceAdapter2 if set, returns null otherwise.
Definition: vtkProperty.h:351
int Interpolation
Definition: vtkProperty.h:498
handles properties associated with a texture map
Definition: vtkTexture.h:70
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int Representation
Definition: vtkProperty.h:499
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:166
#define VTK_POINTS
Definition: vtkProperty.h:49
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:372
#define VTK_GOURAUD
Definition: vtkProperty.h:45
#define VTK_PHONG
Definition: vtkProperty.h:46
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:98
int LineStippleRepeatFactor
Definition: vtkProperty.h:497
bool RenderPointsAsSpheres
Definition: vtkProperty.h:504
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:378
an adapter to pass generic vertex attributes to the rendering pipeline.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double Specular
Definition: vtkProperty.h:491
#define VTK_WIREFRAME
Definition: vtkProperty.h:50
The ShaderProgram uses one or more Shader objects.