Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Rendering/vtkRenderer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkRenderer.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00056 #ifndef __vtkRenderer_h
00057 #define __vtkRenderer_h
00058 
00059 #include "vtkViewport.h"
00060 
00061 #include "vtkVolumeCollection.h" // Needed for access in inline members
00062 #include "vtkActorCollection.h" // Needed for access in inline members
00063 
00064 class vtkRenderWindow;
00065 class vtkVolume;
00066 class vtkCuller;
00067 class vtkActor;
00068 class vtkActor2D;
00069 class vtkCamera;
00070 class vtkLightCollection;
00071 class vtkCullerCollection;
00072 class vtkLight;
00073 
00074 class VTK_RENDERING_EXPORT vtkRenderer : public vtkViewport
00075 {
00076 public:
00077   vtkTypeRevisionMacro(vtkRenderer,vtkViewport);
00078   void PrintSelf(ostream& os, vtkIndent indent);
00079 
00083   static vtkRenderer *New();
00084 
00086 
00089   void AddActor(vtkProp *p) {this->AddProp(p);};
00090   void AddVolume(vtkProp *p) {this->AddProp(p);};
00091   void RemoveActor(vtkProp *p) {this->Actors->RemoveItem(p);this->RemoveProp(p);};
00092   void RemoveVolume(vtkProp *p) {this->Volumes->RemoveItem(p);this->RemoveProp(p);};
00094 
00096   void AddLight(vtkLight *);
00097 
00099   void RemoveLight(vtkLight *);
00100 
00102   vtkLightCollection *GetLights();
00103   
00105   void CreateLight(void);
00106   
00110   virtual vtkLight *MakeLight();
00111 
00113 
00117   vtkGetMacro(TwoSidedLighting,int);
00118   vtkSetMacro(TwoSidedLighting,int);
00119   vtkBooleanMacro(TwoSidedLighting,int);
00121 
00123 
00133   vtkSetMacro(LightFollowCamera,int);
00134   vtkGetMacro(LightFollowCamera,int);
00135   vtkBooleanMacro(LightFollowCamera,int);
00137 
00141   virtual int UpdateLightsGeometryToFollowCamera(void);
00142 
00144   vtkVolumeCollection *GetVolumes();
00145 
00147   vtkActorCollection *GetActors();
00148 
00150   void SetActiveCamera(vtkCamera *);
00151 
00153   vtkCamera *GetActiveCamera();
00154 
00158   virtual vtkCamera *MakeCamera();
00159 
00161   void AddCuller(vtkCuller *);
00162 
00164   void RemoveCuller(vtkCuller *);
00165 
00167   vtkCullerCollection *GetCullers();
00168 
00170 
00171   vtkSetVector3Macro(Ambient,float);
00172   vtkGetVectorMacro(Ambient,float,3);
00174 
00176 
00178   vtkSetMacro(AllocatedRenderTime,float);
00179   virtual float GetAllocatedRenderTime();
00181 
00186   virtual float GetTimeFactor();
00187 
00190   virtual void Render();
00191 
00194   virtual void DeviceRender() =0;
00195 
00197   virtual void Clear() {};
00198 
00200   int VisibleActorCount();
00201 
00203   int VisibleVolumeCount();
00204 
00207   void ComputeVisiblePropBounds( float bounds[6] );
00208 
00210   float *ComputeVisiblePropBounds();
00211 
00214   void ResetCameraClippingRange();
00215 
00217 
00219   void ResetCameraClippingRange( float bounds[6] );
00220   void ResetCameraClippingRange( float xmin, float xmax, 
00221                                  float ymin, float ymax, 
00222                                  float zmin, float zmax);
00224 
00230   void ResetCamera();
00231 
00239   void ResetCamera(float bounds[6]);
00240 
00242 
00243   void ResetCamera(float xmin, float xmax, float ymin, float ymax, 
00244                    float zmin, float zmax);
00246 
00248 
00251   void SetRenderWindow(vtkRenderWindow *);
00252   vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
00253   virtual vtkWindow *GetVTKWindow();
00255   
00257 
00260   vtkSetMacro(BackingStore,int);
00261   vtkGetMacro(BackingStore,int);
00262   vtkBooleanMacro(BackingStore,int);
00264 
00266 
00269   vtkSetMacro(Interactive,int);
00270   vtkGetMacro(Interactive,int);
00271   vtkBooleanMacro(Interactive,int);
00273 
00275 
00277   vtkSetMacro(Layer, int);
00278   vtkGetMacro(Layer, int);
00280 
00283   int  Transparent();
00284 
00286   void WorldToView();
00287 
00289 
00290   void ViewToWorld();
00291   virtual void ViewToWorld(float &wx, float &wy, float &wz);
00293 
00295   virtual void WorldToView(float &wx, float &wy, float &wz);
00296 
00298   float GetZ (int x, int y);
00299 
00301   unsigned long GetMTime();
00302 
00304 
00305   vtkGetMacro( LastRenderTimeInSeconds, float );
00307 
00309 
00313   vtkGetMacro( NumberOfPropsRendered, int );
00315 
00321   vtkAssemblyPath* PickProp(float selectionX, float selectionY);
00322 
00323 protected:
00324   vtkRenderer();
00325   ~vtkRenderer();
00326 
00327   // internal method for doing a render for picking purposes
00328   virtual void PickRender(vtkPropCollection *props);
00329   virtual void PickGeometry();
00330   
00331   vtkCamera *ActiveCamera;
00332   vtkLight  *CreatedLight;
00333 
00334   vtkLightCollection *Lights;
00335   vtkCullerCollection *Cullers;
00336 
00337   vtkActorCollection *Actors;
00338   vtkVolumeCollection *Volumes;
00339   
00340   float              Ambient[3];  
00341   vtkRenderWindow    *RenderWindow;
00342   float              AllocatedRenderTime;
00343   float              TimeFactor;
00344   int                TwoSidedLighting;
00345   int                BackingStore;
00346   unsigned char      *BackingImage;
00347   vtkTimeStamp       RenderTime;
00348 
00349   float              LastRenderTimeInSeconds;
00350 
00351   int                LightFollowCamera;
00352 
00353   // Allocate the time for each prop
00354   void               AllocateTime();
00355 
00356   // Internal variables indicating the number of props
00357   // that have been or will be rendered in each category.
00358   int                NumberOfPropsRendered;
00359 
00360   // A temporary list of props used for culling, and traversal
00361   // of all props when rendering
00362   vtkProp            **PropArray;
00363   int                PropArrayCount;
00364 
00365   // A temporary list used for picking
00366   vtkAssemblyPath    **PathArray;
00367   int                PathArrayCount;
00368 
00369   // Indicates if the renderer should receive events from an interactor.
00370   // Typically only used in conjunction with transparent renderers.
00371   int                Interactive;
00372 
00373   // Shows what layer this renderer belongs to.  Only of interested when
00374   // there are layered renderers.
00375   int                Layer;
00376 
00377   // Holds the result of ComputeVisiblePropBounds so that it is visible from wrapped languages
00378   float              ComputedVisiblePropBounds[6];
00379 
00383   virtual int UpdateGeometry(void);
00384 
00387   virtual int UpdateCamera(void);
00388 
00392   virtual int UpdateLightGeometry(void);
00393 
00396   virtual int UpdateLights(void) {return 0;};
00397   
00398 private:
00399   vtkRenderer(const vtkRenderer&);  // Not implemented.
00400   void operator=(const vtkRenderer&);  // Not implemented.
00401 };
00402 
00403 inline vtkLightCollection *vtkRenderer::GetLights() {
00404   return this->Lights;
00405 }
00406 
00408 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
00409 
00410 
00411 #endif