• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Rendering/vtkProperty.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkProperty.h,v $
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 =========================================================================*/
00033 #ifndef __vtkProperty_h
00034 #define __vtkProperty_h
00035 
00036 #include "vtkObject.h"
00037 
00038 // shading models
00039 #define VTK_FLAT    0
00040 #define VTK_GOURAUD 1
00041 #define VTK_PHONG   2
00042 
00043 // representation models
00044 #define VTK_POINTS    0
00045 #define VTK_WIREFRAME 1
00046 #define VTK_SURFACE   2
00047 
00048 class vtkActor;
00049 class vtkRenderer;
00050 class vtkShaderProgram;
00051 class vtkTexture;
00052 class vtkWindow;
00053 class vtkXMLDataElement;
00054 class vtkXMLMaterial;
00055 
00056 class vtkPropertyInternals;
00057 
00058 class VTK_RENDERING_EXPORT vtkProperty : public vtkObject
00059 {
00060 public:
00061   vtkTypeRevisionMacro(vtkProperty,vtkObject);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00069   static vtkProperty *New();
00070 
00072   void DeepCopy(vtkProperty *p);
00073 
00079   virtual void Render(vtkActor *,vtkRenderer *);
00080 
00086   virtual void BackfaceRender(vtkActor *,vtkRenderer *) {};
00087 
00088   //BTX
00090 
00092   virtual void PostRender(vtkActor*, vtkRenderer*);
00093   //ETX
00095 
00097 
00098   vtkGetMacro(Lighting,bool);
00099   vtkSetMacro(Lighting,bool);
00100   vtkBooleanMacro(Lighting,bool);
00102   
00104 
00105   vtkSetClampMacro(Interpolation,int,VTK_FLAT,VTK_PHONG);
00106   vtkGetMacro(Interpolation,int);
00107   void SetInterpolationToFlat() {this->SetInterpolation(VTK_FLAT);};
00108   void SetInterpolationToGouraud() {this->SetInterpolation(VTK_GOURAUD);};
00109   void SetInterpolationToPhong() {this->SetInterpolation(VTK_PHONG);};
00110   const char *GetInterpolationAsString();
00112 
00114 
00115   vtkSetClampMacro(Representation,int,VTK_POINTS,VTK_SURFACE);
00116   vtkGetMacro(Representation,int);
00117   void SetRepresentationToPoints() {this->SetRepresentation(VTK_POINTS);};
00118   void SetRepresentationToWireframe() {
00119     this->SetRepresentation(VTK_WIREFRAME);};
00120   void SetRepresentationToSurface() {this->SetRepresentation(VTK_SURFACE);};
00121   const char *GetRepresentationAsString();
00123 
00125 
00128   void SetColor(double r, double g, double b);
00129   void SetColor(double a[3]) { this->SetColor(a[0], a[1], a[2]); };
00130   double *GetColor();
00131   void GetColor(double rgb[3]);
00132   void GetColor(double &r, double &g, double &b);
00134 
00136 
00137   vtkSetClampMacro(Ambient,double,0.0,1.0);
00138   vtkGetMacro(Ambient,double);
00140 
00142 
00143   vtkSetClampMacro(Diffuse,double,0.0,1.0);
00144   vtkGetMacro(Diffuse,double);
00146 
00148 
00149   vtkSetClampMacro(Specular,double,0.0,1.0);
00150   vtkGetMacro(Specular,double);
00152 
00154 
00155   vtkSetClampMacro(SpecularPower,double,0.0,128.0);
00156   vtkGetMacro(SpecularPower,double);
00158 
00160 
00162   vtkSetClampMacro(Opacity,double,0.0,1.0);
00163   vtkGetMacro(Opacity,double);
00165 
00167 
00171   vtkSetVector3Macro(AmbientColor,double);
00172   vtkGetVector3Macro(AmbientColor,double);
00174 
00176 
00177   vtkSetVector3Macro(DiffuseColor,double);
00178   vtkGetVector3Macro(DiffuseColor,double);
00180 
00182 
00183   vtkSetVector3Macro(SpecularColor,double);
00184   vtkGetVector3Macro(SpecularColor,double);
00186 
00188 
00191   vtkGetMacro(EdgeVisibility,int);
00192   vtkSetMacro(EdgeVisibility,int);
00193   vtkBooleanMacro(EdgeVisibility,int);
00195 
00197 
00198   vtkSetVector3Macro(EdgeColor,double);
00199   vtkGetVector3Macro(EdgeColor,double);
00201 
00203 
00205   vtkSetClampMacro(LineWidth,float,0,VTK_LARGE_FLOAT);
00206   vtkGetMacro(LineWidth,float);
00208 
00210 
00213   vtkSetMacro(LineStipplePattern,int);
00214   vtkGetMacro(LineStipplePattern,int);
00216 
00218 
00221   vtkSetClampMacro(LineStippleRepeatFactor,int,1,VTK_LARGE_INTEGER);
00222   vtkGetMacro(LineStippleRepeatFactor,int);
00224 
00226 
00228   vtkSetClampMacro(PointSize,float,0,VTK_LARGE_FLOAT);
00229   vtkGetMacro(PointSize,float);
00231 
00233 
00236   vtkGetMacro(BackfaceCulling,int);
00237   vtkSetMacro(BackfaceCulling,int);
00238   vtkBooleanMacro(BackfaceCulling,int);
00240 
00242 
00245   vtkGetMacro(FrontfaceCulling,int);
00246   vtkSetMacro(FrontfaceCulling,int);
00247   vtkBooleanMacro(FrontfaceCulling,int);
00249 
00251 
00253   vtkGetObjectMacro(Material, vtkXMLMaterial);
00255 
00257 
00258   vtkGetStringMacro(MaterialName);
00260 
00263   void LoadMaterial(const char* name);
00264 
00266   void LoadMaterialFromString(const char* materialxml);
00267 
00269   void LoadMaterial(vtkXMLMaterial*);
00270 
00272 
00274   vtkSetMacro(Shading, int);
00275   vtkGetMacro(Shading, int);
00276   vtkBooleanMacro(Shading, int);
00278 
00280 
00282   vtkGetObjectMacro(ShaderProgram, vtkShaderProgram);
00284 
00286 
00290   virtual void AddShaderVariable(const char* name, int numVars, int* x);
00291   virtual void AddShaderVariable(const char* name, int numVars, float* x);
00292   virtual void AddShaderVariable(const char* name, int numVars, double* x);
00294 
00296 
00297   void AddShaderVariable(const char* name, int v)
00298     {
00299     this->AddShaderVariable(name, 1, &v);
00300     }
00301   void AddShaderVariable(const char* name, float v)
00302     {
00303     this->AddShaderVariable(name, 1, &v);
00304     }
00305   void AddShaderVariable(const char* name, double v)
00306     {
00307     this->AddShaderVariable(name, 1, &v);
00308     }
00309   void AddShaderVariable(const char* name, int v1, int v2)
00310     {
00311     int v[2];
00312     v[0] = v1;
00313     v[1] = v2;
00314     this->AddShaderVariable(name, 2, v);
00315     }
00316   void AddShaderVariable(const char* name, float v1, float v2)
00317     {
00318     float v[2];
00319     v[0] = v1;
00320     v[1] = v2;
00321     this->AddShaderVariable(name, 2, v);
00322     }
00323   void AddShaderVariable(const char* name, double v1, double v2)
00324     {
00325     double v[2];
00326     v[0] = v1;
00327     v[1] = v2;
00328     this->AddShaderVariable(name, 2, v);
00329     }
00330   void AddShaderVariable(const char* name, int v1, int v2, int v3)
00331     {
00332     int v[3];
00333     v[0] = v1;
00334     v[1] = v2;
00335     v[2] = v3;
00336     this->AddShaderVariable(name, 3, v);
00337     }
00338   void AddShaderVariable(const char* name, float v1, float v2, float v3)
00339     {
00340     float v[3];
00341     v[0] = v1;
00342     v[1] = v2;
00343     v[2] = v3;
00344     this->AddShaderVariable(name, 3, v);
00345     }
00346   void AddShaderVariable(const char* name, double v1, double v2, double v3)
00347     {
00348     double v[3];
00349     v[0] = v1;
00350     v[1] = v2;
00351     v[2] = v3;
00352     this->AddShaderVariable(name, 3, v);
00353     }
00355 
00357 
00361   void SetTexture(const char* name, vtkTexture* texture);
00362   vtkTexture* GetTexture(const char* name);
00364 
00366 
00370   void SetTexture(int unit, vtkTexture* texture);
00371   vtkTexture* GetTexture(int unit);
00372   void RemoveTexture(int unit);
00374 
00375 
00378   void RemoveTexture(const char* name);
00379 
00381   void RemoveAllTextures();
00382 
00384   int GetNumberOfTextures();
00385 
00389   virtual void ReleaseGraphicsResources(vtkWindow *win);
00390 
00392 
00394   enum VTKTextureUnit
00395   {
00396     VTK_TEXTURE_UNIT_0 = 0,
00397     VTK_TEXTURE_UNIT_1,
00398     VTK_TEXTURE_UNIT_2,
00399     VTK_TEXTURE_UNIT_3,
00400     VTK_TEXTURE_UNIT_4,
00401     VTK_TEXTURE_UNIT_5,
00402     VTK_TEXTURE_UNIT_6,
00403     VTK_TEXTURE_UNIT_7
00404   };
00406 //ETX
00407 
00408 protected:
00409   vtkProperty();
00410   ~vtkProperty();
00411 
00413 
00414   void LoadProperty();
00415   void LoadTextures();
00416   void LoadTexture(vtkXMLDataElement* elem);
00417   void LoadPerlineNoise(vtkXMLDataElement* );
00418   void LoadMember(vtkXMLDataElement* elem);
00420 
00421   double Color[3];
00422   double AmbientColor[3];
00423   double DiffuseColor[3];
00424   double SpecularColor[3];
00425   double EdgeColor[3];
00426   double Ambient;
00427   double Diffuse;
00428   double Specular;
00429   double SpecularPower;
00430   double Opacity;
00431   float PointSize;
00432   float LineWidth;
00433   int   LineStipplePattern;
00434   int   LineStippleRepeatFactor;
00435   int   Interpolation;
00436   int   Representation;
00437   int   EdgeVisibility;
00438   int   BackfaceCulling;
00439   int   FrontfaceCulling;
00440   bool Lighting;
00441 
00442   int Shading;
00443 
00444   char* MaterialName;
00445   vtkSetStringMacro(MaterialName);
00446 
00447   vtkShaderProgram* ShaderProgram;
00448   void SetShaderProgram(vtkShaderProgram*);
00449 
00450   vtkXMLMaterial* Material; // TODO: I wonder if this reference needs to be maintained.
00451 
00454   virtual void ReadFrameworkMaterial();
00455   
00456 //BTX
00457   // These friends are provided only for the time being
00458   // till we device a graceful way of loading texturing for GLSL.
00459   friend class vtkGLSLShaderProgram;
00460   friend class vtkShader;
00461   // FIXME:
00462   // Don't use these methods. They will be removed. They are provided only
00463   // for the time-being.
00464   vtkTexture* GetTextureAtIndex(int index);
00465   int GetTextureUnitAtIndex(int index);
00466   int GetTextureUnit(const char* name);
00467 //ETX
00468 
00469 private:
00470   vtkProperty(const vtkProperty&);  // Not implemented.
00471   void operator=(const vtkProperty&);  // Not implemented.
00472 
00473   vtkPropertyInternals* Internals;
00474 };
00475 
00477 inline const char *vtkProperty::GetInterpolationAsString(void)
00478 {
00479   if ( this->Interpolation == VTK_FLAT )
00480     {
00481     return "Flat";
00482     }
00483   else if ( this->Interpolation == VTK_GOURAUD )
00484     {
00485     return "Gouraud";
00486     }
00487   else
00488     {
00489     return "Phong";
00490     }
00491 }
00492 
00493 
00495 inline const char *vtkProperty::GetRepresentationAsString(void)
00496 {
00497   if ( this->Representation == VTK_POINTS )
00498     {
00499     return "Points";
00500     }
00501   else if ( this->Representation == VTK_WIREFRAME )
00502     {
00503     return "Wireframe";
00504     }
00505   else
00506     {
00507     return "Surface";
00508     }
00509 }
00510 
00511 
00512 
00513 #endif

Generated by  doxygen 1.7.1