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;
58 class vtkPainter;
61 class vtkTexture;
62 
64 {
65 public:
66  vtkTypeMacro(vtkRenderer,vtkViewport);
67  void PrintSelf(ostream& os, vtkIndent indent);
68 
72  static vtkRenderer *New();
73 
75 
78  void AddActor(vtkProp *p);
79  void AddVolume(vtkProp *p);
80  void RemoveActor(vtkProp *p);
81  void RemoveVolume(vtkProp *p);
83 
85  void AddLight(vtkLight *);
86 
88  void RemoveLight(vtkLight *);
89 
91  void RemoveAllLights();
92 
94  vtkLightCollection *GetLights();
95 
99  void SetLightCollection(vtkLightCollection *lights);
100 
102  void CreateLight(void);
103 
107  virtual vtkLight *MakeLight();
108 
110 
114  vtkGetMacro(TwoSidedLighting,int);
115  vtkSetMacro(TwoSidedLighting,int);
116  vtkBooleanMacro(TwoSidedLighting,int);
118 
120 
130  vtkSetMacro(LightFollowCamera,int);
131  vtkGetMacro(LightFollowCamera,int);
132  vtkBooleanMacro(LightFollowCamera,int);
134 
136 
142  vtkGetMacro(AutomaticLightCreation,int);
143  vtkSetMacro(AutomaticLightCreation,int);
144  vtkBooleanMacro(AutomaticLightCreation,int);
146 
150  virtual int UpdateLightsGeometryToFollowCamera(void);
151 
153  vtkVolumeCollection *GetVolumes();
154 
156  vtkActorCollection *GetActors();
157 
159  void SetActiveCamera(vtkCamera *);
160 
164  vtkCamera *GetActiveCamera();
165 
169  virtual vtkCamera *MakeCamera();
170 
172 
176  vtkSetMacro(Erase, int);
177  vtkGetMacro(Erase, int);
178  vtkBooleanMacro(Erase, int);
180 
182 
185  vtkSetMacro(Draw, int);
186  vtkGetMacro(Draw, int);
187  vtkBooleanMacro(Draw, int);
189 
193  int CaptureGL2PSSpecialProp(vtkProp *);
194 
198  void SetGL2PSSpecialPropCollection(vtkPropCollection *);
199 
201  void AddCuller(vtkCuller *);
202 
204  void RemoveCuller(vtkCuller *);
205 
207  vtkCullerCollection *GetCullers();
208 
210 
211  vtkSetVector3Macro(Ambient,double);
212  vtkGetVectorMacro(Ambient,double,3);
214 
216 
218  vtkSetMacro(AllocatedRenderTime,double);
219  virtual double GetAllocatedRenderTime();
221 
226  virtual double GetTimeFactor();
227 
232  virtual void Render();
233 
236  virtual void DeviceRender() =0;
237 
242  virtual void DeviceRenderTranslucentPolygonalGeometry();
243 
245  virtual void Clear() {}
246 
248  int VisibleActorCount();
249 
251  int VisibleVolumeCount();
252 
255  void ComputeVisiblePropBounds( double bounds[6] );
256 
258  double *ComputeVisiblePropBounds();
259 
262  void ResetCameraClippingRange();
263 
265 
268  void ResetCameraClippingRange( double bounds[6] );
269  void ResetCameraClippingRange( double xmin, double xmax,
270  double ymin, double ymax,
271  double zmin, double zmax);
273 
275 
279  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
280  vtkGetMacro(NearClippingPlaneTolerance,double);
282 
288  void ResetCamera();
289 
297  void ResetCamera(double bounds[6]);
298 
300 
301  void ResetCamera(double xmin, double xmax, double ymin, double ymax,
302  double zmin, double zmax);
304 
306 
311  virtual vtkWindow *GetVTKWindow();
313 
315 
318  vtkSetMacro(BackingStore,int);
319  vtkGetMacro(BackingStore,int);
320  vtkBooleanMacro(BackingStore,int);
322 
324 
327  vtkSetMacro(Interactive,int);
328  vtkGetMacro(Interactive,int);
329  vtkBooleanMacro(Interactive,int);
331 
333 
341  virtual void SetLayer(int layer);
342  vtkGetMacro(Layer, int);
344 
346 
353  vtkGetMacro(PreserveColorBuffer, int);
354  vtkSetMacro(PreserveColorBuffer, int);
355  vtkBooleanMacro(PreserveColorBuffer, int);
357 
359 
362  vtkSetMacro(PreserveDepthBuffer, int);
363  vtkGetMacro(PreserveDepthBuffer, int);
364  vtkBooleanMacro(PreserveDepthBuffer, int);
366 
369  int Transparent();
370 
372  void WorldToView();
373 
375 
376  void ViewToWorld();
377  virtual void ViewToWorld(double &wx, double &wy, double &wz);
379 
381  virtual void WorldToView(double &wx, double &wy, double &wz);
382 
385  double GetZ (int x, int y);
386 
388  unsigned long GetMTime();
389 
391 
392  vtkGetMacro( LastRenderTimeInSeconds, double );
394 
396 
400  vtkGetMacro( NumberOfPropsRendered, int );
402 
404 
409  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
410  {
411  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
412  }
413  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
414  double selectionX2, double selectionY2);
416 
420  virtual void StereoMidpoint() { return; };
421 
426  double GetTiledAspectRatio();
427 
429 
433  { return (this->ActiveCamera != NULL); }
435 
436 
438 
445  vtkSetMacro(UseDepthPeeling,int);
446  vtkGetMacro(UseDepthPeeling,int);
447  vtkBooleanMacro(UseDepthPeeling,int);
449 
451 
458  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
459  vtkGetMacro(OcclusionRatio,double);
461 
463 
466  vtkSetMacro(MaximumNumberOfPeels,int);
467  vtkGetMacro(MaximumNumberOfPeels,int);
469 
471 
473  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
475 
477 
481  void SetDelegate(vtkRendererDelegate *d);
482  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
484 
486 
489  vtkGetObjectMacro(Selector, vtkHardwareSelector);
491 
493 
495  virtual void SetBackgroundTexture(vtkTexture*);
496  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
498 
500 
502  vtkSetMacro(TexturedBackground,bool);
503  vtkGetMacro(TexturedBackground,bool);
504  vtkBooleanMacro(TexturedBackground,bool);
506 
507  // method to release graphics resources in any derived renderers.
509 
510 //BTX
511 protected:
512  vtkRenderer();
513  ~vtkRenderer();
514 
515  // internal method for doing a render for picking purposes
516  virtual void PickRender(vtkPropCollection *props);
517  virtual void PickGeometry();
518 
519  // internal method to expand bounding box to consider model transform
520  // matrix or model view transform matrix based on whether or not deering
521  // frustum is used.
522  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
523 
526 
529 
532 
533  double Ambient[3];
536  double TimeFactor;
540  unsigned char *BackingImage;
541  int BackingStoreSize[2];
543 
545 
547 
548  // Allocate the time for each prop
549  void AllocateTime();
550 
551  // Internal variables indicating the number of props
552  // that have been or will be rendered in each category.
554 
555  // A temporary list of props used for culling, and traversal
556  // of all props when rendering
559 
560  // A temporary list used for picking
563 
564  // Indicates if the renderer should receive events from an interactor.
565  // Typically only used in conjunction with transparent renderers.
567 
568  // Shows what layer this renderer belongs to. Only of interested when
569  // there are layered renderers.
570  int Layer;
573 
574  // Holds the result of ComputeVisiblePropBounds so that it is visible from
575  // wrapped languages
576  double ComputedVisiblePropBounds[6];
577 
584 
589  int Erase;
590 
594  int Draw;
595 
599 
600  // Friend class to allow render passes to access functions.
601  friend class vtkRenderPass;
602 
606  virtual int UpdateGeometry();
607 
612  virtual int UpdateTranslucentPolygonalGeometry();
613 
616  virtual int UpdateCamera(void);
617 
621  virtual int UpdateLightGeometry(void);
622 
625  virtual int UpdateLights(void) {return 0;}
626 
629  vtkCamera *GetActiveCameraAndResetIfCreated();
630 
635 
644 
649 
653 
654  // HARDWARE SELECTION ----------------------------------------
655  friend class vtkHardwareSelector;
656 
658 
660  { this->Selector = selector; this->Modified(); }
662 
663  // End Ivars for visible cell selecting.
665 
666  //---------------------------------------------------------------
667  friend class vtkRendererDelegate;
669 
672 
673 private:
674  vtkRenderer(const vtkRenderer&); // Not implemented.
675  void operator=(const vtkRenderer&); // Not implemented.
676 //ETX
677 };
678 
680  return this->Lights;
681 }
682 
685 
686 #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
virtual void ReleaseGraphicsResources(vtkWindow *)
Definition: vtkRenderer.h:508
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
int BackingStore
Definition: vtkRenderer.h:539
int PreserveColorBuffer
Definition: vtkRenderer.h:571
abstract specification for Viewports
Definition: vtkViewport.h:46
int UseDepthPeeling
Definition: vtkRenderer.h:634
vtkRenderWindow * RenderWindow
Definition: vtkRenderer.h:534
double OcclusionRatio
Definition: vtkRenderer.h:643
virtual int UpdateLights(void)
Definition: vtkRenderer.h:625
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:63
double AllocatedRenderTime
Definition: vtkRenderer.h:535
a list of lights
vtkRendererDelegate * Delegate
Definition: vtkRenderer.h:668
vtkTimeStamp RenderTime
Definition: vtkRenderer.h:542
a list of Props
double LastRenderTimeInSeconds
Definition: vtkRenderer.h:544
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
vtkVolumeCollection * Volumes
Definition: vtkRenderer.h:531
vtkProp ** PropArray
Definition: vtkRenderer.h:557
vtkCullerCollection * Cullers
Definition: vtkRenderer.h:528
virtual vtkAssemblyPath * PickProp(double selectionX, double selectionY)=0
void UpdateGeometry(vtkRenderer *renderer)
void SetSelector(vtkHardwareSelector *selector)
Definition: vtkRenderer.h:659
void PrintSelf(ostream &os, vtkIndent indent)
double TimeFactor
Definition: vtkRenderer.h:536
a list of nodes that form an assembly path
unsigned char * BackingImage
Definition: vtkRenderer.h:540
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:420
a virtual camera for 3D rendering
Definition: vtkCamera.h:48
vtkCamera * ActiveCamera
Definition: vtkRenderer.h:524
a virtual light for 3D rendering
Definition: vtkLight.h:60
vtkLightCollection * GetLights()
Definition: vtkRenderer.h:679
vtkPropCollection * GL2PSSpecialPropCollection
Definition: vtkRenderer.h:598
int PropArrayCount
Definition: vtkRenderer.h:558
a list of volumes
handles properties associated with a texture map
Definition: vtkTexture.h:69
virtual void Modified()
vtkLightCollection * Lights
Definition: vtkRenderer.h:527
int PathArrayCount
Definition: vtkRenderer.h:562
vtkActorCollection * Actors
Definition: vtkRenderer.h:530
bool TexturedBackground
Definition: vtkRenderer.h:670
void UpdateLightGeometry(vtkRenderer *renderer)
vtkWeakPointer< vtkRenderWindow > RenderWindow
a list of actors
vtkHardwareSelector * Selector
Definition: vtkRenderer.h:664
double NearClippingPlaneTolerance
Definition: vtkRenderer.h:583
a list of Cullers
create a window for renderers to draw into
Abstract class for drawing poly data.
Definition: vtkPainter.h:63
virtual void ViewToWorld()
int LastRenderingUsedDepthPeeling
Definition: vtkRenderer.h:652
#define VTKRENDERINGCORE_EXPORT
Render the props of a vtkRenderer.
manager for OpenGL-based selection.
vtkTexture * BackgroundTexture
Definition: vtkRenderer.h:671
int TwoSidedLighting
Definition: vtkRenderer.h:537
vtkRenderWindow * GetRenderWindow()
Definition: vtkRenderer.h:310
int LightFollowCamera
Definition: vtkRenderer.h:546
int AutomaticLightCreation
Definition: vtkRenderer.h:538
vtkCullerCollection * GetCullers()
Definition: vtkRenderer.h:684
static vtkObject * New()
Perform part of the rendering of a vtkRenderer.
Definition: vtkRenderPass.h:54
int PreserveDepthBuffer
Definition: vtkRenderer.h:572
virtual vtkWindow * GetVTKWindow()=0
vtkAssemblyPath ** PathArray
Definition: vtkRenderer.h:561
int NumberOfPropsRendered
Definition: vtkRenderer.h:553
vtkLight * CreatedLight
Definition: vtkRenderer.h:525
virtual void WorldToView()
vtkAssemblyPath * PickProp(double selectionX, double selectionY)
Definition: vtkRenderer.h:409
virtual void Clear()
Definition: vtkRenderer.h:245
int IsActiveCameraCreated()
Definition: vtkRenderer.h:432
int MaximumNumberOfPeels
Definition: vtkRenderer.h:648