VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Core/vtkRenderer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkRenderer.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 =========================================================================*/
00040 #ifndef vtkRenderer_h
00041 #define vtkRenderer_h
00042 
00043 #include "vtkRenderingCoreModule.h" // For export macro
00044 #include "vtkViewport.h"
00045 
00046 #include "vtkVolumeCollection.h" // Needed for access in inline members
00047 #include "vtkActorCollection.h" // Needed for access in inline members
00048 
00049 class vtkRenderWindow;
00050 class vtkVolume;
00051 class vtkCuller;
00052 class vtkActor;
00053 class vtkActor2D;
00054 class vtkCamera;
00055 class vtkLightCollection;
00056 class vtkCullerCollection;
00057 class vtkLight;
00058 class vtkPainter;
00059 class vtkHardwareSelector;
00060 class vtkRendererDelegate;
00061 class vtkTexture;
00062 
00063 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
00064 {
00065 public:
00066   vtkTypeMacro(vtkRenderer,vtkViewport);
00067   void PrintSelf(ostream& os, vtkIndent indent);
00068 
00072   static vtkRenderer *New();
00073 
00075 
00078   void AddActor(vtkProp *p);
00079   void AddVolume(vtkProp *p);
00080   void RemoveActor(vtkProp *p);
00081   void RemoveVolume(vtkProp *p);
00083 
00085   void AddLight(vtkLight *);
00086 
00088   void RemoveLight(vtkLight *);
00089 
00091   void RemoveAllLights();
00092 
00094   vtkLightCollection *GetLights();
00095 
00099   void SetLightCollection(vtkLightCollection *lights);
00100 
00102   void CreateLight(void);
00103 
00107   virtual vtkLight *MakeLight();
00108 
00110 
00114   vtkGetMacro(TwoSidedLighting,int);
00115   vtkSetMacro(TwoSidedLighting,int);
00116   vtkBooleanMacro(TwoSidedLighting,int);
00118 
00120 
00130   vtkSetMacro(LightFollowCamera,int);
00131   vtkGetMacro(LightFollowCamera,int);
00132   vtkBooleanMacro(LightFollowCamera,int);
00134 
00136 
00142   vtkGetMacro(AutomaticLightCreation,int);
00143   vtkSetMacro(AutomaticLightCreation,int);
00144   vtkBooleanMacro(AutomaticLightCreation,int);
00146 
00150   virtual int UpdateLightsGeometryToFollowCamera(void);
00151 
00153   vtkVolumeCollection *GetVolumes();
00154 
00156   vtkActorCollection *GetActors();
00157 
00159   void SetActiveCamera(vtkCamera *);
00160 
00164   vtkCamera *GetActiveCamera();
00165 
00169   virtual vtkCamera *MakeCamera();
00170 
00172 
00176   vtkSetMacro(Erase, int);
00177   vtkGetMacro(Erase, int);
00178   vtkBooleanMacro(Erase, int);
00180 
00182 
00185   vtkSetMacro(Draw, int);
00186   vtkGetMacro(Draw, int);
00187   vtkBooleanMacro(Draw, int);
00189 
00193   int CaptureGL2PSSpecialProp(vtkProp *);
00194 
00198   void SetGL2PSSpecialPropCollection(vtkPropCollection *);
00199 
00201   void AddCuller(vtkCuller *);
00202 
00204   void RemoveCuller(vtkCuller *);
00205 
00207   vtkCullerCollection *GetCullers();
00208 
00210 
00211   vtkSetVector3Macro(Ambient,double);
00212   vtkGetVectorMacro(Ambient,double,3);
00214 
00216 
00218   vtkSetMacro(AllocatedRenderTime,double);
00219   virtual double GetAllocatedRenderTime();
00221 
00226   virtual double GetTimeFactor();
00227 
00232   virtual void Render();
00233 
00236   virtual void DeviceRender() =0;
00237 
00242   virtual void DeviceRenderTranslucentPolygonalGeometry();
00243 
00245   virtual void Clear() {}
00246 
00248   int VisibleActorCount();
00249 
00251   int VisibleVolumeCount();
00252 
00255   void ComputeVisiblePropBounds( double bounds[6] );
00256 
00258   double *ComputeVisiblePropBounds();
00259 
00262   void ResetCameraClippingRange();
00263 
00265 
00268   void ResetCameraClippingRange( double bounds[6] );
00269   void ResetCameraClippingRange( double xmin, double xmax,
00270                                  double ymin, double ymax,
00271                                  double zmin, double zmax);
00273 
00275 
00279   vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
00280   vtkGetMacro(NearClippingPlaneTolerance,double);
00282 
00288   void ResetCamera();
00289 
00297   void ResetCamera(double bounds[6]);
00298 
00300 
00301   void ResetCamera(double xmin, double xmax, double ymin, double ymax,
00302                    double zmin, double zmax);
00304 
00306 
00309   void SetRenderWindow(vtkRenderWindow *);
00310   vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
00311   virtual vtkWindow *GetVTKWindow();
00313 
00315 
00318   vtkSetMacro(BackingStore,int);
00319   vtkGetMacro(BackingStore,int);
00320   vtkBooleanMacro(BackingStore,int);
00322 
00324 
00327   vtkSetMacro(Interactive,int);
00328   vtkGetMacro(Interactive,int);
00329   vtkBooleanMacro(Interactive,int);
00331 
00333 
00335   vtkSetMacro(Layer, int);
00336   vtkGetMacro(Layer, int);
00338 
00340 
00342   vtkSetMacro(PreserveDepthBuffer, int);
00343   vtkGetMacro(PreserveDepthBuffer, int);
00344   vtkBooleanMacro(PreserveDepthBuffer, int);
00346 
00349   int  Transparent();
00350 
00352   void WorldToView();
00353 
00355 
00356   void ViewToWorld();
00357   virtual void ViewToWorld(double &wx, double &wy, double &wz);
00359 
00361   virtual void WorldToView(double &wx, double &wy, double &wz);
00362 
00365   double GetZ (int x, int y);
00366 
00368   unsigned long GetMTime();
00369 
00371 
00372   vtkGetMacro( LastRenderTimeInSeconds, double );
00374 
00376 
00380   vtkGetMacro( NumberOfPropsRendered, int );
00382 
00384 
00389   vtkAssemblyPath* PickProp(double selectionX, double selectionY)
00390     {
00391     return this->PickProp(selectionX, selectionY, selectionX, selectionY);
00392     }
00393   vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
00394                             double selectionX2, double selectionY2);
00396 
00400   virtual void StereoMidpoint() { return; };
00401 
00406   double GetTiledAspectRatio();
00407 
00409 
00412   int IsActiveCameraCreated()
00413     { return (this->ActiveCamera != NULL); }
00415 
00416 
00418 
00425   vtkSetMacro(UseDepthPeeling,int);
00426   vtkGetMacro(UseDepthPeeling,int);
00427   vtkBooleanMacro(UseDepthPeeling,int);
00429 
00431 
00438   vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
00439   vtkGetMacro(OcclusionRatio,double);
00441 
00443 
00446   vtkSetMacro(MaximumNumberOfPeels,int);
00447   vtkGetMacro(MaximumNumberOfPeels,int);
00449 
00451 
00453   vtkGetMacro(LastRenderingUsedDepthPeeling,int);
00455 
00457 
00461   void SetDelegate(vtkRendererDelegate *d);
00462   vtkGetObjectMacro(Delegate,vtkRendererDelegate);
00464 
00466 
00469   vtkGetObjectMacro(Selector, vtkHardwareSelector);
00471 
00473 
00475   void SetBackgroundTexture(vtkTexture*);
00476   vtkGetObjectMacro(BackgroundTexture, vtkTexture);
00478 
00480 
00482   vtkSetMacro(TexturedBackground,bool);
00483   vtkGetMacro(TexturedBackground,bool);
00484   vtkBooleanMacro(TexturedBackground,bool);
00486 
00487   // method to release graphics resources in any derived renderers.
00488   virtual void ReleaseGraphicsResources(vtkWindow *) { }
00489 
00490 //BTX
00491 protected:
00492   vtkRenderer();
00493   ~vtkRenderer();
00494 
00495   // internal method for doing a render for picking purposes
00496   virtual void PickRender(vtkPropCollection *props);
00497   virtual void PickGeometry();
00498 
00499   // internal method to expand bounding box to consider model transform
00500   // matrix or model view transform matrix based on whether or not deering
00501   // frustum is used.
00502   virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
00503 
00504   vtkCamera *ActiveCamera;
00505   vtkLight  *CreatedLight;
00506 
00507   vtkLightCollection *Lights;
00508   vtkCullerCollection *Cullers;
00509 
00510   vtkActorCollection *Actors;
00511   vtkVolumeCollection *Volumes;
00512 
00513   double              Ambient[3];
00514   vtkRenderWindow    *RenderWindow;
00515   double              AllocatedRenderTime;
00516   double              TimeFactor;
00517   int                TwoSidedLighting;
00518   int                AutomaticLightCreation;
00519   int                BackingStore;
00520   unsigned char      *BackingImage;
00521   int                BackingStoreSize[2];
00522   vtkTimeStamp       RenderTime;
00523 
00524   double              LastRenderTimeInSeconds;
00525 
00526   int                LightFollowCamera;
00527 
00528   // Allocate the time for each prop
00529   void               AllocateTime();
00530 
00531   // Internal variables indicating the number of props
00532   // that have been or will be rendered in each category.
00533   int                NumberOfPropsRendered;
00534 
00535   // A temporary list of props used for culling, and traversal
00536   // of all props when rendering
00537   vtkProp            **PropArray;
00538   int                PropArrayCount;
00539 
00540   // A temporary list used for picking
00541   vtkAssemblyPath    **PathArray;
00542   int                PathArrayCount;
00543 
00544   // Indicates if the renderer should receive events from an interactor.
00545   // Typically only used in conjunction with transparent renderers.
00546   int                Interactive;
00547 
00548   // Shows what layer this renderer belongs to.  Only of interested when
00549   // there are layered renderers.
00550   int                Layer;
00551   int                PreserveDepthBuffer;
00552 
00553   // Holds the result of ComputeVisiblePropBounds so that it is visible from
00554   // wrapped languages
00555   double              ComputedVisiblePropBounds[6];
00556 
00562   double              NearClippingPlaneTolerance;
00563 
00568   int Erase;
00569 
00573   int Draw;
00574 
00577   vtkPropCollection *GL2PSSpecialPropCollection;
00578 
00579   // Friend class to allow render passes to access functions.
00580   friend class vtkRenderPass;
00581 
00585   virtual int UpdateGeometry();
00586 
00591   virtual int UpdateTranslucentPolygonalGeometry();
00592 
00595   virtual int UpdateCamera(void);
00596 
00600   virtual int UpdateLightGeometry(void);
00601 
00604   virtual int UpdateLights(void) {return 0;}
00605 
00608   vtkCamera *GetActiveCameraAndResetIfCreated();
00609 
00613   int UseDepthPeeling;
00614 
00622   double OcclusionRatio;
00623 
00627   int MaximumNumberOfPeels;
00628 
00631   int LastRenderingUsedDepthPeeling;
00632 
00633   // HARDWARE SELECTION ----------------------------------------
00634   friend class vtkHardwareSelector;
00635 
00637 
00638   void SetSelector(vtkHardwareSelector* selector)
00639     { this->Selector = selector; this->Modified(); }
00641 
00642   // End Ivars for visible cell selecting.
00643   vtkHardwareSelector* Selector;
00644 
00645   //---------------------------------------------------------------
00646   friend class vtkRendererDelegate;
00647   vtkRendererDelegate *Delegate;
00648 
00649   bool TexturedBackground;
00650   vtkTexture* BackgroundTexture;
00651 
00652 private:
00653   vtkRenderer(const vtkRenderer&);  // Not implemented.
00654   void operator=(const vtkRenderer&);  // Not implemented.
00655 //ETX
00656 };
00657 
00658 inline vtkLightCollection *vtkRenderer::GetLights() {
00659   return this->Lights;
00660 }
00661 
00663 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
00664 
00665 #endif