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 #include <map> // used for ivar
43 
44 // shading models
45 #define VTK_FLAT 0
46 #define VTK_GOURAUD 1
47 #define VTK_PHONG 2
48 
49 // representation models
50 #define VTK_POINTS 0
51 #define VTK_WIREFRAME 1
52 #define VTK_SURFACE 2
53 
54 class vtkActor;
55 class vtkInformation;
56 class vtkRenderer;
57 class vtkShaderProgram;
59 class vtkTexture;
60 class vtkWindow;
61 class vtkXMLDataElement;
62 class vtkXMLMaterial;
63 
64 class vtkPropertyInternals;
65 
66 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
67 {
68 public:
69  vtkTypeMacro(vtkProperty,vtkObject);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
78  static vtkProperty *New();
79 
83  void DeepCopy(vtkProperty *p);
84 
92  virtual void Render(vtkActor *, vtkRenderer *);
93 
100  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
101 
107  virtual void PostRender(vtkActor*, vtkRenderer*);
108 
110 
113  vtkGetMacro(Lighting, bool);
114  vtkSetMacro(Lighting, bool);
115  vtkBooleanMacro(Lighting, bool);
117 
119 
125  vtkGetMacro(RenderPointsAsSpheres, bool);
126  vtkSetMacro(RenderPointsAsSpheres, bool);
127  vtkBooleanMacro(RenderPointsAsSpheres, bool);
129 
131 
138  vtkGetMacro(RenderLinesAsTubes, bool);
139  vtkSetMacro(RenderLinesAsTubes, bool);
140  vtkBooleanMacro(RenderLinesAsTubes, bool);
142 
144 
147  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
148  vtkGetMacro(Interpolation,int);
150  { this->SetInterpolation(VTK_FLAT); }
152  { this->SetInterpolation(VTK_GOURAUD); }
154  { this->SetInterpolation(VTK_PHONG); }
155  const char *GetInterpolationAsString();
157 
159 
162  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
163  vtkGetMacro(Representation,int);
165  { this->SetRepresentation(VTK_POINTS); }
167  { this->SetRepresentation(VTK_WIREFRAME); }
169  { this->SetRepresentation(VTK_SURFACE); }
170  const char *GetRepresentationAsString();
172 
174 
179  virtual void SetColor(double r, double g, double b);
180  virtual void SetColor(double a[3]);
181  double *GetColor() VTK_SIZEHINT(3);
182  void GetColor(double rgb[3]);
183  void GetColor(double &r, double &g, double &b);
185 
187 
190  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
191  vtkGetMacro(Ambient, double);
193 
195 
198  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
199  vtkGetMacro(Diffuse, double);
201 
203 
206  vtkSetClampMacro(Specular, double, 0.0, 1.0);
207  vtkGetMacro(Specular, double);
209 
211 
214  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
215  vtkGetMacro(SpecularPower, double);
217 
219 
223  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
224  vtkGetMacro(Opacity, double);
226 
228 
234  vtkSetVector3Macro(AmbientColor, double);
235  vtkGetVector3Macro(AmbientColor, double);
237 
239 
242  vtkSetVector3Macro(DiffuseColor, double);
243  vtkGetVector3Macro(DiffuseColor, double);
245 
247 
250  vtkSetVector3Macro(SpecularColor, double);
251  vtkGetVector3Macro(SpecularColor, double);
253 
255 
260  vtkGetMacro(EdgeVisibility, vtkTypeBool);
261  vtkSetMacro(EdgeVisibility, vtkTypeBool);
262  vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
264 
266 
269  vtkSetVector3Macro(EdgeColor, double);
270  vtkGetVector3Macro(EdgeColor, double);
272 
274 
279  vtkGetMacro(VertexVisibility, vtkTypeBool);
280  vtkSetMacro(VertexVisibility, vtkTypeBool);
281  vtkBooleanMacro(VertexVisibility, vtkTypeBool);
283 
285 
288  vtkSetVector3Macro(VertexColor, double);
289  vtkGetVector3Macro(VertexColor, double);
291 
293 
297  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
298  vtkGetMacro(LineWidth, float);
300 
302 
307  vtkSetMacro(LineStipplePattern, int);
308  vtkGetMacro(LineStipplePattern, int);
310 
312 
317  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
318  vtkGetMacro(LineStippleRepeatFactor, int);
320 
322 
326  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
327  vtkGetMacro(PointSize, float);
329 
331 
336  vtkGetMacro(BackfaceCulling, vtkTypeBool);
337  vtkSetMacro(BackfaceCulling, vtkTypeBool);
338  vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
340 
342 
347  vtkGetMacro(FrontfaceCulling, vtkTypeBool);
348  vtkSetMacro(FrontfaceCulling, vtkTypeBool);
349  vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
351 
353 
356  vtkSetStringMacro(MaterialName);
357  vtkGetStringMacro(MaterialName);
359 
361 
365  vtkSetMacro(Shading, vtkTypeBool);
366  vtkGetMacro(Shading, vtkTypeBool);
367  vtkBooleanMacro(Shading, vtkTypeBool);
369 
374  { return nullptr; }
375 
377 
385  virtual void AddShaderVariable(const char *name, int numVars, int *x);
386  virtual void AddShaderVariable(const char *name, int numVars, float *x);
387  virtual void AddShaderVariable(const char *name, int numVars, double *x);
389 
391 
394  void AddShaderVariable(const char* name, int v)
395  { this->AddShaderVariable(name, 1, &v); }
396  void AddShaderVariable(const char* name, float v)
397  { this->AddShaderVariable(name, 1, &v); }
398  void AddShaderVariable(const char* name, double v)
399  { this->AddShaderVariable(name, 1, &v); }
400  void AddShaderVariable(const char* name, int v1, int v2)
401  {
402  int v[2] = {v1, v2};
403  this->AddShaderVariable(name, 2, v);
404  }
405  void AddShaderVariable(const char* name, float v1, float v2)
406  {
407  float v[2] = {v1, v2};
408  this->AddShaderVariable(name, 2, v);
409  }
410  void AddShaderVariable(const char* name, double v1, double v2)
411  {
412  double v[2] = {v1, v2};
413  this->AddShaderVariable(name, 2, v);
414  }
415  void AddShaderVariable(const char* name, int v1, int v2, int v3)
416  {
417  int v[3] = {v1, v2, v3};
418  this->AddShaderVariable(name, 3, v);
419  }
420  void AddShaderVariable(const char* name, float v1, float v2, float v3)
421  {
422  float v[3] = {v1, v2, v3};
423  this->AddShaderVariable(name, 3, v);
424  }
425  void AddShaderVariable(const char* name, double v1, double v2, double v3)
426  {
427  double v[3] = {v1, v2, v3};
428  this->AddShaderVariable(name, 3, v);
429  }
431 
433 
441  void SetTexture(const char* name, vtkTexture* texture);
442  vtkTexture* GetTexture(const char* name);
444 
446 
452  VTK_LEGACY(void SetTexture(int unit, vtkTexture* texture));
453  VTK_LEGACY(vtkTexture* GetTexture(int unit));
454  VTK_LEGACY(void RemoveTexture(int unit));
456 
460  void RemoveTexture(const char* name);
461 
465  void RemoveAllTextures();
466 
470  int GetNumberOfTextures();
471 
475  std::map<std::string, vtkTexture *> &GetAllTextures() {
476  return this->Textures; }
477 
483  virtual void ReleaseGraphicsResources(vtkWindow *win);
484 
485 
486 #ifndef VTK_LEGACY_REMOVE
487  // deprecated. Textures should use names not units
489  {
490  VTK_TEXTURE_UNIT_0 = 0,
497  VTK_TEXTURE_UNIT_7
498  };
499 #endif
500 
502 
505  vtkGetObjectMacro(Information, vtkInformation);
506  virtual void SetInformation(vtkInformation*);
508 
509 protected:
510  vtkProperty();
511  ~vtkProperty() override;
512 
516  static void ComputeCompositeColor(double result[3],
517  double ambient, const double ambient_color[3],
518  double diffuse, const double diffuse_color[3],
519  double specular, const double specular_color[3]);
520 
521  double Color[3];
522  double AmbientColor[3];
523  double DiffuseColor[3];
524  double SpecularColor[3];
525  double EdgeColor[3];
526  double VertexColor[3];
527  double Ambient;
528  double Diffuse;
529  double Specular;
531  double Opacity;
532  float PointSize;
533  float LineWidth;
542  bool Lighting;
545 
547 
549 
550  typedef std::map<std::string, vtkTexture*> MapOfTextures;
551  MapOfTextures Textures;
552 
553  // Arbitrary extra information associated with this Property.
555 
556 private:
557  vtkProperty(const vtkProperty&) = delete;
558  void operator=(const vtkProperty&) = delete;
559 };
560 
562 
566 {
567  if (this->Interpolation == VTK_FLAT)
568  {
569  return "Flat";
570  }
571  else if (this->Interpolation == VTK_GOURAUD)
572  {
573  return "Gouraud";
574  }
575  else
576  {
577  return "Phong";
578  }
579 }
581 
583 
587 {
588  if (this->Representation == VTK_POINTS)
589  {
590  return "Points";
591  }
592  else if (this->Representation == VTK_WIREFRAME)
593  {
594  return "Wireframe";
595  }
596  else
597  {
598  return "Surface";
599  }
600 }
602 
603 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:420
double Opacity
Definition: vtkProperty.h:531
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:153
abstract base class for most VTK objects
Definition: vtkObject.h:59
float PointSize
Definition: vtkProperty.h:532
bool RenderLinesAsTubes
Definition: vtkProperty.h:544
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:398
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:534
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:538
Store vtkAlgorithm input/output information.
float LineWidth
Definition: vtkProperty.h:533
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:425
represent surface properties of a geometric object
Definition: vtkProperty.h:66
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:586
#define VTK_SURFACE
Definition: vtkProperty.h:52
#define VTK_INT_MAX
Definition: vtkType.h:159
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:149
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:415
double Ambient
Definition: vtkProperty.h:527
double SpecularPower
Definition: vtkProperty.h:530
char * MaterialName
Definition: vtkProperty.h:548
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:396
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 wrappers.
Definition: vtkProperty.h:410
std::map< std::string, vtkTexture * > MapOfTextures
Definition: vtkProperty.h:550
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:164
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:151
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double Diffuse
Definition: vtkProperty.h:528
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:405
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_FLAT
Definition: vtkProperty.h:45
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:166
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Get the vtkShaderDeviceAdapter2 if set, returns null otherwise.
Definition: vtkProperty.h:373
int Interpolation
Definition: vtkProperty.h:536
handles properties associated with a texture map
Definition: vtkTexture.h:71
int Representation
Definition: vtkProperty.h:537
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:168
#define VTK_SIZEHINT(...)
#define VTK_POINTS
Definition: vtkProperty.h:50
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:394
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
Definition: vtkProperty.h:475
#define VTK_GOURAUD
Definition: vtkProperty.h:46
vtkTypeBool Shading
Definition: vtkProperty.h:546
#define VTK_PHONG
Definition: vtkProperty.h:47
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:100
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:541
int LineStippleRepeatFactor
Definition: vtkProperty.h:535
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:565
bool RenderPointsAsSpheres
Definition: vtkProperty.h:543
MapOfTextures Textures
Definition: vtkProperty.h:551
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:539
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:400
an adapter to pass generic vertex attributes to the rendering pipeline.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkInformation * Information
Definition: vtkProperty.h:554
double Specular
Definition: vtkProperty.h:529
#define VTK_WIREFRAME
Definition: vtkProperty.h:51
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:540
The ShaderProgram uses one or more Shader objects.