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 =========================================================================*/
40 #ifndef vtkRenderer_h
41 #define vtkRenderer_h
42 
43 #include "vtkRenderingCoreModule.h" // For export macro
44 #include "vtkViewport.h"
45 
46 #include "vtkVolumeCollection.h" // Needed for access in inline members
47 #include "vtkActorCollection.h" // Needed for access in inline members
48 
49 class vtkRenderWindow;
50 class vtkVolume;
51 class vtkCuller;
52 class vtkActor;
53 class vtkActor2D;
54 class vtkCamera;
55 class vtkLightCollection;
57 class vtkLight;
60 class vtkTexture;
61 
63 {
64 public:
65  vtkTypeMacro(vtkRenderer,vtkViewport);
66  void PrintSelf(ostream& os, vtkIndent indent);
67 
71  static vtkRenderer *New();
72 
74 
77  void AddActor(vtkProp *p);
78  void AddVolume(vtkProp *p);
79  void RemoveActor(vtkProp *p);
80  void RemoveVolume(vtkProp *p);
82 
84  void AddLight(vtkLight *);
85 
87  void RemoveLight(vtkLight *);
88 
90  void RemoveAllLights();
91 
93  vtkLightCollection *GetLights();
94 
98  void SetLightCollection(vtkLightCollection *lights);
99 
101  void CreateLight(void);
102 
106  virtual vtkLight *MakeLight();
107 
109 
113  vtkGetMacro(TwoSidedLighting,int);
114  vtkSetMacro(TwoSidedLighting,int);
115  vtkBooleanMacro(TwoSidedLighting,int);
117 
119 
129  vtkSetMacro(LightFollowCamera,int);
130  vtkGetMacro(LightFollowCamera,int);
131  vtkBooleanMacro(LightFollowCamera,int);
133 
135 
141  vtkGetMacro(AutomaticLightCreation,int);
142  vtkSetMacro(AutomaticLightCreation,int);
143  vtkBooleanMacro(AutomaticLightCreation,int);
145 
149  virtual int UpdateLightsGeometryToFollowCamera(void);
150 
152  vtkVolumeCollection *GetVolumes();
153 
155  vtkActorCollection *GetActors();
156 
158  void SetActiveCamera(vtkCamera *);
159 
163  vtkCamera *GetActiveCamera();
164 
168  virtual vtkCamera *MakeCamera();
169 
171 
175  vtkSetMacro(Erase, int);
176  vtkGetMacro(Erase, int);
177  vtkBooleanMacro(Erase, int);
179 
181 
184  vtkSetMacro(Draw, int);
185  vtkGetMacro(Draw, int);
186  vtkBooleanMacro(Draw, int);
188 
192  int CaptureGL2PSSpecialProp(vtkProp *);
193 
197  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
198 
200  void AddCuller(vtkCuller *);
201 
203  void RemoveCuller(vtkCuller *);
204 
206  vtkCullerCollection *GetCullers();
207 
209 
210  vtkSetVector3Macro(Ambient,double);
211  vtkGetVectorMacro(Ambient,double,3);
213 
215 
217  vtkSetMacro(AllocatedRenderTime,double);
218  virtual double GetAllocatedRenderTime();
220 
225  virtual double GetTimeFactor();
226 
231  virtual void Render();
232 
235  virtual void DeviceRender() =0;
236 
241  virtual void DeviceRenderTranslucentPolygonalGeometry();
242 
244  virtual void Clear() {}
245 
247  int VisibleActorCount();
248 
250  int VisibleVolumeCount();
251 
254  void ComputeVisiblePropBounds( double bounds[6] );
255 
257  double *ComputeVisiblePropBounds();
258 
261  void ResetCameraClippingRange();
262 
264 
267  void ResetCameraClippingRange( double bounds[6] );
268  void ResetCameraClippingRange( double xmin, double xmax,
269  double ymin, double ymax,
270  double zmin, double zmax);
272 
274 
278  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
279  vtkGetMacro(NearClippingPlaneTolerance,double);
281 
287  void ResetCamera();
288 
296  void ResetCamera(double bounds[6]);
297 
299 
300  void ResetCamera(double xmin, double xmax, double ymin, double ymax,
301  double zmin, double zmax);
303 
305 
310  virtual vtkWindow *GetVTKWindow();
312 
314 
317  vtkSetMacro(BackingStore,int);
318  vtkGetMacro(BackingStore,int);
319  vtkBooleanMacro(BackingStore,int);
321 
323 
326  vtkSetMacro(Interactive,int);
327  vtkGetMacro(Interactive,int);
328  vtkBooleanMacro(Interactive,int);
330 
332 
340  virtual void SetLayer(int layer);
341  vtkGetMacro(Layer, int);
343 
345 
352  vtkGetMacro(PreserveColorBuffer, int);
353  vtkSetMacro(PreserveColorBuffer, int);
354  vtkBooleanMacro(PreserveColorBuffer, int);
356 
358 
361  vtkSetMacro(PreserveDepthBuffer, int);
362  vtkGetMacro(PreserveDepthBuffer, int);
363  vtkBooleanMacro(PreserveDepthBuffer, int);
365 
368  int Transparent();
369 
371  void WorldToView();
372 
374 
375  void ViewToWorld();
376  virtual void ViewToWorld(double &wx, double &wy, double &wz);
378 
380  virtual void WorldToView(double &wx, double &wy, double &wz);
381 
384  double GetZ (int x, int y);
385 
387  unsigned long GetMTime();
388 
390 
391  vtkGetMacro( LastRenderTimeInSeconds, double );
393 
395 
399  vtkGetMacro( NumberOfPropsRendered, int );
401 
403 
408  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
409  {
410  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
411  }
412  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
413  double selectionX2, double selectionY2);
415 
419  virtual void StereoMidpoint() { return; };
420 
425  double GetTiledAspectRatio();
426 
428 
432  { return (this->ActiveCamera != NULL); }
434 
435 
437 
444  vtkSetMacro(UseDepthPeeling,int);
445  vtkGetMacro(UseDepthPeeling,int);
446  vtkBooleanMacro(UseDepthPeeling,int);
448 
450 
457  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
458  vtkGetMacro(OcclusionRatio,double);
460 
462 
465  vtkSetMacro(MaximumNumberOfPeels,int);
466  vtkGetMacro(MaximumNumberOfPeels,int);
468 
470 
472  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
474 
476 
480  void SetDelegate(vtkRendererDelegate *d);
481  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
483 
485 
488  vtkGetObjectMacro(Selector, vtkHardwareSelector);
490 
492 
494  virtual void SetBackgroundTexture(vtkTexture*);
495  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
497 
499 
501  vtkSetMacro(TexturedBackground,bool);
502  vtkGetMacro(TexturedBackground,bool);
503  vtkBooleanMacro(TexturedBackground,bool);
505 
506  // method to release graphics resources in any derived renderers.
507  virtual void ReleaseGraphicsResources(vtkWindow *);
508 
510 
511  vtkSetMacro(UseShadows,int);
512  vtkGetMacro(UseShadows,int);
513  vtkBooleanMacro(UseShadows,int);
515 
516 //BTX
517 protected:
518  vtkRenderer();
519  ~vtkRenderer();
520 
521  // internal method for doing a render for picking purposes
522  virtual void PickRender(vtkPropCollection *props);
523  virtual void PickGeometry();
524 
525  // internal method to expand bounding box to consider model transform
526  // matrix or model view transform matrix based on whether or not deering
527  // frustum is used.
528  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
529 
532 
535 
538 
539  double Ambient[3];
542  double TimeFactor;
546  unsigned char *BackingImage;
547  int BackingStoreSize[2];
549 
551 
553 
554  // Allocate the time for each prop
555  void AllocateTime();
556 
557  // Internal variables indicating the number of props
558  // that have been or will be rendered in each category.
560 
561  // A temporary list of props used for culling, and traversal
562  // of all props when rendering
565 
566  // A temporary list used for picking
569 
570  // Indicates if the renderer should receive events from an interactor.
571  // Typically only used in conjunction with transparent renderers.
573 
574  // Shows what layer this renderer belongs to. Only of interested when
575  // there are layered renderers.
576  int Layer;
579 
580  // Holds the result of ComputeVisiblePropBounds so that it is visible from
581  // wrapped languages
582  double ComputedVisiblePropBounds[6];
583 
590 
595  int Erase;
596 
600  int Draw;
601 
605 
606  // Friend class to allow render passes to access functions.
607  friend class vtkRenderPass;
608 
612  virtual int UpdateGeometry();
613 
618  virtual int UpdateTranslucentPolygonalGeometry();
619 
622  virtual int UpdateCamera(void);
623 
627  virtual int UpdateLightGeometry(void);
628 
631  virtual int UpdateLights(void) {return 0;}
632 
635  vtkCamera *GetActiveCameraAndResetIfCreated();
636 
640 
645 
654 
659 
663 
664  // HARDWARE SELECTION ----------------------------------------
665  friend class vtkHardwareSelector;
666 
668 
670  { this->Selector = selector; this->Modified(); }
672 
673  // End Ivars for visible cell selecting.
675 
676  //---------------------------------------------------------------
677  friend class vtkRendererDelegate;
679 
682 
683 private:
684  vtkRenderer(const vtkRenderer&); // Not implemented.
685  void operator=(const vtkRenderer&); // Not implemented.
686 //ETX
687 };
688 
690  return this->Lights;
691 }
692 
695 
696 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
int BackingStore
Definition: vtkRenderer.h:545
int PreserveColorBuffer
Definition: vtkRenderer.h:577
abstract specification for Viewports
Definition: vtkViewport.h:46
int UseDepthPeeling
Definition: vtkRenderer.h:644
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:540
double OcclusionRatio
Definition: vtkRenderer.h:653
virtual int UpdateLights(void)
Definition: vtkRenderer.h:631
a actor that draws 2D data
Definition: vtkActor2D.h:44
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void UpdateCamera(vtkRenderer *renderer)
virtual void SetRenderWindow(vtkRenderWindow *renwin)
abstract specification for renderers
Definition: vtkRenderer.h:62
double AllocatedRenderTime
Definition: vtkRenderer.h:541
a list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:678
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:548
a list of Props
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:550
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:537
vtkProp ** PropArray
Definition: vtkRenderer.h:563
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:534
virtual vtkAssemblyPath * PickProp(double selectionX, double selectionY)=0
void UpdateGeometry(vtkRenderer *renderer)
void SetSelector(vtkHardwareSelector *selector)
Definition: vtkRenderer.h:669
void PrintSelf(ostream &os, vtkIndent indent)
double TimeFactor
Definition: vtkRenderer.h:542
a list of nodes that form an assembly path
unsigned char * BackingImage
Definition: vtkRenderer.h:546
virtual unsigned long GetMTime()
a superclass for prop cullers
Definition: vtkCuller.h:39
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void StereoMidpoint()
Definition: vtkRenderer.h:419
a virtual camera for 3D rendering
Definition: vtkCamera.h:49
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:530
a virtual light for 3D rendering
Definition: vtkLight.h:60
vtkLightCollection * GetLights()
Definition: vtkRenderer.h:689
vtkPropCollection * GL2PSSpecialPropCollection
Definition: vtkRenderer.h:604
int PropArrayCount
Definition: vtkRenderer.h:564
a list of volumes
handles properties associated with a texture map
Definition: vtkTexture.h:69
virtual void Modified()
vtkLightCollection * Lights
Definition: vtkRenderer.h:533
int PathArrayCount
Definition: vtkRenderer.h:568
vtkActorCollection * Actors
Definition: vtkRenderer.h:536
bool TexturedBackground
Definition: vtkRenderer.h:680
void UpdateLightGeometry(vtkRenderer *renderer)
vtkWeakPointer< vtkRenderWindow > RenderWindow
a list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:674
double NearClippingPlaneTolerance
Definition: vtkRenderer.h:589
a list of Cullers
create a window for renderers to draw into
virtual void ViewToWorld()
int LastRenderingUsedDepthPeeling
Definition: vtkRenderer.h:662
#define VTKRENDERINGCORE_EXPORT
Render the props of a vtkRenderer.
manager for OpenGL-based selection.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:681
int TwoSidedLighting
Definition: vtkRenderer.h:543
vtkRenderWindow * GetRenderWindow()
Definition: vtkRenderer.h:309
int LightFollowCamera
Definition: vtkRenderer.h:552
int AutomaticLightCreation
Definition: vtkRenderer.h:544
vtkCullerCollection * GetCullers()
Definition: vtkRenderer.h:694
static vtkObject * New()
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:57
int PreserveDepthBuffer
Definition: vtkRenderer.h:578
virtual vtkWindow * GetVTKWindow()=0
vtkAssemblyPath ** PathArray
Definition: vtkRenderer.h:567
int NumberOfPropsRendered
Definition: vtkRenderer.h:559
vtkLight * CreatedLight
Definition: vtkRenderer.h:531
virtual void WorldToView()
vtkAssemblyPath * PickProp(double selectionX, double selectionY)
Definition: vtkRenderer.h:408
virtual void Clear()
Definition: vtkRenderer.h:244
int IsActiveCameraCreated()
Definition: vtkRenderer.h:431
int MaximumNumberOfPeels
Definition: vtkRenderer.h:658