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 =========================================================================*/
32 #ifndef vtkRenderer_h
33 #define vtkRenderer_h
34 
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include "vtkViewport.h"
37 
38 #include "vtkActorCollection.h" // Needed for access in inline members
39 #include "vtkVolumeCollection.h" // Needed for access in inline members
40 
41 class vtkFXAAOptions;
42 class vtkRenderWindow;
43 class vtkVolume;
44 class vtkCuller;
45 class vtkActor;
46 class vtkActor2D;
47 class vtkCamera;
49 class vtkInformation;
50 class vtkLightCollection;
52 class vtkLight;
55 class vtkRenderPass;
56 class vtkTexture;
57 
58 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
59 {
60 public:
61  vtkTypeMacro(vtkRenderer, vtkViewport);
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
69  static vtkRenderer* New();
70 
72 
77  void AddActor(vtkProp* p);
78  void AddVolume(vtkProp* p);
79  void RemoveActor(vtkProp* p);
80  void RemoveVolume(vtkProp* p);
82 
86  void AddLight(vtkLight*);
87 
91  void RemoveLight(vtkLight*);
92 
96  void RemoveAllLights();
97 
101  vtkLightCollection* GetLights();
102 
109  void SetLightCollection(vtkLightCollection* lights);
110 
114  void CreateLight(void);
115 
121  virtual vtkLight* MakeLight();
122 
124 
130  vtkGetMacro(TwoSidedLighting, vtkTypeBool);
131  vtkSetMacro(TwoSidedLighting, vtkTypeBool);
132  vtkBooleanMacro(TwoSidedLighting, vtkTypeBool);
134 
136 
149  vtkSetMacro(LightFollowCamera, vtkTypeBool);
150  vtkGetMacro(LightFollowCamera, vtkTypeBool);
151  vtkBooleanMacro(LightFollowCamera, vtkTypeBool);
153 
155 
163  vtkGetMacro(AutomaticLightCreation, vtkTypeBool);
164  vtkSetMacro(AutomaticLightCreation, vtkTypeBool);
165  vtkBooleanMacro(AutomaticLightCreation, vtkTypeBool);
167 
173  virtual vtkTypeBool UpdateLightsGeometryToFollowCamera(void);
174 
178  vtkVolumeCollection* GetVolumes();
179 
183  vtkActorCollection* GetActors();
184 
188  void SetActiveCamera(vtkCamera*);
189 
195  vtkCamera* GetActiveCamera();
196 
202  virtual vtkCamera* MakeCamera();
203 
205 
211  vtkSetMacro(Erase, vtkTypeBool);
212  vtkGetMacro(Erase, vtkTypeBool);
213  vtkBooleanMacro(Erase, vtkTypeBool);
215 
217 
222  vtkSetMacro(Draw, vtkTypeBool);
223  vtkGetMacro(Draw, vtkTypeBool);
224  vtkBooleanMacro(Draw, vtkTypeBool);
226 
231  int CaptureGL2PSSpecialProp(vtkProp*);
232 
238  void SetGL2PSSpecialPropCollection(vtkPropCollection*);
239 
243  void AddCuller(vtkCuller*);
244 
248  void RemoveCuller(vtkCuller*);
249 
253  vtkCullerCollection* GetCullers();
254 
256 
259  vtkSetVector3Macro(Ambient, double);
260  vtkGetVectorMacro(Ambient, double, 3);
262 
264 
268  vtkSetMacro(AllocatedRenderTime, double);
269  virtual double GetAllocatedRenderTime();
271 
278  virtual double GetTimeFactor();
279 
286  virtual void Render();
287 
291  virtual void DeviceRender(){};
292 
299  virtual void DeviceRenderOpaqueGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
300 
310  virtual void DeviceRenderTranslucentPolygonalGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
311 
316  virtual void ClearLights(void) {}
317 
321  virtual void Clear() {}
322 
326  int VisibleActorCount();
327 
331  int VisibleVolumeCount();
332 
337  void ComputeVisiblePropBounds(double bounds[6]);
338 
342  double* ComputeVisiblePropBounds() VTK_SIZEHINT(6);
343 
348  virtual void ResetCameraClippingRange();
349 
351 
357  virtual void ResetCameraClippingRange(double bounds[6]);
358  virtual void ResetCameraClippingRange(
359  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
361 
363 
368  vtkSetClampMacro(NearClippingPlaneTolerance, double, 0, 0.99);
369  vtkGetMacro(NearClippingPlaneTolerance, double);
371 
373 
378  vtkSetClampMacro(ClippingRangeExpansion, double, 0, 0.99);
379  vtkGetMacro(ClippingRangeExpansion, double);
381 
388  virtual void ResetCamera();
389 
399  virtual void ResetCamera(double bounds[6]);
400 
404  virtual void ResetCamera(
405  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
406 
408 
413  void SetRenderWindow(vtkRenderWindow*);
414  vtkRenderWindow* GetRenderWindow() { return this->RenderWindow; }
415  vtkWindow* GetVTKWindow() override;
417 
419 
425  vtkSetMacro(BackingStore, vtkTypeBool);
426  vtkGetMacro(BackingStore, vtkTypeBool);
427  vtkBooleanMacro(BackingStore, vtkTypeBool);
429 
431 
436  vtkSetMacro(Interactive, vtkTypeBool);
437  vtkGetMacro(Interactive, vtkTypeBool);
438  vtkBooleanMacro(Interactive, vtkTypeBool);
440 
442 
453  virtual void SetLayer(int layer);
454  vtkGetMacro(Layer, int);
456 
458 
468  vtkGetMacro(PreserveColorBuffer, vtkTypeBool);
469  vtkSetMacro(PreserveColorBuffer, vtkTypeBool);
470  vtkBooleanMacro(PreserveColorBuffer, vtkTypeBool);
472 
474 
478  vtkSetMacro(PreserveDepthBuffer, vtkTypeBool);
479  vtkGetMacro(PreserveDepthBuffer, vtkTypeBool);
480  vtkBooleanMacro(PreserveDepthBuffer, vtkTypeBool);
482 
487  int Transparent();
488 
492  void WorldToView() override;
493 
495 
498  void ViewToWorld() override;
499  void ViewToWorld(double& wx, double& wy, double& wz) override;
501 
505  void WorldToView(double& wx, double& wy, double& wz) override;
506 
508 
511  void WorldToPose(double& wx, double& wy, double& wz) override;
512  void PoseToWorld(double& wx, double& wy, double& wz) override;
513  void ViewToPose(double& wx, double& wy, double& wz) override;
514  void PoseToView(double& wx, double& wy, double& wz) override;
516 
521  double GetZ(int x, int y);
522 
526  vtkMTimeType GetMTime() override;
527 
529 
532  vtkGetMacro(LastRenderTimeInSeconds, double);
534 
536 
542  vtkGetMacro(NumberOfPropsRendered, int);
544 
546 
553  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
554  {
555  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
556  }
558  double selectionX1, double selectionY1, double selectionX2, double selectionY2) override;
560 
566  virtual void StereoMidpoint() { return; }
567 
574  double GetTiledAspectRatio();
575 
581  vtkTypeBool IsActiveCameraCreated() { return (this->ActiveCamera != nullptr); }
582 
584 
594  vtkSetMacro(UseDepthPeeling, vtkTypeBool);
595  vtkGetMacro(UseDepthPeeling, vtkTypeBool);
596  vtkBooleanMacro(UseDepthPeeling, vtkTypeBool);
598 
604  vtkSetMacro(UseDepthPeelingForVolumes, bool);
605  vtkGetMacro(UseDepthPeelingForVolumes, bool);
606  vtkBooleanMacro(UseDepthPeelingForVolumes, bool);
607 
609 
618  vtkSetClampMacro(OcclusionRatio, double, 0.0, 0.5);
619  vtkGetMacro(OcclusionRatio, double);
621 
623 
628  vtkSetMacro(MaximumNumberOfPeels, int);
629  vtkGetMacro(MaximumNumberOfPeels, int);
631 
633 
638  vtkGetMacro(LastRenderingUsedDepthPeeling, vtkTypeBool);
640 
642 
648  void SetDelegate(vtkRendererDelegate* d);
649  vtkGetObjectMacro(Delegate, vtkRendererDelegate);
651 
653 
658  vtkGetObjectMacro(Selector, vtkHardwareSelector);
660 
662 
667  virtual void SetLeftBackgroundTexture(vtkTexture*);
668  vtkTexture* GetLeftBackgroundTexture();
669  virtual void SetBackgroundTexture(vtkTexture*);
670  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
672 
674 
678  virtual void SetRightBackgroundTexture(vtkTexture*);
679  vtkGetObjectMacro(RightBackgroundTexture, vtkTexture);
681 
683 
687  vtkSetMacro(TexturedBackground, bool);
688  vtkGetMacro(TexturedBackground, bool);
689  vtkBooleanMacro(TexturedBackground, bool);
691 
692  // method to release graphics resources in any derived renderers.
693  virtual void ReleaseGraphicsResources(vtkWindow*);
694 
696 
699  vtkSetMacro(UseFXAA, bool);
700  vtkGetMacro(UseFXAA, bool);
701  vtkBooleanMacro(UseFXAA, bool);
703 
705 
708  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions);
709  virtual void SetFXAAOptions(vtkFXAAOptions*);
711 
713 
717  vtkSetMacro(UseShadows, vtkTypeBool);
718  vtkGetMacro(UseShadows, vtkTypeBool);
719  vtkBooleanMacro(UseShadows, vtkTypeBool);
721 
723 
727  vtkSetMacro(UseHiddenLineRemoval, vtkTypeBool);
728  vtkGetMacro(UseHiddenLineRemoval, vtkTypeBool);
729  vtkBooleanMacro(UseHiddenLineRemoval, vtkTypeBool);
731 
732  // Set/Get a custom render pass.
733  // Initial value is NULL.
734  void SetPass(vtkRenderPass* p);
735  vtkGetObjectMacro(Pass, vtkRenderPass);
736 
738 
741  vtkGetObjectMacro(Information, vtkInformation);
742  virtual void SetInformation(vtkInformation*);
744 
746 
752  vtkSetMacro(UseImageBasedLighting, bool);
753  vtkGetMacro(UseImageBasedLighting, bool);
754  vtkBooleanMacro(UseImageBasedLighting, bool);
756 
758 
769  vtkGetObjectMacro(EnvironmentTexture, vtkTexture);
770  virtual void SetEnvironmentTexture(vtkTexture* texture, bool isSRGB = false);
772 
774 
777  vtkGetVector3Macro(EnvironmentUp, double);
778  vtkSetVector3Macro(EnvironmentUp, double);
780 
782 
785  vtkGetVector3Macro(EnvironmentRight, double);
786  vtkSetVector3Macro(EnvironmentRight, double);
788 
789 protected:
790  vtkRenderer();
791  ~vtkRenderer() override;
792 
793  // internal method to expand bounding box to consider model transform
794  // matrix or model view transform matrix based on whether or not deering
795  // frustum is used.
796  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4* matrix);
797 
800 
803 
806 
807  double Ambient[3];
810  double TimeFactor;
814  unsigned char* BackingImage;
815  int BackingStoreSize[2];
817 
819 
821 
822  // Allocate the time for each prop
823  void AllocateTime();
824 
825  // Internal variables indicating the number of props
826  // that have been or will be rendered in each category.
828 
829  // A temporary list of props used for culling, and traversal
830  // of all props when rendering
833 
834  // Indicates if the renderer should receive events from an interactor.
835  // Typically only used in conjunction with transparent renderers.
837 
838  // Shows what layer this renderer belongs to. Only of interested when
839  // there are layered renderers.
840  int Layer;
843 
844  // Holds the result of ComputeVisiblePropBounds so that it is visible from
845  // wrapped languages
846  double ComputedVisiblePropBounds[6];
847 
856 
862 
870 
877 
882 
888  virtual int UpdateGeometry(vtkFrameBufferObjectBase* fbo = nullptr);
889 
897  virtual int UpdateTranslucentPolygonalGeometry();
898 
904  virtual int UpdateOpaquePolygonalGeometry();
905 
910  virtual int UpdateCamera(void);
911 
917  virtual vtkTypeBool UpdateLightGeometry(void);
918 
923  virtual int UpdateLights(void) { return 0; }
924 
930  vtkCamera* GetActiveCameraAndResetIfCreated();
931 
936  bool UseFXAA;
937 
942 
948 
954 
962 
968 
979 
986 
993 
994  // HARDWARE SELECTION ----------------------------------------
995  friend class vtkHardwareSelector;
996 
1001  {
1002  this->Selector = selector;
1003  this->Modified();
1004  }
1005 
1006  // End Ivars for visible cell selecting.
1008 
1009  //---------------------------------------------------------------
1010  friend class vtkRendererDelegate;
1012 
1016 
1017  friend class vtkRenderPass;
1019 
1020  // Arbitrary extra information associated with this renderer
1022 
1025 
1026  double EnvironmentUp[3];
1027  double EnvironmentRight[3];
1028 
1029 private:
1030  vtkRenderer(const vtkRenderer&) = delete;
1031  void operator=(const vtkRenderer&) = delete;
1032 };
1033 
1035 {
1036  return this->Lights;
1037 }
1038 
1043 {
1044  return this->Cullers;
1045 }
1046 
1047 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkInformation * Information
Definition: vtkRenderer.h:1021
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:861
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off...
Definition: vtkRenderer.h:947
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:553
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:1018
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:316
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:808
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:978
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:923
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:1024
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:967
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:842
vtkTypeBool IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:581
abstract specification for renderers
Definition: vtkRenderer.h:58
vtkTypeBool BackingStore
Definition: vtkRenderer.h:813
double AllocatedRenderTime
Definition: vtkRenderer.h:809
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:1011
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:820
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:816
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:811
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:818
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:805
vtkProp ** PropArray
Definition: vtkRenderer.h:831
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:876
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:802
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:1000
double TimeFactor
Definition: vtkRenderer.h:810
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:841
unsigned char * BackingImage
Definition: vtkRenderer.h:814
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:566
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:798
vtkTypeBool AutomaticLightCreation
Definition: vtkRenderer.h:812
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:936
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:961
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:1034
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:881
int PropArrayCount
Definition: vtkRenderer.h:832
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:941
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:836
vtkLightCollection * Lights
Definition: vtkRenderer.h:801
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:804
bool TexturedBackground
Definition: vtkRenderer.h:1013
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:1007
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:855
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:953
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
virtual void DeviceRender()
Create an image.
Definition: vtkRenderer.h:291
Render the props of a vtkRenderer.
bool UseImageBasedLighting
Definition: vtkRenderer.h:1023
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:1014
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:414
vtkTypeBool LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling...
Definition: vtkRenderer.h:992
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:1042
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:827
vtkLight * CreatedLight
Definition: vtkRenderer.h:799
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:321
vtkTexture * RightBackgroundTexture
Definition: vtkRenderer.h:1015
Configuration for FXAA implementations.
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:985
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:869