VTK  9.0.1
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 "vtkObject.h"
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include <map> // used for ivar
37 #include <string> // used for ivar
38 
39 // shading models
40 #define VTK_FLAT 0
41 #define VTK_GOURAUD 1
42 #define VTK_PHONG 2
43 #define VTK_PBR 3
44 
45 // representation models
46 #define VTK_POINTS 0
47 #define VTK_WIREFRAME 1
48 #define VTK_SURFACE 2
49 
50 class vtkActor;
51 class vtkInformation;
52 class vtkRenderer;
53 class vtkShaderProgram;
54 class vtkTexture;
55 class vtkWindow;
56 class vtkXMLDataElement;
57 class vtkXMLMaterial;
58 
59 class vtkPropertyInternals;
60 
61 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
62 {
63 public:
64  vtkTypeMacro(vtkProperty, vtkObject);
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
73  static vtkProperty* New();
74 
78  void DeepCopy(vtkProperty* p);
79 
87  virtual void Render(vtkActor*, vtkRenderer*);
88 
95  virtual void BackfaceRender(vtkActor*, vtkRenderer*) {}
96 
102  virtual void PostRender(vtkActor*, vtkRenderer*);
103 
105 
108  vtkGetMacro(Lighting, bool);
109  vtkSetMacro(Lighting, bool);
110  vtkBooleanMacro(Lighting, bool);
112 
114 
120  vtkGetMacro(RenderPointsAsSpheres, bool);
121  vtkSetMacro(RenderPointsAsSpheres, bool);
122  vtkBooleanMacro(RenderPointsAsSpheres, bool);
124 
126 
133  vtkGetMacro(RenderLinesAsTubes, bool);
134  vtkSetMacro(RenderLinesAsTubes, bool);
135  vtkBooleanMacro(RenderLinesAsTubes, bool);
137 
139 
142  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
143  vtkGetMacro(Interpolation, int);
144  void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
145  void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
146  void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
147  void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
148  const char* GetInterpolationAsString();
150 
152 
155  vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
156  vtkGetMacro(Representation, int);
157  void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
158  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
159  void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
160  const char* GetRepresentationAsString();
162 
164 
169  virtual void SetColor(double r, double g, double b);
170  virtual void SetColor(double a[3]);
171  double* GetColor() VTK_SIZEHINT(3);
172  void GetColor(double rgb[3]);
173  void GetColor(double& r, double& g, double& b);
175 
177 
183  vtkSetClampMacro(Metallic, double, 0.0, 1.0);
184  vtkGetMacro(Metallic, double);
186 
188 
195  vtkSetClampMacro(Roughness, double, 0.0, 1.0);
196  vtkGetMacro(Roughness, double);
198 
200 
205  vtkSetMacro(NormalScale, double);
206  vtkGetMacro(NormalScale, double);
208 
210 
216  vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
217  vtkGetMacro(OcclusionStrength, double);
219 
221 
227  vtkSetVector3Macro(EmissiveFactor, double);
228  vtkGetVector3Macro(EmissiveFactor, double);
230 
232 
235  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
236  vtkGetMacro(Ambient, double);
238 
240 
243  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
244  vtkGetMacro(Diffuse, double);
246 
248 
251  vtkSetClampMacro(Specular, double, 0.0, 1.0);
252  vtkGetMacro(Specular, double);
254 
256 
259  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
260  vtkGetMacro(SpecularPower, double);
262 
264 
268  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
269  vtkGetMacro(Opacity, double);
271 
273 
279  vtkSetVector3Macro(AmbientColor, double);
280  vtkGetVector3Macro(AmbientColor, double);
282 
284 
288  vtkSetVector3Macro(DiffuseColor, double);
289  vtkGetVector3Macro(DiffuseColor, double);
291 
293 
296  vtkSetVector3Macro(SpecularColor, double);
297  vtkGetVector3Macro(SpecularColor, double);
299 
301 
306  vtkGetMacro(EdgeVisibility, vtkTypeBool);
307  vtkSetMacro(EdgeVisibility, vtkTypeBool);
308  vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
310 
312 
315  vtkSetVector3Macro(EdgeColor, double);
316  vtkGetVector3Macro(EdgeColor, double);
318 
320 
325  vtkGetMacro(VertexVisibility, vtkTypeBool);
326  vtkSetMacro(VertexVisibility, vtkTypeBool);
327  vtkBooleanMacro(VertexVisibility, vtkTypeBool);
329 
331 
334  vtkSetVector3Macro(VertexColor, double);
335  vtkGetVector3Macro(VertexColor, double);
337 
339 
343  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
344  vtkGetMacro(LineWidth, float);
346 
348 
353  vtkSetMacro(LineStipplePattern, int);
354  vtkGetMacro(LineStipplePattern, int);
356 
358 
363  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
364  vtkGetMacro(LineStippleRepeatFactor, int);
366 
368 
372  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
373  vtkGetMacro(PointSize, float);
375 
377 
382  vtkGetMacro(BackfaceCulling, vtkTypeBool);
383  vtkSetMacro(BackfaceCulling, vtkTypeBool);
384  vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
386 
388 
393  vtkGetMacro(FrontfaceCulling, vtkTypeBool);
394  vtkSetMacro(FrontfaceCulling, vtkTypeBool);
395  vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
397 
399 
402  vtkSetStringMacro(MaterialName);
403  vtkGetStringMacro(MaterialName);
405 
407 
411  vtkSetMacro(Shading, vtkTypeBool);
412  vtkGetMacro(Shading, vtkTypeBool);
413  vtkBooleanMacro(Shading, vtkTypeBool);
415 
417 
425  virtual void AddShaderVariable(const char* name, int numVars, int* x);
426  virtual void AddShaderVariable(const char* name, int numVars, float* x);
427  virtual void AddShaderVariable(const char* name, int numVars, double* x);
429 
431 
434  void AddShaderVariable(const char* name, int v) { this->AddShaderVariable(name, 1, &v); }
435  void AddShaderVariable(const char* name, float v) { this->AddShaderVariable(name, 1, &v); }
436  void AddShaderVariable(const char* name, double v) { this->AddShaderVariable(name, 1, &v); }
437  void AddShaderVariable(const char* name, int v1, int v2)
438  {
439  int v[2] = { v1, v2 };
440  this->AddShaderVariable(name, 2, v);
441  }
442  void AddShaderVariable(const char* name, float v1, float v2)
443  {
444  float v[2] = { v1, v2 };
445  this->AddShaderVariable(name, 2, v);
446  }
447  void AddShaderVariable(const char* name, double v1, double v2)
448  {
449  double v[2] = { v1, v2 };
450  this->AddShaderVariable(name, 2, v);
451  }
452  void AddShaderVariable(const char* name, int v1, int v2, int v3)
453  {
454  int v[3] = { v1, v2, v3 };
455  this->AddShaderVariable(name, 3, v);
456  }
457  void AddShaderVariable(const char* name, float v1, float v2, float v3)
458  {
459  float v[3] = { v1, v2, v3 };
460  this->AddShaderVariable(name, 3, v);
461  }
462  void AddShaderVariable(const char* name, double v1, double v2, double v3)
463  {
464  double v[3] = { v1, v2, v3 };
465  this->AddShaderVariable(name, 3, v);
466  }
468 
470 
482  void SetTexture(const char* name, vtkTexture* texture);
483  vtkTexture* GetTexture(const char* name);
485 
492  void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
493 
503  void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
504 
513  void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
514 
522  void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
523 
527  void RemoveTexture(const char* name);
528 
532  void RemoveAllTextures();
533 
537  int GetNumberOfTextures();
538 
542  std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
543 
549  virtual void ReleaseGraphicsResources(vtkWindow* win);
550 
552 
555  vtkGetObjectMacro(Information, vtkInformation);
556  virtual void SetInformation(vtkInformation*);
558 
559 protected:
560  vtkProperty();
561  ~vtkProperty() override;
562 
566  static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
567  double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
568 
569  double Color[3];
570  double AmbientColor[3];
571  double DiffuseColor[3];
572  double SpecularColor[3];
573  double EdgeColor[3];
574  double VertexColor[3];
575  double Ambient;
576  double Diffuse;
577  double Metallic;
578  double Roughness;
579  double NormalScale;
581  double EmissiveFactor[3];
582  double Specular;
584  double Opacity;
585  float PointSize;
586  float LineWidth;
595  bool Lighting;
598 
600 
602 
603  typedef std::map<std::string, vtkTexture*> MapOfTextures;
605 
606  // Arbitrary extra information associated with this Property.
608 
609 private:
610  vtkProperty(const vtkProperty&) = delete;
611  void operator=(const vtkProperty&) = delete;
612 };
613 
615 
619 {
620  if (this->Interpolation == VTK_FLAT)
621  {
622  return "Flat";
623  }
624  else if (this->Interpolation == VTK_GOURAUD)
625  {
626  return "Gouraud";
627  }
628  else if (this->Interpolation == VTK_PHONG)
629  {
630  return "Phong";
631  }
632  else // if (this->Interpolation == VTK_PBR)
633  {
634  return "Physically based rendering";
635  }
636 }
638 
640 
644 {
645  if (this->Representation == VTK_POINTS)
646  {
647  return "Points";
648  }
649  else if (this->Representation == VTK_WIREFRAME)
650  {
651  return "Wireframe";
652  }
653  else
654  {
655  return "Surface";
656  }
657 }
659 
660 #endif
vtkProperty::SetInterpolationToPhong
void SetInterpolationToPhong()
Definition: vtkProperty.h:146
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkProperty::SetInterpolationToPBR
void SetInterpolationToPBR()
Definition: vtkProperty.h:147
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, double v)
Definition: vtkProperty.h:436
vtkProperty::EdgeVisibility
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:591
vtkProperty::GetRepresentationAsString
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:643
vtkProperty::RenderLinesAsTubes
bool RenderLinesAsTubes
Definition: vtkProperty.h:597
vtkProperty::SetInterpolationToFlat
void SetInterpolationToFlat()
Definition: vtkProperty.h:144
vtkProperty::Opacity
double Opacity
Definition: vtkProperty.h:584
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Definition: vtkProperty.h:452
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkProperty::SpecularPower
double SpecularPower
Definition: vtkProperty.h:583
vtkProperty::LineWidth
float LineWidth
Definition: vtkProperty.h:586
vtkX3D::Color
@ Color
Definition: vtkX3D.h:52
vtkProperty::SetRepresentationToPoints
void SetRepresentationToPoints()
Definition: vtkProperty.h:157
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkProperty::Lighting
bool Lighting
Definition: vtkProperty.h:595
vtkProperty::Metallic
double Metallic
Definition: vtkProperty.h:577
vtkProperty::MaterialName
char * MaterialName
Definition: vtkProperty.h:601
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Definition: vtkProperty.h:462
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, float v1, float v2)
Definition: vtkProperty.h:442
VTK_WIREFRAME
#define VTK_WIREFRAME
Definition: vtkProperty.h:47
vtkProperty::Roughness
double Roughness
Definition: vtkProperty.h:578
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkProperty::Ambient
double Ambient
Definition: vtkProperty.h:575
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, double v1, double v2)
Definition: vtkProperty.h:447
vtkProperty::MapOfTextures
std::map< std::string, vtkTexture * > MapOfTextures
Definition: vtkProperty.h:603
vtkProperty::SetEmissiveTexture
void SetEmissiveTexture(vtkTexture *texture)
Set the emissive texture.
Definition: vtkProperty.h:522
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, float v)
Definition: vtkProperty.h:435
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:65
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkProperty::Diffuse
double Diffuse
Definition: vtkProperty.h:576
vtkProperty::SetNormalTexture
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
Definition: vtkProperty.h:513
VTK_FLAT
#define VTK_FLAT
Definition: vtkProperty.h:40
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkProperty::SetBaseColorTexture
void SetBaseColorTexture(vtkTexture *texture)
Set the base color texture.
Definition: vtkProperty.h:492
vtkProperty::Interpolation
int Interpolation
Definition: vtkProperty.h:589
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkProperty::SetInterpolationToGouraud
void SetInterpolationToGouraud()
Definition: vtkProperty.h:145
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
VTK_PHONG
#define VTK_PHONG
Definition: vtkProperty.h:42
VTK_SURFACE
#define VTK_SURFACE
Definition: vtkProperty.h:48
vtkProperty::LineStippleRepeatFactor
int LineStippleRepeatFactor
Definition: vtkProperty.h:588
vtkProperty::GetAllTextures
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
Definition: vtkProperty.h:542
vtkProperty::GetInterpolationAsString
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:618
VTK_PBR
#define VTK_PBR
Definition: vtkProperty.h:43
vtkProperty::RenderPointsAsSpheres
bool RenderPointsAsSpheres
Definition: vtkProperty.h:596
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:434
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkXMLDataElement
Represents an XML element and those nested inside.
Definition: vtkXMLDataElement.h:36
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkProperty::Textures
MapOfTextures Textures
Definition: vtkProperty.h:604
VTK_GOURAUD
#define VTK_GOURAUD
Definition: vtkProperty.h:41
vtkProperty::VertexVisibility
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:592
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, int v1, int v2)
Definition: vtkProperty.h:437
vtkProperty::BackfaceRender
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:95
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkProperty::FrontfaceCulling
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:594
vtkObject.h
vtkProperty::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkProperty.h:159
vtkProperty::OcclusionStrength
double OcclusionStrength
Definition: vtkProperty.h:580
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkProperty::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkProperty.h:158
vtkProperty::NormalScale
double NormalScale
Definition: vtkProperty.h:579
vtkProperty::Shading
vtkTypeBool Shading
Definition: vtkProperty.h:599
vtkProperty::Information
vtkInformation * Information
Definition: vtkProperty.h:607
vtkProperty::Representation
int Representation
Definition: vtkProperty.h:590
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
VTK_POINTS
#define VTK_POINTS
Definition: vtkProperty.h:46
vtkProperty::BackfaceCulling
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:593
vtkProperty::AddShaderVariable
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Definition: vtkProperty.h:457
vtkProperty::SetORMTexture
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
Definition: vtkProperty.h:503
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkProperty::Specular
double Specular
Definition: vtkProperty.h:582
vtkProperty::PointSize
float PointSize
Definition: vtkProperty.h:585
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkProperty::LineStipplePattern
int LineStipplePattern
Definition: vtkProperty.h:587