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 =========================================================================*/
36 #ifndef vtkProperty_h
37 #define vtkProperty_h
38 
39 #include "vtkRenderingCoreModule.h" // For export macro
40 #include "vtkObject.h"
41 
42 // shading models
43 #define VTK_FLAT 0
44 #define VTK_GOURAUD 1
45 #define VTK_PHONG 2
46 
47 // representation models
48 #define VTK_POINTS 0
49 #define VTK_WIREFRAME 1
50 #define VTK_SURFACE 2
51 
52 class vtkActor;
53 class vtkRenderer;
54 class vtkShaderProgram;
56 class vtkTexture;
57 class vtkWindow;
58 class vtkXMLDataElement;
59 class vtkXMLMaterial;
60 
61 class vtkPropertyInternals;
62 
64 {
65 public:
66  vtkTypeMacro(vtkProperty,vtkObject);
67  void PrintSelf(ostream& os, vtkIndent indent);
68 
74  static vtkProperty *New();
75 
77  void DeepCopy(vtkProperty *p);
78 
84  virtual void Render(vtkActor *, vtkRenderer *);
85 
91  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
92 
93  //BTX
95 
97  virtual void PostRender(vtkActor*, vtkRenderer*);
98  //ETX
100 
102 
103  vtkGetMacro(Lighting, bool);
104  vtkSetMacro(Lighting, bool);
105  vtkBooleanMacro(Lighting, bool);
107 
109 
110  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
111  vtkGetMacro(Interpolation,int);
113  { this->SetInterpolation(VTK_FLAT); }
115  { this->SetInterpolation(VTK_GOURAUD); }
117  { this->SetInterpolation(VTK_PHONG); }
118  const char *GetInterpolationAsString();
120 
122 
123  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
124  vtkGetMacro(Representation,int);
126  { this->SetRepresentation(VTK_POINTS); }
128  { this->SetRepresentation(VTK_WIREFRAME); }
130  { this->SetRepresentation(VTK_SURFACE); }
131  const char *GetRepresentationAsString();
133 
135 
138  virtual void SetColor(double r, double g, double b);
139  virtual void SetColor(double a[3]);
140  double *GetColor();
141  void GetColor(double rgb[3]);
142  void GetColor(double &r, double &g, double &b);
144 
146 
147  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
148  vtkGetMacro(Ambient, double);
150 
152 
153  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
154  vtkGetMacro(Diffuse, double);
156 
158 
159  vtkSetClampMacro(Specular, double, 0.0, 1.0);
160  vtkGetMacro(Specular, double);
162 
164 
165  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
166  vtkGetMacro(SpecularPower, double);
168 
170 
172  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
173  vtkGetMacro(Opacity, double);
175 
177 
181  vtkSetVector3Macro(AmbientColor, double);
182  vtkGetVector3Macro(AmbientColor, double);
184 
186 
187  vtkSetVector3Macro(DiffuseColor, double);
188  vtkGetVector3Macro(DiffuseColor, double);
190 
192 
193  vtkSetVector3Macro(SpecularColor, double);
194  vtkGetVector3Macro(SpecularColor, double);
196 
198 
201  vtkGetMacro(EdgeVisibility, int);
202  vtkSetMacro(EdgeVisibility, int);
203  vtkBooleanMacro(EdgeVisibility, int);
205 
207 
208  vtkSetVector3Macro(EdgeColor, double);
209  vtkGetVector3Macro(EdgeColor, double);
211 
213 
215  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
216  vtkGetMacro(LineWidth, float);
218 
220 
223  vtkSetMacro(LineStipplePattern, int);
224  vtkGetMacro(LineStipplePattern, int);
226 
228 
231  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
232  vtkGetMacro(LineStippleRepeatFactor, int);
234 
236 
238  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
239  vtkGetMacro(PointSize, float);
241 
243 
246  vtkGetMacro(BackfaceCulling, int);
247  vtkSetMacro(BackfaceCulling, int);
248  vtkBooleanMacro(BackfaceCulling, int);
250 
252 
255  vtkGetMacro(FrontfaceCulling, int);
256  vtkSetMacro(FrontfaceCulling, int);
257  vtkBooleanMacro(FrontfaceCulling, int);
259 
261 
262  vtkGetStringMacro(MaterialName);
264 
266 
268  vtkSetMacro(Shading, int);
269  vtkGetMacro(Shading, int);
270  vtkBooleanMacro(Shading, int);
272 
274 
276  { return NULL; }
278 
280 
284  virtual void AddShaderVariable(const char *name, int numVars, int *x);
285  virtual void AddShaderVariable(const char *name, int numVars, float *x);
286  virtual void AddShaderVariable(const char *name, int numVars, double *x);
288 
290 
291  void AddShaderVariable(const char* name, int v)
292  { this->AddShaderVariable(name, 1, &v); }
293  void AddShaderVariable(const char* name, float v)
294  { this->AddShaderVariable(name, 1, &v); }
295  void AddShaderVariable(const char* name, double v)
296  { this->AddShaderVariable(name, 1, &v); }
297  void AddShaderVariable(const char* name, int v1, int v2)
298  {
299  int v[2] = {v1, v2};
300  this->AddShaderVariable(name, 2, v);
301  }
302  void AddShaderVariable(const char* name, float v1, float v2)
303  {
304  float v[2] = {v1, v2};
305  this->AddShaderVariable(name, 2, v);
306  }
307  void AddShaderVariable(const char* name, double v1, double v2)
308  {
309  double v[2] = {v1, v2};
310  this->AddShaderVariable(name, 2, v);
311  }
312  void AddShaderVariable(const char* name, int v1, int v2, int v3)
313  {
314  int v[3] = {v1, v2, v3};
315  this->AddShaderVariable(name, 3, v);
316  }
317  void AddShaderVariable(const char* name, float v1, float v2, float v3)
318  {
319  float v[3] = {v1, v2, v3};
320  this->AddShaderVariable(name, 3, v);
321  }
322  void AddShaderVariable(const char* name, double v1, double v2, double v3)
323  {
324  double v[3] = {v1, v2, v3};
325  this->AddShaderVariable(name, 3, v);
326  }
328 
330 
334  void SetTexture(const char* name, vtkTexture* texture);
335  vtkTexture* GetTexture(const char* name);
337 
339 
343  void SetTexture(int unit, vtkTexture* texture);
344  vtkTexture* GetTexture(int unit);
345  void RemoveTexture(int unit);
347 
350  void RemoveTexture(const char* name);
351 
353  void RemoveAllTextures();
354 
356  int GetNumberOfTextures();
357 
361  virtual void ReleaseGraphicsResources(vtkWindow *win);
362 
363 //BTX
365 
368  {
369  VTK_TEXTURE_UNIT_0 = 0,
376  VTK_TEXTURE_UNIT_7
377  };
378 //ETX
380 
381 protected:
382  vtkProperty();
383  ~vtkProperty();
384 
386 
387  static void ComputeCompositeColor(double result[3],
388  double ambient, const double ambient_color[3],
389  double diffuse, const double diffuse_color[3],
390  double specular, const double specular_color[3]);
392 
393  double Color[3];
394  double AmbientColor[3];
395  double DiffuseColor[3];
396  double SpecularColor[3];
397  double EdgeColor[3];
398  double Ambient;
399  double Diffuse;
400  double Specular;
402  double Opacity;
403  float PointSize;
404  float LineWidth;
412  bool Lighting;
413 
414  int Shading;
415 
417  vtkSetStringMacro(MaterialName);
418 
419 //BTX
420  // FIXME:
421  // Don't use these methods. They will be removed. They are provided only
422  // for the time-being.
423  vtkTexture* GetTextureAtIndex(int index);
424  int GetTextureUnitAtIndex(int index);
425  int GetTextureUnit(const char* name);
426 //ETX
427 
428 private:
429  vtkProperty(const vtkProperty&); // Not implemented.
430  void operator=(const vtkProperty&); // Not implemented.
431 
432  vtkPropertyInternals* Internals;
433 };
434 
436 
438 {
439  if (this->Interpolation == VTK_FLAT)
440  {
441  return "Flat";
442  }
443  else if (this->Interpolation == VTK_GOURAUD)
444  {
445  return "Gouraud";
446  }
447  else
448  {
449  return "Phong";
450  }
451 }
453 
455 
457 {
458  if (this->Representation == VTK_POINTS)
459  {
460  return "Points";
461  }
462  else if (this->Representation == VTK_WIREFRAME)
463  {
464  return "Wireframe";
465  }
466  else
467  {
468  return "Surface";
469  }
470 }
472 
473 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Definition: vtkProperty.h:317
double Opacity
Definition: vtkProperty.h:402
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
void SetInterpolationToPhong()
Definition: vtkProperty.h:116
abstract base class for most VTK objects
Definition: vtkObject.h:61
float PointSize
Definition: vtkProperty.h:403
void AddShaderVariable(const char *name, double v)
Definition: vtkProperty.h:295
Represents an XML element and those nested inside.
int LineStipplePattern
Definition: vtkProperty.h:405
float LineWidth
Definition: vtkProperty.h:404
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Definition: vtkProperty.h:322
represent surface properties of a geometric object
Definition: vtkProperty.h:63
const char * GetRepresentationAsString()
Definition: vtkProperty.h:456
#define VTK_SURFACE
Definition: vtkProperty.h:50
#define VTK_INT_MAX
Definition: vtkType.h:132
void SetInterpolationToFlat()
Definition: vtkProperty.h:112
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Definition: vtkProperty.h:312
double Ambient
Definition: vtkProperty.h:398
double SpecularPower
Definition: vtkProperty.h:401
char * MaterialName
Definition: vtkProperty.h:416
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
int FrontfaceCulling
Definition: vtkProperty.h:411
void AddShaderVariable(const char *name, float v)
Definition: vtkProperty.h:293
abstract specification for renderers
Definition: vtkRenderer.h:63
void AddShaderVariable(const char *name, double v1, double v2)
Definition: vtkProperty.h:307
void SetRepresentationToPoints()
Definition: vtkProperty.h:125
void SetInterpolationToGouraud()
Definition: vtkProperty.h:114
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
double Diffuse
Definition: vtkProperty.h:399
#define VTK_FLOAT_MAX
Definition: vtkType.h:140
int EdgeVisibility
Definition: vtkProperty.h:409
void AddShaderVariable(const char *name, float v1, float v2)
Definition: vtkProperty.h:302
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
int BackfaceCulling
Definition: vtkProperty.h:410
#define VTK_FLAT
Definition: vtkProperty.h:43
void SetRepresentationToWireframe()
Definition: vtkProperty.h:127
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Definition: vtkProperty.h:275
int Interpolation
Definition: vtkProperty.h:407
handles properties associated with a texture map
Definition: vtkTexture.h:69
int Representation
Definition: vtkProperty.h:408
void SetRepresentationToSurface()
Definition: vtkProperty.h:129
#define VTK_POINTS
Definition: vtkProperty.h:48
void AddShaderVariable(const char *name, int v)
Definition: vtkProperty.h:291
#define VTK_GOURAUD
Definition: vtkProperty.h:44
#define VTK_PHONG
Definition: vtkProperty.h:45
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
Definition: vtkProperty.h:91
int LineStippleRepeatFactor
Definition: vtkProperty.h:406
const char * GetInterpolationAsString()
Definition: vtkProperty.h:437
#define VTKRENDERINGCORE_EXPORT
void AddShaderVariable(const char *name, int v1, int v2)
Definition: vtkProperty.h:297
an adapter to pass generic vertex attributes to the rendering pipeline. .SECTION This class is an ada...
static vtkObject * New()
double Specular
Definition: vtkProperty.h:400
#define VTK_WIREFRAME
Definition: vtkProperty.h:49
The ShaderProgram uses one or more Shader objects.