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);
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 
313  virtual void DeviceRenderTranslucentPolygonalGeometry();
314 
319  virtual void ClearLights(void) {};
320 
324  virtual void Clear() {}
325 
329  int VisibleActorCount();
330 
334  int VisibleVolumeCount();
335 
340  void ComputeVisiblePropBounds( double bounds[6] );
341 
345  double *ComputeVisiblePropBounds();
346 
351  void ResetCameraClippingRange();
352 
354 
360  void ResetCameraClippingRange( double bounds[6] );
361  void ResetCameraClippingRange( double xmin, double xmax,
362  double ymin, double ymax,
363  double zmin, double zmax);
365 
367 
372  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
373  vtkGetMacro(NearClippingPlaneTolerance,double);
375 
377 
382  vtkSetClampMacro(ClippingRangeExpansion,double,0,0.99);
383  vtkGetMacro(ClippingRangeExpansion,double);
385 
392  virtual void ResetCamera();
393 
403  virtual void ResetCamera(double bounds[6]);
404 
408  virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax,
409  double zmin, double zmax);
410 
412 
419  virtual vtkWindow *GetVTKWindow();
421 
423 
429  vtkSetMacro(BackingStore,int);
430  vtkGetMacro(BackingStore,int);
431  vtkBooleanMacro(BackingStore,int);
433 
435 
440  vtkSetMacro(Interactive,int);
441  vtkGetMacro(Interactive,int);
442  vtkBooleanMacro(Interactive,int);
444 
446 
457  virtual void SetLayer(int layer);
458  vtkGetMacro(Layer, int);
460 
462 
472  vtkGetMacro(PreserveColorBuffer, int);
473  vtkSetMacro(PreserveColorBuffer, int);
474  vtkBooleanMacro(PreserveColorBuffer, int);
476 
478 
482  vtkSetMacro(PreserveDepthBuffer, int);
483  vtkGetMacro(PreserveDepthBuffer, int);
484  vtkBooleanMacro(PreserveDepthBuffer, int);
486 
491  int Transparent();
492 
496  void WorldToView();
497 
499 
502  void ViewToWorld();
503  virtual void ViewToWorld(double &wx, double &wy, double &wz);
505 
509  virtual void WorldToView(double &wx, double &wy, double &wz);
510 
515  double GetZ (int x, int y);
516 
521 
523 
526  vtkGetMacro( LastRenderTimeInSeconds, double );
528 
530 
536  vtkGetMacro( NumberOfPropsRendered, int );
538 
540 
547  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
548  {
549  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
550  }
551  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
552  double selectionX2, double selectionY2);
554 
560  virtual void StereoMidpoint() { return; };
561 
568  double GetTiledAspectRatio();
569 
576  { return (this->ActiveCamera != NULL); }
577 
578 
580 
590  vtkSetMacro(UseDepthPeeling,int);
591  vtkGetMacro(UseDepthPeeling,int);
592  vtkBooleanMacro(UseDepthPeeling,int);
594 
596 
605  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
606  vtkGetMacro(OcclusionRatio,double);
608 
610 
615  vtkSetMacro(MaximumNumberOfPeels,int);
616  vtkGetMacro(MaximumNumberOfPeels,int);
618 
620 
625  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
627 
629 
635  void SetDelegate(vtkRendererDelegate *d);
636  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
638 
640 
645  vtkGetObjectMacro(Selector, vtkHardwareSelector);
647 
649 
653  virtual void SetBackgroundTexture(vtkTexture*);
654  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
656 
658 
662  vtkSetMacro(TexturedBackground,bool);
663  vtkGetMacro(TexturedBackground,bool);
664  vtkBooleanMacro(TexturedBackground,bool);
666 
667  // method to release graphics resources in any derived renderers.
668  virtual void ReleaseGraphicsResources(vtkWindow *);
669 
671 
674  vtkSetMacro(UseFXAA, bool)
675  vtkGetMacro(UseFXAA, bool)
676  vtkBooleanMacro(UseFXAA, bool)
678 
680 
683  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
684  virtual void SetFXAAOptions(vtkFXAAOptions*);
686 
688 
692  vtkSetMacro(UseShadows,int);
693  vtkGetMacro(UseShadows,int);
694  vtkBooleanMacro(UseShadows,int);
696 
698 
702  vtkSetMacro(UseHiddenLineRemoval, int)
703  vtkGetMacro(UseHiddenLineRemoval, int)
704  vtkBooleanMacro(UseHiddenLineRemoval, int)
706 
707  // Set/Get a custom render pass.
708  // Initial value is NULL.
709  void SetPass(vtkRenderPass *p);
710  vtkGetObjectMacro(Pass, vtkRenderPass);
711 
713 
716  vtkGetObjectMacro(Information, vtkInformation);
717  virtual void SetInformation(vtkInformation*);
719 
720 protected:
721  vtkRenderer();
722  ~vtkRenderer();
723 
724  // internal method for doing a render for picking purposes
725  virtual void PickRender(vtkPropCollection *props);
726  virtual void PickGeometry();
727 
728  // internal method to expand bounding box to consider model transform
729  // matrix or model view transform matrix based on whether or not deering
730  // frustum is used.
731  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
732 
733  vtkCamera *ActiveCamera;
734  vtkLight *CreatedLight;
735 
738 
741 
742  double Ambient[3];
744  double AllocatedRenderTime;
745  double TimeFactor;
746  int TwoSidedLighting;
747  int AutomaticLightCreation;
748  int BackingStore;
749  unsigned char *BackingImage;
750  int BackingStoreSize[2];
751  vtkTimeStamp RenderTime;
752 
753  double LastRenderTimeInSeconds;
754 
755  int LightFollowCamera;
756 
757  // Allocate the time for each prop
758  void AllocateTime();
759 
760  // Internal variables indicating the number of props
761  // that have been or will be rendered in each category.
762  int NumberOfPropsRendered;
763 
764  // A temporary list of props used for culling, and traversal
765  // of all props when rendering
766  vtkProp **PropArray;
767  int PropArrayCount;
768 
769  // A temporary list used for picking
770  vtkAssemblyPath **PathArray;
771  int PathArrayCount;
772 
773  // Indicates if the renderer should receive events from an interactor.
774  // Typically only used in conjunction with transparent renderers.
775  int Interactive;
776 
777  // Shows what layer this renderer belongs to. Only of interested when
778  // there are layered renderers.
779  int Layer;
780  int PreserveColorBuffer;
781  int PreserveDepthBuffer;
782 
783  // Holds the result of ComputeVisiblePropBounds so that it is visible from
784  // wrapped languages
785  double ComputedVisiblePropBounds[6];
786 
794  double NearClippingPlaneTolerance;
795 
800  double ClippingRangeExpansion;
801 
808  int Erase;
809 
815  int Draw;
816 
820  vtkPropCollection *GL2PSSpecialPropCollection;
821 
827  virtual int UpdateGeometry();
828 
836  virtual int UpdateTranslucentPolygonalGeometry();
837 
843  virtual int UpdateOpaquePolygonalGeometry();
844 
849  virtual int UpdateCamera(void);
850 
856  virtual int UpdateLightGeometry(void);
857 
862  virtual int UpdateLights(void) {return 0;}
863 
869  vtkCamera *GetActiveCameraAndResetIfCreated();
870 
875  bool UseFXAA;
876 
881 
887 
893 
901 
912 
919 
926 
927  // HARDWARE SELECTION ----------------------------------------
928  friend class vtkHardwareSelector;
929 
934  { this->Selector = selector; this->Modified(); }
935 
936  // End Ivars for visible cell selecting.
938 
939  //---------------------------------------------------------------
940  friend class vtkRendererDelegate;
942 
945 
946  friend class vtkRenderPass;
948 
949  // Arbitrary extra information associated with this renderer
951 
952 private:
953  vtkRenderer(const vtkRenderer&) VTK_DELETE_FUNCTION;
954  void operator=(const vtkRenderer&) VTK_DELETE_FUNCTION;
955 
956 };
957 
958 inline vtkLightCollection *vtkRenderer::GetLights() {
959  return this->Lights;
960 }
961 
965 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
966 
967 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkInformation * Information
Definition: vtkRenderer.h:950
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:892
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
Store vtkAlgorithm input/output information.
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkRenderPass * Pass
Definition: vtkRenderer.h:947
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:319
int UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:900
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:911
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
virtual void SetRenderWindow(vtkRenderWindow *renwin)
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
a list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:941
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
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:933
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
a list of nodes that form an assembly path
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:560
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
a virtual light for 3D rendering
Definition: vtkLight.h:61
bool UseFXAA
If this flag is on and the rendering engine supports it, FXAA will be used to antialias the scene...
Definition: vtkRenderer.h:875
virtual vtkMTimeType GetMTime()
Return this object's modified time.
a list of volumes
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:880
handles properties associated with a texture map
Definition: vtkTexture.h:70
virtual void Modified()
Update the modification time for this object.
bool TexturedBackground
Definition: vtkRenderer.h:943
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkWeakPointer< vtkRenderWindow > RenderWindow
a list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:937
a 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:886
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:925
Render the props of a vtkRenderer.
manager for OpenGL-based selection.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:944
vtkRenderWindow * GetRenderWindow()
Specify the rendering window in which to draw.
Definition: vtkRenderer.h:418
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:965
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.
virtual void WorldToView()
Convert world point coordinates to view coordinates.
vtkAssemblyPath * PickProp(double selectionX, double selectionY)
Return the prop (via a vtkAssemblyPath) that has the highest z value at the given x...
Definition: vtkRenderer.h:547
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:324
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:575
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:918