VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkProperty.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00036 #ifndef __vtkProperty_h 00037 #define __vtkProperty_h 00038 00039 #include "vtkRenderingCoreModule.h" // For export macro 00040 #include "vtkObject.h" 00041 00042 // shading models 00043 #define VTK_FLAT 0 00044 #define VTK_GOURAUD 1 00045 #define VTK_PHONG 2 00046 00047 // representation models 00048 #define VTK_POINTS 0 00049 #define VTK_WIREFRAME 1 00050 #define VTK_SURFACE 2 00051 00052 class vtkActor; 00053 class vtkRenderer; 00054 class vtkShaderProgram; 00055 class vtkShaderDeviceAdapter2; 00056 class vtkTexture; 00057 class vtkWindow; 00058 class vtkXMLDataElement; 00059 class vtkXMLMaterial; 00060 00061 class vtkPropertyInternals; 00062 00063 class VTKRENDERINGCORE_EXPORT vtkProperty : public vtkObject 00064 { 00065 public: 00066 vtkTypeMacro(vtkProperty,vtkObject); 00067 void PrintSelf(ostream& os, vtkIndent indent); 00068 00074 static vtkProperty *New(); 00075 00077 void DeepCopy(vtkProperty *p); 00078 00084 virtual void Render(vtkActor *, vtkRenderer *); 00085 00091 virtual void BackfaceRender(vtkActor *, vtkRenderer *) {} 00092 00093 //BTX 00095 00097 virtual void PostRender(vtkActor*, vtkRenderer*); 00098 //ETX 00100 00102 00103 vtkGetMacro(Lighting, bool); 00104 vtkSetMacro(Lighting, bool); 00105 vtkBooleanMacro(Lighting, bool); 00107 00109 00110 vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PHONG); 00111 vtkGetMacro(Interpolation,int); 00112 void SetInterpolationToFlat() 00113 { this->SetInterpolation(VTK_FLAT); } 00114 void SetInterpolationToGouraud() 00115 { this->SetInterpolation(VTK_GOURAUD); } 00116 void SetInterpolationToPhong() 00117 { this->SetInterpolation(VTK_PHONG); } 00118 const char *GetInterpolationAsString(); 00120 00122 00123 vtkSetClampMacro(Representation,int, VTK_POINTS, VTK_SURFACE); 00124 vtkGetMacro(Representation,int); 00125 void SetRepresentationToPoints() 00126 { this->SetRepresentation(VTK_POINTS); } 00127 void SetRepresentationToWireframe() 00128 { this->SetRepresentation(VTK_WIREFRAME); } 00129 void SetRepresentationToSurface() 00130 { this->SetRepresentation(VTK_SURFACE); } 00131 const char *GetRepresentationAsString(); 00133 00135 00138 virtual void SetColor(double r, double g, double b); 00139 virtual void SetColor(double a[3]); 00140 double *GetColor(); 00141 void GetColor(double rgb[3]); 00142 void GetColor(double &r, double &g, double &b); 00144 00146 00147 vtkSetClampMacro(Ambient, double, 0.0, 1.0); 00148 vtkGetMacro(Ambient, double); 00150 00152 00153 vtkSetClampMacro(Diffuse, double, 0.0, 1.0); 00154 vtkGetMacro(Diffuse, double); 00156 00158 00159 vtkSetClampMacro(Specular, double, 0.0, 1.0); 00160 vtkGetMacro(Specular, double); 00162 00164 00165 vtkSetClampMacro(SpecularPower, double, 0.0, 128.0); 00166 vtkGetMacro(SpecularPower, double); 00168 00170 00172 vtkSetClampMacro(Opacity, double, 0.0, 1.0); 00173 vtkGetMacro(Opacity, double); 00175 00177 00181 vtkSetVector3Macro(AmbientColor, double); 00182 vtkGetVector3Macro(AmbientColor, double); 00184 00186 00187 vtkSetVector3Macro(DiffuseColor, double); 00188 vtkGetVector3Macro(DiffuseColor, double); 00190 00192 00193 vtkSetVector3Macro(SpecularColor, double); 00194 vtkGetVector3Macro(SpecularColor, double); 00196 00198 00201 vtkGetMacro(EdgeVisibility, int); 00202 vtkSetMacro(EdgeVisibility, int); 00203 vtkBooleanMacro(EdgeVisibility, int); 00205 00207 00208 vtkSetVector3Macro(EdgeColor, double); 00209 vtkGetVector3Macro(EdgeColor, double); 00211 00213 00215 vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX); 00216 vtkGetMacro(LineWidth, float); 00218 00220 00223 vtkSetMacro(LineStipplePattern, int); 00224 vtkGetMacro(LineStipplePattern, int); 00226 00228 00231 vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX); 00232 vtkGetMacro(LineStippleRepeatFactor, int); 00234 00236 00238 vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX); 00239 vtkGetMacro(PointSize, float); 00241 00243 00246 vtkGetMacro(BackfaceCulling, int); 00247 vtkSetMacro(BackfaceCulling, int); 00248 vtkBooleanMacro(BackfaceCulling, int); 00250 00252 00255 vtkGetMacro(FrontfaceCulling, int); 00256 vtkSetMacro(FrontfaceCulling, int); 00257 vtkBooleanMacro(FrontfaceCulling, int); 00259 00261 00262 vtkGetStringMacro(MaterialName); 00264 00266 00268 vtkSetMacro(Shading, int); 00269 vtkGetMacro(Shading, int); 00270 vtkBooleanMacro(Shading, int); 00272 00274 00275 virtual vtkShaderDeviceAdapter2* GetShaderDeviceAdapter2() 00276 { return NULL; } 00278 00280 00284 virtual void AddShaderVariable(const char *name, int numVars, int *x); 00285 virtual void AddShaderVariable(const char *name, int numVars, float *x); 00286 virtual void AddShaderVariable(const char *name, int numVars, double *x); 00288 00290 00291 void AddShaderVariable(const char* name, int v) 00292 { this->AddShaderVariable(name, 1, &v); } 00293 void AddShaderVariable(const char* name, float v) 00294 { this->AddShaderVariable(name, 1, &v); } 00295 void AddShaderVariable(const char* name, double v) 00296 { this->AddShaderVariable(name, 1, &v); } 00297 void AddShaderVariable(const char* name, int v1, int v2) 00298 { 00299 int v[2] = {v1, v2}; 00300 this->AddShaderVariable(name, 2, v); 00301 } 00302 void AddShaderVariable(const char* name, float v1, float v2) 00303 { 00304 float v[2] = {v1, v2}; 00305 this->AddShaderVariable(name, 2, v); 00306 } 00307 void AddShaderVariable(const char* name, double v1, double v2) 00308 { 00309 double v[2] = {v1, v2}; 00310 this->AddShaderVariable(name, 2, v); 00311 } 00312 void AddShaderVariable(const char* name, int v1, int v2, int v3) 00313 { 00314 int v[3] = {v1, v2, v3}; 00315 this->AddShaderVariable(name, 3, v); 00316 } 00317 void AddShaderVariable(const char* name, float v1, float v2, float v3) 00318 { 00319 float v[3] = {v1, v2, v3}; 00320 this->AddShaderVariable(name, 3, v); 00321 } 00322 void AddShaderVariable(const char* name, double v1, double v2, double v3) 00323 { 00324 double v[3] = {v1, v2, v3}; 00325 this->AddShaderVariable(name, 3, v); 00326 } 00328 00330 00334 void SetTexture(const char* name, vtkTexture* texture); 00335 vtkTexture* GetTexture(const char* name); 00337 00339 00343 void SetTexture(int unit, vtkTexture* texture); 00344 vtkTexture* GetTexture(int unit); 00345 void RemoveTexture(int unit); 00347 00350 void RemoveTexture(const char* name); 00351 00353 void RemoveAllTextures(); 00354 00356 int GetNumberOfTextures(); 00357 00361 virtual void ReleaseGraphicsResources(vtkWindow *win); 00362 00363 //BTX 00365 00367 enum VTKTextureUnit 00368 { 00369 VTK_TEXTURE_UNIT_0 = 0, 00370 VTK_TEXTURE_UNIT_1, 00371 VTK_TEXTURE_UNIT_2, 00372 VTK_TEXTURE_UNIT_3, 00373 VTK_TEXTURE_UNIT_4, 00374 VTK_TEXTURE_UNIT_5, 00375 VTK_TEXTURE_UNIT_6, 00376 VTK_TEXTURE_UNIT_7 00377 }; 00378 //ETX 00380 00381 protected: 00382 vtkProperty(); 00383 ~vtkProperty(); 00384 00386 00387 static void ComputeCompositeColor(double result[3], 00388 double ambient, const double ambient_color[3], 00389 double diffuse, const double diffuse_color[3], 00390 double specular, const double specular_color[3]); 00392 00393 double Color[3]; 00394 double AmbientColor[3]; 00395 double DiffuseColor[3]; 00396 double SpecularColor[3]; 00397 double EdgeColor[3]; 00398 double Ambient; 00399 double Diffuse; 00400 double Specular; 00401 double SpecularPower; 00402 double Opacity; 00403 float PointSize; 00404 float LineWidth; 00405 int LineStipplePattern; 00406 int LineStippleRepeatFactor; 00407 int Interpolation; 00408 int Representation; 00409 int EdgeVisibility; 00410 int BackfaceCulling; 00411 int FrontfaceCulling; 00412 bool Lighting; 00413 00414 int Shading; 00415 00416 char* MaterialName; 00417 vtkSetStringMacro(MaterialName); 00418 00419 //BTX 00420 // FIXME: 00421 // Don't use these methods. They will be removed. They are provided only 00422 // for the time-being. 00423 vtkTexture* GetTextureAtIndex(int index); 00424 int GetTextureUnitAtIndex(int index); 00425 int GetTextureUnit(const char* name); 00426 //ETX 00427 00428 private: 00429 vtkProperty(const vtkProperty&); // Not implemented. 00430 void operator=(const vtkProperty&); // Not implemented. 00431 00432 vtkPropertyInternals* Internals; 00433 }; 00434 00436 00437 inline const char *vtkProperty::GetInterpolationAsString(void) 00438 { 00439 if (this->Interpolation == VTK_FLAT) 00440 { 00441 return "Flat"; 00442 } 00443 else if (this->Interpolation == VTK_GOURAUD) 00444 { 00445 return "Gouraud"; 00446 } 00447 else 00448 { 00449 return "Phong"; 00450 } 00451 } 00453 00455 00456 inline const char *vtkProperty::GetRepresentationAsString(void) 00457 { 00458 if (this->Representation == VTK_POINTS) 00459 { 00460 return "Points"; 00461 } 00462 else if (this->Representation == VTK_WIREFRAME) 00463 { 00464 return "Wireframe"; 00465 } 00466 else 00467 { 00468 return "Surface"; 00469 } 00470 } 00472 00473 #endif