VTK
vtkRenderer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRenderer.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
38 #ifndef vtkRenderer_h
39 #define vtkRenderer_h
40 
41 #include "vtkRenderingCoreModule.h" // For export macro
42 #include "vtkViewport.h"
43 
44 #include "vtkVolumeCollection.h" // Needed for access in inline members
45 #include "vtkActorCollection.h" // Needed for access in inline members
46 
47 class vtkFXAAOptions;
48 class vtkRenderWindow;
49 class vtkVolume;
50 class vtkCuller;
51 class vtkActor;
52 class vtkActor2D;
53 class vtkCamera;
54 class vtkInformation;
55 class vtkLightCollection;
57 class vtkLight;
60 class vtkRenderPass;
61 class vtkTexture;
62 
63 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
64 {
65 public:
66  vtkTypeMacro(vtkRenderer,vtkViewport);
67  void PrintSelf(ostream& os, vtkIndent indent);
68 
74  static vtkRenderer *New();
75 
77 
82  void AddActor(vtkProp *p);
83  void AddVolume(vtkProp *p);
84  void RemoveActor(vtkProp *p);
85  void RemoveVolume(vtkProp *p);
87 
91  void AddLight(vtkLight *);
92 
96  void RemoveLight(vtkLight *);
97 
101  void RemoveAllLights();
102 
106  vtkLightCollection *GetLights();
107 
114  void SetLightCollection(vtkLightCollection *lights);
115 
119  void CreateLight(void);
120 
126  virtual vtkLight *MakeLight();
127 
129 
135  vtkGetMacro(TwoSidedLighting,int);
136  vtkSetMacro(TwoSidedLighting,int);
137  vtkBooleanMacro(TwoSidedLighting,int);
139 
141 
154  vtkSetMacro(LightFollowCamera,int);
155  vtkGetMacro(LightFollowCamera,int);
156  vtkBooleanMacro(LightFollowCamera,int);
158 
160 
168  vtkGetMacro(AutomaticLightCreation,int);
169  vtkSetMacro(AutomaticLightCreation,int);
170  vtkBooleanMacro(AutomaticLightCreation,int);
172 
178  virtual int UpdateLightsGeometryToFollowCamera(void);
179 
183  vtkVolumeCollection *GetVolumes();
184 
188  vtkActorCollection *GetActors();
189 
193  void SetActiveCamera(vtkCamera *);
194 
200  vtkCamera *GetActiveCamera();
201 
207  virtual vtkCamera *MakeCamera();
208 
210 
216  vtkSetMacro(Erase, int);
217  vtkGetMacro(Erase, int);
218  vtkBooleanMacro(Erase, int);
220 
222 
227  vtkSetMacro(Draw, int);
228  vtkGetMacro(Draw, int);
229  vtkBooleanMacro(Draw, int);
231 
236  int CaptureGL2PSSpecialProp(vtkProp *);
237 
243  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
244 
248  void AddCuller(vtkCuller *);
249 
253  void RemoveCuller(vtkCuller *);
254 
258  vtkCullerCollection *GetCullers();
259 
261 
264  vtkSetVector3Macro(Ambient,double);
265  vtkGetVectorMacro(Ambient,double,3);
267 
269 
273  vtkSetMacro(AllocatedRenderTime,double);
274  virtual double GetAllocatedRenderTime();
276 
283  virtual double GetTimeFactor();
284 
291  virtual void Render();
292 
296  virtual void DeviceRender() =0;
297 
304  virtual void DeviceRenderOpaqueGeometry();
305 
313  virtual void DeviceRenderTranslucentPolygonalGeometry();
314 
319  virtual void ClearLights(void) {};
320 
324  virtual void Clear() {}
325 
329  int VisibleActorCount();
330 
334  int VisibleVolumeCount();
335 
340  void ComputeVisiblePropBounds( double bounds[6] );
341 
345  double *ComputeVisiblePropBounds();
346 
351  void ResetCameraClippingRange();
352 
354 
360  void ResetCameraClippingRange( double bounds[6] );
361  void ResetCameraClippingRange( double xmin, double xmax,
362  double ymin, double ymax,
363  double zmin, double zmax);
365 
367 
372  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
373  vtkGetMacro(NearClippingPlaneTolerance,double);
375 
377 
382  vtkSetClampMacro(ClippingRangeExpansion,double,0,0.99);
383  vtkGetMacro(ClippingRangeExpansion,double);
385 
392  virtual void ResetCamera();
393 
403  virtual void ResetCamera(double bounds[6]);
404 
408  virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax,
409  double zmin, double zmax);
410 
412 
418  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
419  virtual vtkWindow *GetVTKWindow();
421 
423 
429  vtkSetMacro(BackingStore,int);
430  vtkGetMacro(BackingStore,int);
431  vtkBooleanMacro(BackingStore,int);
433 
435 
440  vtkSetMacro(Interactive,int);
441  vtkGetMacro(Interactive,int);
442  vtkBooleanMacro(Interactive,int);
444 
446 
457  virtual void SetLayer(int layer);
458  vtkGetMacro(Layer, int);
460 
462 
472  vtkGetMacro(PreserveColorBuffer, int);
473  vtkSetMacro(PreserveColorBuffer, int);
474  vtkBooleanMacro(PreserveColorBuffer, int);
476 
478 
482  vtkSetMacro(PreserveDepthBuffer, int);
483  vtkGetMacro(PreserveDepthBuffer, int);
484  vtkBooleanMacro(PreserveDepthBuffer, int);
486 
491  int Transparent();
492 
496  void WorldToView();
497 
499 
502  void ViewToWorld();
503  virtual void ViewToWorld(double &wx, double &wy, double &wz);
505 
509  virtual void WorldToView(double &wx, double &wy, double &wz);
510 
515  double GetZ (int x, int y);
516 
521 
523 
526  vtkGetMacro( LastRenderTimeInSeconds, double );
528 
530 
536  vtkGetMacro( NumberOfPropsRendered, int );
538 
540 
547  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
548  {
549  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
550  }
551  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
552  double selectionX2, double selectionY2);
554 
560  virtual void StereoMidpoint() { return; };
561 
568  double GetTiledAspectRatio();
569 
576  { return (this->ActiveCamera != NULL); }
577 
578 
580 
590  vtkSetMacro(UseDepthPeeling,int);
591  vtkGetMacro(UseDepthPeeling,int);
592  vtkBooleanMacro(UseDepthPeeling,int);
594 
596 
605  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
606  vtkGetMacro(OcclusionRatio,double);
608 
610 
615  vtkSetMacro(MaximumNumberOfPeels,int);
616  vtkGetMacro(MaximumNumberOfPeels,int);
618 
620 
625  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
627 
629 
635  void SetDelegate(vtkRendererDelegate *d);
636  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
638 
640 
645  vtkGetObjectMacro(Selector, vtkHardwareSelector);
647 
649 
653  virtual void SetBackgroundTexture(vtkTexture*);
654  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
656 
658 
662  vtkSetMacro(TexturedBackground,bool);
663  vtkGetMacro(TexturedBackground,bool);
664  vtkBooleanMacro(TexturedBackground,bool);
666 
667  // method to release graphics resources in any derived renderers.
668  virtual void ReleaseGraphicsResources(vtkWindow *);
669 
671 
674  vtkSetMacro(UseFXAA, bool)
675  vtkGetMacro(UseFXAA, bool)
676  vtkBooleanMacro(UseFXAA, bool)
678 
680 
683  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
684  virtual void SetFXAAOptions(vtkFXAAOptions*);
686 
688 
692  vtkSetMacro(UseShadows,int);
693  vtkGetMacro(UseShadows,int);
694  vtkBooleanMacro(UseShadows,int);
696 
698 
702  vtkSetMacro(UseHiddenLineRemoval, int)
703  vtkGetMacro(UseHiddenLineRemoval, int)
704  vtkBooleanMacro(UseHiddenLineRemoval, int)
706 
707  // Set/Get a custom render pass.
708  // Initial value is NULL.
709  void SetPass(vtkRenderPass *p);
710  vtkGetObjectMacro(Pass, vtkRenderPass);
711 
713 
716  vtkGetObjectMacro(Information, vtkInformation);
717  virtual void SetInformation(vtkInformation*);
719 
720 protected:
721  vtkRenderer();
722  ~vtkRenderer();
723 
724  // internal method for doing a render for picking purposes
725  virtual void PickRender(vtkPropCollection *props);
726  virtual void PickGeometry();
727 
728  // internal method to expand bounding box to consider model transform
729  // matrix or model view transform matrix based on whether or not deering
730  // frustum is used.
731  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
732 
735 
738 
741 
742  double Ambient[3];
745  double TimeFactor;
749  unsigned char *BackingImage;
750  int BackingStoreSize[2];
752 
754 
756 
757  // Allocate the time for each prop
758  void AllocateTime();
759 
760  // Internal variables indicating the number of props
761  // that have been or will be rendered in each category.
763 
764  // A temporary list of props used for culling, and traversal
765  // of all props when rendering
768 
769  // A temporary list used for picking
772 
773  // Indicates if the renderer should receive events from an interactor.
774  // Typically only used in conjunction with transparent renderers.
776 
777  // Shows what layer this renderer belongs to. Only of interested when
778  // there are layered renderers.
779  int Layer;
782 
783  // Holds the result of ComputeVisiblePropBounds so that it is visible from
784  // wrapped languages
785  double ComputedVisiblePropBounds[6];
786 
795 
801 
808  int Erase;
809 
815  int Draw;
816 
821 
827  virtual int UpdateGeometry();
828 
836  virtual int UpdateTranslucentPolygonalGeometry();
837 
843  virtual int UpdateOpaquePolygonalGeometry();
844 
849  virtual int UpdateCamera(void);
850 
856  virtual int UpdateLightGeometry(void);
857 
862  virtual int UpdateLights(void) {return 0;}
863 
869  vtkCamera *GetActiveCameraAndResetIfCreated();
870 
875  bool UseFXAA;
876 
881 
887 
893 
901 
912 
919 
926 
927  // HARDWARE SELECTION ----------------------------------------
928  friend class vtkHardwareSelector;
929 
934  { this->Selector = selector; this->Modified(); }
935 
936  // End Ivars for visible cell selecting.
938 
939  //---------------------------------------------------------------
940  friend class vtkRendererDelegate;
942 
945 
946  friend class vtkRenderPass;
948 
949  // Arbitrary extra information associated with this renderer
951 
952 private:
953  vtkRenderer(const vtkRenderer&) VTK_DELETE_FUNCTION;
954  void operator=(const vtkRenderer&) VTK_DELETE_FUNCTION;
955 
956 };
957 
959  return this->Lights;
960 }
961 
966 
967 #endif
vtkVolumeCollection
a list of volumes
Definition: vtkVolumeCollection.h:35
vtkLight
a virtual light for 3D rendering
Definition: vtkLight.h:61
vtkRenderer::ClippingRangeExpansion
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:800
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
vtkRenderer::Pass
vtkRenderPass * Pass
Definition: vtkRenderer.h:947
vtkRenderer::UseHiddenLineRemoval
int UseHiddenLineRemoval
When this flag is on and the rendering engine supports it, wireframe polydata will be rendered using ...
Definition: vtkRenderer.h:892
vtkRenderer::Clear
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:324
vtkRenderer::IsActiveCameraCreated
int IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:575
vtkRenderer::UpdateLights
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:862
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkRenderer::PreserveColorBuffer
int PreserveColorBuffer
Definition: vtkRenderer.h:780
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkLightCollection
a list of lights
Definition: vtkLightCollection.h:38
vtkRenderer::AllocatedRenderTime
double AllocatedRenderTime
Definition: vtkRenderer.h:744
vtkRenderer::ClearLights
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:319
vtkRenderer::UseDepthPeeling
int UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:900
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkRenderer::RenderTime
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:751
vtkFXAAOptions
Configuration for FXAA implementations.
Definition: vtkFXAAOptions.h:30
vtkRenderer::OcclusionRatio
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:911
SetRenderWindow
virtual void SetRenderWindow(vtkRenderWindow *renwin)
Updates the extensions string.
vtkViewport::PickProp
virtual vtkAssemblyPath * PickProp(double selectionX, double selectionY)=0
Return the Prop that has the highest z value at the given x, y position in the viewport.
vtkViewport.h
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:41
vtkRenderer::BackingImage
unsigned char * BackingImage
Definition: vtkRenderer.h:749
vtkRenderer::StereoMidpoint
virtual void StereoMidpoint()
Do anything necessary between rendering the left and right viewpoints in a stereo render.
Definition: vtkRenderer.h:560
vtkRenderer::RenderWindow
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:743
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkRenderer::Layer
int Layer
Definition: vtkRenderer.h:779
vtkRenderer::UseFXAA
bool UseFXAA
If this flag is on and the rendering engine supports it, FXAA will be used to antialias the scene.
Definition: vtkRenderer.h:875
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkRenderer::SetSelector
void SetSelector(vtkHardwareSelector *selector)
Called by vtkHardwareSelector when it begins rendering for selection.
Definition: vtkRenderer.h:933
vtkRendererDelegate
Render the props of a vtkRenderer.
Definition: vtkRendererDelegate.h:37
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:70
vtkActorCollection.h
vtkRenderer::LastRenderTimeInSeconds
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:753
vtkRenderer::ActiveCamera
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:733
vtkVolumeCollection.h
vtkRenderer::Volumes
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:740
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkRenderer::Cullers
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:737
vtkHardwareSelector
manager for OpenGL-based selection.
Definition: vtkHardwareSelector.h:78
vtkRenderer::GetLights
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:958
vtkViewport::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkRenderer::Delegate
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:941
vtkRenderer::PropArrayCount
int PropArrayCount
Definition: vtkRenderer.h:767
vtkRenderer::TimeFactor
double TimeFactor
Definition: vtkRenderer.h:745
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkCuller
a superclass for prop cullers
Definition: vtkCuller.h:40
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkRenderer::PathArrayCount
int PathArrayCount
Definition: vtkRenderer.h:771
vtkRenderer::Erase
int Erase
When this flag is off, the renderer will not erase the background or the Zbuffer.
Definition: vtkRenderer.h:808
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkRenderer::PropArray
vtkProp ** PropArray
Definition: vtkRenderer.h:766
vtkCullerCollection
a list of Cullers
Definition: vtkCullerCollection.h:34
vtkRenderer::FXAAOptions
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:880
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkRenderer::Actors
vtkActorCollection * Actors
Definition: vtkRenderer.h:739
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkViewport::ViewToWorld
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkRenderer::Interactive
int Interactive
Definition: vtkRenderer.h:775
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkRenderer::LightFollowCamera
int LightFollowCamera
Definition: vtkRenderer.h:755
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkRenderer::AutomaticLightCreation
int AutomaticLightCreation
Definition: vtkRenderer.h:747
vtkRenderer::LastRenderingUsedDepthPeeling
int LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling.
Definition: vtkRenderer.h:925
vtkViewport::GetVTKWindow
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
vtkRenderer::GL2PSSpecialPropCollection
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:820
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:45
vtkRenderer::Selector
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:937
vtkRenderer::Lights
vtkLightCollection * Lights
Definition: vtkRenderer.h:736
vtkRenderer::NearClippingPlaneTolerance
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:794
vtkRenderer::UseShadows
int UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off.
Definition: vtkRenderer.h:886
vtkRenderer::BackgroundTexture
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:944
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkRenderer::TwoSidedLighting
int TwoSidedLighting
Definition: vtkRenderer.h:746
vtkRenderer::Draw
int Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:815
vtkRenderer::TexturedBackground
bool TexturedBackground
Definition: vtkRenderer.h:943
vtkRenderer::PickProp
vtkAssemblyPath * PickProp(double selectionX, double selectionY)
Return the prop (via a vtkAssemblyPath) that has the highest z value at the given x,...
Definition: vtkRenderer.h:547
vtkActorCollection
a list of actors
Definition: vtkActorCollection.h:39
vtkRenderer::PreserveDepthBuffer
int PreserveDepthBuffer
Definition: vtkRenderer.h:781
vtkRenderer::MaximumNumberOfPeels
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:918
vtkRenderer::PathArray
vtkAssemblyPath ** PathArray
Definition: vtkRenderer.h:770
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:86
vtkRenderer::GetRenderWindow
vtkRenderWindow * GetRenderWindow()
Definition: vtkRenderer.h:418
vtkRenderer::CreatedLight
vtkLight * CreatedLight
Definition: vtkRenderer.h:734
vtkPropCollection
a list of Props
Definition: vtkPropCollection.h:38
vtkViewport::WorldToView
virtual void WorldToView()
Convert world point coordinates to view coordinates.
vtkRenderer::GetCullers
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:965
vtkRenderer::NumberOfPropsRendered
int NumberOfPropsRendered
Definition: vtkRenderer.h:762
vtkRenderer::Information
vtkInformation * Information
Definition: vtkRenderer.h:950
vtkRenderer::BackingStore
int BackingStore
Definition: vtkRenderer.h:748
vtkRenderPass
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:58