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;
55 class vtkInformation;
56 class vtkLightCollection;
58 class vtkLight;
61 class vtkRenderPass;
62 class vtkTexture;
63 
64 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
65 {
66 public:
67  vtkTypeMacro(vtkRenderer,vtkViewport);
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
75  static vtkRenderer *New();
76 
78 
83  void AddActor(vtkProp *p);
84  void AddVolume(vtkProp *p);
85  void RemoveActor(vtkProp *p);
86  void RemoveVolume(vtkProp *p);
88 
92  void AddLight(vtkLight *);
93 
97  void RemoveLight(vtkLight *);
98 
102  void RemoveAllLights();
103 
107  vtkLightCollection *GetLights();
108 
115  void SetLightCollection(vtkLightCollection *lights);
116 
120  void CreateLight(void);
121 
127  virtual vtkLight *MakeLight();
128 
130 
136  vtkGetMacro(TwoSidedLighting,vtkTypeBool);
137  vtkSetMacro(TwoSidedLighting,vtkTypeBool);
138  vtkBooleanMacro(TwoSidedLighting,vtkTypeBool);
140 
142 
155  vtkSetMacro(LightFollowCamera,vtkTypeBool);
156  vtkGetMacro(LightFollowCamera,vtkTypeBool);
157  vtkBooleanMacro(LightFollowCamera,vtkTypeBool);
159 
161 
169  vtkGetMacro(AutomaticLightCreation,vtkTypeBool);
170  vtkSetMacro(AutomaticLightCreation,vtkTypeBool);
171  vtkBooleanMacro(AutomaticLightCreation,vtkTypeBool);
173 
179  virtual int UpdateLightsGeometryToFollowCamera(void);
180 
184  vtkVolumeCollection *GetVolumes();
185 
189  vtkActorCollection *GetActors();
190 
194  void SetActiveCamera(vtkCamera *);
195 
201  vtkCamera *GetActiveCamera();
202 
208  virtual vtkCamera *MakeCamera();
209 
211 
217  vtkSetMacro(Erase, vtkTypeBool);
218  vtkGetMacro(Erase, vtkTypeBool);
219  vtkBooleanMacro(Erase, vtkTypeBool);
221 
223 
228  vtkSetMacro(Draw, vtkTypeBool);
229  vtkGetMacro(Draw, vtkTypeBool);
230  vtkBooleanMacro(Draw, vtkTypeBool);
232 
237  int CaptureGL2PSSpecialProp(vtkProp *);
238 
244  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
245 
249  void AddCuller(vtkCuller *);
250 
254  void RemoveCuller(vtkCuller *);
255 
259  vtkCullerCollection *GetCullers();
260 
262 
265  vtkSetVector3Macro(Ambient,double);
266  vtkGetVectorMacro(Ambient,double,3);
268 
270 
274  vtkSetMacro(AllocatedRenderTime,double);
275  virtual double GetAllocatedRenderTime();
277 
284  virtual double GetTimeFactor();
285 
292  virtual void Render();
293 
297  virtual void DeviceRender() =0;
298 
305  virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
306 
316  virtual void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
317 
322  virtual void ClearLights(void) {};
323 
327  virtual void Clear() {}
328 
332  int VisibleActorCount();
333 
337  int VisibleVolumeCount();
338 
343  void ComputeVisiblePropBounds( double bounds[6] );
344 
348  double *ComputeVisiblePropBounds() VTK_SIZEHINT(6);
349 
354  virtual void ResetCameraClippingRange();
355 
357 
363  virtual void ResetCameraClippingRange( double bounds[6] );
364  virtual void ResetCameraClippingRange( double xmin, double xmax,
365  double ymin, double ymax,
366  double zmin, double zmax);
368 
370 
375  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
376  vtkGetMacro(NearClippingPlaneTolerance,double);
378 
380 
385  vtkSetClampMacro(ClippingRangeExpansion,double,0,0.99);
386  vtkGetMacro(ClippingRangeExpansion,double);
388 
395  virtual void ResetCamera();
396 
406  virtual void ResetCamera(double bounds[6]);
407 
411  virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax,
412  double zmin, double zmax);
413 
415 
420  void SetRenderWindow(vtkRenderWindow *);
421  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
422  vtkWindow *GetVTKWindow() override;
424 
426 
432  vtkSetMacro(BackingStore,vtkTypeBool);
433  vtkGetMacro(BackingStore,vtkTypeBool);
434  vtkBooleanMacro(BackingStore,vtkTypeBool);
436 
438 
443  vtkSetMacro(Interactive,vtkTypeBool);
444  vtkGetMacro(Interactive,vtkTypeBool);
445  vtkBooleanMacro(Interactive,vtkTypeBool);
447 
449 
460  virtual void SetLayer(int layer);
461  vtkGetMacro(Layer, int);
463 
465 
475  vtkGetMacro(PreserveColorBuffer, vtkTypeBool);
476  vtkSetMacro(PreserveColorBuffer, vtkTypeBool);
477  vtkBooleanMacro(PreserveColorBuffer, vtkTypeBool);
479 
481 
485  vtkSetMacro(PreserveDepthBuffer, vtkTypeBool);
486  vtkGetMacro(PreserveDepthBuffer, vtkTypeBool);
487  vtkBooleanMacro(PreserveDepthBuffer, vtkTypeBool);
489 
494  int Transparent();
495 
499  void WorldToView() override;
500 
502 
505  void ViewToWorld() override;
506  void ViewToWorld(double &wx, double &wy, double &wz) override;
508 
512  void WorldToView(double &wx, double &wy, double &wz) override;
513 
515 
518  void WorldToPose(double &wx, double &wy, double &wz) override;
519  void PoseToWorld(double &wx, double &wy, double &wz) override;
520  void ViewToPose(double &wx, double &wy, double &wz) override;
521  void PoseToView(double &wx, double &wy, double &wz) override;
523 
528  double GetZ (int x, int y);
529 
533  vtkMTimeType GetMTime() override;
534 
536 
539  vtkGetMacro( LastRenderTimeInSeconds, double );
541 
543 
549  vtkGetMacro( NumberOfPropsRendered, int );
551 
553 
560  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
561  {
562  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
563  }
564  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
565  double selectionX2, double selectionY2) override;
567 
573  virtual void StereoMidpoint() { return; };
574 
581  double GetTiledAspectRatio();
582 
589  { return (this->ActiveCamera != nullptr); }
590 
591 
593 
603  vtkSetMacro(UseDepthPeeling,vtkTypeBool);
604  vtkGetMacro(UseDepthPeeling,vtkTypeBool);
605  vtkBooleanMacro(UseDepthPeeling,vtkTypeBool);
607 
613  vtkSetMacro(UseDepthPeelingForVolumes, bool)
614  vtkGetMacro(UseDepthPeelingForVolumes, bool)
615  vtkBooleanMacro(UseDepthPeelingForVolumes, bool)
616 
617  //@{
627  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
628  vtkGetMacro(OcclusionRatio,double);
630 
632 
637  vtkSetMacro(MaximumNumberOfPeels,int);
638  vtkGetMacro(MaximumNumberOfPeels,int);
640 
642 
647  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
649 
651 
657  void SetDelegate(vtkRendererDelegate *d);
658  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
660 
662 
667  vtkGetObjectMacro(Selector, vtkHardwareSelector);
669 
671 
676  virtual void SetLeftBackgroundTexture(vtkTexture*);
677  vtkTexture* GetLeftBackgroundTexture();
678  virtual void SetBackgroundTexture(vtkTexture*);
679  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
681 
683 
687  virtual void SetRightBackgroundTexture(vtkTexture*);
688  vtkGetObjectMacro(RightBackgroundTexture, vtkTexture);
690 
692 
696  vtkSetMacro(TexturedBackground,bool);
697  vtkGetMacro(TexturedBackground,bool);
698  vtkBooleanMacro(TexturedBackground,bool);
700 
701  // method to release graphics resources in any derived renderers.
702  virtual void ReleaseGraphicsResources(vtkWindow *);
703 
705 
708  vtkSetMacro(UseFXAA, bool)
709  vtkGetMacro(UseFXAA, bool)
710  vtkBooleanMacro(UseFXAA, bool)
712 
714 
717  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
718  virtual void SetFXAAOptions(vtkFXAAOptions*);
720 
722 
726  vtkSetMacro(UseShadows,vtkTypeBool);
727  vtkGetMacro(UseShadows,vtkTypeBool);
728  vtkBooleanMacro(UseShadows,vtkTypeBool);
730 
732 
736  vtkSetMacro(UseHiddenLineRemoval, vtkTypeBool)
737  vtkGetMacro(UseHiddenLineRemoval, vtkTypeBool)
738  vtkBooleanMacro(UseHiddenLineRemoval, vtkTypeBool)
740 
741  // Set/Get a custom render pass.
742  // Initial value is NULL.
743  void SetPass(vtkRenderPass *p);
744  vtkGetObjectMacro(Pass, vtkRenderPass);
745 
747 
750  vtkGetObjectMacro(Information, vtkInformation);
751  virtual void SetInformation(vtkInformation*);
753 
755 
761  vtkSetMacro(UseImageBasedLighting, bool)
762  vtkGetMacro(UseImageBasedLighting, bool)
763  vtkBooleanMacro(UseImageBasedLighting, bool)
765 
767 
770  vtkGetObjectMacro(EnvironmentCubeMap, vtkTexture);
771  virtual void SetEnvironmentCubeMap(vtkTexture*);
773 
774 protected:
775  vtkRenderer();
776  ~vtkRenderer() override;
777 
778  // internal method to expand bounding box to consider model transform
779  // matrix or model view transform matrix based on whether or not deering
780  // frustum is used.
781  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
782 
785 
788 
791 
792  double Ambient[3];
795  double TimeFactor;
799  unsigned char *BackingImage;
800  int BackingStoreSize[2];
802 
804 
806 
807  // Allocate the time for each prop
808  void AllocateTime();
809 
810  // Internal variables indicating the number of props
811  // that have been or will be rendered in each category.
813 
814  // A temporary list of props used for culling, and traversal
815  // of all props when rendering
818 
819  // Indicates if the renderer should receive events from an interactor.
820  // Typically only used in conjunction with transparent renderers.
822 
823  // Shows what layer this renderer belongs to. Only of interested when
824  // there are layered renderers.
825  int Layer;
828 
829  // Holds the result of ComputeVisiblePropBounds so that it is visible from
830  // wrapped languages
831  double ComputedVisiblePropBounds[6];
832 
841 
847 
855 
862 
867 
873  virtual int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
874 
882  virtual int UpdateTranslucentPolygonalGeometry();
883 
889  virtual int UpdateOpaquePolygonalGeometry();
890 
895  virtual int UpdateCamera(void);
896 
902  virtual int UpdateLightGeometry(void);
903 
908  virtual int UpdateLights(void) {return 0;}
909 
915  vtkCamera *GetActiveCameraAndResetIfCreated();
916 
921  bool UseFXAA;
922 
927 
933 
939 
947 
953 
964 
971 
978 
979  // HARDWARE SELECTION ----------------------------------------
980  friend class vtkHardwareSelector;
981 
986  { this->Selector = selector; this->Modified(); }
987 
988  // End Ivars for visible cell selecting.
990 
991  //---------------------------------------------------------------
992  friend class vtkRendererDelegate;
994 
998 
999  friend class vtkRenderPass;
1001 
1002  // Arbitrary extra information associated with this renderer
1004 
1007 
1008 private:
1009  vtkRenderer(const vtkRenderer&) = delete;
1010  void operator=(const vtkRenderer&) = delete;
1011 
1012 };
1013 
1015  return this->Lights;
1016 }
1017 
1021 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
1022 
1023 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkInformation * Information
Definition: vtkRenderer.h:1003
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:846
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off...
Definition: vtkRenderer.h:932
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
virtual void WorldToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:256
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkAssemblyPath * PickProp(double selectionX, double selectionY) override
Return the prop (via a vtkAssemblyPath) that has the highest z value at the given x...
Definition: vtkRenderer.h:560
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:304
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkRenderPass * Pass
Definition: vtkRenderer.h:1000
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:322
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:793
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:963
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:908
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:952
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:827
vtkTypeBool IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:588
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkTypeBool BackingStore
Definition: vtkRenderer.h:798
double AllocatedRenderTime
Definition: vtkRenderer.h:794
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:993
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:805
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:801
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:796
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:803
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:790
vtkProp ** PropArray
Definition: vtkRenderer.h:816
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:861
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:787
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.
abstract interface to OpenGL FBOs
void SetSelector(vtkHardwareSelector *selector)
Called by vtkHardwareSelector when it begins rendering for selection.
Definition: vtkRenderer.h:985
double TimeFactor
Definition: vtkRenderer.h:795
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:826
unsigned char * BackingImage
Definition: vtkRenderer.h:799
a superclass for prop cullers
Definition: vtkCuller.h:40
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void StereoMidpoint()
Do anything necessary between rendering the left and right viewpoints in a stereo render...
Definition: vtkRenderer.h:573
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:783
a virtual light for 3D rendering
Definition: vtkLight.h:62
bool UseFXAA
If this flag is on and the rendering engine supports it, FXAA will be used to antialias the scene...
Definition: vtkRenderer.h:921
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkTypeBool UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:946
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:1014
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:249
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:866
int PropArrayCount
Definition: vtkRenderer.h:817
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:926
handles properties associated with a texture map
Definition: vtkTexture.h:71
virtual void Modified()
Update the modification time for this object.
vtkTypeBool Interactive
Definition: vtkRenderer.h:821
vtkLightCollection * Lights
Definition: vtkRenderer.h:786
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:248
#define VTK_SIZEHINT(...)
vtkActorCollection * Actors
Definition: vtkRenderer.h:789
bool TexturedBackground
Definition: vtkRenderer.h:995
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:989
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:255
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:840
an ordered list of Cullers
create a window for renderers to draw into
vtkTypeBool UseHiddenLineRemoval
When this flag is on and the rendering engine supports it, wireframe polydata will be rendered using ...
Definition: vtkRenderer.h:938
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
int LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling...
Definition: vtkRenderer.h:977
Render the props of a vtkRenderer.
bool UseImageBasedLighting
Definition: vtkRenderer.h:1005
vtkTexture * EnvironmentCubeMap
Definition: vtkRenderer.h:1006
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:996
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:421
int AutomaticLightCreation
Definition: vtkRenderer.h:797
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:1021
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:59
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
int NumberOfPropsRendered
Definition: vtkRenderer.h:812
vtkLight * CreatedLight
Definition: vtkRenderer.h:784
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:327
vtkTexture * RightBackgroundTexture
Definition: vtkRenderer.h:997
Configuration for FXAA implementations.
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:970
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:854