VTK  9.0.1
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 =========================================================================*/
35 #ifndef vtkRenderer_h
36 #define vtkRenderer_h
37 
38 #include "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkViewport.h"
40 
41 #include "vtkActorCollection.h" // Needed for access in inline members
42 #include "vtkVolumeCollection.h" // Needed for access in inline members
43 
44 class vtkFXAAOptions;
45 class vtkRenderWindow;
46 class vtkVolume;
47 class vtkCuller;
48 class vtkActor;
49 class vtkActor2D;
50 class vtkCamera;
52 class vtkInformation;
53 class vtkLightCollection;
55 class vtkLight;
58 class vtkRenderPass;
59 class vtkTexture;
60 
61 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
62 {
63 public:
64  vtkTypeMacro(vtkRenderer, vtkViewport);
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
72  static vtkRenderer* New();
73 
75 
80  void AddActor(vtkProp* p);
81  void AddVolume(vtkProp* p);
82  void RemoveActor(vtkProp* p);
83  void RemoveVolume(vtkProp* p);
85 
89  void AddLight(vtkLight*);
90 
94  void RemoveLight(vtkLight*);
95 
99  void RemoveAllLights();
100 
104  vtkLightCollection* GetLights();
105 
112  void SetLightCollection(vtkLightCollection* lights);
113 
117  void CreateLight(void);
118 
124  virtual vtkLight* MakeLight();
125 
127 
133  vtkGetMacro(TwoSidedLighting, vtkTypeBool);
134  vtkSetMacro(TwoSidedLighting, vtkTypeBool);
135  vtkBooleanMacro(TwoSidedLighting, vtkTypeBool);
137 
139 
152  vtkSetMacro(LightFollowCamera, vtkTypeBool);
153  vtkGetMacro(LightFollowCamera, vtkTypeBool);
154  vtkBooleanMacro(LightFollowCamera, vtkTypeBool);
156 
158 
166  vtkGetMacro(AutomaticLightCreation, vtkTypeBool);
167  vtkSetMacro(AutomaticLightCreation, vtkTypeBool);
168  vtkBooleanMacro(AutomaticLightCreation, vtkTypeBool);
170 
176  virtual vtkTypeBool UpdateLightsGeometryToFollowCamera(void);
177 
181  vtkVolumeCollection* GetVolumes();
182 
186  vtkActorCollection* GetActors();
187 
191  void SetActiveCamera(vtkCamera*);
192 
198  vtkCamera* GetActiveCamera();
199 
205  virtual vtkCamera* MakeCamera();
206 
208 
214  vtkSetMacro(Erase, vtkTypeBool);
215  vtkGetMacro(Erase, vtkTypeBool);
216  vtkBooleanMacro(Erase, vtkTypeBool);
218 
220 
225  vtkSetMacro(Draw, vtkTypeBool);
226  vtkGetMacro(Draw, vtkTypeBool);
227  vtkBooleanMacro(Draw, vtkTypeBool);
229 
234  int CaptureGL2PSSpecialProp(vtkProp*);
235 
241  void SetGL2PSSpecialPropCollection(vtkPropCollection*);
242 
246  void AddCuller(vtkCuller*);
247 
251  void RemoveCuller(vtkCuller*);
252 
256  vtkCullerCollection* GetCullers();
257 
259 
262  vtkSetVector3Macro(Ambient, double);
263  vtkGetVectorMacro(Ambient, double, 3);
265 
267 
271  vtkSetMacro(AllocatedRenderTime, double);
272  virtual double GetAllocatedRenderTime();
274 
281  virtual double GetTimeFactor();
282 
289  virtual void Render();
290 
294  virtual void DeviceRender(){};
295 
302  virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
303 
313  virtual void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
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() VTK_SIZEHINT(6);
346 
351  virtual void ResetCameraClippingRange();
352 
354 
360  virtual void ResetCameraClippingRange(double bounds[6]);
361  virtual void ResetCameraClippingRange(
362  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
364 
366 
371  vtkSetClampMacro(NearClippingPlaneTolerance, double, 0, 0.99);
372  vtkGetMacro(NearClippingPlaneTolerance, double);
374 
376 
381  vtkSetClampMacro(ClippingRangeExpansion, double, 0, 0.99);
382  vtkGetMacro(ClippingRangeExpansion, double);
384 
391  virtual void ResetCamera();
392 
402  virtual void ResetCamera(double bounds[6]);
403 
407  virtual void ResetCamera(
408  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
409 
411 
416  void SetRenderWindow(vtkRenderWindow*);
417  vtkRenderWindow* GetRenderWindow() { return this->RenderWindow; }
418  vtkWindow* GetVTKWindow() override;
420 
422 
428  vtkSetMacro(BackingStore, vtkTypeBool);
429  vtkGetMacro(BackingStore, vtkTypeBool);
430  vtkBooleanMacro(BackingStore, vtkTypeBool);
432 
434 
439  vtkSetMacro(Interactive, vtkTypeBool);
440  vtkGetMacro(Interactive, vtkTypeBool);
441  vtkBooleanMacro(Interactive, vtkTypeBool);
443 
445 
456  virtual void SetLayer(int layer);
457  vtkGetMacro(Layer, int);
459 
461 
471  vtkGetMacro(PreserveColorBuffer, vtkTypeBool);
472  vtkSetMacro(PreserveColorBuffer, vtkTypeBool);
473  vtkBooleanMacro(PreserveColorBuffer, vtkTypeBool);
475 
477 
481  vtkSetMacro(PreserveDepthBuffer, vtkTypeBool);
482  vtkGetMacro(PreserveDepthBuffer, vtkTypeBool);
483  vtkBooleanMacro(PreserveDepthBuffer, vtkTypeBool);
485 
490  int Transparent();
491 
495  void WorldToView() override;
496 
498 
501  void ViewToWorld() override;
502  void ViewToWorld(double& wx, double& wy, double& wz) override;
504 
508  void WorldToView(double& wx, double& wy, double& wz) override;
509 
511 
514  void WorldToPose(double& wx, double& wy, double& wz) override;
515  void PoseToWorld(double& wx, double& wy, double& wz) override;
516  void ViewToPose(double& wx, double& wy, double& wz) override;
517  void PoseToView(double& wx, double& wy, double& wz) override;
519 
524  double GetZ(int x, int y);
525 
529  vtkMTimeType GetMTime() override;
530 
532 
535  vtkGetMacro(LastRenderTimeInSeconds, double);
537 
539 
545  vtkGetMacro(NumberOfPropsRendered, int);
547 
549 
556  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
557  {
558  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
559  }
561  double selectionX1, double selectionY1, double selectionX2, double selectionY2) override;
563 
569  virtual void StereoMidpoint() { return; }
570 
577  double GetTiledAspectRatio();
578 
584  vtkTypeBool IsActiveCameraCreated() { return (this->ActiveCamera != nullptr); }
585 
587 
597  vtkSetMacro(UseDepthPeeling, vtkTypeBool);
598  vtkGetMacro(UseDepthPeeling, vtkTypeBool);
599  vtkBooleanMacro(UseDepthPeeling, vtkTypeBool);
601 
607  vtkSetMacro(UseDepthPeelingForVolumes, bool);
608  vtkGetMacro(UseDepthPeelingForVolumes, bool);
609  vtkBooleanMacro(UseDepthPeelingForVolumes, bool);
610 
612 
621  vtkSetClampMacro(OcclusionRatio, double, 0.0, 0.5);
622  vtkGetMacro(OcclusionRatio, double);
624 
626 
631  vtkSetMacro(MaximumNumberOfPeels, int);
632  vtkGetMacro(MaximumNumberOfPeels, int);
634 
636 
641  vtkGetMacro(LastRenderingUsedDepthPeeling, vtkTypeBool);
643 
645 
651  void SetDelegate(vtkRendererDelegate* d);
652  vtkGetObjectMacro(Delegate, vtkRendererDelegate);
654 
656 
661  vtkGetObjectMacro(Selector, vtkHardwareSelector);
663 
665 
670  virtual void SetLeftBackgroundTexture(vtkTexture*);
671  vtkTexture* GetLeftBackgroundTexture();
672  virtual void SetBackgroundTexture(vtkTexture*);
673  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
675 
677 
681  virtual void SetRightBackgroundTexture(vtkTexture*);
682  vtkGetObjectMacro(RightBackgroundTexture, vtkTexture);
684 
686 
690  vtkSetMacro(TexturedBackground, bool);
691  vtkGetMacro(TexturedBackground, bool);
692  vtkBooleanMacro(TexturedBackground, bool);
694 
695  // method to release graphics resources in any derived renderers.
696  virtual void ReleaseGraphicsResources(vtkWindow*);
697 
699 
702  vtkSetMacro(UseFXAA, bool);
703  vtkGetMacro(UseFXAA, bool);
704  vtkBooleanMacro(UseFXAA, bool);
706 
708 
711  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions);
712  virtual void SetFXAAOptions(vtkFXAAOptions*);
714 
716 
720  vtkSetMacro(UseShadows, vtkTypeBool);
721  vtkGetMacro(UseShadows, vtkTypeBool);
722  vtkBooleanMacro(UseShadows, vtkTypeBool);
724 
726 
730  vtkSetMacro(UseHiddenLineRemoval, vtkTypeBool);
731  vtkGetMacro(UseHiddenLineRemoval, vtkTypeBool);
732  vtkBooleanMacro(UseHiddenLineRemoval, vtkTypeBool);
734 
735  // Set/Get a custom render pass.
736  // Initial value is NULL.
737  void SetPass(vtkRenderPass* p);
738  vtkGetObjectMacro(Pass, vtkRenderPass);
739 
741 
744  vtkGetObjectMacro(Information, vtkInformation);
745  virtual void SetInformation(vtkInformation*);
747 
749 
755  vtkSetMacro(UseImageBasedLighting, bool);
756  vtkGetMacro(UseImageBasedLighting, bool);
757  vtkBooleanMacro(UseImageBasedLighting, bool);
759 
761 
772  vtkGetObjectMacro(EnvironmentTexture, vtkTexture);
773  virtual void SetEnvironmentTexture(vtkTexture* texture, bool isSRGB = false);
775 
777 
780  vtkGetVector3Macro(EnvironmentUp, double);
781  vtkSetVector3Macro(EnvironmentUp, double);
783 
785 
788  vtkGetVector3Macro(EnvironmentRight, double);
789  vtkSetVector3Macro(EnvironmentRight, double);
791 
792 protected:
793  vtkRenderer();
794  ~vtkRenderer() override;
795 
796  // internal method to expand bounding box to consider model transform
797  // matrix or model view transform matrix based on whether or not deering
798  // frustum is used.
799  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4* matrix);
800 
803 
806 
809 
810  double Ambient[3];
813  double TimeFactor;
817  unsigned char* BackingImage;
818  int BackingStoreSize[2];
820 
822 
824 
825  // Allocate the time for each prop
826  void AllocateTime();
827 
828  // Internal variables indicating the number of props
829  // that have been or will be rendered in each category.
831 
832  // A temporary list of props used for culling, and traversal
833  // of all props when rendering
836 
837  // Indicates if the renderer should receive events from an interactor.
838  // Typically only used in conjunction with transparent renderers.
840 
841  // Shows what layer this renderer belongs to. Only of interested when
842  // there are layered renderers.
843  int Layer;
846 
847  // Holds the result of ComputeVisiblePropBounds so that it is visible from
848  // wrapped languages
849  double ComputedVisiblePropBounds[6];
850 
859 
865 
873 
880 
885 
891  virtual int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
892 
900  virtual int UpdateTranslucentPolygonalGeometry();
901 
907  virtual int UpdateOpaquePolygonalGeometry();
908 
913  virtual int UpdateCamera(void);
914 
920  virtual vtkTypeBool UpdateLightGeometry(void);
921 
926  virtual int UpdateLights(void) { return 0; }
927 
933  vtkCamera* GetActiveCameraAndResetIfCreated();
934 
939  bool UseFXAA;
940 
945 
951 
957 
965 
971 
982 
989 
996 
997  // HARDWARE SELECTION ----------------------------------------
998  friend class vtkHardwareSelector;
999 
1004  {
1005  this->Selector = selector;
1006  this->Modified();
1007  }
1008 
1009  // End Ivars for visible cell selecting.
1011 
1012  //---------------------------------------------------------------
1013  friend class vtkRendererDelegate;
1015 
1019 
1020  friend class vtkRenderPass;
1022 
1023  // Arbitrary extra information associated with this renderer
1025 
1028 
1029  double EnvironmentUp[3];
1030  double EnvironmentRight[3];
1031 
1032 private:
1033  vtkRenderer(const vtkRenderer&) = delete;
1034  void operator=(const vtkRenderer&) = delete;
1035 };
1036 
1038 {
1039  return this->Lights;
1040 }
1041 
1046 {
1047  return this->Cullers;
1048 }
1049 
1050 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkInformation * Information
Definition: vtkRenderer.h:1024
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:864
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off...
Definition: vtkRenderer.h:950
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
virtual void WorldToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:261
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
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:556
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkRenderPass * Pass
Definition: vtkRenderer.h:1021
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:319
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:811
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:981
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:926
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkTexture * EnvironmentTexture
Definition: vtkRenderer.h:1027
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:970
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:845
vtkTypeBool IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:584
abstract specification for renderers
Definition: vtkRenderer.h:61
vtkTypeBool BackingStore
Definition: vtkRenderer.h:816
double AllocatedRenderTime
Definition: vtkRenderer.h:812
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:1014
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:823
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:819
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:814
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:821
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:808
vtkProp ** PropArray
Definition: vtkRenderer.h:834
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:879
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:805
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:1003
double TimeFactor
Definition: vtkRenderer.h:813
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:844
unsigned char * BackingImage
Definition: vtkRenderer.h:817
a superclass for prop cullers
Definition: vtkCuller.h:37
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void StereoMidpoint()
Do anything necessary between rendering the left and right viewpoints in a stereo render...
Definition: vtkRenderer.h:569
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:801
vtkTypeBool AutomaticLightCreation
Definition: vtkRenderer.h:815
a virtual light for 3D rendering
Definition: vtkLight.h:56
bool UseFXAA
If this flag is on and the rendering engine supports it, FXAA will be used to antialias the scene...
Definition: vtkRenderer.h:939
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:964
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:1037
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:254
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:884
int PropArrayCount
Definition: vtkRenderer.h:835
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:944
handles properties associated with a texture map
Definition: vtkTexture.h:65
virtual void Modified()
Update the modification time for this object.
vtkTypeBool Interactive
Definition: vtkRenderer.h:839
vtkLightCollection * Lights
Definition: vtkRenderer.h:804
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:253
#define VTK_SIZEHINT(...)
vtkActorCollection * Actors
Definition: vtkRenderer.h:807
bool TexturedBackground
Definition: vtkRenderer.h:1016
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:1010
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:260
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:858
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:956
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
virtual void DeviceRender()
Create an image.
Definition: vtkRenderer.h:294
Render the props of a vtkRenderer.
bool UseImageBasedLighting
Definition: vtkRenderer.h:1026
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:1017
vtkTypeBool LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling...
Definition: vtkRenderer.h:995
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:1045
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:56
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
int NumberOfPropsRendered
Definition: vtkRenderer.h:830
vtkLight * CreatedLight
Definition: vtkRenderer.h:802
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:324
vtkTexture * RightBackgroundTexture
Definition: vtkRenderer.h:1018
Configuration for FXAA implementations.
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:988
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:872