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 
263  void ResetCameraClippingRange( double bounds[6] );
264  void ResetCameraClippingRange( double xmin, double xmax,
265  double ymin, double ymax,
266  double zmin, double zmax);
268 
270 
274  vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
275  vtkGetMacro(NearClippingPlaneTolerance,double);
277 
283  void ResetCamera();
284 
292  void ResetCamera(double bounds[6]);
293 
295 
296  void ResetCamera(double xmin, double xmax, double ymin, double ymax,
297  double zmin, double zmax);
299 
301 
304  void SetRenderWindow(vtkRenderWindow *);
305  vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
306  virtual vtkWindow *GetVTKWindow();
308 
310 
313  vtkSetMacro(BackingStore,int);
314  vtkGetMacro(BackingStore,int);
315  vtkBooleanMacro(BackingStore,int);
317 
319 
322  vtkSetMacro(Interactive,int);
323  vtkGetMacro(Interactive,int);
324  vtkBooleanMacro(Interactive,int);
326 
328 
330  vtkSetMacro(Layer, int);
331  vtkGetMacro(Layer, int);
333 
335 
337  vtkSetMacro(PreserveDepthBuffer, int);
338  vtkGetMacro(PreserveDepthBuffer, int);
339  vtkBooleanMacro(PreserveDepthBuffer, int);
341 
344  int Transparent();
345 
347  void WorldToView();
348 
350 
351  void ViewToWorld();
352  virtual void ViewToWorld(double &wx, double &wy, double &wz);
354 
356  virtual void WorldToView(double &wx, double &wy, double &wz);
357 
360  double GetZ (int x, int y);
361 
363  unsigned long GetMTime();
364 
366 
367  vtkGetMacro( LastRenderTimeInSeconds, double );
369 
371 
375  vtkGetMacro( NumberOfPropsRendered, int );
377 
379 
384  vtkAssemblyPath* PickProp(double selectionX, double selectionY)
385  {
386  return this->PickProp(selectionX, selectionY, selectionX, selectionY);
387  }
388  vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
389  double selectionX2, double selectionY2);
391 
395  virtual void StereoMidpoint() { return; };
396 
401  double GetTiledAspectRatio();
402 
404 
407  int IsActiveCameraCreated()
408  { return (this->ActiveCamera != NULL); }
410 
411 
413 
420  vtkSetMacro(UseDepthPeeling,int);
421  vtkGetMacro(UseDepthPeeling,int);
422  vtkBooleanMacro(UseDepthPeeling,int);
424 
426 
433  vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
434  vtkGetMacro(OcclusionRatio,double);
436 
438 
441  vtkSetMacro(MaximumNumberOfPeels,int);
442  vtkGetMacro(MaximumNumberOfPeels,int);
444 
446 
448  vtkGetMacro(LastRenderingUsedDepthPeeling,int);
450 
452 
456  void SetDelegate(vtkRendererDelegate *d);
457  vtkGetObjectMacro(Delegate,vtkRendererDelegate);
459 
461 
462  void SetPass(vtkRenderPass *p);
463  vtkGetObjectMacro(Pass,vtkRenderPass);
465 
467 
470  vtkGetObjectMacro(Selector, vtkHardwareSelector);
472 
474 
476  void SetBackgroundTexture(vtkTexture*);
477  vtkGetObjectMacro(BackgroundTexture, vtkTexture);
479 
481 
483  vtkSetMacro(TexturedBackground,bool);
484  vtkGetMacro(TexturedBackground,bool);
485  vtkBooleanMacro(TexturedBackground,bool);
487 
488 //BTX
489 protected:
490  vtkRenderer();
491  ~vtkRenderer();
492 
493  // internal method for doing a render for picking purposes
494  virtual void PickRender(vtkPropCollection *props);
495  virtual void PickGeometry();
496 
499 
502 
505 
506  double Ambient[3];
509  double TimeFactor;
513  unsigned char *BackingImage;
514  int BackingStoreSize[2];
516 
518 
520 
521  // Allocate the time for each prop
522  void AllocateTime();
523 
524  // Internal variables indicating the number of props
525  // that have been or will be rendered in each category.
527 
528  // A temporary list of props used for culling, and traversal
529  // of all props when rendering
532 
533  // A temporary list used for picking
536 
537  // Indicates if the renderer should receive events from an interactor.
538  // Typically only used in conjunction with transparent renderers.
540 
541  // Shows what layer this renderer belongs to. Only of interested when
542  // there are layered renderers.
543  int Layer;
545 
546  // Holds the result of ComputeVisiblePropBounds so that it is visible from
547  // wrapped languages
548  double ComputedVisiblePropBounds[6];
549 
556 
561  int Erase;
562 
566  int Draw;
567 
571  virtual int UpdateGeometry(void);
572 
577  virtual int UpdateTranslucentPolygonalGeometry();
578 
581  virtual int UpdateCamera(void);
582 
586  virtual int UpdateLightGeometry(void);
587 
590  virtual int UpdateLights(void) {return 0;}
591 
594  vtkCamera *GetActiveCameraAndResetIfCreated();
595 
600 
609 
614 
618 
619 #if !defined(VTK_LEGACY_REMOVE)
620  // VISIBLE CELL SELECTION ----------------------------------------
622 
624 
627  enum {NOT_SELECTING = 0, COLOR_BY_PROCESSOR, COLOR_BY_ACTOR,
628  COLOR_BY_CELL_ID_HIGH, COLOR_BY_CELL_ID_MID, COLOR_BY_CELL_ID_LOW,
629  COLOR_BY_VERTEX};
631 
632  vtkSetMacro(SelectMode, int);
633  vtkSetMacro(SelectConst, unsigned int);
634 
638 
640  virtual int UpdateGeometryForSelection(void);
641 
643 
645  vtkPainter* SwapInSelectablePainter(vtkProp *,
646  int &);
648 
650 
652  void SwapOutSelectablePainter(vtkProp *,
653  vtkPainter*,
654  int );
656 
658 
662 
663  // Ivars for visible cell selecting
665  unsigned int SelectConst;
667  // End Ivars for visible cell selecting.
668 #endif
669 
670  // HARDWARE SELECTION ----------------------------------------
671  friend class vtkHardwareSelector;
672 
674 
675  void SetSelector(vtkHardwareSelector* selector)
676  { this->Selector = selector; this->Modified(); }
678 
679  // End Ivars for visible cell selecting.
681 
682  //---------------------------------------------------------------
683  friend class vtkRendererDelegate;
685 
686  friend class vtkRenderPass;
688 
691 
692 private:
693  vtkRenderer(const vtkRenderer&); // Not implemented.
694  void operator=(const vtkRenderer&); // Not implemented.
695 //ETX
696 };
697 
699  return this->Lights;
700 }
701 
704 
705 
706 #endif