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,vtkTypeBool);
136  vtkSetMacro(TwoSidedLighting,vtkTypeBool);
137  vtkBooleanMacro(TwoSidedLighting,vtkTypeBool);
139 
141 
154  vtkSetMacro(LightFollowCamera,vtkTypeBool);
155  vtkGetMacro(LightFollowCamera,vtkTypeBool);
156  vtkBooleanMacro(LightFollowCamera,vtkTypeBool);
158 
160 
168  vtkGetMacro(AutomaticLightCreation,vtkTypeBool);
169  vtkSetMacro(AutomaticLightCreation,vtkTypeBool);
170  vtkBooleanMacro(AutomaticLightCreation,vtkTypeBool);
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, vtkTypeBool);
217  vtkGetMacro(Erase, vtkTypeBool);
218  vtkBooleanMacro(Erase, vtkTypeBool);
220 
222 
227  vtkSetMacro(Draw, vtkTypeBool);
228  vtkGetMacro(Draw, vtkTypeBool);
229  vtkBooleanMacro(Draw, vtkTypeBool);
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() VTK_SIZEHINT(6);
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 
419  void SetRenderWindow(vtkRenderWindow *);
420  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
421  vtkWindow *GetVTKWindow() override;
423 
425 
431  vtkSetMacro(BackingStore,vtkTypeBool);
432  vtkGetMacro(BackingStore,vtkTypeBool);
433  vtkBooleanMacro(BackingStore,vtkTypeBool);
435 
437 
442  vtkSetMacro(Interactive,vtkTypeBool);
443  vtkGetMacro(Interactive,vtkTypeBool);
444  vtkBooleanMacro(Interactive,vtkTypeBool);
446 
448 
459  virtual void SetLayer(int layer);
460  vtkGetMacro(Layer, int);
462 
464 
474  vtkGetMacro(PreserveColorBuffer, vtkTypeBool);
475  vtkSetMacro(PreserveColorBuffer, vtkTypeBool);
476  vtkBooleanMacro(PreserveColorBuffer, vtkTypeBool);
478 
480 
484  vtkSetMacro(PreserveDepthBuffer, vtkTypeBool);
485  vtkGetMacro(PreserveDepthBuffer, vtkTypeBool);
486  vtkBooleanMacro(PreserveDepthBuffer, vtkTypeBool);
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 
514 
517  void WorldToPose(double &wx, double &wy, double &wz) override;
518  void PoseToWorld(double &wx, double &wy, double &wz) override;
519  void ViewToPose(double &wx, double &wy, double &wz) override;
520  void PoseToView(double &wx, double &wy, double &wz) override;
522 
527  double GetZ (int x, int y);
528 
532  vtkMTimeType GetMTime() override;
533 
535 
538  vtkGetMacro( LastRenderTimeInSeconds, double );
540 
542 
548  vtkGetMacro( NumberOfPropsRendered, int );
550 
552 
559  vtkAssemblyPath* PickProp(double selectionX, double selectionY) override
560  {
561  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
562  }
563  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
564  double selectionX2, double selectionY2) override;
566 
572  virtual void StereoMidpoint() { return; };
573 
580  double GetTiledAspectRatio();
581 
588  { return (this->ActiveCamera != nullptr); }
589 
590 
592 
602  vtkSetMacro(UseDepthPeeling,vtkTypeBool);
603  vtkGetMacro(UseDepthPeeling,vtkTypeBool);
604  vtkBooleanMacro(UseDepthPeeling,vtkTypeBool);
606 
612  vtkSetMacro(UseDepthPeelingForVolumes, bool)
613  vtkGetMacro(UseDepthPeelingForVolumes, bool)
614  vtkBooleanMacro(UseDepthPeelingForVolumes, bool)
615 
616  //@{
626  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
627  vtkGetMacro(OcclusionRatio,double);
629 
631 
636  vtkSetMacro(MaximumNumberOfPeels,int);
637  vtkGetMacro(MaximumNumberOfPeels,int);
639 
641 
646  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
648 
650 
656  void SetDelegate(vtkRendererDelegate *d);
657  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
659 
661 
666  vtkGetObjectMacro(Selector, vtkHardwareSelector);
668 
670 
675  virtual void SetLeftBackgroundTexture(vtkTexture*);
676  vtkTexture* GetLeftBackgroundTexture();
677  virtual void SetBackgroundTexture(vtkTexture*);
678  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
680 
682 
686  virtual void SetRightBackgroundTexture(vtkTexture*);
687  vtkGetObjectMacro(RightBackgroundTexture, vtkTexture);
689 
691 
695  vtkSetMacro(TexturedBackground,bool);
696  vtkGetMacro(TexturedBackground,bool);
697  vtkBooleanMacro(TexturedBackground,bool);
699 
700  // method to release graphics resources in any derived renderers.
701  virtual void ReleaseGraphicsResources(vtkWindow *);
702 
704 
707  vtkSetMacro(UseFXAA, bool)
708  vtkGetMacro(UseFXAA, bool)
709  vtkBooleanMacro(UseFXAA, bool)
711 
713 
716  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
717  virtual void SetFXAAOptions(vtkFXAAOptions*);
719 
721 
725  vtkSetMacro(UseShadows,vtkTypeBool);
726  vtkGetMacro(UseShadows,vtkTypeBool);
727  vtkBooleanMacro(UseShadows,vtkTypeBool);
729 
731 
735  vtkSetMacro(UseHiddenLineRemoval, vtkTypeBool)
736  vtkGetMacro(UseHiddenLineRemoval, vtkTypeBool)
737  vtkBooleanMacro(UseHiddenLineRemoval, vtkTypeBool)
739 
740  // Set/Get a custom render pass.
741  // Initial value is NULL.
742  void SetPass(vtkRenderPass *p);
743  vtkGetObjectMacro(Pass, vtkRenderPass);
744 
746 
749  vtkGetObjectMacro(Information, vtkInformation);
750  virtual void SetInformation(vtkInformation*);
752 
753 protected:
754  vtkRenderer();
755  ~vtkRenderer() override;
756 
757  // internal method to expand bounding box to consider model transform
758  // matrix or model view transform matrix based on whether or not deering
759  // frustum is used.
760  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
761 
764 
767 
770 
771  double Ambient[3];
774  double TimeFactor;
778  unsigned char *BackingImage;
779  int BackingStoreSize[2];
781 
783 
785 
786  // Allocate the time for each prop
787  void AllocateTime();
788 
789  // Internal variables indicating the number of props
790  // that have been or will be rendered in each category.
792 
793  // A temporary list of props used for culling, and traversal
794  // of all props when rendering
797 
798  // Indicates if the renderer should receive events from an interactor.
799  // Typically only used in conjunction with transparent renderers.
801 
802  // Shows what layer this renderer belongs to. Only of interested when
803  // there are layered renderers.
804  int Layer;
807 
808  // Holds the result of ComputeVisiblePropBounds so that it is visible from
809  // wrapped languages
810  double ComputedVisiblePropBounds[6];
811 
820 
826 
834 
841 
846 
852  virtual int UpdateGeometry();
853 
861  virtual int UpdateTranslucentPolygonalGeometry();
862 
868  virtual int UpdateOpaquePolygonalGeometry();
869 
874  virtual int UpdateCamera(void);
875 
881  virtual int UpdateLightGeometry(void);
882 
887  virtual int UpdateLights(void) {return 0;}
888 
894  vtkCamera *GetActiveCameraAndResetIfCreated();
895 
900  bool UseFXAA;
901 
906 
912 
918 
926 
932 
943 
950 
957 
958  // HARDWARE SELECTION ----------------------------------------
959  friend class vtkHardwareSelector;
960 
965  { this->Selector = selector; this->Modified(); }
966 
967  // End Ivars for visible cell selecting.
969 
970  //---------------------------------------------------------------
971  friend class vtkRendererDelegate;
973 
977 
978  friend class vtkRenderPass;
980 
981  // Arbitrary extra information associated with this renderer
983 
984 private:
985  vtkRenderer(const vtkRenderer&) = delete;
986  void operator=(const vtkRenderer&) = delete;
987 
988 };
989 
991  return this->Lights;
992 }
993 
997 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
998 
999 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkInformation * Information
Definition: vtkRenderer.h:982
double ClippingRangeExpansion
Specify enlargement of bounds when resetting the camera clipping range.
Definition: vtkRenderer.h:825
vtkTypeBool UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off...
Definition: vtkRenderer.h:911
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
virtual void WorldToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:256
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:559
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkRenderPass * Pass
Definition: vtkRenderer.h:979
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.
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:772
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:942
virtual int UpdateLights(void)
Ask all lights to load themselves into rendering pipeline.
Definition: vtkRenderer.h:887
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
bool UseDepthPeelingForVolumes
This flag is on and the GPU supports it, depth-peel volumes along with the translucent geometry...
Definition: vtkRenderer.h:931
vtkTypeBool PreserveDepthBuffer
Definition: vtkRenderer.h:806
vtkTypeBool IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:587
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkTypeBool BackingStore
Definition: vtkRenderer.h:777
double AllocatedRenderTime
Definition: vtkRenderer.h:773
an ordered list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:972
vtkTypeBool LightFollowCamera
Definition: vtkRenderer.h:784
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:780
an ordered list of Props
vtkTypeBool TwoSidedLighting
Definition: vtkRenderer.h:775
int vtkTypeBool
Definition: vtkABI.h:69
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:782
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:769
vtkProp ** PropArray
Definition: vtkRenderer.h:795
vtkTypeBool Draw
When this flag is off, render commands are ignored.
Definition: vtkRenderer.h:840
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:766
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:964
double TimeFactor
Definition: vtkRenderer.h:774
a list of nodes that form an assembly path
vtkTypeBool PreserveColorBuffer
Definition: vtkRenderer.h:805
unsigned char * BackingImage
Definition: vtkRenderer.h:778
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:572
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:762
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:900
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:925
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:990
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:249
vtkPropCollection * GL2PSSpecialPropCollection
Temporary collection used by vtkRenderWindow::CaptureGL2PSSpecialProps.
Definition: vtkRenderer.h:845
int PropArrayCount
Definition: vtkRenderer.h:796
an ordered list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:905
handles properties associated with a texture map
Definition: vtkTexture.h:71
virtual void Modified()
Update the modification time for this object.
vtkTypeBool Interactive
Definition: vtkRenderer.h:800
vtkLightCollection * Lights
Definition: vtkRenderer.h:765
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:248
#define VTK_SIZEHINT(...)
vtkActorCollection * Actors
Definition: vtkRenderer.h:768
bool TexturedBackground
Definition: vtkRenderer.h:974
an ordered list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:968
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:255
double NearClippingPlaneTolerance
Specifies the minimum distance of the near clipping plane as a percentage of the far clipping plane d...
Definition: vtkRenderer.h:819
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:917
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:956
Render the props of a vtkRenderer.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:975
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:420
int AutomaticLightCreation
Definition: vtkRenderer.h:776
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:997
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
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
int NumberOfPropsRendered
Definition: vtkRenderer.h:791
vtkLight * CreatedLight
Definition: vtkRenderer.h:763
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:326
vtkTexture * RightBackgroundTexture
Definition: vtkRenderer.h:976
Configuration for FXAA implementations.
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:949
vtkTypeBool Erase
When this flag is off, the renderer will not erase the background or the Zbuffer. ...
Definition: vtkRenderer.h:833