Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 
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 =========================================================================*/
00040 #ifndef __vtkRenderer_h
00041 #define __vtkRenderer_h
00042 
00043 #include "vtkViewport.h"
00044 
00045 #include "vtkVolumeCollection.h" // Needed for access in inline members
00046 #include "vtkActorCollection.h" // Needed for access in inline members
00047 
00048 class vtkRenderWindow;
00049 class vtkVolume;
00050 class vtkCuller;
00051 class vtkActor;
00052 class vtkActor2D;
00053 class vtkCamera;
00054 class vtkLightCollection;
00055 class vtkCullerCollection;
00056 class vtkLight;
00057 
00058 class VTK_RENDERING_EXPORT vtkRenderer : public vtkViewport
00059 {
00060 public:
00061   vtkTypeRevisionMacro(vtkRenderer,vtkViewport);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00067   static vtkRenderer *New();
00068 
00070 
00073   void AddActor(vtkProp *p) {this->AddProp(p);};
00074   void AddVolume(vtkProp *p) {this->AddProp(p);};
00075   void RemoveActor(vtkProp *p) {this->Actors->RemoveItem(p);this->RemoveProp(p);};
00076   void RemoveVolume(vtkProp *p) {this->Volumes->RemoveItem(p);this->RemoveProp(p);};
00078 
00080   void AddLight(vtkLight *);
00081 
00083   void RemoveLight(vtkLight *);
00084 
00086   vtkLightCollection *GetLights();
00087   
00089   void CreateLight(void);
00090   
00094   virtual vtkLight *MakeLight();
00095 
00097 
00101   vtkGetMacro(TwoSidedLighting,int);
00102   vtkSetMacro(TwoSidedLighting,int);
00103   vtkBooleanMacro(TwoSidedLighting,int);
00105 
00107 
00117   vtkSetMacro(LightFollowCamera,int);
00118   vtkGetMacro(LightFollowCamera,int);
00119   vtkBooleanMacro(LightFollowCamera,int);
00121 
00123 
00129   vtkGetMacro(AutomaticLightCreation,int);
00130   vtkSetMacro(AutomaticLightCreation,int);
00131   vtkBooleanMacro(AutomaticLightCreation,int);
00133 
00137   virtual int UpdateLightsGeometryToFollowCamera(void);
00138 
00140   vtkVolumeCollection *GetVolumes();
00141 
00143   vtkActorCollection *GetActors();
00144 
00146   void SetActiveCamera(vtkCamera *);
00147 
00149   vtkCamera *GetActiveCamera();
00150 
00154   virtual vtkCamera *MakeCamera();
00155 
00157   void AddCuller(vtkCuller *);
00158 
00160   void RemoveCuller(vtkCuller *);
00161 
00163   vtkCullerCollection *GetCullers();
00164 
00166 
00167   vtkSetVector3Macro(Ambient,double);
00168   vtkGetVectorMacro(Ambient,double,3);
00170 
00172 
00174   vtkSetMacro(AllocatedRenderTime,double);
00175   virtual double GetAllocatedRenderTime();
00177 
00182   virtual double GetTimeFactor();
00183 
00186   virtual void Render();
00187 
00190   virtual void DeviceRender() =0;
00191 
00193   virtual void Clear() {};
00194 
00196   int VisibleActorCount();
00197 
00199   int VisibleVolumeCount();
00200 
00203   void ComputeVisiblePropBounds( double bounds[6] );
00204 
00206   double *ComputeVisiblePropBounds();
00207 
00210   void ResetCameraClippingRange();
00211 
00213 
00215   void ResetCameraClippingRange( double bounds[6] );
00216   void ResetCameraClippingRange( double xmin, double xmax, 
00217                                  double ymin, double ymax, 
00218                                  double zmin, double zmax);
00220 
00222 
00224   vtkSetMacro(NearClippingPlaneTolerance,double);
00225   vtkGetMacro(NearClippingPlaneTolerance,double);
00227 
00233   void ResetCamera();
00234 
00242   void ResetCamera(double bounds[6]);
00243 
00245 
00246   void ResetCamera(double xmin, double xmax, double ymin, double ymax, 
00247                    double zmin, double zmax);
00249 
00251 
00254   void SetRenderWindow(vtkRenderWindow *);
00255   vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
00256   virtual vtkWindow *GetVTKWindow();
00258   
00260 
00263   vtkSetMacro(BackingStore,int);
00264   vtkGetMacro(BackingStore,int);
00265   vtkBooleanMacro(BackingStore,int);
00267 
00269 
00272   vtkSetMacro(Interactive,int);
00273   vtkGetMacro(Interactive,int);
00274   vtkBooleanMacro(Interactive,int);
00276 
00278 
00280   vtkSetMacro(Layer, int);
00281   vtkGetMacro(Layer, int);
00283 
00286   int  Transparent();
00287 
00289   void WorldToView();
00290 
00292 
00293   void ViewToWorld();
00294   virtual void ViewToWorld(double &wx, double &wy, double &wz);
00296 
00298   virtual void WorldToView(double &wx, double &wy, double &wz);
00299 
00301   double GetZ (int x, int y);
00302 
00304   unsigned long GetMTime();
00305 
00307 
00308   vtkGetMacro( LastRenderTimeInSeconds, double );
00310 
00312 
00316   vtkGetMacro( NumberOfPropsRendered, int );
00318 
00324   vtkAssemblyPath* PickProp(double selectionX, double selectionY);
00325 
00326 protected:
00327   vtkRenderer();
00328   ~vtkRenderer();
00329 
00330   // internal method for doing a render for picking purposes
00331   virtual void PickRender(vtkPropCollection *props);
00332   virtual void PickGeometry();
00333   
00334   vtkCamera *ActiveCamera;
00335   vtkLight  *CreatedLight;
00336 
00337   vtkLightCollection *Lights;
00338   vtkCullerCollection *Cullers;
00339 
00340   vtkActorCollection *Actors;
00341   vtkVolumeCollection *Volumes;
00342   
00343   double              Ambient[3];  
00344   vtkRenderWindow    *RenderWindow;
00345   double              AllocatedRenderTime;
00346   double              TimeFactor;
00347   int                TwoSidedLighting;
00348   int                AutomaticLightCreation;
00349   int                BackingStore;
00350   unsigned char      *BackingImage;
00351   vtkTimeStamp       RenderTime;
00352 
00353   double              LastRenderTimeInSeconds;
00354 
00355   int                LightFollowCamera;
00356 
00357   // Allocate the time for each prop
00358   void               AllocateTime();
00359 
00360   // Internal variables indicating the number of props
00361   // that have been or will be rendered in each category.
00362   int                NumberOfPropsRendered;
00363 
00364   // A temporary list of props used for culling, and traversal
00365   // of all props when rendering
00366   vtkProp            **PropArray;
00367   int                PropArrayCount;
00368 
00369   // A temporary list used for picking
00370   vtkAssemblyPath    **PathArray;
00371   int                PathArrayCount;
00372 
00373   // Indicates if the renderer should receive events from an interactor.
00374   // Typically only used in conjunction with transparent renderers.
00375   int                Interactive;
00376 
00377   // Shows what layer this renderer belongs to.  Only of interested when
00378   // there are layered renderers.
00379   int                Layer;
00380 
00381   // Holds the result of ComputeVisiblePropBounds so that it is visible from
00382   // wrapped languages
00383   double              ComputedVisiblePropBounds[6];
00384 
00390   double              NearClippingPlaneTolerance;
00391 
00395   virtual int UpdateGeometry(void);
00396 
00399   virtual int UpdateCamera(void);
00400 
00404   virtual int UpdateLightGeometry(void);
00405 
00408   virtual int UpdateLights(void) {return 0;};
00409   
00410 private:
00411   vtkRenderer(const vtkRenderer&);  // Not implemented.
00412   void operator=(const vtkRenderer&);  // Not implemented.
00413 };
00414 
00415 inline vtkLightCollection *vtkRenderer::GetLights() {
00416   return this->Lights;
00417 }
00418 
00420 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
00421 
00422 
00423 #endif