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 =========================================================================*/
41 #ifndef vtkRenderer_h
42 #define vtkRenderer_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkViewport.h"
46 
47 #include "vtkActorCollection.h" // Needed for access in inline members
48 #include "vtkVolumeCollection.h" // Needed for access in inline members
49 
50 class vtkFXAAOptions;
51 class vtkRenderWindow;
52 class vtkVolume;
53 class vtkCuller;
54 class vtkActor;
55 class vtkActor2D;
56 class vtkCamera;
58 class vtkInformation;
59 class vtkLightCollection;
61 class vtkLight;
64 class vtkRenderPass;
65 class vtkTexture;
66 
67 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
68 {
69 public:
70  vtkTypeMacro(vtkRenderer, vtkViewport);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
78  static vtkRenderer* New();
79 
81 
86  void AddActor(vtkProp* p);
87  void AddVolume(vtkProp* p);
88  void RemoveActor(vtkProp* p);
89  void RemoveVolume(vtkProp* p);
91 
95  void AddLight(vtkLight*);
96 
100  void RemoveLight(vtkLight*);
101 
105  void RemoveAllLights();
106 
110  vtkLightCollection* GetLights();
111 
118  void SetLightCollection(vtkLightCollection* lights);
119 
123  void CreateLight(void);
124 
130  virtual vtkLight* MakeLight();
131 
133 
139  vtkGetMacro(TwoSidedLighting, vtkTypeBool);
140  vtkSetMacro(TwoSidedLighting, vtkTypeBool);
141  vtkBooleanMacro(TwoSidedLighting, vtkTypeBool);
143 
145 
158  vtkSetMacro(LightFollowCamera, vtkTypeBool);
159  vtkGetMacro(LightFollowCamera, vtkTypeBool);
160  vtkBooleanMacro(LightFollowCamera, vtkTypeBool);
162 
164 
172  vtkGetMacro(AutomaticLightCreation, vtkTypeBool);
173  vtkSetMacro(AutomaticLightCreation, vtkTypeBool);
174  vtkBooleanMacro(AutomaticLightCreation, vtkTypeBool);
176 
182  virtual vtkTypeBool UpdateLightsGeometryToFollowCamera(void);
183 
187  vtkVolumeCollection* GetVolumes();
188 
192  vtkActorCollection* GetActors();
193 
197  void SetActiveCamera(vtkCamera*);
198 
204  vtkCamera* GetActiveCamera();
205 
211  virtual vtkCamera* MakeCamera();
212 
214 
220  vtkSetMacro(Erase, vtkTypeBool);
221  vtkGetMacro(Erase, vtkTypeBool);
222  vtkBooleanMacro(Erase, vtkTypeBool);
224 
226 
231  vtkSetMacro(Draw, vtkTypeBool);
232  vtkGetMacro(Draw, vtkTypeBool);
233  vtkBooleanMacro(Draw, vtkTypeBool);
235 
240  int CaptureGL2PSSpecialProp(vtkProp*);
241 
247  void SetGL2PSSpecialPropCollection(vtkPropCollection*);
248 
252  void AddCuller(vtkCuller*);
253 
257  void RemoveCuller(vtkCuller*);
258 
262  vtkCullerCollection* GetCullers();
263 
265 
268  vtkSetVector3Macro(Ambient, double);
269  vtkGetVectorMacro(Ambient, double, 3);
271 
273 
277  vtkSetMacro(AllocatedRenderTime, double);
278  virtual double GetAllocatedRenderTime();
280 
287  virtual double GetTimeFactor();
288 
295  virtual void Render();
296 
300  virtual void DeviceRender(){};
301 
308  virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
309 
319  virtual void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
320 
325  virtual void ClearLights(void) {}
326 
330  virtual void Clear() {}
331 
335  int VisibleActorCount();
336 
340  int VisibleVolumeCount();
341 
346  void ComputeVisiblePropBounds(double bounds[6]);
347 
351  double* ComputeVisiblePropBounds() VTK_SIZEHINT(6);
352 
357  virtual void ResetCameraClippingRange();
358 
360 
366  virtual void ResetCameraClippingRange(double bounds[6]);
367  virtual void ResetCameraClippingRange(
368  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
370 
372 
377  vtkSetClampMacro(NearClippingPlaneTolerance, double, 0, 0.99);
378  vtkGetMacro(NearClippingPlaneTolerance, double);
380 
382 
387  vtkSetClampMacro(ClippingRangeExpansion, double, 0, 0.99);
388  vtkGetMacro(ClippingRangeExpansion, double);
390 
397  virtual void ResetCamera();
398 
408  virtual void ResetCamera(double bounds[6]);
409 
413  virtual void ResetCamera(
414  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
415 
417 
422  void SetRenderWindow(vtkRenderWindow*);
423  vtkRenderWindow* GetRenderWindow() { return this->RenderWindow; }
424  vtkWindow* GetVTKWindow() override;
426 
428 
434  vtkSetMacro(BackingStore, vtkTypeBool);
435  vtkGetMacro(BackingStore, vtkTypeBool);
436  vtkBooleanMacro(BackingStore, vtkTypeBool);
438 
440 
445  vtkSetMacro(Interactive, vtkTypeBool);
446  vtkGetMacro(Interactive, vtkTypeBool);
447  vtkBooleanMacro(Interactive, vtkTypeBool);
449 
451 
462  virtual void SetLayer(int layer);
463  vtkGetMacro(Layer, int);
465 
467 
477  vtkGetMacro(PreserveColorBuffer, vtkTypeBool);
478  vtkSetMacro(PreserveColorBuffer, vtkTypeBool);
479  vtkBooleanMacro(PreserveColorBuffer, vtkTypeBool);
481 
483 
487  vtkSetMacro(PreserveDepthBuffer, vtkTypeBool);
488  vtkGetMacro(PreserveDepthBuffer, vtkTypeBool);
489  vtkBooleanMacro(PreserveDepthBuffer, vtkTypeBool);
491 
496  int Transparent();
497 
501  void WorldToView() override;
502 
504 
507  void ViewToWorld() override;
508  void ViewToWorld(double& wx, double& wy, double& wz) override;
510 
514  void WorldToView(double& wx, double& wy, double& wz) override;
515 
517 
520  void WorldToPose(double& wx, double& wy, double& wz) override;
521  void PoseToWorld(double& wx, double& wy, double& wz) override;
522  void ViewToPose(double& wx, double& wy, double& wz) override;
523  void PoseToView(double& wx, double& wy, double& wz) override;
525 
530  double GetZ(int x, int y);
531 
535  vtkMTimeType GetMTime() override;
536 
538 
541  vtkGetMacro(LastRenderTimeInSeconds, double);
543 
545 
551  vtkGetMacro(NumberOfPropsRendered, int);
553 
555 
562  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
563  {
564  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
565  }
567  double selectionX1, double selectionY1, double selectionX2, double selectionY2) override;
569 
575  virtual void StereoMidpoint() { return; }
576 
583  double GetTiledAspectRatio();
584 
590  vtkTypeBool IsActiveCameraCreated() { return (this->ActiveCamera != nullptr); }
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 
618 
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, vtkTypeBool);
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 
778  vtkGetObjectMacro(EnvironmentTexture, vtkTexture);
779  virtual void SetEnvironmentTexture(vtkTexture* texture, bool isSRGB = false);
781 
783 
786  vtkGetVector3Macro(EnvironmentUp, double);
787  vtkSetVector3Macro(EnvironmentUp, double);
789 
791 
794  vtkGetVector3Macro(EnvironmentRight, double);
795  vtkSetVector3Macro(EnvironmentRight, double);
797 
798 protected:
799  vtkRenderer();
800  ~vtkRenderer() override;
801 
802  // internal method to expand bounding box to consider model transform
803  // matrix or model view transform matrix based on whether or not deering
804  // frustum is used.
805  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4* matrix);
806 
809 
812 
815 
816  double Ambient[3];
819  double TimeFactor;
823  unsigned char* BackingImage;
824  int BackingStoreSize[2];
826 
828 
830 
831  // Allocate the time for each prop
832  void AllocateTime();
833 
834  // Internal variables indicating the number of props
835  // that have been or will be rendered in each category.
837 
838  // A temporary list of props used for culling, and traversal
839  // of all props when rendering
842 
843  // Indicates if the renderer should receive events from an interactor.
844  // Typically only used in conjunction with transparent renderers.
846 
847  // Shows what layer this renderer belongs to. Only of interested when
848  // there are layered renderers.
849  int Layer;
852 
853  // Holds the result of ComputeVisiblePropBounds so that it is visible from
854  // wrapped languages
855  double ComputedVisiblePropBounds[6];
856 
865 
871 
879 
886 
891 
897  virtual int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
898 
906  virtual int UpdateTranslucentPolygonalGeometry();
907 
913  virtual int UpdateOpaquePolygonalGeometry();
914 
919  virtual int UpdateCamera(void);
920 
926  virtual vtkTypeBool UpdateLightGeometry(void);
927 
932  virtual int UpdateLights(void) { return 0; }
933 
939  vtkCamera* GetActiveCameraAndResetIfCreated();
940 
945  bool UseFXAA;
946 
951 
957 
963 
971 
977 
988 
995 
1002 
1003  // HARDWARE SELECTION ----------------------------------------
1004  friend class vtkHardwareSelector;
1005 
1010  {
1011  this->Selector = selector;
1012  this->Modified();
1013  }
1014 
1015  // End Ivars for visible cell selecting.
1017 
1018  //---------------------------------------------------------------
1019  friend class vtkRendererDelegate;
1021 
1025 
1026  friend class vtkRenderPass;
1028 
1029  // Arbitrary extra information associated with this renderer
1031 
1034 
1035  double EnvironmentUp[3];
1036  double EnvironmentRight[3];
1037 
1038 private:
1039  vtkRenderer(const vtkRenderer&) = delete;
1040  void operator=(const vtkRenderer&) = delete;
1041 };
1042 
1044 {
1045  return this->Lights;
1046 }
1047 
1052 {
1053  return this->Cullers;
1054 }
1055 
1056 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkInformation * Information
Definition: vtkRenderer.h:1030
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:870
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off...
Definition: vtkRenderer.h:956
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:562
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:1027
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:325
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:817
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:987
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:932
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:1033
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:976
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:851
vtkTypeBool IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:590
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkTypeBool BackingStore
Definition: vtkRenderer.h:822
double AllocatedRenderTime
Definition: vtkRenderer.h:818
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:1020
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:829
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:825
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:820
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:827
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:814
vtkProp ** PropArray
Definition: vtkRenderer.h:840
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:885
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:811
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:1009
double TimeFactor
Definition: vtkRenderer.h:819
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:850
unsigned char * BackingImage
Definition: vtkRenderer.h:823
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:575
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:807
vtkTypeBool AutomaticLightCreation
Definition: vtkRenderer.h:821
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:945
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:970
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:1043
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:890
int PropArrayCount
Definition: vtkRenderer.h:841
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:950
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:845
vtkLightCollection * Lights
Definition: vtkRenderer.h:810
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:813
bool TexturedBackground
Definition: vtkRenderer.h:1022
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:1016
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:864
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:962
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
virtual void DeviceRender()
Create an image.
Definition: vtkRenderer.h:300
Render the props of a vtkRenderer.
bool UseImageBasedLighting
Definition: vtkRenderer.h:1032
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:1023
vtkTypeBool LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling...
Definition: vtkRenderer.h:1001
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:1051
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:836
vtkLight * CreatedLight
Definition: vtkRenderer.h:808
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:330
vtkTexture * RightBackgroundTexture
Definition: vtkRenderer.h:1024
Configuration for FXAA implementations.
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:994
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:878