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 =========================================================================*/
32 #ifndef vtkRenderer_h
33 #define vtkRenderer_h
34 
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include "vtkViewport.h"
37 
38 #include "vtkVolumeCollection.h" // Needed for access in inline members
39 #include "vtkActorCollection.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;
48 class vtkInformation;
49 class vtkLightCollection;
51 class vtkLight;
54 class vtkRenderPass;
55 class vtkTexture;
56 
57 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
58 {
59 public:
60  vtkTypeMacro(vtkRenderer,vtkViewport);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
68  static vtkRenderer *New();
69 
71 
76  void AddActor(vtkProp *p);
77  void AddVolume(vtkProp *p);
78  void RemoveActor(vtkProp *p);
79  void RemoveVolume(vtkProp *p);
81 
85  void AddLight(vtkLight *);
86 
90  void RemoveLight(vtkLight *);
91 
95  void RemoveAllLights();
96 
100  vtkLightCollection *GetLights();
101 
108  void SetLightCollection(vtkLightCollection *lights);
109 
113  void CreateLight(void);
114 
120  virtual vtkLight *MakeLight();
121 
123 
129  vtkGetMacro(TwoSidedLighting,vtkTypeBool);
130  vtkSetMacro(TwoSidedLighting,vtkTypeBool);
131  vtkBooleanMacro(TwoSidedLighting,vtkTypeBool);
133 
135 
148  vtkSetMacro(LightFollowCamera,vtkTypeBool);
149  vtkGetMacro(LightFollowCamera,vtkTypeBool);
150  vtkBooleanMacro(LightFollowCamera,vtkTypeBool);
152 
154 
162  vtkGetMacro(AutomaticLightCreation,vtkTypeBool);
163  vtkSetMacro(AutomaticLightCreation,vtkTypeBool);
164  vtkBooleanMacro(AutomaticLightCreation,vtkTypeBool);
166 
172  virtual int UpdateLightsGeometryToFollowCamera(void);
173 
177  vtkVolumeCollection *GetVolumes();
178 
182  vtkActorCollection *GetActors();
183 
187  void SetActiveCamera(vtkCamera *);
188 
194  vtkCamera *GetActiveCamera();
195 
201  virtual vtkCamera *MakeCamera();
202 
204 
210  vtkSetMacro(Erase, vtkTypeBool);
211  vtkGetMacro(Erase, vtkTypeBool);
212  vtkBooleanMacro(Erase, vtkTypeBool);
214 
216 
221  vtkSetMacro(Draw, vtkTypeBool);
222  vtkGetMacro(Draw, vtkTypeBool);
223  vtkBooleanMacro(Draw, vtkTypeBool);
225 
230  int CaptureGL2PSSpecialProp(vtkProp *);
231 
237  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
238 
242  void AddCuller(vtkCuller *);
243 
247  void RemoveCuller(vtkCuller *);
248 
252  vtkCullerCollection *GetCullers();
253 
255 
258  vtkSetVector3Macro(Ambient,double);
259  vtkGetVectorMacro(Ambient,double,3);
261 
263 
267  vtkSetMacro(AllocatedRenderTime,double);
268  virtual double GetAllocatedRenderTime();
270 
277  virtual double GetTimeFactor();
278 
285  virtual void Render();
286 
290  virtual void DeviceRender() =0;
291 
298  virtual void DeviceRenderOpaqueGeometry();
299 
309  virtual void DeviceRenderTranslucentPolygonalGeometry();
310 
315  virtual void ClearLights(void) {};
316 
320  virtual void Clear() {}
321 
325  int VisibleActorCount();
326 
330  int VisibleVolumeCount();
331 
336  void ComputeVisiblePropBounds( double bounds[6] );
337 
341  double *ComputeVisiblePropBounds() VTK_SIZEHINT(6);
342 
347  virtual void ResetCameraClippingRange();
348 
350 
356  virtual void ResetCameraClippingRange( double bounds[6] );
357  virtual void ResetCameraClippingRange( double xmin, double xmax,
358  double ymin, double ymax,
359  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(double xmin, double xmax, double ymin, double ymax,
405  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  }
557  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
558  double selectionX2, double selectionY2) override;
560 
566  virtual void StereoMidpoint() { return; };
567 
574  double GetTiledAspectRatio();
575 
582  { return (this->ActiveCamera != nullptr); }
583 
584 
586 
596  vtkSetMacro(UseDepthPeeling,vtkTypeBool);
597  vtkGetMacro(UseDepthPeeling,vtkTypeBool);
598  vtkBooleanMacro(UseDepthPeeling,vtkTypeBool);
600 
606  vtkSetMacro(UseDepthPeelingForVolumes, bool)
607  vtkGetMacro(UseDepthPeelingForVolumes, bool)
608  vtkBooleanMacro(UseDepthPeelingForVolumes, bool)
609 
610  //@{
620  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
621  vtkGetMacro(OcclusionRatio,double);
623 
625 
630  vtkSetMacro(MaximumNumberOfPeels,int);
631  vtkGetMacro(MaximumNumberOfPeels,int);
633 
635 
640  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
642 
644 
650  void SetDelegate(vtkRendererDelegate *d);
651  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
653 
655 
660  vtkGetObjectMacro(Selector, vtkHardwareSelector);
662 
664 
668  virtual void SetBackgroundTexture(vtkTexture*);
669  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
671 
673 
677  vtkSetMacro(TexturedBackground,bool);
678  vtkGetMacro(TexturedBackground,bool);
679  vtkBooleanMacro(TexturedBackground,bool);
681 
682  // method to release graphics resources in any derived renderers.
683  virtual void ReleaseGraphicsResources(vtkWindow *);
684 
686 
689  vtkSetMacro(UseFXAA, bool)
690  vtkGetMacro(UseFXAA, bool)
691  vtkBooleanMacro(UseFXAA, bool)
693 
695 
698  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
699  virtual void SetFXAAOptions(vtkFXAAOptions*);
701 
703 
707  vtkSetMacro(UseShadows,vtkTypeBool);
708  vtkGetMacro(UseShadows,vtkTypeBool);
709  vtkBooleanMacro(UseShadows,vtkTypeBool);
711 
713 
717  vtkSetMacro(UseHiddenLineRemoval, vtkTypeBool)
718  vtkGetMacro(UseHiddenLineRemoval, vtkTypeBool)
719  vtkBooleanMacro(UseHiddenLineRemoval, vtkTypeBool)
721 
722  // Set/Get a custom render pass.
723  // Initial value is NULL.
724  void SetPass(vtkRenderPass *p);
725  vtkGetObjectMacro(Pass, vtkRenderPass);
726 
728 
731  vtkGetObjectMacro(Information, vtkInformation);
732  virtual void SetInformation(vtkInformation*);
734 
735 protected:
736  vtkRenderer();
737  ~vtkRenderer() override;
738 
739  // internal method to expand bounding box to consider model transform
740  // matrix or model view transform matrix based on whether or not deering
741  // frustum is used.
742  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
743 
746 
749 
752 
753  double Ambient[3];
756  double TimeFactor;
760  unsigned char *BackingImage;
761  int BackingStoreSize[2];
763 
765 
767 
768  // Allocate the time for each prop
769  void AllocateTime();
770 
771  // Internal variables indicating the number of props
772  // that have been or will be rendered in each category.
774 
775  // A temporary list of props used for culling, and traversal
776  // of all props when rendering
779 
780  // Indicates if the renderer should receive events from an interactor.
781  // Typically only used in conjunction with transparent renderers.
783 
784  // Shows what layer this renderer belongs to. Only of interested when
785  // there are layered renderers.
786  int Layer;
789 
790  // Holds the result of ComputeVisiblePropBounds so that it is visible from
791  // wrapped languages
792  double ComputedVisiblePropBounds[6];
793 
802 
808 
816 
823 
828 
834  virtual int UpdateGeometry();
835 
843  virtual int UpdateTranslucentPolygonalGeometry();
844 
850  virtual int UpdateOpaquePolygonalGeometry();
851 
856  virtual int UpdateCamera(void);
857 
863  virtual int UpdateLightGeometry(void);
864 
869  virtual int UpdateLights(void) {return 0;}
870 
876  vtkCamera *GetActiveCameraAndResetIfCreated();
877 
882  bool UseFXAA;
883 
888 
894 
900 
908 
914 
925 
932 
939 
940  // HARDWARE SELECTION ----------------------------------------
941  friend class vtkHardwareSelector;
942 
947  { this->Selector = selector; this->Modified(); }
948 
949  // End Ivars for visible cell selecting.
951 
952  //---------------------------------------------------------------
953  friend class vtkRendererDelegate;
955 
958 
959  friend class vtkRenderPass;
961 
962  // Arbitrary extra information associated with this renderer
964 
965 private:
966  vtkRenderer(const vtkRenderer&) = delete;
967  void operator=(const vtkRenderer&) = delete;
968 
969 };
970 
972  return this->Lights;
973 }
974 
979 
980 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkInformation * Information
Definition: vtkRenderer.h:963
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:807
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off.
Definition: vtkRenderer.h:893
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:253
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:302
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkRenderPass * Pass
Definition: vtkRenderer.h:960
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:315
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:754
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:924
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:869
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry.
Definition: vtkRenderer.h:913
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:788
abstract specification for renderers
Definition: vtkRenderer.h:57
vtkTypeBool BackingStore
Definition: vtkRenderer.h:759
double AllocatedRenderTime
Definition: vtkRenderer.h:755
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:954
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:766
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:762
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:757
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:764
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:751
vtkProp ** PropArray
Definition: vtkRenderer.h:777
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:822
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:748
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.
void SetSelector(vtkHardwareSelector *selector)
Called by vtkHardwareSelector when it begins rendering for selection.
Definition: vtkRenderer.h:946
double TimeFactor
Definition: vtkRenderer.h:756
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:787
unsigned char * BackingImage
Definition: vtkRenderer.h:760
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:44
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:744
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:882
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:907
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:971
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:246
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:827
int PropArrayCount
Definition: vtkRenderer.h:778
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:887
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:782
vtkLightCollection * Lights
Definition: vtkRenderer.h:747
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:245
#define VTK_SIZEHINT(...)
vtkActorCollection * Actors
Definition: vtkRenderer.h:750
bool TexturedBackground
Definition: vtkRenderer.h:956
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:950
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:252
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:801
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:899
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:938
Render the props of a vtkRenderer.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:957
int AutomaticLightCreation
Definition: vtkRenderer.h:758
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:978
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:55
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
int NumberOfPropsRendered
Definition: vtkRenderer.h:773
vtkLight * CreatedLight
Definition: vtkRenderer.h:745
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:320
Configuration for FXAA implementations.
int IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:581
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:931
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer.
Definition: vtkRenderer.h:815