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 "vtkViewport.h"
44 
45 #include "vtkVolumeCollection.h" // Needed for access in inline members
46 #include "vtkActorCollection.h" // Needed for access in inline members
47 
48 class vtkRenderWindow;
49 class vtkVolume;
50 class vtkCuller;
51 class vtkActor;
52 class vtkActor2D;
53 class vtkCamera;
54 class vtkLightCollection;
56 class vtkLight;
57 class vtkPainter;
61 class vtkRenderPass;
62 class vtkTexture;
63 
64 #if !defined(VTK_LEGACY_REMOVE)
66 #endif
67 
68 
70 {
71 public:
72  vtkTypeMacro(vtkRenderer,vtkViewport);
73  void PrintSelf(ostream& os, vtkIndent indent);
74 
78  static vtkRenderer *New();
79 
81 
84  void AddActor(vtkProp *p);
85  void AddVolume(vtkProp *p);
86  void RemoveActor(vtkProp *p);
87  void RemoveVolume(vtkProp *p);
89 
91  void AddLight(vtkLight *);
92 
94  void RemoveLight(vtkLight *);
95 
97  void RemoveAllLights();
98 
100  vtkLightCollection *GetLights();
101 
105  void SetLightCollection(vtkLightCollection *lights);
106 
108  void CreateLight(void);
109 
113  virtual vtkLight *MakeLight();
114 
116 
120  vtkGetMacro(TwoSidedLighting,int);
121  vtkSetMacro(TwoSidedLighting,int);
122  vtkBooleanMacro(TwoSidedLighting,int);
124 
126 
136  vtkSetMacro(LightFollowCamera,int);
137  vtkGetMacro(LightFollowCamera,int);
138  vtkBooleanMacro(LightFollowCamera,int);
140 
142 
148  vtkGetMacro(AutomaticLightCreation,int);
149  vtkSetMacro(AutomaticLightCreation,int);
150  vtkBooleanMacro(AutomaticLightCreation,int);
152 
156  virtual int UpdateLightsGeometryToFollowCamera(void);
157 
159  vtkVolumeCollection *GetVolumes();
160 
162  vtkActorCollection *GetActors();
163 
165  void SetActiveCamera(vtkCamera *);
166 
170  vtkCamera *GetActiveCamera();
171 
175  virtual vtkCamera *MakeCamera();
176 
178 
182  vtkSetMacro(Erase, int);
183  vtkGetMacro(Erase, int);
184  vtkBooleanMacro(Erase, int);
186 
188 
191  vtkSetMacro(Draw, int);
192  vtkGetMacro(Draw, int);
193  vtkBooleanMacro(Draw, int);
195 
197  void AddCuller(vtkCuller *);
198 
200  void RemoveCuller(vtkCuller *);
201 
203  vtkCullerCollection *GetCullers();
204 
206 
207  vtkSetVector3Macro(Ambient,double);
208  vtkGetVectorMacro(Ambient,double,3);
210 
212 
214  vtkSetMacro(AllocatedRenderTime,double);
215  virtual double GetAllocatedRenderTime();
217 
222  virtual double GetTimeFactor();
223 
228  virtual void Render();
229 
232  virtual void DeviceRender() =0;
233 
238  virtual void DeviceRenderTranslucentPolygonalGeometry();
239 
241  virtual void Clear() {};
242 
244  int VisibleActorCount();
245 
247  int VisibleVolumeCount();
248 
251  void ComputeVisiblePropBounds( double bounds[6] );
252 
254  double *ComputeVisiblePropBounds();
255 
258  void ResetCameraClippingRange();
259 
261 
264  void ResetCameraClippingRange( double bounds[6] );
265  void ResetCameraClippingRange( double xmin, double xmax,
266  double ymin, double ymax,
267  double zmin, double zmax);
269 
271 
275  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
276  vtkGetMacro(NearClippingPlaneTolerance,double);
278 
284  void ResetCamera();
285 
293  void ResetCamera(double bounds[6]);
294 
296 
297  void ResetCamera(double xmin, double xmax, double ymin, double ymax,
298  double zmin, double zmax);
300 
302 
305  void SetRenderWindow(vtkRenderWindow *);
306  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
307  virtual vtkWindow *GetVTKWindow();
309 
311 
314  vtkSetMacro(BackingStore,int);
315  vtkGetMacro(BackingStore,int);
316  vtkBooleanMacro(BackingStore,int);
318 
320 
323  vtkSetMacro(Interactive,int);
324  vtkGetMacro(Interactive,int);
325  vtkBooleanMacro(Interactive,int);
327 
329 
331  vtkSetMacro(Layer, int);
332  vtkGetMacro(Layer, int);
334 
336 
338  vtkSetMacro(PreserveDepthBuffer, int);
339  vtkGetMacro(PreserveDepthBuffer, int);
340  vtkBooleanMacro(PreserveDepthBuffer, int);
342 
345  int Transparent();
346 
348  void WorldToView();
349 
351 
352  void ViewToWorld();
353  virtual void ViewToWorld(double &wx, double &wy, double &wz);
355 
357  virtual void WorldToView(double &wx, double &wy, double &wz);
358 
361  double GetZ (int x, int y);
362 
364  unsigned long GetMTime();
365 
367 
368  vtkGetMacro( LastRenderTimeInSeconds, double );
370 
372 
376  vtkGetMacro( NumberOfPropsRendered, int );
378 
380 
385  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
386  {
387  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
388  }
389  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
390  double selectionX2, double selectionY2);
392 
396  virtual void StereoMidpoint() { return; };
397 
402  double GetTiledAspectRatio();
403 
405 
408  int IsActiveCameraCreated()
409  { return (this->ActiveCamera != NULL); }
411 
412 
414 
421  vtkSetMacro(UseDepthPeeling,int);
422  vtkGetMacro(UseDepthPeeling,int);
423  vtkBooleanMacro(UseDepthPeeling,int);
425 
427 
434  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
435  vtkGetMacro(OcclusionRatio,double);
437 
439 
442  vtkSetMacro(MaximumNumberOfPeels,int);
443  vtkGetMacro(MaximumNumberOfPeels,int);
445 
447 
449  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
451 
453 
457  void SetDelegate(vtkRendererDelegate *d);
458  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
460 
462 
463  void SetPass(vtkRenderPass *p);
464  vtkGetObjectMacro(Pass,vtkRenderPass);
466 
468 
471  vtkGetObjectMacro(Selector, vtkHardwareSelector);
473 
475 
477  void SetBackgroundTexture(vtkTexture*);
478  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
480 
482 
484  vtkSetMacro(TexturedBackground,bool);
485  vtkGetMacro(TexturedBackground,bool);
486  vtkBooleanMacro(TexturedBackground,bool);
488 
489 //BTX
490 protected:
491  vtkRenderer();
492  ~vtkRenderer();
493 
494  // internal method for doing a render for picking purposes
495  virtual void PickRender(vtkPropCollection *props);
496  virtual void PickGeometry();
497 
498  // internal method to expand bounding box to consider model transform
499  // matrix or model view transform matrix based on whether or not deering
500  // frustum is used.
501  virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
502 
505 
508 
511 
512  double Ambient[3];
515  double TimeFactor;
519  unsigned char *BackingImage;
520  int BackingStoreSize[2];
522 
524 
526 
527  // Allocate the time for each prop
528  void AllocateTime();
529 
530  // Internal variables indicating the number of props
531  // that have been or will be rendered in each category.
533 
534  // A temporary list of props used for culling, and traversal
535  // of all props when rendering
538 
539  // A temporary list used for picking
542 
543  // Indicates if the renderer should receive events from an interactor.
544  // Typically only used in conjunction with transparent renderers.
546 
547  // Shows what layer this renderer belongs to. Only of interested when
548  // there are layered renderers.
549  int Layer;
551 
552  // Holds the result of ComputeVisiblePropBounds so that it is visible from
553  // wrapped languages
554  double ComputedVisiblePropBounds[6];
555 
562 
567  int Erase;
568 
572  int Draw;
573 
577  virtual int UpdateGeometry(void);
578 
583  virtual int UpdateTranslucentPolygonalGeometry();
584 
587  virtual int UpdateCamera(void);
588 
592  virtual int UpdateLightGeometry(void);
593 
596  virtual int UpdateLights(void) {return 0;}
597 
600  vtkCamera *GetActiveCameraAndResetIfCreated();
601 
606 
615 
620 
624 
625 #if !defined(VTK_LEGACY_REMOVE)
626  // VISIBLE CELL SELECTION ----------------------------------------
628 
630 
633  enum {NOT_SELECTING = 0, COLOR_BY_PROCESSOR, COLOR_BY_ACTOR,
634  COLOR_BY_CELL_ID_HIGH, COLOR_BY_CELL_ID_MID, COLOR_BY_CELL_ID_LOW,
635  COLOR_BY_VERTEX};
637 
638  vtkSetMacro(SelectMode, int);
639  vtkSetMacro(SelectConst, unsigned int);
640 
644 
646  virtual int UpdateGeometryForSelection(void);
647 
649 
651  vtkPainter* SwapInSelectablePainter(vtkProp *,
652  int &);
654 
656 
658  void SwapOutSelectablePainter(vtkProp *,
659  vtkPainter*,
660  int );
662 
664 
668 
669  // Ivars for visible cell selecting
671  unsigned int SelectConst;
673  // End Ivars for visible cell selecting.
674 #endif
675 
676  // HARDWARE SELECTION ----------------------------------------
677  friend class vtkHardwareSelector;
678 
680 
681  void SetSelector(vtkHardwareSelector* selector)
682  { this->Selector = selector; this->Modified(); }
684 
685  // End Ivars for visible cell selecting.
687 
688  //---------------------------------------------------------------
689  friend class vtkRendererDelegate;
691 
692  friend class vtkRenderPass;
694 
697 
698 private:
699  vtkRenderer(const vtkRenderer&); // Not implemented.
700  void operator=(const vtkRenderer&); // Not implemented.
701 //ETX
702 };
703 
705  return this->Lights;
706 }
707 
710 
711 
712 #endif