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 
277  vtkGetMacro(VertexVisibility, int);
278  vtkSetMacro(VertexVisibility, int);
279  vtkBooleanMacro(VertexVisibility, int);
281 
283 
286  vtkSetVector3Macro(VertexColor, double);
287  vtkGetVector3Macro(VertexColor, double);
289 
291 
295  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
296  vtkGetMacro(LineWidth, float);
298 
300 
305  vtkSetMacro(LineStipplePattern, int);
306  vtkGetMacro(LineStipplePattern, int);
308 
310 
315  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
316  vtkGetMacro(LineStippleRepeatFactor, int);
318 
320 
324  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
325  vtkGetMacro(PointSize, float);
327 
329 
334  vtkGetMacro(BackfaceCulling, int);
335  vtkSetMacro(BackfaceCulling, int);
336  vtkBooleanMacro(BackfaceCulling, int);
338 
340 
345  vtkGetMacro(FrontfaceCulling, int);
346  vtkSetMacro(FrontfaceCulling, int);
347  vtkBooleanMacro(FrontfaceCulling, int);
349 
351 
354  vtkGetStringMacro(MaterialName);
356 
358 
362  vtkSetMacro(Shading, int);
363  vtkGetMacro(Shading, int);
364  vtkBooleanMacro(Shading, int);
366 
371  { return NULL; }
372 
374 
382  virtual void AddShaderVariable(const char *name, int numVars, int *x);
383  virtual void AddShaderVariable(const char *name, int numVars, float *x);
384  virtual void AddShaderVariable(const char *name, int numVars, double *x);
386 
388 
391  void AddShaderVariable(const char* name, int v)
392  { this->AddShaderVariable(name, 1, &v); }
393  void AddShaderVariable(const char* name, float v)
394  { this->AddShaderVariable(name, 1, &v); }
395  void AddShaderVariable(const char* name, double v)
396  { this->AddShaderVariable(name, 1, &v); }
397  void AddShaderVariable(const char* name, int v1, int v2)
398  {
399  int v[2] = {v1, v2};
400  this->AddShaderVariable(name, 2, v);
401  }
402  void AddShaderVariable(const char* name, float v1, float v2)
403  {
404  float v[2] = {v1, v2};
405  this->AddShaderVariable(name, 2, v);
406  }
407  void AddShaderVariable(const char* name, double v1, double v2)
408  {
409  double v[2] = {v1, v2};
410  this->AddShaderVariable(name, 2, v);
411  }
412  void AddShaderVariable(const char* name, int v1, int v2, int v3)
413  {
414  int v[3] = {v1, v2, v3};
415  this->AddShaderVariable(name, 3, v);
416  }
417  void AddShaderVariable(const char* name, float v1, float v2, float v3)
418  {
419  float v[3] = {v1, v2, v3};
420  this->AddShaderVariable(name, 3, v);
421  }
422  void AddShaderVariable(const char* name, double v1, double v2, double v3)
423  {
424  double v[3] = {v1, v2, v3};
425  this->AddShaderVariable(name, 3, v);
426  }
428 
430 
436  void SetTexture(const char* name, vtkTexture* texture);
437  vtkTexture* GetTexture(const char* name);
439 
441 
447  void SetTexture(int unit, vtkTexture* texture);
448  vtkTexture* GetTexture(int unit);
449  void RemoveTexture(int unit);
451 
456  void RemoveTexture(const char* name);
457 
461  void RemoveAllTextures();
462 
466  int GetNumberOfTextures();
467 
473  virtual void ReleaseGraphicsResources(vtkWindow *win);
474 
480  {
481  VTK_TEXTURE_UNIT_0 = 0,
488  VTK_TEXTURE_UNIT_7
489  };
490 
491 protected:
492  vtkProperty();
493  ~vtkProperty();
494 
498  static void ComputeCompositeColor(double result[3],
499  double ambient, const double ambient_color[3],
500  double diffuse, const double diffuse_color[3],
501  double specular, const double specular_color[3]);
502 
503  double Color[3];
504  double AmbientColor[3];
505  double DiffuseColor[3];
506  double SpecularColor[3];
507  double EdgeColor[3];
508  double VertexColor[3];
509  double Ambient;
510  double Diffuse;
511  double Specular;
513  double Opacity;
514  float PointSize;
515  float LineWidth;
524  bool Lighting;
527 
528  int Shading;
529 
531  vtkSetStringMacro(MaterialName);
532 
533  // FIXME:
534  // Don't use these methods. They will be removed. They are provided only
535  // for the time-being.
536  vtkTexture* GetTextureAtIndex(int index);
537  int GetTextureUnitAtIndex(int index);
538  int GetTextureUnit(const char* name);
539 
540 private:
541  vtkProperty(const vtkProperty&) VTK_DELETE_FUNCTION;
542  void operator=(const vtkProperty&) VTK_DELETE_FUNCTION;
543 
544  vtkPropertyInternals* Internals;
545 };
546 
548 
551 inline const char *vtkProperty::GetInterpolationAsString(void)
552 {
553  if (this->Interpolation == VTK_FLAT)
554  {
555  return "Flat";
556  }
557  else if (this->Interpolation == VTK_GOURAUD)
558  {
559  return "Gouraud";
560  }
561  else
562  {
563  return "Phong";
564  }
565 }
567 
569 
573 {
574  if (this->Representation == VTK_POINTS)
575  {
576  return "Points";
577  }
578  else if (this->Representation == VTK_WIREFRAME)
579  {
580  return "Wireframe";
581  }
582  else
583  {
584  return "Surface";
585  }
586 }
588 
589 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:417
double Opacity
Definition: vtkProperty.h:513
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:514
VTKTextureUnit
Used to specify which texture unit a texture will use.
Definition: vtkProperty.h:479
bool RenderLinesAsTubes
Definition: vtkProperty.h:526
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:395
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:516
float LineWidth
Definition: vtkProperty.h:515
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:422
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:572
#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:412
double Ambient
Definition: vtkProperty.h:509
double SpecularPower
Definition: vtkProperty.h:512
char * MaterialName
Definition: vtkProperty.h:530
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int FrontfaceCulling
Definition: vtkProperty.h:523
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:393
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:407
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
int VertexVisibility
Definition: vtkProperty.h:521
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double Diffuse
Definition: vtkProperty.h:510
#define VTK_FLOAT_MAX
Definition: vtkType.h:161
int EdgeVisibility
Definition: vtkProperty.h:520
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:402
a simple class to control print indentation
Definition: vtkIndent.h:39
int BackfaceCulling
Definition: vtkProperty.h:522
#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:370
int Interpolation
Definition: vtkProperty.h:518
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:519
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:391
#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:517
bool RenderPointsAsSpheres
Definition: vtkProperty.h:525
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:397
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:511
#define VTK_WIREFRAME
Definition: vtkProperty.h:50
The ShaderProgram uses one or more Shader objects.