00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00040 #ifndef __vtkRenderer_h
00041 #define __vtkRenderer_h
00042
00043 #include "vtkViewport.h"
00044
00045 #include "vtkVolumeCollection.h"
00046 #include "vtkActorCollection.h"
00047
00048 class vtkRenderWindow;
00049 class vtkVolume;
00050 class vtkCuller;
00051 class vtkActor;
00052 class vtkActor2D;
00053 class vtkCamera;
00054 class vtkLightCollection;
00055 class vtkCullerCollection;
00056 class vtkLight;
00057 class vtkPainter;
00058 class vtkIdentColoredPainter;
00059 class vtkHardwareSelector;
00060 class vtkRendererDelegate;
00061 class vtkRenderPass;
00062 class vtkTexture;
00063
00064 #if !defined(VTK_LEGACY_REMOVE)
00065 class vtkVisibleCellSelector;
00066 #endif
00067
00068
00069 class VTK_RENDERING_EXPORT vtkRenderer : public vtkViewport
00070 {
00071 public:
00072 vtkTypeMacro(vtkRenderer,vtkViewport);
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074
00078 static vtkRenderer *New();
00079
00081
00084 void AddActor(vtkProp *p);
00085 void AddVolume(vtkProp *p);
00086 void RemoveActor(vtkProp *p);
00087 void RemoveVolume(vtkProp *p);
00089
00091 void AddLight(vtkLight *);
00092
00094 void RemoveLight(vtkLight *);
00095
00097 void RemoveAllLights();
00098
00100 vtkLightCollection *GetLights();
00101
00105 void SetLightCollection(vtkLightCollection *lights);
00106
00108 void CreateLight(void);
00109
00113 virtual vtkLight *MakeLight();
00114
00116
00120 vtkGetMacro(TwoSidedLighting,int);
00121 vtkSetMacro(TwoSidedLighting,int);
00122 vtkBooleanMacro(TwoSidedLighting,int);
00124
00126
00136 vtkSetMacro(LightFollowCamera,int);
00137 vtkGetMacro(LightFollowCamera,int);
00138 vtkBooleanMacro(LightFollowCamera,int);
00140
00142
00148 vtkGetMacro(AutomaticLightCreation,int);
00149 vtkSetMacro(AutomaticLightCreation,int);
00150 vtkBooleanMacro(AutomaticLightCreation,int);
00152
00156 virtual int UpdateLightsGeometryToFollowCamera(void);
00157
00159 vtkVolumeCollection *GetVolumes();
00160
00162 vtkActorCollection *GetActors();
00163
00165 void SetActiveCamera(vtkCamera *);
00166
00170 vtkCamera *GetActiveCamera();
00171
00175 virtual vtkCamera *MakeCamera();
00176
00178
00182 vtkSetMacro(Erase, int);
00183 vtkGetMacro(Erase, int);
00184 vtkBooleanMacro(Erase, int);
00186
00188
00191 vtkSetMacro(Draw, int);
00192 vtkGetMacro(Draw, int);
00193 vtkBooleanMacro(Draw, int);
00195
00197 void AddCuller(vtkCuller *);
00198
00200 void RemoveCuller(vtkCuller *);
00201
00203 vtkCullerCollection *GetCullers();
00204
00206
00207 vtkSetVector3Macro(Ambient,double);
00208 vtkGetVectorMacro(Ambient,double,3);
00210
00212
00214 vtkSetMacro(AllocatedRenderTime,double);
00215 virtual double GetAllocatedRenderTime();
00217
00222 virtual double GetTimeFactor();
00223
00228 virtual void Render();
00229
00232 virtual void DeviceRender() =0;
00233
00238 virtual void DeviceRenderTranslucentPolygonalGeometry();
00239
00241 virtual void Clear() {};
00242
00244 int VisibleActorCount();
00245
00247 int VisibleVolumeCount();
00248
00251 void ComputeVisiblePropBounds( double bounds[6] );
00252
00254 double *ComputeVisiblePropBounds();
00255
00258 void ResetCameraClippingRange();
00259
00261
00263 void ResetCameraClippingRange( double bounds[6] );
00264 void ResetCameraClippingRange( double xmin, double xmax,
00265 double ymin, double ymax,
00266 double zmin, double zmax);
00268
00270
00274 vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
00275 vtkGetMacro(NearClippingPlaneTolerance,double);
00277
00283 void ResetCamera();
00284
00292 void ResetCamera(double bounds[6]);
00293
00295
00296 void ResetCamera(double xmin, double xmax, double ymin, double ymax,
00297 double zmin, double zmax);
00299
00301
00304 void SetRenderWindow(vtkRenderWindow *);
00305 vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
00306 virtual vtkWindow *GetVTKWindow();
00308
00310
00313 vtkSetMacro(BackingStore,int);
00314 vtkGetMacro(BackingStore,int);
00315 vtkBooleanMacro(BackingStore,int);
00317
00319
00322 vtkSetMacro(Interactive,int);
00323 vtkGetMacro(Interactive,int);
00324 vtkBooleanMacro(Interactive,int);
00326
00328
00330 vtkSetMacro(Layer, int);
00331 vtkGetMacro(Layer, int);
00333
00335
00337 vtkSetMacro(PreserveDepthBuffer, int);
00338 vtkGetMacro(PreserveDepthBuffer, int);
00339 vtkBooleanMacro(PreserveDepthBuffer, int);
00341
00344 int Transparent();
00345
00347 void WorldToView();
00348
00350
00351 void ViewToWorld();
00352 virtual void ViewToWorld(double &wx, double &wy, double &wz);
00354
00356 virtual void WorldToView(double &wx, double &wy, double &wz);
00357
00360 double GetZ (int x, int y);
00361
00363 unsigned long GetMTime();
00364
00366
00367 vtkGetMacro( LastRenderTimeInSeconds, double );
00369
00371
00375 vtkGetMacro( NumberOfPropsRendered, int );
00377
00379
00384 vtkAssemblyPath* PickProp(double selectionX, double selectionY)
00385 {
00386 return this->PickProp(selectionX, selectionY, selectionX, selectionY);
00387 }
00388 vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
00389 double selectionX2, double selectionY2);
00391
00395 virtual void StereoMidpoint() { return; };
00396
00401 double GetTiledAspectRatio();
00402
00404
00407 int IsActiveCameraCreated()
00408 { return (this->ActiveCamera != NULL); }
00410
00411
00413
00420 vtkSetMacro(UseDepthPeeling,int);
00421 vtkGetMacro(UseDepthPeeling,int);
00422 vtkBooleanMacro(UseDepthPeeling,int);
00424
00426
00433 vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
00434 vtkGetMacro(OcclusionRatio,double);
00436
00438
00441 vtkSetMacro(MaximumNumberOfPeels,int);
00442 vtkGetMacro(MaximumNumberOfPeels,int);
00444
00446
00448 vtkGetMacro(LastRenderingUsedDepthPeeling,int);
00450
00452
00456 void SetDelegate(vtkRendererDelegate *d);
00457 vtkGetObjectMacro(Delegate,vtkRendererDelegate);
00459
00461
00462 void SetPass(vtkRenderPass *p);
00463 vtkGetObjectMacro(Pass,vtkRenderPass);
00465
00467
00470 vtkGetObjectMacro(Selector, vtkHardwareSelector);
00472
00474
00476 void SetBackgroundTexture(vtkTexture*);
00477 vtkGetObjectMacro(BackgroundTexture, vtkTexture);
00479
00481
00483 vtkSetMacro(TexturedBackground,bool);
00484 vtkGetMacro(TexturedBackground,bool);
00485 vtkBooleanMacro(TexturedBackground,bool);
00487
00488
00489 protected:
00490 vtkRenderer();
00491 ~vtkRenderer();
00492
00493
00494 virtual void PickRender(vtkPropCollection *props);
00495 virtual void PickGeometry();
00496
00497 vtkCamera *ActiveCamera;
00498 vtkLight *CreatedLight;
00499
00500 vtkLightCollection *Lights;
00501 vtkCullerCollection *Cullers;
00502
00503 vtkActorCollection *Actors;
00504 vtkVolumeCollection *Volumes;
00505
00506 double Ambient[3];
00507 vtkRenderWindow *RenderWindow;
00508 double AllocatedRenderTime;
00509 double TimeFactor;
00510 int TwoSidedLighting;
00511 int AutomaticLightCreation;
00512 int BackingStore;
00513 unsigned char *BackingImage;
00514 int BackingStoreSize[2];
00515 vtkTimeStamp RenderTime;
00516
00517 double LastRenderTimeInSeconds;
00518
00519 int LightFollowCamera;
00520
00521
00522 void AllocateTime();
00523
00524
00525
00526 int NumberOfPropsRendered;
00527
00528
00529
00530 vtkProp **PropArray;
00531 int PropArrayCount;
00532
00533
00534 vtkAssemblyPath **PathArray;
00535 int PathArrayCount;
00536
00537
00538
00539 int Interactive;
00540
00541
00542
00543 int Layer;
00544 int PreserveDepthBuffer;
00545
00546
00547
00548 double ComputedVisiblePropBounds[6];
00549
00555 double NearClippingPlaneTolerance;
00556
00561 int Erase;
00562
00566 int Draw;
00567
00571 virtual int UpdateGeometry(void);
00572
00577 virtual int UpdateTranslucentPolygonalGeometry();
00578
00581 virtual int UpdateCamera(void);
00582
00586 virtual int UpdateLightGeometry(void);
00587
00590 virtual int UpdateLights(void) {return 0;}
00591
00594 vtkCamera *GetActiveCameraAndResetIfCreated();
00595
00599 int UseDepthPeeling;
00600
00608 double OcclusionRatio;
00609
00613 int MaximumNumberOfPeels;
00614
00617 int LastRenderingUsedDepthPeeling;
00618
00619 #if !defined(VTK_LEGACY_REMOVE)
00620
00621 friend class vtkVisibleCellSelector;
00622
00624
00627 enum {NOT_SELECTING = 0, COLOR_BY_PROCESSOR, COLOR_BY_ACTOR,
00628 COLOR_BY_CELL_ID_HIGH, COLOR_BY_CELL_ID_MID, COLOR_BY_CELL_ID_LOW,
00629 COLOR_BY_VERTEX};
00631
00632 vtkSetMacro(SelectMode, int);
00633 vtkSetMacro(SelectConst, unsigned int);
00634
00637 void SetIdentPainter(vtkIdentColoredPainter*);
00638
00640 virtual int UpdateGeometryForSelection(void);
00641
00643
00645 vtkPainter* SwapInSelectablePainter(vtkProp *,
00646 int &);
00648
00650
00652 void SwapOutSelectablePainter(vtkProp *,
00653 vtkPainter*,
00654 int );
00656
00658
00659 vtkProp **PropsSelectedFrom;
00660 int PropsSelectedFromCount;
00662
00663
00664 int SelectMode;
00665 unsigned int SelectConst;
00666 vtkIdentColoredPainter *IdentPainter;
00667
00668 #endif
00669
00670
00671 friend class vtkHardwareSelector;
00672
00674
00675 void SetSelector(vtkHardwareSelector* selector)
00676 { this->Selector = selector; this->Modified(); }
00678
00679
00680 vtkHardwareSelector* Selector;
00681
00682
00683 friend class vtkRendererDelegate;
00684 vtkRendererDelegate *Delegate;
00685
00686 friend class vtkRenderPass;
00687 vtkRenderPass *Pass;
00688
00689 bool TexturedBackground;
00690 vtkTexture* BackgroundTexture;
00691
00692 private:
00693 vtkRenderer(const vtkRenderer&);
00694 void operator=(const vtkRenderer&);
00695
00696 };
00697
00698 inline vtkLightCollection *vtkRenderer::GetLights() {
00699 return this->Lights;
00700 }
00701
00703 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
00704
00705
00706 #endif