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;
54 class vtkInformation;
55 class vtkLightCollection;
57 class vtkLight;
60 class vtkRenderPass;
61 class vtkTexture;
62 
63 class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
64 {
65 public:
66  vtkTypeMacro(vtkRenderer,vtkViewport);
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
74  static vtkRenderer *New();
75 
77 
82  void AddActor(vtkProp *p);
83  void AddVolume(vtkProp *p);
84  void RemoveActor(vtkProp *p);
85  void RemoveVolume(vtkProp *p);
87 
91  void AddLight(vtkLight *);
92 
96  void RemoveLight(vtkLight *);
97 
101  void RemoveAllLights();
102 
106  vtkLightCollection *GetLights();
107 
114  void SetLightCollection(vtkLightCollection *lights);
115 
119  void CreateLight(void);
120 
126  virtual vtkLight *MakeLight();
127 
129 
135  vtkGetMacro(TwoSidedLighting,int);
136  vtkSetMacro(TwoSidedLighting,int);
137  vtkBooleanMacro(TwoSidedLighting,int);
139 
141 
154  vtkSetMacro(LightFollowCamera,int);
155  vtkGetMacro(LightFollowCamera,int);
156  vtkBooleanMacro(LightFollowCamera,int);
158 
160 
168  vtkGetMacro(AutomaticLightCreation,int);
169  vtkSetMacro(AutomaticLightCreation,int);
170  vtkBooleanMacro(AutomaticLightCreation,int);
172 
178  virtual int UpdateLightsGeometryToFollowCamera(void);
179 
183  vtkVolumeCollection *GetVolumes();
184 
188  vtkActorCollection *GetActors();
189 
193  void SetActiveCamera(vtkCamera *);
194 
200  vtkCamera *GetActiveCamera();
201 
207  virtual vtkCamera *MakeCamera();
208 
210 
216  vtkSetMacro(Erase, int);
217  vtkGetMacro(Erase, int);
218  vtkBooleanMacro(Erase, int);
220 
222 
227  vtkSetMacro(Draw, int);
228  vtkGetMacro(Draw, int);
229  vtkBooleanMacro(Draw, int);
231 
236  int CaptureGL2PSSpecialProp(vtkProp *);
237 
243  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
244 
248  void AddCuller(vtkCuller *);
249 
253  void RemoveCuller(vtkCuller *);
254 
258  vtkCullerCollection *GetCullers();
259 
261 
264  vtkSetVector3Macro(Ambient,double);
265  vtkGetVectorMacro(Ambient,double,3);
267 
269 
273  vtkSetMacro(AllocatedRenderTime,double);
274  virtual double GetAllocatedRenderTime();
276 
283  virtual double GetTimeFactor();
284 
291  virtual void Render();
292 
296  virtual void DeviceRender() =0;
297 
304  virtual void DeviceRenderOpaqueGeometry();
305 
315  virtual void DeviceRenderTranslucentPolygonalGeometry();
316 
321  virtual void ClearLights(void) {};
322 
326  virtual void Clear() {}
327 
331  int VisibleActorCount();
332 
336  int VisibleVolumeCount();
337 
342  void ComputeVisiblePropBounds( double bounds[6] );
343 
347  double *ComputeVisiblePropBounds();
348 
353  virtual void ResetCameraClippingRange();
354 
356 
362  virtual void ResetCameraClippingRange( double bounds[6] );
363  virtual void ResetCameraClippingRange( double xmin, double xmax,
364  double ymin, double ymax,
365  double zmin, double zmax);
367 
369 
374  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
375  vtkGetMacro(NearClippingPlaneTolerance,double);
377 
379 
384  vtkSetClampMacro(ClippingRangeExpansion,double,0,0.99);
385  vtkGetMacro(ClippingRangeExpansion,double);
387 
394  virtual void ResetCamera();
395 
405  virtual void ResetCamera(double bounds[6]);
406 
410  virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax,
411  double zmin, double zmax);
412 
414 
420  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
421  vtkWindow *GetVTKWindow() override;
423 
425 
431  vtkSetMacro(BackingStore,int);
432  vtkGetMacro(BackingStore,int);
433  vtkBooleanMacro(BackingStore,int);
435 
437 
442  vtkSetMacro(Interactive,int);
443  vtkGetMacro(Interactive,int);
444  vtkBooleanMacro(Interactive,int);
446 
448 
459  virtual void SetLayer(int layer);
460  vtkGetMacro(Layer, int);
462 
464 
474  vtkGetMacro(PreserveColorBuffer, int);
475  vtkSetMacro(PreserveColorBuffer, int);
476  vtkBooleanMacro(PreserveColorBuffer, int);
478 
480 
484  vtkSetMacro(PreserveDepthBuffer, int);
485  vtkGetMacro(PreserveDepthBuffer, int);
486  vtkBooleanMacro(PreserveDepthBuffer, int);
488 
493  int Transparent();
494 
498  void WorldToView() override;
499 
501 
504  void ViewToWorld() override;
505  void ViewToWorld(double &wx, double &wy, double &wz) override;
507 
511  void WorldToView(double &wx, double &wy, double &wz) override;
512 
517  double GetZ (int x, int y);
518 
522  vtkMTimeType GetMTime() override;
523 
525 
528  vtkGetMacro( LastRenderTimeInSeconds, double );
530 
532 
538  vtkGetMacro( NumberOfPropsRendered, int );
540 
542 
549  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
550  {
551  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
552  }
553  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
554  double selectionX2, double selectionY2) override;
556 
562  virtual void StereoMidpoint() { return; };
563 
570  double GetTiledAspectRatio();
571 
578  { return (this->ActiveCamera != nullptr); }
579 
580 
582 
592  vtkSetMacro(UseDepthPeeling,int);
593  vtkGetMacro(UseDepthPeeling,int);
594  vtkBooleanMacro(UseDepthPeeling,int);
596 
602  vtkSetMacro(UseDepthPeelingForVolumes, bool)
603  vtkGetMacro(UseDepthPeelingForVolumes, bool)
604  vtkBooleanMacro(UseDepthPeelingForVolumes, bool)
605 
606  //@{
616  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
617  vtkGetMacro(OcclusionRatio,double);
619 
621 
626  vtkSetMacro(MaximumNumberOfPeels,int);
627  vtkGetMacro(MaximumNumberOfPeels,int);
629 
631 
636  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
638 
640 
646  void SetDelegate(vtkRendererDelegate *d);
647  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
649 
651 
656  vtkGetObjectMacro(Selector, vtkHardwareSelector);
658 
660 
664  virtual void SetBackgroundTexture(vtkTexture*);
665  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
667 
669 
673  vtkSetMacro(TexturedBackground,bool);
674  vtkGetMacro(TexturedBackground,bool);
675  vtkBooleanMacro(TexturedBackground,bool);
677 
678  // method to release graphics resources in any derived renderers.
679  virtual void ReleaseGraphicsResources(vtkWindow *);
680 
682 
685  vtkSetMacro(UseFXAA, bool)
686  vtkGetMacro(UseFXAA, bool)
687  vtkBooleanMacro(UseFXAA, bool)
689 
691 
694  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
695  virtual void SetFXAAOptions(vtkFXAAOptions*);
697 
699 
703  vtkSetMacro(UseShadows,int);
704  vtkGetMacro(UseShadows,int);
705  vtkBooleanMacro(UseShadows,int);
707 
709 
713  vtkSetMacro(UseHiddenLineRemoval, int)
714  vtkGetMacro(UseHiddenLineRemoval, int)
715  vtkBooleanMacro(UseHiddenLineRemoval, int)
717 
718  // Set/Get a custom render pass.
719  // Initial value is NULL.
720  void SetPass(vtkRenderPass *p);
721  vtkGetObjectMacro(Pass, vtkRenderPass);
722 
724 
727  vtkGetObjectMacro(Information, vtkInformation);
728  virtual void SetInformation(vtkInformation*);
730 
731 protected:
732  vtkRenderer();
733  ~vtkRenderer() override;
734 
735  // internal method for doing a render for picking purposes
736  virtual void PickRender(vtkPropCollection *props);
737  virtual void PickGeometry();
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  // A temporary list used for picking
783 
784  // Indicates if the renderer should receive events from an interactor.
785  // Typically only used in conjunction with transparent renderers.
787 
788  // Shows what layer this renderer belongs to. Only of interested when
789  // there are layered renderers.
790  int Layer;
793 
794  // Holds the result of ComputeVisiblePropBounds so that it is visible from
795  // wrapped languages
796  double ComputedVisiblePropBounds[6];
797 
806 
812 
819  int Erase;
820 
826  int Draw;
827 
832 
838  virtual int UpdateGeometry();
839 
847  virtual int UpdateTranslucentPolygonalGeometry();
848 
854  virtual int UpdateOpaquePolygonalGeometry();
855 
860  virtual int UpdateCamera(void);
861 
867  virtual int UpdateLightGeometry(void);
868 
873  virtual int UpdateLights(void) {return 0;}
874 
880  vtkCamera *GetActiveCameraAndResetIfCreated();
881 
886  bool UseFXAA;
887 
892 
898 
904 
912 
918 
929 
936 
943 
944  // HARDWARE SELECTION ----------------------------------------
945  friend class vtkHardwareSelector;
946 
951  { this->Selector = selector; this->Modified(); }
952 
953  // End Ivars for visible cell selecting.
955 
956  //---------------------------------------------------------------
957  friend class vtkRendererDelegate;
959 
962 
963  friend class vtkRenderPass;
965 
966  // Arbitrary extra information associated with this renderer
968 
969 private:
970  vtkRenderer(const vtkRenderer&) = delete;
971  void operator=(const vtkRenderer&) = delete;
972 
973 };
974 
976  return this->Lights;
977 }
978 
983 
984 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkInformation * Information
Definition: vtkRenderer.h:967
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:811
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
int UseHiddenLineRemoval
When this flag is on and the rendering engine supports it, wireframe polydata will be rendered using ...
Definition: vtkRenderer.h:903
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:549
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
int BackingStore
Definition: vtkRenderer.h:759
int PreserveColorBuffer
Definition: vtkRenderer.h:791
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkRenderPass * Pass
Definition: vtkRenderer.h:964
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:321
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:911
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:928
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:873
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
bool UseDepthPeelingForVolumes
This this flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry.
Definition: vtkRenderer.h:917
virtual void SetRenderWindow(vtkRenderWindow *renwin)
abstract specification for renderers
Definition: vtkRenderer.h:63
double AllocatedRenderTime
Definition: vtkRenderer.h:755
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:958
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:762
an ordered list of Props
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:764
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:751
vtkProp ** PropArray
Definition: vtkRenderer.h:777
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:950
double TimeFactor
Definition: vtkRenderer.h:756
a list of nodes that form an assembly path
unsigned char * BackingImage
Definition: vtkRenderer.h:760
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:562
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:744
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:886
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:975
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:831
int PropArrayCount
Definition: vtkRenderer.h:778
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:891
handles properties associated with a texture map
Definition: vtkTexture.h:71
virtual void Modified()
Update the modification time for this object.
vtkLightCollection * Lights
Definition: vtkRenderer.h:747
int PathArrayCount
Definition: vtkRenderer.h:782
int Erase
When this flag is off, the renderer will not erase the background or the Zbuffer.
Definition: vtkRenderer.h:819
vtkActorCollection * Actors
Definition: vtkRenderer.h:750
int Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:826
bool TexturedBackground
Definition: vtkRenderer.h:960
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:954
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:805
an ordered list of Cullers
create a window for renderers to draw into
int UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off.
Definition: vtkRenderer.h:897
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:942
Render the props of a vtkRenderer.
manager for OpenGL-based selection.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:961
int TwoSidedLighting
Definition: vtkRenderer.h:757
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:420
int LightFollowCamera
Definition: vtkRenderer.h:766
int AutomaticLightCreation
Definition: vtkRenderer.h:758
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:982
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:58
int PreserveDepthBuffer
Definition: vtkRenderer.h:792
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
vtkAssemblyPath ** PathArray
Definition: vtkRenderer.h:781
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:326
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:577
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:935