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 =========================================================================*/
31 #ifndef vtkProperty_h
32 #define vtkProperty_h
33 
34 #include "vtkRenderingCoreModule.h" // For export macro
35 #include "vtkObject.h"
36 #include <map> // used for ivar
37 
38 // shading models
39 #define VTK_FLAT 0
40 #define VTK_GOURAUD 1
41 #define VTK_PHONG 2
42 
43 // representation models
44 #define VTK_POINTS 0
45 #define VTK_WIREFRAME 1
46 #define VTK_SURFACE 2
47 
48 class vtkActor;
49 class vtkInformation;
50 class vtkRenderer;
51 class vtkShaderProgram;
53 class vtkTexture;
54 class vtkWindow;
55 class vtkXMLDataElement;
56 class vtkXMLMaterial;
57 
58 class vtkPropertyInternals;
59 
60 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
61 {
62 public:
63  vtkTypeMacro(vtkProperty,vtkObject);
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
72  static vtkProperty *New();
73 
77  void DeepCopy(vtkProperty *p);
78 
86  virtual void Render(vtkActor *, vtkRenderer *);
87 
94  virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
95 
101  virtual void PostRender(vtkActor*, vtkRenderer*);
102 
104 
107  vtkGetMacro(Lighting, bool);
108  vtkSetMacro(Lighting, bool);
109  vtkBooleanMacro(Lighting, bool);
111 
113 
119  vtkGetMacro(RenderPointsAsSpheres, bool);
120  vtkSetMacro(RenderPointsAsSpheres, bool);
121  vtkBooleanMacro(RenderPointsAsSpheres, bool);
123 
125 
132  vtkGetMacro(RenderLinesAsTubes, bool);
133  vtkSetMacro(RenderLinesAsTubes, bool);
134  vtkBooleanMacro(RenderLinesAsTubes, bool);
136 
138 
141  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
142  vtkGetMacro(Interpolation,int);
144  { this->SetInterpolation(VTK_FLAT); }
146  { this->SetInterpolation(VTK_GOURAUD); }
148  { this->SetInterpolation(VTK_PHONG); }
149  const char *GetInterpolationAsString();
151 
153 
156  vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
157  vtkGetMacro(Representation,int);
159  { this->SetRepresentation(VTK_POINTS); }
161  { this->SetRepresentation(VTK_WIREFRAME); }
163  { this->SetRepresentation(VTK_SURFACE); }
164  const char *GetRepresentationAsString();
166 
168 
173  virtual void SetColor(double r, double g, double b);
174  virtual void SetColor(double a[3]);
175  double *GetColor() VTK_SIZEHINT(3);
176  void GetColor(double rgb[3]);
177  void GetColor(double &r, double &g, double &b);
179 
181 
184  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
185  vtkGetMacro(Ambient, double);
187 
189 
192  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
193  vtkGetMacro(Diffuse, double);
195 
197 
200  vtkSetClampMacro(Specular, double, 0.0, 1.0);
201  vtkGetMacro(Specular, double);
203 
205 
208  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
209  vtkGetMacro(SpecularPower, double);
211 
213 
217  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
218  vtkGetMacro(Opacity, double);
220 
222 
228  vtkSetVector3Macro(AmbientColor, double);
229  vtkGetVector3Macro(AmbientColor, double);
231 
233 
236  vtkSetVector3Macro(DiffuseColor, double);
237  vtkGetVector3Macro(DiffuseColor, double);
239 
241 
244  vtkSetVector3Macro(SpecularColor, double);
245  vtkGetVector3Macro(SpecularColor, double);
247 
249 
254  vtkGetMacro(EdgeVisibility, vtkTypeBool);
255  vtkSetMacro(EdgeVisibility, vtkTypeBool);
256  vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
258 
260 
263  vtkSetVector3Macro(EdgeColor, double);
264  vtkGetVector3Macro(EdgeColor, double);
266 
268 
273  vtkGetMacro(VertexVisibility, vtkTypeBool);
274  vtkSetMacro(VertexVisibility, vtkTypeBool);
275  vtkBooleanMacro(VertexVisibility, vtkTypeBool);
277 
279 
282  vtkSetVector3Macro(VertexColor, double);
283  vtkGetVector3Macro(VertexColor, double);
285 
287 
291  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
292  vtkGetMacro(LineWidth, float);
294 
296 
301  vtkSetMacro(LineStipplePattern, int);
302  vtkGetMacro(LineStipplePattern, int);
304 
306 
311  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
312  vtkGetMacro(LineStippleRepeatFactor, int);
314 
316 
320  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
321  vtkGetMacro(PointSize, float);
323 
325 
330  vtkGetMacro(BackfaceCulling, vtkTypeBool);
331  vtkSetMacro(BackfaceCulling, vtkTypeBool);
332  vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
334 
336 
341  vtkGetMacro(FrontfaceCulling, vtkTypeBool);
342  vtkSetMacro(FrontfaceCulling, vtkTypeBool);
343  vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
345 
347 
350  vtkSetStringMacro(MaterialName);
351  vtkGetStringMacro(MaterialName);
353 
355 
359  vtkSetMacro(Shading, vtkTypeBool);
360  vtkGetMacro(Shading, vtkTypeBool);
361  vtkBooleanMacro(Shading, vtkTypeBool);
363 
367  virtual vtkShaderDeviceAdapter2* GetShaderDeviceAdapter2()
368  { return nullptr; }
369 
371 
379  virtual void AddShaderVariable(const char *name, int numVars, int *x);
380  virtual void AddShaderVariable(const char *name, int numVars, float *x);
381  virtual void AddShaderVariable(const char *name, int numVars, double *x);
383 
385 
388  void AddShaderVariable(const char* name, int v)
389  { this->AddShaderVariable(name, 1, &v); }
390  void AddShaderVariable(const char* name, float v)
391  { this->AddShaderVariable(name, 1, &v); }
392  void AddShaderVariable(const char* name, double v)
393  { this->AddShaderVariable(name, 1, &v); }
394  void AddShaderVariable(const char* name, int v1, int v2)
395  {
396  int v[2] = {v1, v2};
397  this->AddShaderVariable(name, 2, v);
398  }
399  void AddShaderVariable(const char* name, float v1, float v2)
400  {
401  float v[2] = {v1, v2};
402  this->AddShaderVariable(name, 2, v);
403  }
404  void AddShaderVariable(const char* name, double v1, double v2)
405  {
406  double v[2] = {v1, v2};
407  this->AddShaderVariable(name, 2, v);
408  }
409  void AddShaderVariable(const char* name, int v1, int v2, int v3)
410  {
411  int v[3] = {v1, v2, v3};
412  this->AddShaderVariable(name, 3, v);
413  }
414  void AddShaderVariable(const char* name, float v1, float v2, float v3)
415  {
416  float v[3] = {v1, v2, v3};
417  this->AddShaderVariable(name, 3, v);
418  }
419  void AddShaderVariable(const char* name, double v1, double v2, double v3)
420  {
421  double v[3] = {v1, v2, v3};
422  this->AddShaderVariable(name, 3, v);
423  }
425 
427 
435  void SetTexture(const char* name, vtkTexture* texture);
436  vtkTexture* GetTexture(const char* name);
438 
440 
446  VTK_LEGACY(void SetTexture(int unit, vtkTexture* texture));
447  VTK_LEGACY(vtkTexture* GetTexture(int unit));
448  VTK_LEGACY(void RemoveTexture(int unit));
450 
454  void RemoveTexture(const char* name);
455 
459  void RemoveAllTextures();
460 
464  int GetNumberOfTextures();
465 
469  std::map<std::string, vtkTexture *> &GetAllTextures() {
470  return this->Textures; }
471 
477  virtual void ReleaseGraphicsResources(vtkWindow *win);
478 
479 
480 #ifndef VTK_LEGACY_REMOVE
481  // deprecated. Textures should use names not units
483  {
484  VTK_TEXTURE_UNIT_0 = 0,
491  VTK_TEXTURE_UNIT_7
492  };
493 #endif
494 
496 
499  vtkGetObjectMacro(Information, vtkInformation);
500  virtual void SetInformation(vtkInformation*);
502 
503 protected:
504  vtkProperty();
505  ~vtkProperty() override;
506 
510  static void ComputeCompositeColor(double result[3],
511  double ambient, const double ambient_color[3],
512  double diffuse, const double diffuse_color[3],
513  double specular, const double specular_color[3]);
514 
515  double Color[3];
516  double AmbientColor[3];
517  double DiffuseColor[3];
518  double SpecularColor[3];
519  double EdgeColor[3];
520  double VertexColor[3];
521  double Ambient;
522  double Diffuse;
523  double Specular;
525  double Opacity;
526  float PointSize;
527  float LineWidth;
536  bool Lighting;
539 
541 
543 
544  typedef std::map<std::string, vtkTexture*> MapOfTextures;
546 
547  // Arbitrary extra information associated with this Property.
549 
550 private:
551  vtkProperty(const vtkProperty&) = delete;
552  void operator=(const vtkProperty&) = delete;
553 
554  vtkPropertyInternals* Internals;
555 };
556 
558 
562 {
563  if (this->Interpolation == VTK_FLAT)
564  {
565  return "Flat";
566  }
567  else if (this->Interpolation == VTK_GOURAUD)
568  {
569  return "Gouraud";
570  }
571  else
572  {
573  return "Phong";
574  }
575 }
577 
579 
583 {
584  if (this->Representation == VTK_POINTS)
585  {
586  return "Points";
587  }
588  else if (this->Representation == VTK_WIREFRAME)
589  {
590  return "Wireframe";
591  }
592  else
593  {
594  return "Surface";
595  }
596 }
598 
599 #endif
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:414
double Opacity
Definition: vtkProperty.h:525
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:147
abstract base class for most VTK objects
Definition: vtkObject.h:53
float PointSize
Definition: vtkProperty.h:526
bool RenderLinesAsTubes
Definition: vtkProperty.h:538
void AddShaderVariable(const char *name, double v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:392
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:528
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:532
Store vtkAlgorithm input/output information.
float LineWidth
Definition: vtkProperty.h:527
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:419
represent surface properties of a geometric object
Definition: vtkProperty.h:60
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:582
#define VTK_SURFACE
Definition: vtkProperty.h:46
#define VTK_INT_MAX
Definition: vtkType.h:157
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:143
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:409
double Ambient
Definition: vtkProperty.h:521
double SpecularPower
Definition: vtkProperty.h:524
char * MaterialName
Definition: vtkProperty.h:542
void AddShaderVariable(const char *name, float v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:390
abstract specification for renderers
Definition: vtkRenderer.h:57
void AddShaderVariable(const char *name, double v1, double v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:404
std::map< std::string, vtkTexture * > MapOfTextures
Definition: vtkProperty.h:544
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:158
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:145
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
double Diffuse
Definition: vtkProperty.h:522
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
void AddShaderVariable(const char *name, float v1, float v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:399
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_FLAT
Definition: vtkProperty.h:39
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:160
int Interpolation
Definition: vtkProperty.h:530
handles properties associated with a texture map
Definition: vtkTexture.h:65
int Representation
Definition: vtkProperty.h:531
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:162
#define VTK_SIZEHINT(...)
#define VTK_POINTS
Definition: vtkProperty.h:44
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:388
std::map< std::string, vtkTexture * > & GetAllTextures()
Returns all the textures in this property and their names.
Definition: vtkProperty.h:469
#define VTK_GOURAUD
Definition: vtkProperty.h:40
vtkTypeBool Shading
Definition: vtkProperty.h:540
#define VTK_PHONG
Definition: vtkProperty.h:41
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:94
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:535
int LineStippleRepeatFactor
Definition: vtkProperty.h:529
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:561
bool RenderPointsAsSpheres
Definition: vtkProperty.h:537
MapOfTextures Textures
Definition: vtkProperty.h:545
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:533
void AddShaderVariable(const char *name, int v1, int v2)
Methods to provide to add shader variables from wrappers.
Definition: vtkProperty.h:394
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:548
double Specular
Definition: vtkProperty.h:523
#define VTK_WIREFRAME
Definition: vtkProperty.h:45
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:534
The ShaderProgram uses one or more Shader objects.