VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkRenderer.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00040 #ifndef __vtkRenderer_h 00041 #define __vtkRenderer_h 00042 00043 #include "vtkViewport.h" 00044 00045 #include "vtkVolumeCollection.h" // Needed for access in inline members 00046 #include "vtkActorCollection.h" // Needed for access in inline members 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 00264 void ResetCameraClippingRange( double bounds[6] ); 00265 void ResetCameraClippingRange( double xmin, double xmax, 00266 double ymin, double ymax, 00267 double zmin, double zmax); 00269 00271 00275 vtkSetClampMacro(NearClippingPlaneTolerance,double,0,0.99); 00276 vtkGetMacro(NearClippingPlaneTolerance,double); 00278 00284 void ResetCamera(); 00285 00293 void ResetCamera(double bounds[6]); 00294 00296 00297 void ResetCamera(double xmin, double xmax, double ymin, double ymax, 00298 double zmin, double zmax); 00300 00302 00305 void SetRenderWindow(vtkRenderWindow *); 00306 vtkRenderWindow *GetRenderWindow() {return this->RenderWindow;}; 00307 virtual vtkWindow *GetVTKWindow(); 00309 00311 00314 vtkSetMacro(BackingStore,int); 00315 vtkGetMacro(BackingStore,int); 00316 vtkBooleanMacro(BackingStore,int); 00318 00320 00323 vtkSetMacro(Interactive,int); 00324 vtkGetMacro(Interactive,int); 00325 vtkBooleanMacro(Interactive,int); 00327 00329 00331 vtkSetMacro(Layer, int); 00332 vtkGetMacro(Layer, int); 00334 00336 00338 vtkSetMacro(PreserveDepthBuffer, int); 00339 vtkGetMacro(PreserveDepthBuffer, int); 00340 vtkBooleanMacro(PreserveDepthBuffer, int); 00342 00345 int Transparent(); 00346 00348 void WorldToView(); 00349 00351 00352 void ViewToWorld(); 00353 virtual void ViewToWorld(double &wx, double &wy, double &wz); 00355 00357 virtual void WorldToView(double &wx, double &wy, double &wz); 00358 00361 double GetZ (int x, int y); 00362 00364 unsigned long GetMTime(); 00365 00367 00368 vtkGetMacro( LastRenderTimeInSeconds, double ); 00370 00372 00376 vtkGetMacro( NumberOfPropsRendered, int ); 00378 00380 00385 vtkAssemblyPath* PickProp(double selectionX, double selectionY) 00386 { 00387 return this->PickProp(selectionX, selectionY, selectionX, selectionY); 00388 } 00389 vtkAssemblyPath* PickProp(double selectionX1, double selectionY1, 00390 double selectionX2, double selectionY2); 00392 00396 virtual void StereoMidpoint() { return; }; 00397 00402 double GetTiledAspectRatio(); 00403 00405 00408 int IsActiveCameraCreated() 00409 { return (this->ActiveCamera != NULL); } 00411 00412 00414 00421 vtkSetMacro(UseDepthPeeling,int); 00422 vtkGetMacro(UseDepthPeeling,int); 00423 vtkBooleanMacro(UseDepthPeeling,int); 00425 00427 00434 vtkSetClampMacro(OcclusionRatio,double,0.0,0.5); 00435 vtkGetMacro(OcclusionRatio,double); 00437 00439 00442 vtkSetMacro(MaximumNumberOfPeels,int); 00443 vtkGetMacro(MaximumNumberOfPeels,int); 00445 00447 00449 vtkGetMacro(LastRenderingUsedDepthPeeling,int); 00451 00453 00457 void SetDelegate(vtkRendererDelegate *d); 00458 vtkGetObjectMacro(Delegate,vtkRendererDelegate); 00460 00462 00463 void SetPass(vtkRenderPass *p); 00464 vtkGetObjectMacro(Pass,vtkRenderPass); 00466 00468 00471 vtkGetObjectMacro(Selector, vtkHardwareSelector); 00473 00475 00477 void SetBackgroundTexture(vtkTexture*); 00478 vtkGetObjectMacro(BackgroundTexture, vtkTexture); 00480 00482 00484 vtkSetMacro(TexturedBackground,bool); 00485 vtkGetMacro(TexturedBackground,bool); 00486 vtkBooleanMacro(TexturedBackground,bool); 00488 00489 //BTX 00490 protected: 00491 vtkRenderer(); 00492 ~vtkRenderer(); 00493 00494 // internal method for doing a render for picking purposes 00495 virtual void PickRender(vtkPropCollection *props); 00496 virtual void PickGeometry(); 00497 00498 // internal method to expand bounding box to consider model transform 00499 // matrix or model view transform matrix based on whether or not deering 00500 // frustum is used. 00501 virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix); 00502 00503 vtkCamera *ActiveCamera; 00504 vtkLight *CreatedLight; 00505 00506 vtkLightCollection *Lights; 00507 vtkCullerCollection *Cullers; 00508 00509 vtkActorCollection *Actors; 00510 vtkVolumeCollection *Volumes; 00511 00512 double Ambient[3]; 00513 vtkRenderWindow *RenderWindow; 00514 double AllocatedRenderTime; 00515 double TimeFactor; 00516 int TwoSidedLighting; 00517 int AutomaticLightCreation; 00518 int BackingStore; 00519 unsigned char *BackingImage; 00520 int BackingStoreSize[2]; 00521 vtkTimeStamp RenderTime; 00522 00523 double LastRenderTimeInSeconds; 00524 00525 int LightFollowCamera; 00526 00527 // Allocate the time for each prop 00528 void AllocateTime(); 00529 00530 // Internal variables indicating the number of props 00531 // that have been or will be rendered in each category. 00532 int NumberOfPropsRendered; 00533 00534 // A temporary list of props used for culling, and traversal 00535 // of all props when rendering 00536 vtkProp **PropArray; 00537 int PropArrayCount; 00538 00539 // A temporary list used for picking 00540 vtkAssemblyPath **PathArray; 00541 int PathArrayCount; 00542 00543 // Indicates if the renderer should receive events from an interactor. 00544 // Typically only used in conjunction with transparent renderers. 00545 int Interactive; 00546 00547 // Shows what layer this renderer belongs to. Only of interested when 00548 // there are layered renderers. 00549 int Layer; 00550 int PreserveDepthBuffer; 00551 00552 // Holds the result of ComputeVisiblePropBounds so that it is visible from 00553 // wrapped languages 00554 double ComputedVisiblePropBounds[6]; 00555 00561 double NearClippingPlaneTolerance; 00562 00567 int Erase; 00568 00572 int Draw; 00573 00577 virtual int UpdateGeometry(void); 00578 00583 virtual int UpdateTranslucentPolygonalGeometry(); 00584 00587 virtual int UpdateCamera(void); 00588 00592 virtual int UpdateLightGeometry(void); 00593 00596 virtual int UpdateLights(void) {return 0;} 00597 00600 vtkCamera *GetActiveCameraAndResetIfCreated(); 00601 00605 int UseDepthPeeling; 00606 00614 double OcclusionRatio; 00615 00619 int MaximumNumberOfPeels; 00620 00623 int LastRenderingUsedDepthPeeling; 00624 00625 #if !defined(VTK_LEGACY_REMOVE) 00626 // VISIBLE CELL SELECTION ---------------------------------------- 00627 friend class vtkVisibleCellSelector; 00628 00630 00633 enum {NOT_SELECTING = 0, COLOR_BY_PROCESSOR, COLOR_BY_ACTOR, 00634 COLOR_BY_CELL_ID_HIGH, COLOR_BY_CELL_ID_MID, COLOR_BY_CELL_ID_LOW, 00635 COLOR_BY_VERTEX}; 00637 00638 vtkSetMacro(SelectMode, int); 00639 vtkSetMacro(SelectConst, unsigned int); 00640 00643 void SetIdentPainter(vtkIdentColoredPainter*); 00644 00646 virtual int UpdateGeometryForSelection(void); 00647 00649 00651 vtkPainter* SwapInSelectablePainter(vtkProp *, 00652 int &); 00654 00656 00658 void SwapOutSelectablePainter(vtkProp *, 00659 vtkPainter*, 00660 int ); 00662 00664 00665 vtkProp **PropsSelectedFrom; 00666 int PropsSelectedFromCount; 00668 00669 // Ivars for visible cell selecting 00670 int SelectMode; 00671 unsigned int SelectConst; 00672 vtkIdentColoredPainter *IdentPainter; 00673 // End Ivars for visible cell selecting. 00674 #endif 00675 00676 // HARDWARE SELECTION ---------------------------------------- 00677 friend class vtkHardwareSelector; 00678 00680 00681 void SetSelector(vtkHardwareSelector* selector) 00682 { this->Selector = selector; this->Modified(); } 00684 00685 // End Ivars for visible cell selecting. 00686 vtkHardwareSelector* Selector; 00687 00688 //--------------------------------------------------------------- 00689 friend class vtkRendererDelegate; 00690 vtkRendererDelegate *Delegate; 00691 00692 friend class vtkRenderPass; 00693 vtkRenderPass *Pass; 00694 00695 bool TexturedBackground; 00696 vtkTexture* BackgroundTexture; 00697 00698 private: 00699 vtkRenderer(const vtkRenderer&); // Not implemented. 00700 void operator=(const vtkRenderer&); // Not implemented. 00701 //ETX 00702 }; 00703 00704 inline vtkLightCollection *vtkRenderer::GetLights() { 00705 return this->Lights; 00706 } 00707 00709 inline vtkCullerCollection *vtkRenderer::GetCullers(){return this->Cullers;} 00710 00711 00712 #endif