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
53class vtkActor;
54class vtkRenderer;
57class vtkTexture;
58class vtkWindow;
60class vtkXMLMaterial;
61
62class vtkPropertyInternals;
63
64class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject
65{
66public:
67 vtkTypeMacro(vtkProperty,vtkObject);
68 void PrintSelf(ostream& os, vtkIndent indent);
69
76 static vtkProperty *New();
77
82
90 virtual void Render(vtkActor *, vtkRenderer *);
91
98 virtual void BackfaceRender(vtkActor *, vtkRenderer *) {}
99
106
108
111 vtkGetMacro(Lighting, bool);
112 vtkSetMacro(Lighting, bool);
113 vtkBooleanMacro(Lighting, bool);
115
117
123 vtkGetMacro(RenderPointsAsSpheres, bool);
124 vtkSetMacro(RenderPointsAsSpheres, bool);
125 vtkBooleanMacro(RenderPointsAsSpheres, bool);
127
129
136 vtkGetMacro(RenderLinesAsTubes, bool);
137 vtkSetMacro(RenderLinesAsTubes, bool);
138 vtkBooleanMacro(RenderLinesAsTubes, bool);
140
142
145 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG);
146 vtkGetMacro(Interpolation,int);
148 { this->SetInterpolation(VTK_FLAT); }
150 { this->SetInterpolation(VTK_GOURAUD); }
152 { this->SetInterpolation(VTK_PHONG); }
153 const char *GetInterpolationAsString();
155
157
160 vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE);
161 vtkGetMacro(Representation,int);
163 { this->SetRepresentation(VTK_POINTS); }
165 { this->SetRepresentation(VTK_WIREFRAME); }
167 { this->SetRepresentation(VTK_SURFACE); }
168 const char *GetRepresentationAsString();
170
172
177 virtual void SetColor(double r, double g, double b);
178 virtual void SetColor(double a[3]);
179 double *GetColor();
180 void GetColor(double rgb[3]);
181 void GetColor(double &r, double &g, double &b);
183
185
188 vtkSetClampMacro(Ambient, double, 0.0, 1.0);
189 vtkGetMacro(Ambient, double);
191
193
196 vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
197 vtkGetMacro(Diffuse, double);
199
201
204 vtkSetClampMacro(Specular, double, 0.0, 1.0);
205 vtkGetMacro(Specular, double);
207
209
212 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
213 vtkGetMacro(SpecularPower, double);
215
217
221 vtkSetClampMacro(Opacity, double, 0.0, 1.0);
222 vtkGetMacro(Opacity, double);
224
226
232 vtkSetVector3Macro(AmbientColor, double);
233 vtkGetVector3Macro(AmbientColor, double);
235
237
240 vtkSetVector3Macro(DiffuseColor, double);
241 vtkGetVector3Macro(DiffuseColor, double);
243
245
248 vtkSetVector3Macro(SpecularColor, double);
249 vtkGetVector3Macro(SpecularColor, double);
251
253
258 vtkGetMacro(EdgeVisibility, int);
259 vtkSetMacro(EdgeVisibility, int);
260 vtkBooleanMacro(EdgeVisibility, int);
262
264
267 vtkSetVector3Macro(EdgeColor, double);
268 vtkGetVector3Macro(EdgeColor, double);
270
272
276 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
277 vtkGetMacro(LineWidth, float);
279
281
286 vtkSetMacro(LineStipplePattern, int);
287 vtkGetMacro(LineStipplePattern, int);
289
291
296 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
297 vtkGetMacro(LineStippleRepeatFactor, int);
299
301
305 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
306 vtkGetMacro(PointSize, float);
308
310
315 vtkGetMacro(BackfaceCulling, int);
316 vtkSetMacro(BackfaceCulling, int);
317 vtkBooleanMacro(BackfaceCulling, int);
319
321
326 vtkGetMacro(FrontfaceCulling, int);
327 vtkSetMacro(FrontfaceCulling, int);
328 vtkBooleanMacro(FrontfaceCulling, int);
330
332
335 vtkGetStringMacro(MaterialName);
337
339
343 vtkSetMacro(Shading, int);
344 vtkGetMacro(Shading, int);
345 vtkBooleanMacro(Shading, int);
347
352 { return NULL; }
353
355
363 virtual void AddShaderVariable(const char *name, int numVars, int *x);
364 virtual void AddShaderVariable(const char *name, int numVars, float *x);
365 virtual void AddShaderVariable(const char *name, int numVars, double *x);
367
369
372 void AddShaderVariable(const char* name, int v)
373 { this->AddShaderVariable(name, 1, &v); }
374 void AddShaderVariable(const char* name, float v)
375 { this->AddShaderVariable(name, 1, &v); }
376 void AddShaderVariable(const char* name, double v)
377 { this->AddShaderVariable(name, 1, &v); }
378 void AddShaderVariable(const char* name, int v1, int v2)
379 {
380 int v[2] = {v1, v2};
381 this->AddShaderVariable(name, 2, v);
382 }
383 void AddShaderVariable(const char* name, float v1, float v2)
384 {
385 float v[2] = {v1, v2};
386 this->AddShaderVariable(name, 2, v);
387 }
388 void AddShaderVariable(const char* name, double v1, double v2)
389 {
390 double v[2] = {v1, v2};
391 this->AddShaderVariable(name, 2, v);
392 }
393 void AddShaderVariable(const char* name, int v1, int v2, int v3)
394 {
395 int v[3] = {v1, v2, v3};
396 this->AddShaderVariable(name, 3, v);
397 }
398 void AddShaderVariable(const char* name, float v1, float v2, float v3)
399 {
400 float v[3] = {v1, v2, v3};
401 this->AddShaderVariable(name, 3, v);
402 }
403 void AddShaderVariable(const char* name, double v1, double v2, double v3)
404 {
405 double v[3] = {v1, v2, v3};
406 this->AddShaderVariable(name, 3, v);
407 }
409
411
417 void SetTexture(const char* name, vtkTexture* texture);
420
422
428 void SetTexture(int unit, vtkTexture* texture);
430 void RemoveTexture(int unit);
432
437 void RemoveTexture(const char* name);
438
443
448
455
461 {
462 VTK_TEXTURE_UNIT_0 = 0,
469 VTK_TEXTURE_UNIT_7
470 };
471
472protected:
475
479 static void ComputeCompositeColor(double result[3],
480 double ambient, const double ambient_color[3],
481 double diffuse, const double diffuse_color[3],
482 double specular, const double specular_color[3]);
483
484 double Color[3];
485 double AmbientColor[3];
486 double DiffuseColor[3];
487 double SpecularColor[3];
488 double EdgeColor[3];
489 double Ambient;
490 double Diffuse;
491 double Specular;
493 double Opacity;
506
508
510 vtkSetStringMacro(MaterialName);
511
512 // FIXME:
513 // Don't use these methods. They will be removed. They are provided only
514 // for the time-being.
517 int GetTextureUnit(const char* name);
518
519private:
520 vtkProperty(const vtkProperty&) VTK_DELETE_FUNCTION;
521 void operator=(const vtkProperty&) VTK_DELETE_FUNCTION;
522
523 vtkPropertyInternals* Internals;
524};
525
527
531{
532 if (this->Interpolation == VTK_FLAT)
533 {
534 return "Flat";
535 }
536 else if (this->Interpolation == VTK_GOURAUD)
537 {
538 return "Gouraud";
539 }
540 else
541 {
542 return "Phong";
543 }
544}
546
548
552{
553 if (this->Representation == VTK_POINTS)
554 {
555 return "Points";
556 }
557 else if (this->Representation == VTK_WIREFRAME)
558 {
559 return "Wireframe";
560 }
561 else
562 {
563 return "Surface";
564 }
565}
567
568#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent surface properties of a geometric object
Definition: vtkProperty.h:65
void SetTexture(int unit, vtkTexture *texture)
Set/Get the texture object to control rendering texture maps.
static vtkProperty * New()
Construct object with object color, ambient color, diffuse color, specular color, and edge color whit...
vtkTexture * GetTextureAtIndex(int index)
virtual void AddShaderVariable(const char *name, int numVars, int *x)
Provide values to initialize shader variables.
void SetRepresentationToPoints()
Definition: vtkProperty.h:162
int LineStipplePattern
Definition: vtkProperty.h:496
void SetTexture(const char *name, vtkTexture *texture)
Set/Get the texture object to control rendering texture maps.
void SetRepresentationToWireframe()
Definition: vtkProperty.h:164
int LineStippleRepeatFactor
Definition: vtkProperty.h:497
vtkTexture * GetTexture(int unit)
double * GetColor()
static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3], double diffuse, const double diffuse_color[3], double specular, const double specular_color[3])
Computes composite color.
virtual void SetColor(double a[3])
double Diffuse
Definition: vtkProperty.h:490
void AddShaderVariable(const char *name, double v1, double v2)
Definition: vtkProperty.h:388
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:98
double Opacity
Definition: vtkProperty.h:493
int Representation
Definition: vtkProperty.h:499
float LineWidth
Definition: vtkProperty.h:495
int GetNumberOfTextures()
Returns the number of textures in this property.
void SetInterpolationToFlat()
Definition: vtkProperty.h:147
void RemoveAllTextures()
Remove all the textures.
int GetTextureUnit(const char *name)
void GetColor(double &r, double &g, double &b)
void SetInterpolationToGouraud()
Definition: vtkProperty.h:149
void DeepCopy(vtkProperty *p)
Assign one property to another.
int Interpolation
Definition: vtkProperty.h:498
vtkTexture * GetTexture(const char *name)
virtual vtkShaderDeviceAdapter2 * GetShaderDeviceAdapter2()
Get the vtkShaderDeviceAdapter2 if set, returns null otherwise.
Definition: vtkProperty.h:351
void AddShaderVariable(const char *name, double v)
Definition: vtkProperty.h:376
virtual void Render(vtkActor *, vtkRenderer *)
This method causes the property to set up whatever is required for its instance variables.
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:530
void SetRepresentationToSurface()
Definition: vtkProperty.h:166
void SetInterpolationToPhong()
Definition: vtkProperty.h:151
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void AddShaderVariable(const char *name, double v1, double v2, double v3)
Definition: vtkProperty.h:403
bool RenderPointsAsSpheres
Definition: vtkProperty.h:504
virtual void AddShaderVariable(const char *name, int numVars, float *x)
float PointSize
Definition: vtkProperty.h:494
void AddShaderVariable(const char *name, int v1, int v2, int v3)
Definition: vtkProperty.h:393
void RemoveTexture(int unit)
virtual void SetColor(double r, double g, double b)
Set the color of the object.
void AddShaderVariable(const char *name, float v1, float v2, float v3)
Definition: vtkProperty.h:398
double Specular
Definition: vtkProperty.h:491
bool RenderLinesAsTubes
Definition: vtkProperty.h:505
virtual void ReleaseGraphicsResources(vtkWindow *win)
Release any graphics resources that are being consumed by this property.
void AddShaderVariable(const char *name, int v)
Methods to provide to add shader variables from tcl.
Definition: vtkProperty.h:372
double SpecularPower
Definition: vtkProperty.h:492
void RemoveTexture(const char *name)
Remove a texture from the collection.
void AddShaderVariable(const char *name, float v1, float v2)
Definition: vtkProperty.h:383
int BackfaceCulling
Definition: vtkProperty.h:501
int EdgeVisibility
Definition: vtkProperty.h:500
virtual void AddShaderVariable(const char *name, int numVars, double *x)
int FrontfaceCulling
Definition: vtkProperty.h:502
void GetColor(double rgb[3])
virtual void PostRender(vtkActor *, vtkRenderer *)
This method is called after the actor has been rendered.
double Ambient
Definition: vtkProperty.h:489
VTKTextureUnit
Used to specify which texture unit a texture will use.
Definition: vtkProperty.h:461
@ VTK_TEXTURE_UNIT_5
Definition: vtkProperty.h:467
@ VTK_TEXTURE_UNIT_3
Definition: vtkProperty.h:465
@ VTK_TEXTURE_UNIT_6
Definition: vtkProperty.h:468
@ VTK_TEXTURE_UNIT_4
Definition: vtkProperty.h:466
@ VTK_TEXTURE_UNIT_2
Definition: vtkProperty.h:464
@ VTK_TEXTURE_UNIT_1
Definition: vtkProperty.h:463
void AddShaderVariable(const char *name, int v1, int v2)
Definition: vtkProperty.h:378
int GetTextureUnitAtIndex(int index)
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:551
void AddShaderVariable(const char *name, float v)
Definition: vtkProperty.h:374
char * MaterialName
Definition: vtkProperty.h:509
abstract specification for renderers
Definition: vtkRenderer.h:64
an adapter to pass generic vertex attributes to the rendering pipeline.
The ShaderProgram uses one or more Shader objects.
handles properties associated with a texture map
Definition: vtkTexture.h:71
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
Represents an XML element and those nested inside.
@ Color
Definition: vtkX3D.h:46
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
#define VTK_POINTS
Definition: vtkProperty.h:49
#define VTK_WIREFRAME
Definition: vtkProperty.h:50
#define VTK_PHONG
Definition: vtkProperty.h:46
#define VTK_FLAT
Definition: vtkProperty.h:44
#define VTK_SURFACE
Definition: vtkProperty.h:51
#define VTK_GOURAUD
Definition: vtkProperty.h:45
#define VTK_INT_MAX
Definition: vtkType.h:153
#define VTK_FLOAT_MAX
Definition: vtkType.h:161