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
47class vtkFXAAOptions;
48class vtkRenderWindow;
49class vtkVolume;
50class vtkCuller;
51class vtkActor;
52class vtkActor2D;
53class vtkCamera;
54class vtkInformation;
57class vtkLight;
60class vtkRenderPass;
61class vtkTexture;
62
63class VTKRENDERINGCORE_EXPORT vtkRenderer : public vtkViewport
64{
65public:
66 vtkTypeMacro(vtkRenderer,vtkViewport);
67 void PrintSelf(ostream& os, vtkIndent indent);
68
74 static vtkRenderer *New();
75
77
82 void AddActor(vtkProp *p);
87
92
97
102
106 vtkLightCollection *GetLights();
107
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
179
184
189
194
201
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
237
244
249
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
305
314
319 virtual void ClearLights(void) {};
320
324 virtual void Clear() {}
325
330
335
340 void ComputeVisiblePropBounds( double bounds[6] );
341
346
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
418 vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
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
492
497
499
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
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
636 vtkGetObjectMacro(Delegate,vtkRendererDelegate);
638
640
645 vtkGetObjectMacro(Selector, vtkHardwareSelector);
647
649
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.
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
720protected:
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];
743 vtkRenderWindow *RenderWindow;
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
870
876
881
887
893
901
912
919
926
927 // HARDWARE SELECTION ----------------------------------------
929
934 { this->Selector = selector; this->Modified(); }
935
936 // End Ivars for visible cell selecting.
938
939 //---------------------------------------------------------------
942
945
946 friend class vtkRenderPass;
948
949 // Arbitrary extra information associated with this renderer
951
952private:
953 vtkRenderer(const vtkRenderer&) VTK_DELETE_FUNCTION;
954 void operator=(const vtkRenderer&) VTK_DELETE_FUNCTION;
955
956};
957
959 return this->Lights;
960}
961
966
967#endif
a actor that draws 2D data
Definition: vtkActor2D.h:46
a list of actors
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
a list of nodes that form an assembly path
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
a list of Cullers
a superclass for prop cullers
Definition: vtkCuller.h:41
Configuration for FXAA implementations.
manager for OpenGL-based selection.
a simple class to control print indentation
Definition: vtkIndent.h:40
Store vtkAlgorithm input/output information.
a list of lights
a virtual light for 3D rendering
Definition: vtkLight.h:62
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
virtual void Modified()
Update the modification time for this object.
a list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:59
create a window for renderers to draw into
Render the props of a vtkRenderer.
abstract specification for renderers
Definition: vtkRenderer.h:64
virtual void ResetCamera(double bounds[6])
Automatically set up the camera based on a specified bounding box (xmin,xmax, ymin,...
void RemoveVolume(vtkProp *p)
virtual void SetLayer(int layer)
Set/Get the layer that this renderer belongs to.
vtkCamera * GetActiveCameraAndResetIfCreated()
Get the current camera and reset it only if it gets created automatically (see GetActiveCamera).
void WorldToView()
Convert world point coordinates to view coordinates.
virtual vtkWindow * GetVTKWindow()
Return the vtkWindow that owns this vtkViewport.
virtual void ClearLights(void)
Internal method temporarily removes lights before reloading them into graphics pipeline.
Definition: vtkRenderer.h:319
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
vtkCamera * GetActiveCamera()
Get the current camera.
void AddCuller(vtkCuller *)
Add an culler to the list of cullers.
vtkRenderPass * Pass
Definition: vtkRenderer.h:947
vtkActorCollection * GetActors()
Return any actors in this renderer.
void ResetCameraClippingRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
double GetTiledAspectRatio()
Compute the aspect ratio of this renderer for the current tile.
void AddLight(vtkLight *)
Add a light to the list of lights.
vtkCullerCollection * GetCullers()
Return the collection of cullers.
Definition: vtkRenderer.h:965
virtual vtkCamera * MakeCamera()
Create a new Camera sutible for use with this type of Renderer.
int UseShadows
If this flag is on and the rendering engine supports it render shadows Initial value is off.
Definition: vtkRenderer.h:886
int UseDepthPeeling
If this flag is on and the GPU supports it, depth peeling is used for rendering translucent materials...
Definition: vtkRenderer.h:900
virtual void ViewToWorld(double &wx, double &wy, double &wz)
int Transparent()
Returns a boolean indicating if this renderer is transparent.
int VisibleActorCount()
Returns the number of visible actors.
virtual vtkLight * MakeLight()
Create a new Light sutible for use with this type of Renderer.
void RemoveLight(vtkLight *)
Remove a light from the list of lights.
void RemoveActor(vtkProp *p)
void SetSelector(vtkHardwareSelector *selector)
Called by vtkHardwareSelector when it begins rendering for selection.
Definition: vtkRenderer.h:933
int MaximumNumberOfPeels
In case of depth peeling, define the maximum number of peeling layers.
Definition: vtkRenderer.h:918
int VisibleVolumeCount()
Returns the number of visible volumes.
vtkMTimeType GetMTime()
Return the MTime of the renderer also considering its ivars.
virtual void StereoMidpoint()
Do anything necessary between rendering the left and right viewpoints in a stereo render.
Definition: vtkRenderer.h:560
bool TexturedBackground
Definition: vtkRenderer.h:943
void RemoveCuller(vtkCuller *)
Remove an actor from the list of cullers.
double OcclusionRatio
In case of use of depth peeling technique for rendering translucent material, define the threshold un...
Definition: vtkRenderer.h:911
int LastRenderingUsedDepthPeeling
Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling.
Definition: vtkRenderer.h:925
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
vtkVolumeCollection * GetVolumes()
Return the collection of volumes.
int CaptureGL2PSSpecialProp(vtkProp *)
This function is called to capture an instance of vtkProp that requires special handling during vtkRe...
static vtkRenderer * New()
Create a vtkRenderer with a black background, a white ambient light, two-sided lighting turned on,...
void ResetCameraClippingRange(double bounds[6])
Reset the camera clipping range based on a bounding box.
virtual void DeviceRenderTranslucentPolygonalGeometry()
Render translucent polygonal geometry.
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:941
void SetLightCollection(vtkLightCollection *lights)
Set the collection of lights.
virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Alternative version of ResetCamera(bounds[6]);.
void ResetCameraClippingRange()
Reset the camera clipping range based on the bounds of the visible actors.
virtual void ReleaseGraphicsResources(vtkWindow *)
void ViewToWorld()
Convert view point coordinates to world coordinates.
int UseHiddenLineRemoval
When this flag is on and the rendering engine supports it, wireframe polydata will be rendered using ...
Definition: vtkRenderer.h:892
void RemoveAllLights()
Remove all lights from the list of lights.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:944
double GetZ(int x, int y)
Given a pixel location, return the Z value.
double * ComputeVisiblePropBounds()
Wrapper-friendly version of ComputeVisiblePropBounds.
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:737
void AddActor(vtkProp *p)
Add/Remove different types of props to the renderer.
virtual double GetTimeFactor()
Get the ratio between allocated time and actual render time.
vtkAssemblyPath * PickProp(double selectionX1, double selectionY1, double selectionX2, double selectionY2)
Return the Prop that has the highest z value at the given x1, y1 and x2,y2 positions in the viewport.
vtkRenderWindow * GetRenderWindow()
Definition: vtkRenderer.h:418
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:937
virtual void WorldToView(double &wx, double &wy, double &wz)
Convert world point coordinates to view coordinates.
vtkLightCollection * Lights
Definition: vtkRenderer.h:736
void CreateLight(void)
Create and add a light to renderer.
void SetActiveCamera(vtkCamera *)
Specify the camera to use for this renderer.
virtual void Render()
CALLED BY vtkRenderWindow ONLY.
vtkLightCollection * GetLights()
Return the collection of lights.
Definition: vtkRenderer.h:958
vtkFXAAOptions * FXAAOptions
Holds the FXAA configuration.
Definition: vtkRenderer.h:880
void SetRenderWindow(vtkRenderWindow *)
Specify the rendering window in which to draw.
virtual void DeviceRenderOpaqueGeometry()
Render opaque polygonal geometry.
virtual void ResetCamera()
Automatically set up the camera based on the visible actors.
virtual void SetBackgroundTexture(vtkTexture *)
Set/Get the texture to be used for the background.
void AddVolume(vtkProp *p)
virtual double GetAllocatedRenderTime()
virtual void Clear()
Clear the image to the background color.
Definition: vtkRenderer.h:324
void ComputeVisiblePropBounds(double bounds[6])
Compute the bounding box of all the visible props Used in ResetCamera() and ResetCameraClippingRange(...
int IsActiveCameraCreated()
This method returns 1 if the ActiveCamera has already been set or automatically created by the render...
Definition: vtkRenderer.h:575
void SetGL2PSSpecialPropCollection(vtkPropCollection *)
Set the prop collection object used during vtkRenderWindow::CaptureGL2PSSpecialProps().
void SetDelegate(vtkRendererDelegate *d)
Set/Get a custom Render call.
virtual void DeviceRender()=0
Create an image.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkInformation * Information
Definition: vtkRenderer.h:950
virtual int UpdateLightsGeometryToFollowCamera(void)
Ask the lights in the scene that are not in world space (for instance, Headlights or CameraLights tha...
handles properties associated with a texture map
Definition: vtkTexture.h:71
record modification and/or execution time
Definition: vtkTimeStamp.h:36
abstract specification for Viewports
Definition: vtkViewport.h:48
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.
a list of volumes
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248