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 =========================================================================*/
31 #ifndef vtkProperty_h
32 #define vtkProperty_h
33 
34 #include "vtkRenderingCoreModule.h" // For export macro
35 #include "vtkObject.h"
36 
37 // shading models
38 #define VTK_FLAT 0
39 #define VTK_GOURAUD 1
40 #define VTK_PHONG 2
41 
42 // representation models
43 #define VTK_POINTS 0
44 #define VTK_WIREFRAME 1
45 #define VTK_SURFACE 2
46 
47 class vtkActor;
48 class vtkRenderer;
49 class vtkShaderProgram;
51 class vtkTexture;
52 class vtkWindow;
53 class vtkXMLDataElement;
54 class vtkXMLMaterial;
55 
56 class vtkPropertyInternals;
57 
58 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
59 {
60 public:
61  vtkTypeMacro(vtkProperty,vtkObject);
62  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
63 
70  static vtkProperty *New();
71 
75  void DeepCopy(vtkProperty *p);
76 
84  virtual void Render(vtkActor *, vtkRenderer *);
85 
92  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
93 
99  virtual void PostRender(vtkActor*, vtkRenderer*);
100 
102 
105  vtkGetMacro(Lighting, bool);
106  vtkSetMacro(Lighting, bool);
107  vtkBooleanMacro(Lighting, bool);
109 
111 
117  vtkGetMacro(RenderPointsAsSpheres, bool);
118  vtkSetMacro(RenderPointsAsSpheres, bool);
119  vtkBooleanMacro(RenderPointsAsSpheres, bool);
121 
123 
130  vtkGetMacro(RenderLinesAsTubes, bool);
131  vtkSetMacro(RenderLinesAsTubes, bool);
132  vtkBooleanMacro(RenderLinesAsTubes, bool);
134 
136 
139  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
140  vtkGetMacro(Interpolation,int);
142  { this->SetInterpolation(VTK_FLAT); }
144  { this->SetInterpolation(VTK_GOURAUD); }
146  { this->SetInterpolation(VTK_PHONG); }
147  const char *GetInterpolationAsString();
149 
151 
154  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
155  vtkGetMacro(Representation,int);
157  { this->SetRepresentation(VTK_POINTS); }
159  { this->SetRepresentation(VTK_WIREFRAME); }
161  { this->SetRepresentation(VTK_SURFACE); }
162  const char *GetRepresentationAsString();
164 
166 
171  virtual void SetColor(double r, double g, double b);
172  virtual void SetColor(double a[3]);
173  double *GetColor();
174  void GetColor(double rgb[3]);
175  void GetColor(double &r, double &g, double &b);
177 
179 
182  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
183  vtkGetMacro(Ambient, double);
185 
187 
190  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
191  vtkGetMacro(Diffuse, double);
193 
195 
198  vtkSetClampMacro(Specular, double, 0.0, 1.0);
199  vtkGetMacro(Specular, double);
201 
203 
206  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
207  vtkGetMacro(SpecularPower, double);
209 
211 
215  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
216  vtkGetMacro(Opacity, double);
218 
220 
226  vtkSetVector3Macro(AmbientColor, double);
227  vtkGetVector3Macro(AmbientColor, double);
229 
231 
234  vtkSetVector3Macro(DiffuseColor, double);
235  vtkGetVector3Macro(DiffuseColor, double);
237 
239 
242  vtkSetVector3Macro(SpecularColor, double);
243  vtkGetVector3Macro(SpecularColor, double);
245 
247 
252  vtkGetMacro(EdgeVisibility, int);
253  vtkSetMacro(EdgeVisibility, int);
254  vtkBooleanMacro(EdgeVisibility, int);
256 
258 
261  vtkSetVector3Macro(EdgeColor, double);
262  vtkGetVector3Macro(EdgeColor, double);
264 
266 
271  vtkGetMacro(VertexVisibility, int);
272  vtkSetMacro(VertexVisibility, int);
273  vtkBooleanMacro(VertexVisibility, int);
275 
277 
280  vtkSetVector3Macro(VertexColor, double);
281  vtkGetVector3Macro(VertexColor, double);
283 
285 
289  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
290  vtkGetMacro(LineWidth, float);
292 
294 
299  vtkSetMacro(LineStipplePattern, int);
300  vtkGetMacro(LineStipplePattern, int);
302 
304 
309  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
310  vtkGetMacro(LineStippleRepeatFactor, int);
312 
314 
318  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
319  vtkGetMacro(PointSize, float);
321 
323 
328  vtkGetMacro(BackfaceCulling, int);
329  vtkSetMacro(BackfaceCulling, int);
330  vtkBooleanMacro(BackfaceCulling, int);
332 
334 
339  vtkGetMacro(FrontfaceCulling, int);
340  vtkSetMacro(FrontfaceCulling, int);
341  vtkBooleanMacro(FrontfaceCulling, int);
343 
345 
348  vtkGetStringMacro(MaterialName);
350 
352 
356  vtkSetMacro(Shading, int);
357  vtkGetMacro(Shading, int);
358  vtkBooleanMacro(Shading, int);
360 
365  { return NULL; }
366 
368 
376  virtual void AddShaderVariable(const char *name, int numVars, int *x);
377  virtual void AddShaderVariable(const char *name, int numVars, float *x);
378  virtual void AddShaderVariable(const char *name, int numVars, double *x);
380 
382 
385  void AddShaderVariable(const char* name, int v)
386  { this->AddShaderVariable(name, 1, &v); }
387  void AddShaderVariable(const char* name, float v)
388  { this->AddShaderVariable(name, 1, &v); }
389  void AddShaderVariable(const char* name, double v)
390  { this->AddShaderVariable(name, 1, &v); }
391  void AddShaderVariable(const char* name, int v1, int v2)
392  {
393  int v[2] = {v1, v2};
394  this->AddShaderVariable(name, 2, v);
395  }
396  void AddShaderVariable(const char* name, float v1, float v2)
397  {
398  float v[2] = {v1, v2};
399  this->AddShaderVariable(name, 2, v);
400  }
401  void AddShaderVariable(const char* name, double v1, double v2)
402  {
403  double v[2] = {v1, v2};
404  this->AddShaderVariable(name, 2, v);
405  }
406  void AddShaderVariable(const char* name, int v1, int v2, int v3)
407  {
408  int v[3] = {v1, v2, v3};
409  this->AddShaderVariable(name, 3, v);
410  }
411  void AddShaderVariable(const char* name, float v1, float v2, float v3)
412  {
413  float v[3] = {v1, v2, v3};
414  this->AddShaderVariable(name, 3, v);
415  }
416  void AddShaderVariable(const char* name, double v1, double v2, double v3)
417  {
418  double v[3] = {v1, v2, v3};
419  this->AddShaderVariable(name, 3, v);
420  }
422 
424 
430  void SetTexture(const char* name, vtkTexture* texture);
431  vtkTexture* GetTexture(const char* name);
433 
435 
441  void SetTexture(int unit, vtkTexture* texture);
442  vtkTexture* GetTexture(int unit);
443  void RemoveTexture(int unit);
445 
450  void RemoveTexture(const char* name);
451 
455  void RemoveAllTextures();
456 
460  int GetNumberOfTextures();
461 
467  virtual void ReleaseGraphicsResources(vtkWindow *win);
468 
474  {
475  VTK_TEXTURE_UNIT_0 = 0,
482  VTK_TEXTURE_UNIT_7
483  };
484 
485 protected:
486  vtkProperty();
487  ~vtkProperty() VTK_OVERRIDE;
488 
492  static void ComputeCompositeColor(double result[3],
493  double ambient, const double ambient_color[3],
494  double diffuse, const double diffuse_color[3],
495  double specular, const double specular_color[3]);
496 
497  double Color[3];
498  double AmbientColor[3];
499  double DiffuseColor[3];
500  double SpecularColor[3];
501  double EdgeColor[3];
502  double VertexColor[3];
503  double Ambient;
504  double Diffuse;
505  double Specular;
506  double SpecularPower;
507  double Opacity;
508  float PointSize;
509  float LineWidth;
510  int LineStipplePattern;
511  int LineStippleRepeatFactor;
512  int Interpolation;
513  int Representation;
514  int EdgeVisibility;
515  int VertexVisibility;
516  int BackfaceCulling;
517  int FrontfaceCulling;
518  bool Lighting;
519  bool RenderPointsAsSpheres;
520  bool RenderLinesAsTubes;
521 
522  int Shading;
523 
524  char* MaterialName;
525  vtkSetStringMacro(MaterialName);
526 
527  // FIXME:
528  // Don't use these methods. They will be removed. They are provided only
529  // for the time-being.
530  vtkTexture* GetTextureAtIndex(int index);
531  int GetTextureUnitAtIndex(int index);
532  int GetTextureUnit(const char* name);
533 
534 private:
535  vtkProperty(const vtkProperty&) VTK_DELETE_FUNCTION;
536  void operator=(const vtkProperty&) VTK_DELETE_FUNCTION;
537 
538  vtkPropertyInternals* Internals;
539 };
540 
542 
545 inline const char *vtkProperty::GetInterpolationAsString(void)
546 {
547  if (this->Interpolation == VTK_FLAT)
548  {
549  return "Flat";
550  }
551  else if (this->Interpolation == VTK_GOURAUD)
552  {
553  return "Gouraud";
554  }
555  else
556  {
557  return "Phong";
558  }
559 }
561 
563 
567 {
568  if (this->Representation == VTK_POINTS)
569  {
570  return "Points";
571  }
572  else if (this->Representation == VTK_WIREFRAME)
573  {
574  return "Wireframe";
575  }
576  else
577  {
578  return "Surface";
579  }
580 }
582 
583 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:411
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:145
abstract base class for most VTK objects
Definition: vtkObject.h:53
VTKTextureUnit
Used to specify which texture unit a texture will use.
Definition: vtkProperty.h:473
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:389
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.
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:416
represent surface properties of a geometric object
Definition: vtkProperty.h:58
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:566
#define VTK_SURFACE
Definition: vtkProperty.h:45
#define VTK_INT_MAX
Definition: vtkType.h:157
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:141
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:406
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:387
abstract specification for renderers
Definition: vtkRenderer.h:57
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:401
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:156
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:143
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:396
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_FLAT
Definition: vtkProperty.h:38
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:158
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Get the vtkShaderDeviceAdapter2 if set, returns null otherwise.
Definition: vtkProperty.h:364
handles properties associated with a texture map
Definition: vtkTexture.h:64
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:160
#define VTK_POINTS
Definition: vtkProperty.h:43
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:385
#define VTK_GOURAUD
Definition: vtkProperty.h:39
#define VTK_PHONG
Definition: vtkProperty.h:40
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:92
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:391
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...
#define VTK_WIREFRAME
Definition: vtkProperty.h:44
The ShaderProgram uses one or more Shader objects.