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 vtkInformation;
55 class vtkRenderer;
56 class vtkShaderProgram;
58 class vtkTexture;
59 class vtkWindow;
60 class vtkXMLDataElement;
61 class vtkXMLMaterial;
62 
63 class vtkPropertyInternals;
64 
65 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
66 {
67 public:
68  vtkTypeMacro(vtkProperty,vtkObject);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
77  static vtkProperty *New();
78 
82  void DeepCopy(vtkProperty *p);
83 
91  virtual void Render(vtkActor *, vtkRenderer *);
92 
99  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
100 
106  virtual void PostRender(vtkActor*, vtkRenderer*);
107 
109 
112  vtkGetMacro(Lighting, bool);
113  vtkSetMacro(Lighting, bool);
114  vtkBooleanMacro(Lighting, bool);
116 
118 
124  vtkGetMacro(RenderPointsAsSpheres, bool);
125  vtkSetMacro(RenderPointsAsSpheres, bool);
126  vtkBooleanMacro(RenderPointsAsSpheres, bool);
128 
130 
137  vtkGetMacro(RenderLinesAsTubes, bool);
138  vtkSetMacro(RenderLinesAsTubes, bool);
139  vtkBooleanMacro(RenderLinesAsTubes, bool);
141 
143 
146  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
147  vtkGetMacro(Interpolation,int);
149  { this->SetInterpolation(VTK_FLAT); }
151  { this->SetInterpolation(VTK_GOURAUD); }
153  { this->SetInterpolation(VTK_PHONG); }
154  const char *GetInterpolationAsString();
156 
158 
161  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
162  vtkGetMacro(Representation,int);
164  { this->SetRepresentation(VTK_POINTS); }
166  { this->SetRepresentation(VTK_WIREFRAME); }
168  { this->SetRepresentation(VTK_SURFACE); }
169  const char *GetRepresentationAsString();
171 
173 
178  virtual void SetColor(double r, double g, double b);
179  virtual void SetColor(double a[3]);
180  double *GetColor();
181  void GetColor(double rgb[3]);
182  void GetColor(double &r, double &g, double &b);
184 
186 
189  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
190  vtkGetMacro(Ambient, double);
192 
194 
197  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
198  vtkGetMacro(Diffuse, double);
200 
202 
205  vtkSetClampMacro(Specular, double, 0.0, 1.0);
206  vtkGetMacro(Specular, double);
208 
210 
213  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
214  vtkGetMacro(SpecularPower, double);
216 
218 
222  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
223  vtkGetMacro(Opacity, double);
225 
227 
233  vtkSetVector3Macro(AmbientColor, double);
234  vtkGetVector3Macro(AmbientColor, double);
236 
238 
241  vtkSetVector3Macro(DiffuseColor, double);
242  vtkGetVector3Macro(DiffuseColor, double);
244 
246 
249  vtkSetVector3Macro(SpecularColor, double);
250  vtkGetVector3Macro(SpecularColor, double);
252 
254 
259  vtkGetMacro(EdgeVisibility, int);
260  vtkSetMacro(EdgeVisibility, int);
261  vtkBooleanMacro(EdgeVisibility, int);
263 
265 
268  vtkSetVector3Macro(EdgeColor, double);
269  vtkGetVector3Macro(EdgeColor, double);
271 
273 
278  vtkGetMacro(VertexVisibility, int);
279  vtkSetMacro(VertexVisibility, int);
280  vtkBooleanMacro(VertexVisibility, int);
282 
284 
287  vtkSetVector3Macro(VertexColor, double);
288  vtkGetVector3Macro(VertexColor, double);
290 
292 
296  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
297  vtkGetMacro(LineWidth, float);
299 
301 
306  vtkSetMacro(LineStipplePattern, int);
307  vtkGetMacro(LineStipplePattern, int);
309 
311 
316  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
317  vtkGetMacro(LineStippleRepeatFactor, int);
319 
321 
325  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
326  vtkGetMacro(PointSize, float);
328 
330 
335  vtkGetMacro(BackfaceCulling, int);
336  vtkSetMacro(BackfaceCulling, int);
337  vtkBooleanMacro(BackfaceCulling, int);
339 
341 
346  vtkGetMacro(FrontfaceCulling, int);
347  vtkSetMacro(FrontfaceCulling, int);
348  vtkBooleanMacro(FrontfaceCulling, int);
350 
352 
355  vtkSetStringMacro(MaterialName);
356  vtkGetStringMacro(MaterialName);
358 
360 
364  vtkSetMacro(Shading, int);
365  vtkGetMacro(Shading, int);
366  vtkBooleanMacro(Shading, int);
368 
373  { return nullptr; }
374 
376 
384  virtual void AddShaderVariable(const char *name, int numVars, int *x);
385  virtual void AddShaderVariable(const char *name, int numVars, float *x);
386  virtual void AddShaderVariable(const char *name, int numVars, double *x);
388 
390 
393  void AddShaderVariable(const char* name, int v)
394  { this->AddShaderVariable(name, 1, &v); }
395  void AddShaderVariable(const char* name, float v)
396  { this->AddShaderVariable(name, 1, &v); }
397  void AddShaderVariable(const char* name, double v)
398  { this->AddShaderVariable(name, 1, &v); }
399  void AddShaderVariable(const char* name, int v1, int v2)
400  {
401  int v[2] = {v1, v2};
402  this->AddShaderVariable(name, 2, v);
403  }
404  void AddShaderVariable(const char* name, float v1, float v2)
405  {
406  float v[2] = {v1, v2};
407  this->AddShaderVariable(name, 2, v);
408  }
409  void AddShaderVariable(const char* name, double v1, double v2)
410  {
411  double v[2] = {v1, v2};
412  this->AddShaderVariable(name, 2, v);
413  }
414  void AddShaderVariable(const char* name, int v1, int v2, int v3)
415  {
416  int v[3] = {v1, v2, v3};
417  this->AddShaderVariable(name, 3, v);
418  }
419  void AddShaderVariable(const char* name, float v1, float v2, float v3)
420  {
421  float v[3] = {v1, v2, v3};
422  this->AddShaderVariable(name, 3, v);
423  }
424  void AddShaderVariable(const char* name, double v1, double v2, double v3)
425  {
426  double v[3] = {v1, v2, v3};
427  this->AddShaderVariable(name, 3, v);
428  }
430 
432 
438  void SetTexture(const char* name, vtkTexture* texture);
439  vtkTexture* GetTexture(const char* name);
441 
443 
449  void SetTexture(int unit, vtkTexture* texture);
450  vtkTexture* GetTexture(int unit);
451  void RemoveTexture(int unit);
453 
458  void RemoveTexture(const char* name);
459 
463  void RemoveAllTextures();
464 
468  int GetNumberOfTextures();
469 
475  virtual void ReleaseGraphicsResources(vtkWindow *win);
476 
482  {
483  VTK_TEXTURE_UNIT_0 = 0,
490  VTK_TEXTURE_UNIT_7
491  };
492 
494 
497  vtkGetObjectMacro(Information, vtkInformation);
498  virtual void SetInformation(vtkInformation*);
500 
501 protected:
502  vtkProperty();
503  ~vtkProperty() override;
504 
508  static void ComputeCompositeColor(double result[3],
509  double ambient, const double ambient_color[3],
510  double diffuse, const double diffuse_color[3],
511  double specular, const double specular_color[3]);
512 
513  double Color[3];
514  double AmbientColor[3];
515  double DiffuseColor[3];
516  double SpecularColor[3];
517  double EdgeColor[3];
518  double VertexColor[3];
519  double Ambient;
520  double Diffuse;
521  double Specular;
523  double Opacity;
524  float PointSize;
525  float LineWidth;
534  bool Lighting;
537 
538  int Shading;
539 
541 
542  // FIXME:
543  // Don't use these methods. They will be removed. They are provided only
544  // for the time-being.
545  vtkTexture* GetTextureAtIndex(int index);
546  int GetTextureUnitAtIndex(int index);
547  int GetTextureUnit(const char* name);
548 
549  // Arbitrary extra information associated with this Property.
551 
552 private:
553  vtkProperty(const vtkProperty&) = delete;
554  void operator=(const vtkProperty&) = delete;
555 
556  vtkPropertyInternals* Internals;
557 };
558 
560 
564 {
565  if (this->Interpolation == VTK_FLAT)
566  {
567  return "Flat";
568  }
569  else if (this->Interpolation == VTK_GOURAUD)
570  {
571  return "Gouraud";
572  }
573  else
574  {
575  return "Phong";
576  }
577 }
579 
581 
585 {
586  if (this->Representation == VTK_POINTS)
587  {
588  return "Points";
589  }
590  else if (this->Representation == VTK_WIREFRAME)
591  {
592  return "Wireframe";
593  }
594  else
595  {
596  return "Surface";
597  }
598 }
600 
601 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:419
double Opacity
Definition: vtkProperty.h:523
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:152
abstract base class for most VTK objects
Definition: vtkObject.h:59
float PointSize
Definition: vtkProperty.h:524
VTKTextureUnit
Used to specify which texture unit a texture will use.
Definition: vtkProperty.h:481
bool RenderLinesAsTubes
Definition: vtkProperty.h:536
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:397
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:526
Store vtkAlgorithm input/output information.
float LineWidth
Definition: vtkProperty.h:525
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:424
represent surface properties of a geometric object
Definition: vtkProperty.h:65
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:584
#define VTK_SURFACE
Definition: vtkProperty.h:51
#define VTK_INT_MAX
Definition: vtkType.h:157
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:148
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:414
double Ambient
Definition: vtkProperty.h:519
double SpecularPower
Definition: vtkProperty.h:522
char * MaterialName
Definition: vtkProperty.h:540
int FrontfaceCulling
Definition: vtkProperty.h:533
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:395
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:409
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:163
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:150
int VertexVisibility
Definition: vtkProperty.h:531
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double Diffuse
Definition: vtkProperty.h:520
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
int EdgeVisibility
Definition: vtkProperty.h:530
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:404
a simple class to control print indentation
Definition: vtkIndent.h:39
int BackfaceCulling
Definition: vtkProperty.h:532
#define VTK_FLAT
Definition: vtkProperty.h:44
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:165
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Get the vtkShaderDeviceAdapter2 if set, returns null otherwise.
Definition: vtkProperty.h:372
int Interpolation
Definition: vtkProperty.h:528
handles properties associated with a texture map
Definition: vtkTexture.h:71
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int Representation
Definition: vtkProperty.h:529
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:167
#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:393
#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:99
int LineStippleRepeatFactor
Definition: vtkProperty.h:527
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:563
bool RenderPointsAsSpheres
Definition: vtkProperty.h:535
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:399
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...
vtkInformation * Information
Definition: vtkProperty.h:550
double Specular
Definition: vtkProperty.h:521
#define VTK_WIREFRAME
Definition: vtkProperty.h:50
The ShaderProgram uses one or more Shader objects.