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) VTK_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,int);
130  vtkSetMacro(TwoSidedLighting,int);
131  vtkBooleanMacro(TwoSidedLighting,int);
133 
135 
148  vtkSetMacro(LightFollowCamera,int);
149  vtkGetMacro(LightFollowCamera,int);
150  vtkBooleanMacro(LightFollowCamera,int);
152 
154 
162  vtkGetMacro(AutomaticLightCreation,int);
163  vtkSetMacro(AutomaticLightCreation,int);
164  vtkBooleanMacro(AutomaticLightCreation,int);
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, int);
211  vtkGetMacro(Erase, int);
212  vtkBooleanMacro(Erase, int);
214 
216 
221  vtkSetMacro(Draw, int);
222  vtkGetMacro(Draw, int);
223  vtkBooleanMacro(Draw, int);
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();
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 
414  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
415  vtkWindow *GetVTKWindow() VTK_OVERRIDE;
417 
419 
425  vtkSetMacro(BackingStore,int);
426  vtkGetMacro(BackingStore,int);
427  vtkBooleanMacro(BackingStore,int);
429 
431 
436  vtkSetMacro(Interactive,int);
437  vtkGetMacro(Interactive,int);
438  vtkBooleanMacro(Interactive,int);
440 
442 
453  virtual void SetLayer(int layer);
454  vtkGetMacro(Layer, int);
456 
458 
468  vtkGetMacro(PreserveColorBuffer, int);
469  vtkSetMacro(PreserveColorBuffer, int);
470  vtkBooleanMacro(PreserveColorBuffer, int);
472 
474 
478  vtkSetMacro(PreserveDepthBuffer, int);
479  vtkGetMacro(PreserveDepthBuffer, int);
480  vtkBooleanMacro(PreserveDepthBuffer, int);
482 
487  int Transparent();
488 
492  void WorldToView() VTK_OVERRIDE;
493 
495 
498  void ViewToWorld() VTK_OVERRIDE;
499  void ViewToWorld(double &wx, double &wy, double &wz) VTK_OVERRIDE;
501 
505  void WorldToView(double &wx, double &wy, double &wz) VTK_OVERRIDE;
506 
511  double GetZ (int x, int y);
512 
516  vtkMTimeType GetMTime() VTK_OVERRIDE;
517 
519 
522  vtkGetMacro( LastRenderTimeInSeconds, double );
524 
526 
532  vtkGetMacro( NumberOfPropsRendered, int );
534 
536 
543  vtkAssemblyPath* PickProp(double selectionX, double selectionY) VTK_OVERRIDE
544  {
545  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
546  }
547  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
548  double selectionX2, double selectionY2) VTK_OVERRIDE;
550 
556  virtual void StereoMidpoint() { return; };
557 
564  double GetTiledAspectRatio();
565 
572  { return (this->ActiveCamera != NULL); }
573 
574 
576 
586  vtkSetMacro(UseDepthPeeling,int);
587  vtkGetMacro(UseDepthPeeling,int);
588  vtkBooleanMacro(UseDepthPeeling,int);
590 
596  vtkSetMacro(UseDepthPeelingForVolumes, bool)
597  vtkGetMacro(UseDepthPeelingForVolumes, bool)
598  vtkBooleanMacro(UseDepthPeelingForVolumes, bool)
599 
600  //@{
610  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
611  vtkGetMacro(OcclusionRatio,double);
613 
615 
620  vtkSetMacro(MaximumNumberOfPeels,int);
621  vtkGetMacro(MaximumNumberOfPeels,int);
623 
625 
630  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
632 
634 
640  void SetDelegate(vtkRendererDelegate *d);
641  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
643 
645 
650  vtkGetObjectMacro(Selector, vtkHardwareSelector);
652 
654 
658  virtual void SetBackgroundTexture(vtkTexture*);
659  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
661 
663 
667  vtkSetMacro(TexturedBackground,bool);
668  vtkGetMacro(TexturedBackground,bool);
669  vtkBooleanMacro(TexturedBackground,bool);
671 
672  // method to release graphics resources in any derived renderers.
673  virtual void ReleaseGraphicsResources(vtkWindow *);
674 
676 
679  vtkSetMacro(UseFXAA, bool)
680  vtkGetMacro(UseFXAA, bool)
681  vtkBooleanMacro(UseFXAA, bool)
683 
685 
688  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
689  virtual void SetFXAAOptions(vtkFXAAOptions*);
691 
693 
697  vtkSetMacro(UseShadows,int);
698  vtkGetMacro(UseShadows,int);
699  vtkBooleanMacro(UseShadows,int);
701 
703 
707  vtkSetMacro(UseHiddenLineRemoval, int)
708  vtkGetMacro(UseHiddenLineRemoval, int)
709  vtkBooleanMacro(UseHiddenLineRemoval, int)
711 
712  // Set/Get a custom render pass.
713  // Initial value is NULL.
714  void SetPass(vtkRenderPass *p);
715  vtkGetObjectMacro(Pass, vtkRenderPass);
716 
718 
721  vtkGetObjectMacro(Information, vtkInformation);
722  virtual void SetInformation(vtkInformation*);
724 
725 protected:
726  vtkRenderer();
727  ~vtkRenderer() VTK_OVERRIDE;
728 
729  // internal method for doing a render for picking purposes
730  virtual void PickRender(vtkPropCollection *props);
731  virtual void PickGeometry();
732 
733  // internal method to expand bounding box to consider model transform
734  // matrix or model view transform matrix based on whether or not deering
735  // frustum is used.
736  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
737 
740 
743 
746 
747  double Ambient[3];
750  double TimeFactor;
754  unsigned char *BackingImage;
755  int BackingStoreSize[2];
757 
759 
761 
762  // Allocate the time for each prop
763  void AllocateTime();
764 
765  // Internal variables indicating the number of props
766  // that have been or will be rendered in each category.
768 
769  // A temporary list of props used for culling, and traversal
770  // of all props when rendering
773 
774  // A temporary list used for picking
777 
778  // Indicates if the renderer should receive events from an interactor.
779  // Typically only used in conjunction with transparent renderers.
781 
782  // Shows what layer this renderer belongs to. Only of interested when
783  // there are layered renderers.
784  int Layer;
787 
788  // Holds the result of ComputeVisiblePropBounds so that it is visible from
789  // wrapped languages
790  double ComputedVisiblePropBounds[6];
791 
800 
806 
813  int Erase;
814 
820  int Draw;
821 
826 
832  virtual int UpdateGeometry();
833 
841  virtual int UpdateTranslucentPolygonalGeometry();
842 
848  virtual int UpdateOpaquePolygonalGeometry();
849 
854  virtual int UpdateCamera(void);
855 
861  virtual int UpdateLightGeometry(void);
862 
867  virtual int UpdateLights(void) {return 0;}
868 
874  vtkCamera *GetActiveCameraAndResetIfCreated();
875 
880  bool UseFXAA;
881 
886 
892 
898 
906 
912 
923 
930 
937 
938  // HARDWARE SELECTION ----------------------------------------
939  friend class vtkHardwareSelector;
940 
945  { this->Selector = selector; this->Modified(); }
946 
947  // End Ivars for visible cell selecting.
949 
950  //---------------------------------------------------------------
951  friend class vtkRendererDelegate;
953 
956 
957  friend class vtkRenderPass;
959 
960  // Arbitrary extra information associated with this renderer
962 
963 private:
964  vtkRenderer(const vtkRenderer&) VTK_DELETE_FUNCTION;
965  void operator=(const vtkRenderer&) VTK_DELETE_FUNCTION;
966 
967 };
968 
970  return this->Lights;
971 }
972 
976 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
977 
978 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
vtkInformation * Information
Definition: vtkRenderer.h:961
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:805
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
int UseHiddenLineRemoval
When this flag is on and the rendering engine supports it, wireframe polydata will be rendered using ...
Definition: vtkRenderer.h:897
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:543
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
int BackingStore
Definition: vtkRenderer.h:753
int PreserveColorBuffer
Definition: vtkRenderer.h:785
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkRenderPass * Pass
Definition: vtkRenderer.h:958
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.
int UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:905
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:748
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:922
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:867
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
bool UseDepthPeelingForVolumes
This this flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:911
virtual void SetRenderWindow(vtkRenderWindow *renwin)
abstract specification for renderers
Definition: vtkRenderer.h:57
double AllocatedRenderTime
Definition: vtkRenderer.h:749
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:952
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:756
an ordered list of Props
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:758
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:745
vtkProp ** PropArray
Definition: vtkRenderer.h:771
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:742
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:944
double TimeFactor
Definition: vtkRenderer.h:750
a list of nodes that form an assembly path
unsigned char * BackingImage
Definition: vtkRenderer.h:754
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:556
a virtual camera for 3D rendering
Definition: vtkCamera.h:44
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:738
a virtual light for 3D rendering
Definition: vtkLight.h:55
bool UseFXAA
If this flag is on and the rendering engine supports it, FXAA will be used to antialias the scene...
Definition: vtkRenderer.h:880
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:969
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:825
int PropArrayCount
Definition: vtkRenderer.h:772
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:885
handles properties associated with a texture map
Definition: vtkTexture.h:64
virtual void Modified()
Update the modification time for this object.
vtkLightCollection * Lights
Definition: vtkRenderer.h:741
int PathArrayCount
Definition: vtkRenderer.h:776
int Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:813
vtkActorCollection * Actors
Definition: vtkRenderer.h:744
int Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:820
bool TexturedBackground
Definition: vtkRenderer.h:954
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:948
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:799
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:891
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:936
Render the props of a vtkRenderer.
manager for OpenGL-based selection.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:955
int TwoSidedLighting
Definition: vtkRenderer.h:751
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:414
int LightFollowCamera
Definition: vtkRenderer.h:760
int AutomaticLightCreation
Definition: vtkRenderer.h:752
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:976
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
int PreserveDepthBuffer
Definition: vtkRenderer.h:786
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
vtkAssemblyPath ** PathArray
Definition: vtkRenderer.h:775
int NumberOfPropsRendered
Definition: vtkRenderer.h:767
vtkLight * CreatedLight
Definition: vtkRenderer.h:739
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:571
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:929