00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00037 #ifndef __vtkRenderer_h
00038 #define __vtkRenderer_h
00039
00040 #include "vtkViewport.h"
00041
00042 #include "vtkVolumeCollection.h"
00043 #include "vtkActorCollection.h"
00044
00045 class vtkRenderWindow;
00046 class vtkVolume;
00047 class vtkCuller;
00048 class vtkActor;
00049 class vtkActor2D;
00050 class vtkCamera;
00051 class vtkLightCollection;
00052 class vtkCullerCollection;
00053 class vtkLight;
00054 class vtkPainter;
00055 class vtkIdentColoredPainter;
00056 class vtkHardwareSelector;
00057 class vtkRendererDelegate;
00058 class vtkRenderPass;
00059 class vtkTexture;
00060
00061 #if !defined(VTK_LEGACY_REMOVE)
00062 class vtkVisibleCellSelector;
00063 #endif
00064
00065
00066 class VTK_RENDERING_EXPORT vtkRenderer : public vtkViewport
00067 {
00068 public:
00069 vtkTypeRevisionMacro(vtkRenderer,vtkViewport);
00070 void PrintSelf(ostream& os, vtkIndent indent);
00071
00075 static vtkRenderer *New();
00076
00078
00081 void AddActor(vtkProp *p);
00082 void AddVolume(vtkProp *p);
00083 void RemoveActor(vtkProp *p);
00084 void RemoveVolume(vtkProp *p);
00086
00088 void AddLight(vtkLight *);
00089
00091 void RemoveLight(vtkLight *);
00092
00094 void RemoveAllLights();
00095
00097 vtkLightCollection *GetLights();
00098
00102 void SetLightCollection(vtkLightCollection *lights);
00103
00105 void CreateLight(void);
00106
00110 virtual vtkLight *MakeLight();
00111
00113
00117 vtkGetMacro(TwoSidedLighting,int);
00118 vtkSetMacro(TwoSidedLighting,int);
00119 vtkBooleanMacro(TwoSidedLighting,int);
00121
00123
00133 vtkSetMacro(LightFollowCamera,int);
00134 vtkGetMacro(LightFollowCamera,int);
00135 vtkBooleanMacro(LightFollowCamera,int);
00137
00139
00145 vtkGetMacro(AutomaticLightCreation,int);
00146 vtkSetMacro(AutomaticLightCreation,int);
00147 vtkBooleanMacro(AutomaticLightCreation,int);
00149
00153 virtual int UpdateLightsGeometryToFollowCamera(void);
00154
00156 vtkVolumeCollection *GetVolumes();
00157
00159 vtkActorCollection *GetActors();
00160
00162 void SetActiveCamera(vtkCamera *);
00163
00167 vtkCamera *GetActiveCamera();
00168
00172 virtual vtkCamera *MakeCamera();
00173
00175
00179 vtkSetMacro(Erase, int);
00180 vtkGetMacro(Erase, int);
00181 vtkBooleanMacro(Erase, int);
00183
00185
00188 vtkSetMacro(Draw, int);
00189 vtkGetMacro(Draw, int);
00190 vtkBooleanMacro(Draw, int);
00192
00194 void AddCuller(vtkCuller *);
00195
00197 void RemoveCuller(vtkCuller *);
00198
00200 vtkCullerCollection *GetCullers();
00201
00203
00204 vtkSetVector3Macro(Ambient,double);
00205 vtkGetVectorMacro(Ambient,double,3);
00207
00209
00211 vtkSetMacro(AllocatedRenderTime,double);
00212 virtual double GetAllocatedRenderTime();
00214
00219 virtual double GetTimeFactor();
00220
00225 virtual void Render();
00226
00229 virtual void DeviceRender() =0;
00230
00235 virtual void DeviceRenderTranslucentPolygonalGeometry();
00236
00238 virtual void Clear() {};
00239
00241 int VisibleActorCount();
00242
00244 int VisibleVolumeCount();
00245
00248 void ComputeVisiblePropBounds( double bounds[6] );
00249
00251 double *ComputeVisiblePropBounds();
00252
00255 void ResetCameraClippingRange();
00256
00258
00260 void ResetCameraClippingRange( double bounds[6] );
00261 void ResetCameraClippingRange( double xmin, double xmax,
00262 double ymin, double ymax,
00263 double zmin, double zmax);
00265
00267
00271 vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99);
00272 vtkGetMacro(NearClippingPlaneTolerance,double);
00274
00280 void ResetCamera();
00281
00289 void ResetCamera(double bounds[6]);
00290
00292
00293 void ResetCamera(double xmin, double xmax, double ymin, double ymax,
00294 double zmin, double zmax);
00296
00298
00301 void SetRenderWindow(vtkRenderWindow *);
00302 vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;};
00303 virtual vtkWindow *GetVTKWindow();
00305
00307
00310 vtkSetMacro(BackingStore,int);
00311 vtkGetMacro(BackingStore,int);
00312 vtkBooleanMacro(BackingStore,int);
00314
00316
00319 vtkSetMacro(Interactive,int);
00320 vtkGetMacro(Interactive,int);
00321 vtkBooleanMacro(Interactive,int);
00323
00325
00327 vtkSetMacro(Layer, int);
00328 vtkGetMacro(Layer, int);
00330
00332
00334 vtkSetMacro(PreserveDepthBuffer, int);
00335 vtkGetMacro(PreserveDepthBuffer, int);
00336 vtkBooleanMacro(PreserveDepthBuffer, int);
00338
00341 int Transparent();
00342
00344 void WorldToView();
00345
00347
00348 void ViewToWorld();
00349 virtual void ViewToWorld(double &wx, double &wy, double &wz);
00351
00353 virtual void WorldToView(double &wx, double &wy, double &wz);
00354
00357 double GetZ (int x, int y);
00358
00360 unsigned long GetMTime();
00361
00363
00364 vtkGetMacro( LastRenderTimeInSeconds, double );
00366
00368
00372 vtkGetMacro( NumberOfPropsRendered, int );
00374
00376
00381 vtkAssemblyPath* PickProp(double selectionX, double selectionY)
00382 {
00383 return this->PickProp(selectionX, selectionY, selectionX, selectionY);
00384 }
00385 vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
00386 double selectionX2, double selectionY2);
00388
00392 virtual void StereoMidpoint() { return; };
00393
00398 double GetTiledAspectRatio();
00399
00401
00404 int IsActiveCameraCreated()
00405 { return (this->ActiveCamera != NULL); }
00407
00408
00410
00417 vtkSetMacro(UseDepthPeeling,int);
00418 vtkGetMacro(UseDepthPeeling,int);
00419 vtkBooleanMacro(UseDepthPeeling,int);
00421
00423
00430 vtkSetClampMacro(OcclusionRatio,double,0.0,0.5);
00431 vtkGetMacro(OcclusionRatio,double);
00433
00435
00438 vtkSetMacro(MaximumNumberOfPeels,int);
00439 vtkGetMacro(MaximumNumberOfPeels,int);
00441
00443
00445 vtkGetMacro(LastRenderingUsedDepthPeeling,int);
00447
00449
00453 void SetDelegate(vtkRendererDelegate *d);
00454 vtkGetObjectMacro(Delegate,vtkRendererDelegate);
00456
00458
00459 void SetPass(vtkRenderPass *p);
00460 vtkGetObjectMacro(Pass,vtkRenderPass);
00462
00464
00467 vtkGetObjectMacro(Selector, vtkHardwareSelector);
00469
00471
00473 void SetBackgroundTexture(vtkTexture*);
00474 vtkGetObjectMacro(BackgroundTexture, vtkTexture);
00476
00478
00480 vtkSetMacro(TexturedBackground,bool);
00481 vtkGetMacro(TexturedBackground,bool);
00482 vtkBooleanMacro(TexturedBackground,bool);
00484
00485
00486 protected:
00487 vtkRenderer();
00488 ~vtkRenderer();
00489
00490
00491 virtual void PickRender(vtkPropCollection *props);
00492 virtual void PickGeometry();
00493
00494 vtkCamera *ActiveCamera;
00495 vtkLight *CreatedLight;
00496
00497 vtkLightCollection *Lights;
00498 vtkCullerCollection *Cullers;
00499
00500 vtkActorCollection *Actors;
00501 vtkVolumeCollection *Volumes;
00502
00503 double Ambient[3];
00504 vtkRenderWindow *RenderWindow;
00505 double AllocatedRenderTime;
00506 double TimeFactor;
00507 int TwoSidedLighting;
00508 int AutomaticLightCreation;
00509 int BackingStore;
00510 unsigned char *BackingImage;
00511 int BackingStoreSize[2];
00512 vtkTimeStamp RenderTime;
00513
00514 double LastRenderTimeInSeconds;
00515
00516 int LightFollowCamera;
00517
00518
00519 void AllocateTime();
00520
00521
00522
00523 int NumberOfPropsRendered;
00524
00525
00526
00527 vtkProp **PropArray;
00528 int PropArrayCount;
00529
00530
00531 vtkAssemblyPath **PathArray;
00532 int PathArrayCount;
00533
00534
00535
00536 int Interactive;
00537
00538
00539
00540 int Layer;
00541 int PreserveDepthBuffer;
00542
00543
00544
00545 double ComputedVisiblePropBounds[6];
00546
00552 double NearClippingPlaneTolerance;
00553
00558 int Erase;
00559
00563 int Draw;
00564
00568 virtual int UpdateGeometry(void);
00569
00574 virtual int UpdateTranslucentPolygonalGeometry();
00575
00578 virtual int UpdateCamera(void);
00579
00583 virtual int UpdateLightGeometry(void);
00584
00587 virtual int UpdateLights(void) {return 0;}
00588
00591 vtkCamera *GetActiveCameraAndResetIfCreated();
00592
00596 int UseDepthPeeling;
00597
00605 double OcclusionRatio;
00606
00610 int MaximumNumberOfPeels;
00611
00614 int LastRenderingUsedDepthPeeling;
00615
00616 #if !defined(VTK_LEGACY_REMOVE)
00617
00618 friend class vtkVisibleCellSelector;
00619
00621
00624 enum {NOT_SELECTING = 0, COLOR_BY_PROCESSOR, COLOR_BY_ACTOR,
00625 COLOR_BY_CELL_ID_HIGH, COLOR_BY_CELL_ID_MID, COLOR_BY_CELL_ID_LOW,
00626 COLOR_BY_VERTEX};
00628
00629 vtkSetMacro(SelectMode, int);
00630 vtkSetMacro(SelectConst, unsigned int);
00631
00634 void SetIdentPainter(vtkIdentColoredPainter*);
00635
00637 virtual int UpdateGeometryForSelection(void);
00638
00640
00642 vtkPainter* SwapInSelectablePainter(vtkProp *,
00643 int &);
00645
00647
00649 void SwapOutSelectablePainter(vtkProp *,
00650 vtkPainter*,
00651 int );
00653
00655
00656 vtkProp **PropsSelectedFrom;
00657 int PropsSelectedFromCount;
00659
00660
00661 int SelectMode;
00662 unsigned int SelectConst;
00663 vtkIdentColoredPainter *IdentPainter;
00664
00665 #endif
00666
00667
00668 friend class vtkHardwareSelector;
00669
00671
00672 void SetSelector(vtkHardwareSelector* selector)
00673 { this->Selector = selector; this->Modified(); }
00675
00676
00677 vtkHardwareSelector* Selector;
00678
00679
00680 friend class vtkRendererDelegate;
00681 vtkRendererDelegate *Delegate;
00682
00683 friend class vtkRenderPass;
00684 vtkRenderPass *Pass;
00685
00686 bool TexturedBackground;
00687 vtkTexture* BackgroundTexture;
00688
00689 private:
00690 vtkRenderer(const vtkRenderer&);
00691 void operator=(const vtkRenderer&);
00692
00693 };
00694
00695 inline vtkLightCollection *vtkRenderer::GetLights() {
00696 return this->Lights;
00697 }
00698
00700 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;}
00701
00702
00703 #endif